Commit graph

204 commits

Author SHA1 Message Date
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
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
Bobby Holley
962a4a79bb Bug 1325734 - Remove Servo Layout's dependency on the initial-ness of the style. r=emilio 2017-01-09 11:51:36 -08:00
Bobby Holley
b9d99390ad Switch to crates.io for atomic_refcell. 2017-01-03 18:14:27 -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
Alan Jeffrey
9be4fd56ce Removed util. 2016-12-14 18:04:37 -06: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
Simon Sapin
b203ab2419 Rename selector_impl.rs to selector_parser.rs
This makes it consistent with an upcoming update of the selectors crate.
2016-11-20 15:30:37 +01:00
Bobby Holley
b31ed2298c Eliminate HAS_CHANGED in favor of explicit RestyleDamage. 2016-11-16 12:09:49 -08:00
Bobby Holley
dda2928386 Remove TDocument from the style and layout crates.
The style system never actually does anything with the document. This allows us
to remove a bunch of stubbing on the Gecko side and streamline some things on
the Servo side in future patches.
2016-11-14 13:04:13 -08:00
bors-servo
ef5ca14283 Auto merge of #14084 - mrobinson:scroll_root_2, r=glennw
Don't promote all scrollable regions to stacking contexts

<!-- Please describe your changes on the following line: -->

Don't promote all scrollable regions to stacking contexts

Instead annotate all flows with their owning ScrollRoots. When
processing the display list items into a flattened display list, we add
PushScrollRoot and PopScrollRoot to signal when scrolling regions start
and end. It is possible for content from different scrolling regions to
intersect and when they do, the stack of scrolling regions is
duplicated.  When these duplicated scrolling regions stacks reach
WebRender, it will scroll them in tandem.

The PushScrollRoot and PopScrollRoot items are currently represented as
StackingContexts in WebRender, but eventually these will be replaced
with special WebRender display items.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #13529 and #13298. (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/14084)
<!-- Reviewable:end -->
2016-11-07 18:49:53 -06:00
Bobby Holley
a2c7a9d0fb Stop using associated types for the concrete TRestyleDamage implementation.
MozReview-Commit-ID: LfaZFCVlIb1
2016-11-07 11:10:48 -08:00
Martin Robinson
ef82d772c1 Don't promote all scrollable regions to stacking contexts
Instead annotate all flows with their owning ScrollRoots. When
processing the display list items into a flattened display list, we add
PushScrollRoot and PopScrollRoot to signal when scrolling regions start
and end. It is possible for content from different scrolling regions to
intersect and when they do, the stack of scrolling regions is
duplicated.  When these duplicated scrolling regions stacks reach
WebRender, it will scroll them in tandem.

The PushScrollRoot and PopScrollRoot items are currently represented as
StackingContexts in WebRender, but eventually these will be replaced
with special WebRender display items.

Fixes #13529.
Fixed #13298.
2016-11-05 18:36:45 +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
bors-servo
3a3f3192a8 Auto merge of #13957 - mrobinson:scroll_root, r=glennw
Track overflow:scroll stacking contexts with ScrollRootId instead of StackingContextId

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because this PR should not change behavior.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/13957)
<!-- Reviewable:end -->
2016-10-30 15:27:56 -05:00
Martin Robinson
71d285af80 Use a new id type for tracking scrolling areas
This is a step in disassociating scrolling areas from stacking
contexts. Now scroll areas are defined by unique ids, which means that
in the future stacking context will be able to contain more than one.
2016-10-30 21:10:04 +01: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
46e29184bd Move core pseudo-element handling to ThreadSafeLayoutElement. 2016-10-28 10:47:57 -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
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
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
Ms2ger
fd68208da6 Stop creating a LayoutContext in build_display_list_for_subtree. 2016-08-24 10:16:53 +02:00
Ms2ger
871c207c44 Pass SharedLayoutContext to Flow::compute_absolute_position. 2016-08-24 10:12:38 +02:00
Emilio Cobos Álvarez
3af774bd75
Rewrite the style sharing candidate cache.
The style candidate cache had regressed a few times (see #12534), and my
intuition is that being able to disable all style sharing with a single rule in
the page is really unfortunate.

This commit redesigns the style sharing cache in order to be a optimistic cache,
but then reject candidates if they match different sibling-affecting selectors
in the page, for example.

So far the numbers have improved, but not so much as I'd wanted (~10%/20% of
non-incremental restyling time in general). The current implementation is really
dumb though (we recompute and re-match a lot of stuff), so we should be able to
optimise it quite a bit.

I have different ideas for improving it (that may or may not work), apart of the
low-hanging fruit like don't re-matching candidates all the time but I have to
measure the real impact.

Also, I need to verify it against try.
2016-08-17 14:16:16 -07:00
Emilio Cobos Álvarez
544a117911
style: Force to stop computing children if we find the parent has display: none. 2016-08-10 18:26:21 -07:00
Simon Sapin
fdb2071b2d Update to selectors 0.8.2 2016-08-09 18:18:38 +02:00
Emilio Cobos Álvarez
d81fe27b11
style: Avoid propagating the restyle flag all through the dom when a node gets dirty.
This puts us in pair with stylo.
2016-07-25 10:50:04 -07:00
Simon Sapin
6d0e48f6cc Remove some type aliases that are now just re-exports. 2016-07-20 08:42:47 +02:00
Simon Sapin
789807b7b0 Remove the ComputedValue traits and style_struct_traits 2016-07-20 08:42:40 +02:00
Bobby Holley
1d8d1cb9d9 Upgrade rust-selectors. 2016-07-05 18:03:40 -07:00
Ms2ger
4381107c21 Make the STYLE_BLOOM global private. 2016-06-23 13:52:26 +02:00
Ms2ger
577c2d2078 Store SharedStyleContext in AssignISizes. 2016-06-22 15:02:06 +02:00
Ms2ger
ea45e76840 Pass SharedStyleContext to assign_inline_sizes. 2016-06-22 14:50:04 +02:00
Ms2ger
0c726cfe6b Make RecalcStyleAndConstructFlows generic over the LayoutNode implementation. 2016-06-20 19:08:04 +02:00
Ms2ger
0d0b268138 Move LayoutNode and related traits to script_layout_interface. 2016-06-20 19:07:54 +02:00
Ms2ger
afc7118a67 Introduce a ThreadSafeLayoutNodeHelpers trait for methods to stay in layout. 2016-06-20 19:02:48 +02:00