LibWeb: Route presentational hints through the CSS cascade

Previously, presentational hints bypassed the regular cascade pipeline
and wrote directly into `CascadedProperties` under
`CascadeOrigin::Author`. That meant `var()` substitution and the
invalid-at-computed-value-time fallback had to be duplicated in a
separate per-element pass, which in practice missed the IACVT step and
could leave a `GuaranteedInvalidStyleValue` in the cascaded
properties. This caused a crash in downstream code that assumed the
value had been resolved.

This introduces an `AuthorPresentationalHint` cascade origin and feeds
them through the cascade as normal declarations. This means that
`var()` resolution now happens in only one place.
This commit is contained in:
Tim Ledbetter
2026-04-30 10:44:26 +01:00
committed by Sam Atkins
parent 297b1af9bf
commit d1fc4b4234
Notes: github-actions[bot] 2026-04-30 18:51:41 +00:00
67 changed files with 316 additions and 374 deletions

View File

@@ -6,7 +6,6 @@
*/
#include <LibWeb/Bindings/HTMLIFrameElement.h>
#include <LibWeb/CSS/CascadedProperties.h>
#include <LibWeb/CSS/ComputedProperties.h>
#include <LibWeb/CSS/Invalidation/EmbeddedContentInvalidator.h>
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
@@ -251,9 +250,9 @@ bool HTMLIFrameElement::is_presentational_hint(FlyString const& name) const
return name == HTML::AttributeNames::frameborder;
}
void HTMLIFrameElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
void HTMLIFrameElement::apply_presentational_hints(Vector<CSS::StyleProperty>& properties) const
{
Base::apply_presentational_hints(cascaded_properties);
Base::apply_presentational_hints(properties);
// https://html.spec.whatwg.org/multipage/rendering.html#attributes-for-embedded-content-and-images:attr-iframe-frameborder
// When an iframe element has a frameborder attribute whose value, when parsed using the rules for parsing integers,
@@ -263,10 +262,10 @@ void HTMLIFrameElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperti
auto frameborder = parse_integer(*frameborder_attribute);
if (!frameborder.has_value() || frameborder == 0) {
auto zero = CSS::LengthStyleValue::create(CSS::Length::make_px(0));
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderTopWidth, zero);
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderRightWidth, zero);
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderBottomWidth, zero);
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderLeftWidth, zero);
properties.append({ .property_id = CSS::PropertyID::BorderTopWidth, .value = zero });
properties.append({ .property_id = CSS::PropertyID::BorderRightWidth, .value = zero });
properties.append({ .property_id = CSS::PropertyID::BorderBottomWidth, .value = zero });
properties.append({ .property_id = CSS::PropertyID::BorderLeftWidth, .value = zero });
}
}
}