Truly independent web browser
LibWeb: Collect what a user-agent sheet defines once per process
Andreas Klingbe8aa00ffd47
diff --git a/Libraries/LibWeb/CSS/StyleScope.cpp b/Libraries/LibWeb/CSS/StyleScope.cppindex 5a3a13ffe7a..5be154cb95e 100644--- a/Libraries/LibWeb/CSS/StyleScope.cpp+++ b/Libraries/LibWeb/CSS/StyleScope.cpp@@ -430,9 +430,11 @@ void StyleScope::add_rules_to_rule_cache(CascadeOrigin cascade_origin)for_each_stylesheet(cascade_origin, [&](auto& sheet) {if (!sheet.native_media_list().matches())return;- // OPTIMIZATION: A constructed sheet may be adopted by many shadow roots. What it defines is collected once,- // on the sheet, and every scope that adopts it takes that in.- if (sheet.constructed())+ // OPTIMIZATION: A constructed sheet may be adopted by many shadow roots, and a user-agent sheet is one for every+ // document of the process. What it defines is collected once, on the sheet, and every scope that+ // takes it takes that in.+ // NB: This holds for a user-agent sheet because no @media in one holds what this collects.+ if (sheet.constructed() || cascade_origin == CascadeOrigin::UserAgent)m_rule_cache->add_rules_from_cache(sheet.rule_cache());elsem_rule_cache->add_rules_from_sheet(sheet, cascade_origin);diff --git a/Libraries/LibWeb/CSS/StyleSheetState.cpp b/Libraries/LibWeb/CSS/StyleSheetState.cppindex 62ce3c117fc..102cbc50a20 100644--- a/Libraries/LibWeb/CSS/StyleSheetState.cpp+++ b/Libraries/LibWeb/CSS/StyleSheetState.cpp@@ -550,10 +550,10 @@ void StyleSheetState::for_each_owning_style_scope(Function<void(StyleScope&)> coStyleRuleCache const& StyleSheetState::rule_cache(){- VERIFY(constructed());if (!m_rule_cache) {m_rule_cache = make<StyleRuleCache>();- m_rule_cache->add_rules_from_sheet(*this, CascadeOrigin::Author);+ // NB: Only a constructed sheet and a user-agent sheet are asked for this.+ m_rule_cache->add_rules_from_sheet(*this, constructed() ? CascadeOrigin::Author : CascadeOrigin::UserAgent);}return *m_rule_cache;}