Bug 1245748 - Add an assignment operator to Keyframe that takes an rvalue reference; r?heycam draft
authorBrian Birtles <birtles@gmail.com>
Tue, 29 Mar 2016 11:29:20 +0900
changeset 345707 3501e38a53ef143e8b6e476f4c6c0cbdb3661f5a
parent 345706 3a6102002282b7a0ce84a96ccc1b3d8b18423097
child 345708 425195ff458ab3fd6066cf06999ee717c7158722
push id14148
push userbbirtles@mozilla.com
push dateWed, 30 Mar 2016 04:59:38 +0000
reviewersheycam
bugs1245748
milestone48.0a1
Bug 1245748 - Add an assignment operator to Keyframe that takes an rvalue reference; r?heycam This is needed in order to use std::stable_sort with this type since some implementations of std::stable_sort require this (as opposed to simply a move constructor). MozReview-Commit-ID: 5QmcIxkC4aB
dom/animation/KeyframeEffect.h
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -84,21 +84,26 @@ struct PropertyValuePair
  * When the target element or style context changes, however, we rebuild these
  * per-property arrays from the original list of keyframes objects. As a result,
  * these objects represent the master definition of the effect's values.
  */
 struct Keyframe
 {
   Keyframe() = default;
   Keyframe(Keyframe&& aOther)
-    : mOffset(aOther.mOffset)
-    , mComputedOffset(aOther.mComputedOffset)
-    , mTimingFunction(Move(aOther.mTimingFunction))
-    , mPropertyValues(Move(aOther.mPropertyValues))
+  {
+    *this = Move(aOther);
+  }
+  Keyframe& operator=(Keyframe&& aOther)
   {
+    mOffset         = aOther.mOffset;
+    mComputedOffset = aOther.mComputedOffset;
+    mTimingFunction = Move(aOther.mTimingFunction);
+    mPropertyValues = Move(aOther.mPropertyValues);
+    return *this;
   }
 
   Maybe<double>                 mOffset;
   double                        mComputedOffset = 0.0;
   Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
                                                  // "linear"
   nsTArray<PropertyValuePair>   mPropertyValues;
 };