Commit graph

86 commits

Author SHA1 Message Date
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
Bobby Holley
648ce1e44e Make the DomTraversalContext own the SharedStyleContext and share it immutably across the traversal.
This allows us to get rid of a bunch of lifetimes and simplify a lot of code. It
also lets us get rid of that nasty lifetime transmute, which is awesome.

The situation with thread-local contexts is still suboptimal, but we fix that in
subsequent patches.
2016-12-16 10:57:27 -08:00
bors-servo
535563be31 Auto merge of #14581 - bholley:dont_traverse_xbl, r=heycam
stylo: Avoid traversing children of XBL-bound elements during initial styling

Corresponding Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1294572

CC @heycam @emilio

<!-- 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/14581)
<!-- Reviewable:end -->
2016-12-14 19:41:12 -08:00
Alan Jeffrey
9be4fd56ce Removed util. 2016-12-14 18:04:37 -06:00
Bobby Holley
652e891d0d Bug 1294572 - Avoid traversing children of XBL-bound elements during initial styling. r=heycam
MozReview-Commit-ID: JHABvLnMYco
2016-12-14 10:26:50 -08:00
Bobby Holley
3a56954069 Bug 1322945 - Change skip_root to unstyled_children_only and use StyleNewChildren in more places. r=heycam
I noticed that our current behavior in ContentRangeInserted is incorrect. Unlike
ContentInserted (where this code lived originally), ContentRangeInserted takes a
start and end element. I'm not sure if we ever take that path for new content that
needs style, but it seemed sketchy. And generally, it seems nice to just always
style new content the same way (though we still need to style NAC by the subtree
root, since it hasn't been attached to the parent yet).

For situations where there is indeed only one unstyled child, the traversal
overhead should be neglible, since we special-case the single-element in
parallel.rs to avoid calling into rayon.

Being more explicit about what we want here also makes us more robust against
the other handful of callpaths that can take us into
nsCSSFrameConstructor::{ContentRangeInserted,ContentAppended}. Currently we
can call StyleNewSubtree on an already-styled element via RecreateFramesForContent,
which triggers an assertion in the servo traversal.

MozReview-Commit-ID: DqCGh90deHH
2016-12-12 18:50:33 -08:00
Bobby Holley
851568f59e Bug 1322945 - Only assert against _restyling_ roots with later siblings. r=heycam
The problem is with restyles, so we should leave the door open on
initial styling if that ends up making sense.

MozReview-Commit-ID: 5GOFBEUZhDe
2016-12-12 18:50:33 -08:00
Bobby Holley
80460cc549 Make Restyle tracking more granular.
The primary idea of this patch is to ditch the rigid enum of Previous/Current
styles, and replace it with a series of indicators for the various types of
work that needs to be performed (expanding snapshots, rematching, recascading,
and damage processing). This loses us a little bit of sanity checking (since
the up-to-date-ness of our style is no longer baked into the type system), but
gives us a lot more flexibility that we'll need going forward (especially when
we separate matching from cascading). We also eliminate get_styling_mode in
favor of a method on the traversal.

This patch does a few other things as ridealongs:
* Temporarily eliminates the handling for transfering ownership of styles to the
  frame. We'll need this again at some point, but for now it's causing too much
  complexity for a half-implemented feature.
* Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is
  a constant source of compilation failures from either needing to be imported
  or being unnecessarily imported (which varies between gecko and servo).
* Expands Snapshots for the traversal root, which was missing before.
* Fixes up the skip_root stuff to avoid visiting the skipped root.
* Unifies parallel traversal and avoids spawning for a single work item.
* Adds an explicit pre_traverse step do any pre-processing and determine whether
  we need to traverse at all.

MozReview-Commit-ID: IKhLAkAigXE
2016-12-09 14:46:40 -10:00
Emilio Cobos Álvarez
de1a3d879f
style: Enable the bloom filter recovering. 2016-11-27 15:55:10 +01:00
Emilio Cobos Álvarez
84a50ed5cb
style: Introduce StyleBloom
The idea is this will fix the bad behavior of the bloom filter in parallel
traversal.
2016-11-27 15:55:10 +01:00
Bobby Holley
e65b1be07b Revert restyled_previous_sibling_element tracking, and separate child preprocessing.
I realized that I fixed this issue incorrectly when the test failed before. Our design
document specifies that restyle hints must be expanded by the parent before traversing
children, so that we can properly apply LaterSiblings restyle hints. This includes
parents that do not themselves need processing (StylingMode::Traverse).

