mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 07:09:41 +00:00
LibWeb: Invalidate less elements affected by CSS custom properties
Before this change, whenever element's attributes changed, we would add a flag to "pending invalidation", indicating that all descendants whose style uses CSS custom properties needed to be recomputed. This resulted in severe overinvalidation, because we would run invalidation regardless of whether any custom property on affected element actually changed. This change takes another approach, and now we decide whether descendant's style needs to be recomputed based on whether ancestor's style recomputation results in a change of custom properties, though this approach adds a little overhead to style computation as now we have to compare old vs new hashmap of custom properties. This brings substantial improvement on discord and x.com where, before this change, advantage of using invalidation sets was lost and we had to recompute all descendants, because almost all of them use custom properties.
This commit is contained in:
parent
cbe4ba60c3
commit
d1fbb7b51e
Notes:
github-actions[bot]
2025-07-30 09:07:23 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: d1fbb7b51e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5618
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/tcl3
13 changed files with 71 additions and 67 deletions
|
@ -4339,8 +4339,10 @@ NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(Parsin
|
|||
NonnullRefPtr<CSSStyleValue const> Parser::resolve_unresolved_style_value(DOM::AbstractElement& element, GuardedSubstitutionContexts& guarded_contexts, PropertyIDOrCustomPropertyName property, UnresolvedStyleValue const& unresolved)
|
||||
{
|
||||
// AD-HOC: Report that we might rely on custom properties.
|
||||
// FIXME: This over-invalidates. Find a way of invalidating only when we need to - specifically, when var() is used.
|
||||
element.element().set_style_uses_css_custom_properties(true);
|
||||
if (unresolved.includes_attr_function())
|
||||
element.element().set_style_uses_attr_css_function();
|
||||
if (unresolved.includes_var_function())
|
||||
element.element().set_style_uses_var_css_function();
|
||||
|
||||
// To replace substitution functions in a property prop:
|
||||
auto const& property_name = property.visit(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue