script: Ensure notify_invalidations() is always called when modifying stylesheets (#38530)

This change supplements the missing stylesheet invalidation
notifications to fix some bugs that the modification of stylesheet does
not take effect. Additionally, this PR add a RAII thing to mark the
modification scope of stylesheet rules, which will facilitate to add
extra logic before the modification happens.

Fixes: there is relevant issue #38211 , but it can't be fixed by this
PR.
Testing: This fixes some subtests in
`/css/cssom/CSSStyleSheet-constructable.html`.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This commit is contained in:
JoeDow 2025-08-15 17:14:34 +08:00 committed by GitHub
parent aca4bde93d
commit 8b574539d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 8 additions and 11 deletions

View file

@ -114,6 +114,7 @@ impl CSSKeyframesRuleMethods<crate::DomTypeHolder> for CSSKeyframesRule {
.keyframes
.push(rule);
self.rulelist(can_gc).append_lazy_dom_rule();
self.cssrule.parent_stylesheet().notify_invalidations();
}
}
@ -145,6 +146,7 @@ impl CSSKeyframesRuleMethods<crate::DomTypeHolder> for CSSKeyframesRule {
let name = KeyframesName::from_ident(&value);
let mut guard = self.cssrule.shared_lock().write();
self.keyframesrule.write_with(&mut guard).name = name;
self.cssrule.parent_stylesheet().notify_invalidations();
Ok(())
}
}