diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 32e8d55b307..146dc230b39 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -58,11 +58,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -2514,4 +2516,22 @@ WebIDL::ExceptionOr> Document::create_attribute_ns(Deprec return Attr::create(*this, extracted_qualified_name); } +// https://html.spec.whatwg.org/multipage/browsing-the-web.html#make-active +void Document::make_active() +{ + // 1. Let window be document's relevant global object. + auto& window = verify_cast(HTML::relevant_global_object(*this)); + + // 2. Set document's browsing context's WindowProxy's [[Window]] internal slot value to window. + m_browsing_context->window_proxy()->set_window(window); + + // 3. Set document's visibility state to document's node navigable's traversable navigable's system visibility state. + if (navigable()) { + m_visibility_state = navigable()->traversable_navigable()->system_visibility_state(); + } + + // 4. Set window's relevant settings object's execution ready flag. + HTML::relevant_settings_object(window).execution_ready = true; +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index deebe65e26e..08dda4e7bc4 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -468,6 +468,8 @@ public: DeprecatedString dump_accessibility_tree_as_json(); + void make_active(); + protected: virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; diff --git a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp index ea854f17905..fdcf39d01a1 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -256,9 +256,9 @@ void WindowProxy::visit_edges(JS::Cell::Visitor& visitor) visitor.visit(m_window.ptr()); } -void WindowProxy::set_window(Badge, JS::NonnullGCPtr window) +void WindowProxy::set_window(JS::NonnullGCPtr window) { - m_window = window; + m_window = move(window); } JS::NonnullGCPtr WindowProxy::associated_browsing_context() const diff --git a/Userland/Libraries/LibWeb/HTML/WindowProxy.h b/Userland/Libraries/LibWeb/HTML/WindowProxy.h index 7cccafb354b..5c32c7b63eb 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowProxy.h +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.h @@ -32,7 +32,7 @@ public: virtual JS::ThrowCompletionOr> internal_own_property_keys() const override; JS::GCPtr window() const { return m_window; } - void set_window(Badge, JS::NonnullGCPtr); + void set_window(JS::NonnullGCPtr); JS::NonnullGCPtr associated_browsing_context() const;