From 7daa462ef81618685846a52e715087bcf661b7f3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 3 Sep 2023 21:46:36 +0200 Subject: [PATCH] LibWeb: Remove BrowsingContext::create_a_new_top_level_browsing_context This call has been replaced by `create_a_new_top_level_browsing_context_and_document` after specification was refactored to use navigables. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 4 ++-- Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp | 12 +----------- Userland/Libraries/LibWeb/HTML/BrowsingContext.h | 1 - .../Libraries/LibWeb/HTML/TraversableNavigable.cpp | 7 +------ .../Libraries/LibWeb/HTML/TraversableNavigable.h | 6 ++++++ 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 1358644215..86c597749b 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -126,9 +126,9 @@ static JS::NonnullGCPtr obtain_a_browsing_context_to_use_ return browsing_context; } - // 3. Let newBrowsingContext be the result of creating a new top-level browsing context. + // 3. Let newBrowsingContext be the first return value of creating a new top-level browsing context and document VERIFY(browsing_context.page()); - auto new_browsing_context = HTML::BrowsingContext::create_a_new_top_level_browsing_context(*browsing_context.page()); + auto new_browsing_context = HTML::create_a_new_top_level_browsing_context_and_document(*browsing_context.page()).release_value_but_fixme_should_propagate_errors().browsing_context; // FIXME: 4. If navigationCOOP's value is "same-origin-plurs-COEP", then set newBrowsingContext's group's // cross-origin isolation mode to either "logical" or "concrete". The choice of which is implementation-defined. diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp index 86c51d9107..d9d4f45869 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp @@ -105,16 +105,6 @@ HTML::Origin determine_the_origin(AK::URL const& url, SandboxingFlagSet sandbox_ return URL::url_origin(url); } -// https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-top-level-browsing-context -JS::NonnullGCPtr BrowsingContext::create_a_new_top_level_browsing_context(Web::Page& page) -{ - // 1. Let group be the result of creating a new browsing context group. - auto group = BrowsingContextGroup::create_a_new_browsing_context_group(page); - - // 2. Return group's browsing context set[0]. - return *group->browsing_context_set().begin(); -} - // https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context JS::NonnullGCPtr BrowsingContext::create_a_new_browsing_context(Page& page, JS::GCPtr creator, JS::GCPtr embedder, BrowsingContextGroup&) { @@ -859,7 +849,7 @@ BrowsingContext::ChosenBrowsingContext BrowsingContext::choose_a_browsing_contex else { // 1. Set chosen to the result of creating a new auxiliary browsing context with current. // FIXME: We have no concept of auxiliary browsing context - chosen = HTML::BrowsingContext::create_a_new_top_level_browsing_context(*m_page); + chosen = HTML::create_a_new_top_level_browsing_context_and_document(*m_page).release_value_but_fixme_should_propagate_errors().browsing_context; // 2. If sandboxingFlagSet's sandboxed navigation browsing context flag is set, then current must be // set as chosen's one permitted sandboxed navigator. diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h index d97ab0bbcd..e09220e4f1 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h @@ -39,7 +39,6 @@ class BrowsingContext final public: static JS::NonnullGCPtr create_a_new_browsing_context(Page&, JS::GCPtr creator, JS::GCPtr embedder, BrowsingContextGroup&); - static JS::NonnullGCPtr create_a_new_top_level_browsing_context(Page&); struct BrowsingContextAndDocument { JS::NonnullGCPtr browsing_context; diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 6eb34026c6..3e0905e2e3 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -36,13 +36,8 @@ static OrderedHashTable& user_agent_top_level_traversable return set; } -struct BrowsingContextAndDocument { - JS::NonnullGCPtr browsing_context; - JS::NonnullGCPtr document; -}; - // https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-top-level-browsing-context -static WebIDL::ExceptionOr create_a_new_top_level_browsing_context_and_document(Page& page) +WebIDL::ExceptionOr create_a_new_top_level_browsing_context_and_document(Page& page) { // 1. Let group and document be the result of creating a new browsing context group and document. auto [group, document] = TRY(BrowsingContextGroup::create_a_new_browsing_context_group_and_document(page)); diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h index 8ddf98c11b..72c6bb139b 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.h @@ -84,6 +84,12 @@ private: WeakPtr m_page; }; +struct BrowsingContextAndDocument { + JS::NonnullGCPtr browsing_context; + JS::NonnullGCPtr document; +}; + +WebIDL::ExceptionOr create_a_new_top_level_browsing_context_and_document(Page& page); void finalize_a_same_document_navigation(JS::NonnullGCPtr traversable, JS::NonnullGCPtr target_navigable, JS::NonnullGCPtr target_entry, JS::GCPtr entry_to_replace); }