Commit graph

113 commits

Author SHA1 Message Date
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
Bobby Holley
7e3671fc4c Introduce is_native_anonymous and cull style traversal of doomed native anonymous content.
MozReview-Commit-ID: LqwmavJnqW
2017-04-01 12:33:37 -07:00
bors-servo
8adf191973 Auto merge of #16159 - bholley:note_dirty_descendants, r=heycam
Centralize note_dirty_descendants implementation, and fully propagate dirty_descendants in resolve_style.

The current code can leave the tree in an inconsistent state, with the dirty
descendants bit not fully propagated.

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

<!-- 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/16159)
<!-- Reviewable:end -->
2017-03-29 06:52:07 -05:00
Bobby Holley
7c58483aff Centralize note_dirty_descendants implementation, and fully propagate dirty_descendants in resolve_style.
The current code can leave the tree in an inconsistent state, with the dirty
descendants bit not fully propagated.

MozReview-Commit-ID: ALI6etmlrDa
2017-03-27 20:43:24 -07:00
Emilio Cobos Álvarez
af37f7667b
style: Cleanup a bit the restyle hint propagation code. 2017-03-27 13:30:48 +02:00
Hiroyuki Ikezoe
e4fe416c9d Process animation-only traversal.
All traversal processes are like this:

1. Traverse only elements that have this restyle hint (animation-only traversal)
   RESTYLE_CSS_ANIMATIONS is stripped off from restyle hints of the elements
2. Traverse all dirty elements (normal traversal)
3. Create a SequentialTask if we have updated CSS Animations properties in
   the normal traversal
4. Traverse elements that need to have updated animation style as a result of 3
   (second animation-only traversal)
2017-03-27 06:19:51 +09:00
Hiroyuki Ikezoe
499d1c4117 Introduce TraversalFlags to represents target elements of the traversal we are about to do. 2017-03-27 06:19:51 +09:00
Emilio Cobos Álvarez
2b99c76052
Bug 1349553: Add a bit of debugging information to the preprocess_children stage.
MozReview-Commit-ID: 7zv62MRX8dE
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-03-23 09:51:22 +01:00
Simon Sapin
aeffca2a59 Replace RwLock<StyleRule> with Locked<StyleRule> 2017-03-19 22:30:37 +01:00
Emilio Cobos Álvarez
32bf8093cc
Bug 1340334: Allow sibling hints in StoredRestyleHint, and handle them correctly. r=bholley
MozReview-Commit-ID: H6NuKsfjEdj
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-03-02 03:05:56 +01:00
Bobby Holley
d9606a4fae Implement "handled for descendants" tracking for RestyleDamage.
MozReview-Commit-ID: Bbk99ogILXC
2017-02-17 10:15:53 -08:00
Bobby Holley
0e3aeac922 Stop returning rule nodes from match_element and overhaul style calculation logic. 2017-02-10 10:34:28 -08:00
Bobby Holley
5873de3fb6 Allow the ComputedValues in ComputedStyle to be null.
This is necessary to start synthesizing the styles in match_element and avoid
round-tripping them through the caller.
2017-02-10 10:34:27 -08:00
Bobby Holley
1c530f9279 Hoist style sharing cache handling to the top of compute_style. 2017-02-10 10:34:27 -08:00
Bobby Holley
095265affe Hoist some work out of the tail of compute_style into the caller.
This is really part of the "recalc" rather than the "compute" work. But more to
the point, it lets us early-return on the style-sharing stuff (see the next patch).
2017-02-10 10:34:27 -08:00
Bobby Holley
e7a8f5ec30 Bug 1336646 - Use the bloom filter for manual style resolves and pass a mutable StyleContext into match_element. r=emilio
We need to do something here to avoid a double-borrow when passing a mutable
StyleContext to match_element. After some discussion on IRC, we decided that
building the bloom filter for this case is probably worthwhile.
2017-02-08 17:09:35 -08:00
Emilio Cobos Álvarez
2594cb9c33
style: Refactor the traversal so it's more easy to read and straight-forward. 2017-02-02 11:58:36 +01:00
Emilio Cobos Álvarez
8859aa004f
style: Avoid selector-matching when only the style attribute is changed. 2017-02-02 11:58:08 +01:00
Emilio Cobos Álvarez
f00b628c3a
style: Expose the traversal kind to the style system.
This way we'll be able to take different paths for the sequential and parallel
traversals in some concrete cases.

This is a preliminar patch to fix bug 1332525.
2017-01-24 08:41:29 +01:00
Bobby Holley
5370224877 Bug 1331856 - Add style performance statistics to Servo. r=emilio
MozReview-Commit-ID: ECHZgYNA8nb
2017-01-19 15:05:19 -08:00
Bobby Holley
e29cd8f532 Bug 1329854 - Avoid propagating the dirty descendants bit when appending items to display:none subtrees. r=heycam 2017-01-12 17:39:54 -08:00
Bobby Holley
3fcfc9c5fc Bug 1325734 - Simplify ElementData and eliminate the concept of consuming styles. r=emilio 2017-01-09 11:51:37 -08:00
Bobby Holley
4558efbca5 Bug 1325734 - Explicitly track whether we're performing the initial style. r=emilio 2017-01-09 11:51:37 -08:00
Bobby Holley
92b9d70c3a Bug 1325734 - Pass the thread-local context into should_traverse_children. r=emilio 2017-01-09 11:51:37 -08:00
Bobby Holley
3060865577 Bug 1325734 - Parameterize the style traversal on TElement instead of TNode. r=emilio
This works around the issue described in https://github.com/rust-lang/rust/issues/38917
2017-01-09 11:51:36 -08:00
Emilio Cobos Álvarez
ac8547416d
style: Move relations_are_shareable to matching.rs
It's only used there.
2017-01-07 01:53:15 +01:00
Emilio Cobos Álvarez
d14290e3a5
style: Document traversal.rs 2016-12-31 12:17:04 +01:00
Cameron McCormack
be1a73dac5 Don't persist styles on elements not in the document. 2016-12-30 10:58:31 +08:00
Bobby Holley
ab71b29959 style: Add a special, explicit path for lazy style resolution and use it for GetComputedStyle.
MozReview-Commit-ID: KAM9mVoxCHE
2016-12-28 11:52:46 +08:00
Bobby Holley
940cda1d15 Remove generation, remove filter pop, and add size tests. 2016-12-22 11:09:55 -08:00
Bobby Holley
b6e948dc5d Hoist bloom filter into scoped TLS and simplify code. 2016-12-22 10:42:53 -08:00
Bobby Holley
946e7fb7c3 Stop using UnsafeNode in the StyleSharingCandidateCache. 2016-12-21 11:10:41 -08:00
Bobby Holley
c5f01fe3b8 Introduce and use Scoped TLS.
It turns out that it's problematic to embed ThreadLocalStyleContext within
LayoutContext, because parameterizing the former on TElement (which we do
in the next patch) infects all the traversal stuff with the trait parameters,
which we don't really want.

In general, it probably makes sense to use separate scoped TLS types for
the separate DOM and Flow tree passes, so we can add a different ScopedTLS
type for the Flow pass if we ever need it.

We also reorder the |scope| and |shared| parameters in parallel.rs, because
it aligns more with the order in style/parallel.rs. I did this when I was
adding a TLS parameter to all these functions, which I realized we don't need
for now.
2016-12-21 11:10:39 -08:00