LibWeb: Generalize support for dimension attributes

Rather than each element which supports dimension attributes needing to
implement parsing the attributes and setting the appropriate style, we
can generalize this functionality. This will also make each element more
closely resemble the spec text, as we will be effectively declaring, for
example, "The img element supports dimension attributes" in code.
This commit is contained in:
Timothy Flynn 2024-04-10 21:44:11 -04:00 committed by Andreas Kling
parent 058dd225dd
commit 4b1abcf61d
Notes: sideshowbarker 2024-07-17 00:59:43 +09:00
8 changed files with 32 additions and 42 deletions

View file

@ -169,20 +169,6 @@ void HTMLIFrameElement::removed_from(DOM::Node* node)
destroy_the_child_navigable();
}
// https://html.spec.whatwg.org/multipage/rendering.html#attributes-for-embedded-content-and-images
void HTMLIFrameElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::width) {
if (auto parsed_value = parse_dimension_value(value))
style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
} else if (name == HTML::AttributeNames::height) {
if (auto parsed_value = parse_dimension_value(value))
style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
}
});
}
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#iframe-load-event-steps
void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
{