1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 10:27:35 +00:00

LibWeb: Implement getSVGDocument() for BrowsingContextContainer

Specifically HTMLIFrameElement and HTMLObjectElement. HTMLEmbedElement
will gain it automatically once it's also converted to inherit from
BrowsingContextContainer.
This commit is contained in:
Idan Horowitz 2022-03-24 22:08:06 +02:00 committed by Andreas Kling
parent fed11e625e
commit f82d4d001d
4 changed files with 18 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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();

View file

@ -19,4 +19,6 @@ interface HTMLIFrameElement : HTMLElement {
[LegacyNullToEmptyString, Reflect=marginheight] attribute DOMString marginHeight;
[LegacyNullToEmptyString, Reflect=marginwidth] attribute DOMString marginWidth;
Document? getSVGDocument();
};

View file

@ -20,4 +20,5 @@ interface HTMLObjectElement : HTMLElement {
[LegacyNullToEmptyString, Reflect] attribute DOMString border;
Document? getSVGDocument();
};