Переглянути джерело

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.
Andreas Kling 2 роки тому
батько
коміт
2801ddfa76

+ 9 - 0
Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp

@@ -103,4 +103,13 @@ const DOM::Document* BrowsingContextContainer::get_svg_document() const
     return nullptr;
     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<HTML::Window*>(&document->window());
+}
+
 }
 }

+ 2 - 0
Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h

@@ -21,6 +21,8 @@ public:
     const DOM::Document* content_document() const;
     const DOM::Document* content_document() const;
     DOM::Document const* content_document_without_origin_check() const;
     DOM::Document const* content_document_without_origin_check() const;
 
 
+    HTML::Window* content_window() const;
+
     DOM::Document const* get_svg_document() const;
     DOM::Document const* get_svg_document() const;
 
 
 protected:
 protected:

+ 3 - 0
Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl

@@ -13,6 +13,9 @@ interface HTMLIFrameElement : HTMLElement {
 
 
     readonly attribute Document? contentDocument;
     readonly attribute Document? contentDocument;
 
 
+    // FIXME: Should return a WindowProxy?
+    readonly attribute Window? contentWindow;
+
     [Reflect] attribute DOMString align;
     [Reflect] attribute DOMString align;
     [Reflect] attribute DOMString scrolling;
     [Reflect] attribute DOMString scrolling;
     [Reflect=frameborder] attribute DOMString frameBorder;
     [Reflect=frameborder] attribute DOMString frameBorder;