Bug 1182978 (part 1) - Use nsTHashtable::Iterator in nsSMILAnimationController. r=birtles.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 22 Jul 2015 00:13:49 -0700
changeset 287545 2a7c0feb7bb6514488553743451f07a921bf6fef
parent 287544 dcb602330f0e3e62c6dfb555eaaec5bfa382a4bb
child 287546 2c58983492ec5805e407f2292c82a5f1bbb52049
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1182978
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 1182978 (part 1) - Use nsTHashtable::Iterator in nsSMILAnimationController. r=birtles.
dom/smil/nsSMILAnimationController.cpp
dom/smil/nsSMILAnimationController.h
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -207,32 +207,23 @@ nsSMILAnimationController::OnPageHide()
 // Cycle-collection support
 
 void
 nsSMILAnimationController::Traverse(
     nsCycleCollectionTraversalCallback* aCallback)
 {
   // Traverse last compositor table
   if (mLastCompositorTable) {
-    mLastCompositorTable->EnumerateEntries(CompositorTableEntryTraverse,
-                                           aCallback);
+    for (auto iter = mLastCompositorTable->Iter(); !iter.Done(); iter.Next()) {
+      nsSMILCompositor* compositor = iter.Get();
+      compositor->Traverse(aCallback);
+    }
   }
 }
 
-/*static*/ PLDHashOperator
-nsSMILAnimationController::CompositorTableEntryTraverse(
-                                      nsSMILCompositor* aCompositor,
-                                      void* aArg)
-{
-  nsCycleCollectionTraversalCallback* cb =
-    static_cast<nsCycleCollectionTraversalCallback*>(aArg);
-  aCompositor->Traverse(cb);
-  return PL_DHASH_NEXT;
-}
-
 void
 nsSMILAnimationController::Unlink()
 {
   mLastCompositorTable = nullptr;
 }
 
 //----------------------------------------------------------------------
 // Refresh driver lifecycle related methods
@@ -381,19 +372,30 @@ nsSMILAnimationController::DoSample(bool
   RewindElements();
   DoMilestoneSamples();
 
   // STEP 2: Sample the child time containers
   //
   // When we sample the child time containers they will simply record the sample
   // time in document time.
   TimeContainerHashtable activeContainers(mChildContainerTable.Count());
-  SampleTimeContainerParams tcParams = { &activeContainers,
-                                         aSkipUnchangedContainers };
-  mChildContainerTable.EnumerateEntries(SampleTimeContainer, &tcParams);
+  for (auto iter = mChildContainerTable.Iter(); !iter.Done(); iter.Next()) {
+    nsSMILTimeContainer* container = iter.Get()->GetKey();
+    if (!container) {
+      continue;
+    }
+
+    if (!container->IsPausedByType(nsSMILTimeContainer::PAUSE_BEGIN) &&
+        (container->NeedsSample() || !aSkipUnchangedContainers)) {
+      container->ClearMilestones();
+      container->Sample();
+      container->MarkSeekFinished();
+      activeContainers.PutEntry(container);
+    }
+  }
 
   // STEP 3: (i)  Sample the timed elements AND
   //         (ii) Create a table of compositors
   //
   // (i) Here we sample the timed elements (fetched from the
   // SVGAnimationElements) which determine from the active time if the
   // element is active and what its simple time etc. is. This information is
   // then passed to its time client (nsSMILAnimationFunction).
@@ -636,39 +638,16 @@ nsSMILAnimationController::GetMilestoneE
 
   container->PopMilestoneElementsAtMilestone(params->mMilestone,
                                              params->mElements);
 
   return PL_DHASH_NEXT;
 }
 
 /*static*/ PLDHashOperator
