Commit graph

174 commits

Author SHA1 Message Date
Hiroyuki Ikezoe
fce7c2d885 Check ElementHasAnimations before trying to get animations rules.
In case of ::before and ::after element, the generated content has no
ElementHasAnimations flag, their parent has the flag.
2017-05-24 11:12:10 +09:00
Hiroyuki Ikezoe
4935d972e5 Use animation values that have been processed during animation-only restyle for normal restyle. 2017-05-24 11:11:57 +09:00
Hiroyuki Ikezoe
35e0e3aa11 Move AnimationRules into declaration_block.rs. 2017-05-24 11:11:42 +09:00
Simon Sapin
c5e37f3d2c Remove unused selectors::Element::each_class 2017-05-18 17:13:14 +02:00
Emilio Cobos Álvarez
e8d1c5316d
style: Refactor the cascade function.
The `cascade_primary_or_pseudo` function was nice when we shared more code, but
right now I think it just makes it harder to understand what's going on.
2017-05-17 16:32:30 +02:00
Emilio Cobos Álvarez
2ffffcfdce
Bug 1364377: Fix inheritance of NAC, and selector-matching of pseudo-implementing NAC. r=bholley
MozReview-Commit-ID: DjSyaWHq1Xj
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2017-05-12 13:07:29 +02:00
bors-servo
48fdda3f07 Auto merge of #16785 - aethanyc:fix-typo-and-simplify, r=mbrubeck
Fix typo and simplify for PresentationalHintsSynthesizer

<!-- 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 do not require tests because it only affects build.

<!-- 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/16785)
<!-- Reviewable:end -->
2017-05-12 02:41:25 -05:00
Ting-Yu Lin
dd5f73750c Fix typo for PresentationalHintsSynthesizer 2017-05-10 11:28:26 -07: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
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
Brian Birtles
97ce9ed5b0 Add SMIL override cascade level 2017-04-27 12:35:12 +09:00
Boris Chiou
02fc1789e8 Bug 1357357 - Make the parser of transition-property match the spec.
1. We add a new arm to TransitionProperty, TransitionProperty::Unsupported,
   which contains an Atom, so it's better to remove the Copy trait from
   TransitionProperty.
2. TransitionProperty::Unsupported(Atom) represents any non-animatable, custom,
   or unrecognized property, and we use Atom to store the ident string for
   serialization.
2017-04-26 21:35:05 +08: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
Boris Chiou
b1476f1f81 Bug 1341372 - Part 2: Support has_css_transitions.
Add one FFI to check if there is any transition in CSSTransitionCollection.
This will be used to check if we need to update transition and if we
should compute the after-change style.

MozReview-Commit-ID: 6HpVAtrx6Rc
2017-04-17 17:06:31 +08:00
Boris Chiou
1c1e487491 Bug 1341372 - Part 1: Let animation-only restyle include css-transition.
Animation-only restyle should include both Animation and Transition
cascade levels.

MozReview-Commit-ID: 5l6gaJKbixM
2017-04-17 17:06:12 +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
Manish Goregaokar
e402c72d0e stylo: Store font metrics provider in thread local style context 2017-04-09 19:15:35 +08:00
Bobby Holley
3f52052cf9 Do the sequential traversal breadth-first.
While we're at it, we also eliminate the 'unknown' dom depth for the
bloom filter. Computing depth has negligible cost relative to the
amount of work we do setting up the bloom filter at a given depth.
Doing it once per traversal should be totally fine.

I originally separated the elimination of unknown dom depth from the
traversal changes, but I got bloom filter crashes on the intermediate
patch, presumably because I didn't properly fix the sequential traversal
for this case. Given that the final state is green, I just decided to
squash and move on.
2017-04-09 14:52:49 +08:00
Bobby Holley
7e3671fc4c Introduce is_native_anonymous and cull style traversal of doomed native anonymous content.
MozReview-Commit-ID: LqwmavJnqW
2017-04-01 12:33:37 -07:00
Emilio Cobos Álvarez
a4bc106e07
style: Make the servo and gecko implementations of Element::note_descendants equivalent. 2017-03-31 11:39:19 +02:00
Bobby Holley
7c58483aff Centralize note_dirty_descendants implementation, and fully propagate dirty_descendants in resolve_style.
The current code can leave the tree in an inconsistent state, with the dirty
descendants bit not fully propagated.

