From 92e305760e39f7ec19efdb559b346b38bcb68017 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 15 May 2014 08:38:37 +0900 Subject: [PATCH] Bug 1004383 part 2 - Rename StyleAnimation to ElementAnimation; r=dholbert We currently have mozilla::StyleAnimation as well as nsStyleAnimation. This patch renames StyleAnimation back to ElementAnimation. Although ElementAnimation is very similar to ElementAnimations, in the near future we expect to retire ElementAnimations and replace it with a common AnimationSet-like structure that is covers the features of ElementAnimations and ElementTransitions. --- layout/base/nsDisplayList.cpp | 4 ++-- layout/base/nsLayoutUtils.cpp | 2 +- layout/style/AnimationCommon.cpp | 4 ++-- layout/style/AnimationCommon.h | 8 +++---- layout/style/nsAnimationManager.cpp | 35 +++++++++++++++-------------- layout/style/nsAnimationManager.h | 8 +++---- layout/style/nsTransitionManager.h | 4 ++-- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 22471efbe754..1d31187ddd82 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -313,7 +313,7 @@ ToTimingFunction(css::ComputedTimingFunction& aCTF) static void AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, - mozilla::StyleAnimation* ea, Layer* aLayer, + mozilla::ElementAnimation* ea, Layer* aLayer, AnimationData& aData, bool aPending) { NS_ASSERTION(aLayer->AsContainerLayer(), "Should only animate ContainerLayer"); @@ -377,7 +377,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty, mozilla::TimeStamp currentTime = aFrame->PresContext()->RefreshDriver()->MostRecentRefresh(); for (uint32_t animIdx = 0; animIdx < aAnimations.Length(); animIdx++) { - mozilla::StyleAnimation* anim = aAnimations[animIdx]; + mozilla::ElementAnimation* anim = aAnimations[animIdx]; if (!(anim->HasAnimationOfProperty(aProperty) && anim->IsRunningAt(currentTime))) { continue; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index d0ab19719cd9..896be6cdf554 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -391,7 +391,7 @@ nsLayoutUtils::ComputeSuitableScaleForAnimation(nsIContent* aContent) (aContent, nsGkAtoms::animationsProperty, eCSSProperty_transform); if (animations) { for (uint32_t animIdx = animations->mAnimations.Length(); animIdx-- != 0; ) { - mozilla::StyleAnimation* anim = animations->mAnimations[animIdx]; + mozilla::ElementAnimation* anim = animations->mAnimations[animIdx]; for (uint32_t propIdx = anim->mProperties.Length(); propIdx-- != 0; ) { AnimationProperty& prop = anim->mProperties[propIdx]; if (prop.mProperty == eCSSProperty_transform) { diff --git a/layout/style/AnimationCommon.cpp b/layout/style/AnimationCommon.cpp index 57ac817273b2..e403b43874dd 100644 --- a/layout/style/AnimationCommon.cpp +++ b/layout/style/AnimationCommon.cpp @@ -363,7 +363,7 @@ ComputedTimingFunction::GetValue(double aPortion) const } /* end sub-namespace css */ bool -StyleAnimation::IsRunningAt(TimeStamp aTime) const +ElementAnimation::IsRunningAt(TimeStamp aTime) const { if (IsPaused() || mIterationDuration.ToMilliseconds() <= 0.0 || mStartTime.IsNull()) { @@ -375,7 +375,7 @@ StyleAnimation::IsRunningAt(TimeStamp aTime) const } bool -StyleAnimation::HasAnimationOfProperty(nsCSSProperty aProperty) const +ElementAnimation::HasAnimationOfProperty(nsCSSProperty aProperty) const { for (uint32_t propIdx = 0, propEnd = mProperties.Length(); propIdx != propEnd; ++propIdx) { diff --git a/layout/style/AnimationCommon.h b/layout/style/AnimationCommon.h index ddfc606dbd32..670036f4d2b8 100644 --- a/layout/style/AnimationCommon.h +++ b/layout/style/AnimationCommon.h @@ -222,9 +222,9 @@ struct AnimationProperty * Data about one animation (i.e., one of the values of * 'animation-name') running on an element. */ -struct StyleAnimation +struct ElementAnimation { - StyleAnimation() + ElementAnimation() : mIsRunningOnCompositor(false) , mLastNotification(LAST_NOTIFICATION_NONE) { @@ -279,10 +279,10 @@ struct StyleAnimation InfallibleTArray mProperties; - NS_INLINE_DECL_REFCOUNTING(StyleAnimation) + NS_INLINE_DECL_REFCOUNTING(ElementAnimation) }; -typedef InfallibleTArray > StyleAnimationPtrArray; +typedef InfallibleTArray > ElementAnimationPtrArray; namespace css { diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 9b4b8ba089bb..cbcc62073b23 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -54,7 +54,7 @@ ElementAnimations::GetPositionInIteration(TimeDuration aElapsedDuration, TimeDuration aIterationDuration, double aIterationCount, uint32_t aDirection, - StyleAnimation* aAnimation, + ElementAnimation* aAnimation, ElementAnimations* aEa, EventArray* aEventsToDispatch) { @@ -68,8 +68,8 @@ ElementAnimations::GetPositionInIteration(TimeDuration aElapsedDuration, if (aAnimation) { // Dispatch 'animationend' when needed. if (aAnimation->mLastNotification != - StyleAnimation::LAST_NOTIFICATION_END) { - aAnimation->mLastNotification = StyleAnimation::LAST_NOTIFICATION_END; + ElementAnimation::LAST_NOTIFICATION_END) { + aAnimation->mLastNotification = ElementAnimation::LAST_NOTIFICATION_END; AnimationEventInfo ei(aEa->mElement, aAnimation->mName, NS_ANIMATION_END, aElapsedDuration, aEa->PseudoElement()); aEventsToDispatch->AppendElement(ei); @@ -149,7 +149,7 @@ ElementAnimations::GetPositionInIteration(TimeDuration aElapsedDuration, // immediately in many cases. It's not clear to me if that's the // right thing to do. uint32_t message = - aAnimation->mLastNotification == StyleAnimation::LAST_NOTIFICATION_NONE + aAnimation->mLastNotification == ElementAnimation::LAST_NOTIFICATION_NONE ? NS_ANIMATION_START : NS_ANIMATION_ITERATION; aAnimation->mLastNotification = whichIteration; @@ -179,7 +179,7 @@ ElementAnimations::EnsureStyleRuleFor(TimeStamp aRefreshTime, // the style recalculation if we find any. if (aIsThrottled) { for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) { - StyleAnimation* anim = mAnimations[animIdx]; + ElementAnimation* anim = mAnimations[animIdx]; if (anim->mProperties.Length() == 0 || anim->mIterationDuration.ToMilliseconds() <= 0.0) { @@ -205,7 +205,8 @@ ElementAnimations::EnsureStyleRuleFor(TimeStamp aRefreshTime, // changing. if (!anim->mIsRunningOnCompositor || (anim->mLastNotification != oldLastNotification && - anim->mLastNotification == StyleAnimation::LAST_NOTIFICATION_END)) { + anim->mLastNotification == + ElementAnimation::LAST_NOTIFICATION_END)) { aIsThrottled = false; break; } @@ -230,7 +231,7 @@ ElementAnimations::EnsureStyleRuleFor(TimeStamp aRefreshTime, nsCSSPropertySet properties; for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) { - StyleAnimation* anim = mAnimations[animIdx]; + ElementAnimation* anim = mAnimations[animIdx]; if (anim->mProperties.Length() == 0 || anim->mIterationDuration.ToMilliseconds() <= 0.0) { @@ -330,7 +331,7 @@ bool ElementAnimations::HasAnimationOfProperty(nsCSSProperty aProperty) const { for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) { - const StyleAnimation* anim = mAnimations[animIdx]; + const ElementAnimation* anim = mAnimations[animIdx]; if (anim->HasAnimationOfProperty(aProperty)) { return true; } @@ -360,7 +361,7 @@ ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const TimeStamp now = frame->PresContext()->RefreshDriver()->MostRecentRefresh(); for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) { - const StyleAnimation* anim = mAnimations[animIdx]; + const ElementAnimation* anim = mAnimations[animIdx]; for (uint32_t propIdx = 0, propEnd = anim->mProperties.Length(); propIdx != propEnd; ++propIdx) { if (IsGeometricProperty(anim->mProperties[propIdx].mProperty) && @@ -374,7 +375,7 @@ ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const bool hasOpacity = false; bool hasTransform = false; for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) { - const StyleAnimation* anim = mAnimations[animIdx]; + const ElementAnimation* anim = mAnimations[animIdx]; if (!anim->IsRunningAt(now)) { continue; } @@ -547,7 +548,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext, } // build the animations list - StyleAnimationPtrArray newAnimations; + ElementAnimationPtrArray newAnimations; BuildAnimations(aStyleContext, newAnimations); if (newAnimations.IsEmpty()) { @@ -577,7 +578,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext, if (!ea->mAnimations.IsEmpty()) { for (uint32_t newIdx = 0, newEnd = newAnimations.Length(); newIdx != newEnd; ++newIdx) { - nsRefPtr newAnim = newAnimations[newIdx]; + nsRefPtr newAnim = newAnimations[newIdx]; // Find the matching animation with this name in the old list // of animations. Because of this code, they must all have @@ -587,9 +588,9 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext, // different pause states, they, well, get what they deserve. // We'll use the last one since it's more likely to be the one // doing something. - const StyleAnimation* oldAnim = nullptr; + const ElementAnimation* oldAnim = nullptr; for (uint32_t oldIdx = ea->mAnimations.Length(); oldIdx-- != 0; ) { - const StyleAnimation* a = ea->mAnimations[oldIdx]; + const ElementAnimation* a = ea->mAnimations[oldIdx]; if (a->mName == newAnim->mName) { oldAnim = a; break; @@ -717,7 +718,7 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext, void nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, - StyleAnimationPtrArray& aAnimations) + ElementAnimationPtrArray& aAnimations) { NS_ABORT_IF_FALSE(aAnimations.IsEmpty(), "expect empty array"); @@ -728,8 +729,8 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext, for (uint32_t animIdx = 0, animEnd = disp->mAnimationNameCount; animIdx != animEnd; ++animIdx) { const nsAnimation& src = disp->mAnimations[animIdx]; - nsRefPtr dest = - *aAnimations.AppendElement(new StyleAnimation()); + nsRefPtr dest = + *aAnimations.AppendElement(new ElementAnimation()); dest->mName = src.GetName(); dest->mIterationCount = src.GetIterationCount(); diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 1c12755a8467..4b565fba2c7e 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -66,7 +66,7 @@ struct ElementAnimations MOZ_FINAL // This way of calling the function can be used from the compositor. Note // that if the animation has not started yet, has already ended, or is paused, // it should not be run from the compositor. When this function is called - // from the main thread, we need the actual StyleAnimation* in order to + // from the main thread, we need the actual ElementAnimation* in order to // get correct animation-fill behavior and to fire animation events. // This function returns -1 for the position if the animation should not be // run (because it is not currently active and has no fill behavior), but @@ -78,7 +78,7 @@ struct ElementAnimations MOZ_FINAL TimeDuration aIterationDuration, double aIterationCount, uint32_t aDirection, - mozilla::StyleAnimation* aAnimation = + mozilla::ElementAnimation* aAnimation = nullptr, ElementAnimations* aEa = nullptr, EventArray* aEventsToDispatch = nullptr); @@ -127,7 +127,7 @@ struct ElementAnimations MOZ_FINAL // either completed or paused). May be invalidated by a style change. bool mNeedsRefreshes; - mozilla::StyleAnimationPtrArray mAnimations; + mozilla::ElementAnimationPtrArray mAnimations; }; class nsAnimationManager MOZ_FINAL @@ -236,7 +236,7 @@ protected: private: void BuildAnimations(nsStyleContext* aStyleContext, - mozilla::StyleAnimationPtrArray& aAnimations); + mozilla::ElementAnimationPtrArray& aAnimations); bool BuildSegment(InfallibleTArray& aSegments, nsCSSProperty aProperty, const nsAnimation& aAnimation, diff --git a/layout/style/nsTransitionManager.h b/layout/style/nsTransitionManager.h index 0e49591b0195..f824b0738e83 100644 --- a/layout/style/nsTransitionManager.h +++ b/layout/style/nsTransitionManager.h @@ -23,7 +23,7 @@ struct ElementDependentRuleProcessorData; * Per-Element data * *****************************************************************************/ -struct ElementPropertyTransition : public mozilla::StyleAnimation +struct ElementPropertyTransition : public mozilla::ElementAnimation { // This is the start value to be used for a check for whether a // transition is being reversed. Normally the same as @@ -49,7 +49,7 @@ struct ElementPropertyTransition : public mozilla::StyleAnimation bool IsRemovedSentinel() const { - // Note that mozilla::StyleAnimation::IsRunningAt depends on removed + // Note that mozilla::ElementAnimation::IsRunningAt depends on removed // sentinels being represented by a null mStartTime. return mStartTime.IsNull(); }