LibWeb: Make CSSKeyframeRule.parentRule actually point to parent rule

This commit is contained in:
Andreas Kling 2024-06-14 17:09:41 +02:00 committed by Andreas Kling
parent 7f2c833a39
commit 19fa630fa7
Notes: sideshowbarker 2024-07-17 11:29:41 +09:00
4 changed files with 14 additions and 7 deletions

View file

@ -1,5 +1,7 @@
fooRule: [object CSSKeyframesRule] ~ @keyframes "foo" { 0% { color: rgb(0, 0, 0); } 100% { color: rgb(255, 255, 255); } }
fooRule.cssRules: [object CSSRuleList]
fooRule.cssRules[0]: [object CSSKeyframeRule] ~ 0% { color: rgb(0, 0, 0); }
fooRule.cssRules[0].parentRule: [object CSSKeyframesRule]
fooRule.cssRules[0].parentRule: [object CSSKeyframesRule] ~ @keyframes "foo" { 0% { color: rgb(0, 0, 0); } 100% { color: rgb(255, 255, 255); } }
fooRule.cssRules[0].style.parentRule: [object CSSKeyframeRule] ~ 0% { color: rgb(0, 0, 0); }
fooRule.cssRules[0].style.parentRule === fooRule.cssRules[0]: true

View file

@ -11,6 +11,8 @@
println("fooRule: " + fooRule + " ~ " + fooRule.cssText);
println("fooRule.cssRules: " + fooRule.cssRules);
println("fooRule.cssRules[0]: " + fooRule.cssRules[0] + " ~ " + fooRule.cssRules[0].cssText);
println("fooRule.cssRules[0].parentRule: " + fooRule.cssRules[0].parentRule);
println("fooRule.cssRules[0].parentRule: " + fooRule.cssRules[0].parentRule + " ~ " + fooRule.cssRules[0].parentRule.cssText);
println("fooRule.cssRules[0].style.parentRule: " + fooRule.cssRules[0].style.parentRule + " ~ " + fooRule.cssRules[0].style.parentRule.cssText);
println("fooRule.cssRules[0].style.parentRule === fooRule.cssRules[0]: " + (fooRule.cssRules[0].style.parentRule === fooRule.cssRules[0]));
});

View file

@ -19,6 +19,15 @@ JS::NonnullGCPtr<CSSKeyframesRule> CSSKeyframesRule::create(JS::Realm& realm, Fl
return realm.heap().allocate<CSSKeyframesRule>(realm, realm, move(name), move(css_rules));
}
CSSKeyframesRule::CSSKeyframesRule(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes)
: CSSRule(realm)
, m_name(move(name))
, m_rules(move(keyframes))
{
for (auto& rule : *m_rules)
rule->set_parent_rule(this);
}
void CSSKeyframesRule::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);

View file

@ -37,13 +37,7 @@ public:
void set_name(String const& name) { m_name = name; }
private:
CSSKeyframesRule(JS::Realm& realm, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes)
: CSSRule(realm)
, m_name(move(name))
, m_rules(move(keyframes))
{
}
CSSKeyframesRule(JS::Realm&, FlyString name, JS::NonnullGCPtr<CSSRuleList> keyframes);
virtual void visit_edges(Visitor&) override;
virtual void initialize(JS::Realm&) override;