Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBug 1340683 - stylo: Implement the :-moz-any pseudo-class #15966
Conversation
highfive
commented
Mar 15, 2017
highfive
commented
Mar 15, 2017
|
r? @SimonSapin |
|
This still fails the |
| @@ -120,7 +120,7 @@ pub trait Parser { | |||
| } | |||
| } | |||
|
|
|||
| #[derive(PartialEq, Clone, Debug)] | |||
| #[derive(PartialEq, Eq, Hash, Clone, Debug)] | |||
This comment has been minimized.
This comment has been minimized.
emilio
Mar 15, 2017
Member
Is this change needed just due to the bounds in SelectorImpls definition?
If so, I believe we can remove them since we switched to conditional compilation in style and should have a concrete type now.
Also, in pseudo-classes it doesn't really matter I think, since we only store PseudoElements in HashMaps.
This comment has been minimized.
This comment has been minimized.
mbrubeck
Mar 15, 2017
•
Author
Contributor
No, it's also required by #[derive(Clone, Eq, Hash, PartialEq)]
for struct ComplexSelector.
| @@ -661,7 +661,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { | |||
| NonTSPseudoClass::MozTableBorderNonzero | | |||
| NonTSPseudoClass::MozBrowserFrame => unsafe { | |||
| Gecko_MatchesElement(pseudo_class.to_gecko_pseudoclasstype().unwrap(), self.0) | |||
| } | |||
| }, | |||
| NonTSPseudoClass::MozAny(ref selectors) => matches(&selectors.0, self, None), | |||
This comment has been minimized.
This comment has been minimized.
emilio
Mar 15, 2017
Member
This doesn't pass the ElementFlags, nor the StyleRelations here. I believe it should be ok, because we unconditionally insert the appropriate flag for all the custom non-tree-structural pseudo-classes, and because of the limit on only-descendant combinators.
Can you verify that something like http://searchfox.org/mozilla-central/source/layout/reftests/css-selectors/state-dependent-in-any.html (perhaps tweaking manually with :hover or :active, or something we actually implement instead of :valid) works?
This comment has been minimized.
This comment has been minimized.
mbrubeck
Mar 15, 2017
Author
Contributor
Can you verify that something like http://searchfox.org/mozilla-central/source/layout/reftests/css-selectors/state-dependent-in-any.html (perhaps tweaking manually with :hover or :active, or something we actually implement instead of :valid) works?
Selectors like :-moz-any(:hover) do not seem to update correctly on state changes; I'm not certain why, since as you said AFFECTED_BY_STATE is always set.
Also, things like :-moz-any(:first-child) are valid and should set HAS_EDGE_CHILD_SELECTOR and AFFECTED_BY_CHILD_INDEX, so I think we do need to pass the relations and flags here.
This comment has been minimized.
This comment has been minimized.
mbrubeck
Mar 15, 2017
Author
Contributor
Ah, part of the problem is that pseudo_class_state_flag was not implemented correctly for MozAny.
This comment has been minimized.
This comment has been minimized.
|
Oh, I had already started reviewing before you commented :) Upon reflection, I believe the dynamic changes will not pass until https://bugzilla.mozilla.org/show_bug.cgi?id=1338982 is fixed (I'm going to fix it in https://bugzilla.mozilla.org/show_bug.cgi?id=1345950, but I wanted #15890 to land first) |
| match_ignore_ascii_case! { &name, | ||
| "-moz-any" => { | ||
| // https://developer.mozilla.org/en-US/docs/Web/CSS/:any | ||
| // The selectors may not contain pseudo-elements and the only combinator allowed is |
This comment has been minimized.
This comment has been minimized.
bzbarsky
Mar 15, 2017
Contributor
The devmo docs don't seem to match the code. The code has:
// Check that none of the selectors in the list have combinators or
// pseudo-elements.
and proceeds to do just that. See http://searchfox.org/mozilla-central/rev/ca7015fa45b30b29176fbaa70ba0a36fe9263c38/layout/style/nsCSSParser.cpp#6511-6518
This comment has been minimized.
This comment has been minimized.
|
Note that we also have tests for this at http://searchfox.org/mozilla-central/rev/ca7015fa45b30b29176fbaa70ba0a36fe9263c38/layout/style/test/test_selectors.html#1184-1209 and the second test there tests that descendant combinators don't parse... But it looks like lack of support for other things earlier in the test (e.g. :placeholder-shown) causes it to throw exceptions that prevent it from even reaching this part. :( Maybe we should change should_serialize_to to more gracefully handle cases when the selector is not supported at all. :( @upsuper |
Done. I think this is ready for re-review now. |
|
Oops, I didn't see all of the review comments because I hadn't refreshed the page. Addressing some more.. |
b72298c
to
10ad449
|
Updated to correctly calculate |
|
|
|
Rebased. |
|
Looks good. We've talked over IRC and we'll make sure there are bugs on file for the remaining failures in I'm pretty sure they'll be fixed by:
But better getting them on file. |
| @@ -207,6 +245,10 @@ impl NonTSPseudoClass { | |||
| match *self { | |||
| $(NonTSPseudoClass::$name => flag!($state),)* | |||
| $(NonTSPseudoClass::$s_name(..) => flag!($s_state),)* | |||
| NonTSPseudoClass::MozAny(ref selectors) => { | |||
| selectors.iter().fold(ElementState::empty(), |state, s| | |||
This comment has been minimized.
This comment has been minimized.
emilio
Mar 16, 2017
Member
nit: since the closure wraps to the next line, let's just wrap it with braces.
This comment has been minimized.
This comment has been minimized.
| @@ -293,6 +336,11 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> { | |||
| let name = String::from(parser.expect_ident_or_string()?).into_boxed_str(); | |||
| NonTSPseudoClass::$s_name(name) | |||
| }, )* | |||
| "-moz-any" => { | |||
| let selectors = parser.parse_comma_separated(|input| | |||
| ComplexSelector::parse(self, input))?; | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| /// Returns the union of any `ElementState` flags for components of a `ComplexSelector` | ||
| pub fn complex_selector_to_state(sel: &ComplexSelector<SelectorImpl>) -> ElementState { | ||
| sel.compound_selector.iter().fold(ElementState::empty(), |state, s| | ||
| state | selector_to_state(s) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@bors-servo r+ |
|
|
|
Whoops. @bors-servo r- Please address the review nits, then r=me |
|
@bors-servo r=emilio |
|
|
|
@bors-servo r=emilio |
|
|
|
|
Bug 1340683 - stylo: Implement the :-moz-any pseudo-class Adds support for the non-standard [:-moz-any](https://developer.mozilla.org/en-US/docs/Web/CSS/:any) selector. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1340683 - [x] These changes do not require tests because they are gecko-only <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15966) <!-- Reviewable:end -->
|
|
mbrubeck commentedMar 15, 2017
•
edited by larsbergstrom
Adds support for the non-standard :-moz-any selector.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is