Bug 1352067 - Part 2: Avoid passing any nullptr into Servo_AnimationValue_DeepEqual. draft
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 31 Mar 2017 11:04:08 +0800
changeset 553949 312fe2269afd00312a5bb646ee6bf1a34a917ac7
parent 553948 b423c681232530f8fba6988d79dd7bdacc12030f
child 622251 5ead8f48bac76952a91e2aa10dd8aaf7dab7c804
push id51838
push userbmo:boris.chiou@gmail.com
push dateFri, 31 Mar 2017 03:08:58 +0000
bugs1352067
milestone55.0a1
Bug 1352067 - Part 2: Avoid passing any nullptr into Servo_AnimationValue_DeepEqual. The FFI type conversion in AnimationValue::as_arc will check if the parameter is nullptr or not. If it is, we will get a debug assertion, so we shouldn't pass a nullptr into it. Add a short-circuit evaluation in operator==(). MozReview-Commit-ID: KWko2ipJwbo
layout/style/StyleAnimationValue.cpp
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -5198,17 +5198,20 @@ StyleAnimationValue::operator==(const St
 
 bool
 AnimationValue::operator==(const AnimationValue& aOther) const
 {
   // It is possible to compare an empty AnimationValue with others, so both
   // mServo and mGecko could be null while comparing.
   MOZ_ASSERT(!mServo || mGecko.IsNull());
   if (mServo) {
-    return Servo_AnimationValue_DeepEqual(mServo, aOther.mServo);
+    // If one of the value is nullptr, Servo_AnimationValue_DeepEqual will
+    // trigger a debug assertion.
+    return !!aOther.mServo &&
+           Servo_AnimationValue_DeepEqual(mServo, aOther.mServo);
   }
   return mGecko == aOther.mGecko;
 }
 
 float
 AnimationValue::GetOpacity() const
 {
   MOZ_ASSERT(!mServo != mGecko.IsNull());