Bug 1430884 - Rename unthrottling transform animations stuff. r=birtles

In the next patch, we are going to unthrottle UpdateOverflow change hint which
is also produced by non-transform properties.

MozReview-Commit-ID: BrJxo32uBJO

--HG--
extra : rebase_source : daeb91bc4ce44a120ce4092f9f113c78f0553326
This commit is contained in:
Hiroyuki Ikezoe 2018-06-25 09:12:21 +09:00
parent 79b444cd26
commit f0ecedfe01
3 changed files with 36 additions and 34 deletions

View File

@ -170,13 +170,13 @@ public:
size_t Count() const { return mEffects.Count(); }
const TimeStamp& LastTransformSyncTime() const
const TimeStamp& LastOverflowAnimationSyncTime() const
{
return mLastTransformSyncTime;
return mLastOverflowAnimationSyncTime;
}
void UpdateLastTransformSyncTime(const TimeStamp& aRefreshTime)
void UpdateLastOverflowAnimationSyncTime(const TimeStamp& aRefreshTime)
{
mLastTransformSyncTime = aRefreshTime;
mLastOverflowAnimationSyncTime = aRefreshTime;
}
bool CascadeNeedsUpdate() const { return mCascadeNeedsUpdate; }
@ -207,11 +207,14 @@ private:
OwningEffectSet mEffects;
// Refresh driver timestamp from the moment when transform animations in this
// effect set were last updated and sent to the compositor. This is used for
// transform animations that run on the compositor but need to be updated on
// the main thread periodically (e.g. so scrollbars can be updated).
TimeStamp mLastTransformSyncTime;
// Refresh driver timestamp from the moment when the animations which produce
// overflow change hints in this effect set were last updated.
// This is used for animations whose main-thread restyling is throttled either
// because they are running on the compositor or because they are not visible.
// We still need to update them on the main thread periodically, however (e.g.
// so scrollbars can be updated), so this tracks the last time we did that.
TimeStamp mLastOverflowAnimationSyncTime;
// Dirty flag to represent when the mPropertiesWithImportantRules and
// mPropertiesForAnimationsLevel on effects in this set might need to be

View File

@ -511,11 +511,11 @@ KeyframeEffect::ComposeStyle(
ComposeStyleRule(aComposeResult, prop, *segment, computedTiming);
}
// If the animation produces a transform change hint that affects the overflow
// region, we need to record the current time to unthrottle the animation
// If the animation produces a change hint that affects the overflow region,
// we need to record the current time to unthrottle the animation
// periodically when the animation is being throttled because it's scrolled
// out of view.
if (HasTransformThatMightAffectOverflow()) {
if (HasPropertiesThatMightAffectOverflow()) {
nsPresContext* presContext =
nsContentUtils::GetContextForContent(mTarget->mElement);
if (presContext) {
@ -524,7 +524,7 @@ KeyframeEffect::ComposeStyle(
EffectSet::GetEffectSet(mTarget->mElement, mTarget->mPseudoType);
MOZ_ASSERT(effectSet, "ComposeStyle should only be called on an effect "
"that is part of an effect set");
effectSet->UpdateLastTransformSyncTime(now);
effectSet->UpdateLastOverflowAnimationSyncTime(now);
}
}
}
@ -1231,19 +1231,18 @@ KeyframeEffect::CanThrottle() const
!frame->IsVisibleOrMayHaveVisibleDescendants();
if ((isVisibilityHidden && !HasVisibilityChange()) ||
frame->IsScrolledOutOfView()) {
// If there are transform change hints, unthrottle the animation
// periodically since it might affect the overflow region.
if (HasTransformThatMightAffectOverflow()) {
// Don't throttle finite transform animations since the animation might
// suddenly come into view and if it was throttled it will be
// out-of-sync.
// 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
? CanThrottleTransformChangesInScrollable(*frame)
: CanThrottleTransformChanges(*frame);
? CanThrottleOverflowChangesInScrollable(*frame)
: CanThrottleOverflowChanges(*frame);
}
return true;
}
@ -1279,8 +1278,8 @@ KeyframeEffect::CanThrottle() const
// If this is a transform animation that affects the overflow region,
// we should unthrottle the animation periodically.
if (HasTransformThatMightAffectOverflow() &&
!CanThrottleTransformChangesInScrollable(*frame)) {
if (HasPropertiesThatMightAffectOverflow() &&
!CanThrottleOverflowChangesInScrollable(*frame)) {
return false;
}
}
@ -1295,24 +1294,24 @@ KeyframeEffect::CanThrottle() const
}
bool
KeyframeEffect::CanThrottleTransformChanges(const nsIFrame& aFrame) const
KeyframeEffect::CanThrottleOverflowChanges(const nsIFrame& aFrame) const
{
TimeStamp now = aFrame.PresContext()->RefreshDriver()->MostRecentRefresh();
EffectSet* effectSet = EffectSet::GetEffectSet(mTarget->mElement,
mTarget->mPseudoType);
MOZ_ASSERT(effectSet, "CanThrottleTransformChanges is expected to be called"
MOZ_ASSERT(effectSet, "CanOverflowTransformChanges is expected to be called"
" on an effect in an effect set");
MOZ_ASSERT(mAnimation, "CanThrottleTransformChanges is expected to be called"
MOZ_ASSERT(mAnimation, "CanOverflowTransformChanges is expected to be called"
" on an effect with a parent animation");
TimeStamp lastSyncTime = effectSet->LastTransformSyncTime();
TimeStamp lastSyncTime = effectSet->LastOverflowAnimationSyncTime();
// If this animation can cause overflow, we can throttle some of the ticks.
return (!lastSyncTime.IsNull() &&
(now - lastSyncTime) < OverflowRegionRefreshInterval());
}
bool
KeyframeEffect::CanThrottleTransformChangesInScrollable(nsIFrame& aFrame) const
KeyframeEffect::CanThrottleOverflowChangesInScrollable(nsIFrame& aFrame) const
{
// If the target element is not associated with any documents, we don't care
// it.
@ -1333,7 +1332,7 @@ KeyframeEffect::CanThrottleTransformChangesInScrollable(nsIFrame& aFrame) const
return true;
}
if (CanThrottleTransformChanges(aFrame)) {
if (CanThrottleOverflowChanges(aFrame)) {
return true;
}

View File

@ -421,8 +421,8 @@ private:
nsIFrame* GetStyleFrame() const;
bool CanThrottle() const;
bool CanThrottleTransformChanges(const nsIFrame& aFrame) const;
bool CanThrottleTransformChangesInScrollable(nsIFrame& aFrame) const;
bool CanThrottleOverflowChanges(const nsIFrame& aFrame) const;
bool CanThrottleOverflowChangesInScrollable(nsIFrame& aFrame) const;
// Returns true if the computedTiming has changed since the last
// composition.
@ -440,11 +440,11 @@ private:
void UpdateEffectSet(mozilla::EffectSet* aEffectSet = nullptr) const;
// Returns true if this effect has transform and the transform might affect
// the overflow region.
// Returns true if this effect has properties that might affect the overflow
// region.
// This function is used for updating scroll bars or notifying intersection
// observers reflected by the transform.
bool HasTransformThatMightAffectOverflow() const
bool HasPropertiesThatMightAffectOverflow() const
{
return mCumulativeChangeHint & (nsChangeHint_UpdatePostTransformOverflow |
nsChangeHint_AddOrRemoveTransform |