Bug 1122414 part 1 - Factor out a TransitionProperty method in ElementPropertyTransition; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Tue, 14 Apr 2015 09:11:44 +0900
changeset 270311 4af1955b7abbb15db3a11410586217e9c16bbcc4
parent 270310 2ae6b31b1eb288aac1f23bc9be5759389ed7ef25
child 270312 71cd1e22d1062b2d21755e2d1b6325833fecf0ce
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1122414
milestone40.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 1122414 part 1 - Factor out a TransitionProperty method in ElementPropertyTransition; r=jwatt
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -419,23 +419,22 @@ nsTransitionManager::ConsiderStartingTra
                                      0.5, dummyValue);
 
   bool haveCurrentTransition = false;
   size_t currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
   const ElementPropertyTransition *oldPT = nullptr;
   if (aElementTransitions) {
     AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
     for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
-      MOZ_ASSERT(players[i]->GetSource() &&
-                 players[i]->GetSource()->Properties().Length() == 1,
-                 "Should have one animation property for a transition");
-      if (players[i]->GetSource()->Properties()[0].mProperty == aProperty) {
+      const ElementPropertyTransition *iPt =
+        players[i]->GetSource()->AsTransition();
+      if (iPt->TransitionProperty() == aProperty) {
         haveCurrentTransition = true;
         currentIndex = i;
-        oldPT = players[currentIndex]->GetSource()->AsTransition();
+        oldPT = iPt;
         break;
       }
     }
   }
 
   // If we got a style change that changed the value to the endpoint
   // of the currently running transition, we don't want to interrupt
   // its timing function.
@@ -571,23 +570,21 @@ nsTransitionManager::ConsiderStartingTra
       NS_WARNING("allocating CommonAnimationManager failed");
       return;
     }
   }
 
   AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
 #ifdef DEBUG
   for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
-    MOZ_ASSERT(players[i]->GetSource() &&
-               players[i]->GetSource()->Properties().Length() == 1,
-               "Should have one animation property for a transition");
     MOZ_ASSERT(
       i == currentIndex ||
       (players[i]->GetSource() &&
-       players[i]->GetSource()->Properties()[0].mProperty != aProperty),
+       players[i]->GetSource()->AsTransition()->TransitionProperty()
+         != aProperty),
       "duplicate transitions for property");
   }
 #endif
   if (haveCurrentTransition) {
     players[currentIndex]->Cancel();
     oldPT = nullptr; // Clear pointer so it doesn't dangle
     players[currentIndex] = player;
   } else {
@@ -802,19 +799,18 @@ nsTransitionManager::FlushTransitions(Fl
         --i;
         AnimationPlayer* player = collection->mPlayers[i];
         if (!player->GetSource()->IsFinishedTransition()) {
           MOZ_ASSERT(player->GetSource(),
                      "Transitions should have source content");
           ComputedTiming computedTiming =
             player->GetSource()->GetComputedTiming();
           if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) {
-            MOZ_ASSERT(player->GetSource()->Properties().Length() == 1,
-                       "Should have one animation property for a transition");
-            nsCSSProperty prop = player->GetSource()->Properties()[0].mProperty;
+            nsCSSProperty prop =
+              player->GetSource()->AsTransition()->TransitionProperty();
             TimeDuration duration =
               player->GetSource()->Timing().mIterationDuration;
             events.AppendElement(
               TransitionEventInfo(collection->mElement, prop,
                                   duration,
                                   collection->PseudoElement()));
 
             // Leave this transition in the list for one more refresh
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -37,16 +37,23 @@ struct ElementPropertyTransition : publi
                             nsCSSPseudoElements::Type aPseudoType,
                             const AnimationTiming &aTiming)
     : dom::Animation(aDocument, aTarget, aPseudoType, aTiming, EmptyString())
   { }
 
   virtual ElementPropertyTransition* AsTransition() { return this; }
   virtual const ElementPropertyTransition* AsTransition() const { return this; }
 
+  nsCSSProperty TransitionProperty() const {
+    MOZ_ASSERT(Properties().Length() == 1,
+               "Transitions should have exactly one animation property. "
+               "Perhaps we are using an un-initialized transition?");
+    return Properties()[0].mProperty;
+  }
+
   // This is the start value to be used for a check for whether a
   // transition is being reversed.  Normally the same as
   // mProperties[0].mSegments[0].mFromValue, except when this transition
   // started as the reversal of another in-progress transition.
   // Needed so we can handle two reverses in a row.
   mozilla::StyleAnimationValue mStartForReversingTest;
   // Likewise, the portion (in value space) of the "full" reversed
   // transition that we're actually covering.  For example, if a :hover