diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index 8093e6942e4..9045588f6f8 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -164,19 +164,19 @@ Tab::Tab() m_link_context_menu = GUI::Menu::construct(); m_link_context_menu->add_action(GUI::Action::create("Open", [this](auto&) { - m_page_view->on_link_click(m_link_context_menu_href, "", 0); + m_page_view->on_link_click(m_link_context_menu_url, "", 0); })); m_link_context_menu->add_action(GUI::Action::create("Open in new tab", [this](auto&) { - m_page_view->on_link_click(m_link_context_menu_href, "_blank", 0); + m_page_view->on_link_click(m_link_context_menu_url, "_blank", 0); })); m_link_context_menu->add_action(GUI::Action::create("Copy link", [this](auto&) { - GUI::Clipboard::the().set_data(m_page_view->document()->complete_url(m_link_context_menu_href).to_string()); + GUI::Clipboard::the().set_data(m_link_context_menu_url.to_string()); })); m_link_context_menu->add_separator(); m_link_context_menu->add_action(GUI::Action::create("Download", [this](auto&) { auto window = GUI::Window::construct(); window->set_rect(300, 300, 300, 150); - auto url = m_page_view->document()->complete_url(m_link_context_menu_href); + auto url = m_link_context_menu_url; window->set_title(String::format("0%% of %s", url.basename().characters())); window->set_resizable(false); window->set_main_widget(url); @@ -184,8 +184,8 @@ Tab::Tab() (void)window.leak_ref(); })); - m_page_view->on_link_context_menu_request = [this](auto& href, auto& screen_position) { - m_link_context_menu_href = href; + m_page_view->on_link_context_menu_request = [this](auto& url, auto& screen_position) { + m_link_context_menu_url = url; m_link_context_menu->popup(screen_position); }; diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index ecf93386194..ddf285675a1 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -73,7 +73,7 @@ private: RefPtr m_toolbar_container; RefPtr m_link_context_menu; - String m_link_context_menu_href; + URL m_link_context_menu_url; RefPtr m_tab_context_menu; RefPtr m_page_context_menu; diff --git a/Libraries/LibWeb/Frame/EventHandler.cpp b/Libraries/LibWeb/Frame/EventHandler.cpp index 97bdfb327c5..c24636bad79 100644 --- a/Libraries/LibWeb/Frame/EventHandler.cpp +++ b/Libraries/LibWeb/Frame/EventHandler.cpp @@ -145,7 +145,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt } } } else if (button == GUI::MouseButton::Right) { - page_client.page_did_request_link_context_menu(m_frame.to_main_frame_position(position), link->href(), link->target(), modifiers); + page_client.page_did_request_link_context_menu(m_frame.to_main_frame_position(position), url, link->target(), modifiers); } else if (button == GUI::MouseButton::Middle) { page_client.page_did_middle_click_link(url, link->target(), modifiers); } diff --git a/Libraries/LibWeb/Page.h b/Libraries/LibWeb/Page.h index d33d2b5cdcc..5ac8af8c44d 100644 --- a/Libraries/LibWeb/Page.h +++ b/Libraries/LibWeb/Page.h @@ -75,7 +75,7 @@ public: virtual void page_did_change_selection() { } virtual void page_did_request_cursor_change(GUI::StandardCursor) { } virtual void page_did_request_context_menu(const Gfx::IntPoint&) { } - virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, [[maybe_unused]] const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } + virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } virtual void page_did_click_link(const URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } virtual void page_did_middle_click_link(const URL&, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { } virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) { } diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index b55b185a188..b53f8169519 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -201,10 +201,10 @@ void PageView::page_did_request_context_menu(const Gfx::IntPoint& content_positi on_context_menu_request(screen_relative_rect().location().translated(to_widget_position(content_position))); } -void PageView::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const String& href, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) +void PageView::page_did_request_link_context_menu(const Gfx::IntPoint& content_position, const URL& url, [[maybe_unused]] const String& target, [[maybe_unused]] unsigned modifiers) { if (on_link_context_menu_request) - on_link_context_menu_request(href, screen_relative_rect().location().translated(to_widget_position(content_position))); + on_link_context_menu_request(url, screen_relative_rect().location().translated(to_widget_position(content_position))); } void PageView::page_did_click_link(const URL& url, const String& target, unsigned modifiers) diff --git a/Libraries/LibWeb/PageView.h b/Libraries/LibWeb/PageView.h index c44814059f5..83af62053e1 100644 --- a/Libraries/LibWeb/PageView.h +++ b/Libraries/LibWeb/PageView.h @@ -61,7 +61,7 @@ public: Function on_context_menu_request; Function on_link_click; - Function on_link_context_menu_request; + Function on_link_context_menu_request; Function on_link_middle_click; Function on_link_hover; Function on_title_change; @@ -102,7 +102,7 @@ private: virtual void page_did_change_selection() override; virtual void page_did_request_cursor_change(GUI::StandardCursor) override; virtual void page_did_request_context_menu(const Gfx::IntPoint&) override; - virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const String& href, const String& target, unsigned modifiers) override; + virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override; virtual void page_did_click_link(const URL&, const String& target, unsigned modifiers) override; virtual void page_did_middle_click_link(const URL&, const String& target, unsigned modifiers) override; virtual void page_did_enter_tooltip_area(const Gfx::IntPoint&, const String&) override;