MozReview-Commit-ID: ALI6etmlrDa
2017-03-27 20:43:24 -07:00
Hiroyuki Ikezoe
4183b0dff2 Introduce UpdateAnimationTasks to perform a bunch of animation's tasks in a SequentialTask.
The UpdateAnimationsTasks is a bitflags and each bit is generated from
Gecko's UpdateAnimationsTasks (enum class) values for matching values
between C++ and Rust. For this reason, the bitflags is annotated as
(feature = "gecko"), as a result update_animations() which uses this bitflags
also became gecko-only function.
2017-03-27 17:38:09 +09:00
Hiroyuki Ikezoe
0c843d4b7d Add an FFI to check that a given (pseudo-) element has any type of animations or not.
If an element has any type of animations in match_elements(), we need to call
UpdateEffectProperties() to update KeyframeEffectReadOnly::mProperties.
2017-03-27 17:32:18 +09:00
Hiroyuki Ikezoe
be332fe5a4 Add flag that represents the traversal is only for animation-only restyle.
We will set the flag when the root node of the traversal has
has-animation-only-dirty-descendants flag or has animation restyle hints.
Also we will use this flag to detect whether we need to trigger CSS transitions
or not.
2017-03-27 06:19:51 +09:00
Hiroyuki Ikezoe
661574f9df Add NODE_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO to represent that an element's descendant has animation. 2017-03-27 06:19:51 +09:00
Simon Sapin
1bacd0eb15 Move all PropertyDeclarationBlock from RwLock<_> to Locked<_> 2017-03-19 22:30:38 +01:00
Hiroyuki Ikezoe
ba18c14b91 Split get_animation_rules into get_animation_rule and get_transition_rule.
If an element has only CSS animations we don't need to get transition rule,
and vice versa. This will be used when we implement eRestyle_CSSAnimations
and eRestyle_CSSTransitions.
2017-03-17 12:28:37 +09:00
Hiroyuki Ikezoe
c32ba98031 Skip update_animations if we have no running animations and the element becomes display:none. 2017-03-10 11:37:05 +09:00
Hiroyuki Ikezoe
9ff99d4608 Update CSS animations in a SequentialTask.
We create the SequentialTask only if:

* We have no old computed values and we have animation name style in the new
  computed values.
* Any animation properties is changed.
* display property is changed from 'none' and we have animation name style.
* display property is changed to 'none'.

In a subsequent patch we skip the SequentialTask if we have no running
animations and the display propery is changed to 'none'.
2017-03-10 11:36:58 +09:00
Bobby Holley
1f4f099efe Clean up and simplify the accumulation of restyle damage. 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
9e860df9df Bug 1336646 - Apply selector flags during traversal. r=emilio 2017-02-08 19:21:05 -08:00
Boris Chiou
19aea7ea78 Bug 1317209 - Part 5: Support transition cascade level. r=emilio
Support a new enum, EffectCompositor_CascadeLevel, which is an equivalent of
EffectCompositor::CascadeLevel in Gecko.
2017-01-24 18:44:07 +08:00
Boris Chiou
c09b204d5d Bug 1317209 - Part 3: Add TElement::get_animation_rule. r=heycam
We use TElement::get_animation_rule to get the animation rules from
Gecko side, which contain the interpolated values of the specific
element and the pseudo type.
2017-01-24 16:11:01 +08:00
Emilio Cobos Álvarez
bc381ee945
style: Fully document the dom module. 2016-12-31 12:17:11 +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
ea6a61af59 Stop using UnsafeNode in the parallel traversal.
\o/ \o/ \o/
2016-12-22 10:42:53 -08:00
Bobby Holley
96dc0d1eac Hoist SendElement into dom.rs, label construction as unsafe, and add corresponding SendNode. 2016-12-22 10:42:53 -08: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
Cameron McCormack
33ac29e830 Fix feature check for Gecko-specific assertions. 2016-12-14 13:53:09 +08:00
Emilio Cobos Álvarez
864fe8a9a7
style: Make some removed assertions Servo-only instead. 2016-12-13 08:35:57 +01:00
Bobby Holley
61eadbe7f1 Bug 1322945 - Improve ergonomics and share more code for style crate DOM tree logging. r=heycam
MozReview-Commit-ID: 4Fy3ujpI4n2
2016-12-12 18:50:33 -08:00
Bobby Holley
75e4c16bc7 Bug 1322945 - Remove the requirement that the parent styles must be current to style a subtree. r=heycam
Sometimes Gecko eagerly styles things without processing pending restyles first. In
general we'd like to avoid this, but there can be good reasons (for example, needing
to construct a frame for some small piece of newly-added content in order to do something
specific with that frame, but not wanting to flush all of layout). Just handle it.

MozReview-Commit-ID: EjXs0M4855Q
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
Cameron McCormack
7a4a37870c Skip root- and item-based display style fixup for Gecko NAC.
MozReview-Commit-ID: 6AV2UWyl6pl
2016-12-06 00:56:55 -10: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
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
Simon Sapin
08066800cd Rename selector_matching.rs to stylist.rs 2016-11-20 15:29:09 +01:00