Bug 1341985 - Call UpdateAnimations even if the element has no computed values. r=birtles,heycam
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 10 Mar 2017 11:53:19 +0900
changeset 346902 5adbe41c0e30884f177b861987f529ba7ea32d40
parent 346901 9d0b76d2226743c55583724831772e8659ed63bb
child 346903 13ad5103ea6287d7c11a4984561aacd5c668e21c
push id31480
push usercbook@mozilla.com
push dateFri, 10 Mar 2017 10:37:06 +0000
treeherdermozilla-central@e18d3dd20e8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles, heycam
bugs1341985
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1341985 - Call UpdateAnimations even if the element has no computed values. r=birtles,heycam MozReview-Commit-ID: 2dgAF7WOWxr
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
layout/style/nsAnimationManager.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -430,22 +430,21 @@ Gecko_StyleAnimationsEquals(RawGeckoStyl
                             RawGeckoStyleAnimationListBorrowed aB)
 {
   return *aA == *aB;
 }
 
 void
 Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
                        nsIAtom* aPseudoTagOrNull,
-                       ServoComputedValuesBorrowed aComputedValues,
+                       ServoComputedValuesBorrowedOrNull aComputedValues,
                        ServoComputedValuesBorrowedOrNull aParentComputedValues)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aElement);
-  MOZ_ASSERT(aComputedValues);
 
   nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
   if (!presContext) {
     return;
   }
 
   if (presContext->IsDynamic() && aElement->IsInComposedDoc()) {
     presContext->AnimationManager()->
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -190,17 +190,17 @@ Gecko_GetHTMLPresentationAttrDeclaration
 RawServoDeclarationBlockStrong
 Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
                        nsIAtom* aPseudoTag,
                        mozilla::EffectCompositor::CascadeLevel aCascadeLevel);
 bool Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed,
                                  RawGeckoStyleAnimationListBorrowed);
 void Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
                             nsIAtom* aPseudoTagOrNull,
-                            ServoComputedValuesBorrowed aComputedValues,
+                            ServoComputedValuesBorrowedOrNull aComputedValues,
                             ServoComputedValuesBorrowedOrNull aParentComputedValues);
 bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement,
                                    nsIAtom* aPseudoTagOrNull);
 
 // Atoms.
 nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
 void Gecko_AddRefAtom(nsIAtom* aAtom);
 void Gecko_ReleaseAtom(nsIAtom* aAtom);
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -1059,22 +1059,27 @@ nsAnimationManager::UpdateAnimations(
              "Should not update animations for print or print preview");
   MOZ_ASSERT(aElement->IsInComposedDoc(),
              "Should not update animations that are not attached to the "
              "document tree");
 
   CSSPseudoElementType pseudoType =
     nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
                                        CSSEnabledState::eForAllContent);
+  if (!aComputedValues) {
+    // If we are in a display:none subtree we will have no computed values.
+    // Since CSS animations should not run in display:none subtrees we should
+    // stop (actually, destroy) any animations on this element here.
+    StopAnimationsForElement(aElement, pseudoType);
+    return;
+  }
+
   NonOwningAnimationTarget target(aElement, pseudoType);
   ServoCSSAnimationBuilder builder(aComputedValues, aParentComputedValues);
 
-  // Currently we don't seem to call this UpdateAnimations for elements in
-  // display:none subtree. We will call this function for such elements with
-  // null computed values in bug 1341985.
   const nsStyleDisplay *disp = Servo_GetStyleDisplay(aComputedValues);
   DoUpdateAnimations(target, *disp, builder);
 }
 
 template<class BuilderType>
 void
 nsAnimationManager::DoUpdateAnimations(
   const NonOwningAnimationTarget& aTarget,