aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/css
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-08-01 10:13:21 -0700
committerPatrick Walton <pcwalton@mimiga.net>2015-08-01 23:01:43 -0700
commit7349b6ac283bfeba68bceb00d94f0299d542d173 (patch)
tree02248d21312cdf918f5aac4460cbfe087a56440a /components/layout/css
parent92cbb9368471d12f0d5492abd7e04b16df549366 (diff)
downloadservo-7349b6ac283bfeba68bceb00d94f0299d542d173.tar.gz
servo-7349b6ac283bfeba68bceb00d94f0299d542d173.zip
layout: Tie transitions to the DOM node and finish them instantly when
new styles are set. Tying transitions to the DOM node avoids quadratic complexity when updating them. Finishing transitions instantly when styles are updated makes our behavior more correct.
Diffstat (limited to 'components/layout/css')
-rw-r--r--components/layout/css/matching.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs
index 1d147dcdbdd..1a372a82905 100644
--- a/components/layout/css/matching.rs
+++ b/components/layout/css/matching.rs
@@ -420,7 +420,8 @@ trait PrivateMatchMethods {
applicable_declarations_cache:
&mut ApplicableDeclarationsCache,
new_animations_sender: &Sender<Animation>,
- shareable: bool)
+ shareable: bool,
+ animate_properties: bool)
-> RestyleDamage;
fn share_style_with_candidate_if_possible(&self,
@@ -438,8 +439,21 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
applicable_declarations_cache:
&mut ApplicableDeclarationsCache,
new_animations_sender: &Sender<Animation>,
- shareable: bool)
+ shareable: bool,
+ animate_properties: bool)
-> RestyleDamage {
+ // Finish any transitions.
+ if animate_properties {
+ if let Some(ref mut style) = *style {
+ let this_opaque = self.opaque();
+ if let Some(ref animations) = layout_context.running_animations.get(&this_opaque) {
+ for animation in animations.iter() {
+ animation.property_animation.update(&mut *Arc::make_unique(style), 1.0);
+ }
+ }
+ }
+ }
+
let mut this_style;
let cacheable;
match parent_style {
@@ -470,11 +484,8 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
// Trigger transitions if necessary. This will reset `this_style` back to its old value if
// it did trigger a transition.
- match *style {
- None => {
- // This is a newly-created node; we've nothing to transition from!
- }
- Some(ref style) => {
+ if animate_properties {
+ if let Some(ref style) = *style {
animation::start_transitions_if_applicable(new_animations_sender,
self.opaque(),
&**style,
@@ -488,7 +499,8 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
// Cache the resolved style if it was cacheable.
if cacheable {
- applicable_declarations_cache.insert(applicable_declarations.to_vec(), this_style.clone());
+ applicable_declarations_cache.insert(applicable_declarations.to_vec(),
+ this_style.clone());
}
// Write in the final style and return the damage done to our caller.
@@ -686,7 +698,8 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
&mut layout_data.shared_data.style,
applicable_declarations_cache,
new_animations_sender,
- applicable_declarations.normal_shareable);
+ applicable_declarations.normal_shareable,
+ true);
if applicable_declarations.before.len() > 0 {
damage = damage | self.cascade_node_pseudo_element(
layout_context,
@@ -695,6 +708,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
&mut layout_data.data.before_style,
applicable_declarations_cache,
new_animations_sender,
+ false,
false);
}
if applicable_declarations.after.len() > 0 {
@@ -705,6 +719,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
&mut layout_data.data.after_style,
applicable_declarations_cache,
new_animations_sender,
+ false,
false);
}
layout_data.data.restyle_damage = damage;