Commit graph

309 commits

Author SHA1 Message Date
Boris Zbarsky
5ddf455235 Fix style sharing cache lookups to compare ids of the two elements.
Otherwise we can have a situation like this:

  <style>
    .notmatching > #foo {}
  </style>
  <span id="foo"></span>
  <span></span>

and the style sharing cache lookup for the second <span> would try to revalidate
against the cached value for the first <span>, but end up failing asserts about
the two elements matching lists of revalidation selectors that have the same
length.
2017-05-15 15:55:05 -04:00
Josh Matthews
dabebdfbf5 Root nodes for the duration of their CSS transitions.
This ensures that we can pass a node address as part of the asynchronous
transition end notification, making it safe to fire the corresponding
DOM event on the node from the script thread. Without explicitly rooting
this node when the transition starts, we risk the node being GCed before
the transition is complete.
2017-05-15 14:07:41 -04:00
Bobby Holley
bf242088c7 Use a SmallVec when gathering applicable declarations. 2017-05-15 18:36:38 +02:00
bors-servo
eeb1ee9723 Auto merge of #16802 - emilio:slim-down-slc, r=bholley
style: Slim down SharedStyleContext, and do various other cleanups around the style crate.

This slims down SharedStyleContext, in preparation for a few things.

First, I would like to eventually move the stylist to the document in Servo, in
order for it to hold the StyleSheetSet.

Also, this gets rid of a fair amount of overhead while creating it in stylo.

Fixes bug 1363245.

<!-- 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/16802)
<!-- Reviewable:end -->
2017-05-12 08:56:47 -05:00
Emilio Cobos Álvarez
2ffffcfdce
Bug 1364377: Fix inheritance of NAC, and selector-matching of pseudo-implementing NAC. r=bholley
MozReview-Commit-ID: DjSyaWHq1Xj
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-12 13:07:29 +02:00
Emilio Cobos Álvarez
ebd9bf8181
style: Slim down SharedStyleContext.
This slims down SharedStyleContext, in preparation for a few things.

First, I would like to eventually move the stylist to the document in Servo, in
order for it to hold the StyleSheetSet.

Also, this gets rid of a fair amount of overhead while creating it in stylo.

Fixes bug 1363245.
2017-05-11 21:05:41 +02:00
Bobby Holley
e9d4110ad4 Handle importance when inserting into the rule tree. 2017-05-11 17:37:17 +02:00
Emilio Cobos Álvarez
46bf5d61f0
Bug 1355343: Take all the snapshots into account. r=bholley
I've chosen this approach mainly because there's no other good way to guarantee
the model is correct than holding the snapshots alive until a style refresh.

What I tried before this (storing them in a sort of "immutable element data") is
a pain, since we call into style from the frame constructor and other content
notifications, which makes keeping track of which snapshots should be cleared an
which shouldn't an insane task.

Ideally we'd have a single entry-point for style, but that's not the case right
now, and changing that requires pretty non-trivial changes to the frame
constructor.

MozReview-Commit-ID: FF1KWZv2iBM
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-10 12:05:39 +02:00
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07:00
Emilio Cobos Álvarez
5cbc6a9b16
Bug 1360508: Adjust text-combine properly. r=jryans
Text style is always resolved via ServoStyleSet::ResolveStyleForText, either
from the frame constructor initially, or from
ServoRestyleManager::ProcessPostTraversalForText.

So text-only adjustments should go there instead. Since that doesn't call into
cascade(), all the code that passes `pseudo` there is dead code we can remove.

MozReview-Commit-ID: jpbBYpLlUL
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-28 17:21:10 +02:00
bors-servo
d8bcc0db1a Auto merge of #16609 - nox:quirks, r=Manishearth,emilio
Implement unitless length quirk

The Gecko side doesn't propagate its quirks mode yet.

<!-- 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/16609)
<!-- Reviewable:end -->
2017-04-27 22:32:24 -05:00
Emilio Cobos Álvarez
7a556a7f03
Bug 1360399: Don't deduplicate revalidation selectors. r=bholley
It's unfortunate, but it's a correctness issue. I was looking at the
expectations update here:

 * https://hg.mozilla.org/integration/autoland/rev/659cddddd434

And investigating it I realised that it's wrong to coalesce selectors like that,
because we keep the bloom filter flags.

So in the test cases disabled, we have a selector that looks like this:

msub > :not(:first-child),
msup > :not(:first-child),
msubsup > :not(:first-child),
mmultiscripts > :not(:first-child) {
    -moz-script-level: +1;
    -moz-math-display: inline;
}

And an element that looks like this:

<msubsup><mi></mi><mi></mi></msubsup>