So we need to preprocess children even in the case where we don't restyle the parent.
On the flip side, we do in fact know whether a child needs processing before enqueuing
it, so we can skip the conservative visit I added before.

MozReview-Commit-ID: AEiRzdsN0h5
2016-11-24 17:07:40 -08:00
Bobby Holley
992f7dddf4 Bug 1317016 - Basic infrastructure for RestyleHint-driven traversal.
MozReview-Commit-ID: 7wH5XcILVmX
2016-11-24 17:07:38 -08:00
Bobby Holley
5741b8150a Separate rule node computation from cascade. 2016-11-11 14:04:17 -08:00
Emilio Cobos Álvarez
de4fe6e2b6 Concurrent rule tree, v1
This patch introduces infrastructure for the rule tree, and constructs it.

We don't use it yet, nor have good heuristics for GC'ing it, but this should not
happen anymore once we store the rule node reference in the node.

I haven't messed up with memory orders because I want to do a try run with it,
then mess with them.

Take down the ApplicableDeclarationsCache, use the rule tree for doing the cascade.
2016-11-05 17:29:52 +01:00
Bobby Holley
fb70ee2c0c Drop style data from descendants on display:none.
MozReview-Commit-ID: 8ls43oAGWRg
2016-11-01 11:03:04 -07:00
Bobby Holley
1a5e2b4673 Eliminate RestyleResult.
The new incremental restyle algorithm will make traversal decisions in a more
centralized way.

MozReview-Commit-ID: GH6gFt4VUJO
2016-11-01 11:03:04 -07:00
Bobby Holley
71b9004d86 Replace begin_styling with a centralized mechanism to set a node up for either styling or restyling.
We also make sure that an element never has an ElementData with ElementDataStyles::Uninitialized,
and eagerly call prepare_for_styling whenever an ElementData is instantiated.

MozReview-Commit-ID: 9YP6eSmdMt0
2016-11-01 11:03:04 -07:00
Bobby Holley
be89f73675 Rename NodeData and associated data structures to Element*.
MozReview-Commit-ID: 96VsmsoZtjZ
2016-10-29 14:58:07 -07:00
Bobby Holley
5442fbec3f Hoist most styling functionality from TNode to TElement.
MozReview-Commit-ID: DZ8ZrsZIiAU
2016-10-29 13:45:40 -07:00
Bobby Holley
2fce2fbb0c Move all *MatchMethods to TElement.
MozReview-Commit-ID: 3V6JIlOVVhw
2016-10-27 10:22:33 -07:00
Bobby Holley
1090abae87 Don't traverse text nodes during styling.
MozReview-Commit-ID: 6CtQMxbcLnF
2016-10-27 10:22:32 -07:00
Bobby Holley
1cfd5e8172 Hoist RestyleDamage onto TElement.
Instead of maintaining a dummy restyle damage field for text nodes, we can just
perform the necessary parent inheritance and is_changed adjustments on the fly
in ThreadSafeLayoutNode, simplifying the requirements on the style system.

MozReview-Commit-ID: DCqiCRLsLUF
2016-10-27 09:15:36 -07:00
Bobby Holley
05c1f1e016 Introduce StylingMode and deprecate explicit dirtiness.
MozReview-Commit-ID: 5tF075EJKBa
2016-10-26 00:23:18 -07:00
Bobby Holley
adf0fe9b9a Rearrange some data structures in preparation for the new incremental restyle algorithm.
MozReview-Commit-ID: 8iOALQylOuK
2016-10-21 13:00:01 -07:00
Bobby Holley
b493565cc1 Stop ticking animations on non-dirty nodes during traversal. 2016-10-20 19:25:04 -07:00
Bobby Holley
cc96b292c2 Simplify TNode a bit.
A couple of changes here:
* Remove the option to unset with the dirty bit setters.
* Add an explicit API for setting text node style.
* Hoist has_changed handling into the restyle damage setter and text node style setter.
* Make set_style take a non-Option.
2016-10-20 09:47:54 -07:00
Bobby Holley
bfbbef6ecd Remove borrow_data and mutate_data from TNode.
The new restyle architecture doesn't store these things in consistent
places, so we need a more abstract API.
2016-10-10 20:36:31 -07:00
Alexandrov Sergey
512764b7da force style calculation/element construction for non-incremental mode 2016-08-23 01:45:18 +03:00