Commit graph

145 commits

Author SHA1 Message Date
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
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
Emilio Cobos Álvarez
badb8f398a
style: Support ::before / ::after on ::slotted pseudos.
See https://github.com/w3c/csswg-drafts/issues/3150 for the issue that would
expand this to all pseudos.

Differential Revision: https://phabricator.services.mozilla.com/D9994
2018-11-05 12:29:30 +01:00
Emilio Cobos Álvarez
edc40ce320
style: Implement @supports selector() syntax.
This implements the selector(<complex-selector>) syntax for @supports.

See https://github.com/w3c/csswg-drafts/issues/3207 for explainer and
discussion.

Probably would should wait for that to be sorted out to land this, or maybe we
should put it behind a pref to get the code landed and change our
implementation if the discussion there leads to a change.

Differential Revision: https://phabricator.services.mozilla.com/D8864
2018-10-19 00:40:02 +02:00
Anshul Malik
a28c642fc7 format components/selectors 2018-09-12 00:24:20 +05:30
Cameron McCormack
62419adaaa
style: Shrink selectors::Component to 24 bytes.
This saves about 37 KiB of memory across the UA style sheets.

Bug: 1475197
Reviewed-by: emilio
2018-08-08 01:36:53 +02:00
Emilio Cobos Álvarez
07456bbd3d
style: Simplify selector serialization.
Bug: 1471063
Reviewed-by: xidorn
MozReview-Commit-ID: 959U7yd5W9j
2018-07-01 00:06:48 +02:00
Emilio Cobos Álvarez
84280c5203
style: Deindent the serialization loop.
Bug: 1471063
Reviewed-by: xidorn
MozReview-Commit-ID: GPlUAx7YXVb
2018-07-01 00:06:35 +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
Emilio Cobos Álvarez
8821ad72f4
style: Make pseudo-elements work with :host.
Imported WebKit's test as a WPT.

Bug: 1465291
Reviewed-by: xidorn
MozReview-Commit-ID: 19ZThuoqKLW
2018-06-12 12:15:10 -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
Bobby Holley
f7ae1a37e3 Manual fixups so that the rustfmt output won't trigger tidy. 2018-04-10 17:33:25 -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
1eab5927a5
selectors: Don't serialize :nth-child(-n) as -1n. 2018-04-07 14:54:23 +02:00
Emilio Cobos Álvarez
48ad41cfb5
Remove useless AsciiExt imports.
These warn with the next Nightly.
2018-03-27 10:30:02 +02:00
Emilio Cobos Álvarez
9fa2618197
style: Add infrastructure to match :host. 2018-03-14 15:10:05 +01:00
Emilio Cobos Álvarez
1654f297ca
style: Tidy a couple things. 2018-03-14 15:10:05 +01:00
Emilio Cobos Álvarez
bbe7ff86da
selectors: Simplify SelectorIter::next. 2018-01-18 23:50:03 +01:00
Simon Sapin
358bac953d Move Visit trait bounds to where they’re needed 2018-01-12 15:44:07 +01:00
Simon Sapin
1a6010f19f Document selectors::Visit 2018-01-12 15:40:16 +01:00
Simon Sapin
c14b766ff5 Rename SelectorMethods to Visit, after its one method. 2018-01-12 15:26:56 +01:00
Simon Sapin
5d920df460 Move PrecomputedHash bounds to where they’re actually needed. 2018-01-12 15:10:47 +01:00
Simon Sapin
5a82a1d455 Reverse the dependency between selectors and malloc_size_of 2018-01-12 15:10:04 +01:00
Emilio Cobos Álvarez
335ca47361
style: Use Default for ExtraStyleData instead of Option. 2018-01-12 12:08:47 +01:00
Emilio Cobos Álvarez
1e27f2883b
selectors: Allow defining an implementation-dependent field in the matching context. 2018-01-12 12:08:38 +01: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
b556ddbf55
style: Don't support a list of selectors in ::slotted yet.
Bug: 1425757
Reviewed-by: xidorn
MozReview-Commit-ID: G0I0gM2sWTh
2017-12-20 15:55:09 +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
bors-servo
c6bf85eca9 Auto merge of #19536 - emilio:compound-selector-list, r=mbrubeck
style: Move the code to parse a list of compound selectors.

I'll need this for ::slotted().

