mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Fix underinvalidation when inline style has custom properties
We have an optimization that allows us to invalidate only the style of the element itself and mark descendants for inherited properties update when the "style" attribute changes (unless there are any CSS rules that use the "style" attribute, then we also invalidate all descendants that might be affected by those rules). This optimization was not taking into account that when the inline style has custom properties, we also need to invalidate all descendants whose style might be affected by them. This change fixes this bug by saving a flag in Element that indicates whether its style depends on any custom properties and then invalidating all descendants with this flag set when the "style" attribute changes. Unlike font relative lengths invalidation, for elements that depend on custom properties, we need to actually recompute the style, instead of individual properties, because values without expanded custom properties are gone after cascading, and it has to be done again. The test added for this change is a version of an existing test we had restructured such that it doesn't trigger aggressive style invalidation caused by DOM structured changes until the last moment when test results are printed.
This commit is contained in:
parent
8b5a25e47f
commit
d79bb1aac2
Notes:
github-actions[bot]
2025-01-28 11:39:06 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: d79bb1aac2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3378
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 62 additions and 12 deletions
|
@ -9569,6 +9569,14 @@ NonnullRefPtr<CSSStyleValue> Parser::resolve_unresolved_style_value(DOM::Element
|
|||
Vector<ComponentValue> values_with_variables_expanded;
|
||||
|
||||
HashMap<FlyString, NonnullRefPtr<PropertyDependencyNode>> dependencies;
|
||||
ScopeGuard mark_element_if_uses_custom_properties = [&] {
|
||||
for (auto const& name : dependencies.keys()) {
|
||||
if (is_a_custom_property_name_string(name)) {
|
||||
element.set_style_uses_css_custom_properties(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!expand_variables(element, pseudo_element, string_from_property_id(property_id), dependencies, unresolved_values_without_variables_expanded, values_with_variables_expanded))
|
||||
return CSSKeywordValue::create(Keyword::Unset);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue