mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +00:00
Ladybird: Open target _blank links in new tab
This commit is contained in:
parent
05a2d1f0e0
commit
14c9ef2563
3 changed files with 26 additions and 9 deletions
|
@ -369,6 +369,25 @@ Tab& BrowserWindow::new_tab(QString const& url, Web::HTML::ActivateTab activate_
|
||||||
return tab.view().handle();
|
return tab.view().handle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tab_ptr->view().on_tab_open_request = [this](auto url, auto activate_tab) {
|
||||||
|
auto& tab = new_tab(qstring_from_ak_deprecated_string(url.to_deprecated_string()), activate_tab);
|
||||||
|
return tab.view().handle();
|
||||||
|
};
|
||||||
|
|
||||||
|
tab_ptr->view().on_link_click = [this](auto url, auto target, unsigned modifiers) {
|
||||||
|
// TODO: maybe activate tabs according to some configuration, this is just normal current browser behavior
|
||||||
|
if (modifiers == Mod_Ctrl) {
|
||||||
|
m_current_tab->view().on_tab_open_request(url, Web::HTML::ActivateTab::No);
|
||||||
|
} else if (target == "_blank") {
|
||||||
|
m_current_tab->view().on_tab_open_request(url, Web::HTML::ActivateTab::Yes);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tab_ptr->view().on_link_middle_click = [this](auto url, auto target, unsigned modifiers) {
|
||||||
|
m_current_tab->view().on_link_click(url, target, Mod_Ctrl);
|
||||||
|
(void)modifiers;
|
||||||
|
};
|
||||||
|
|
||||||
tab_ptr->view().on_get_all_cookies = [this](auto const& url) {
|
tab_ptr->view().on_get_all_cookies = [this](auto const& url) {
|
||||||
return m_cookie_jar.get_all_cookies(url);
|
return m_cookie_jar.get_all_cookies(url);
|
||||||
};
|
};
|
||||||
|
|
|
@ -778,19 +778,16 @@ void WebContentView::notify_server_did_unhover_link(Badge<WebContentClient>)
|
||||||
|
|
||||||
void WebContentView::notify_server_did_click_link(Badge<WebContentClient>, AK::URL const& url, DeprecatedString const& target, unsigned int modifiers)
|
void WebContentView::notify_server_did_click_link(Badge<WebContentClient>, AK::URL const& url, DeprecatedString const& target, unsigned int modifiers)
|
||||||
{
|
{
|
||||||
// FIXME
|
if (on_link_click) {
|
||||||
(void)url;
|
on_link_click(url, target, modifiers);
|
||||||
(void)target;
|
}
|
||||||
(void)modifiers;
|
|
||||||
// if (on_link_click)
|
|
||||||
// on_link_click(url, target, modifiers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentView::notify_server_did_middle_click_link(Badge<WebContentClient>, AK::URL const& url, DeprecatedString const& target, unsigned int modifiers)
|
void WebContentView::notify_server_did_middle_click_link(Badge<WebContentClient>, AK::URL const& url, DeprecatedString const& target, unsigned int modifiers)
|
||||||
{
|
{
|
||||||
(void)url;
|
if (on_link_middle_click) {
|
||||||
(void)target;
|
on_link_middle_click(url, target, modifiers);
|
||||||
(void)modifiers;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContentView::notify_server_did_start_loading(Badge<WebContentClient>, AK::URL const& url, bool is_redirect)
|
void WebContentView::notify_server_did_start_loading(Badge<WebContentClient>, AK::URL const& url, bool is_redirect)
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
virtual ~WebContentView() override;
|
virtual ~WebContentView() override;
|
||||||
|
|
||||||
Function<String(Web::HTML::ActivateTab)> on_new_tab;
|
Function<String(Web::HTML::ActivateTab)> on_new_tab;
|
||||||
|
Function<String(const AK::URL&, Web::HTML::ActivateTab)> on_tab_open_request;
|
||||||
Function<void()> on_close;
|
Function<void()> on_close;
|
||||||
Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
|
Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
|
||||||
Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click;
|
Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue