Commit graph

36 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
e3009a4de9
style: Implement shadow part forwarding (minus invalidation).
Some of the stuff, in particular inside GeckoBindings stuff should be
refactored to be less ugly and duplicate a bit less code, but the rest of the
code should be landable as is.

Some invalidation changes are already needed because we weren't matching with
the right shadow host during invalidation (which made existing ::part() tests
fail).

Pending invalidation work:

 * Making exportparts work right on the snapshots.
 * Invalidating parts from descendant hosts.

They're not very hard but I need to think how to best implement it:

 * Maybe get rid of ShadowRoot::mParts and just walk DOM descendants in the
   Shadow DOM.

 * Maybe implement a ElementHasExportPartsAttr much like HasPartAttr and use
   that to keep the list of elements.

 * Maybe invalidate :host and ::part() together in here[1]

 * Maybe something else.

Opinions?

[1]: https://searchfox.org/mozilla-central/rev/131338e5017bc0283d86fb73844407b9a2155c98/servo/components/style/invalidation/element/invalidator.rs#561

Differential Revision: https://phabricator.services.mozilla.com/D53730
2019-11-30 20:45:03 +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
Pyfisch
cb07debcb6 Format remaining files 2018-11-06 22:30:31 +01:00
Emilio Cobos Álvarez
a3fcfb6435
style: Add a fast path for querySelector{,All} when we have classes or tags in the rightmost compound.
Before this patch we were only optimizing the case of a single selector, which
is fine, but not enough to catch ones like .foo .bar or so.

This patch allows us to optimize classes and tags in the rightmost compound,
while keeping the current optimization for #id selectors.

Need to profile this, but code-wise should be ready for review.

Differential Revision: https://phabricator.services.mozilla.com/D9351
2018-11-05 12:29:10 +01:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
38cbada278
style: Optimize QuerySelector in shadow trees.
Pretty much the same setup we have for document.

We have the awkwardness of having to check containing shadow manually for
ShadowRoot because it's not available in TNode (and making it available added a
bit more complexity that wasn't worth it IMO).

Bug: 1464428
Reviewed-by: xidorn
MozReview-Commit-ID: CqOh0sLHf6o
2018-05-28 16:02:31 +02: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
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
7ab4b21bc3
selectors: Remove the get_ prefix from get_local_name and get_namespace. 2018-02-24 22:45:38 +01:00
Emilio Cobos Álvarez
b26f3280d2
style: Add invalidation support for ::slotted().
Bug: 1424607
Reviewed-by: heycam
MozReview-Commit-ID: 8pIVUx27o7x
2018-01-09 14:26:02 +01:00
Emilio Cobos Álvarez
f32f09656b
style: Allow disabling invalidation-based querySelector from C++
Rust compile times are hard.

MozReview-Commit-ID: 9Xhtf7f3Vzv
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:40 +01:00
Emilio Cobos Álvarez
f0999365e2
style: Bump the selector length heuristic.
A selector with combinators has to have length > 2 (a component, a combinator,
another component).

MozReview-Commit-ID: GvMEbRdOVi2
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:39 +01:00
Emilio Cobos Álvarez
72ec0392a4
style: Add a query-selector fast path for #id foo.
MozReview-Commit-ID: DkrLcfQLPga
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:38 +01:00
Emilio Cobos Álvarez
dbfc1eb3e0
style: Extract a bit better the logic for finding elements with an ID under a subtree.
MozReview-Commit-ID: Hj9yxBk1OvS
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:38 +01:00
Emilio Cobos Álvarez
0032d04bcf
style: Optimize all ids in the rightmost compound selector.
This is effectively the same optimization Gecko has now.

MozReview-Commit-ID: 21HrjpHdpOz
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:38 +01:00
Emilio Cobos Álvarez
60aec43dad
style: Add a fast path for querySelector/All with a single id selector using the doc ID table.
MozReview-Commit-ID: JVnDO890kn4
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:37 +01:00
Emilio Cobos Álvarez
93272f46a5
style: Move the single simple selector optimizations to a different function.
MozReview-Commit-ID: EEM3AzW2A9s
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:36 +01:00
Gecko Backout
8f8fd517ed Backed out changeset dbd300f4d75b for build bustage. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/19108
2017-11-03 23:56:42 +00:00
Emilio Cobos Álvarez
bfabd9f855
style: Allow disabling invalidation-based querySelector from C++
Rust compile times are hard.

MozReview-Commit-ID: 9Xhtf7f3Vzv
2017-11-03 14:18:48 +01:00
Emilio Cobos Álvarez
9a378a89b4
style: Bump the selector length heuristic.
A selector with combinators has to have length > 2 (a component, a combinator,
another component).

MozReview-Commit-ID: GvMEbRdOVi2
2017-11-03 14:18:46 +01:00
Emilio Cobos Álvarez
eea8ecd345
style: Add a query-selector fast path for #id foo.
MozReview-Commit-ID: DkrLcfQLPga
2017-11-03 14:18:45 +01:00
Emilio Cobos Álvarez
ea8f493ae6
style: Extract a bit better the logic for finding elements with an ID under a subtree.
MozReview-Commit-ID: Hj9yxBk1OvS
2017-11-03 14:18:44 +01:00
Emilio Cobos Álvarez
b03b59b218
style: Optimize all ids in the rightmost compound selector.
This is effectively the same optimization Gecko has now.

MozReview-Commit-ID: 21HrjpHdpOz
2017-11-03 14:18:44 +01:00
Emilio Cobos Álvarez
1fd7269949
style: Add a fast path for querySelector/All with a single id selector using the doc ID table.
MozReview-Commit-ID: JVnDO890kn4
2017-11-03 14:18:43 +01:00
Emilio Cobos Álvarez
c3876a42a8
style: Move the single simple selector optimizations to a different function.
MozReview-Commit-ID: EEM3AzW2A9s
2017-11-03 13:49:15 +01:00
Emilio Cobos Álvarez
dd5cd29a61
style: Introduce TDocument::is_html_element and TDocument::quirks_mode.
This allows some code to read a bit nicer, and stop passing down quirks mode to
querySelector / querySelectorAll.
2017-10-26 13:22:31 +02:00
Emilio Cobos Álvarez
644b502b0d
style: Ensure QuerySelector only processes the light tree.
MozReview-Commit-ID: 7Nw1SEuWNaC
2017-10-23 08:27:50 +02:00
Emilio Cobos Álvarez
dd7196949f
style: Don't use the invalidation machinery unless we may get some benefit from it.
MozReview-Commit-ID: 8Wpn2bjuHBQ
2017-10-23 08:27:49 +02:00
Emilio Cobos Álvarez
d73af807b7
style: Add a few QuerySelector fast-paths.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:27:46 +02:00
Emilio Cobos Álvarez
2274fd7ef3
style: Refactor querySelector to be generic over the query type, and implement a tree-walking variant of it.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:25:09 +02:00
Emilio Cobos Álvarez
6d78e9ba54
style: Add a very simple invalidation-based querySelector.
MozReview-Commit-ID: Fimc8tz4OWX
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:52 +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
f64f8b8be2
style: Share code for Element::Closest. 2017-10-13 17:21:31 +02:00
Emilio Cobos Álvarez
9e6c49d479
style: Share code for Element::Matches. 2017-10-13 17:21:26 +02:00