mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-02 20:20:00 +00:00
Bug 1045993 part 2 - Move the animation name from AnimationPlayer to Animation; r=dbaron
This patch stores the animation name on the Animation object rather than its AnimationPlayer. This is because Animation objects don't have a reference to their AnimationPlayer but their AnimationEffect needs access to the animation name. This patch also adds an accessor for AnimationPlayer to get the name from its Animation (since players *do* have a reference to their source animation content).
This commit is contained in:
parent
29081b3bb1
commit
058b40127c
@ -125,9 +125,12 @@ class AnimationEffect;
|
||||
class Animation : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
Animation(nsIDocument* aDocument, const AnimationTiming &aTiming)
|
||||
Animation(nsIDocument* aDocument,
|
||||
const AnimationTiming &aTiming,
|
||||
const nsSubstring& aName)
|
||||
: mDocument(aDocument)
|
||||
, mTiming(aTiming)
|
||||
, mName(aName)
|
||||
, mIsFinishedTransition(false)
|
||||
, mLastNotification(LAST_NOTIFICATION_NONE)
|
||||
{
|
||||
@ -162,6 +165,10 @@ public:
|
||||
return mTiming;
|
||||
}
|
||||
|
||||
const nsString& Name() const {
|
||||
return mName;
|
||||
}
|
||||
|
||||
// Return the duration from the start the active interval to the point where
|
||||
// the animation begins playback. This is zero unless the animation has
|
||||
// a negative delay in which case it is the absolute value of the delay.
|
||||
@ -250,6 +257,7 @@ protected:
|
||||
Nullable<TimeDuration> mParentTime;
|
||||
|
||||
AnimationTiming mTiming;
|
||||
nsString mName;
|
||||
// A flag to mark transitions that have finished and are due to
|
||||
// be removed on the next throttle-able cycle.
|
||||
bool mIsFinishedTransition;
|
||||
|
@ -55,6 +55,10 @@ public:
|
||||
void SetSource(Animation* aSource);
|
||||
void Tick();
|
||||
|
||||
const nsString& Name() const {
|
||||
return mSource ? mSource->Name() : EmptyString();
|
||||
}
|
||||
|
||||
bool IsPaused() const {
|
||||
return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
|
||||
}
|
||||
@ -83,7 +87,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
nsString mName;
|
||||
// The beginning of the delay period.
|
||||
TimeStamp mStartTime;
|
||||
TimeStamp mPauseStart;
|
||||
|
@ -77,7 +77,7 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
|
||||
computedTiming.mCurrentIteration;
|
||||
TimeDuration elapsedTime =
|
||||
std::max(iterationStart, anim->InitialAdvance());
|
||||
AnimationEventInfo ei(aCollection->mElement, player->mName, message,
|
||||
AnimationEventInfo ei(aCollection->mElement, player->Name(), message,
|
||||
elapsedTime, aCollection->PseudoElement());
|
||||
aEventsToDispatch.AppendElement(ei);
|
||||
}
|
||||
@ -94,7 +94,7 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
|
||||
TimeDuration elapsedTime =
|
||||
std::min(anim->InitialAdvance(), computedTiming.mActiveDuration);
|
||||
AnimationEventInfo ei(aCollection->mElement,
|
||||
player->mName, NS_ANIMATION_START,
|
||||
player->Name(), NS_ANIMATION_START,
|
||||
elapsedTime, aCollection->PseudoElement());
|
||||
aEventsToDispatch.AppendElement(ei);
|
||||
}
|
||||
@ -102,7 +102,7 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
|
||||
if (anim->LastNotification() != Animation::LAST_NOTIFICATION_END) {
|
||||
anim->SetLastNotification(Animation::LAST_NOTIFICATION_END);
|
||||
AnimationEventInfo ei(aCollection->mElement,
|
||||
player->mName, NS_ANIMATION_END,
|
||||
player->Name(), NS_ANIMATION_END,
|
||||
computedTiming.mActiveDuration,
|
||||
aCollection->PseudoElement());
|
||||
aEventsToDispatch.AppendElement(ei);
|
||||
@ -285,7 +285,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
size_t oldIdx = collection->mPlayers.Length();
|
||||
while (oldIdx-- != 0) {
|
||||
AnimationPlayer* a = collection->mPlayers[oldIdx];
|
||||
if (a->mName == newPlayer->mName) {
|
||||
if (a->Name() == newPlayer->Name()) {
|
||||
oldPlayer = a;
|
||||
break;
|
||||
}
|
||||
@ -442,8 +442,6 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
nsRefPtr<AnimationPlayer> dest =
|
||||
*aPlayers.AppendElement(new AnimationPlayer(aTimeline));
|
||||
|
||||
dest->mName = src.GetName();
|
||||
|
||||
AnimationTiming timing;
|
||||
timing.mIterationDuration =
|
||||
TimeDuration::FromMilliseconds(src.GetDuration());
|
||||
@ -453,7 +451,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
timing.mFillMode = src.GetFillMode();
|
||||
|
||||
nsRefPtr<Animation> destAnim =
|
||||
new Animation(mPresContext->Document(), timing);
|
||||
new Animation(mPresContext->Document(), timing, src.GetName());
|
||||
dest->SetSource(destAnim);
|
||||
|
||||
dest->mStartTime = now;
|
||||
|
@ -26,7 +26,7 @@ struct AnimationEventInfo {
|
||||
mozilla::InternalAnimationEvent mEvent;
|
||||
|
||||
AnimationEventInfo(mozilla::dom::Element *aElement,
|
||||
const nsString& aAnimationName,
|
||||
const nsSubstring& aAnimationName,
|
||||
uint32_t aMessage, mozilla::TimeDuration aElapsedTime,
|
||||
const nsAString& aPseudoElement)
|
||||
: mElement(aElement), mEvent(true, aMessage)
|
||||
|
@ -33,7 +33,7 @@ struct ElementPropertyTransition : public dom::Animation
|
||||
{
|
||||
ElementPropertyTransition(nsIDocument* aDocument,
|
||||
const AnimationTiming &aTiming)
|
||||
: dom::Animation(aDocument, aTiming) { }
|
||||
: dom::Animation(aDocument, aTiming, EmptyString()) { }
|
||||
|
||||
virtual ElementPropertyTransition* AsTransition() { return this; }
|
||||
virtual const ElementPropertyTransition* AsTransition() const { return this; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user