Bug 1249219 - Part 2: Remove struct PseudoElementHashKey. r=birtles
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 21 Mar 2016 16:49:50 +0800
changeset 289691 c6919c17077a19a65fcd90b54d5d04ec7a279bcb
parent 289690 8186c484a64deccb39ba59d13cf0e8c8c9872e37
child 289692 ac1b7305c0cdf3f97dbf0d20cd7b811be832a7f3
push id30108
push usercbook@mozilla.com
push dateTue, 22 Mar 2016 11:14:31 +0000
treeherdermozilla-central@ea6298e1b4f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1249219
milestone48.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 1249219 - Part 2: Remove struct PseudoElementHashKey. r=birtles We use NonOwningAnimationTarget as the hash key.
dom/animation/EffectCompositor.cpp
dom/animation/PseudoElementHashEntry.h
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -145,17 +145,17 @@ EffectCompositor::RequestRestyle(dom::El
                                  CascadeLevel aCascadeLevel)
 {
   if (!mPresContext) {
     // Pres context will be null after the effect compositor is disconnected.
     return;
   }
 
   auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel];
-  PseudoElementHashKey key = { aElement, aPseudoType };
+  PseudoElementHashEntry::KeyType key = { aElement, aPseudoType };
 
   if (aRestyleType == RestyleType::Throttled) {
     if (!elementsToRestyle.Contains(key)) {
       elementsToRestyle.Put(key, false);
     }
     mPresContext->Document()->SetNeedStyleFlush();
   } else {
     // Get() returns 0 if the element is not found. It will also return
@@ -227,17 +227,17 @@ EffectCompositor::MaybeUpdateAnimationRu
                                            CSSPseudoElementType aPseudoType,
                                            CascadeLevel aCascadeLevel)
 {
   // First update cascade results since that may cause some elements to
   // be marked as needing a restyle.
   MaybeUpdateCascadeResults(aElement, aPseudoType);
 
   auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel];
-  PseudoElementHashKey key = { aElement, aPseudoType };
+  PseudoElementHashEntry::KeyType key = { aElement, aPseudoType };
 
   if (!mPresContext || !elementsToRestyle.Contains(key)) {
     return;
   }
 
   ComposeAnimationRule(aElement, aPseudoType, aCascadeLevel,
                        mPresContext->RefreshDriver()->MostRecentRefresh());
 
@@ -273,17 +273,17 @@ EffectCompositor::GetAnimationRule(dom::
     return nullptr;
   }
 
   MaybeUpdateAnimationRule(aElement, aPseudoType, aCascadeLevel);
 
 #ifdef DEBUG
   {
     auto& elementsToRestyle = mElementsToRestyle[aCascadeLevel];
-    PseudoElementHashKey key = { aElement, aPseudoType };
+    PseudoElementHashEntry::KeyType key = { aElement, aPseudoType };
     MOZ_ASSERT(!elementsToRestyle.Contains(key),
                "Element should no longer require a restyle after its "
                "animation rule has been updated");
   }
 #endif
 
   EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
   if (!effectSet) {
@@ -359,17 +359,18 @@ EffectCompositor::AddStyleUpdatesTo(Rest
     auto& elementSet = mElementsToRestyle[cascadeLevel];
 
     // Copy the list of elements to restyle to a separate array that we can
     // iterate over. This is because we need to call MaybeUpdateCascadeResults
     // on each element, but doing that can mutate elementSet. In this case
     // it will only mutate the bool value associated with each element in the
     // set but even doing that will cause assertions in PLDHashTable to fail
     // if we are iterating over the hashtable at the same time.
-    nsTArray<PseudoElementHashKey> elementsToRestyle(elementSet.Count());
+    nsTArray<PseudoElementHashEntry::KeyType> elementsToRestyle(
+      elementSet.Count());
     for (auto iter = elementSet.Iter(); !iter.Done(); iter.Next()) {
       elementsToRestyle.AppendElement(iter.Key());
     }
 
     for (auto& pseudoElem : elementsToRestyle) {
       MaybeUpdateCascadeResults(pseudoElem.mElement, pseudoElem.mPseudoType);
 
       ComposeAnimationRule(pseudoElem.mElement,
--- a/dom/animation/PseudoElementHashEntry.h
+++ b/dom/animation/PseudoElementHashEntry.h
@@ -4,43 +4,36 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_PseudoElementHashEntry_h
 #define mozilla_PseudoElementHashEntry_h
 
 #include "mozilla/dom/Element.h"
 #include "mozilla/HashFunctions.h"
+#include "mozilla/NonOwningAnimationTarget.h"
 #include "PLDHashTable.h"
 
 namespace mozilla {
 
-enum class CSSPseudoElementType : uint8_t;
-
-struct PseudoElementHashKey
-{
-  dom::Element* mElement;
-  CSSPseudoElementType mPseudoType;
-};
-
 // A hash entry that uses a RefPtr<dom::Element>, CSSPseudoElementType pair
 class PseudoElementHashEntry : public PLDHashEntryHdr
 {
 public:
-  typedef PseudoElementHashKey KeyType;
-  typedef const PseudoElementHashKey* KeyTypePointer;
+  typedef NonOwningAnimationTarget KeyType;
+  typedef const NonOwningAnimationTarget* KeyTypePointer;
 
   explicit PseudoElementHashEntry(KeyTypePointer aKey)
     : mElement(aKey->mElement)
     , mPseudoType(aKey->mPseudoType) { }
   explicit PseudoElementHashEntry(const PseudoElementHashEntry& aCopy)=default;
 
   ~PseudoElementHashEntry() = default;
 
-  KeyType GetKey() const { return {mElement, mPseudoType}; }
+  KeyType GetKey() const { return { mElement, mPseudoType }; }
   bool KeyEquals(KeyTypePointer aKey) const
   {
     return mElement == aKey->mElement &&
            mPseudoType == aKey->mPseudoType;
   }
 
   static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
   static PLDHashNumber HashKey(KeyTypePointer aKey)