Procházet zdrojové kódy

LibWeb: Expose Document.body to the web

Also, make it return a HTMLElement since Document.body should actually
return the frameset element in a frame-based document.
Andreas Kling před 5 roky
rodič
revize
faff557400

+ 1 - 0
Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp

@@ -376,6 +376,7 @@ void generate_implementation(const IDL::Interface& interface)
     out() << "#include <LibWeb/Bindings/NodeWrapperFactory.h>";
     out() << "#include <LibWeb/Bindings/" << wrapper_class << ".h>";
     out() << "#include <LibWeb/DOM/Element.h>";
+    out() << "#include <LibWeb/DOM/HTMLElement.h>";
 
     out() << "namespace Web {";
     out() << "namespace Bindings {";

+ 1 - 1
Libraries/LibWeb/DOM/Document.cpp

@@ -138,7 +138,7 @@ const HTMLHeadElement* Document::head() const
     return html->first_child_of_type<HTMLHeadElement>();
 }
 
-const HTMLBodyElement* Document::body() const
+const HTMLElement* Document::body() const
 {
     auto* html = document_element();
     if (!html)

+ 1 - 1
Libraries/LibWeb/DOM/Document.h

@@ -81,7 +81,7 @@ public:
 
     const HTMLHtmlElement* document_element() const;
     const HTMLHeadElement* head() const;
-    const HTMLBodyElement* body() const;
+    const HTMLElement* body() const;
 
     String title() const;
 

+ 2 - 0
Libraries/LibWeb/DOM/Document.idl

@@ -5,4 +5,6 @@ interface Document : Node {
     ArrayFromVector querySelectorAll(DOMString selectors);
     Element createElement(DOMString tagName);
 
+    readonly attribute HTMLElement? body;
+
 }