LibWeb/CSS: Clear child CSS rules' caches too

If a rule gets its caches cleared because it's moved in the OM, then its
child rules' caches are likely invalid and need clearing too.

Assuming that caches only point "upwards", this will correctly clear
them all. For the time being that will be true.
This commit is contained in:
Sam Atkins 2024-11-04 17:13:51 +00:00 committed by Andreas Kling
parent e6291c8d0e
commit 0b23dddb4b
Notes: github-actions[bot] 2024-11-07 14:12:48 +00:00
4 changed files with 13 additions and 4 deletions

View file

@ -6,7 +6,8 @@ Rerun
Found 13 tests
13 Fail
1 Pass
12 Fail
Details
Result Test Name MessageFail CSSStyleRule is a CSSGroupingRule
Fail Simple CSSOM manipulation of subrules
@ -20,4 +21,4 @@ Fail Simple CSSOM manipulation of subrules 7
Fail Simple CSSOM manipulation of subrules 8
Fail Simple CSSOM manipulation of subrules 9
Fail Simple CSSOM manipulation of subrules 10
Fail Mutating the selectorText of outer rule invalidates inner rules
Pass Mutating the selectorText of outer rule invalidates inner rules

View file

@ -34,6 +34,13 @@ void CSSGroupingRule::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_rules);
}
void CSSGroupingRule::clear_caches()
{
Base::clear_caches();
for (auto& rule : *m_rules)
rule->clear_caches();
}
WebIDL::ExceptionOr<u32> CSSGroupingRule::insert_rule(StringView rule, u32 index)
{
TRY(m_rules->insert_a_css_rule(rule, index));

View file

@ -35,6 +35,7 @@ protected:
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
virtual void clear_caches() override;
private:
JS::NonnullGCPtr<CSSRuleList> m_rules;

View file

@ -58,13 +58,13 @@ public:
// https://drafts.csswg.org/cssom-1/#serialize-a-css-rule
virtual String serialized() const = 0;
virtual void clear_caches();
protected:
explicit CSSRule(JS::Realm&, Type);
virtual void visit_edges(Cell::Visitor&) override;
virtual void clear_caches();
[[nodiscard]] FlyString const& parent_layer_internal_qualified_name() const
{
if (!m_cached_layer_name.has_value())