Bug 1433008 - Make AnimationEventInfo, InternalTransitionEvent and InternalAnimationEvent movable. r=masayuki
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 30 Jan 2018 09:26:48 +0900
changeset 748780 374419fd9b2ee1bfa737a7d290aa4f5e7a2ac655
parent 748779 59ae8c3043e832687eee02de7ce66c50cdb5aea3
child 748781 f1ec38bffa532b929223bb298bbaf59bedc76c59
push id97228
push usersfraser@mozilla.com
push dateTue, 30 Jan 2018 10:21:04 +0000
reviewersmasayuki
bugs1433008
milestone60.0a1
Bug 1433008 - Make AnimationEventInfo, InternalTransitionEvent and InternalAnimationEvent movable. r=masayuki And disallow using copy constructor and copy assignment for the structs. MozReview-Commit-ID: 7jSktlu1SqN
dom/animation/AnimationEventDispatcher.h
widget/ContentEvents.h
--- a/dom/animation/AnimationEventDispatcher.h
+++ b/dom/animation/AnimationEventDispatcher.h
@@ -68,23 +68,20 @@ struct AnimationEventInfo
     event.mPropertyName =
       NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(aProperty));
     // XXX Looks like nobody initialize WidgetEvent::time
     event.mElapsedTime = aElapsedTime;
     event.mPseudoElement =
       nsCSSPseudoElements::PseudoTypeAsString(aTarget.mPseudoType);
   }
 
-  // InternalAnimationEvent and InternalTransitionEvent don't support
-  // copy-construction, so we need to ourselves in order to work with nsTArray.
-  //
-  // FIXME: Drop this copy constructor and copy assignment below once
-  // WidgetEvent have move constructor and move assignment (bug 1433008).
-  AnimationEventInfo(const AnimationEventInfo& aOther) = default;
-  AnimationEventInfo& operator=(const AnimationEventInfo& aOther) = default;
+  AnimationEventInfo(const AnimationEventInfo& aOther) = delete;
+  AnimationEventInfo& operator=(const AnimationEventInfo& aOther) = delete;
+  AnimationEventInfo(AnimationEventInfo&& aOther) = default;
+  AnimationEventInfo& operator=(AnimationEventInfo&& aOther) = default;
 
   WidgetEvent* AsWidgetEvent()
   {
     if (mEvent.is<InternalTransitionEvent>()) {
       return &mEvent.as<InternalTransitionEvent>();
     }
     if (mEvent.is<InternalAnimationEvent>()) {
       return &mEvent.as<InternalAnimationEvent>();
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -237,16 +237,21 @@ public:
   }
 
   InternalTransitionEvent(bool aIsTrusted, EventMessage aMessage)
     : WidgetEvent(aIsTrusted, aMessage, eTransitionEventClass)
     , mElapsedTime(0.0)
   {
   }
 
+  InternalTransitionEvent(const InternalTransitionEvent& aOther) = delete;
+  InternalTransitionEvent& operator=(const InternalTransitionEvent& aOther) = delete;
+  InternalTransitionEvent(InternalTransitionEvent&& aOther) = default;
+  InternalTransitionEvent& operator=(InternalTransitionEvent&& aOther) = default;
+
   virtual WidgetEvent* Duplicate() const override
   {
     MOZ_ASSERT(mClass == eTransitionEventClass,
                "Duplicate() must be overridden by sub class");
     InternalTransitionEvent* result =
       new InternalTransitionEvent(false, mMessage);
     result->AssignTransitionEventData(*this, true);
     result->mFlags = mFlags;
@@ -281,16 +286,21 @@ public:
   }
 
   InternalAnimationEvent(bool aIsTrusted, EventMessage aMessage)
     : WidgetEvent(aIsTrusted, aMessage, eAnimationEventClass)
     , mElapsedTime(0.0)
   {
   }
 
+  InternalAnimationEvent(const InternalAnimationEvent& aOther) = delete;
+  InternalAnimationEvent& operator=(const InternalAnimationEvent& aOther) = delete;
+  InternalAnimationEvent(InternalAnimationEvent&& aOther) = default;
+  InternalAnimationEvent& operator=(InternalAnimationEvent&& aOther) = default;
+
   virtual WidgetEvent* Duplicate() const override
   {
     MOZ_ASSERT(mClass == eAnimationEventClass,
                "Duplicate() must be overridden by sub class");
     InternalAnimationEvent* result =
       new InternalAnimationEvent(false, mMessage);
     result->AssignAnimationEventData(*this, true);
     result->mFlags = mFlags;