mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 880596 part 8 - Rename ElementAnimation to StyleAnimation; r=dbaron
We need a basic representation of animations from which we can derive subclasses to represent specific cases such as transitions. For now we will retrofit ElementAnimation for that purpose hence renaming it to StyleAnimation. This patch removes the "using namespace mozilla::layers" line from AnimationCommon.cpp since the unified build system concatenates several files together before compiling making using declarations like this leak into other files potentially creating ambiguities. Previously, when we were calling ElementAnimation, 'Animation', there were ambiguities between mozilla::layers::Animation and this new 'Animation' class. In general, it is probably a good idea to limit the scope of these using declarations so I've kept that change.
This commit is contained in:
parent
70cf5d9db3
commit
016517a8be
@ -315,7 +315,7 @@ ToTimingFunction(css::ComputedTimingFunction& aCTF)
|
||||
|
||||
static void
|
||||
AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
|
||||
ElementAnimation* ea, Layer* aLayer,
|
||||
mozilla::StyleAnimation* ea, Layer* aLayer,
|
||||
AnimationData& aData, bool aPending)
|
||||
{
|
||||
NS_ASSERTION(aLayer->AsContainerLayer(), "Should only animate ContainerLayer");
|
||||
@ -325,8 +325,10 @@ AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
|
||||
// all data passed directly to the compositor should be in css pixels
|
||||
float scale = nsDeviceContext::AppUnitsPerCSSPixel();
|
||||
|
||||
Animation* animation = aPending ? aLayer->AddAnimationForNextTransaction()
|
||||
: aLayer->AddAnimation();
|
||||
mozilla::layers::Animation* animation =
|
||||
aPending ?
|
||||
aLayer->AddAnimationForNextTransaction() :
|
||||
aLayer->AddAnimation();
|
||||
|
||||
animation->startTime() = ea->mStartTime + ea->mDelay;
|
||||
animation->duration() = ea->mIterationDuration;
|
||||
@ -379,7 +381,7 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
|
||||
mozilla::TimeStamp currentTime =
|
||||
aFrame->PresContext()->RefreshDriver()->MostRecentRefresh();
|
||||
for (uint32_t animIdx = 0; animIdx < aAnimations.Length(); animIdx++) {
|
||||
ElementAnimation* anim = &aAnimations[animIdx];
|
||||
mozilla::StyleAnimation* anim = &aAnimations[animIdx];
|
||||
if (!(anim->HasAnimationOfProperty(aProperty) &&
|
||||
anim->IsRunningAt(currentTime))) {
|
||||
continue;
|
||||
|
@ -381,7 +381,7 @@ nsLayoutUtils::ComputeSuitableScaleForAnimation(nsIContent* aContent)
|
||||
(aContent, nsGkAtoms::animationsProperty, eCSSProperty_transform);
|
||||
if (animations) {
|
||||
for (uint32_t animIdx = animations->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
ElementAnimation& anim = animations->mAnimations[animIdx];
|
||||
mozilla::StyleAnimation& anim = animations->mAnimations[animIdx];
|
||||
for (uint32_t propIdx = anim.mProperties.Length(); propIdx-- != 0; ) {
|
||||
AnimationProperty& prop = anim.mProperties[propIdx];
|
||||
if (prop.mProperty == eCSSProperty_transform) {
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "nsStyleChangeList.h"
|
||||
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using mozilla::layers::Layer;
|
||||
|
||||
namespace mozilla {
|
||||
namespace css {
|
||||
@ -360,8 +360,10 @@ ComputedTimingFunction::GetValue(double aPortion) const
|
||||
}
|
||||
}
|
||||
|
||||
} /* end sub-namespace css */
|
||||
|
||||
bool
|
||||
ElementAnimation::IsRunningAt(TimeStamp aTime) const
|
||||
StyleAnimation::IsRunningAt(TimeStamp aTime) const
|
||||
{
|
||||
if (IsPaused() || mIterationDuration.ToMilliseconds() <= 0.0 ||
|
||||
mStartTime.IsNull()) {
|
||||
@ -373,7 +375,7 @@ ElementAnimation::IsRunningAt(TimeStamp aTime) const
|
||||
}
|
||||
|
||||
bool
|
||||
ElementAnimation::HasAnimationOfProperty(nsCSSProperty aProperty) const
|
||||
StyleAnimation::HasAnimationOfProperty(nsCSSProperty aProperty) const
|
||||
{
|
||||
for (uint32_t propIdx = 0, propEnd = mProperties.Length();
|
||||
propIdx != propEnd; ++propIdx) {
|
||||
@ -384,6 +386,8 @@ ElementAnimation::HasAnimationOfProperty(nsCSSProperty aProperty) const
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace css {
|
||||
|
||||
bool
|
||||
CommonElementAnimationData::CanAnimatePropertyOnCompositor(const dom::Element *aElement,
|
||||
nsCSSProperty aProperty,
|
||||
|
@ -203,6 +203,8 @@ private:
|
||||
uint32_t mSteps;
|
||||
};
|
||||
|
||||
} /* end css sub-namespace */
|
||||
|
||||
struct AnimationPropertySegment
|
||||
{
|
||||
float mFromKey, mToKey;
|
||||
@ -220,9 +222,9 @@ struct AnimationProperty
|
||||
* Data about one animation (i.e., one of the values of
|
||||
* 'animation-name') running on an element.
|
||||
*/
|
||||
struct ElementAnimation
|
||||
struct StyleAnimation
|
||||
{
|
||||
ElementAnimation()
|
||||
StyleAnimation()
|
||||
: mIsRunningOnCompositor(false)
|
||||
, mLastNotification(LAST_NOTIFICATION_NONE)
|
||||
{
|
||||
@ -278,6 +280,8 @@ struct ElementAnimation
|
||||
InfallibleTArray<AnimationProperty> mProperties;
|
||||
};
|
||||
|
||||
namespace css {
|
||||
|
||||
struct CommonElementAnimationData : public PRCList
|
||||
{
|
||||
CommonElementAnimationData(dom::Element *aElement, nsIAtom *aElementProperty,
|
||||
|
@ -54,7 +54,7 @@ ElementAnimations::GetPositionInIteration(TimeDuration aElapsedDuration,
|
||||
TimeDuration aIterationDuration,
|
||||
double aIterationCount,
|
||||
uint32_t aDirection,
|
||||
ElementAnimation* aAnimation,
|
||||
StyleAnimation* aAnimation,
|
||||
ElementAnimations* aEa,
|
||||
EventArray* aEventsToDispatch)
|
||||
{
|
||||
@ -68,8 +68,8 @@ ElementAnimations::GetPositionInIteration(TimeDuration aElapsedDuration,
|
||||
if (aAnimation) {
|
||||
// Dispatch 'animationend' when needed.
|
||||
if (aAnimation->mLastNotification !=
|
||||
ElementAnimation::LAST_NOTIFICATION_END) {
|
||||
aAnimation->mLastNotification = ElementAnimation::LAST_NOTIFICATION_END;
|
||||
StyleAnimation::LAST_NOTIFICATION_END) {
|
||||
aAnimation->mLastNotification = StyleAnimation::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 == ElementAnimation::LAST_NOTIFICATION_NONE
|
||||
aAnimation->mLastNotification == StyleAnimation::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; ) {
|
||||
ElementAnimation &anim = mAnimations[animIdx];
|
||||
StyleAnimation &anim = mAnimations[animIdx];
|
||||
|
||||
if (anim.mProperties.Length() == 0 ||
|
||||
anim.mIterationDuration.ToMilliseconds() <= 0.0) {
|
||||
@ -205,7 +205,7 @@ ElementAnimations::EnsureStyleRuleFor(TimeStamp aRefreshTime,
|
||||
// changing.
|
||||
if (!anim.mIsRunningOnCompositor ||
|
||||
(anim.mLastNotification != oldLastNotification &&
|
||||
anim.mLastNotification == ElementAnimation::LAST_NOTIFICATION_END)) {
|
||||
anim.mLastNotification == StyleAnimation::LAST_NOTIFICATION_END)) {
|
||||
aIsThrottled = false;
|
||||
break;
|
||||
}
|
||||
@ -230,7 +230,7 @@ ElementAnimations::EnsureStyleRuleFor(TimeStamp aRefreshTime,
|
||||
nsCSSPropertySet properties;
|
||||
|
||||
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
ElementAnimation &anim = mAnimations[animIdx];
|
||||
StyleAnimation &anim = mAnimations[animIdx];
|
||||
|
||||
if (anim.mProperties.Length() == 0 ||
|
||||
anim.mIterationDuration.ToMilliseconds() <= 0.0) {
|
||||
@ -330,7 +330,7 @@ bool
|
||||
ElementAnimations::HasAnimationOfProperty(nsCSSProperty aProperty) const
|
||||
{
|
||||
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const ElementAnimation &anim = mAnimations[animIdx];
|
||||
const StyleAnimation &anim = mAnimations[animIdx];
|
||||
if (anim.HasAnimationOfProperty(aProperty)) {
|
||||
return true;
|
||||
}
|
||||
@ -360,7 +360,7 @@ ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const
|
||||
TimeStamp now = frame->PresContext()->RefreshDriver()->MostRecentRefresh();
|
||||
|
||||
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const ElementAnimation& anim = mAnimations[animIdx];
|
||||
const StyleAnimation& anim = mAnimations[animIdx];
|
||||
for (uint32_t propIdx = 0, propEnd = anim.mProperties.Length();
|
||||
propIdx != propEnd; ++propIdx) {
|
||||
if (IsGeometricProperty(anim.mProperties[propIdx].mProperty) &&
|
||||
@ -374,7 +374,7 @@ ElementAnimations::CanPerformOnCompositorThread(CanAnimateFlags aFlags) const
|
||||
bool hasOpacity = false;
|
||||
bool hasTransform = false;
|
||||
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
|
||||
const ElementAnimation& anim = mAnimations[animIdx];
|
||||
const StyleAnimation& anim = mAnimations[animIdx];
|
||||
if (!anim.IsRunningAt(now)) {
|
||||
continue;
|
||||
}
|
||||
@ -547,7 +547,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
}
|
||||
|
||||
// build the animations list
|
||||
InfallibleTArray<ElementAnimation> newAnimations;
|
||||
InfallibleTArray<StyleAnimation> newAnimations;
|
||||
BuildAnimations(aStyleContext, newAnimations);
|
||||
|
||||
if (newAnimations.IsEmpty()) {
|
||||
@ -577,7 +577,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
if (!ea->mAnimations.IsEmpty()) {
|
||||
for (uint32_t newIdx = 0, newEnd = newAnimations.Length();
|
||||
newIdx != newEnd; ++newIdx) {
|
||||
ElementAnimation *newAnim = &newAnimations[newIdx];
|
||||
StyleAnimation *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 +587,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 ElementAnimation *oldAnim = nullptr;
|
||||
const StyleAnimation *oldAnim = nullptr;
|
||||
for (uint32_t oldIdx = ea->mAnimations.Length(); oldIdx-- != 0; ) {
|
||||
const ElementAnimation *a = &ea->mAnimations[oldIdx];
|
||||
const StyleAnimation *a = &ea->mAnimations[oldIdx];
|
||||
if (a->mName == newAnim->mName) {
|
||||
oldAnim = a;
|
||||
break;
|
||||
@ -717,7 +717,8 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext,
|
||||
|
||||
void
|
||||
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
InfallibleTArray<ElementAnimation>& aAnimations)
|
||||
InfallibleTArray<StyleAnimation>&
|
||||
aAnimations)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(aAnimations.IsEmpty(), "expect empty array");
|
||||
|
||||
@ -728,7 +729,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
for (uint32_t animIdx = 0, animEnd = disp->mAnimationNameCount;
|
||||
animIdx != animEnd; ++animIdx) {
|
||||
const nsAnimation& aSrc = disp->mAnimations[animIdx];
|
||||
ElementAnimation& aDest = *aAnimations.AppendElement();
|
||||
StyleAnimation& aDest = *aAnimations.AppendElement();
|
||||
|
||||
aDest.mName = aSrc.GetName();
|
||||
aDest.mIterationCount = aSrc.GetIterationCount();
|
||||
|
@ -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 ElementAnimation* in order to
|
||||
// from the main thread, we need the actual StyleAnimation* 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,8 +78,8 @@ struct ElementAnimations MOZ_FINAL
|
||||
TimeDuration aIterationDuration,
|
||||
double aIterationCount,
|
||||
uint32_t aDirection,
|
||||
mozilla::css::ElementAnimation*
|
||||
aAnimation = nullptr,
|
||||
mozilla::StyleAnimation* 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;
|
||||
|
||||
InfallibleTArray<mozilla::css::ElementAnimation> mAnimations;
|
||||
InfallibleTArray<mozilla::StyleAnimation> mAnimations;
|
||||
};
|
||||
|
||||
class nsAnimationManager MOZ_FINAL
|
||||
@ -236,9 +236,8 @@ protected:
|
||||
|
||||
private:
|
||||
void BuildAnimations(nsStyleContext* aStyleContext,
|
||||
InfallibleTArray<mozilla::css::ElementAnimation>&
|
||||
aAnimations);
|
||||
bool BuildSegment(InfallibleTArray<mozilla::css::AnimationPropertySegment>&
|
||||
InfallibleTArray<mozilla::StyleAnimation>& aAnimations);
|
||||
bool BuildSegment(InfallibleTArray<mozilla::AnimationPropertySegment>&
|
||||
aSegments,
|
||||
nsCSSProperty aProperty, const nsAnimation& aAnimation,
|
||||
float aFromKey, nsStyleContext* aFromContext,
|
||||
|
@ -23,7 +23,7 @@ struct ElementDependentRuleProcessorData;
|
||||
* Per-Element data *
|
||||
*****************************************************************************/
|
||||
|
||||
struct ElementPropertyTransition : public mozilla::css::ElementAnimation
|
||||
struct ElementPropertyTransition : public mozilla::StyleAnimation
|
||||
{
|
||||
// This is the start value to be used for a check for whether a
|
||||
// transition is being reversed. Normally the same as
|
||||
@ -49,8 +49,8 @@ struct ElementPropertyTransition : public mozilla::css::ElementAnimation
|
||||
|
||||
bool IsRemovedSentinel() const
|
||||
{
|
||||
// Note that ElementAnimation::IsRunningAt depends on removed sentinels
|
||||
// being represented by a null mStartTime.
|
||||
// Note that mozilla::StyleAnimation::IsRunningAt depends on removed
|
||||
// sentinels being represented by a null mStartTime.
|
||||
return mStartTime.IsNull();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user