Bug 1265611 - Make TransitionProperty() and ToValue() safe when mProperties is not set
MozReview-Commit-ID: KIzE5jdvPfT
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -48,29 +48,38 @@ struct ElementPropertyTransition : publi
ElementPropertyTransition* AsTransition() override { return this; }
const ElementPropertyTransition* AsTransition() const override
{
return this;
}
nsCSSProperty TransitionProperty() const {
- MOZ_ASSERT(mProperties.Length() == 1,
- "Transitions should have exactly one animation property. "
+ MOZ_ASSERT(mFrames.Length() == 2,
+ "Transitions should have exactly two animation frames. "
"Perhaps we are using an un-initialized transition?");
- return mProperties[0].mProperty;
+ MOZ_ASSERT(mFrames[0].mPropertyValues.Length() == 1,
+ "Transitions should have exactly one property in their first "
+ "frame");
+ return mFrames[0].mPropertyValues[0].mProperty;
}
StyleAnimationValue ToValue() const {
- MOZ_ASSERT(mProperties.Length() == 1,
- "Transitions should have exactly one animation property");
- MOZ_ASSERT(mProperties[0].mSegments.Length() == 1,
- "Transitions should have one animation property segment ");
+ // If we failed to generate properties from the transition frames,
+ // return a null value but also show a warning since we should be
+ // detecting that kind of situation in advance and not generating a
+ // transition in the first place.
+ if (mProperties.Length() < 1 ||
+ mProperties[0].mSegments.Length() < 1) {
+ NS_WARNING("Failed to generate transition property values");
+ return StyleAnimationValue();
+ }
return mProperties[0].mSegments[0].mToValue;
}
+
// This is the start value to be used for a check for whether a
// transition is being reversed. Normally the same as
// mProperties[0].mSegments[0].mFromValue, except when this transition
// started as the reversal of another in-progress transition.
// Needed so we can handle two reverses in a row.
StyleAnimationValue mStartForReversingTest;
// Likewise, the portion (in value space) of the "full" reversed
// transition that we're actually covering. For example, if a :hover