Skip to content

Commit

Permalink
Bug 1292001 - Drop TransitionProperty() and ToValue() from ElementPro…
Browse files Browse the repository at this point in the history
…pertyTransition; r=boris

These are no longer needed and they make assumptions about the shape of the
keyframes/properties which are not valid if the keyframes are replaced.

Differential Revision: https://phabricator.services.mozilla.com/D64520

--HG--
extra : moz-landing-system : lando
  • Loading branch information
birtles committed Mar 2, 2020
1 parent cace4bb commit 2f448cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 28 deletions.
19 changes: 13 additions & 6 deletions layout/style/nsTransitionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,18 @@ void CSSTransition::UpdateStartValueFromReplacedTransition() {
void CSSTransition::SetEffectFromStyle(dom::AnimationEffect* aEffect) {
Animation::SetEffectNoUpdate(aEffect);

// Initialize transition property.
ElementPropertyTransition* pt = aEffect ? aEffect->AsTransition() : nullptr;
if (eCSSProperty_UNKNOWN == mTransitionProperty && pt) {
mTransitionProperty = pt->TransitionProperty();
mTransitionToValue = pt->ToValue();
// Initialize transition property and to value.
//
// Typically this should only be called with a KeyframeEffect representing
// a simple transition, but just to be sure we check the effect has the
// expected shape first.
const KeyframeEffect* keyframeEffect = aEffect->AsKeyframeEffect();
if (MOZ_LIKELY(keyframeEffect && keyframeEffect->Properties().Length() == 1 &&
keyframeEffect->Properties()[0].mSegments.Length() == 1)) {
mTransitionProperty = keyframeEffect->Properties()[0].mProperty;
mTransitionToValue = keyframeEffect->Properties()[0].mSegments[0].mToValue;
} else {
MOZ_ASSERT_UNREACHABLE("Transition effect has unexpected shape");
}
}

Expand Down Expand Up @@ -768,7 +775,7 @@ bool nsTransitionManager::ConsiderInitiatingTransition(

duration *= valuePortion;

startForReversingTest = oldPT->ToValue();
startForReversingTest = oldTransition->ToValue();
reversePortion = valuePortion;
}

Expand Down
22 changes: 0 additions & 22 deletions layout/style/nsTransitionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,6 @@ struct ElementPropertyTransition : public dom::KeyframeEffect {
return this;
}

nsCSSPropertyID TransitionProperty() const {
MOZ_ASSERT(mKeyframes.Length() == 2,
"Transitions should have exactly two animation keyframes. "
"Perhaps we are using an un-initialized transition?");
MOZ_ASSERT(mKeyframes[0].mPropertyValues.Length() == 1,
"Transitions should have exactly one property in their first "
"frame");
return mKeyframes[0].mPropertyValues[0].mProperty;
}

AnimationValue ToValue() const {
// 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 AnimationValue();
}
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
Expand Down

0 comments on commit 2f448cd

Please sign in to comment.