Commit graph

277 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
1bb6ce2c88
style: Use more CascadeData and less Stylist for XBL stuff.
Just some more uses of Stylist in XBL that can be converted right away.

I'm trying to make XBL not use a Stylist, slowly...
2018-02-12 11:25:24 +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
cd04664fb9
style: Use CascadeFlags for what they're for.
Now that we have an Element around on cascade, we can stop using the cascade
flags mechanism to pass various element-related state, like "is this element the
root", or "should it use the item-based display fixup".

That fixes handwaviness in the handling of those flags from style reparenting,
and code duplication to handle tricky stuff like :visited.

There are a number of other changes that are worth noticing:

 * skip_root_and_item_based_display_fixup is renamed to skip_item_display_fixup:

   TElement::is_root() already implies being the document element, which by
   definition is not native anonymous and not a pseudo-element.

   Thus, you never get fixed-up if your NAC or a pseudo, which is what the code
   tried to avoid, so the only fixup with a point is the item one, which is
   necessary.

 * The pseudo-element probing code was refactored to return early a
   Option::<CascadeInputs>::None, which is nicer than what it was doing.

 * The visited_links_enabled check has moved to selector-matching time. The rest
   of the checks aren't based on whether the element is a link, or are properly
   guarded by parent_style.visited_style().is_some() or visited_rules.is_some().

   Thus you can transitively infer that no element will end up with a :visited
   style, not even from style reparenting.

Anyway, the underlying reason why I want the element in StyleAdjuster is because
we're going to implement an adjustment in there depending on the tag of the
element (converting display: contents to display: none depending on the tag), so
computing that information eagerly, including a hash lookup, wouldn't be nice.
2018-01-23 13:18:54 +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
Bobby Holley
f858ce91e8 Avoid entraining various Debug impls in release builds.
MozReview-Commit-ID: Lp9i9EI5qdU
2018-01-13 09:51:46 -08: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
f3ea248188
style: Remove TNode::set_can_be_fragmented and TNode::can_be_fragmented.
Replace them instead by a computed value flag, the same way as the
IS_IN_DISPLAY_NONE_SUBTREE flag works.
2018-01-04 14:45:54 +01:00
Emilio Cobos Álvarez
bab6077c1c
Revert #19666 since we do create NAC elements and expect them to be inline.
This reverts commit 1970e82b0d, reversing
changes made to e882660ea6.

The reparenting logic is still bogus, but I'll figure out how to deal with that
in a bit.
2017-12-31 17:00:26 +01:00
Emilio Cobos Álvarez
e464f5b020
style: Simplify the skip item based display fixup adjustment.
In practice the only NAC that possibly inherits from a grid or flex container
are pseudos.

In Gecko, if the root element is an item container, custom anon content would
also sometimes incorrectly inherit from that (see bug 1405635), but that's fixed
in Stylo.

We remove the IS_ROOT_ELEMENT blockification from the "skip display fixup"
check, since the root element is never NAC or anything like that, so there's no
need for the check.

This also fixes some reparenting fishiness related to pseudo-elements. We were
only skipping the fixup when reparenting anon boxes, not when reparenting normal
element styles, nor when reparenting other pseudo styles which are not anon
boxes.
2017-12-31 13:57:49 +01:00
Matt Brubeck
3005a26daf style: Use the ? operator for Option 2017-12-09 08:29:53 -08:00
bors-servo
e4cfff8364 Auto merge of #19296 - emilio:bye-unstyled-only, r=heycam
style: Get rid of unstyled children only traversals.

They're useless now, provided we remove the hack to not traverse XBL-bound
elements on initial styling.

Bug: 1418456
Reviewed-by: heycam
MozReview-Commit-ID: AvBVdyF1wb6

<!-- 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/19296)
<!-- Reviewable:end -->
2017-11-20 04:18:30 -06:00
Emilio Cobos Álvarez
b1fecea0aa
style: Get rid of unstyled children only traversals.
They're useless now, provided we remove the hack to not traverse XBL-bound
elements on initial styling.

