Bug 1182981 part 2 - Use nsTHashtable::Iterator in AnimationTimeline; r=njn
authorBrian Birtles <birtles@gmail.com>
Tue, 21 Jul 2015 10:47:23 +0900
changeset 253848 f5237a8342b13400b733855a2f2e351ac9efaebf
parent 253847 b7b704a33d93f935f337f64a2e67bc79d9a2f036
child 253849 def8fc96ab63795e0af4b615a56e9eac84774768
push id29081
push usercbook@mozilla.com
push dateTue, 21 Jul 2015 14:57:20 +0000
treeherdermozilla-central@512c7e8f0030 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1182981
milestone42.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 1182981 part 2 - Use nsTHashtable::Iterator in AnimationTimeline; r=njn
dom/animation/AnimationTimeline.cpp
--- a/dom/animation/AnimationTimeline.cpp
+++ b/dom/animation/AnimationTimeline.cpp
@@ -15,73 +15,49 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(An
 NS_IMPL_CYCLE_COLLECTING_ADDREF(AnimationTimeline)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(AnimationTimeline)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AnimationTimeline)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
-namespace {
-  struct AddAnimationParams {
-    AnimationTimeline::AnimationSequence& mSequence;
-#ifdef DEBUG
-    // This is only used for a pointer-equality assertion
-    AnimationTimeline* mTimeline;
-#endif
-  };
-} // namespace
-
-static PLDHashOperator
-AppendAnimationToSequence(nsRefPtrHashKey<dom::Animation>* aKey,
-                          void* aParams)
-{
-  Animation* animation = aKey->GetKey();
-  AddAnimationParams* params = static_cast<AddAnimationParams*>(aParams);
-
-  MOZ_ASSERT(animation->IsRelevant(),
-             "Animations registered with a timeline should be relevant");
-  MOZ_ASSERT(animation->GetTimeline() == params->mTimeline,
-             "Animation should refer to this timeline");
-
-  // Bug 1174575: Until we implement a suitable PseudoElement interface we
-  // don't have anything to return for the |target| attribute of
-  // KeyframeEffect(ReadOnly) objects that refer to pseudo-elements.
-  // Rather than return some half-baked version of these objects (e.g.
-  // we a null effect attribute) we simply don't provide access to animations
-  // whose effect refers to a pseudo-element until we can support them properly.
-  Element* target;
-  nsCSSPseudoElements::Type pseudoType;
-  animation->GetEffect()->GetTarget(target, pseudoType);
-  if (pseudoType != nsCSSPseudoElements::ePseudo_NotPseudoElement) {
-    return PL_DHASH_NEXT;
-  }
-
-  params->mSequence.AppendElement(animation);
-
-  return PL_DHASH_NEXT;
-}
-
 void
 AnimationTimeline::GetAnimations(AnimationSequence& aAnimations)
 {
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mWindow);
   if (mWindow) {
     nsIDocument* doc = window->GetDoc();
     if (doc) {
       doc->FlushPendingNotifications(Flush_Style);
     }
   }
 
-#ifdef DEBUG
-  AddAnimationParams params{ aAnimations, this };
-#else
-  AddAnimationParams params{ aAnimations };
-#endif
-  mAnimations.EnumerateEntries(AppendAnimationToSequence, &params);
+  for (auto iter = mAnimations.Iter(); !iter.Done(); iter.Next()) {
+    Animation* animation = iter.Get()->GetKey();
+
+    MOZ_ASSERT(animation->IsRelevant(),
+               "Animations registered with a timeline should be relevant");
+    MOZ_ASSERT(animation->GetTimeline() == this,
+               "Animation should refer to this timeline");
+
+    // Bug 1174575: Until we implement a suitable PseudoElement interface we
+    // don't have anything to return for the |target| attribute of
+    // KeyframeEffect(ReadOnly) objects that refer to pseudo-elements.
+    // Rather than return some half-baked version of these objects (e.g.
+    // we a null effect attribute) we simply don't provide access to animations
+    // whose effect refers to a pseudo-element until we can support them
+    // properly.
+    Element* target;
+    nsCSSPseudoElements::Type pseudoType;
+    animation->GetEffect()->GetTarget(target, pseudoType);
+    if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement) {
+      aAnimations.AppendElement(animation);
+    }
+  }
 
   // Sort animations by priority
   aAnimations.Sort(AnimationPtrComparator<nsRefPtr<Animation>>());
 }
 
 void
 AnimationTimeline::AddAnimation(Animation& aAnimation)
 {