summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2022-12-17 14:26:48 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-26 15:51:50 +0200
commit3c89286467d50234763712b3870350d3480d93df (patch)
treeca0d1839a965b857cf38414f8b211bfdf9ee6a72 /Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp
parent9a19bdbfcfe2d7ff8eedde93d0ba01927d7a89df (diff)
downloadserenity-3c89286467d50234763712b3870350d3480d93df.zip
LibWeb: Implement creation of fresh top-level traversables
Co-authored-by: Andreas Kling <kling@serenityos.org>
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp
index c8f81ff651..754f3f3ad0 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.cpp
@@ -35,6 +35,23 @@ void BrowsingContextGroup::visit_edges(Cell::Visitor& visitor)
visitor.visit(context);
}
+// https://html.spec.whatwg.org/multipage/document-sequences.html#creating-a-new-browsing-context-group-and-document
+auto BrowsingContextGroup::create_a_new_browsing_context_group_and_document(Page& page) -> WebIDL::ExceptionOr<BrowsingContextGroupAndDocument>
+{
+ // 1. Let group be a new browsing context group.
+ // 2. Append group to the user agent's browsing context group set.
+ auto group = Bindings::main_thread_vm().heap().allocate_without_realm<BrowsingContextGroup>(page);
+
+ // 3. Let browsingContext and document be the result of creating a new browsing context and document with null, null, and group.
+ auto [browsing_context, document] = TRY(BrowsingContext::create_a_new_browsing_context_and_document(page, nullptr, nullptr, group));
+
+ // 4. Append browsingContext to group.
+ group->append(browsing_context);
+
+ // 5. Return group and document.
+ return BrowsingContextGroupAndDocument { group, document };
+}
+
// https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context-group
JS::NonnullGCPtr<BrowsingContextGroup> BrowsingContextGroup::create_a_new_browsing_context_group(Web::Page& page)
{