Bug 1267187 - added assert before doing modulo with the second argument being |num|. r=birtles
authorAndi-Bogdan Postelnicu <bogdan.postelnicu@softvision.ro>
Mon, 25 Apr 2016 13:47:21 +0300
changeset 296092 8e9e288140e0e31d287f1a79cf354cecf02eacbb
parent 296091 7027dba69da42164fc1600d665e36053154ed693
child 296093 4ab494362b8d08b7ff4b3e46df306cf3b741910d
push id76185
push userBogdan.Postelnicu@softvision.ro
push dateWed, 04 May 2016 11:55:17 +0000
treeherdermozilla-inbound@8e9e288140e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1267187
milestone49.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 1267187 - added assert before doing modulo with the second argument being |num|. r=birtles MozReview-Commit-ID: eUZeAbudib
layout/style/nsRuleNode.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -5311,16 +5311,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
     display->*(i.sdCount) = d.num;
   }
 
   // Fill in the transitions we just allocated with the appropriate values.
   for (uint32_t i = 0; i < numTransitions; ++i) {
     StyleTransition *transition = &display->mTransitions[i];
 
     if (i >= delay.num) {
+      MOZ_ASSERT(delay.num, "delay.num must be greater than 0");
       transition->SetDelay(display->mTransitions[i % delay.num].GetDelay());
     } else if (delay.unit == eCSSUnit_Inherit) {
       // FIXME (Bug 522599) (for all transition properties): write a test that
       // detects when this was wrong for i >= delay.num if parent had
       // count for this property not equal to length
       MOZ_ASSERT(i < parentDisplay->mTransitionDelayCount,
                  "delay.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
@@ -5339,16 +5340,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
           transition->SetDelay(delay.list->mValue.GetFloatValue());
           break;
         default:
           NS_NOTREACHED("Invalid delay unit");
       }
     }
 
     if (i >= duration.num) {
+      MOZ_ASSERT(duration.num, "duration.num must be greater than 0");
       transition->SetDuration(
         display->mTransitions[i % duration.num].GetDuration());
     } else if (duration.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mTransitionDurationCount,
                  "duration.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       transition->SetDuration(parentDisplay->mTransitions[i].GetDuration());
@@ -5365,16 +5367,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
           transition->SetDuration(duration.list->mValue.GetFloatValue());
           break;
         default:
           NS_NOTREACHED("Invalid duration unit");
       }
     }
 
     if (i >= property.num) {
+      MOZ_ASSERT(property.num, "property.num must be greater than 0");
       transition->CopyPropertyFrom(display->mTransitions[i % property.num]);
     } else if (property.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mTransitionPropertyCount,
                  "property.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       transition->CopyPropertyFrom(parentDisplay->mTransitions[i]);
     } else if (property.unit == eCSSUnit_Initial ||
@@ -5400,16 +5403,18 @@ nsRuleNode::ComputeDisplayData(void* aSt
       } else {
         MOZ_ASSERT(val.GetUnit() == eCSSUnit_All,
                    "Invalid transition property unit");
         transition->SetProperty(eCSSPropertyExtra_all_properties);
       }
     }
 
     if (i >= timingFunction.num) {
+      MOZ_ASSERT(timingFunction.num,
+        "timingFunction.num must be greater than 0");
       transition->SetTimingFunction(
         display->mTransitions[i % timingFunction.num].GetTimingFunction());
     } else if (timingFunction.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mTransitionTimingFunctionCount,
                  "timingFunction.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       transition->SetTimingFunction(
@@ -5468,16 +5473,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
     display->*(i.sdCount) = d.num;
   }
 
   // Fill in the animations we just allocated with the appropriate values.
   for (uint32_t i = 0; i < numAnimations; ++i) {
     StyleAnimation *animation = &display->mAnimations[i];
 
     if (i >= animDelay.num) {
+      MOZ_ASSERT(animDelay.num, "animDelay.num must be greater than 0");
       animation->SetDelay(display->mAnimations[i % animDelay.num].GetDelay());
     } else if (animDelay.unit == eCSSUnit_Inherit) {
       // FIXME (Bug 522599) (for all animation properties): write a test that
       // detects when this was wrong for i >= animDelay.num if parent had
       // count for this property not equal to length
       MOZ_ASSERT(i < parentDisplay->mAnimationDelayCount,
                  "animDelay.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
@@ -5496,16 +5502,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
           animation->SetDelay(animDelay.list->mValue.GetFloatValue());
           break;
         default:
           NS_NOTREACHED("Invalid delay unit");
       }
     }
 
     if (i >= animDuration.num) {
+      MOZ_ASSERT(animDuration.num, "animDuration.num must be greater than 0");
       animation->SetDuration(
         display->mAnimations[i % animDuration.num].GetDuration());
     } else if (animDuration.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationDurationCount,
                  "animDuration.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetDuration(parentDisplay->mAnimations[i].GetDuration());
@@ -5522,16 +5529,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
           animation->SetDuration(animDuration.list->mValue.GetFloatValue());
           break;
         default:
           NS_NOTREACHED("Invalid duration unit");
       }
     }
 
     if (i >= animName.num) {
+      MOZ_ASSERT(animName.num, "animName.num must be greater than 0");
       animation->SetName(display->mAnimations[i % animName.num].GetName());
     } else if (animName.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationNameCount,
                  "animName.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetName(parentDisplay->mAnimations[i].GetName());
     } else if (animName.unit == eCSSUnit_Initial ||
@@ -5550,16 +5558,18 @@ nsRuleNode::ComputeDisplayData(void* aSt
           break;
         }
         default:
           MOZ_ASSERT(false, "Invalid animation-name unit");
       }
     }
 
     if (i >= animTimingFunction.num) {
+      MOZ_ASSERT(animTimingFunction.num,
+        "animTimingFunction.num must be greater than 0");
       animation->SetTimingFunction(
         display->mAnimations[i % animTimingFunction.num].GetTimingFunction());
     } else if (animTimingFunction.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationTimingFunctionCount,
                  "animTimingFunction.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetTimingFunction(
@@ -5569,16 +5579,18 @@ nsRuleNode::ComputeDisplayData(void* aSt
       animation->SetTimingFunction(
         nsTimingFunction(NS_STYLE_TRANSITION_TIMING_FUNCTION_EASE));
     } else if (animTimingFunction.list) {
       ComputeTimingFunction(animTimingFunction.list->mValue,
                             animation->TimingFunctionSlot());
     }
 
     if (i >= animDirection.num) {
+      MOZ_ASSERT(animDirection.num,
+        "animDirection.num must be greater than 0");
       animation->SetDirection(display->mAnimations[i % animDirection.num].GetDirection());
     } else if (animDirection.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationDirectionCount,
                  "animDirection.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetDirection(parentDisplay->mAnimations[i].GetDirection());
     } else if (animDirection.unit == eCSSUnit_Initial ||
@@ -5588,16 +5600,17 @@ nsRuleNode::ComputeDisplayData(void* aSt
       MOZ_ASSERT(animDirection.list->mValue.GetUnit() == eCSSUnit_Enumerated,
                  "Invalid animation-direction unit");
 
       animation->SetDirection(
           static_cast<dom::PlaybackDirection>(animDirection.list->mValue.GetIntValue()));
     }
 
     if (i >= animFillMode.num) {
+      MOZ_ASSERT(animFillMode.num, "animFillMode.num must be greater than 0");
       animation->SetFillMode(display->mAnimations[i % animFillMode.num].GetFillMode());
     } else if (animFillMode.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationFillModeCount,
                  "animFillMode.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetFillMode(parentDisplay->mAnimations[i].GetFillMode());
     } else if (animFillMode.unit == eCSSUnit_Initial ||
@@ -5607,16 +5620,18 @@ nsRuleNode::ComputeDisplayData(void* aSt
       MOZ_ASSERT(animFillMode.list->mValue.GetUnit() == eCSSUnit_Enumerated,
                  "Invalid animation-fill-mode unit");
 
       animation->SetFillMode(
           static_cast<dom::FillMode>(animFillMode.list->mValue.GetIntValue()));
     }
 
     if (i >= animPlayState.num) {
+      MOZ_ASSERT(animPlayState.num,
+        "animPlayState.num must be greater than 0");
       animation->SetPlayState(display->mAnimations[i % animPlayState.num].GetPlayState());
     } else if (animPlayState.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationPlayStateCount,
                  "animPlayState.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetPlayState(parentDisplay->mAnimations[i].GetPlayState());
     } else if (animPlayState.unit == eCSSUnit_Initial ||
@@ -5625,16 +5640,18 @@ nsRuleNode::ComputeDisplayData(void* aSt
     } else if (animPlayState.list) {
       MOZ_ASSERT(animPlayState.list->mValue.GetUnit() == eCSSUnit_Enumerated,
                  "Invalid animation-play-state unit");
 
       animation->SetPlayState(animPlayState.list->mValue.GetIntValue());
     }
 
     if (i >= animIterationCount.num) {
+      MOZ_ASSERT(animIterationCount.num,
+        "animIterationCount.num must be greater than 0");
       animation->SetIterationCount(display->mAnimations[i % animIterationCount.num].GetIterationCount());
     } else if (animIterationCount.unit == eCSSUnit_Inherit) {
       MOZ_ASSERT(i < parentDisplay->mAnimationIterationCountCount,
                  "animIterationCount.num computed incorrectly");
       MOZ_ASSERT(!conditions.Cacheable(),
                  "should have made conditions.Cacheable() false above");
       animation->SetIterationCount(parentDisplay->mAnimations[i].GetIterationCount());
     } else if (animIterationCount.unit == eCSSUnit_Initial ||