Bug 1358966 - Call additive or accumulative functions for each sub properties of shorthand. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 09 Jun 2017 06:19:37 +0900
changeset 411218 a9f39ff3b27bd0ca1b9a3e80a2d7e0e195a249ef
parent 411217 854d41e31f4bcfbe093b89580b51d72a24c7c095
child 411219 9dfcdc2bfc8a2d596a0d449747279bfaf41281b7
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1358966
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1358966 - Call additive or accumulative functions for each sub properties of shorthand. r=birtles MozReview-Commit-ID: 26uflUKa2oa
dom/smil/nsSMILCSSValueType.cpp
--- a/dom/smil/nsSMILCSSValueType.cpp
+++ b/dom/smil/nsSMILCSSValueType.cpp
@@ -286,51 +286,66 @@ AddOrAccumulateForServo(nsSMILValue& aDe
                         const ValueWrapper* aValueToAddWrapper,
                         ValueWrapper* aDestWrapper,
                         CompositeOperation aCompositeOp,
                         uint64_t aCount)
 {
   nsCSSPropertyID property = aValueToAddWrapper
                              ? aValueToAddWrapper->mPropID
                              : aDestWrapper->mPropID;
-  const RefPtr<RawServoAnimationValue>* valueToAdd =
-    aValueToAddWrapper
-    ? &aValueToAddWrapper->mServoValues[0]
-    : nullptr;
-  const RefPtr<RawServoAnimationValue>* destValue =
-    aDestWrapper
-    ? &aDestWrapper->mServoValues[0]
-    : nullptr;
-  RefPtr<RawServoAnimationValue> zeroValueStorage;
-  if (!FinalizeServoAnimationValues(valueToAdd, destValue, zeroValueStorage)) {
-    return false;
+  size_t len = aValueToAddWrapper
+               ? aValueToAddWrapper->mServoValues.Length()
+               : aDestWrapper->mServoValues.Length();
+
+  MOZ_ASSERT(!aValueToAddWrapper || !aDestWrapper ||
+             aValueToAddWrapper->mServoValues.Length() ==
+               aDestWrapper->mServoValues.Length(),
+             "Both of values'length in the wrappers should be the same if "
+             "both of them exist");
+
+  for (size_t i = 0; i < len; i++) {
+    const RefPtr<RawServoAnimationValue>* valueToAdd =
+      aValueToAddWrapper
+      ? &aValueToAddWrapper->mServoValues[i]
+      : nullptr;
+    const RefPtr<RawServoAnimationValue>* destValue =
+      aDestWrapper
+      ? &aDestWrapper->mServoValues[i]
+      : nullptr;
+    RefPtr<RawServoAnimationValue> zeroValueStorage;
+    if (!FinalizeServoAnimationValues(valueToAdd, destValue, zeroValueStorage)) {
+      return false;
+    }
+
+    // FinalizeServoAnimationValues may have updated destValue so we should make
+    // sure the aDest and aDestWrapper outparams are up-to-date.
+    if (aDestWrapper) {
+      aDestWrapper->mServoValues[i] = *destValue;
+    } else {
+      // aDest may be a barely-initialized "zero" destination.
+      aDest.mU.mPtr = aDestWrapper = new ValueWrapper(property, *destValue);
+      aDestWrapper->mServoValues.SetLength(len);
+    }
+
+    RefPtr<RawServoAnimationValue> result;
+    if (aCompositeOp == CompositeOperation::Add) {
+      result = Servo_AnimationValues_Add(*destValue, *valueToAdd).Consume();
+    } else {
+      result = Servo_AnimationValues_Accumulate(*destValue,
+                                                *valueToAdd,
+                                                aCount).Consume();
+    }
+
+    if (!result) {
+      return false;
+    }
+    aDestWrapper->mServoValues[i] = result;
   }
 
-  // FinalizeServoAnimationValues may have updated destValue so we should make
-  // sure the aDest and aDestWrapper outparams are up-to-date.
-  if (aDestWrapper) {
-    aDestWrapper->mServoValues[0] = *destValue;
-  } else {
-    // aDest may be a barely-initialized "zero" destination.
-    aDest.mU.mPtr = aDestWrapper = new ValueWrapper(property, *destValue);
-  }
-
-  RefPtr<RawServoAnimationValue> result;
-  if (aCompositeOp == CompositeOperation::Add) {
-    result = Servo_AnimationValues_Add(*destValue, *valueToAdd).Consume();
-  } else {
-    result = Servo_AnimationValues_Accumulate(*destValue,
-                                              *valueToAdd,
-                                              aCount).Consume();
-  }
-
-  if (result) {
-    aDestWrapper->mServoValues[0] = result;
-  }
-  return result;
+  return true;
 }
 
 static bool
 AddOrAccumulate(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
                 CompositeOperation aCompositeOp, uint64_t aCount)
 {
   MOZ_ASSERT(aValueToAdd.mType == aDest.mType,
              "Trying to add mismatching types");
@@ -351,20 +366,24 @@ AddOrAccumulate(nsSMILValue& aDest, cons
                              ? valueToAddWrapper->mPropID
                              : destWrapper->mPropID;
   // Special case: font-size-adjust and stroke-dasharray are explicitly
   // non-additive (even though StyleAnimationValue *could* support adding them)
   if (property == eCSSProperty_font_size_adjust ||
       property == eCSSProperty_stroke_dasharray) {
     return false;
   }
+  // Skip font shorthand since it includes font-size-adjust.
+  if (property == eCSSProperty_font) {
+    return false;
+  }
 
   bool isServo = valueToAddWrapper
-                 ? valueToAddWrapper->mServoValues[0]
-                 : destWrapper->mServoValues[0];
+                 ? !valueToAddWrapper->mServoValues.IsEmpty()
+                 : !destWrapper->mServoValues.IsEmpty();
   if (isServo) {
     return AddOrAccumulateForServo(aDest,
                                    valueToAddWrapper,
                                    destWrapper,
                                    aCompositeOp,
                                    aCount);
   }