<!-- 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/19536)
<!-- Reviewable:end -->
2017-12-09 17:15:14 -06:00
Emilio Cobos Álvarez
b1f25a2b1f
style: Move the code to parse a list of compound selectors.
I'll need this for ::slotted().
2017-12-09 16:47:37 +01:00
Emilio Cobos Álvarez
bf564e0238
style: Simplify naming and signatures of single-colon pseudo stuff.
Also drop a few FIXMEs while at it, since they look bogus.
2017-12-09 16:12:22 +01:00
Cameron McCormack
523ffd587d selectors: Allow white space in the brackets of an attribute selector. 2017-11-18 14:47:33 +08:00
Emilio Cobos Álvarez
28c04278e1
style: Sprinkle some inline in trivial methods.
These methods are instantiated by the Gecko library, and used during
querySelector, which means that they end up being super-hot in micro-benchmarks.

MozReview-Commit-ID: K1XJb0QyX5a
2017-11-15 13:45:32 +01:00
Simon Sapin
954b2cc3d8
Allow unused imports for AsciiExt in style code.
See #19128, this part is cherry-picked so Gecko can build with rust nightly.
2017-11-09 12:43:23 +01:00
Emilio Cobos Álvarez
e1aa829d67
selectors: Reformat signatures in the parser module.
I was doing something unrelated with this code, and each signature uses a
different style. This PR unifies them.
2017-10-22 16:33:04 +02:00
Matt Brubeck
efc3683cc7 Fix commonmark Markdown warnings in docs, part 1
Fixes warnings from rust-lang/rust#44229 when `--enable-commonmark` is
passed to rustdoc.

This is mostly a global find-and-replace for bare URIs on lines by
themselves in doc comments.
2017-10-17 11:24:57 -07:00
Emilio Cobos Álvarez
f1cc225e97
style: Use left-to-right indices in the invalidator.
This will make easier to create external invalidations, and also makes reasoning
about the invalidator a bit easier.
2017-10-16 08:54:00 +02:00
Simon Sapin
46ea99d54b CSS parsing error types: flatten nested enums somewhat 2017-10-10 13:28:30 +02:00
Simon Sapin
c0f8f15f39 Update to cssparser 0.22 (source location in error types) 2017-10-10 13:28:17 +02:00
Xidorn Quan
ab46a0bbe0 Add support for :scope pseudo-class 2017-10-09 22:04:08 +11:00
Nicholas Nethercote
32548e5312 Overhaul MallocSizeOf and related things.
This patch makes the MallocSizeOf stuff in Stylo work more like the HeapSizeOf
stuff already in Servo, except better. In particular, it adds deriving support
for MallocSizeOf, which will make it easier to improve coverage.

The patch does the following.

- Combines servo/components/style/stylesheets/memory.rs and the heapsize crate
  into a new crate, malloc_size_of.

- Forks the heapsize_derive crate, calling it malloc_size_of, so that
  MallocSizeOf can be derived.

- Both the new crates have MIT/Apache licenses, like heapsize, in case they are
  incorporated into heapsize in the future.

- Renames the methods within MallocSizeOf and the related traits so they are
  more concise.

- Removes MallocSizeOfWithGuard.

- Adds `derive(MallocSizeOf)` to a lot of types, in some cases replacing an
  equivalent or almost-equivalent hand-written implementation.

- Adds stuff so that Rc/Arc can be handled properly.
2017-09-12 12:37:51 +10:00
Nicholas Nethercote
61877b7316 Measure selectors.
This patch adds measurement of Selectors within StyleRule. This requires
exposing the pointer within ThinArc.

The patch also adds measurement of the several CssRule variants, in order to
measure nested CssRules (and PropertyDeclarationBlocks) within them:
DocumentRule, MediaRule, PageRule, SupportsRule.
2017-09-07 15:01:11 +10:00
Josh Matthews
3ae7781b5f Use a 1-element smallvec for selector lists. 2017-09-06 12:13:40 -07:00
Brad Werth
51f3a16e19 Bug 1391169 Part 1: Servo-side change Selector to_css function to handle combinators in between universal selectors.
MozReview-Commit-ID: EyVrSAICPm
2017-09-01 09:03:04 -07:00
Josh Matthews
4016371e1d Report more invalid selectors (bug 1384216). 2017-08-28 17:21:57 -07:00
Josh Matthews
9a7cceb0a1 Report invalid selectors (bug 1384216). 2017-08-28 17:21:07 -07:00
Josh Matthews
408c34a76d Report more specific invalid attribute selectors (bug 1384216). 2017-08-28 17:20:45 -07:00