Bug 1433008 - Make WidgetEvent movable. r?masayuki draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 30 Jan 2018 09:26:48 +0900
changeset 748557 ef75e75b47c2670649bbcbf4eb02142361133f0c
parent 748403 117e0c0d1ebe2cf5bdffc3474744add2416fc511
child 748558 3321d12b07f4fd6e7fc50bd2a6ec5935f2628ff8
push id97207
push userbmo:hikezoe@mozilla.com
push dateTue, 30 Jan 2018 00:27:12 +0000
reviewersmasayuki
bugs1433008
milestone60.0a1
Bug 1433008 - Make WidgetEvent movable. r?masayuki The copy-assignment in this patch is used in the copy-constructor. Note that we can't simply use '= default' implementation since we need to use MOZ_COUNT_CTOR() in the move constructor. MozReview-Commit-ID: 8HTMaTONBuN
widget/BasicEvents.h
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -545,16 +545,37 @@ public:
   }
 
   WidgetEvent(const WidgetEvent& aOther)
     : WidgetEventTime()
   {
     MOZ_COUNT_CTOR(WidgetEvent);
     *this = aOther;
   }
+  WidgetEvent& operator=(const WidgetEvent& aOther) = default;
+
+  WidgetEvent(WidgetEvent&& aOther)
+    : WidgetEventTime(Move(aOther))
+    , mClass(aOther.mClass)
+    , mMessage(aOther.mMessage)
+    , mRefPoint(Move(aOther.mRefPoint))
+    , mLastRefPoint(Move(aOther.mLastRefPoint))
+    , mFocusSequenceNumber(aOther.mFocusSequenceNumber)
+    , mFlags(Move(aOther.mFlags))
+    , mSpecifiedEventType(Move(aOther.mSpecifiedEventType))
+    , mSpecifiedEventTypeString(Move(aOther.mSpecifiedEventTypeString))
+    , mTarget(Move(aOther.mTarget))
+    , mCurrentTarget(Move(aOther.mCurrentTarget))
+    , mOriginalTarget(Move(aOther.mOriginalTarget))
+    , mRelatedTarget(Move(aOther.mRelatedTarget))
+    , mPath(Move(aOther.mPath))
+  {
+    MOZ_COUNT_CTOR(WidgetEvent);
+  }
+  WidgetEvent& operator=(WidgetEvent&& aOther) = default;
 
   virtual WidgetEvent* Duplicate() const
   {
     MOZ_ASSERT(mClass == eBasicEventClass,
                "Duplicate() must be overridden by sub class");
     WidgetEvent* result = new WidgetEvent(false, mMessage);
     result->AssignEventData(*this, true);
     result->mFlags = mFlags;