зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1040543 part 5 - Pass down time from AnimationPlayer to Animation; r=bz
This patch makes AnimationPlayers pass their current time down to the Animation they are playing. Since all Animations need from their players is their time, this avoids adding a pointer back to their AnimationPlayer.
This commit is contained in:
Родитель
8f9311bf63
Коммит
249039905a
|
@ -20,5 +20,11 @@ Animation::WrapObject(JSContext* aCx)
|
|||
return AnimationBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
void
|
||||
Animation::SetParentTime(Nullable<TimeDuration> aParentTime)
|
||||
{
|
||||
mParentTime = aParentTime;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
|
@ -32,12 +34,15 @@ public:
|
|||
nsIDocument* GetParentObject() const { return mDocument; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
void SetParentTime(Nullable<TimeDuration> aParentTime);
|
||||
|
||||
protected:
|
||||
virtual ~Animation() { }
|
||||
|
||||
// We use a document for a parent object since the other likely candidate,
|
||||
// the target element, can be empty.
|
||||
nsRefPtr<nsIDocument> mDocument;
|
||||
Nullable<TimeDuration> mParentTime;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -104,7 +104,21 @@ AnimationPlayer::CurrentTime() const
|
|||
void
|
||||
AnimationPlayer::SetSource(Animation* aSource)
|
||||
{
|
||||
if (mSource) {
|
||||
mSource->SetParentTime(Nullable<TimeDuration>());
|
||||
}
|
||||
mSource = aSource;
|
||||
if (mSource) {
|
||||
mSource->SetParentTime(GetLocalTime());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AnimationPlayer::Tick()
|
||||
{
|
||||
if (mSource) {
|
||||
mSource->SetParentTime(GetLocalTime());
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -152,6 +152,7 @@ public:
|
|||
double CurrentTime() const;
|
||||
|
||||
void SetSource(Animation* aSource);
|
||||
void Tick();
|
||||
|
||||
// FIXME: If we succeed in moving transition-specific code to a type of
|
||||
// AnimationEffect (as per the Web Animations API) we should remove these
|
||||
|
|
|
@ -442,6 +442,15 @@ AnimationPlayerCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
|||
delete collection;
|
||||
}
|
||||
|
||||
void
|
||||
AnimationPlayerCollection::Tick()
|
||||
{
|
||||
for (size_t animIdx = 0, animEnd = mAnimations.Length();
|
||||
animIdx != animEnd; animIdx++) {
|
||||
mAnimations[animIdx]->Tick();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
|
||||
EnsureStyleRuleFlags aFlags)
|
||||
|
|
|
@ -182,6 +182,8 @@ struct AnimationPlayerCollection : public PRCList
|
|||
static void PropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
||||
void *aPropertyValue, void *aData);
|
||||
|
||||
void Tick();
|
||||
|
||||
// This updates mNeedsRefreshes so the caller may need to check
|
||||
// for changes to values (for example, nsAnimationManager provides
|
||||
// CheckNeedsRefresh to register or unregister from observing the refresh
|
||||
|
|
|
@ -335,6 +335,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
}
|
||||
collection->mAnimations.SwapElements(newAnimations);
|
||||
collection->mNeedsRefreshes = true;
|
||||
collection->Tick();
|
||||
|
||||
TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
UpdateStyleAndEvents(collection, refreshTime,
|
||||
|
@ -745,6 +746,7 @@ nsAnimationManager::FlushAnimations(FlushFlags aFlags)
|
|||
l = PR_NEXT_LINK(l)) {
|
||||
AnimationPlayerCollection* collection =
|
||||
static_cast<AnimationPlayerCollection*>(l);
|
||||
collection->Tick();
|
||||
bool canThrottleTick = aFlags == Can_Throttle &&
|
||||
collection->CanPerformOnCompositorThread(
|
||||
AnimationPlayerCollection::CanAnimateFlags(0)) &&
|
||||
|
|
|
@ -746,6 +746,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
static_cast<AnimationPlayerCollection*>(next);
|
||||
next = PR_NEXT_LINK(next);
|
||||
|
||||
collection->Tick();
|
||||
bool canThrottleTick = aFlags == Can_Throttle &&
|
||||
collection->CanPerformOnCompositorThread(
|
||||
AnimationPlayerCollection::CanAnimateFlags(0)) &&
|
||||
|
|
Загрузка…
Ссылка в новой задаче