Commit graph

40 commits

Author SHA1 Message Date
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
Michael Howell
748a573917 Add a flag to dump the computed style values
I used this to trace #11818 to a style bug, rather than a layout bug.
2016-08-12 11:11:23 -07:00
Emilio Cobos Álvarez
a36762a9a2
style: Fix pseudo-element restyling. 2016-08-10 18:26:25 -07:00
Emilio Cobos Álvarez
1c322f35a6
Make RestyleDamage::compute take no optional argument, delegate the handling to the caller. 2016-08-10 18:26:24 -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
f419db834c Replace the SelectorImplExt trait with inherent methods. 2016-08-09 18:17:13 +02:00
Emilio Cobos Álvarez
6d67525172
style: Refactor TRestyleDamage and TNode to accept/provide a "style source"
In the Gecko case, this style source would be the style context. In the servo
case, it will be always the computed values.

We could optimise this further in the case of stylo (from three FFI calls to
one) if we use an API of the form CalcAndStore(node, new_cv). But that would
imply borrowing the data twice from Servo (we also have borrow_data_unchecked
fwiw, but...).
2016-08-03 13:31:11 -07:00
Emilio Cobos Álvarez
1470d5b174
stylo: Allow computing change hints during the traversal. 2016-08-03 13:31:11 -07:00
Emilio Cobos Álvarez
c3a727ebda
style: Remove a few more unuseful traversals now we can. 2016-07-27 11:14:45 -07:00
Emilio Cobos Álvarez
611e611215
style: Rewrite the restyle hints code to allow different kinds of element snapshots, and use it for Gecko.
This is a rewrite for how style interfaces with its consumers in order to allow
different representations for an element snapshot.

This also changes the requirements of an element snapshot, requiring them to
only implement MatchAttr, instead of MatchAttrGeneric. This is important for
stylo since implementing MatchAttrGeneric is way more difficult for us given the
atom limitations. This also allows for more performant implementations in the
Gecko side of things.
2016-07-21 14:24:04 -07:00
Simon Sapin
5c70dfab01 Have a concrete SelectorImpl type everywhere in the style crate.
It is conditionally compiled to one implementation or the other
(Gecko or Servo) with `#[cfg(…)]`.
2016-07-20 08:42:46 +02:00
Simon Sapin
4b7060554b Rename ComputedValuesStruct to ComputedValues.
Doing this in a separate commit avoids mixups
with the ComputedValues trait that the previous commit removed.
2016-07-20 08:42:45 +02:00
Simon Sapin
789807b7b0 Remove the ComputedValue traits and style_struct_traits 2016-07-20 08:42:40 +02:00
Shing Lyu
f754cacbd5 Only restyle viewport-relative nodes on viewport size change 2016-07-18 11:01:42 +08:00
Bobby Holley
187a47d89d Remove get_attr from TElement. \o/ 2016-07-05 18:03:41 -07:00
Bobby Holley
364c8e2976 Add attr_equals to TElement.
Same reasons as the previous patch.
2016-07-05 18:03:38 -07:00
Bobby Holley
96af00fbb9 Add has_attr method to TElement.
If this is all the information the caller needs, we can get it from gecko without
worrying about atomization and string conversions.
2016-07-05 18:03:36 -07:00
Bobby Holley
7947afc699 Remove get_attrs from TElement.
This should just be a helper.
2016-07-05 18:03:35 -07:00
Anthony Ramine
a5b524d559 Move util::vec::ForgetfulSink to style::sink and simplify it 2016-07-04 16:48:14 +02:00
bors-servo
3809e4a23d Auto merge of #11834 - servo:style-docs, r=SimonSapin
Add some documentation to the style crate.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11834)
<!-- Reviewable:end -->
2016-06-27 17:14:55 -05:00
Ms2ger
79e0d18a1d Add some documentation to the style crate. 2016-06-27 17:33:14 +02:00
Simon Sapin
f7f81e0ed0 Use our copy of RefCell for style data.
This allows removing `#![feature(as_unsafe_cell)]` in geckolib
and make progress towards #11815.
2016-06-23 16:13:49 +02:00
Simon Sapin
00b6210519 Make the style crate almost build on stable Rust.
`discriminant_value` will need to be replaced with something else later.
2016-06-22 15:44:13 +02:00
Ms2ger
e723d72570 Move the initialize_data method out of the TNode trait.
This reduces the dependency of TNode implementations on layout types.
2016-06-13 15:21:29 +01:00
Emilio Cobos Álvarez
028f9b6cd2
style: layout: Allow a lazy pseudo-element implementation in Servo. 2016-05-04 00:33:58 +02:00
Emilio Cobos Álvarez
2a499d5a0b
layout: Stop storing PrecomputedStyleData in LayoutNode
Use the SharedStyleContext instead.
2016-04-29 22:54:48 +02:00
Emilio Cobos Álvarez
b6402a81d0
style: Add infrastructure for non-eagerly-cascaded pseudo-elements
This commit also removes StylistWrapper and uses Arc::get_mut instead.
2016-04-29 22:54:45 +02:00
Per Lundberg
4cb4cc93e4 Renamed TComputedValues to ComputedValues
This is a followup to #10210, and a continuation of #10185.
2016-03-29 23:30:13 +03:00
faineance
418842faf9 use self.0 instead of destructing single item tuple structs 2016-03-27 11:50:08 +01:00
Bobby Holley
c2daea2c9c Parameterize the rest of the style system on TNode. 2016-03-24 11:50:57 -07:00
Bobby Holley
b1878bd925 Remove lifetimes from T{Node,Element,Document}. 2016-03-14 14:31:57 -07:00
Emilio Cobos Álvarez
61e04df266 style: Refactor the per_pseudo map from StyleData to avoid having an option value type.
This make the layout code way clearer.
2016-02-13 16:05:17 +01:00
Emilio Cobos Álvarez
dd503dfacb Refactor style to be completely backend-independent
This commit refactors the style crate to be completely independent of
the actual implementation and pseudo-elements supported.

This also adds a gecko backend which introduces parsing for the
anonymous box pseudo-elements[1], although there's still no way of
querying them.

https://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSAnonBoxList.h
2016-02-13 16:05:14 +01:00
Emilio Cobos Álvarez
a1c830f1c1 Update rust-selectors
This commits updates rust-selectors to use the generic parser, and as
such it moves the element state into the style crate.
2016-02-03 02:11:31 +01:00
Simon Sapin
9abbd1b5d1 Sequentialize assign_block_size for flows that can be fragmented.
Fragmentation will be intertwined with block size calculation.
2016-01-28 09:42:17 +01:00
Simon Sapin
da2b4ab381 Disable incremental reflow for multicol and their descendants.
Fragmentation with dynamic updates is hard.
2016-01-27 17:33:12 +01:00
Bobby Holley
77b1027646 Hoist style() and unstyle() into TNode. 2016-01-12 13:16:05 -08:00
Bobby Holley
ebc5eb1b98 Make parallel DOM traversal and style calculation operate on TNode instead of LayoutNode. 2016-01-06 17:58:53 -08:00
Bobby Holley
27987c3bb4 Introduce a concept of restyle damage to the style system.
We can't hoist RestyleDamage itself, because it's very layout-dependent. But this
should be enough to let us hoist the things we need.
2016-01-04 09:38:04 -08:00
Bobby Holley
47059d2d26 Separate style+layout and layout-specific wrapper functionality.
This patch does a number of things, unfortunately all at once:
* Hoists a large subset of the layout wrapper functionality into the style system.
* Merges TElementAttributes into the newly-created TElement.
* Reorganizes LayoutData by style vs layout, and removes LayoutDataShared.
* Simplifies the API for borrowing style/layout data.

There's still more to do to make the style system usable standalone, but
this is a good start.
2015-12-29 11:50:03 -08:00