Bug 1415780 - Move AnimationCollection::PseudoTypeAsString into nsCSSPseudoElements. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 27 Jan 2018 21:17:26 +0900
changeset 748019 19e69815abc03543c30e08d57fb9d4d61d1e2f98
parent 748018 a0e5533273a3c240af9bc66833d4ee5eb6b59fc9
child 748020 ce27253273f6e9185f8f0e6fbbedf9705f25f334
push id97048
push userhikezoe@mozilla.com
push dateSat, 27 Jan 2018 12:23:10 +0000
reviewersbirtles
bugs1415780
milestone60.0a1
Bug 1415780 - Move AnimationCollection::PseudoTypeAsString into nsCSSPseudoElements. r?birtles It's not need to be a template function since the function is independent from AnimationType. MozReview-Commit-ID: 13WkRIfaQbZ
layout/style/AnimationCollection.cpp
layout/style/AnimationCollection.h
layout/style/nsAnimationManager.h
layout/style/nsCSSPseudoElements.cpp
layout/style/nsCSSPseudoElements.h
layout/style/nsTransitionManager.h
--- a/layout/style/AnimationCollection.cpp
+++ b/layout/style/AnimationCollection.cpp
@@ -112,33 +112,16 @@ AnimationCollection<AnimationType>::GetO
     *aCreatedCollection = true;
     aElement->SetMayHaveAnimations();
   }
 
   return collection;
 }
 
 template <class AnimationType>
-/* static */ nsString
-AnimationCollection<AnimationType>::PseudoTypeAsString(
-  CSSPseudoElementType aPseudoType)
-{
-  switch (aPseudoType) {
-    case CSSPseudoElementType::before:
-      return NS_LITERAL_STRING("::before");
-    case CSSPseudoElementType::after:
-      return NS_LITERAL_STRING("::after");
-    default:
-      MOZ_ASSERT(aPseudoType == CSSPseudoElementType::NotPseudo,
-                 "Unexpected pseudo type");
-      return EmptyString();
-  }
-}
-
-template <class AnimationType>
 void
 AnimationCollection<AnimationType>::UpdateCheckGeneration(
   nsPresContext* aPresContext)
 {
   mCheckGeneration = aPresContext->RestyleManager()->GetAnimationGeneration();
 }
 
 template<class AnimationType>
--- a/layout/style/AnimationCollection.h
+++ b/layout/style/AnimationCollection.h
@@ -83,18 +83,16 @@ public:
   // We'll set the outparam |aCreatedCollection| to true if we have
   // to create the collection and we successfully do so. Otherwise,
   // we'll set it to false.
   static AnimationCollection<AnimationType>*
     GetOrCreateAnimationCollection(dom::Element* aElement,
                                    CSSPseudoElementType aPseudoType,
                                    bool* aCreatedCollection);
 
-  static nsString PseudoTypeAsString(CSSPseudoElementType aPseudoType);
-
   dom::Element *mElement;
 
   // the atom we use in mElement's prop table (must be a static atom,
   // i.e., in an atom list)
   nsAtom *mElementProperty;
 
   InfallibleTArray<RefPtr<AnimationType>> mAnimations;
 
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -50,18 +50,17 @@ struct AnimationEventInfo {
     , mAnimation(aAnimation)
     , mEvent(true, aMessage)
     , mTimeStamp(aTimeStamp)
   {
     // XXX Looks like nobody initialize WidgetEvent::time
     aAnimationName->ToString(mEvent.mAnimationName);
     mEvent.mElapsedTime = aElapsedTime;
     mEvent.mPseudoElement =
-      AnimationCollection<dom::CSSAnimation>::PseudoTypeAsString(
-        aTarget.mPseudoType);
+      nsCSSPseudoElements::PseudoTypeAsString(aTarget.mPseudoType);
   }
 
   // InternalAnimationEvent doesn't support copy-construction, so we need
   // to ourselves in order to work with nsTArray
   AnimationEventInfo(const AnimationEventInfo& aOther)
     : mElement(aOther.mElement)
     , mAnimation(aOther.mAnimation)
     , mEvent(true, aOther.mEvent.mMessage)
--- a/layout/style/nsCSSPseudoElements.cpp
+++ b/layout/style/nsCSSPseudoElements.cpp
@@ -152,8 +152,24 @@ nsCSSPseudoElements::GetPseudoAtom(const
 }
 
 /* static */ bool
 nsCSSPseudoElements::PseudoElementSupportsUserActionState(const Type aType)
 {
   return PseudoElementHasFlags(aType,
                                CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE);
 }
+
+/* static */ nsString
+nsCSSPseudoElements::PseudoTypeAsString(Type aPseudoType)
+{
+  switch (aPseudoType) {
+    case CSSPseudoElementType::before:
+      return NS_LITERAL_STRING("::before");
+    case CSSPseudoElementType::after:
+      return NS_LITERAL_STRING("::after");
+    default:
+      MOZ_ASSERT(aPseudoType == CSSPseudoElementType::NotPseudo,
+                 "Unexpected pseudo type");
+      return EmptyString();
+  }
+}
+
--- a/layout/style/nsCSSPseudoElements.h
+++ b/layout/style/nsCSSPseudoElements.h
@@ -136,16 +136,18 @@ public:
   }
 
   static bool IsEnabled(Type aType, EnabledState aEnabledState)
   {
     return !PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_UA_SHEET_ONLY) ||
            (aEnabledState & EnabledState::eInUASheets);
   }
 
+  static nsString PseudoTypeAsString(Type aPseudoType);
+
 private:
   // Does the given pseudo-element have all of the flags given?
 
   // Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64037 ,
   // which is a general gcc bug that we seem to have hit only on Android/x86.
 #if defined(ANDROID) && defined(__i386__) && defined(__GNUC__) && \
     !defined(__clang__)
 #if (MOZ_GCC_VERSION_AT_LEAST(4,8,0) && MOZ_GCC_VERSION_AT_MOST(4,8,4)) || \
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -318,18 +318,17 @@ struct TransitionEventInfo {
     , mEvent(true, aMessage)
     , mTimeStamp(aTimeStamp)
   {
     // XXX Looks like nobody initialize WidgetEvent::time
     mEvent.mPropertyName =
       NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
     mEvent.mElapsedTime = aElapsedTime;
     mEvent.mPseudoElement =
-      AnimationCollection<dom::CSSTransition>::PseudoTypeAsString(
-        aTarget.mPseudoType);
+      nsCSSPseudoElements::PseudoTypeAsString(aTarget.mPseudoType);
   }
 
   // InternalTransitionEvent doesn't support copy-construction, so we need
   // to ourselves in order to work with nsTArray
   TransitionEventInfo(const TransitionEventInfo& aOther)
     : mElement(aOther.mElement)
     , mAnimation(aOther.mAnimation)
     , mEvent(aOther.mEvent)