Commit graph

43 commits

Author SHA1 Message Date
Bobby Holley
ae87b8a910 Switch from error! and println! to warn!, and set the default log level to warn on debug builds. 2017-02-14 17:19:01 -08:00
Cameron McCormack
229eb93fa3 Do RestyleHint assertions at runtime so they use build-time bindgen. 2017-02-14 10:38:59 +08:00
Cameron McCormack
bc1d7c2fdd Align RESTYLE_STYLE_ATTRIBUTE value with eRestyle_StyleAttribute. 2017-02-13 13:22:43 +08:00
Bobby Holley
9e860df9df Bug 1336646 - Apply selector flags during traversal. r=emilio 2017-02-08 19:21:05 -08:00
Anthony Ramine
55b2c5c1bd Update selectors to 0.17 2017-02-07 20:33: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
7a9cdbb857
style: Add a style attribute restyle hint. 2017-01-30 19:24:41 +01:00
Emilio Cobos Álvarez
fa8874fb14
style: Document the restyle hints code, and make it operate on TElement.
This removes the annoying constraint of having to provide the current state from
outside of the restyle hints code.
2017-01-02 12:57:52 +01: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
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
81a3de3299 Remove SelectorImpl aliases 2016-11-22 14:50:22 +01: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
b69fdad8e4 Stop using associated types for the concrete ElementSnapshot implementation.
MozReview-Commit-ID: LS23s2RbMBg
2016-11-07 10:07:34 -08:00
Simon Sapin
53b638c0e2 Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
Simon Sapin
29c72d15a9 Make style build without impl<T: HeapSizeOf> HeapSizeOf for Arc<T>.
The removal of this impl is not included in this commit.
CC https://github.com/servo/heapsize/issues/37#issuecomment-249861171
2016-10-04 13:45:57 +02:00
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
Emilio Cobos Álvarez
468b329645
style: Provide whether we're styling or not to rust-selectors.
This makes us not adding the flags to everything in servo.
2016-08-31 17:27:15 -07:00
Emilio Cobos Álvarez
b9d91929aa
Fix debug assertion introduced in #13108 by me.
I'm stupid, and when I did the last moving-the-code-around, I failed miserably
to double-check it in a debug build.
2016-08-30 08:57:44 -07:00
Emilio Cobos Álvarez
3e80f482ba
style: Don't loop over all the set of dependencies always.
The dependency count is not at all minor, and this way we avoid looping
through all of them in the common cases, mainly either changing state, or
attributes.
2016-08-29 16:03:00 -07:00
Anthony Ramine
1c4cc6c703 Update selectors to 0.11
This brings :not() with proper list of complex selectors as argument.
2016-08-20 11:24:17 +02:00
Simon Sapin
d690bd2382 Update selectors to 0.10, with ToCss serialization. 2016-08-18 14:46:24 +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
Simon Sapin
fdb2071b2d Update to selectors 0.8.2 2016-08-09 18:18:38 +02:00
Simon Sapin
f419db834c Replace the SelectorImplExt trait with inherent methods. 2016-08-09 18:17:13 +02:00
Emilio Cobos Álvarez
27b2bad256
stylo: Fix and ensure alignment of restyle hints. Test it on Travis.
Turns out eRestyle_LaterSiblings was not really matching, sigh...
2016-08-03 15:18:32 -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
Bobby Holley
1d8d1cb9d9 Upgrade rust-selectors. 2016-07-05 18:03:40 -07:00
Ms2ger
79e0d18a1d Add some documentation to the style crate. 2016-06-27 17:33:14 +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
Bobby Holley
b521c293dc Add string_cache override for geckolib based on gecko atoms.
The work in these patches is based on Ms2ger's gecko-atom crate.
2016-05-18 11:33:38 -07:00
Matt Brubeck
1e23d90631 Upgrade to bitflags 0.6.0 and selectors 0.5.6
Types generated by `bitflags!` are now private by default.  This PR marks them
`pub` where necessary.
2016-04-30 10:14:03 -07:00
Emilio Cobos Álvarez
41f3b1c2ba
style: Remove unneeded lifetime 2016-04-29 22:54:57 +02:00
Pawel Kondzior
db2e10a70f Report memory usage from LayoutThreadData Stylist [#7038] 2016-03-19 11:53:13 -07: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
Johannes Linke
6b215f38ee Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
Alan Jeffrey
3dec6edd10 Update string_cache to 0.2.
Updated string_cache, html5ever, xml5ever and selectors in Cargo.toml files and Cargo.lock.
Removed references to string_cache_plugin.
Import atom! and ns! from string_cache.
Replaced ns!("") by ns!().
Replaced ns!(XML) and co by ns!(xml) and co.
Replaced atom!(foo) by atom!("foo").
Replaced Atom::from_slice by Atom::from.
Replaced atom.as_slice() by &*atom.
2015-11-25 10:13:21 -06:00
Bobby Holley
7fa7936657 Implement attribute restyle hints.
Fixes #6942.
2015-11-10 11:57:24 -08:00
Bobby Holley
7dba4447f1 Store pristine element state rather than a set of changes.
This is the strategy we'll need to take for attributes, and so this change
puts us in a position to handle attributes and state the same way.

This does mean that we stop taking care to track the situations where our
state has reverted to the original state, with no net change. I think that's
probably of negligible value though.
2015-11-04 19:09:58 -08:00
Bobby Holley
d89816bb5f Consider all the pseudo-classes in a given compound selector when computing restyle hints, not just the rightmost one.
For some reason when I wrote this code I mixed up the rules for pseudo-elements
(rightmost, maximum of one) with those of pseudo-classes (which have no such
restriction). This caused a correctness issue which can be demonstrated with the
associated reftest modification.
2015-11-04 19:01:50 -08:00
Bobby Holley
45fc7f2930 Implement restyle hints for state changes. 2015-10-31 14:28:52 -07:00