Bug: 1418456
Reviewed-by: heycam
MozReview-Commit-ID: AvBVdyF1wb6
2017-11-20 08:24:08 +01:00
Emilio Cobos Álvarez
143341a061
style: Collect more debugging info when collecting rules of detached pseudos.
Called Option::unwrap() on a None value is not a helpful crash message.

This will hopefully help figure out what is causing bug 1418856.
2017-11-20 07:43:54 +01:00
Emilio Cobos Álvarez
c414e90b20
style: Inline DomDescendants.
MozReview-Commit-ID: HeBxicDHlzt
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:40 +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
f993693eb2
style: Introduce TNode::is_in_document.
MozReview-Commit-ID: BrhhoOghtUL
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-11-04 11:34:37 +01:00
Emilio Cobos Álvarez
2783297fa9
style: Add a Document::elements_with_id API.
MozReview-Commit-ID: BNtbJp0RI68
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
e7149f15d7
style: Inline DomDescendants.
MozReview-Commit-ID: HeBxicDHlzt
2017-11-03 14:18:48 +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
be1ba90284
style: Introduce TNode::is_in_document.
MozReview-Commit-ID: BrhhoOghtUL
2017-11-03 14:18:43 +01:00
Emilio Cobos Álvarez
db65c2d346
style: Add a Document::elements_with_id API.
MozReview-Commit-ID: BNtbJp0RI68
2017-11-03 13:49:15 +01:00
Emilio Cobos Álvarez
480d2267e6
style: Don't force ComputedValues to derive Debug.
The code that uses it is of dubious utility, fwiw, but some of it is used on
Servo, so I'll kill that separately.

Bug: 1412486
Reviewed-by: xidorn
MozReview-Commit-ID: KauvXX32zLM
2017-10-31 17:30:52 +01:00
Bastien Orivel
29b4eec141 Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
Emilio Cobos Álvarez
0df912be93
style: Make style sharing look at XBL / Shadow DOM rules.
Bug: 1412251
Reviewed-by: bz
MozReview-Commit-ID: II6lk6OmSZU
2017-10-28 12:43:43 +02:00
Gecko Backout
cda9d186c1 Backed out changeset fc813bf68348 for failing reftest layout/reftests/bugs/272646-1.xul on OS X. r=backout
Backs out https://github.com/servo/servo/pull/19045
2017-10-28 08:08:47 +00:00
bors-servo
592c513c28 Auto merge of #19045 - emilio:shadow-style-sharing, r=bzbarsky
style: Make style sharing look at XBL / Shadow DOM rules.

Bug: 1412251
Reviewed-by: bz
MozReview-Commit-ID: II6lk6OmSZU

<!-- 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/19045)
<!-- Reviewable:end -->
2017-10-27 19:14:20 -05:00
Emilio Cobos Álvarez
4b43b7c7f8
style: Make style sharing look at XBL / Shadow DOM rules.
Bug: 1412251
Reviewed-by: bz
MozReview-Commit-ID: II6lk6OmSZU
2017-10-28 02:13:59 +02: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
bfa7cd7d9e
style: Add TNode::owner_doc. 2017-10-26 13:03:11 +02:00
Emilio Cobos Álvarez
4d4fa69018
style: Introduce a TDocument trait.
This will be useful for querySelector optimizations.
2017-10-26 12:49:13 +02:00
Emilio Cobos Álvarez
6c796b50ec
style: Remove PresentationalHintsSynthesizer.
This is not really an useful abstraction, and I never knew how to spell it.
2017-10-26 11:45:28 +02:00
Emilio Cobos Álvarez
4f997bf333
style: Add methods to iterate a subtree in preorder.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-23 08:25:08 +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
Gecko Backout
11c64178d8 Backed out changeset e64e659c077d: servo PR #18809 and revendor for reftest failures, e.g. in layout/reftests/bugs/392435-1.html. r=backout on a CLOSED TREE
Backs out https://github.com/servo/servo/pull/18809
2017-10-19 21:26:51 +00:00
Bastien Orivel
e8e2d0a4b2 Update bitflags to 1.0 in every servo crate
It still needs dependencies update to remove all the other bitflags
versions.
2017-10-19 15:01:17 +02:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`.
`malloc_size_of` is better -- it handles various cases that `heapsize` does not
-- so this patch changes Servo to use `malloc_size_of`.

This patch makes the following changes to the `malloc_size_of` crate.

- Adds `MallocSizeOf` trait implementations for numerous types, some built-in
  (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`).

- Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't
  support that operation.

- For `HashSet`/`HashMap`, falls back to a computed estimate when
  `enclosing_size_of_op` isn't available.

- Adds an extern "C" `malloc_size_of` function that does the actual heap
  measurement; this is based on the same functions from the `heapsize` crate.

This patch makes the following changes elsewhere.

- Converts all the uses of `heapsize` to instead use `malloc_size_of`.

- Disables the "heapsize"/"heap_size" feature for the external crates that
  provide it.

- Removes the `HeapSizeOf` implementation from `hashglobe`.

- Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of`
  doesn't derive those types, unlike `heapsize`.
2017-10-18 22:20:37 +11:00
Emilio Cobos Álvarez
96b71754c3
style: Remove unused TNode::is_in_doc.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-17 08:57:37 +02:00
Emilio Cobos Álvarez
a11d268468
style: Refactor children handling.
Moving traversal_children away from TNode I can make TNode trivial enough, in
order to share a QuerySelector implementation between Servo and Gecko.
2017-10-17 08:57:35 +02:00
Emilio Cobos Álvarez
bfe230f3ed
style: Remove the ElementExt trait.
It is likely it's the most useless trait ever existing.
2017-10-16 13:30:22 +02:00
Emilio Cobos Álvarez
c60b8288bc
style: Check transitions per longhand to know which transitions to keep.
This fixes the fishy TransitionProperty mapping which I complained about in my
previous refactor.

Turns out that those properties could only be longhands, and thus the expansion
we did before that (and which I removed) was correct.

This fixes the bug by moving back to the previous correct behavior but using the
correct types.

The optimization to avoid creating a HashSet if we're transitioning all
properties or had no existing transition is removed since now we're creating a
LonghandIdSet, which is cheap, and that was only a performance optimization.
2017-10-06 10:02:06 +02:00
Manish Goregaokar
8bce37e6ba stylo: use FnvHashMap everywhere, remove default HashMap construction methods 2017-10-03 14:10:31 -07:00
Emilio Cobos Álvarez
3215e36b5b
style: Cleanup the animated value setup.
We have three different enums to represent slightly different things. Reuse them
properly, and kill some code in the animated_properties module while at it.

MozReview-Commit-ID: 5ZAly8f4lWy
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-29 13:20:50 +02:00
Emilio Cobos Álvarez
19d34b96e5
style: Fix various issues with XBL rule matching.
We were using the wrong MatchingMode and flags setter just because we didn't
bother threading them down.

This patch fixes the issue seen with the video controls.

MozReview-Commit-ID: Il1WOzRDxI1
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-09-27 15:29:04 +02:00
Emilio Cobos Álvarez
e3c58df155
style: Remove UnsafeNode.
No longer needed since a while ago.
2017-09-25 01:58:52 +02:00
Emilio Cobos Álvarez
bd314747da
style: Implement the body text color quirk in a more straight-forward way.
This avoids grabbing the document when values that inherit from the body,
whatever that means, aren't under the body.

In that case we'll get a semi-random value, but that's also mishandled by Gecko
anyways (and probably Blink, though haven't tested), and doesn't really make
much sense.
2017-09-16 02:44:56 +02:00
Emilio Cobos Álvarez
d799dd95eb
style: Trivially reformat a few TElement declarations. 2017-09-16 02:44:53 +02:00
Gecko Backout
558e357216 Backed out changeset 67769dac78c4 for busting builds CLOSED TREE
Backs out https://github.com/servo/servo/pull/18519
2017-09-15 20:47:46 +00:00
Emilio Cobos Álvarez
8c3c56909e
style: Implement the body text color quirk in a more straight-forward way.
This avoids grabbing the document when values that inherit from the body,
whatever that means, aren't under the body.

In that case we'll get a semi-random value, but that's also mishandled by Gecko
anyways (and probably Blink, though haven't tested), and doesn't really make
much sense.
2017-09-15 10:34:42 +02:00