Bug 1188251 part 12 - Use RestyleType::Layer in UpdateCascade; r=dholbert

When updating the cascade results between transitions and animations, if we
detect a change we force an update by taking the following steps:

 a. Updating the animation generation on the restyle manager
 b. Updating the animation generation on the collection
 c. Iterating over all the properties animated by the collection and, for
    each property that we can animate on the compositor, posting a restyle
    event with the appropriate change hint (nsChangeHint_UpdateTransformLayer
    or nsChangeHint_UpdateTransformOpacity)
 d. Marking the collection as needing refreshes
 e. Clearing the style rule refresh time so we generate a new style rule in
    EnsureStyleRuleFor

As it turns out, the newly-added
AnimationCollection::RequestRestyle(RestyleType::Layer) already performs a, b,
d, and e. It also:

* Ensures we are observing the refresh driver if need be (should have no effect
  in this case)
* Clears the last animation style update time on the pres context so that
  subsequent calls to FlushPendingNotifications will update animation style
  (it seems like we probably should have been doing this for changes to cascade
  results anyway)
* Posts a restyle event with restyle hint eRestyle_CSSTransitions or
  eRestyle_CSSAnimations
* Marks the document as needing a style flush (irrelevant since posting
  a restyle event does this anyway)

The only missing piece that would prevent using RequestRestyle in place of this
code when updating cascade results is (c) from the list above. However, (c)
should not be necessary since ElementRestyler::AddLayerChangesForAnimation()
explicitly checks for out-of-date layer animation generation numbers and adds
the appropriate change hints (nsChangeHint_UpdateTransformLayer etc.) to the
change list.
This commit is contained in:
Brian Birtles 2015-08-18 16:11:55 +09:00
parent 3cc3ae622c
commit 7f6947284e
4 changed files with 6 additions and 41 deletions

View File

@ -712,30 +712,6 @@ AnimationCollection::CanPerformOnCompositorThread(
return true;
}
void
AnimationCollection::PostUpdateLayerAnimations()
{
nsCSSPropertySet propsHandled;
for (size_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
const auto& properties = mAnimations[animIdx]->GetEffect()->Properties();
for (size_t propIdx = properties.Length(); propIdx-- != 0; ) {
nsCSSProperty prop = properties[propIdx].mProperty;
if (nsCSSProps::PropHasFlags(prop,
CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR) &&
!propsHandled.HasProperty(prop)) {
propsHandled.AddProperty(prop);
nsChangeHint changeHint = CommonAnimationManager::
LayerAnimationRecordFor(prop)->mChangeHint;
dom::Element* element = GetElementToRestyle();
if (element) {
mManager->mPresContext->RestyleManager()->
PostRestyleEvent(element, nsRestyleHint(0), changeHint);
}
}
}
}
}
bool
AnimationCollection::HasCurrentAnimationOfProperty(nsCSSProperty
aProperty) const

View File

@ -331,8 +331,6 @@ public:
// off-main-thread compositing is enabled as a whole.
bool CanPerformOnCompositorThread(CanAnimateFlags aFlags) const;
void PostUpdateLayerAnimations();
bool HasCurrentAnimationOfProperty(nsCSSProperty aProperty) const;
bool IsForElement() const { // rather than for a pseudo-element

View File

@ -949,14 +949,9 @@ nsAnimationManager::UpdateCascadeResults(
}
}
// If there is any change in the cascade result, update animations on layers
// with the winning animations.
if (changed) {
nsPresContext* presContext = aElementAnimations->mManager->PresContext();
presContext->RestyleManager()->IncrementAnimationGeneration();
aElementAnimations->UpdateAnimationGeneration(presContext);
aElementAnimations->PostUpdateLayerAnimations();
// Invalidate our style rule.
aElementAnimations->mNeedsRefreshes = true;
aElementAnimations->mStyleRuleRefreshTime = TimeStamp();
aElementAnimations->RequestRestyle(AnimationCollection::RestyleType::Layer);
}
}

View File

@ -855,14 +855,10 @@ nsTransitionManager::UpdateCascadeResults(AnimationCollection* aTransitions,
#endif
}
// If there is any change in the cascade result, update animations on layers
// with the winning animations.
if (changed) {
mPresContext->RestyleManager()->IncrementAnimationGeneration();
aTransitions->UpdateAnimationGeneration(mPresContext);
aTransitions->PostUpdateLayerAnimations();
// Invalidate our style rule.
aTransitions->mStyleRuleRefreshTime = TimeStamp();
aTransitions->mNeedsRefreshes = true;
aTransitions->RequestRestyle(AnimationCollection::RestyleType::Layer);
}
}