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
This commit is contained in:
Hiroyuki Ikezoe
2018-06-25 09:12:21 +09:00
parent 9f1570c0cb
commit e83a671b66
3 changed files with 36 additions and 34 deletions

View File

@@ -170,13 +170,13 @@ public:
size_t Count() const { return mEffects.Count(); } 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; } bool CascadeNeedsUpdate() const { return mCascadeNeedsUpdate; }
@@ -207,11 +207,14 @@ private:
OwningEffectSet mEffects; OwningEffectSet mEffects;
// Refresh driver timestamp from the moment when transform animations in this // Refresh driver timestamp from the moment when the animations which produce
// effect set were last updated and sent to the compositor. This is used for // overflow change hints in this effect set were last updated.
// transform animations that run on the compositor but need to be updated on
// the main thread periodically (e.g. so scrollbars can be updated). // This is used for animations whose main-thread restyling is throttled either
TimeStamp mLastTransformSyncTime; // 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 // Dirty flag to represent when the mPropertiesWithImportantRules and
// mPropertiesForAnimationsLevel on effects in this set might need to be // mPropertiesForAnimationsLevel on effects in this set might need to be

View File

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

View File

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