diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-04-23 19:39:12 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-24 07:57:15 +0200 |
commit | 3225c391918ed871d031b760a9372d62d130940b (patch) | |
tree | f198ff7fcde5b3b9fb8275d932a2e4f3187349d1 | |
parent | 32e2207b553fb1682d21dda1690766f8e93b75fb (diff) | |
download | serenity-3225c391918ed871d031b760a9372d62d130940b.zip |
LibWeb: Implement Document::make_active()
Implementation of "make active" algorithm from the spec for Document.
Co-authored-by: Andreas Kling <kling@serenityos.org>
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/WindowProxy.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/WindowProxy.h | 2 |
4 files changed, 25 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 32e8d55b30..146dc230b3 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -58,11 +58,13 @@ #include <LibWeb/HTML/HTMLTitleElement.h> #include <LibWeb/HTML/Location.h> #include <LibWeb/HTML/MessageEvent.h> +#include <LibWeb/HTML/Navigable.h> #include <LibWeb/HTML/NavigationParams.h> #include <LibWeb/HTML/Origin.h> #include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/HTML/Scripting/ExceptionReporter.h> #include <LibWeb/HTML/Scripting/WindowEnvironmentSettingsObject.h> +#include <LibWeb/HTML/TraversableNavigable.h> #include <LibWeb/HTML/Window.h> #include <LibWeb/HTML/WindowProxy.h> #include <LibWeb/HighResolutionTime/TimeOrigin.h> @@ -2514,4 +2516,22 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Attr>> 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::Window>(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 deebe65e26..08dda4e7bc 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<void> 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 ea854f1790..fdcf39d01a 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<BrowsingContext>, JS::NonnullGCPtr<Window> window) +void WindowProxy::set_window(JS::NonnullGCPtr<Window> window) { - m_window = window; + m_window = move(window); } JS::NonnullGCPtr<BrowsingContext> WindowProxy::associated_browsing_context() const diff --git a/Userland/Libraries/LibWeb/HTML/WindowProxy.h b/Userland/Libraries/LibWeb/HTML/WindowProxy.h index 7cccafb354..5c32c7b63e 100644 --- a/Userland/Libraries/LibWeb/HTML/WindowProxy.h +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.h @@ -32,7 +32,7 @@ public: virtual JS::ThrowCompletionOr<JS::MarkedVector<JS::Value>> internal_own_property_keys() const override; JS::GCPtr<Window> window() const { return m_window; } - void set_window(Badge<BrowsingContext>, JS::NonnullGCPtr<Window>); + void set_window(JS::NonnullGCPtr<Window>); JS::NonnullGCPtr<BrowsingContext> associated_browsing_context() const; |