Skip to content

Commit

Permalink
LibWeb/CSS: Clear child CSS rules' caches too
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AtkinsSJ authored and awesomekling committed Nov 7, 2024
1 parent d50fcb7 commit f3139c0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
7 changes: 7 additions & 0 deletions Userland/Libraries/LibWeb/CSS/CSSGroupingRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions Userland/Libraries/LibWeb/CSS/CSSGroupingRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CSSGroupingRule : public CSSRule {

virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
virtual void clear_caches() override;

private:
JS::NonnullGCPtr<CSSRuleList> m_rules;
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/CSS/CSSRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ class CSSRule : public Bindings::PlatformObject {
// 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())
Expand Down

0 comments on commit f3139c0

Please sign in to comment.