diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp index 2fe8f26398..421e580ddf 100644 --- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp +++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp @@ -13,13 +13,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -62,7 +62,7 @@ JS::VM& main_thread_vm() // 8.1.5.1 HostEnsureCanAddPrivateElement(O), https://html.spec.whatwg.org/multipage/webappapis.html#the-hostensurecanaddprivateelement-implementation vm->host_ensure_can_add_private_element = [](JS::Object const& object) -> JS::ThrowCompletionOr { // 1. If O is a WindowProxy object, or implements Location, then return Completion { [[Type]]: throw, [[Value]]: a new TypeError }. - if (is(object) || is(object)) + if (is(object) || is(object)) return vm->throw_completion("Cannot add private elements to window or location object"); // 2. Return NormalCompletion(unused). diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index afc7a8c09d..328a5b367e 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -13,7 +13,6 @@ set(SOURCES Bindings/OptionConstructor.cpp Bindings/PlatformObject.cpp Bindings/WindowConstructor.cpp - Bindings/WindowProxy.cpp Crypto/Crypto.cpp Crypto/SubtleCrypto.cpp CSS/Angle.cpp @@ -262,6 +261,7 @@ set(SOURCES HTML/Timer.cpp HTML/Window.cpp HTML/WindowEventHandlers.cpp + HTML/WindowProxy.cpp HTML/Worker.cpp HTML/WorkerDebugConsoleClient.cpp HTML/WorkerGlobalScope.cpp diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 2af18208cf..8a78242603 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -317,6 +317,7 @@ class TextMetrics; class Timer; class Window; class WindowEnvironmentSettingsObject; +class WindowProxy; class Worker; class WorkerEnvironmentSettingsObject; class WorkerGlobalScope; @@ -467,7 +468,6 @@ namespace Web::Bindings { class LocationObject; class OptionConstructor; class RangePrototype; -class WindowProxy; class Wrappable; class Wrapper; class XMLHttpRequestPrototype; diff --git a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp similarity index 92% rename from Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp rename to Userland/Libraries/LibWeb/HTML/WindowProxy.cpp index 84fe0dddef..9020ff230c 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowProxy.cpp +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.cpp @@ -10,17 +10,17 @@ #include #include #include -#include #include #include #include #include #include +#include -namespace Web::Bindings { +namespace Web::HTML { // 7.4 The WindowProxy exotic object, https://html.spec.whatwg.org/multipage/window-object.html#the-windowproxy-exotic-object -WindowProxy::WindowProxy(JS::Realm& realm, HTML::Window& window) +WindowProxy::WindowProxy(JS::Realm& realm, Window& window) : JS::Object(realm, nullptr) , m_window(window) { @@ -103,7 +103,7 @@ JS::ThrowCompletionOr> WindowProxy::internal_ge return m_window->internal_get_own_property(property_key); // 4. Let property be CrossOriginGetOwnPropertyHelper(W, P). - auto property = cross_origin_get_own_property_helper(const_cast(m_window.ptr()), property_key); + auto property = cross_origin_get_own_property_helper(const_cast(m_window.ptr()), property_key); // 5. If property is not undefined, then return property. if (property.has_value()) @@ -120,7 +120,7 @@ JS::ThrowCompletionOr> WindowProxy::internal_ge } // 7. Return ? CrossOriginPropertyFallback(P). - return TRY(HTML::cross_origin_property_fallback(vm, property_key)); + return TRY(cross_origin_property_fallback(vm, property_key)); } // 7.4.6 [[DefineOwnProperty]] ( P, Desc ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-defineownproperty @@ -151,7 +151,7 @@ JS::ThrowCompletionOr WindowProxy::internal_get(JS::PropertyKey const // 1. Let W be the value of the [[Window]] internal slot of this. // 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object. - HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast(HTML::current_global_object()).browsing_context(), *m_window->browsing_context(), property_key, HTML::current_settings_object()); + check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast(current_global_object()).browsing_context(), *m_window->browsing_context(), property_key, current_settings_object()); // 3. If IsPlatformObjectSameOrigin(W) is true, then return ? OrdinaryGet(this, P, Receiver). // NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method. @@ -160,7 +160,7 @@ JS::ThrowCompletionOr WindowProxy::internal_get(JS::PropertyKey const // 4. Return ? CrossOriginGet(this, P, Receiver). // NOTE: this is passed rather than W as OrdinaryGet and CrossOriginGet will invoke the [[GetOwnProperty]] internal method. - return HTML::cross_origin_get(vm, *this, property_key, receiver); + return cross_origin_get(vm, *this, property_key, receiver); } // 7.4.8 [[Set]] ( P, V, Receiver ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-set @@ -171,7 +171,7 @@ JS::ThrowCompletionOr WindowProxy::internal_set(JS::PropertyKey const& pro // 1. Let W be the value of the [[Window]] internal slot of this. // 2. Check if an access between two browsing contexts should be reported, given the current global object's browsing context, W's browsing context, P, and the current settings object. - HTML::check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast(HTML::current_global_object()).browsing_context(), *m_window->browsing_context(), property_key, HTML::current_settings_object()); + check_if_access_between_two_browsing_contexts_should_be_reported(*verify_cast(current_global_object()).browsing_context(), *m_window->browsing_context(), property_key, current_settings_object()); // 3. If IsPlatformObjectSameOrigin(W) is true, then: if (is_platform_object_same_origin(*m_window)) { @@ -185,7 +185,7 @@ JS::ThrowCompletionOr WindowProxy::internal_set(JS::PropertyKey const& pro // 4. Return ? CrossOriginSet(this, P, V, Receiver). // NOTE: this is passed rather than W as CrossOriginSet will invoke the [[GetOwnProperty]] internal method. - return HTML::cross_origin_set(vm, *this, property_key, value, receiver); + return cross_origin_set(vm, *this, property_key, value, receiver); } // 7.4.9 [[Delete]] ( P ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-delete @@ -219,7 +219,7 @@ JS::ThrowCompletionOr WindowProxy::internal_delete(JS::PropertyKey const& // 7.4.10 [[OwnPropertyKeys]] ( ), https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-ownpropertykeys JS::ThrowCompletionOr> WindowProxy::internal_own_property_keys() const { - auto& event_loop = HTML::main_thread_event_loop(); + auto& event_loop = main_thread_event_loop(); auto& vm = event_loop.vm(); // 1. Let W be the value of the [[Window]] internal slot of this. diff --git a/Userland/Libraries/LibWeb/Bindings/WindowProxy.h b/Userland/Libraries/LibWeb/HTML/WindowProxy.h similarity index 91% rename from Userland/Libraries/LibWeb/Bindings/WindowProxy.h rename to Userland/Libraries/LibWeb/HTML/WindowProxy.h index 11d696d332..75b87c9469 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowProxy.h +++ b/Userland/Libraries/LibWeb/HTML/WindowProxy.h @@ -12,7 +12,7 @@ #include #include -namespace Web::Bindings { +namespace Web::HTML { class WindowProxy final : public JS::Object { JS_OBJECT(WindowProxy, JS::Object); @@ -31,19 +31,19 @@ public: virtual JS::ThrowCompletionOr internal_delete(JS::PropertyKey const&) override; virtual JS::ThrowCompletionOr> internal_own_property_keys() const override; - HTML::Window& window() const { return const_cast(*m_window); } + Window& window() const { return const_cast(*m_window); } // NOTE: Someone will have to replace the wrapped window object as well: // "When the browsing context is navigated, the Window object wrapped by the browsing context's associated WindowProxy object is changed." // I haven't found where that actually happens yet. Make sure to use a Badge guarded setter. private: - WindowProxy(JS::Realm&, HTML::Window&); + WindowProxy(JS::Realm&, Window&); virtual void visit_edges(JS::Cell::Visitor&) override; // [[Window]], https://html.spec.whatwg.org/multipage/window-object.html#concept-windowproxy-window - JS::GCPtr m_window; + JS::GCPtr m_window; }; }