1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 06:54:57 +00:00

LibWeb: Move automatic browsing context creation to HTMLIFrameElement

We will soon have two DOM nodes which contain nested browsing contexts:
HTMLIFrameElement and HTMLObjectElement. Only HTMLIFrameElement should
have its nested context created automatically upon insertion, so move
the invocation of that logic to HTMLIFrameElement.
This commit is contained in:
Timothy Flynn 2022-03-23 20:13:34 -04:00 committed by Andreas Kling
parent 5608bc4eaf
commit f733385cc4
4 changed files with 50 additions and 19 deletions

View file

@ -32,11 +32,28 @@ void HTMLIFrameElement::parse_attribute(const FlyString& name, const String& val
load_src(value);
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-6
void HTMLIFrameElement::inserted()
{
BrowsingContextContainer::inserted();
if (is_connected())
load_src(attribute(HTML::AttributeNames::src));
HTMLElement::inserted();
if (!is_connected())
return;
// 1. Create a new nested browsing context for element.
create_new_nested_browsing_context();
// 2. FIXME: If element has a sandbox attribute, then parse the sandboxing directive given the attribute's value and element's iframe sandboxing flag set.
// 3. Process the iframe attributes for element, with initialInsertion set to true.
load_src(attribute(HTML::AttributeNames::src));
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-7
void HTMLIFrameElement::removed_from(DOM::Node* node)
{
HTMLElement::removed_from(node);
discard_nested_browsing_context();
}
void HTMLIFrameElement::load_src(const String& value)