mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-14 19:06:35 +02:00
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:
committed by
Sam Atkins
parent
297b1af9bf
commit
d1fc4b4234
Notes:
github-actions[bot]
2026-04-30 18:51:41 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/d1fc4b4234b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9176 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/gmta
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <LibWeb/Bindings/HTMLDivElement.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CascadedProperties.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/KeywordStyleValue.h>
|
||||
#include <LibWeb/HTML/HTMLDivElement.h>
|
||||
@@ -31,19 +30,19 @@ bool HTMLDivElement::is_presentational_hint(FlyString const& name) const
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3
|
||||
void HTMLDivElement::apply_presentational_hints(GC::Ref<CSS::CascadedProperties> cascaded_properties) const
|
||||
void HTMLDivElement::apply_presentational_hints(Vector<CSS::StyleProperty>& properties) const
|
||||
{
|
||||
Base::apply_presentational_hints(cascaded_properties);
|
||||
Base::apply_presentational_hints(properties);
|
||||
for_each_attribute([&](auto& name, auto& value) {
|
||||
if (name == HTML::AttributeNames::align) {
|
||||
if (value.equals_ignoring_ascii_case("left"sv))
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::KeywordStyleValue::create(CSS::Keyword::LibwebLeft));
|
||||
properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::LibwebLeft) });
|
||||
else if (value.equals_ignoring_ascii_case("right"sv))
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::KeywordStyleValue::create(CSS::Keyword::LibwebRight));
|
||||
properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::LibwebRight) });
|
||||
else if (value.equals_ignoring_ascii_case("center"sv))
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::KeywordStyleValue::create(CSS::Keyword::LibwebCenter));
|
||||
properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::LibwebCenter) });
|
||||
else if (value.equals_ignoring_ascii_case("justify"sv))
|
||||
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, CSS::KeywordStyleValue::create(CSS::Keyword::Justify));
|
||||
properties.append({ .property_id = CSS::PropertyID::TextAlign, .value = CSS::KeywordStyleValue::create(CSS::Keyword::Justify) });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user