LibWeb: Implement more spec-compliant iframe/frame attribute processing

We're still missing the lazy loading attribute handling, and once we hit
the navigation step, we fall back to totally ad-hoc behavior instead of
going all the way with a Fetch Request.
This commit is contained in:
Andreas Kling 2022-09-19 13:34:36 +02:00
parent 0810e77d77
commit 03375a3dc9
Notes: sideshowbarker 2024-07-17 06:50:08 +09:00
4 changed files with 168 additions and 1 deletions

View file

@ -46,10 +46,51 @@ void HTMLIFrameElement::inserted()
// FIXME: 2. 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.
process_the_iframe_attributes(true);
load_src(attribute(HTML::AttributeNames::src));
}
}
// https://html.spec.whatwg.org/multipage/urls-and-fetching.html#will-lazy-load-element-steps
bool HTMLIFrameElement::will_lazy_load_element() const
{
// 1. If scripting is disabled for element, then return false.
if (document().is_scripting_disabled())
return false;
// FIXME: 2. If element's lazy loading attribute is in the Lazy state, then return true.
// 3. Return false.
return false;
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes
void HTMLIFrameElement::process_the_iframe_attributes(bool initial_insertion)
{
// 1. If element's srcdoc attribute is specified, then:
if (has_attribute(HTML::AttributeNames::srcdoc)) {
// 2. Set element's current navigation was lazy loaded boolean to false.
m_current_navigation_was_lazy_loaded = false;
// 3. If the will lazy load element steps given element return true, then:
if (will_lazy_load_element()) {
// FIXME: 1. Set element's lazy load resumption steps to the rest of this algorithm starting with the step labeled navigate to the srcdoc resource.
// FIXME: 2. Set element's current navigation was lazy loaded boolean to true.
// FIXME: 3. Start intersection-observing a lazy loading element for element.
// FIXME: 4. Return.
}
// FIXME: 4. Navigate to the srcdoc resource: navigate an iframe or frame given element and a new response whose URL list is « about:srcdoc », header list is « (`Content-Type`, `text/html`) », and body is the value of element's srcdoc attribute.
// FIXME: The resulting Document must be considered an iframe srcdoc document.
return;
}
// 2. Otherwise, run the shared attribute processing steps for iframe and frame elements given element and initialInsertion.
shared_attribute_processing_steps_for_iframe_and_frame(initial_insertion);
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-iframe-element:the-iframe-element-7
void HTMLIFrameElement::removed_from(DOM::Node* node)
{