Bug 1460389 - Use non-animated (static) value if the animation is in not in-effect. r?kats,birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 15 May 2018 09:02:38 +0900
changeset 795075 403bd9a7d625a0925bb271071dfa26a25770df91
parent 795074 59d4f9b67848ad30539e754ead7e03c06ddddc37
child 795076 9d4e421b375dd11be261943509b7fc40e3f73767
push id109854
push userhikezoe@mozilla.com
push dateTue, 15 May 2018 00:09:44 +0000
reviewerskats, birtles
bugs1460389
milestone62.0a1
Bug 1460389 - Use non-animated (static) value if the animation is in not in-effect. r?kats,birtles MozReview-Commit-ID: 87YgNy0RkKt
gfx/webrender_bindings/src/bindings.rs
layout/painting/nsDisplayList.cpp
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1615,35 +1615,50 @@ pub extern "C" fn wr_dp_push_stacking_co
     }).collect();
 
     let clip_node_id_ref = unsafe { clip_node_id.as_ref() };
     let clip_node_id = match clip_node_id_ref {
         Some(clip_node_id) => Some(ClipId::Clip(*clip_node_id, state.pipeline_id)),
         None => None,
     };
 
-    let opacity_ref = unsafe { opacity.as_ref() };
-    if let Some(opacity) = opacity_ref {
-        if *opacity < 1.0 {
-            filters.push(FilterOp::Opacity(PropertyBinding::Value(*opacity), *opacity));
-        }
-    }
-
     let transform_ref = unsafe { transform.as_ref() };
     let mut transform_binding = match transform_ref {
         Some(transform) => Some(PropertyBinding::Value(transform.clone())),
         None => None,
     };
 
+    let opacity_ref = unsafe { opacity.as_ref() };
+    let mut has_opacity_animation = false;
     let anim = unsafe { animation.as_ref() };
     if let Some(anim) = anim {
         debug_assert!(anim.id > 0);
         match anim.effect_type {
-            WrAnimationType::Opacity => filters.push(FilterOp::Opacity(PropertyBinding::Binding(PropertyBindingKey::new(anim.id), 1.0), 1.0)),
-            WrAnimationType::Transform => transform_binding = Some(PropertyBinding::Binding(PropertyBindingKey::new(anim.id), LayoutTransform::identity())),
+            WrAnimationType::Opacity => {
+                filters.push(FilterOp::Opacity(PropertyBinding::Binding(PropertyBindingKey::new(anim.id),
+                                                                        // We have to set the static opacity value as
+                                                                        // the value for the case where the animation is
+                                                                        // in not in-effect (e.g. in the delay phase
+                                                                        // with no corresponding fill mode).
+                                                                        opacity_ref.cloned().unwrap_or(1.0)),
+                                                                        1.0));
+                has_opacity_animation = true;
+            },
+            WrAnimationType::Transform => {
+                transform_binding =
+                    Some(PropertyBinding::Binding(PropertyBindingKey::new(anim.id),
+                                                  // Same as above opacity case.
+                                                  transform_ref.cloned().unwrap_or(LayoutTransform::identity())));
+            },
+        }
+    }
+
+    if let Some(opacity) = opacity_ref {
+        if !has_opacity_animation && *opacity < 1.0 {
+            filters.push(FilterOp::Opacity(PropertyBinding::Value(*opacity), *opacity));
         }
     }
 
     let perspective_ref = unsafe { perspective.as_ref() };
     let perspective = match perspective_ref {
         Some(perspective) => Some(perspective.clone()),
         None => None,
     };
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6710,17 +6710,16 @@ nsDisplayOpacity::CreateWebRenderCommand
   animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime());
 
   // Note that animationsId can be 0 (uninitialized in AnimationInfo) if there
   // are no active animations.
   uint64_t animationsId = animationInfo.GetCompositorAnimationsId();
   wr::WrAnimationProperty prop;
 
   if (!animationInfo.GetAnimations().IsEmpty()) {
-    opacityForSC = nullptr;
     prop.id = animationsId;
     prop.effect_type = wr::WrAnimationType::Opacity;
 
 
     OpAddCompositorAnimations
       anim(CompositorAnimations(animationInfo.GetAnimations(), animationsId));
     aManager->WrBridge()->AddWebRenderParentCommand(anim);
     aManager->AddActiveCompositorAnimationId(animationsId);
@@ -8582,21 +8581,16 @@ nsDisplayTransform::CreateWebRenderComma
                            animationInfo, false, true);
   animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime());
 
   // Note that animationsId can be 0 (uninitialized in AnimationInfo) if there
   // are no active animations.
   uint64_t animationsId = animationInfo.GetCompositorAnimationsId();
   wr::WrAnimationProperty prop;
   if (!animationInfo.GetAnimations().IsEmpty()) {
-    // Update transfrom as nullptr in stacking context if there exists
-    // transform animation, the transform value will be resolved
-    // after animation sampling on the compositor
-    transformForSC = nullptr;
-
     prop.id = animationsId;
     prop.effect_type = wr::WrAnimationType::Transform;
 
     OpAddCompositorAnimations
       anim(CompositorAnimations(animationInfo.GetAnimations(), animationsId));
     aManager->WrBridge()->AddWebRenderParentCommand(anim);
     aManager->AddActiveCompositorAnimationId(animationsId);
   } else if (animationsId) {