Commit graph

245 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
36310e3b66
style: Kill some style sharing code.
MozReview-Commit-ID: 42MyHx3QHuu
2017-07-13 15:32:20 +02:00
Emilio Cobos Álvarez
d3c8844549
style: Remove unnecessary TraversalFlags::FOR_DEFAULT_STYLES.
Yay

MozReview-Commit-ID: JiWTEz63AlE
2017-07-12 09:26:41 +02:00
Emilio Cobos Álvarez
c6d5dbbb01
style: Rewrite restyling to split between resolving styles and handling changes.
MozReview-Commit-ID: 4BzjbLbFebF
2017-07-12 09:26:36 +02:00
Emilio Cobos Álvarez
0ad2d39c30
style: Rewrite get*Style using StyleResolverForElement.
Removing the ugly.

MozReview-Commit-ID: BvahbMKS7QU
2017-07-12 09:26:31 +02:00
Bobby Holley
3330653dc8 Rip out the generic abstractions around ThreadLocalStyleContext.
MozReview-Commit-ID: 5WTLuk323Ac
2017-07-05 16:37:17 -07:00
Emilio Cobos Álvarez
5a481547b8
style: Cleanup traversal.rs
Mostly reflowing comments that have become too long or two short with
refactorings, and using consistent indentation.
2017-06-26 22:48:17 +02:00
J. Ryan Stinnett
2b5c56e6a8 Move match and cascade temporaries to CurrentElementInfo
Before this change, the `ComputedStyle` struct that is part of permanent style
data per element holds 2 `StrongRuleNode`s (unvisited and visited) and 2
`Arc<ComputedValues>` (unvisited and visited).

Both rule nodes and the visited values don't actually need to be here.  This
patch moves these 3 to new temporary storage in `CascadeInputs` on
`CurrentElementInfo` during the match and cascade process.  Rule nodes are
pushed down inside the `ComputedValues` for later access after the cascade.
(Visited values were already available there.)

The permanent style data per element now has just the `Arc<ComputedValues>` for
itself and eager pseudo-elements (plus the `RestyleHint`).

MozReview-Commit-ID: 3wq52ERMpdi
2017-06-22 15:47:32 -05:00
Hiroyuki Ikezoe
a3da636f69 Don't traverse any elements that needed only for animation-only restyles in normal traversal.
Before this patch, we were setting the dirty descendants bit in animation-only
restyles and it triggered unnecessary traversal for elements that does not need
the traversal (i.e no need selector matching).
2017-06-19 15:01:17 +09:00
Hiroyuki Ikezoe
5a8e2562d5 Check the child is unstyled without creating element data in preprocess_children.
If we check it and skip the child after ensure_element_data() call,
the child will have an empty element data, so we will succeed
element_data.is_some() check unexpectedly.
2017-06-19 14:56:27 +09:00
Hiroyuki Ikezoe
028c0e4a43 Don't traverse elements that have no style data in animation-only restyle.
Animation-only restyle only works with elements that have already been styled.
2017-06-19 14:55:58 +09:00
Emilio Cobos Álvarez
ffc45e9aaa
style: Inline RestyleData.
Bug: 1368236
MozReview-Commit-ID: 49s3SO0PMHf
2017-06-16 03:36:18 +02:00
Emilio Cobos Álvarez
dc521b2799
style: Remove damage_handled, and use a reconstructed_ancestor bit instead.
Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 8KK0YfhiS2
2017-06-14 13:15:00 +02:00
Emilio Cobos Álvarez
f9c268922d
style: Kill StoredRestyleHint.
Reviewed-By: bholley
Bug: 1368236
MozReview-Commit-ID: 43Cf0rJyhzO
2017-06-14 13:11:10 +02:00
Hiroyuki Ikezoe
8d519011d8 Don't process RestyleKind::MatchAndCascade during animation-only restyle. 2017-06-14 10:51:53 +09:00
Emilio Cobos Álvarez
cb06375fe2
style: Implement a more fine-grained invalidation method.
This commit also removes the old restyle_hints module and splits it into
multiple modules under components/style/invalidation/element/.

