summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-06 19:41:10 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-06 19:41:10 +0200
commit02c5e22f06dbe198fdc51eef488929518856d5c8 (patch)
tree92bdcc549552f2ee835b6bc5c41d5b23d7207569 /Applications
parent1037a24076ed1ee984c979f2d0afae51e9049669 (diff)
downloadserenity-02c5e22f06dbe198fdc51eef488929518856d5c8.zip
LibWeb: Make the link click hooks include the destination URL
We have all the context needed for relative URL resolution inside the engine, so let's not make embedders worry about this.
Diffstat (limited to 'Applications')
-rw-r--r--Applications/Browser/Tab.cpp4
-rw-r--r--Applications/Help/main.cpp5
2 files changed, 3 insertions, 6 deletions
diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp
index c475cd993e..8093e6942e 100644
--- a/Applications/Browser/Tab.cpp
+++ b/Applications/Browser/Tab.cpp
@@ -154,12 +154,10 @@ Tab::Tab()
update_bookmark_button(url.to_string());
};
- m_page_view->on_link_click = [this](auto& href, auto& target, unsigned modifiers) {
+ m_page_view->on_link_click = [this](auto& url, auto& target, unsigned modifiers) {
if (target == "_blank" || modifiers == Mod_Ctrl) {
- auto url = m_page_view->document()->complete_url(href);
on_tab_open_request(url);
} else {
- auto url = m_page_view->document()->complete_url(href);
m_page_view->load(url);
}
};
diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp
index e1449a9579..9a2a7a1cb4 100644
--- a/Applications/Help/main.cpp
+++ b/Applications/Help/main.cpp
@@ -151,10 +151,9 @@ int main(int argc, char* argv[])
open_page(path);
};
- page_view.on_link_click = [&](const String& href, auto&, unsigned) {
+ page_view.on_link_click = [&](auto& url, auto&, unsigned) {
char* current_path = strdup(history.current().characters());
- char* dir_path = dirname(current_path);
- char* path = realpath(String::format("%s/%s", dir_path, href.characters()).characters(), nullptr);
+ char* path = realpath(url.path().characters(), nullptr);
free(current_path);
auto tree_view_index = model->index_from_path(path);
if (tree_view_index.has_value()) {