From 2801ddfa76691d8e9ca7fd6030192dea89e9b528 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 4 Aug 2022 20:13:52 +0200 Subject: [PATCH] LibWeb: Implement (naive) version of HTMLIFrameElement.contentWindow This should really return the WindowProxy, but since we don't have the infrastructure set up just yet, just return the window object itself for now. --- .../Libraries/LibWeb/HTML/BrowsingContextContainer.cpp | 9 +++++++++ .../Libraries/LibWeb/HTML/BrowsingContextContainer.h | 2 ++ Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl | 3 +++ 3 files changed, 14 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp index 0b40fc808a..7842d9ffcc 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp @@ -103,4 +103,13 @@ const DOM::Document* BrowsingContextContainer::get_svg_document() const return nullptr; } +HTML::Window* BrowsingContextContainer::content_window() const +{ + // FIXME: This should return the WindowProxy + auto* document = content_document(); + if (!document) + return nullptr; + return const_cast(&document->window()); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h index 78b6071d9c..5cdc7ca497 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h @@ -21,6 +21,8 @@ public: const DOM::Document* content_document() const; DOM::Document const* content_document_without_origin_check() const; + HTML::Window* content_window() const; + DOM::Document const* get_svg_document() const; protected: diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl index 3ff48d9b1b..8c25b63df6 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl @@ -13,6 +13,9 @@ interface HTMLIFrameElement : HTMLElement { readonly attribute Document? contentDocument; + // FIXME: Should return a WindowProxy? + readonly attribute Window? contentWindow; + [Reflect] attribute DOMString align; [Reflect] attribute DOMString scrolling; [Reflect=frameborder] attribute DOMString frameBorder;