1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:37:46 +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:
Timothy Flynn 2023-03-20 18:39:20 -04:00 committed by Linus Groh
parent 78ed798852
commit e6fc35897f
21 changed files with 81 additions and 62 deletions

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Web::HTML {
enum class ActivateTab {
Yes,
No,
};
}

View file

@ -615,7 +615,7 @@ JS::GCPtr<DOM::Node> BrowsingContext::currently_focused_area()
}
// https://html.spec.whatwg.org/#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name
BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_context(StringView name, bool no_opener)
BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_context(StringView name, bool no_opener, ActivateTab activate_tab)
{
// The rules for choosing a browsing context, given a browsing context name name, a browsing context current, and
// a boolean noopener are as follows:
@ -699,7 +699,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex
// 3. If noopener is true, then set chosen to the result of creating a new top-level browsing context.
if (no_opener) {
auto handle = m_page->client().page_did_request_new_tab();
auto handle = m_page->client().page_did_request_new_tab(activate_tab);
chosen = RemoteBrowsingContext::create_a_new_remote_browsing_context(handle);
}

View file

@ -17,6 +17,7 @@
#include <LibJS/Heap/Cell.h>
#include <LibWeb/DOM/Position.h>
#include <LibWeb/HTML/AbstractBrowsingContext.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWeb/HTML/BrowsingContextContainer.h>
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
#include <LibWeb/HTML/Origin.h>
@ -171,7 +172,7 @@ public:
WindowType window_type;
};
ChosenBrowsingContext choose_a_browsing_context(StringView name, bool no_opener);
ChosenBrowsingContext choose_a_browsing_context(StringView name, bool no_opener, ActivateTab = ActivateTab::Yes);
size_t document_tree_child_browsing_context_count() const;