We're only inserting the first selector msub > :not(:first-child) into the set,
so when we're going to match the <mi> elements we fast-reject it in both cases
due to the bloom filter, so they share style.

I can't see an easy way to fix this keeping the deduplication. If we keep it, we
need to remove the bloom filter optimization, which means that we'd trash the
cache for every first-child in the document (the :not(:first-child) effectively
becomes a global rule).

MozReview-Commit-ID: 9VPkmdj9zDg
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-28 02:57:54 +02:00
J. Ryan Stinnett
978239927d Port text-combine-upright writing mode fixup to Servo
Ports the Gecko fixup for text-combine-upright writing mode to Servo.  In
addition, this passes the current pseudo element (if any) down to the cascade
for use during the fixup process.

MozReview-Commit-ID: BkHd4AvSsOt
2017-04-27 11:39:59 -05:00
Emilio Cobos Álvarez
be0139ff3c
Bug 1331047: Implement the new traversal semantics for stylo. r=bholley,hiro
MozReview-Commit-ID: 4BXx9JpGZKX
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-27 14:26:48 +02:00
Anthony Ramine
f68e2fded9 Propagate quirks mode all the way to ParserContext
The quirks mode is still not properly propagated in geckolib.
2017-04-27 10:41:55 +02:00
Brian Birtles
af9c7fc257 Add restyle hint for SMIL animations 2017-04-27 13:20:37 +09:00
Brian Birtles
ba118dfe69 Rename remove_animation_and_transition_rules to just remove_animation_rules
Now this method covers SMIL override rules, CSS animation / script
animation rules, and CSS transition rules so we should just use
"animation" in the generic sense.
2017-04-27 13:20:36 +09:00
Brian Birtles
97ce9ed5b0 Add SMIL override cascade level 2017-04-27 12:35:12 +09:00
Simon Sapin
1146921866 Keep custom-ident and string separate in animation/keyframes name. 2017-04-26 13:04:22 +09:00
Simon Sapin
d9c2d1a9fb Use CustomIdent for animation-name and @keyframes 2017-04-26 13:02:16 +09:00
Bobby Holley
750851bf43 Share styles between cousins if the parent styles were shared.
MozReview-Commit-ID: 1QFCSzC5xvk
2017-04-23 12:43:16 -07:00
Bobby Holley
1d6892afa3 Make it clearer that we never insert elements with preshints into the cache.
MozReview-Commit-ID: 9bdc0sNZeEy
2017-04-23 12:43:11 -07:00
Bobby Holley
bdb84c7539 Don't skip the style sharing cache if an element is affected by state.
All elements end up with AFFECTED_BY_STATE right now, presumably due to the UA
sheet, and some non-TS pseudo-classes we've added, which means that we currently
never insert anything into the cache.

MozReview-Commit-ID: 5IU4qrjeJFy
2017-04-23 12:40:31 -07:00
Emilio Cobos Álvarez
7bdd614540
style: trivially cleanup the matching code.
I'm reworking this, and found this cleanup that I think is worth to land.
2017-04-23 01:52:22 +02:00
Bobby Holley
cebacc7faa Rename SimpleSelector to Component.
MozReview-Commit-ID: JfaZpHSkG8h
2017-04-20 15:04:48 -07:00
Boris Chiou
5a1582ca4d Bug 1341372 - Part 7: Rename needs_update_animations.
MozReview-Commit-ID: 2bJlBbdX543
2017-04-17 17:09:02 +08:00
Boris Chiou
eb8db7b892 Bug 1341372 - Part 6: Trigger transitions.
1. We need to call get_after_change_style, which is the computed styles
   without transition rules, while process_animations.
2. If we have after-change style, we may replace the new computed values with
   after-change style, according to whether we really need to update
   transitions.
3. There are some cases we don't update transitions, so we need to early
   return. might_needs_transitions_update() will check it first and it
   will filter out most common cases.
4. needs_transitions_update() will check each property and existing running
   transitions to make sure we really don't need to update transitions.
   The logic of this function is similar with that of
   nsTransitionManager::DoUpdateTransitions().

MozReview-Commit-ID: 2ccdPjgrxKz
2017-04-17 17:08:54 +08:00
Boris Chiou
c88ca7dcd0 Bug 1341372 - Part 4: Let get_after_change_style return Option.
It is possible to call get_after_change_style if there is no transition
rule. In order to avoid cloning the token computed values, we just return None.
The caller can use this Option to know which computed values should be
used.

MozReview-Commit-ID: 7fcgSVEtXWh
2017-04-17 17:06:35 +08:00
Boris Chiou
145e1b6bff Bug 1341372 - Part 3: Factor out need_update_animations.
We will add another function, needs_update_transitions, to check if we need
to update transitions, so factor this out.