The basic approach is to walk down the tree using compound selectors as needed,
in order to do as little selector-matching as possible.

Bug: 1368240
MozReview-Commit-ID: 2YO8fKFygZI
2017-06-13 13:26:41 +02:00
Cameron McCormack
c533097e20 style: Distinguish between the tree structures used for traversal and selector matching.
This patch renames TNode::parent_element to traversal_parent, since it returns
the parent from the perspective of traversal (which in Gecko uses the
flattened tree).  It also renames TNode::children to traversal_children
for the saem reason.

We keep parent_element and children functions on TNode to use for selector
matching, which must be done on the real DOM tree structure.
2017-06-09 18:37:35 +08:00
Cameron McCormack
a1093ea868 style: always re-cascade in native anonymous subtrees 2017-06-07 13:22:00 +08:00
Boris Zbarsky
98f95a32da Fix the handling of the Bloom filter in the style sharing cache. 2017-06-05 12:51:51 -04:00
Cameron McCormack
19b61dfc08 style: Recascade the document when rem units are used and the root font-size changes. 2017-06-04 10:03:11 +08:00
bors-servo
38a6a3bff6 Auto merge of #17063 - emilio:pres-hints-sharing, r=bholley
style: Allow sharing styles across elements with presentational hints.

<!-- 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/17063)
<!-- Reviewable:end -->
2017-05-30 07:28:06 -05:00
Cameron McCormack
d0d43707fb style: Support a restyle hint that indicates all descendants must be recascaded.
This also moves the result of deciding whether to recascade from the
RestyleData into the RestyleHint.
2017-05-30 09:14:23 +08:00
Emilio Cobos Álvarez
03952a0c27
style: Also cache the class list in the CurrentElementInfo.
This patch also removes all notion of style sharing from matching.rs, which is
nice.
2017-05-29 22:54:17 +02:00
Cameron McCormack
cc44f05f44 style: Add support for resolving default computed styles. 2017-05-25 14:19:59 +08:00
Hiroyuki Ikezoe
a921d1af22 Make replace_rules returning boolean.
We only use whether the return value is IMPORTANT_RULES_CHANGED or not, so we
can just return true if an important rules was changed in the function.
Also, we can just return false in case of animation rules changes sine for
animation we can ensure there is no importan rules.
Because of these changes, replace_rule_node does not borrow |result| so that
we can drop a scope there.
2017-05-24 14:00:17 +09:00
Emilio Cobos Álvarez
d5f8b91d91
style: Remove unneeded indirection in traversal code. 2017-05-21 16:47:22 +02:00
Hiroyuki Ikezoe
dd29fc1f68 Add a new TraversalRestyleBehavior that represents the traversal is triggered by CSS rule changes.
And propagate the new flag to servo if mRestyleForCSSRuleChanges is set.
2017-05-21 15:18:15 +09:00
Emilio Cobos Álvarez
311c403522
style: Move all the style sharing code outside matching.rs
This is just a code health change. I want to move it away to keep matching.rs as
simple as possible.
2017-05-21 02:30:51 +02:00
Emilio Cobos Álvarez
a12996f030
style: Make a bloom filter arrive to restyle hint computation. 2017-05-21 00:12:16 +02:00
Cameron McCormack
a397590838
style: Refactor RestyleHint to be a struct.
Later PRs will add additional data to it that is not so easy to
represent using bitflags.
2017-05-20 16:28:09 +02:00
Cameron McCormack
8b7a414b1c
style: Use RestyleDamage to determine whether we must continue cascading style changes to children. 2017-05-20 16:25:39 +02:00
Boris Chiou
63dc43648e Trigger restyle if important rules are changed.
If we add/remove important rules, we may need to update a list of all important
rules (in Gecko) which overrides animation properties. Therefore, we need to
set a flag if we update the primary rules which includes important ones.

