diff options
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/LocationObject.cpp | 16 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Bindings/WindowObject.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/AbortController.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/AbortSignal.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Comment.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Range.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Text.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Window.cpp | 20 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Window.h | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/WebSocket.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 12 | ||||
-rw-r--r-- | Userland/Services/WebContent/ConsoleGlobalObject.cpp | 2 |
16 files changed, 44 insertions, 42 deletions
diff --git a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp index adf4deba97..46ec3ffaeb 100644 --- a/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp +++ b/Userland/Libraries/LibWeb/Bindings/ImageConstructor.cpp @@ -43,7 +43,7 @@ JS::Value ImageConstructor::call() JS::Value ImageConstructor::construct(FunctionObject&) { auto& window = static_cast<WindowObject&>(global_object()); - auto& document = window.impl().document(); + auto& document = window.impl().associated_document(); auto image_element = DOM::create_element(document, HTML::TagNames::img, Namespace::HTML); if (vm().argument_count() > 0) { diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index 227a6aebee..1d819baa44 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -41,7 +41,7 @@ LocationObject::~LocationObject() JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_getter) { auto& window = static_cast<WindowObject&>(global_object); - return JS::js_string(vm, window.impl().document().url().to_string()); + return JS::js_string(vm, window.impl().associated_document().url().to_string()); } JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter) @@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter) auto new_href = vm.argument(0).to_string(global_object); if (vm.exception()) return {}; - auto href_url = window.impl().document().complete_url(new_href); + auto href_url = window.impl().associated_document().complete_url(new_href); if (!href_url.is_valid()) { vm.throw_exception<JS::URIError>(global_object, String::formatted("Invalid URL '{}'", new_href)); return {}; @@ -62,26 +62,26 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::href_setter) JS_DEFINE_NATIVE_FUNCTION(LocationObject::pathname_getter) { auto& window = static_cast<WindowObject&>(global_object); - return JS::js_string(vm, window.impl().document().url().path()); + return JS::js_string(vm, window.impl().associated_document().url().path()); } JS_DEFINE_NATIVE_FUNCTION(LocationObject::hostname_getter) { auto& window = static_cast<WindowObject&>(global_object); - return JS::js_string(vm, window.impl().document().url().host()); + return JS::js_string(vm, window.impl().associated_document().url().host()); } JS_DEFINE_NATIVE_FUNCTION(LocationObject::host_getter) { auto& window = static_cast<WindowObject&>(global_object); - auto url = window.impl().document().url(); + auto url = window.impl().associated_document().url(); return JS::js_string(vm, String::formatted("{}:{}", url.host(), url.port())); } JS_DEFINE_NATIVE_FUNCTION(LocationObject::hash_getter) { auto& window = static_cast<WindowObject&>(global_object); - auto fragment = window.impl().document().url().fragment(); + auto fragment = window.impl().associated_document().url().fragment(); if (!fragment.length()) return JS::js_string(vm, ""); StringBuilder builder; @@ -93,7 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::hash_getter) JS_DEFINE_NATIVE_FUNCTION(LocationObject::search_getter) { auto& window = static_cast<WindowObject&>(global_object); - auto query = window.impl().document().url().query(); + auto query = window.impl().associated_document().url().query(); if (!query.length()) return JS::js_string(vm, ""); StringBuilder builder; @@ -106,7 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::protocol_getter) { auto& window = static_cast<WindowObject&>(global_object); StringBuilder builder; - builder.append(window.impl().document().url().protocol()); + builder.append(window.impl().associated_document().url().protocol()); builder.append(':'); return JS::js_string(vm, builder.to_string()); } diff --git a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp index 1cf8b287f4..c0cdd3234b 100644 --- a/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/WindowObject.cpp @@ -97,7 +97,7 @@ void WindowObject::visit_edges(Visitor& visitor) Origin WindowObject::origin() const { - return impl().document().origin(); + return impl().associated_document().origin(); } static DOM::Window* impl_from(JS::VM& vm, JS::GlobalObject& global_object) @@ -358,7 +358,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::top_getter) if (!impl) return {}; - auto* this_browsing_context = impl->document().browsing_context(); + auto* this_browsing_context = impl->associated_document().browsing_context(); if (!this_browsing_context) return JS::js_null(); @@ -374,7 +374,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::parent_getter) if (!impl) return {}; - auto* this_browsing_context = impl->document().browsing_context(); + auto* this_browsing_context = impl->associated_document().browsing_context(); if (!this_browsing_context) return JS::js_null(); @@ -392,7 +392,7 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::document_getter) auto* impl = impl_from(vm, global_object); if (!impl) return {}; - return wrap(global_object, impl->document()); + return wrap(global_object, impl->associated_document()); } JS_DEFINE_NATIVE_FUNCTION(WindowObject::performance_getter) diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.h b/Userland/Libraries/LibWeb/DOM/AbortController.h index 3e9d919978..c8b4a15866 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.h +++ b/Userland/Libraries/LibWeb/DOM/AbortController.h @@ -31,7 +31,7 @@ public: static NonnullRefPtr<AbortController> create_with_global_object(Bindings::WindowObject& window_object) { - return AbortController::create(window_object.impl().document()); + return AbortController::create(window_object.impl().associated_document()); } virtual ~AbortController() override; diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.h b/Userland/Libraries/LibWeb/DOM/AbortSignal.h index 273d28981a..f468eb079e 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.h +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.h @@ -34,7 +34,7 @@ public: static NonnullRefPtr<AbortSignal> create_with_global_object(Bindings::WindowObject& window_object) { - return AbortSignal::create(window_object.impl().document()); + return AbortSignal::create(window_object.impl().associated_document()); } virtual ~AbortSignal() override; diff --git a/Userland/Libraries/LibWeb/DOM/Comment.cpp b/Userland/Libraries/LibWeb/DOM/Comment.cpp index 2d7bcb8fea..77abdb9b16 100644 --- a/Userland/Libraries/LibWeb/DOM/Comment.cpp +++ b/Userland/Libraries/LibWeb/DOM/Comment.cpp @@ -22,7 +22,7 @@ Comment::~Comment() // https://dom.spec.whatwg.org/#dom-comment-comment NonnullRefPtr<Comment> Comment::create_with_global_object(Bindings::WindowObject& window, String const& data) { - return make_ref_counted<Comment>(window.impl().document(), data); + return make_ref_counted<Comment>(window.impl().associated_document(), data); } } diff --git a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp index 50a5aabd86..a9ac6833f2 100644 --- a/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp +++ b/Userland/Libraries/LibWeb/DOM/DocumentFragment.cpp @@ -21,7 +21,7 @@ DocumentFragment::~DocumentFragment() // https://dom.spec.whatwg.org/#dom-documentfragment-documentfragment NonnullRefPtr<DocumentFragment> DocumentFragment::create_with_global_object(Bindings::WindowObject& window) { - return make_ref_counted<DocumentFragment>(window.impl().document()); + return make_ref_counted<DocumentFragment>(window.impl().associated_document()); } } diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index 9b62ebcd1e..b7dba26c5d 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -162,7 +162,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr< target_override = target; } else { // NOTE: This can be done because legacy_target_override is only set for events targeted at Window. - target_override = verify_cast<Window>(*target).document(); + target_override = verify_cast<Window>(*target).associated_document(); } RefPtr<EventTarget> activation_target; diff --git a/Userland/Libraries/LibWeb/DOM/Range.cpp b/Userland/Libraries/LibWeb/DOM/Range.cpp index 3125a41b98..40af4a1444 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.cpp +++ b/Userland/Libraries/LibWeb/DOM/Range.cpp @@ -13,7 +13,7 @@ namespace Web::DOM { NonnullRefPtr<Range> Range::create(Window& window) { - return Range::create(window.document()); + return Range::create(window.associated_document()); } NonnullRefPtr<Range> Range::create(Document& document) diff --git a/Userland/Libraries/LibWeb/DOM/Text.cpp b/Userland/Libraries/LibWeb/DOM/Text.cpp index 6fa80992d2..b724891b84 100644 --- a/Userland/Libraries/LibWeb/DOM/Text.cpp +++ b/Userland/Libraries/LibWeb/DOM/Text.cpp @@ -27,7 +27,7 @@ RefPtr<Layout::Node> Text::create_layout_node() // https://dom.spec.whatwg.org/#dom-text-text NonnullRefPtr<Text> Text::create_with_global_object(Bindings::WindowObject& window, String const& data) { - return make_ref_counted<Text>(window.impl().document(), data); + return make_ref_counted<Text>(window.impl().associated_document(), data); } } diff --git a/Userland/Libraries/LibWeb/DOM/Window.cpp b/Userland/Libraries/LibWeb/DOM/Window.cpp index 52a7f7f875..a787da2e1c 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.cpp +++ b/Userland/Libraries/LibWeb/DOM/Window.cpp @@ -25,7 +25,7 @@ NonnullRefPtr<Window> Window::create_with_document(Document& document) Window::Window(Document& document) : EventTarget(static_cast<Bindings::ScriptExecutionContext&>(document)) - , m_document(document) + , m_associated_document(document) , m_performance(make<HighResolutionTime::Performance>(*this)) , m_screen(CSS::Screen::create(*this)) { @@ -139,7 +139,7 @@ void Window::cancel_animation_frame(i32 id) void Window::did_set_location_href(Badge<Bindings::LocationObject>, URL const& new_href) { - auto* frame = document().browsing_context(); + auto* frame = associated_document().browsing_context(); if (!frame) return; frame->loader().load(new_href, FrameLoader::Type::Navigation); @@ -147,10 +147,10 @@ void Window::did_set_location_href(Badge<Bindings::LocationObject>, URL const& n void Window::did_call_location_reload(Badge<Bindings::LocationObject>) { - auto* frame = document().browsing_context(); + auto* frame = associated_document().browsing_context(); if (!frame) return; - frame->loader().load(document().url(), FrameLoader::Type::Reload); + frame->loader().load(associated_document().url(), FrameLoader::Type::Reload); } bool Window::dispatch_event(NonnullRefPtr<Event> event) @@ -165,26 +165,26 @@ JS::Object* Window::create_wrapper(JS::GlobalObject& global_object) int Window::inner_width() const { - if (!document().layout_node()) + if (!associated_document().layout_node()) return 0; - return document().layout_node()->width(); + return associated_document().layout_node()->width(); } int Window::inner_height() const { - if (!document().layout_node()) + if (!associated_document().layout_node()) return 0; - return document().layout_node()->height(); + return associated_document().layout_node()->height(); } Page* Window::page() { - return document().page(); + return associated_document().page(); } Page const* Window::page() const { - return document().page(); + return associated_document().page(); } } diff --git a/Userland/Libraries/LibWeb/DOM/Window.h b/Userland/Libraries/LibWeb/DOM/Window.h index 054ed289b2..67e742f2a1 100644 --- a/Userland/Libraries/LibWeb/DOM/Window.h +++ b/Userland/Libraries/LibWeb/DOM/Window.h @@ -36,8 +36,8 @@ public: Page* page(); Page const* page() const; - Document const& document() const { return m_document; } - Document& document() { return m_document; } + Document const& associated_document() const { return m_associated_document; } + Document& associated_document() { return m_associated_document; } void alert(String const&); bool confirm(String const&); @@ -75,7 +75,9 @@ public: private: explicit Window(Document&); - Document& m_document; + // https://html.spec.whatwg.org/multipage/window-object.html#concept-document-window + Document& m_associated_document; + WeakPtr<Bindings::WindowObject> m_wrapper; IDAllocator m_timer_id_allocator; diff --git a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp index f1c7164ea2..59067e865a 100644 --- a/Userland/Libraries/LibWeb/HTML/WebSocket.cpp +++ b/Userland/Libraries/LibWeb/HTML/WebSocket.cpp @@ -62,7 +62,7 @@ DOM::ExceptionOr<NonnullRefPtr<WebSocket>> WebSocket::create_with_global_object( } WebSocket::WebSocket(DOM::Window& window, URL& url) - : EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document())) + : EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.associated_document())) , m_window(window) { // FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake diff --git a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp index 86a7036a13..436e647a0e 100644 --- a/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp +++ b/Userland/Libraries/LibWeb/HighResolutionTime/Performance.cpp @@ -14,7 +14,7 @@ namespace Web::HighResolutionTime { Performance::Performance(DOM::Window& window) - : DOM::EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document())) + : DOM::EventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.associated_document())) , m_window(window) , m_timing(make<NavigationTiming::PerformanceTiming>(window)) { diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 021e988002..2261f58a09 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -25,7 +25,7 @@ namespace Web::XHR { XMLHttpRequest::XMLHttpRequest(DOM::Window& window) - : XMLHttpRequestEventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.document())) + : XMLHttpRequestEventTarget(static_cast<Bindings::ScriptExecutionContext&>(window.associated_document())) , m_window(window) { } @@ -119,7 +119,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& auto normalized_method = normalize_method(method); - auto parsed_url = m_window->document().complete_url(url); + auto parsed_url = m_window->associated_document().complete_url(url); if (!parsed_url.is_valid()) return DOM::SyntaxError::create("Invalid URL"); @@ -166,14 +166,14 @@ DOM::ExceptionOr<void> XMLHttpRequest::send() // FIXME: If body is not null, then: - URL request_url = m_window->document().complete_url(m_url.to_string()); - dbgln("XHR send from {} to {}", m_window->document().url(), request_url); + URL request_url = m_window->associated_document().complete_url(m_url.to_string()); + dbgln("XHR send from {} to {}", m_window->associated_document().url(), request_url); // TODO: Add support for preflight requests to support CORS requests Origin request_url_origin = Origin(request_url.protocol(), request_url.host(), request_url.port()); - if (!m_window->document().origin().is_same(request_url_origin)) { - dbgln("XHR failed to load: Same-Origin Policy violation: {} may not load {}", m_window->document().url(), request_url); + if (!m_window->associated_document().origin().is_same(request_url_origin)) { + dbgln("XHR failed to load: Same-Origin Policy violation: {} may not load {}", m_window->associated_document().url(), request_url); auto weak_this = make_weak_ptr(); if (!weak_this) return {}; diff --git a/Userland/Services/WebContent/ConsoleGlobalObject.cpp b/Userland/Services/WebContent/ConsoleGlobalObject.cpp index 1651005282..f1c0af4a34 100644 --- a/Userland/Services/WebContent/ConsoleGlobalObject.cpp +++ b/Userland/Services/WebContent/ConsoleGlobalObject.cpp @@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_GETTER(ConsoleGlobalObject::inspected_node_getter) auto console_global_object = static_cast<ConsoleGlobalObject*>(this_object); auto& window = console_global_object->m_window_object->impl(); - auto* inspected_node = window.document().inspected_node(); + auto* inspected_node = window.associated_document().inspected_node(); if (!inspected_node) return JS::js_undefined(); |