Bug 1305325 - Part 2: Add AnimationProperty::HasNonReplaceComposite. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Wed, 16 Nov 2016 06:30:57 +0900
changeset 439343 0ed5e832d9dc32aefcbeb665d79516b9db78c810
parent 439342 3a6e115ed35a8fb8ead874f78f0afbb5291b3764
child 439344 a7af1e013687423f7c72fc21adaf04700bd336d4
push id35977
push userhiikezoe@mozilla-japan.org
push dateTue, 15 Nov 2016 21:34:46 +0000
reviewersbirtles
bugs1305325
milestone53.0a1
Bug 1305325 - Part 2: Add AnimationProperty::HasNonReplaceComposite. r?birtles We will resolve base values only if HasNonReplaceComposite() returns true. MozReview-Commit-ID: LUui9BpuphW
dom/animation/KeyframeEffectReadOnly.h
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -115,16 +115,18 @@ struct Keyframe
   nsTArray<PropertyValuePair>   mPropertyValues;
 };
 
 struct AnimationPropertySegment
 {
   float mFromKey, mToKey;
   StyleAnimationValue mFromValue, mToValue;
   Maybe<ComputedTimingFunction> mTimingFunction;
+  dom::CompositeOperation mFromComposite = dom::CompositeOperation::Replace;
+  dom::CompositeOperation mToComposite = dom::CompositeOperation::Replace;
 
   bool operator==(const AnimationPropertySegment& aOther) const
   {
     return mFromKey == aOther.mFromKey &&
            mToKey == aOther.mToKey &&
            mFromValue == aOther.mFromValue &&
            mToValue == aOther.mToValue &&
            mTimingFunction == aOther.mTimingFunction;
@@ -176,16 +178,29 @@ struct AnimationProperty
   {
     return mProperty == aOther.mProperty &&
            mSegments == aOther.mSegments;
   }
   bool operator!=(const AnimationProperty& aOther) const
   {
     return !(*this == aOther);
   }
+
+  // Returns true if there is at least one segment with a composite value that
+  // is not 'replace'.
+  bool HasNonReplaceComposite() const
+  {
+    for (const AnimationPropertySegment& segment : mSegments) {
+      if (segment.mFromComposite != dom::CompositeOperation::Replace ||
+          segment.mToComposite != dom::CompositeOperation::Replace) {
+        return true;
+      }
+    }
+    return false;
+  }
 };
 
 struct ElementPropertyTransition;
 
 namespace dom {
 
 class Animation;