Commit graph

95 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
9eaadc6860 style: Shutdown Servo's thread-pool in leak-checking builds, leak the atom table elsewhere.
Differential Revision: https://phabricator.services.mozilla.com/D44217
2019-09-12 22:34:16 +02:00
bors-servo
0d5c6a0c37
Auto merge of #23532 - est31:unused_code_removal_4, r=emilio
Remove unused code (4/4)

<!-- Please describe your changes on the following line: -->

Fourth and final PR in a series of PRs to remove unused/dead code from servo, powered by an (upcoming) tool of mine. Please take a look and tell me if you want to keep something.

* First PR: #23477
* Second PR: #23498
* Third PR: #23499

Shortstat of the combined PR series:
```
47 files changed, 7 insertions(+), 805 deletions(-)
```

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they only remove dead code

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/23532)
<!-- Reviewable:end -->
2019-06-07 20:27:53 -04:00
est31
642b7c3ea1 Remove unused code from selector and style crates 2019-06-07 15:14:21 +02:00
Emilio Cobos Álvarez
9a9a4e12d5 style: Add refcount logging to servo_arc.
Differential Revision: https://phabricator.services.mozilla.com/D32173
2019-06-04 01:03:53 -04:00
Emilio Cobos Álvarez
e5b5cd78a9 style: Remove support for XBL resources.
So much unsound code going away :-)

Differential Revision: https://phabricator.services.mozilla.com/D28380
2019-05-07 12:55:29 +02:00
Brian Birtles
71d9fe5d60 style: Don't share styles when an element has animations applied to it.
We already avoid putting styles in the shared style cache for an element that
has animations[1] but if we are doing the initial style of two siblings where
the _second_ has animations applied, there is nothing to stop us from trying to
share with the first (un-animated) element. This patch adds a check to prevent
sharing in that case since sharing style between animated elements is unsound
for the reasons described in [1].

A number of tests including:

  testing/web-platform/tests/web-animations/animation-model/animation-types/visibility.html

will fail without this fix once we remove the style flush from
KeyframeEffect::SetKeyframes later in this patch series.

[1] https://searchfox.org/mozilla-central/rev/6e3cc153566f5f288ae768a2172385b8436d61dd/servo/components/style/sharing/mod.rs#597

Differential Revision: https://phabricator.services.mozilla.com/D18913
2019-02-23 21:02:53 -08:00
Simon Sapin
be69f9c3e6 Rustfmt has changed its default style :/ 2018-12-28 13:17:47 +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
Manish Goregaokar
84ca681a78
servo_arc cleanups for publishing.
Differential Revision: https://phabricator.services.mozilla.com/D6034
2018-09-18 11:39:54 +02:00
chansuke
8dab4d659a
Format style component. 2018-09-09 16:24:45 +02:00
Emilio Cobos Álvarez
3b90ddd5d1
style: Fix the broken invariants of the rule node cache.
We were spuriously reframing the <shadow> because it initially shared style with
the <br>, which ended up being display: none, while the <shadow> should've been
display: contents from the beginning.

lookup_by_rules seems pretty prone to obscure bugs, and also it's pretty
complex... Probably we should try to get rid of it, I'm unconvinced that it's
worth it.

Even with that, in a normal restyle the <details> wouldn't have ended up with a
style. It of course never had it before the reframe because the <shadow> was
display: none, but that doesn't mean it shouldn't have gotten one, since we
detected we needed to go through kids in:

  https://searchfox.org/mozilla-central/rev/6eea08365e7386a2b81c044e7cc8a3daa51d8754/servo/components/style/matching.rs#500

That code did happen, but since it's an animation-only restyle, we don't look at
unstyled stuff.

That looks somewhat fishy, but I guess for now it's fine as long as display
isn't animatable.

Bug: 1469076
Reviewed-by: heycam
MozReview-Commit-ID: B6NMSTNOKgK
2018-06-23 20:34:50 +02:00
Emilio Cobos Álvarez
5507d53611
style: Make element-backed pseudos inherit from NAC subtree roots and other NAC inherit from their parents.
Currently, NAC always inherits from the closest non-NAC ancestor element,
regardless of whether it is for an element-backed pseudo or not.

This patch changes the inheritance so that for element-backed pseudos, we
inherit from the closest native anonymous root's parent, and for other NAC we
inherit from the parent.

This prevents the following two issues and allows us to remove the
NODE_IS_NATIVE_ANONYMOUS flag:

 * Avoiding inheriting from the non-NAC ancestor in XBL bindings bound to NAC.

   - This is no longer a problem since we apply the rule only if we're a
     pseudo-element, and all pseudo-elements are in native anonymous subtrees.

   - This also allows to remove the hack that propagates the
     NODE_IS_NATIVE_ANONYMOUS flag from the ::cue pseudo-element from
     BindToTree.

 * Inheriting from the wrong thing if we're a nested NAC subtree.

   - We no longer look past our NAC subtree, with the exception of
     ::-moz-number-text's pseudo-elements, for which we do want to propagate
     ::placeholder to.

A few rules from forms.css have been modified because they're useless or needed
to propagate stuff to the anonymous form control in input[type="number"] which
previously inherited from the input itself.

Bug: 1460382
Reviewed-by: heycam
MozReview-Commit-ID: IDKYt3EJtSH
2018-06-02 12:07:07 +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
bd70c405b4
style: Rename StyleContext to ComputedStyle.
Bug: 1447483
Reviewed-by: jwatt
MozReview-Commit-ID: KATZ6DkmpVY
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-03-22 18:04:29 +01:00
Emilio Cobos Álvarez
9364cd21b8
style: Don't share style with an element that has a different proto binding than us.
See the lengthy comment about why... XBL sucks.

