1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:27:35 +00:00

LibWeb: Implement CSSRule.parentRule and .parentStyleSheet

Both of these are supposed to be set when the CSSRule is created. The
spec is silent on setting it when a CSSRule is added to a parent. So,
this is a bit ad-hoc.

The parent rule gets set whenever a rule is added to a new parent. The
parent stylesheet gets set whenever the rule or one of its ancestors is
added to a different stylesheet. There may be some nuance there that
I'm missing, but I'm sure we'll find out quickly once we have WPT
running!
This commit is contained in:
Sam Atkins 2022-04-22 19:56:22 +01:00 committed by Andreas Kling
parent 6e6607a92f
commit c718ba5947
7 changed files with 65 additions and 11 deletions

View file

@ -26,11 +26,13 @@ public:
CSSRuleList const& css_rules() const { return m_rules; }
CSSRuleList& css_rules() { return m_rules; }
NonnullRefPtr<CSSRuleList> css_rules_for_bindings() { return m_rules; }
size_t insert_rule(StringView rule, size_t index = 0);
void delete_rule(size_t index);
DOM::ExceptionOr<u32> insert_rule(StringView rule, u32 index = 0);
DOM::ExceptionOr<void> delete_rule(u32 index);
virtual void for_each_effective_style_rule(Function<void(CSSStyleRule const&)> const& callback) const;
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
protected:
explicit CSSGroupingRule(NonnullRefPtrVector<CSSRule>&&);