Commit graph

91 commits

Author SHA1 Message Date
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
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
bors-servo
fe16c1d5c3 Auto merge of #18809 - Eijebong:bitflags, r=nox
Update bitflags to 1.0 in every servo crate

It still needs dependencies update to remove all the other bitflags
versions.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because it's a dependency update

<!-- 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/18809)
<!-- Reviewable:end -->
2017-10-19 10:35:08 -05: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
Emilio Cobos Álvarez
b0e54968ec
style: Make MatchingContext generic over SelectorImpl.
This will help Xidorn implement tree pseudos, and in general makes sense,
allowing to put specific matching data in a selectors implementation.
2017-10-19 11:33:13 +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
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
7c2265360f
style: Stop threading the ElementData around the invalidator. 2017-10-17 08:57:34 +02:00
Emilio Cobos Álvarez
40d9cd99b5
style: Don't require a full SharedStyleContext for TreeStyleInvalidator.
We only use it to get the quirks mode, and a shared style context is a pretty
heavy-weight struct.

Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-10-17 08:57:33 +02: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
Emilio Cobos Álvarez
dcb8c2fdc7
style: Properly use nesting_level in the invalidation code. 2017-10-14 17:03:36 +02:00
Emilio Cobos Álvarez
11485edc9e
style: Hide LocalMatchingContext.
This type is a lot of complexity related to a very specific thing such as the
hover and active quirk.

Instead of that, move `nesting_level` to `MatchingContext`, and simplify all
this computing whether the quirk applies upfront, for each complex selector we
test.

This is less error-prone, and also allows simplifying more stuff in a bit.
2017-10-14 17:03:35 +02:00
Emilio Cobos Álvarez
e447f819a2
style: Make InvalidationProcessor methods be &mut self.
This would allow querySelector / querySelectorAll to mutate the list of matched
nodes as it sees fit.
2017-10-13 12:17:02 +02:00
Emilio Cobos Álvarez
9034e6a732
style: Add a way to skip the "invalidation on eager pseudo invalidates self" bit. 2017-10-13 12:17:02 +02:00
Emilio Cobos Álvarez
ecdb10ef5c
Be more precise in should_process_descendants. 2017-10-13 12:17:02 +02:00
Emilio Cobos Álvarez
9e61c1962b
style: Unify invalidated_child with invalidated_descendants.
I think invalidated_descendants was buggy, and this fixes it.
2017-10-13 12:17:01 +02:00
Emilio Cobos Álvarez
557353c1f6
style: Move the bounds up in InvalidationProcessor. 2017-10-13 12:17:00 +02:00
Emilio Cobos Álvarez
a5e2f2c76c
style: Isolate all the restyling related logic in the invalidator in an InvalidationProcessor trait.
Ditto, no change in behavior.
2017-10-13 12:17:00 +02:00
Emilio Cobos Álvarez
b9b3e592dd
style: Split the invalidation collection from the invalidator step.
This is the first step in reusing the invalidation machinery for other stuff,
potentially including QuerySelector / QuerySelectorAll.
2017-10-13 12:16:59 +02:00
Emilio Cobos Álvarez
5723cf7d13
style: Tweak the quirks mode while collecting invalidations in XBL stuff. 2017-10-11 11:12:58 +02:00
Emilio Cobos Álvarez
bb6ff9575d
style: Store the quirks mode directly in InvalidationCollector. 2017-10-11 11:10:39 +02:00
Bobby Holley
f5c5be00a7 Diagnostic map semantics.
MozReview-Commit-ID: C0a5g6xMPY0
2017-10-07 12:54:15 -07:00
Bobby Holley
15b866d8de Revert #18668 - Add mprotect diagnostics for HashMap crash 2017-10-03 12:44:26 -07:00
Emilio Cobos Álvarez
aba1cf8cd5
style: Allow passing an nth-index-cache to the invalidation code. 2017-10-02 21:02:28 +02:00
Bobby Holley
98f370130d Semantics for ProtectedHashMap.
MozReview-Commit-ID: K0m65uZi7iw
2017-09-28 14:13:01 -07:00
Bobby Holley
438740b912 Implement an nth-index cache.
MozReview-Commit-ID: Ee0um3QXkxl
2017-09-21 15:25:38 -07:00