mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
LibWeb: Add CSS rule buckets for pseudo elements, and for :root
If a selector must match a pseudo element, or must match the root element, we now cache that information in the MatchingRule struct. We also introduce separate buckets for these rules, so we can avoid running them altogether if the current element can't possibly match. This cuts the number of selectors evaluated by 32% when loading our GitHub repo page https://github.com/SerenityOS/serenity
This commit is contained in:
@@ -37,8 +37,10 @@ struct MatchingRule {
|
||||
size_t style_sheet_index { 0 };
|
||||
size_t rule_index { 0 };
|
||||
size_t selector_index { 0 };
|
||||
|
||||
u32 specificity { 0 };
|
||||
bool contains_pseudo_element { false };
|
||||
bool contains_root_pseudo_class { false };
|
||||
};
|
||||
|
||||
struct FontFaceKey {
|
||||
@@ -129,6 +131,8 @@ private:
|
||||
HashMap<FlyString, Vector<MatchingRule>> rules_by_id;
|
||||
HashMap<FlyString, Vector<MatchingRule>> rules_by_class;
|
||||
HashMap<FlyString, Vector<MatchingRule>> rules_by_tag_name;
|
||||
Vector<MatchingRule> pseudo_element_rules;
|
||||
Vector<MatchingRule> root_rules;
|
||||
Vector<MatchingRule> other_rules;
|
||||
|
||||
HashMap<FlyString, NonnullRefPtr<Animations::KeyframeEffect::KeyFrameSet>> rules_by_animation_keyframes;
|
||||
|
||||
Reference in New Issue
Block a user