Commit graph

205 commits

Author SHA1 Message Date
Hiroyuki Ikezoe
f91126ba86 Add has_current_styles_for_traversal().
In animation-only restyle, we just need to check the element
has animation restyle hints or has recascade self which is a result
of animation-only restyle for ancestors.
has_current_styles() in Servo_ResolveStyle() is intentionally left there,
it will be changed in a subsequent patch.
2017-07-18 19:13:50 +09:00
Manish Goregaokar
89930e7565 stylo: Switch Gecko over to ServoStyleContext 2017-07-17 18:03:23 -07:00
Manish Goregaokar
808b1f509b stylo: Use ComputedValuesInner instead of ComputedValues when we don't need it 2017-07-17 18:02:25 -07:00
Emilio Cobos Álvarez
1316f3640b
style: Fix a typo that makes us resolve styles for the whole spin to the root.
For undisplayed elements, at least.
2017-07-16 16:32:50 +02:00
Bobby Holley
b7de96e702 Pass a callback to recalc_style_at to avoid traversing children twice.
MozReview-Commit-ID: DIHXaVNzbFM
2017-07-15 14:45:51 -07:00
Bobby Holley
e534ec9e47 Move clearing of dirty descendants bit closer to the last place it's needed.
In the next patch, we'll move logic to identify the children for traversal into
preprocess_children (which will be renamed), and the set_dirty_descendants logic
will move along with it. So left as-is, the code here will clobber the flags.

MozReview-Commit-ID: 7ZskKWD4QC3
2017-07-15 14:27:18 -07:00
Emilio Cobos Álvarez
3faba0cfff
style: Remove some no longer needed type arguments. 2017-07-15 19:02:19 +02:00
Emilio Cobos Álvarez
bf9369b29d
script: Move the layout_wrapper outside of script.
This allows us to have ensure_data() and clear_data() functions on the TElement
trait, instead of hacking around it adding methods in random traits.

This also allows us to do some further cleanup, which I'd rather do in a
followup.
2017-07-15 16:41:12 +02:00
Emilio Cobos Álvarez
bd10081919
style: Move comment to a closer location. 2017-07-14 09:24:38 +02:00
Emilio Cobos Álvarez
62310d9bd5
style: Don't use the current element info for cached validation data.
We can take it straight from the validation target.
2017-07-13 15:36:59 +02:00
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