-nsSMILAnimationController::SampleTimeContainer(TimeContainerPtrKey* aKey,
-                                               void* aData)
-{
-  NS_ENSURE_TRUE(aKey, PL_DHASH_NEXT);
-  NS_ENSURE_TRUE(aKey->GetKey(), PL_DHASH_NEXT);
-  NS_ENSURE_TRUE(aData, PL_DHASH_NEXT);
-
-  SampleTimeContainerParams* params =
-    static_cast<SampleTimeContainerParams*>(aData);
-
-  nsSMILTimeContainer* container = aKey->GetKey();
-  if (!container->IsPausedByType(nsSMILTimeContainer::PAUSE_BEGIN) &&
-      (container->NeedsSample() || !params->mSkipUnchangedContainers)) {
-    container->ClearMilestones();
-    container->Sample();
-    container->MarkSeekFinished();
-    params->mActiveContainers->PutEntry(container);
-  }
-
-  return PL_DHASH_NEXT;
-}
-
-/*static*/ PLDHashOperator
 nsSMILAnimationController::SampleAnimation(AnimationElementPtrKey* aKey,
                                            void* aData)
 {
   NS_ENSURE_TRUE(aKey, PL_DHASH_NEXT);
   NS_ENSURE_TRUE(aKey->GetKey(), PL_DHASH_NEXT);
   NS_ENSURE_TRUE(aData, PL_DHASH_NEXT);
 
   SVGAnimationElement* animElem = aKey->GetKey();
--- a/dom/smil/nsSMILAnimationController.h
+++ b/dom/smil/nsSMILAnimationController.h
@@ -113,38 +113,28 @@ protected:
   ~nsSMILAnimationController();
 
   // Typedefs
   typedef nsPtrHashKey<nsSMILTimeContainer> TimeContainerPtrKey;
   typedef nsTHashtable<TimeContainerPtrKey> TimeContainerHashtable;
   typedef nsPtrHashKey<mozilla::dom::SVGAnimationElement> AnimationElementPtrKey;
   typedef nsTHashtable<AnimationElementPtrKey> AnimationElementHashtable;
 
-  struct SampleTimeContainerParams
-  {
-    TimeContainerHashtable* mActiveContainers;
-    bool                    mSkipUnchangedContainers;
-  };
-
   struct SampleAnimationParams
   {
     TimeContainerHashtable* mActiveContainers;
     nsSMILCompositorTable*  mCompositorTable;
   };
 
   struct GetMilestoneElementsParams
   {
     nsTArray<nsRefPtr<mozilla::dom::SVGAnimationElement> > mElements;
     nsSMILMilestone                                        mMilestone;
   };
 
-  // Cycle-collection implementation helpers
-  static PLDHashOperator CompositorTableEntryTraverse(
-      nsSMILCompositor* aCompositor, void* aArg);
-
   // Returns mDocument's refresh driver, if it's got one.
   nsRefreshDriver* GetRefreshDriver();
 
   // Methods for controlling whether we're sampling
   void StartSampling(nsRefreshDriver* aRefreshDriver);
   void StopSampling(nsRefreshDriver* aRefreshDriver);
 
   // Wrapper for StartSampling that defers if no animations are registered.
@@ -163,18 +153,16 @@ protected:
       TimeContainerPtrKey* aKey, void* aData);
 
   void DoMilestoneSamples();
   static PLDHashOperator GetNextMilestone(
       TimeContainerPtrKey* aKey, void* aData);
   static PLDHashOperator GetMilestoneElements(
       TimeContainerPtrKey* aKey, void* aData);
 
-  static PLDHashOperator SampleTimeContainer(
-      TimeContainerPtrKey* aKey, void* aData);
   static PLDHashOperator SampleAnimation(
       AnimationElementPtrKey* aKey, void* aData);
   static void SampleTimedElement(mozilla::dom::SVGAnimationElement* aElement,
                                  TimeContainerHashtable* aActiveContainers);
   static void AddAnimationToCompositorTable(
     mozilla::dom::SVGAnimationElement* aElement, nsSMILCompositorTable* aCompositorTable);
   static bool GetTargetIdentifierForAnimation(
       mozilla::dom::SVGAnimationElement* aAnimElem, nsSMILTargetIdentifier& aResult);