Bug 1430884 - Factor out checking the animation on the given frame can be throttled if the frame is not visible. r=birtles

MozReview-Commit-ID: Kl7qYFXiVqr
This commit is contained in:
Hiroyuki Ikezoe
2018-06-25 11:51:05 +09:00
parent c716dc80d1
commit 5d57d695a1
2 changed files with 38 additions and 28 deletions

View File

@@ -1193,6 +1193,41 @@ KeyframeEffect::OverflowRegionRefreshInterval()
return kOverflowRegionRefreshInterval;
}
bool
KeyframeEffect::CanThrottleIfNotVisible(nsIFrame& aFrame) const
{
// Unless we are newly in-effect, we can throttle the animation if the
// animation is paint only and the target frame is out of view or the document
// is in background tabs.
if (mInEffectOnLastAnimationTimingUpdate && CanIgnoreIfNotVisible()) {
nsIPresShell* presShell = GetPresShell();
if (presShell && !presShell->IsActive()) {
return true;
}
const bool isVisibilityHidden =
!aFrame.IsVisibleOrMayHaveVisibleDescendants();
if ((isVisibilityHidden && !HasVisibilityChange()) ||
aFrame.IsScrolledOutOfView()) {
// Unthrottle the animation if there is a change hint that might affect
// the overflow region.
if (HasPropertiesThatMightAffectOverflow()) {
// Don't throttle finite animations since the animation might suddenly
// come into view and if it was throttled it will be out-of-sync.
if (HasFiniteActiveDuration()) {
return false;
}
return isVisibilityHidden
? CanThrottleOverflowChangesInScrollable(aFrame)
: CanThrottleOverflowChanges(aFrame);
}
return true;
}
}
return false;
}
bool
KeyframeEffect::CanThrottle() const
{
@@ -1218,34 +1253,8 @@ KeyframeEffect::CanThrottle() const
return true;
}
// Unless we are newly in-effect, we can throttle the animation if the
// animation is paint only and the target frame is out of view or the document
// is in background tabs.
if (mInEffectOnLastAnimationTimingUpdate && CanIgnoreIfNotVisible()) {
nsIPresShell* presShell = GetPresShell();
if (presShell && !presShell->IsActive()) {
return true;
}
const bool isVisibilityHidden =
!frame->IsVisibleOrMayHaveVisibleDescendants();
if ((isVisibilityHidden && !HasVisibilityChange()) ||
frame->IsScrolledOutOfView()) {
// Unthrottle the animation if there is a change hint that might affect
// the overflow region.
if (HasPropertiesThatMightAffectOverflow()) {
// Don't throttle finite animations since the animation might suddenly
// come into view and if it was throttled it will be out-of-sync.
if (HasFiniteActiveDuration()) {
return false;
}
return isVisibilityHidden
? CanThrottleOverflowChangesInScrollable(*frame)
: CanThrottleOverflowChanges(*frame);
}
return true;
}
if (CanThrottleIfNotVisible(*frame)) {
return true;
}
// First we need to check layer generation and transform overflow

View File

@@ -423,6 +423,7 @@ private:
bool CanThrottle() const;
bool CanThrottleOverflowChanges(const nsIFrame& aFrame) const;
bool CanThrottleOverflowChangesInScrollable(nsIFrame& aFrame) const;
bool CanThrottleIfNotVisible(nsIFrame& aFrame) const;
// Returns true if the computedTiming has changed since the last
// composition.