mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb: Segregate StyleComputer rule caches per Document-or-ShadowRoot
This means we only need to consider rules from the document and the current shadow root, instead of the document and *every* shadow root. Dramatically reduces the amount of rules processed on many pages. Shaves 2.5 seconds of load time off of https://wpt.fyi/ :^)
This commit is contained in:
parent
e8bc6e9e8e
commit
b5e70908aa
Notes:
github-actions[bot]
2025-01-28 11:25:53 +00:00
Author: https://github.com/awesomekling
Commit: b5e70908aa
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3377
2 changed files with 116 additions and 75 deletions
|
@ -273,23 +273,28 @@ private:
|
|||
HashMap<FlyString, NonnullRefPtr<Animations::KeyframeEffect::KeyFrameSet>> rules_by_animation_keyframes;
|
||||
};
|
||||
|
||||
struct BuiltRuleCaches {
|
||||
NonnullOwnPtr<RuleCache> main_rules;
|
||||
HashMap<FlyString, NonnullOwnPtr<RuleCache>> layer_rules;
|
||||
struct RuleCaches {
|
||||
RuleCache main;
|
||||
HashMap<FlyString, NonnullOwnPtr<RuleCache>> by_layer;
|
||||
};
|
||||
[[nodiscard]] BuiltRuleCaches make_rule_cache_for_cascade_origin(CascadeOrigin, SelectorInsights&, Vector<MatchingRule>& hover_rules);
|
||||
|
||||
[[nodiscard]] RuleCache const* rule_cache_for_cascade_origin(CascadeOrigin, FlyString const& qualified_layer_name) const;
|
||||
struct RuleCachesForDocumentAndShadowRoots {
|
||||
RuleCaches for_document;
|
||||
HashMap<GC::Ref<DOM::ShadowRoot const>, NonnullOwnPtr<RuleCaches>> for_shadow_roots;
|
||||
};
|
||||
|
||||
void make_rule_cache_for_cascade_origin(CascadeOrigin, SelectorInsights&, Vector<MatchingRule>& hover_rules);
|
||||
|
||||
[[nodiscard]] RuleCache const* rule_cache_for_cascade_origin(CascadeOrigin, FlyString const& qualified_layer_name, GC::Ptr<DOM::ShadowRoot const>) const;
|
||||
|
||||
static void collect_selector_insights(Selector const&, SelectorInsights&);
|
||||
|
||||
OwnPtr<SelectorInsights> m_selector_insights;
|
||||
Vector<MatchingRule> m_hover_rules;
|
||||
OwnPtr<StyleInvalidationData> m_style_invalidation_data;
|
||||
OwnPtr<RuleCache> m_author_rule_cache;
|
||||
HashMap<FlyString, NonnullOwnPtr<RuleCache>> m_layer_rule_caches;
|
||||
OwnPtr<RuleCache> m_user_rule_cache;
|
||||
OwnPtr<RuleCache> m_user_agent_rule_cache;
|
||||
OwnPtr<RuleCachesForDocumentAndShadowRoots> m_author_rule_cache;
|
||||
OwnPtr<RuleCachesForDocumentAndShadowRoots> m_user_rule_cache;
|
||||
OwnPtr<RuleCachesForDocumentAndShadowRoots> m_user_agent_rule_cache;
|
||||
GC::Root<CSSStyleSheet> m_user_style_sheet;
|
||||
|
||||
using FontLoaderList = Vector<NonnullOwnPtr<FontLoader>>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue