Commit graph

149 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
723d31a4d8
style: Remove SharedStyleContext::quirks_mode. 2017-08-25 12:23:30 +02:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
bors-servo
ca14848711 Auto merge of #18017 - heycam:split-cascade, r=emilio
style: Move all origin-specific cascade data to PerOriginCascadeData

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

This is a preliminary refactoring in preparation for only rebuilding cascade data for origins that have a change. https://bugzilla.mozilla.org/show_bug.cgi?id=1382925

---
<!-- 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
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/18017)
<!-- Reviewable:end -->
2017-08-09 19:28:07 -05:00
Cameron McCormack
16937ba7cd style: Move invalidation map into PerOriginCascadeData. 2017-08-09 19:27:53 +08:00
Hiroyuki Ikezoe
17eba0d4d6 Drop AnimatedProperty for stylo.
set_list_style_type() for gecko needs an additional argument 'Device' [1], and
making list-style-type animtable makes AnimatedProperty::update() call the
set_list_style_type(). To avoid introducing the Device argument to the setter in
servo, this patch makes simply PropertyAnimation conditional build.
(Whereas in stylo, we don't use the setter for animation, we use clone_xx()
instead.)

[1] https://hg.mozilla.org/mozilla-central/file/1d042bcb2632/servo/components/style/properties/properties.mako.rs#l2667
2017-08-09 17:34:55 +09:00
Cameron McCormack
7f47ae0730 style: Slight refactoring of TraversalStatistics::finish. 2017-08-09 16:24:50 +08:00
Hiroyuki Ikezoe
0841db70ee Set restyle subtree restyle hint if the element animates display style from 'none' to other.
When display style is changed from 'none' to other in animation-only restyle
we need to resolve descendant elements' style that were in the display:none
subtree.

Three possible ways to resolve the descendant elements' style;

1) Traversing unstyled elements in animation-only restyle
   We can't simply traverse unstyled elements in the animation-only restyle
   since when we decided to traverse the unstyled elements we don't know yet
   the elements will be initially styled or are in display:none subtree. It
   will result that the new elements are styled in animation-only restyle,
   it's undesirable.

2) Creating a SequentialTask and resolve the descendants' style with
   ServoStyleSet::StyleNewSubtree()
   We can't resolve the descendants' styles with ServoStyleSet::StyleNewSubtree()
   in SequentialTask since at the moment we are still in servo traversal (i.e.
   sInServoTraversal is true). That means AutoSetInServoTraversal fails
   in PrepareAndTraverseSubtree().

3) Creating a SequentialTask and set restyle subtree hint and defer descendants'
   restyle in a subsequent normal traversal
   Note that, when we process throttled animations flush, we don't process
   normal traversal so the descendants will not be traversed until normal
   restyle happens but it will not be a big problem since it's really rare
   that user clicks display animation element just at the right moment when
   display property changes from none to other.  Also, if it will be really
   a problem, we should process *only* transform animations on the compositor,
   it's ideally right thing to do. Display property never runs on the
   compositor.

This patch takes the third approach.
2017-08-02 18:35:01 +09:00
Alan Jeffrey
936dd3ef63 Speculatively evaluate paint functions during style. 2017-07-31 13:02:28 -05:00
Boris Zbarsky
7161fff1b8 Add a Stylo API for reparenting a given style.
Servo side of part 4 of the fix for Gecko bug 1324619.  r=emilio
2017-07-28 22:54:06 -04:00
Boris Zbarsky
91d4956da5 Don't reconstruct the layout object when going from no pseudo to pseudo with no content for ::before and ::after.
Fixes Gecko bug 1376073.  r=emilio
2017-07-28 17:45:29 -04:00
Bobby Holley
ce295f6daf Pass TraversalFlags from C++ into Rust.
MozReview-Commit-ID: EVUzgnL5coN
2017-07-27 14:25:58 -07:00
Emilio Cobos Álvarez
533ea86bab
style: Mention when visited styles may be disabled. 2017-07-24 00:04:45 +02:00
Emilio Cobos Álvarez
9b2d96f7e7
stylo: Honor the relevant link visited pref.
MozReview-Commit-ID: D5NiEJUpONQ
2017-07-23 22:37:47 +02:00
Alan Jeffrey
caa3585219 Fixed scaling artefacts in paint worklets caused by zoom and hidpi. 2017-07-20 17:25:50 -05:00
Michael Partheil
b07ebbae6b Replace all uses of the style::stylearc alias with servo_arc.
The alias is left there temporarilly and will be removed completely in a later commit where
also components/style/gecko/generated/structs_{debug|release}.rs are re-generated (they still
use the old alias).
2017-07-19 09:29:05 +02:00
Emilio Cobos Álvarez
af36ce2ae1
style: Ensure sequential tasks run after the bloom filter is dropped.
MozReview-Commit-ID: 3LjiPP7THg7
2017-07-14 11:00:19 +02:00
Emilio Cobos Álvarez
62310d9bd5
style: Don't use the current element info for cached validation data.
We can take it straight from the validation target.
2017-07-13 15:36:59 +02:00
Emilio Cobos Álvarez
c6d5dbbb01
style: Rewrite restyling to split between resolving styles and handling changes.
MozReview-Commit-ID: 4BzjbLbFebF
2017-07-12 09:26:36 +02:00
Josh Matthews
a08371e8eb stylo: Create error reporters linked to documents (bug 1352669) 2017-07-10 20:46:08 -04:00
J. Ryan Stinnett
3463a9c210 Pass through visited style for after change
When a transition update is needed during restyling, `get_after_change_style` is
called to re-cascade without transition rules, and this style is then used for
primary styling instead of the style just computed.

`get_after_change_style` used to ignore visited styles, so this meant that if a
transition update was needed, visited styles were effectively dropped.

To fix the crash here, we pass through the existing visited styles when
re-cascading as part of `get_after_change_style`.

MozReview-Commit-ID: 4HBQAdeJ38B
2017-07-10 13:28:12 -05:00
Bobby Holley
41fe5db454 Make the style statistics dump threshold configurable.
I've wanted to change the threshold a couple of times, and adding in a
10-minute opt rebuild cycle is always a bit de-motivating.

I'm making this option gecko-only because it's pretty niche, and adding
support in servo would require threading it through all the options
stuff. We can add support for it there if we ever need it.

MozReview-Commit-ID: HYlJpS3usP4
2017-07-05 17:59:49 -07:00
Boris Zbarsky
52d1b59515 Implement :visited handling for lazy pseudo-elements in stylo.
Part 2 of the fix for Gecko bug 1364242: https://bugzilla.mozilla.org/show_bug.cgi?id=1364242
2017-06-29 16:22:13 -07:00
Bobby Holley
af89c74ab7 Use a newtype within EagerPseudoValues.
MozReview-Commit-ID: IIDxBJ8mqvJ
2017-06-23 16:19:05 -07:00
J. Ryan Stinnett
2b5c56e6a8 Move match and cascade temporaries to CurrentElementInfo
Before this change, the `ComputedStyle` struct that is part of permanent style
data per element holds 2 `StrongRuleNode`s (unvisited and visited) and 2
`Arc<ComputedValues>` (unvisited and visited).

Both rule nodes and the visited values don't actually need to be here.  This
patch moves these 3 to new temporary storage in `CascadeInputs` on
`CurrentElementInfo` during the match and cascade process.  Rule nodes are
pushed down inside the `ComputedValues` for later access after the cascade.
(Visited values were already available there.)

The permanent style data per element now has just the `Arc<ComputedValues>` for
itself and eager pseudo-elements (plus the `RestyleHint`).

MozReview-Commit-ID: 3wq52ERMpdi
2017-06-22 15:47:32 -05:00
J. Ryan Stinnett
c3b2a2f4de Copy ComputedStyle to context
In the patch after this, the existing `ComputedStyle` type is renamed and
repurposed as temporary storage of inputs for the cascade.  To make it a bit
easier to follow what code is new, this patch starts by copying `ComputedStyle`
to context.rs without changes.

MozReview-Commit-ID: 41COA5rEoz7
2017-06-22 15:34:28 -05:00
Simon Sapin
a5bb55790f Untry style 2017-06-18 13:18:13 +02:00
Emilio Cobos Álvarez
cb06375fe2
style: Implement a more fine-grained invalidation method.
This commit also removes the old restyle_hints module and splits it into
multiple modules under components/style/invalidation/element/.

The basic approach is to walk down the tree using compound selectors as needed,
in order to do as little selector-matching as possible.

Bug: 1368240
MozReview-Commit-ID: 2YO8fKFygZI
2017-06-13 13:26:41 +02:00
Nazım Can Altınova
15fe48f3f6
stylo: Support :hover and :active quirk 2017-06-10 22:18:32 +03:00
Kenan Rhoton
8aeb512670 Adapt LRUCache to use ArrayDeque crate instead of VecDeque 2017-06-03 20:59:01 +02:00
Bobby Holley
f40c45fe1a Reduce the number of places where we need to enumerate ValidationData members.
MozReview-Commit-ID: 9m2ebknBFSE
2017-05-31 06:48:33 -07:00
Emilio Cobos Álvarez
7db2776348
s/CachedStyleSharingData/ValidationData.
I still think CachedStyleSharingData should be the name, but not going to fight
over it.
2017-05-30 11:23:59 +02:00
Emilio Cobos Álvarez
0adc02a317
style: Avoid some cfg checks in context.rs 2017-05-29 23:24:06 +02:00
Emilio Cobos Álvarez
03952a0c27
style: Also cache the class list in the CurrentElementInfo.
This patch also removes all notion of style sharing from matching.rs, which is
nice.
2017-05-29 22:54:17 +02:00
Emilio Cobos Álvarez
fb6339bbf9
style: rewrap some comments to 80 columns for consistency with the rest of the code. 2017-05-29 21:39:41 +02:00
bors-servo
1306b16d5a Auto merge of #16968 - HeyZoos:stylist-accessors, r=emilio
Stylist accessors

<!-- Please describe your changes on the following line: -->
Add accessor methods for the `device` and `ruleset` fields in the `Stylist` struct.

---
<!-- 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 #16857 (github issue number if applicable).
<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/16968)
<!-- Reviewable:end -->
2017-05-22 20:12:46 -05:00
Emilio Cobos Álvarez
311c403522
style: Move all the style sharing code outside matching.rs
This is just a code health change. I want to move it away to keep matching.rs as
simple as possible.
2017-05-21 02:30:51 +02:00
heyzoos
4196156bb9 Change device and rule_set references to accessors 2017-05-18 22:18:16 -05:00
Emilio Cobos Álvarez
ebd9bf8181
style: Slim down SharedStyleContext.
This slims down SharedStyleContext, in preparation for a few things.

First, I would like to eventually move the stylist to the document in Servo, in
order for it to hold the StyleSheetSet.

Also, this gets rid of a fair amount of overhead while creating it in stylo.

Fixes bug 1363245.
2017-05-11 21:05:41 +02:00
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
Bobby Holley
552bff8fd1 Re-enable the style sharing cache.
MozReview-Commit-ID: C39vdHjPM7J
2017-05-05 10:48:30 -07:00
Bobby Holley
d78ca4c4f9 Use StyleArc in the style system.
MozReview-Commit-ID: flF0fv9E9M
2017-05-02 17:35:44 -07: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
Bobby Holley
d7e121961f Disable the style sharing cache on opt builds to avoid regressing Talos by matching too many revalidation selectors.
MozReview-Commit-ID: 10qSho1gXjw
2017-04-23 12:43:17 -07:00
Boris Chiou
eb8db7b892 Bug 1341372 - Part 6: Trigger transitions.
1. We need to call get_after_change_style, which is the computed styles
   without transition rules, while process_animations.
2. If we have after-change style, we may replace the new computed values with
   after-change style, according to whether we really need to update
   transitions.
3. There are some cases we don't update transitions, so we need to early
   return. might_needs_transitions_update() will check it first and it
   will filter out most common cases.
4. needs_transitions_update() will check each property and existing running
   transitions to make sure we really don't need to update transitions.
   The logic of this function is similar with that of
   nsTransitionManager::DoUpdateTransitions().

MozReview-Commit-ID: 2ccdPjgrxKz
2017-04-17 17:08:54 +08:00
Bobby Holley
297dc33a9f Store slow selector flags in a hashmap.
This reduces the flag setting overhead on a pessimal testcase from over a
second to ~20ms.
2017-04-13 21:52:47 +08:00
Bobby Holley
687ea0ef9e Add more useful statistics to DUMP_STYLE_STATISTICS. 2017-04-13 13:43:05 +08:00
Bobby Holley
591733408d Limit traversal statistics dumps to subtrees of 50 or more elements.
On Gecko, we get tons of console spam from 1-element traversals if we
don't do this.
2017-04-13 13:41:52 +08:00
Bobby Holley
dc5dbd5542 Store style system options in the global style data and shared style context.
I wanted to add an environmental variable to disable the style sharing
cache for gecko, but the current pattern involves lazy_static!, which
involves an atomic operation on lookup, which is a bit hot to do each
time we try to share styles. This makes that work happen once per
process.
2017-04-12 14:34:42 +08:00
Bobby Holley
1663bf6e5d Cache the results of cache entry revalidation and use the bloom filter. 2017-04-12 10:35:42 +08:00
Manish Goregaokar
e402c72d0e stylo: Store font metrics provider in thread local style context 2017-04-09 19:15:35 +08:00