MozReview-Commit-ID: 8UgeJAVkj6a
2018-03-12 21:47:47 +01:00
Emilio Cobos Álvarez
c338745b17
style: Allow to share style across elements with similar XBL bindings. 2018-03-12 21:47:46 +01:00
Emilio Cobos Álvarez
a37bb8e6aa
style: Reorder style sharing checks so that cheaper and broader ones are earlier. 2018-03-08 22:50:34 +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
8d34aacb3b
style: Remove some useless explicit dereferencing. 2018-02-24 22:45:39 +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
3595c98411
style: Use Option::get_or_insert_with.
Less unwraps is better.
2018-01-10 03:39:29 +01:00
Emilio Cobos Álvarez
76257ae4df
style: Add a necessary check for style sharing between ::slotted() nodes.
If two elements are assigned to different slots, even within the same shadow
root, they could match different rules, due to the slot being assigned to yet
another slot in another shadow root.

MozReview-Commit-ID: CfZJCVxIQzM
2018-01-09 14:26:03 +01:00
Matt Brubeck
99c2db0549 Update to uluru 0.2 and arrayvec 0.4 2017-12-07 10:05:38 -08:00
Emilio Cobos Álvarez
0bcd36838d
style: Remove redundant style sharing check.
We check that a few lines before calling test_candidate.
2017-11-30 17:26:45 +01:00
Emilio Cobos Álvarez
47b02658ec
style: Move lru_cache to its own crate.
One less crate pointlessly in components/.
2017-11-15 16:18:11 +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
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
Bobby Holley
438740b912 Implement an nth-index cache.
MozReview-Commit-ID: Ee0um3QXkxl
2017-09-21 15:25:38 -07:00
Bobby Holley
48466bf876 Introduce an NthIndexCache type and pipe it from ThreadLocalStyleContext to MatchingContext.
Some future refactoring here to pass fewer things as parameters would be nice.
2017-09-20 23:22:38 -07:00
Bobby Holley
05c03d5104 Hoist lookup() into lru_cache.
MozReview-Commit-ID: F5FbKFqpXEh
2017-09-20 23:22:33 -07:00
Bobby Holley
13a3cf27a8 LRUCache::new -> LRUCache::default.
MozReview-Commit-ID: KouOaYTluRx
2017-09-20 23:22:27 -07:00
Bobby Holley
8b6c5988b5 Hoist the LRU cache into its own crate to share it with selectors. 2017-09-20 23:22:20 -07:00
Bobby Holley
4abe8002e9 Bug 1401317 - Make second pass sharing sensitive to DISABLE_STYLE_SHARING_CACHE. r=emilio
MozReview-Commit-ID: 8U0xekMHGg8
2017-09-19 23:09:12 -07:00
Emilio Cobos Álvarez
a5842165d9
style: Assert we don't try to share against ourselves. 2017-09-18 04:57:53 +02:00
Emilio Cobos Álvarez
891bc7d174
style: Massage the resolver code so it's cleaner and prevents the problem.
This way all the borrows stay in the sharing code, and prevents an extra borrow
on a cache hit, which is not a big deal but nice.
2017-09-18 04:57:50 +02:00
Emilio Cobos Álvarez
36fed07b1c
style: avoid testing against ourselves in lookup_for_rules.
There's a path in finish_restyle, where we can recascade a style for a given
element, in get_after_change_style.

I haven't been able to construct a test-case for this, but this is the only
coherent story I have for crashes like:

  https://crash-stats.mozilla.com/report/index/bcdfe629-ca1f-4e4d-aa17-27f890170917#tab-details
2017-09-18 03:23:32 +02:00
Bobby Holley
703a5c93d0 Undo #18497 in the MatchAndCascade case.
It's easy to construct examples where not inserting in those cases causes performance
to get worse (for example, any long list of siblings that match the same selectors
while having some non-effectual differences in LocalName/Class/Id/etc). And the LRU
nature of the cache already does the right thing of pruning non-useful entries.

Fixing this causes several hundred more sharing hits on wikipedia.

MozReview-Commit-ID: L7W8vcMnHaq
2017-09-15 23:21:00 -07:00
Matt Brubeck
286888009f Make LRUCache use a linked list to reduce memmoves.
https://bugzilla.mozilla.org/show_bug.cgi?id=1398957
2017-09-14 11:33:02 -07:00
Emilio Cobos Álvarez
158aa0ffdf
style: Move the check into insert_if_possible. 2017-09-14 11:56:45 +02:00
Emilio Cobos Álvarez
9d671058df
style: Reformat the signature of insert_if_possible. 2017-09-14 09:59:48 +02:00
Bobby Holley
8e5c1c771e Share styles during recascades.
MozReview-Commit-ID: AFTwtzi4P93
2017-09-13 22:06:46 -07:00
Bobby Holley
1c9b39a8e8 Do a second pass on the sharing cache to reuse style by rule node identity.
MozReview-Commit-ID: H67j3Sbt3gr
2017-09-13 22:06:39 -07:00
Bobby Holley
9092e6b4c2 Return the element rather than styles from the style sharing cache.
This gives us more flexibility, and doesn't cost us anything.

MozReview-Commit-ID: CuvOEcLA3My
2017-09-13 22:06:24 -07:00
Bobby Holley
729db5ccec Cache the parent CV identity on ValidationData.
This will make the linear probing faster. If we end up implementing the two-tier
cache setup, this code will be unnecessary and can go away.

MozReview-Commit-ID: BRfV5ump34n
2017-09-13 22:06:17 -07:00
Bobby Holley
7b019f807b Use inheritance_parent to control style_sharing.
Using traversal_parent here is wrong.

MozReview-Commit-ID: GHCIjkgx4VE
2017-09-13 22:06:09 -07:00