Closed Bug 1472065 Opened Last year Closed Last year

simplify management of style sheet and parent rule pointers in css::Rule


(Core :: CSS Parsing and Computation, enhancement, P3)




Tracking Status
firefox63 --- fixed


(Reporter: heycam, Assigned: heycam)


(Blocks 1 open bug)



(1 file)

The style sheet and parent rule should be known at the time the Rule object is constructed, so I think it would be better to pass those in to the constructor rather than wait for SetStyleSheet / SetParentRule calls later.
Blocks: 1471807
Two things to note:

1. I moved the check we do when clearing out mSheet in group rules to avoid quadratic time behavior when unlinking to inside the function that would drop the reference (ServoCSSRuleList::DropSheetReference, renamed from SetStyleSheet).

2. I removed the mention of the direct style sheet owner of ServoCSSRuleList, since previously we would end up calling SetStyleSheet on it for non-top-level group rules anyway.
Comment on attachment 8988973 [details]
Bug 1472065 - Initialize mSheet and mParentRule in css::Rule's constructor.

::: layout/style/Rule.h:132
(Diff revision 1)
>    bool IsKnownLive() const;
> -  // This is sometimes null (e.g., for style attributes).
> -  StyleSheet* mSheet;
> -  // When the parent GroupRule is destroyed, it will call SetParentRule(nullptr)
> -  // on this object. (Through SetParentRuleReference);
> +  // mSheet should only ever be null when we create a synthetic CSSFontFaceRule
> +  // for an InspectorFontFace.
> +  //
> +  // mSheet and mParentRule will be cleared when the parent object is destroyed.

Probably better "when they are detached from the parent object, either because the rule is removed or the parent is destroyed."
Attachment #8988973 - Flags: review?(xidorn+moz) → review+
Pushed by
Initialize mSheet and mParentRule in css::Rule's constructor. r=xidorn
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.