mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:27:34 +00:00
WebContent+Everywhere: Add an option to not activate new tabs over IPC
WebDriver, for example, will want to create new tabs without activating them.
This commit is contained in:
parent
78ed798852
commit
e6fc35897f
21 changed files with 81 additions and 62 deletions
|
@ -102,7 +102,7 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
|
|||
};
|
||||
|
||||
m_window_actions.on_create_new_tab = [this] {
|
||||
create_new_tab(Browser::url_from_user_input(Browser::g_new_tab_url), true);
|
||||
create_new_tab(Browser::url_from_user_input(Browser::g_new_tab_url), Web::HTML::ActivateTab::Yes);
|
||||
};
|
||||
|
||||
m_window_actions.on_create_new_window = [this] {
|
||||
|
@ -148,7 +148,7 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
|
|||
|
||||
build_menus();
|
||||
|
||||
create_new_tab(move(url), true);
|
||||
create_new_tab(move(url), Web::HTML::ActivateTab::Yes);
|
||||
}
|
||||
|
||||
void BrowserWindow::build_menus()
|
||||
|
@ -570,7 +570,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab)
|
|||
set_title(DeprecatedString::formatted("{} - Browser", title.is_empty() ? url.to_deprecated_string() : title));
|
||||
}
|
||||
|
||||
Tab& BrowserWindow::create_new_tab(URL url, bool activate)
|
||||
Tab& BrowserWindow::create_new_tab(URL url, Web::HTML::ActivateTab activate)
|
||||
{
|
||||
auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab"_short_string, *this);
|
||||
|
||||
|
@ -587,7 +587,7 @@ Tab& BrowserWindow::create_new_tab(URL url, bool activate)
|
|||
};
|
||||
|
||||
new_tab.on_tab_open_request = [this](auto& url) {
|
||||
create_new_tab(url, true);
|
||||
create_new_tab(url, Web::HTML::ActivateTab::Yes);
|
||||
};
|
||||
|
||||
new_tab.on_tab_close_request = [this](auto& tab) {
|
||||
|
@ -655,7 +655,7 @@ Tab& BrowserWindow::create_new_tab(URL url, bool activate)
|
|||
|
||||
dbgln_if(SPAM_DEBUG, "Added new tab {:p}, loading {}", &new_tab, url);
|
||||
|
||||
if (activate)
|
||||
if (activate == Web::HTML::ActivateTab::Yes)
|
||||
m_tab_widget->set_active_widget(&new_tab);
|
||||
|
||||
return new_tab;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <LibConfig/Listener.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
|
@ -28,7 +29,7 @@ public:
|
|||
|
||||
GUI::TabWidget& tab_widget();
|
||||
Tab& active_tab();
|
||||
Tab& create_new_tab(URL, bool activate);
|
||||
Tab& create_new_tab(URL, Web::HTML::ActivateTab activate);
|
||||
void create_new_window(URL);
|
||||
|
||||
GUI::Action& go_back_action() { return *m_go_back_action; }
|
||||
|
|
|
@ -468,8 +468,8 @@ Tab::Tab(BrowserWindow& window)
|
|||
go_forward();
|
||||
};
|
||||
|
||||
view().on_new_tab = [this] {
|
||||
auto& tab = this->window().create_new_tab(URL("about:blank"), true);
|
||||
view().on_new_tab = [this](auto activate_tab) {
|
||||
auto& tab = this->window().create_new_tab(URL("about:blank"), activate_tab);
|
||||
return tab.view().handle();
|
||||
};
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
};
|
||||
|
||||
for (size_t i = 1; i < specified_urls.size(); ++i)
|
||||
window->create_new_tab(url_from_argument_string(specified_urls[i]), false);
|
||||
window->create_new_tab(url_from_argument_string(specified_urls[i]), Web::HTML::ActivateTab::No);
|
||||
|
||||
window->show();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue