Bug 1245748 - Add a Move constructor to Keyframe draft
authorBrian Birtles <birtles@gmail.com>
Thu, 24 Mar 2016 10:39:29 +0900
changeset 344239 85ae08b5e6fcc665e33fc7704a7bba061da66a32
parent 344238 1167cfff6e2bbc5aac92aea0a439788cac96f3c5
child 516912 16f61f9eef4c46baed5f326045d097b52885aaa2
push id13778
push userbbirtles@mozilla.com
push dateThu, 24 Mar 2016 03:27:42 +0000
bugs1245748
milestone48.0a1
Bug 1245748 - Add a Move constructor to Keyframe I have confirmed that by adding this, we end up calling SwapElements() on the mPropertyValues member when we build up the nsTArray<Keyframe> result in GetKeyframeListFromPropertyIndexedKeyframe. Without this explicit move constructor (i.e. with only the default move constructor) the copy-constructor for mPropertyValues is called. MozReview-Commit-ID: 6IWkP97RFUr
dom/animation/KeyframeEffect.h
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -77,16 +77,25 @@ struct PropertyValuePair
  * values, etc.
  *
  * 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))
+  {
+  }
+
   Maybe<double>                 mOffset;
   double                        mComputedOffset = 0.0;
   Maybe<ComputedTimingFunction> mTimingFunction; // Nothing() here means
                                                  // "linear"
   nsTArray<PropertyValuePair>   mPropertyValues;
 };
 
 struct AnimationPropertySegment