If we have animations on this element, we update its effect properties, and
also send a task to update cascade results.

Calling get_properties_overriding_animations() might cases some impact
on performance because we need to walk the rule tree, so if possible, we could
just store this set into TNode to avoid finding the properties for both old
and new rules each time. This could be a future work if necessary.
2017-05-20 20:04:56 +08:00
Emilio Cobos Álvarez
0bc185f1c2
Bug 1364412: Properly handle state restyle hints for pseudo-elements. r=bholley 2017-05-16 02:49:39 +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
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
Brian Birtles
0d0c2701ff Clear animation-only dirty descendants bit on display:none descendants
When an element has a display:none ancestor we don't traverse it during
restyle. However, at the end of restyling we expect the tree to be free
of dirty bits. We currently take special care to clear the regular
(non-animation) dirty bit on nodes in display:none subtrees in order to
preserve this invariant. This patch applies the same handling to the
animation-only dirty descendants bit.
2017-04-26 14:14:30 +09:00
Emilio Cobos Álvarez
e32e7dd1c4
style: Remove useless deny(missing_docs).
MozReview-Commit-ID: FEvY3ZlJEnc
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-04-14 11:54:49 +08:00
Hiroyuki Ikezoe
69efaa09c9 Preserve restyle hints other than animation hints in propagate() during animation-only restyle. 2017-04-13 11:57:53 +09:00
Bobby Holley
1663bf6e5d Cache the results of cache entry revalidation and use the bloom filter. 2017-04-12 10:35:42 +08: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
fd2b092839 Auto merge of #16312 - bholley:breadth_first_sequential, r=emilio
Make the sequential traversal breadth-first

Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1354806

<!-- 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/16312)
<!-- Reviewable:end -->
2017-04-09 01:55:09 -05:00
Bobby Holley
3f52052cf9 Do the sequential traversal breadth-first.
While we're at it, we also eliminate the 'unknown' dom depth for the
bloom filter. Computing depth has negligible cost relative to the
amount of work we do setting up the bloom filter at a given depth.
Doing it once per traversal should be totally fine.

I originally separated the elimination of unknown dom depth from the
traversal changes, but I got bloom filter crashes on the intermediate
patch, presumably because I didn't properly fix the sequential traversal
for this case. Given that the final state is green, I just decided to
squash and move on.
2017-04-09 14:52:49 +08:00
Bobby Holley
1b363ac909 Factor out the bottom-up postorder traversal logic. 2017-04-09 12:35:58 +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
Cameron McCormack
5fa9a56247 style: Don't traverse children if the root of the restyle is display:none.
If we append a child to a display:none element, and we use StyleNewChildren on
that parent, we should skip restyling the children.
2017-04-08 23:07:30 +08: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
Bobby Holley
8acb4ed87c Match eager pseudos after the primary cascade.
This is necessary in order to make the computation of eager pseudos depend on
the primary ComputedValues, which we want to do for ::first-letter/::first-line.

This also fixes a bug where the behavior of EagerPseudoStyles::is_empty was reversed
in both the implementation and the callsite.

MozReview-Commit-ID: EXBxclyHWXu
2017-04-06 14:31:16 -07:00
Bobby Holley
19743a67ba Rearrange compute_style and eliminate MatchResults.
This simplifies things by avoiding the computation of MatchResults when we
don't need them.

We continue to compute rule_nodes_changed, even though we don't use it
for the moment, since we will need it soon for various incremental restyle
optimizations.

MozReview-Commit-ID: 4qsUYaD5Bs2
2017-04-06 11:28:24 -07:00
Bobby Holley
42f5aea76a Remove shareable boolean from ComputedValues and simplify code.
This code is all vestigial at this point, presumably after a refactoring.

MozReview-Commit-ID: CV0lKMStq13
2017-04-06 11:28:18 -07:00