Closed Bug 1345699 Opened 7 years ago Closed 7 years ago

stylo: Ensure that we never optimize out recascading in NAC subtrees

Categories

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

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: bholley, Assigned: heycam)

References

Details

Attachments

(1 file)

This isn't so much a work item as it is a reminder to make sure we don't screw this up when we start optimizing the cascade more. Since NAC inherits style from the first non-NAC ancestor, we need to make sure that we don't mistakenly conclude that our direct children can't have inherited any of our properties and then cull the cascade.
Comment on attachment 8874352 [details]
Bug 1345699 - stylo: Always re-cascade in native anonymous subtrees.

https://reviewboard.mozilla.org/r/145716/#review149678

::: servo/components/style/traversal.rs:704
(Diff revision 1)
>          }
>      }
>  
> +    // We must always cascade native anonymous subtrees, since they inherit styles
> +    // from their first non-NAC ancestor.
> +    if element.is_native_anonymous() {

This is somewhat sad for `::before/::after` pseudo-elements I guess... Could we guard it with something like:

```
element.is_native_anonymous() && self.parent_element() != self.closest_native_anonymous_ancestor()
```

Anyway. r=me.

Is there a way to add a test for this? I guess it involves some of the number input pseudos, which may be annoying.
Attachment #8874352 - Flags: review?(emilio+bugs) → review+
(In reply to Emilio Cobos Álvarez [:emilio] from comment #3)
> Is there a way to add a test for this? I guess it involves some of the
> number input pseudos, which may be annoying.

Not only that, it requires a kind of restyle where we'll decide to stop cascading mid-way through the NAC subtree.  I'm putting that test in the too hard basket...
(In reply to Emilio Cobos Álvarez [:emilio] from comment #3)
> This is somewhat sad for `::before/::after` pseudo-elements I guess... Could
> we guard it with something like:
> 
> ```
> element.is_native_anonymous() && self.parent_element() !=
> self.closest_native_anonymous_ancestor()
> ```

How does this help ::before / ::after?
Flags: needinfo?(emilio+bugs)
It would avoid forcibly recascading those, since they wouldn't match that (their DOM parent is their closest non-NAC ancestor).

Of course I made a typo and the condition should read closest_non_native_anonymous_ancestor though.
Flags: needinfo?(emilio+bugs)
But isn't is the case for the root of any NAC subtree, that its parent is the closest non-NAC ancestor?
Oh, sure, but aren't we force are cascading those? You're right that we could check the root flag instead.
Per IRC discussion last night, we should move this check up into the "if compute_self" block so that we don't force cascade NAC subtrees when we didn't even restyle the originating element.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: