Closed Bug 1382102 Opened 7 years ago Closed 7 years ago

stylo: :nth-child() shouldn't match element inside XBL anonymous subtree

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: xidorn, Assigned: TYLin)

References

Details

Attachments

(2 files, 1 obsolete file)

Test layout/style/test/test_selectors_on_anonymous_content.html checks that :nth-child() in the outer document doesn't match element inside XBL anonymous subtree.
This seems to be XBL-related. TYLin, could you have a look?
Flags: needinfo?(tlin)
Priority: -- → P3
https://treeherder.mozilla.org/#/jobs?repo=try&revision=178a0bfb74909b70336819aa367d9293ba87313d
Assignee: nobody → tlin
Status: NEW → ASSIGNED
Flags: needinfo?(tlin)
Comment on attachment 8897422 [details]
style: Skip matching :nth-child if element is the root of anonymous subtree

https://reviewboard.mozilla.org/r/168738/#review174164

r=me, with the method renamed. Thanks for fixing this!

::: servo/components/selectors/matching.rs:779
(Diff revision 1)
>                                     flags_setter: &mut F)
>                                     -> bool
>      where E: Element,
>            F: FnMut(&E, ElementSelectorFlags),
>  {
> +    if element.is_root_of_anonymous_subtree() {

I don't think we should not call `is_root_of_anonymous_subtree` to this.

Anon content is a very specific Gecko thing, and `selectors` is supposed to be a generic crate.

It's somewhat annoying because they shouldn't match even `:nth-child(1)`, sigh...

What about an `ignores_nth_child_selectors` kind of flag, that returns false by default, and returns `is_root_of_anonymous_subtree` in `gecko/wrapper.rs`?

I can't think of a really better name, but if you do find one, that'd be great :)
Attachment #8897422 - Flags: review?(emilio+bugs) → review+
Comment on attachment 8897423 [details]
Bug 1382102 - Update mochitest expectation.

https://reviewboard.mozilla.org/r/168740/#review174168
Attachment #8897423 - Flags: review?(emilio+bugs) → review+
Comment on attachment 8897422 [details]
style: Skip matching :nth-child if element is the root of anonymous subtree

https://reviewboard.mozilla.org/r/168738/#review174164

> I don't think we should not call `is_root_of_anonymous_subtree` to this.
> 
> Anon content is a very specific Gecko thing, and `selectors` is supposed to be a generic crate.
> 
> It's somewhat annoying because they shouldn't match even `:nth-child(1)`, sigh...
> 
> What about an `ignores_nth_child_selectors` kind of flag, that returns false by default, and returns `is_root_of_anonymous_subtree` in `gecko/wrapper.rs`?
> 
> I can't think of a really better name, but if you do find one, that'd be great :)

> Anon content is a very specific Gecko thing, and selectors is supposed to be a generic crate.

You're right. It's better to keep `selectors` generic.

I think `ignores_nth_child_selectors` naming is good enough. Let's use that.
Attachment #8897422 - Attachment is obsolete: true
Attached file Servo PR #18104
Pushed by tlin@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a531a8c8f75a
Update mochitest expectation. r=emilio
https://hg.mozilla.org/mozilla-central/rev/a531a8c8f75a
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: