Commit graph

26 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
ed2e9ce482
Rustfmt and fix tidy on recent changes. 2019-06-25 13:11:31 +02:00
Emilio Cobos Álvarez
fac050325c
style: Add an extra flag to flag ::part() to selectors.
This grows the selector struct, but only in 32-bit, since in 64-bit we take
space from the alignment padding that we're paying due to having the size of the
slice as a word.

Differential Revision: https://phabricator.services.mozilla.com/D32645
2019-06-25 13:11:28 +02:00
Emilio Cobos Álvarez
43444db8a8 style: Cleanup selector-matching for nested pseudo-elements, match ::slotted correctly when there's no selector before it, and add tests.
D29542 fixed the bogus checks that was making nested pseudo-elements match
author rules. This adds tests and ends up being just a cleanup, though as it
turns out we it also fixes an issue with ::slotted() matched from
Element.matches.

Differential Revision: https://phabricator.services.mozilla.com/D27529
2019-05-29 16:14:26 +02:00
Emilio Cobos Álvarez
57874ae90a style: Rustfmt recent changes. 2019-05-07 12:56:02 +02:00
Emilio Cobos Álvarez
a23ad3be50 style: Add parsing support for ::part().
Disabled for now of course. This should be pretty uncontroversial I'd think.

Differential Revision: https://phabricator.services.mozilla.com/D28060
2019-05-07 12:55:44 +02:00
Cameron McCormack
40248ae5fd style: Add derived ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17197
2019-04-12 12:19:52 +02:00
Bobby Holley
af1bbd7b06 style: Derive more.
Differential Revision: https://phabricator.services.mozilla.com/D17029
2019-01-29 02:39:13 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
a15d33a10e cargo fix --edition 2018-11-10 17:47:28 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Emilio Cobos Álvarez
67fae7a2ce
style: Assert earlier to try to get a more helpful stack. 2018-10-28 23:45:18 +01:00
Emilio Cobos Álvarez
e7261d51e9
style: Back out diagnostics for not being helpful enough at diagnosing.
The selectors that crash seem just corrupted data structures, none of the
selectors from crash dumps make sense, and the ones for which I could trace the
source found no issue.
2018-10-28 23:45:13 +01:00
Anshul Malik
a28c642fc7 format components/selectors 2018-09-12 00:24:20 +05:30
Emilio Cobos Álvarez
e6d62b685b
style: Make :host() and ::slotted() account for the inner selector's specificity.
As resolved in https://github.com/w3c/csswg-drafts/issues/1915.

Bug: 1454165
Reviewed-by: xidorn
Differential Revision: https://phabricator.services.mozilla.com/D1849
2018-07-01 00:09:08 +02:00
Emilio Cobos Álvarez
572a93142f
style: Add diagnostics.
Bug: 1416282
Reviewed-by: xidorn
MozReview-Commit-ID: GTnFyZnXR84
2018-06-12 12:15:16 -07:00
Bobby Holley
c99bcdd4b8 Run rustfmt on selectors, servo_arc, and style.
This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
2018-04-10 17:35:15 -07:00
Emilio Cobos Álvarez
eaefaa890e
style: Implement the functional :host(..) selector.
We could invalidate in a slightly more fine-grained way, but I don't think it's
worth the churn vs. keeping the special-cases minimal.

Bug: 1452640
Reviewed-by: xidorn
MozReview-Commit-ID: 5DkQrgwg9GW
2018-04-10 08:04:09 +02:00
Emilio Cobos Álvarez
db5db13559
style: Implement the non-functional :host selector.
Kinda tricky because :host only matches rules on the shadow root where the rules
come from. So we need to be careful during invalidation and style sharing.

I didn't use the non_ts_pseudo_class_list bits because as soon as we implement
the :host(..) bits we're going to need to special-case it anyway.

The general schema is the following:

 * Rightmost featureless :host selectors are handled inserting them in the
   host_rules hashmap. Note that we only insert featureless stuff there. We
   could insert all of them and just filter during matching, but that's slightly
   annoying.

 * The other selectors, like non-featureless :host or what not, are added to the
   normal cascade data. This is harmless, since the shadow host rules are never
   matched against the host, so we know they'll just never match, and avoids
   adding more special-cases.

 * Featureless :host selectors to the left of a combinator are handled during
   matching, in the special-case of next_element_for_combinator in selectors.
   This prevents this from being more invasive, and keeps the usual fast path
   slim, but it's a bit hard to match the spec and the implementation.

   We could keep a copy of the SelectorIter instead in the matching context to
   make the handling of featureless-ness explicit in match_non_ts_pseudo_class,
   but we'd still need the special-case anyway, so I'm not fond of it.

 * We take advantage of one thing that makes this sound. As you may have
   noticed, if you had `root` element which is a ShadowRoot, and you matched
   something like `div:host` against it, using a MatchingContext with
   current_host == root, we'd incorrectly report a match. But this is impossible
   due to the following constraints:

    * Shadow root rules aren't matched against the host during styling (except
      these featureless selectors).

    * DOM APIs' current_host needs to be the _containing_ host, not the element
      itself if you're a Shadow host.

Bug: 992245
Reviewed-by: xidorn
MozReview-Commit-ID: KayYNfTXb5h
2018-04-09 12:19:05 +02:00
Emilio Cobos Álvarez
5115cbd1c0
style: Store ::slotted rules separately on the cascade data, since they may cross the shadow boundary.
MozReview-Commit-ID: EY9nK3169vv
2018-01-09 14:26:02 +01:00
Emilio Cobos Álvarez
7886e033aa
selectors: Add parsing support for ::slotted().
Without turning it on yet, of course.

The reason why I didn't use the general PseudoElement mechanism is because this
pseudo is a bit of its own thing, and I found easier to make ::selectors know
about it (because you need to jump to the assigned slot) than the other way
around.

Also, we need to support ::slotted(..)::before and such, and supporting multiple
pseudo-elements like that breaks some other invariants around the SelectorMap,
and fixing those would require special-casing slotted a lot more in other parts
of the code.

Let me know if you think otherwise.

I also don't like much the boolean tuple return value, but I plan to do some
cleanup in the area in a bit, so it should go away soon, I'd hope.
2017-12-14 06:28:11 +01:00
Xidorn Quan
ab46a0bbe0 Add support for :scope pseudo-class 2017-10-09 22:04:08 +11:00
Josh Matthews
9a7cceb0a1 Report invalid selectors (bug 1384216). 2017-08-28 17:21:07 -07:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
Simon Sapin
7f4c846321 Less unsafe in selectors::builder.
MozReview-Commit-ID: 7IIyio8WAa7
2017-06-20 11:59:11 -07:00
Bobby Holley
1104cdc580 Invert the order of each compound selector.
MozReview-Commit-ID: JkBjqyYgbrB
2017-06-20 11:59:11 -07:00
Bobby Holley
1fc1d64e80 Hoist specificity computation into a new private builder module.
This patch doesn't modify any of the code because making a few things pub. I
did this first to make the next patch easier to audit.

MozReview-Commit-ID: 7PYxoS5bVGN
2017-06-20 11:59:11 -07:00