diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2022-03-24 22:08:06 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-24 21:37:49 +0100 |
commit | f82d4d001d6feb8fa09bbf5882f424bfa1a2a208 (patch) | |
tree | a5c4b4b3a138acd717a449755c9adda7611774ea /Userland/Libraries/LibWeb | |
parent | fed11e625efe1718e498e30ab512c47aa75819a5 (diff) | |
download | serenity-f82d4d001d6feb8fa09bbf5882f424bfa1a2a208.zip |
LibWeb: Implement getSVGDocument() for BrowsingContextContainer
Specifically HTMLIFrameElement and HTMLObjectElement. HTMLEmbedElement
will gain it automatically once it's also converted to inherit from
BrowsingContextContainer.
Diffstat (limited to 'Userland/Libraries/LibWeb')
4 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp index 6512e774ac..255a017e39 100644 --- a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp +++ b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.cpp @@ -90,4 +90,17 @@ DOM::Document const* BrowsingContextContainer::content_document_without_origin_c return m_nested_browsing_context->active_document(); } +// https://html.spec.whatwg.org/multipage/embedded-content-other.html#dom-media-getsvgdocument +const DOM::Document* BrowsingContextContainer::get_svg_document() const +{ + // 1. Let document be this element's content document. + auto const* document = content_document(); + + // 2. If document is non-null and was created by the page load processing model for XML files section because the computed type of the resource in the navigate algorithm was image/svg+xml, then return document. + if (document && document->content_type() == "image/svg+xml"sv) + return document; + // 3. Return null. + return nullptr; +} + } diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h b/Userland/Libraries/LibWeb/HTML/BrowsingContextContainer.h index 4d22443279..8d44b124c6 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; + DOM::Document const* get_svg_document() const; + protected: void create_new_nested_browsing_context(); void discard_nested_browsing_context(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl index d0c8f9ef9b..3ff48d9b1b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.idl @@ -19,4 +19,6 @@ interface HTMLIFrameElement : HTMLElement { [LegacyNullToEmptyString, Reflect=marginheight] attribute DOMString marginHeight; [LegacyNullToEmptyString, Reflect=marginwidth] attribute DOMString marginWidth; + + Document? getSVGDocument(); }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.idl index ea00499873..f44d2fcad0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.idl @@ -20,4 +20,5 @@ interface HTMLObjectElement : HTMLElement { [LegacyNullToEmptyString, Reflect] attribute DOMString border; + Document? getSVGDocument(); }; |