Commit graph

88 commits

Author SHA1 Message Date
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
bors-servo
af077a7222 Auto merge of #18420 - servo:toml, r=nox,emilio
Get rustc commit hash from channel manifest

… added in https://github.com/rust-lang/rust/pull/44218, instead of using the GitHub API.

Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07).

<!-- 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/18420)
<!-- Reviewable:end -->
2017-09-12 05:01:24 -05:00
Simon Sapin
0d4168034f Un-inline some methods initializing thread_local! …
… in order to limit stack frame sizes after extra inlining from
https://github.com/rust-lang/rust/pull/43931

See https://github.com/servo/servo/pull/18420#issuecomment-328769322
2017-09-12 11:42:04 +02:00
Bobby Holley
8268217767 Avoid memmoving ValidationData more than necessary.
MozReview-Commit-ID: 70w3bZ2FU0W
2017-09-11 22:39:35 -07:00
Bobby Holley
74b4f95d71 Encapsulate the sharing cache backend better.
MozReview-Commit-ID: 2x9BIhmwH83
2017-09-11 22:39:34 -07:00
Bobby Holley
db67cd1759 Shorten the naming around the style sharing cache.
MozReview-Commit-ID: EcVQDLoxwFP
2017-09-11 22:39:31 -07:00
Matt Brubeck
21006fb752 Use SmallBitVec to replace BitVec 2017-09-11 06:33:43 -07:00
Hiroyuki Ikezoe
6ed7c69281 Don't cache style data if the element has running animations. 2017-08-23 09:51:27 +09:00