diff --git a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp index 6789443b5f..c088d6030d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSImportRule.cpp @@ -85,7 +85,7 @@ void CSSImportRule::resource_did_load() m_style_sheet = move(sheet); - m_document->style_sheets().bump_generation(); + m_document->style_computer().invalidate_rule_cache(); m_document->invalidate_style(); } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 7ec8a5248e..b44a87eb7e 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -42,7 +42,7 @@ DOM::ExceptionOr CSSStyleSheet::insert_rule(StringView rule, unsigned if (!result.is_exception()) { if (m_style_sheet_list) { - m_style_sheet_list->bump_generation(); + m_style_sheet_list->document().style_computer().invalidate_rule_cache(); m_style_sheet_list->document().invalidate_style(); } } @@ -61,7 +61,7 @@ DOM::ExceptionOr CSSStyleSheet::delete_rule(unsigned index) auto result = m_rules->remove_a_css_rule(index); if (!result.is_exception()) { if (m_style_sheet_list) { - m_style_sheet_list->bump_generation(); + m_style_sheet_list->document().style_computer().invalidate_rule_cache(); m_style_sheet_list->document().invalidate_style(); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index cd4561ee5d..01425724ab 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1071,7 +1071,7 @@ bool PropertyDependencyNode::has_cycles() void StyleComputer::build_rule_cache_if_needed() const { - if (m_rule_cache && m_rule_cache->generation == m_document.style_sheets().generation()) + if (m_rule_cache) return; const_cast(*this).build_rule_cache(); } @@ -1146,8 +1146,6 @@ void StyleComputer::build_rule_cache() dbgln(" Other: {}", m_rule_cache->other_rules.size()); dbgln(" Total: {}", num_class_rules + num_id_rules + num_tag_name_rules + m_rule_cache->other_rules.size()); } - - m_rule_cache->generation = m_document.style_sheets().generation(); } void StyleComputer::invalidate_rule_cache() diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.h b/Userland/Libraries/LibWeb/CSS/StyleComputer.h index 6a1e3976a7..2c688b3cc2 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.h +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.h @@ -104,7 +104,6 @@ private: HashMap> rules_by_tag_name; HashMap> rules_by_pseudo_element; Vector other_rules; - int generation { 0 }; }; OwnPtr m_rule_cache; }; diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp index 23d6dd96d6..a43ab4711a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp @@ -15,7 +15,7 @@ void StyleSheetList::add_sheet(NonnullRefPtr sheet) sheet->set_style_sheet_list({}, this); m_sheets.append(move(sheet)); - ++m_generation; + m_document.style_computer().invalidate_rule_cache(); m_document.invalidate_style(); } @@ -24,7 +24,7 @@ void StyleSheetList::remove_sheet(CSSStyleSheet& sheet) sheet.set_style_sheet_list({}, nullptr); m_sheets.remove_first_matching([&](auto& entry) { return &*entry == &sheet; }); - ++m_generation; + m_document.style_computer().invalidate_rule_cache(); m_document.invalidate_style(); } diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h index 70eb915738..0fe931bece 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h @@ -43,9 +43,6 @@ public: bool is_supported_property_index(u32) const; - int generation() const { return m_generation; } - void bump_generation() { ++m_generation; } - DOM::Document& document() { return m_document; } DOM::Document const& document() const { return m_document; }