Bug 1278136 - Part 1: Add nsLayoutUtils::HasRelevantAnimationOfProperty. r=birtles

We want to know that an nsIFrame has a transform or opacity animations
regardless of its state, e.g., running on the main-thead, paused or
finished but in fill:forwards state, to create a stacking context
for the animation.

MozReview-Commit-ID: mNYsd5RO3u

--HG--
extra : rebase_source : 19f88d9f77f3c329f36a6505c6335bae64050a22
This commit is contained in:
Hiroyuki Ikezoe 2016-07-08 13:01:31 +09:00
Родитель 7cc7e32a9b
Коммит e7a860ecf8
2 изменённых файлов: 29 добавлений и 11 удалений

Просмотреть файл

@ -454,7 +454,7 @@ BackgroundClipTextEnabledPrefChangeCallback(const char* aPrefName,
template<typename TestType>
static bool
HasMatchingCurrentAnimations(const nsIFrame* aFrame, TestType&& aTest)
HasMatchingAnimations(const nsIFrame* aFrame, TestType&& aTest)
{
EffectSet* effects = EffectSet::GetEffectSet(aFrame);
if (!effects) {
@ -462,10 +462,6 @@ HasMatchingCurrentAnimations(const nsIFrame* aFrame, TestType&& aTest)
}
for (KeyframeEffectReadOnly* effect : *effects) {
if (!effect->IsCurrent()) {
continue;
}
if (aTest(*effect)) {
return true;
}
@ -478,10 +474,10 @@ bool
nsLayoutUtils::HasCurrentAnimationOfProperty(const nsIFrame* aFrame,
nsCSSProperty aProperty)
{
return HasMatchingCurrentAnimations(aFrame,
return HasMatchingAnimations(aFrame,
[&aProperty](KeyframeEffectReadOnly& aEffect)
{
return aEffect.HasAnimationOfProperty(aProperty);
return aEffect.IsCurrent() && aEffect.HasAnimationOfProperty(aProperty);
}
);
}
@ -489,12 +485,12 @@ nsLayoutUtils::HasCurrentAnimationOfProperty(const nsIFrame* aFrame,
bool
nsLayoutUtils::HasCurrentTransitions(const nsIFrame* aFrame)
{
return HasMatchingCurrentAnimations(aFrame,
return HasMatchingAnimations(aFrame,
[](KeyframeEffectReadOnly& aEffect)
{
// Since |aEffect| is current, it must have an associated Animation
// so we don't need to null-check the result of GetAnimation().
return aEffect.GetAnimation()->AsCSSTransition();
return aEffect.IsCurrent() && aEffect.GetAnimation()->AsCSSTransition();
}
);
}
@ -504,10 +500,24 @@ nsLayoutUtils::HasCurrentAnimationsForProperties(const nsIFrame* aFrame,
const nsCSSProperty* aProperties,
size_t aPropertyCount)
{
return HasMatchingCurrentAnimations(aFrame,
return HasMatchingAnimations(aFrame,
[&aProperties, &aPropertyCount](KeyframeEffectReadOnly& aEffect)
{
return aEffect.HasAnimationOfProperties(aProperties, aPropertyCount);
return aEffect.IsCurrent() &&
aEffect.HasAnimationOfProperties(aProperties, aPropertyCount);
}
);
}
bool
nsLayoutUtils::HasRelevantAnimationOfProperty(const nsIFrame* aFrame,
nsCSSProperty aProperty)
{
return HasMatchingAnimations(aFrame,
[&aProperty](KeyframeEffectReadOnly& aEffect)
{
return (aEffect.IsInEffect() || aEffect.IsCurrent()) &&
aEffect.HasAnimationOfProperty(aProperty);
}
);
}

Просмотреть файл

@ -2253,6 +2253,14 @@ public:
const nsCSSProperty* aProperties,
size_t aPropertyCount);
/**
* Returns true if the frame has current or in-effect (i.e. in before phase,
* running or filling) animations or transitions for the
* property.
*/
static bool HasRelevantAnimationOfProperty(const nsIFrame* aFrame,
nsCSSProperty aProperty);
/**
* Checks if off-main-thread animations are enabled.
*/