MozReview-Commit-ID: 5LYkyi4aDri
2017-04-17 17:06:33 +08:00
Boris Chiou
1c1e487491 Bug 1341372 - Part 1: Let animation-only restyle include css-transition.
Animation-only restyle should include both Animation and Transition
cascade levels.

MozReview-Commit-ID: 5l6gaJKbixM
2017-04-17 17:06:12 +08:00
Bobby Holley
297dc33a9f Store slow selector flags in a hashmap.
This reduces the flag setting overhead on a pessimal testcase from over a
second to ~20ms.
2017-04-13 21:52:47 +08:00
Emilio Cobos Álvarez
39ab49823b
style: relax assertions in dom::element when setting selector flags.
Fixes #16409
2017-04-13 17:40:18 +08:00
Bobby Holley
dc5dbd5542 Store style system options in the global style data and shared style context.
I wanted to add an environmental variable to disable the style sharing
cache for gecko, but the current pattern involves lazy_static!, which
involves an atomic operation on lookup, which is a bit hot to do each
time we try to share styles. This makes that work happen once per
process.
2017-04-12 14:34:42 +08:00
Bobby Holley
fbdfbb1dfa Do a better job of detecting where there are transitions.
The current code thinks that every element has transitions.
2017-04-12 10:35:47 +08:00
Bobby Holley
cceaf7c619 Logging fixes.
I had these lying around in the other bug.
2017-04-12 10:35:46 +08:00
Bobby Holley
d50946933d Set selector flags when matching elements against revalidation selectors. 2017-04-12 10:35:44 +08:00
Bobby Holley
1663bf6e5d Cache the results of cache entry revalidation and use the bloom filter. 2017-04-12 10:35:42 +08:00
Bobby Holley
d51d95d0c7 Merge style_affecting_attributes_selectors with selectors_for_cache_revalidation. 2017-04-12 09:32:14 +08:00
Bobby Holley
6515f78f6d Check for empty when determining what selectors to use for revalidation. 2017-04-12 09:32:06 +08:00
Hiroyuki Ikezoe
27405bd0b6 Don't call process_animations during animation-only restyles. 2017-04-11 16:42:18 +09:00
Hiroyuki Ikezoe
c316594bd3 Rename cascade_with_replacements to replace_rules.
That's because the function does not invoke cascade() at all.
2017-04-11 16:32:00 +09:00
bors-servo
d77d752990 Auto merge of #16316 - Manishearth:stylo-threadsafe, r=emilio
stylo: Make font base size computation threadsafe

r=emilio https://bugzilla.mozilla.org/show_bug.cgi?id=1351200

<!-- 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/16316)
<!-- Reviewable:end -->
2017-04-09 06:15:51 -05:00
Manish Goregaokar
e402c72d0e stylo: Store font metrics provider in thread local style context 2017-04-09 19:15:35 +08:00
bors-servo
949931ec0c Auto merge of #16293 - emilio:refactor-selectors, r=bholley
style: Refactor the selectors crate to remove ad-hoc logic.

Also refactors a lot of the restyle hint code to use these new hooks, and removes a lot of hacks in servo that shouldn't be needed because of correct handling of restyles due to attribute changes.

I just smoketested this, so going for a full try run now.

<!-- 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/16293)
<!-- Reviewable:end -->
2017-04-09 05:17:55 -05:00
Emilio Cobos Álvarez
0ea58d1ffa
style: Stop special-casing a few attributes for style sharing, and use a visitor to track dependencies.
Also, simplify all the pre-snapshot attribute hacks in the script and style
code.

MozReview-Commit-ID: 6c9ipeb7Tnr
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-09 18:15:50 +08:00
Cameron McCormack
3f71c80e2f style: Handle TraversalRestyleBehavior::ForReconstruct in the Servo restyle. 2017-04-08 23:09:00 +08:00
Cameron McCormack
2bbeb21551 style: Move TraversalFlags into SharedStyleContext. 2017-04-08 23:07:35 +08:00
Emilio Cobos Álvarez
e29b84de18
style: Hash less stuff in the bloom filter, using the precomputed hashes we have. 2017-04-08 02:02:11 +02:00
Xidorn Quan
c857878ce9 Remove servo_config dependency for geckolib 2017-04-07 17:20:42 +10:00
Bobby Holley
788d9ad0aa Hoist possibly_expired_animations into CurrentElementInfo.
The current mechanism requires threading a lot of this state through a bunch of
callsites that are several layers of abstraction above the code that actually
uses this vector (which is only compiled for servo). Putting it in
CurrentElementInfo gets it nicely out of the way.

MozReview-Commit-ID: 9PLBKcJreN0
2017-04-06 17:51:59 -07:00