Commit graph

116 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
9fa2618197
style: Add infrastructure to match :host. 2018-03-14 15:10:05 +01:00
Emilio Cobos Álvarez
ef4ea7cc49
style: Separate the XBL and shadow dom styling bits.
Bug: 1441022
Reviewed-by: xidorn
MozReview-Commit-ID: 2W0BmZ8wWXg
2018-03-07 15:42:28 +01:00
Emilio Cobos Álvarez
13f61a6e5f
style: Indent properly a couple more functions. 2018-02-24 23:23:16 +01:00
Emilio Cobos Álvarez
f2efd04a5d
style: Make Element::id not clone the attribute. 2018-02-24 22:45:43 +01:00
Emilio Cobos Álvarez
98c9292ecb
style: Remove get_ prefix from get_state and get_id. 2018-02-24 22:45:42 +01: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
5e64cb3516
style: Make XBL / Shadow DOM use something more light-weight than a Stylist.
It's just a struct aggregating stylesheets + CascadeData, with a quirks_mode
parameter because XBL sucks so bad.

Bug: 1436059
Reviewed-by: xidorn
MozReview-Commit-ID: 7q99tSNXo0K
2018-02-16 13:42:36 +01:00
Emilio Cobos Álvarez
4d9ce6b880
style: Temporarily use OrderMap on Gecko.
This will allow us to discard std hash map as a source of crashes.
2018-01-31 16:29:35 +01:00
Emilio Cobos Álvarez
61e60a87e5
selectors: Never match ::slotted on <slot>s.
This fixes the test from https://github.com/w3c/web-platform-tests/pull/9212 in
Gecko.
2018-01-27 17:57:17 +01:00
Emilio Cobos Álvarez
657d8b8e31
style: Look at the snapshots when invalidating due to stylesheet changes.
Otherwise removal of stylesheets may get out of sync with other DOM changes, and
we may fail to invalidate the style of the affected elements.

Bug: 1432850
Reviewed-by: bz
MozReview-Commit-ID: DrMTgLzQcnk
2018-01-27 02:34:27 +01:00
Emilio Cobos Álvarez
8e25c9e674
style: Track the visited-handling-mode on the MatchingContext.
Instead of on the stack.

This fixes bugs where we're not passing the value around correctly, like from
::-moz-any.

This is a fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1431539.
2018-01-19 13:22:37 +01:00
Emilio Cobos Álvarez
e4f08ee2bb
selectors: Add a MatchingContext::nest function, make nesting_level private. 2018-01-19 12:40:17 +01:00
Emilio Cobos Álvarez
665690bba6
style: Hook in the document invalidator.
Bug: 1409672
Reviewed-by: xidorn
MozReview-Commit-ID: EoSMrYPS7dl
2018-01-17 18:03:16 +01:00
Emilio Cobos Álvarez
7bdeeaa702
style: Fix slotted invalidation.
This is a partial revert of
ce1d8cd232

If you're in a shadow tree, you may not be slotted but you still need to look at
the slotted rules, since a <slot> could be a descendant of yours.

Just use the same invalidation map everywhere, and remove complexity.

This means that we can do some extra work while trying to gather invalidation
if there are slotted rules, but I don't think it's a problem.

The test is ported from https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/fast/css/invalidation/slotted.html?l=1&rcl=58d68fdf783d7edde1c82a642e037464861f2787

Curiously, Blink fails the test as written, presumably because they don't flush
styles from getComputedStyle correctly (in their test they do via
updateStyleAndReturnAffectedElementCount), due to <slot>s not being in the flat
tree in their implementation.

Bug: 1429846
Reviewed-by: heycam
MozReview-Commit-ID: 6b7BQ6bGMgd
2018-01-17 14:35:19 +01:00
Xidorn Quan
d0fd92221c Optimize selector matching for some common cases. 2018-01-17 09:46:57 +11:00
Simon Sapin
c14b766ff5 Rename SelectorMethods to Visit, after its one method. 2018-01-12 15:26:56 +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
9a1f20f1e8
style: Add a comment about figuring out what the best way to deal with XBL is. 2018-01-12 12:08:46 +01:00
Emilio Cobos Álvarez
a69d229615
style: Use a more compact form for should_process_descendants. 2018-01-12 12:08:43 +01:00
Emilio Cobos Álvarez
5b7d9eb94a
style: Add a document state invalidator. 2018-01-12 12:08:42 +01:00
Emilio Cobos Álvarez
2c1d72ad1a
style: Track document state dependencies in the invalidation maps. 2018-01-12 12:08:41 +01:00
Emilio Cobos Álvarez
14661e470f
style: Add a couple FIXMEs I've noticed while working on this.
::slotted is hard.
2018-01-12 12:08:40 +01:00
Emilio Cobos Álvarez
268f0f75b9
style: Factor out a few invalidation functions that are going to be shared soon. 2018-01-11 14:49:31 +01:00
Emilio Cobos Álvarez
b91efadd8d
style: Move invalidation::element::collector to invalidation::element::state_and_attributes.
Since it's what that file is about.
2018-01-11 14:49:31 +01:00
Emilio Cobos Álvarez
ce1d8cd232
style: Make invalidation state also be with the ::slotted rules.
MozReview-Commit-ID: GYmsXYvL9vj
2018-01-09 14:26:03 +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
040379208e
style: Implement GeckoElement::assigned_slot.
This allows to selector-match ::slotted, though we still don't parse it.

