mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1150810 part 4 - Store global on Animation; r=smaug, jwatt
The connection between an Animation and an AnimationTimeline is optional. That is, it is possible to have an Animation without an AnimationTimeline. Until now we have often just assumed the timeline will be set but eventually we need to support the possibility of the timeline being null. Indeed, later in this patch series we will set the timeline out-of-band (i.e. not in the constructor) using SetTimeline which opens up the possibility that timeline will be null for a period of time. This patch paves the way for having an optional timeline by storing the global used for, e.g. creating promises, on the Animation object itself.
This commit is contained in:
parent
70ca5ce014
commit
cd630f438e
@ -21,7 +21,7 @@ namespace dom {
|
||||
// Static members
|
||||
uint64_t Animation::sNextSequenceNum = 0;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Animation, mTimeline,
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Animation, mGlobal, mTimeline,
|
||||
mEffect, mReady, mFinished)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(Animation)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(Animation)
|
||||
@ -173,21 +173,11 @@ Animation::PlayState() const
|
||||
return AnimationPlayState::Running;
|
||||
}
|
||||
|
||||
static inline already_AddRefed<Promise>
|
||||
CreatePromise(AnimationTimeline* aTimeline, ErrorResult& aRv)
|
||||
{
|
||||
nsIGlobalObject* global = aTimeline->GetParentObject();
|
||||
if (global) {
|
||||
return Promise::Create(global, aRv);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Promise*
|
||||
Animation::GetReady(ErrorResult& aRv)
|
||||
{
|
||||
if (!mReady) {
|
||||
mReady = CreatePromise(mTimeline, aRv); // Lazily create on demand
|
||||
if (!mReady && mGlobal) {
|
||||
mReady = Promise::Create(mGlobal, aRv); // Lazily create on demand
|
||||
}
|
||||
if (!mReady) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
@ -200,8 +190,8 @@ Animation::GetReady(ErrorResult& aRv)
|
||||
Promise*
|
||||
Animation::GetFinished(ErrorResult& aRv)
|
||||
{
|
||||
if (!mFinished) {
|
||||
mFinished = CreatePromise(mTimeline, aRv); // Lazily create on demand
|
||||
if (!mFinished && mGlobal) {
|
||||
mFinished = Promise::Create(mGlobal, aRv); // Lazily create on demand
|
||||
}
|
||||
if (!mFinished) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "mozilla/dom/KeyframeEffect.h" // for KeyframeEffectReadOnly
|
||||
#include "mozilla/dom/Promise.h" // for Promise
|
||||
#include "nsCSSProperty.h" // for nsCSSProperty
|
||||
#include "nsIGlobalObject.h"
|
||||
|
||||
// X11 has a #define for CurrentTime.
|
||||
#ifdef CurrentTime
|
||||
@ -53,8 +54,9 @@ protected:
|
||||
virtual ~Animation() {}
|
||||
|
||||
public:
|
||||
explicit Animation(AnimationTimeline* aTimeline)
|
||||
: mTimeline(aTimeline)
|
||||
explicit Animation(nsIGlobalObject* aGlobal, AnimationTimeline* aTimeline)
|
||||
: mGlobal(aGlobal)
|
||||
, mTimeline(aTimeline)
|
||||
, mPlaybackRate(1.0)
|
||||
, mPendingState(PendingState::NotPending)
|
||||
, mSequenceNum(kUnsequenced)
|
||||
@ -339,6 +341,7 @@ protected:
|
||||
virtual css::CommonAnimationManager* GetAnimationManager() const = 0;
|
||||
AnimationCollection* GetCollection() const;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> mGlobal;
|
||||
nsRefPtr<AnimationTimeline> mTimeline;
|
||||
nsRefPtr<KeyframeEffectReadOnly> mEffect;
|
||||
// The beginning of the delay period.
|
||||
|
@ -598,7 +598,9 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
continue;
|
||||
}
|
||||
|
||||
nsRefPtr<CSSAnimation> dest = new CSSAnimation(aTimeline, src.GetName());
|
||||
nsRefPtr<CSSAnimation> dest =
|
||||
new CSSAnimation(mPresContext->Document()->GetScopeObject(), aTimeline,
|
||||
src.GetName());
|
||||
dest->SetOwningElement(
|
||||
OwningElementRef(*aTarget, aStyleContext->GetPseudoType()));
|
||||
dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsStyleContext;
|
||||
|
||||
namespace mozilla {
|
||||
@ -56,9 +57,10 @@ namespace dom {
|
||||
class CSSAnimation final : public Animation
|
||||
{
|
||||
public:
|
||||
explicit CSSAnimation(dom::AnimationTimeline* aTimeline,
|
||||
explicit CSSAnimation(nsIGlobalObject* aGlobal,
|
||||
dom::AnimationTimeline* aTimeline,
|
||||
const nsSubstring& aAnimationName)
|
||||
: dom::Animation(aTimeline)
|
||||
: dom::Animation(aGlobal, aTimeline)
|
||||
, mAnimationName(aAnimationName)
|
||||
, mIsStylePaused(false)
|
||||
, mPauseShouldStick(false)
|
||||
|
@ -632,7 +632,8 @@ nsTransitionManager::ConsiderStartingTransition(
|
||||
segment.mToKey = 1;
|
||||
segment.mTimingFunction.Init(tf);
|
||||
|
||||
nsRefPtr<CSSTransition> animation = new CSSTransition(timeline);
|
||||
nsRefPtr<CSSTransition> animation =
|
||||
new CSSTransition(mPresContext->Document()->GetScopeObject(), timeline);
|
||||
animation->SetOwningElement(
|
||||
OwningElementRef(*aElement, aNewStyleContext->GetPseudoType()));
|
||||
animation->SetCreationSequence(
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "AnimationCommon.h"
|
||||
#include "nsCSSPseudoElements.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
class nsStyleContext;
|
||||
class nsPresContext;
|
||||
class nsCSSPropertySet;
|
||||
@ -79,8 +80,9 @@ namespace dom {
|
||||
class CSSTransition final : public Animation
|
||||
{
|
||||
public:
|
||||
explicit CSSTransition(dom::AnimationTimeline* aTimeline)
|
||||
: dom::Animation(aTimeline)
|
||||
explicit CSSTransition(nsIGlobalObject* aGlobal,
|
||||
dom::AnimationTimeline* aTimeline)
|
||||
: dom::Animation(aGlobal, aTimeline)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user