1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:27:34 +00:00

LibWeb: Improve performance of CSS custom property resolution

By memoizing already resolved custom properties in the DOM::Element,
we achieve a notable speed increase when loading SerenityOS on GitHub.
This commit is contained in:
Tobias Christiansen 2021-05-28 21:21:44 +02:00 committed by Ali Mohammad Pur
parent 3ede1d08f5
commit 301eb998c6
3 changed files with 22 additions and 6 deletions

View file

@ -30,7 +30,7 @@ public:
DOM::Document& document() { return m_document; }
const DOM::Document& document() const { return m_document; }
NonnullRefPtr<StyleProperties> resolve_style(const DOM::Element&) const;
NonnullRefPtr<StyleProperties> resolve_style(DOM::Element&) const;
Vector<MatchingRule> collect_matching_rules(const DOM::Element&) const;
void sort_matching_rules(Vector<MatchingRule>&) const;
@ -38,8 +38,8 @@ public:
Optional<StyleProperty> style {};
u32 specificity { 0 };
};
CustomPropertyResolutionTuple resolve_custom_property_with_specificity(const DOM::Element&, const String&) const;
Optional<StyleProperty> resolve_custom_property(const DOM::Element&, const String&) const;
CustomPropertyResolutionTuple resolve_custom_property_with_specificity(DOM::Element&, const String&) const;
Optional<StyleProperty> resolve_custom_property(DOM::Element&, const String&) const;
static bool is_inherited_property(CSS::PropertyID);