mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
LibWeb: Make the link context menu hook include the destination URL
This commit is contained in:
parent
02c5e22f06
commit
fd65a24834
Notes:
sideshowbarker
2024-07-19 05:06:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fd65a248349
6 changed files with 13 additions and 13 deletions
|
@ -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<DownloadWidget>(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);
|
||||
};
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ private:
|
|||
RefPtr<GUI::ToolBarContainer> m_toolbar_container;
|
||||
|
||||
RefPtr<GUI::Menu> m_link_context_menu;
|
||||
String m_link_context_menu_href;
|
||||
URL m_link_context_menu_url;
|
||||
|
||||
RefPtr<GUI::Menu> m_tab_context_menu;
|
||||
RefPtr<GUI::Menu> m_page_context_menu;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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&) { }
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
Function<void(const Gfx::IntPoint& screen_position)> on_context_menu_request;
|
||||
Function<void(const URL&, const String& target, unsigned modifiers)> on_link_click;
|
||||
Function<void(const String& href, const Gfx::IntPoint& screen_position)> on_link_context_menu_request;
|
||||
Function<void(const URL&, const Gfx::IntPoint& screen_position)> on_link_context_menu_request;
|
||||
Function<void(const URL&)> on_link_middle_click;
|
||||
Function<void(const URL&)> on_link_hover;
|
||||
Function<void(const String&)> 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;
|
||||
|
|
Loading…
Reference in a new issue