Bug: 1425755
Reviewed-by: heycam
MozReview-Commit-ID: ItELHkf2PMl
2018-01-08 19:01:41 +01:00
Matt Brubeck
3005a26daf style: Use the ? operator for Option 2017-12-09 08:29:53 -08:00
Emilio Cobos Álvarez
3119db724a
selectors: Simplify :visited by only using the "is inside link" information.
Right now we go through a lot of hoops to see if we ever see a relevant link.

However, that information is not needed: if the element is a link, we'll always
need to compute its visited style because its its own relevant link.

If the element inherits from a link, we need to also compute the visited style
anyway.

So the "has a relevant link been found" is pretty useless when we know what are
we inheriting from.

The branches at the beginning of matches_complex_selector_internal were
affecting performance, and there are no good reasons to keep them.

I've verified that this passes all the visited tests in mozilla central, and
that the test-cases too-flaky to be landed still pass.
2017-12-08 05:35:12 +01:00
Emilio Cobos Álvarez
2beb441d04
style: Bail out from invalidation if we're the root and got tons of descendant invalidations.
Bug: 1420741
Reviewed-by: heycam
MozReview-Commit-ID: 4Kja20Ep9qD
2017-11-30 12:28:59 +01:00
bors-servo
95aac490a5 Auto merge of #19426 - emilio:cache-invalidation, r=xidorn
style: Require an nth-index cache for invalidation.

<!-- 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/19426)
<!-- Reviewable:end -->
2017-11-29 16:36:48 -06:00
Emilio Cobos Álvarez
02ad6d3d90
style: Require an nth-index cache for invalidation. 2017-11-29 21:22:29 +01:00
Emilio Cobos Álvarez
dceda4465c
style: Log a bit more information about invalidation collection. 2017-11-29 19:23:53 +01:00
Michael Wilson
10f3ef42bb style: :dir() pseudo class now represented by enum
Fixes #19195
2017-11-15 18:12:44 -08:00
Emilio Cobos Álvarez
afb09536f9
style: Remove some unneeded indirections in the invalidation code.
MozReview-Commit-ID: 5h5SE3ieC0A
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:39 +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
931aae9760
style: Remove some unneeded indirections in the invalidation code.
MozReview-Commit-ID: 5h5SE3ieC0A
2017-11-03 14:18:47 +01:00
Bastien Orivel
29b4eec141 Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
bors-servo
26279064eb Auto merge of #19060 - emilio:invalidation-fishy, r=nox
style: Fix some fishiness in the invalidation code.

See individual commits for details, I think this is not observable.

<!-- 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/19060)
<!-- Reviewable:end -->
2017-10-30 07:39:00 -05:00
Emilio Cobos Álvarez
f060cbb38c
style: Properly forward ElementWrapper::blocks_ancestor_combinators.
Not doing it is buggy. I think the only outcome of it is that we may
over-invalidate, so it's probably not a huge deal, but worth doing it.
2017-10-30 12:40:25 +01:00
Emilio Cobos Álvarez
bea79aabff
style: Implement ElementWrapper::pseudo_element_originating_element in terms of its TElement implementation.
This matches right now, but it may not in the future.
2017-10-30 12:40:24 +01:00
Emilio Cobos Álvarez
7861ec1d5b
style: Make the SelectorMap API slightly nicer. 2017-10-30 12:33:44 +01:00
Manish Goregaokar
b118ba72d0 Revert "Diagnostic map semantics."
This reverts commit f5c5be00a7.
2017-10-23 13:51:08 -07: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
7f5536d5bc
style: Ensure invalidated_self is called at most once per element.
MozReview-Commit-ID: 1M0WuAduqun
2017-10-23 08:22:51 +02:00
Emilio Cobos Álvarez
bd2a82334b
style: Don't look at user and author rules if the element can't be affected by them.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:50 +02:00
Emilio Cobos Álvarez
1b32709d95
style: avoid selector refcount churn during invalidation.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:49 +02:00
Emilio Cobos Álvarez
258efb70df
style: Move MatchingContext to the InvalidationProcessor.
This avoids threading the quirks mode and nth-index cache around, and prevents
having to thread even more arguments down for the querySelector stuff (at least
VisitedHandlingMode and the style scope).

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:48 +02:00
Emilio Cobos Álvarez
5ac0f5121e
style: Add a way to add self-invalidations to the initial collection.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:47 +02:00
Emilio Cobos Álvarez
191c39f28c
style: Make invalidations with offset zero "universal" invalidations.
We'll use this for querySelector / querySelectorAll.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:22:46 +02:00