--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -580,17 +580,19 @@ nsTransitionManager::StyleContextChanged
}
nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
DebugOnly<bool> startedAny = false;
// We don't have to update transitions if display:none, although we will
// cancel them after restyling.
if (!afterChangeStyle->IsInDisplayNoneSubtree()) {
- startedAny = UpdateTransitions(disp, aElement, collection,
+ NonOwningAnimationTarget target = { aElement,
+ afterChangeStyle->GetPseudoType() };
+ startedAny = UpdateTransitions(disp, target, collection,
aOldStyleContext, afterChangeStyle);
}
MOZ_ASSERT(!startedAny || collection,
"must have element transitions if we started any transitions");
EffectCompositor::CascadeLevel cascadeLevel =
EffectCompositor::CascadeLevel::Transitions;
@@ -614,24 +616,25 @@ nsTransitionManager::StyleContextChanged
pseudoType,
cascadeLevel);
}
}
bool
nsTransitionManager::UpdateTransitions(
const nsStyleDisplay* aDisp,
- dom::Element* aElement,
+ NonOwningAnimationTarget& aTarget,
CSSTransitionCollection*& aElementTransitions,
nsStyleContext* aOldStyleContext,
nsStyleContext* aNewStyleContext)
{
MOZ_ASSERT(aDisp, "Null nsStyleDisplay");
MOZ_ASSERT(!aElementTransitions ||
- aElementTransitions->mElement == aElement, "Element mismatch");
+ aElementTransitions->mElement == aTarget.mElement,
+ "Element mismatch");
// Per http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html
// I'll consider only the transitions from the number of items in
// 'transition-property' on down, and later ones will override earlier
// ones (tracked using |whichStarted|).
bool startedAny = false;
nsCSSPropertyIDSet whichStarted;
for (uint32_t i = aDisp->mTransitionPropertyCount; i-- != 0; ) {
@@ -648,31 +651,31 @@ nsTransitionManager::UpdateTransitions(
if (property == eCSSPropertyExtra_no_properties ||
property == eCSSPropertyExtra_variable ||
property == eCSSProperty_UNKNOWN) {
// Nothing to do, but need to exclude this from cases below.
} else if (property == eCSSPropertyExtra_all_properties) {
for (nsCSSPropertyID p = nsCSSPropertyID(0);
p < eCSSProperty_COUNT_no_shorthands;
p = nsCSSPropertyID(p + 1)) {
- ConsiderInitiatingTransition(p, t, aElement, aElementTransitions,
+ ConsiderInitiatingTransition(p, t, aTarget, aElementTransitions,
aOldStyleContext, aNewStyleContext,
&startedAny, &whichStarted);
}
} else if (nsCSSProps::IsShorthand(property)) {
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property,
CSSEnabledState::eForAllContent)
{
- ConsiderInitiatingTransition(*subprop, t, aElement,
+ ConsiderInitiatingTransition(*subprop, t, aTarget,
aElementTransitions,
aOldStyleContext, aNewStyleContext,
&startedAny, &whichStarted);
}
} else {
- ConsiderInitiatingTransition(property, t, aElement, aElementTransitions,
+ ConsiderInitiatingTransition(property, t, aTarget, aElementTransitions,
aOldStyleContext, aNewStyleContext,
&startedAny, &whichStarted);
}
}
}
// Stop any transitions for properties that are no longer in
// 'transition-property', including finished transitions.
@@ -729,19 +732,17 @@ nsTransitionManager::UpdateTransitions(
// duration are both zero, or because the new value is not
// interpolable); a new transition would have anim->ToValue()
// matching currentValue
!ExtractNonDiscreteComputedValue(anim->TransitionProperty(),
aNewStyleContext, currentValue) ||
currentValue != anim->ToValue()) {
// stop the transition
if (anim->HasCurrentEffect()) {
- EffectSet* effectSet =
- EffectSet::GetEffectSet(aElement,
- aNewStyleContext->GetPseudoType());
+ EffectSet* effectSet = EffectSet::GetEffectSet(aTarget);
if (effectSet) {
effectSet->UpdateAnimationGeneration(mPresContext);
}
}
anim->CancelFromStyle();
animations.RemoveElementAt(i);
}
} while (i != 0);
@@ -798,28 +799,29 @@ GetTransitionKeyframes(nsCSSPropertyID a
return keyframes;
}
void
nsTransitionManager::ConsiderInitiatingTransition(
nsCSSPropertyID aProperty,
const StyleTransition& aTransition,
- dom::Element* aElement,
+ NonOwningAnimationTarget& aTarget,
CSSTransitionCollection*& aElementTransitions,
nsStyleContext* aOldStyleContext,
nsStyleContext* aNewStyleContext,
bool* aStartedAny,
nsCSSPropertyIDSet* aWhichStarted)
{
// IsShorthand itself will assert if aProperty is not a property.
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
"property out of range");
NS_ASSERTION(!aElementTransitions ||
- aElementTransitions->mElement == aElement, "Element mismatch");
+ aElementTransitions->mElement == aTarget.mElement,
+ "Element mismatch");
// Ignore disabled properties. We can arrive here if the transition-property
// is 'all' and the disabled property has a default value which derives value
// from another property, e.g. color.
if (!nsCSSProps::IsEnabled(aProperty, CSSEnabledState::eForAllContent)) {
return;
}
@@ -830,18 +832,16 @@ nsTransitionManager::ConsiderInitiatingT
// http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html .
return;
}
if (nsCSSProps::kAnimTypeTable[aProperty] == eStyleAnimType_None) {
return;
}
- dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
-
AnimationValue startValue, endValue;
bool haveValues =
ExtractNonDiscreteComputedValue(aProperty, aOldStyleContext, startValue) &&
ExtractNonDiscreteComputedValue(aProperty, aNewStyleContext, endValue);
bool haveChange = startValue != endValue;
bool shouldAnimate =
@@ -895,32 +895,32 @@ nsTransitionManager::ConsiderInitiatingT
// in-progress value (which is particularly easy to cause when we're
// currently in the 'transition-delay'). It also might happen because we
// just got a style change to a value that can't be interpolated.
OwningCSSTransitionPtrArray& animations =
aElementTransitions->mAnimations;
animations[currentIndex]->CancelFromStyle();
oldPT = nullptr; // Clear pointer so it doesn't dangle
animations.RemoveElementAt(currentIndex);
- EffectSet* effectSet =
- EffectSet::GetEffectSet(aElement, aNewStyleContext->GetPseudoType());
+ EffectSet* effectSet = EffectSet::GetEffectSet(aTarget);
if (effectSet) {
effectSet->UpdateAnimationGeneration(mPresContext);
}
if (animations.IsEmpty()) {
aElementTransitions->Destroy();
// |aElementTransitions| is now a dangling pointer!
aElementTransitions = nullptr;
}
// GetAnimationRule already called RestyleForAnimation.
}
return;
}
+ dom::DocumentTimeline* timeline = aTarget.mElement->OwnerDoc()->Timeline();
const nsTimingFunction &tf = aTransition.GetTimingFunction();
float delay = aTransition.GetDelay();
float duration = aTransition.GetDuration();
if (duration < 0.0) {
// The spec says a negative duration is treated as zero.
duration = 0.0;
}
@@ -971,48 +971,48 @@ nsTransitionManager::ConsiderInitiatingT
}
TimingParams timing =
TimingParamsFromCSSParams(duration, delay,
1.0 /* iteration count */,
dom::PlaybackDirection::Normal,
dom::FillMode::Backwards);
- // aElement is non-null here, so we emplace it directly.
+ // aTarget.mElement is non-null here, so we emplace it directly.
Maybe<OwningAnimationTarget> target;
- target.emplace(aElement, aNewStyleContext->GetPseudoType());
+ target.emplace(aTarget.mElement, aTarget.mPseudoType);
KeyframeEffectParams effectOptions;
RefPtr<ElementPropertyTransition> pt =
- new ElementPropertyTransition(aElement->OwnerDoc(), target, timing,
+ new ElementPropertyTransition(aTarget.mElement->OwnerDoc(), target, timing,
startForReversingTest, reversePortion,
effectOptions);
pt->SetKeyframes(GetTransitionKeyframes(aProperty,
Move(startValue), Move(endValue), tf),
aNewStyleContext);
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"ServoRestyleManager should not use nsTransitionManager "
"for transitions");
RefPtr<CSSTransition> animation =
new CSSTransition(mPresContext->Document()->GetScopeObject());
animation->SetOwningElement(
- OwningElementRef(*aElement, aNewStyleContext->GetPseudoType()));
+ OwningElementRef(*aTarget.mElement, aTarget.mPseudoType));
animation->SetTimelineNoUpdate(timeline);
animation->SetCreationSequence(
mPresContext->RestyleManager()->AsGecko()->GetAnimationGeneration());
animation->SetEffectFromStyle(pt);
animation->PlayFromStyle();
if (!aElementTransitions) {
bool createdCollection = false;
aElementTransitions =
CSSTransitionCollection::GetOrCreateAnimationCollection(
- aElement, aNewStyleContext->GetPseudoType(), &createdCollection);
+ aTarget.mElement, aTarget.mPseudoType, &createdCollection);
if (!aElementTransitions) {
MOZ_ASSERT(!createdCollection, "outparam should agree with return value");
NS_WARNING("allocating collection failed");
return;
}
if (createdCollection) {
AddElementCollection(aElementTransitions);
@@ -1057,18 +1057,17 @@ nsTransitionManager::ConsiderInitiatingT
animations[currentIndex] = animation;
} else {
if (!animations.AppendElement(animation)) {
NS_WARNING("out of memory");
return;
}
}
- EffectSet* effectSet =
- EffectSet::GetEffectSet(aElement, aNewStyleContext->GetPseudoType());
+ EffectSet* effectSet = EffectSet::GetEffectSet(aTarget);
if (effectSet) {
effectSet->UpdateAnimationGeneration(mPresContext);
}
*aStartedAny = true;
aWhichStarted->AddProperty(aProperty);
}
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -412,25 +412,25 @@ protected:
OwningCSSTransitionPtrArray;
// Update the transitions. It'd start new, replace, or stop current
// transitions if need. aDisp and aElement shouldn't be nullptr.
// aElementTransitions is the collection of current transitions, and it
// could be a nullptr if we don't have any transitions.
bool
UpdateTransitions(const nsStyleDisplay* aDisp,
- mozilla::dom::Element* aElement,
+ mozilla::NonOwningAnimationTarget& aTarget,
CSSTransitionCollection*& aElementTransitions,
nsStyleContext* aOldStyleContext,
nsStyleContext* aNewStyleContext);
void
ConsiderInitiatingTransition(nsCSSPropertyID aProperty,
const mozilla::StyleTransition& aTransition,
- mozilla::dom::Element* aElement,
+ mozilla::NonOwningAnimationTarget& aTarget,
CSSTransitionCollection*& aElementTransitions,
nsStyleContext* aOldStyleContext,
nsStyleContext* aNewStyleContext,
bool* aStartedAny,
nsCSSPropertyIDSet* aWhichStarted);
bool mInAnimationOnlyStyleUpdate;