mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1214536 - Part 5: Add AnimationEffectTimingReadOnly interface. r=birtles, r=smaug
1. Add AnimationEffectTimingReadOnly.webidl. 2. Add AnimationEffectTimingReadOnly cpp files. 3. Use AnimationEffectTimingReadOnly as KeyframeEffectReadOnly::mTiming.
This commit is contained in:
parent
3256ae1fde
commit
ee8d7bfb6e
@ -14,6 +14,7 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AnimationEffectTimingReadOnly;
|
||||
struct ComputedTimingProperties;
|
||||
|
||||
class AnimationEffectReadOnly : public nsISupports,
|
||||
@ -30,6 +31,8 @@ public:
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
|
||||
virtual already_AddRefed<AnimationEffectTimingReadOnly> TimingAsObject() const = 0;
|
||||
|
||||
virtual void GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const
|
||||
{
|
||||
}
|
||||
|
50
dom/animation/AnimationEffectTimingReadOnly.cpp
Normal file
50
dom/animation/AnimationEffectTimingReadOnly.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/AnimationEffectTimingReadOnly.h"
|
||||
#include "mozilla/dom/AnimationEffectTimingReadOnlyBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
bool
|
||||
AnimationTiming::operator==(const AnimationTiming& aOther) const
|
||||
{
|
||||
bool durationEqual;
|
||||
if (mDuration.IsUnrestrictedDouble()) {
|
||||
durationEqual = aOther.mDuration.IsUnrestrictedDouble() &&
|
||||
(mDuration.GetAsUnrestrictedDouble() ==
|
||||
aOther.mDuration.GetAsUnrestrictedDouble());
|
||||
} else if (mDuration.IsString()) {
|
||||
durationEqual = aOther.mDuration.IsString() &&
|
||||
(mDuration.GetAsString() ==
|
||||
aOther.mDuration.GetAsString());
|
||||
} else {
|
||||
// Check if both are uninitialized
|
||||
durationEqual = !aOther.mDuration.IsUnrestrictedDouble() &&
|
||||
!aOther.mDuration.IsString();
|
||||
}
|
||||
return durationEqual &&
|
||||
mDelay == aOther.mDelay &&
|
||||
mIterations == aOther.mIterations &&
|
||||
mDirection == aOther.mDirection &&
|
||||
mFill == aOther.mFill;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationEffectTimingReadOnly, mParent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationEffectTimingReadOnly, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationEffectTimingReadOnly, Release)
|
||||
|
||||
JSObject*
|
||||
AnimationEffectTimingReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AnimationEffectTimingReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
87
dom/animation/AnimationEffectTimingReadOnly.h
Normal file
87
dom/animation/AnimationEffectTimingReadOnly.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_AnimationEffectTimingReadOnly_h
|
||||
#define mozilla_dom_AnimationEffectTimingReadOnly_h
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
// X11 has a #define for None
|
||||
#ifdef None
|
||||
#undef None
|
||||
#endif
|
||||
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h" // for FillMode
|
||||
// and PlaybackDirection
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct AnimationTiming
|
||||
{
|
||||
// The unitialized state of mDuration represents "auto".
|
||||
// Bug 1237173: We will replace this with Maybe<TimeDuration>.
|
||||
dom::OwningUnrestrictedDoubleOrString mDuration;
|
||||
TimeDuration mDelay; // Initializes to zero
|
||||
double mIterations = 1.0; // Can be NaN, negative, +/-Infinity
|
||||
dom::PlaybackDirection mDirection = dom::PlaybackDirection::Normal;
|
||||
dom::FillMode mFill = dom::FillMode::Auto;
|
||||
|
||||
bool operator==(const AnimationTiming& aOther) const;
|
||||
bool operator!=(const AnimationTiming& aOther) const
|
||||
{
|
||||
return !(*this == aOther);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace dom {
|
||||
|
||||
class AnimationEffectTimingReadOnly : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
AnimationEffectTimingReadOnly() = default;
|
||||
explicit AnimationEffectTimingReadOnly(const AnimationTiming& aTiming)
|
||||
: mTiming(aTiming) { }
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationEffectTimingReadOnly)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationEffectTimingReadOnly)
|
||||
|
||||
protected:
|
||||
virtual ~AnimationEffectTimingReadOnly() = default;
|
||||
|
||||
public:
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
double Delay() const { return mTiming.mDelay.ToMilliseconds(); }
|
||||
double EndDelay() const { return 0.0; }
|
||||
FillMode Fill() const { return mTiming.mFill; }
|
||||
double IterationStart() const { return 0.0; }
|
||||
double Iterations() const { return mTiming.mIterations; }
|
||||
void GetDuration(OwningUnrestrictedDoubleOrString& aRetVal) const
|
||||
{
|
||||
aRetVal = mTiming.mDuration;
|
||||
}
|
||||
PlaybackDirection Direction() const { return mTiming.mDirection; }
|
||||
void GetEasing(nsString& aRetVal) const { aRetVal.AssignLiteral("linear"); }
|
||||
|
||||
const AnimationTiming& Timing() const { return mTiming; }
|
||||
void SetTiming(const AnimationTiming& aTiming) { mTiming = aTiming; }
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
AnimationTiming mTiming;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_AnimationEffectTimingReadOnly_h
|
@ -50,4 +50,4 @@ private:
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_AnimationEffectReadOnly_h
|
||||
#endif // mozilla_ComputedTimingFunction_h
|
||||
|
@ -78,11 +78,12 @@ KeyframeEffectReadOnly::KeyframeEffectReadOnly(
|
||||
const AnimationTiming& aTiming)
|
||||
: AnimationEffectReadOnly(aDocument)
|
||||
, mTarget(aTarget)
|
||||
, mTiming(aTiming)
|
||||
, mPseudoType(aPseudoType)
|
||||
, mInEffectOnLastAnimationTimingUpdate(false)
|
||||
{
|
||||
MOZ_ASSERT(aTarget, "null animation target is not yet supported");
|
||||
|
||||
mTiming = new AnimationEffectTimingReadOnly(aTiming);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
@ -104,13 +105,20 @@ KeyframeEffectReadOnly::Composite() const
|
||||
return CompositeOperation::Replace;
|
||||
}
|
||||
|
||||
already_AddRefed<AnimationEffectTimingReadOnly>
|
||||
KeyframeEffectReadOnly::TimingAsObject() const
|
||||
{
|
||||
RefPtr<AnimationEffectTimingReadOnly> temp(mTiming);
|
||||
return temp.forget();
|
||||
}
|
||||
|
||||
void
|
||||
KeyframeEffectReadOnly::SetTiming(const AnimationTiming& aTiming)
|
||||
{
|
||||
if (mTiming == aTiming) {
|
||||
if (mTiming->Timing() == aTiming) {
|
||||
return;
|
||||
}
|
||||
mTiming = aTiming;
|
||||
mTiming->SetTiming(aTiming);
|
||||
if (mAnimation) {
|
||||
mAnimation->NotifyEffectTimingUpdated();
|
||||
}
|
||||
@ -191,9 +199,9 @@ void
|
||||
KeyframeEffectReadOnly::GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const
|
||||
{
|
||||
const Nullable<TimeDuration> currentTime = GetLocalTime();
|
||||
GetComputedTimingDictionary(GetComputedTimingAt(currentTime, mTiming),
|
||||
GetComputedTimingDictionary(GetComputedTimingAt(currentTime, Timing()),
|
||||
currentTime,
|
||||
mTiming,
|
||||
Timing(),
|
||||
aRetVal);
|
||||
}
|
||||
|
||||
|
@ -15,20 +15,16 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ComputedTimingFunction.h" // ComputedTimingFunction
|
||||
#include "mozilla/LayerAnimationInfo.h" // LayerAnimations::kRecords
|
||||
#include "mozilla/OwningNonNull.h" // OwningNonNull<...>
|
||||
#include "mozilla/StickyTimeDuration.h"
|
||||
#include "mozilla/StyleAnimationValue.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/dom/AnimationEffectReadOnly.h"
|
||||
#include "mozilla/dom/AnimationEffectTimingReadOnly.h" // AnimationTiming
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/KeyframeBinding.h"
|
||||
#include "mozilla/dom/Nullable.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
|
||||
// Fix X11 header brain damage that conflicts with dom::FillMode::None
|
||||
#ifdef None
|
||||
#undef None
|
||||
#endif
|
||||
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h"
|
||||
|
||||
struct JSContext;
|
||||
class nsCSSPropertySet;
|
||||
@ -48,47 +44,6 @@ enum class IterationCompositeOperation : uint32_t;
|
||||
enum class CompositeOperation : uint32_t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Input timing parameters.
|
||||
*
|
||||
* Eventually this will represent all the input timing parameters specified
|
||||
* by content but for now it encapsulates just the subset of those
|
||||
* parameters passed to GetPositionInIteration.
|
||||
*/
|
||||
struct AnimationTiming
|
||||
{
|
||||
dom::OwningUnrestrictedDoubleOrString mDuration;
|
||||
TimeDuration mDelay;
|
||||
double mIterations; // Can be NaN, negative, +/-Infinity
|
||||
dom::PlaybackDirection mDirection;
|
||||
dom::FillMode mFill;
|
||||
|
||||
bool operator==(const AnimationTiming& aOther) const {
|
||||
bool durationEqual;
|
||||
if (mDuration.IsUnrestrictedDouble()) {
|
||||
durationEqual = aOther.mDuration.IsUnrestrictedDouble() &&
|
||||
(mDuration.GetAsUnrestrictedDouble() ==
|
||||
aOther.mDuration.GetAsUnrestrictedDouble());
|
||||
} else if (mDuration.IsString()) {
|
||||
durationEqual = aOther.mDuration.IsString() &&
|
||||
(mDuration.GetAsString() ==
|
||||
aOther.mDuration.GetAsString());
|
||||
} else {
|
||||
// Check if both are uninitialized
|
||||
durationEqual = !aOther.mDuration.IsUnrestrictedDouble() &&
|
||||
!aOther.mDuration.IsString();
|
||||
}
|
||||
return durationEqual &&
|
||||
mDelay == aOther.mDelay &&
|
||||
mIterations == aOther.mIterations &&
|
||||
mDirection == aOther.mDirection &&
|
||||
mFill == aOther.mFill;
|
||||
}
|
||||
bool operator!=(const AnimationTiming& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores the results of calculating the timing properties of an animation
|
||||
* at a given sample time.
|
||||
@ -264,9 +219,9 @@ public:
|
||||
aRetVal.AssignLiteral("distribute");
|
||||
}
|
||||
|
||||
const AnimationTiming& Timing() const { return mTiming; }
|
||||
AnimationTiming& Timing() { return mTiming; }
|
||||
const AnimationTiming& Timing() const { return mTiming->Timing(); }
|
||||
void SetTiming(const AnimationTiming& aTiming);
|
||||
already_AddRefed<AnimationEffectTimingReadOnly> TimingAsObject() const override;
|
||||
void NotifyAnimationTimingUpdated();
|
||||
|
||||
Nullable<TimeDuration> GetLocalTime() const;
|
||||
@ -290,7 +245,7 @@ public:
|
||||
ComputedTiming
|
||||
GetComputedTiming(const AnimationTiming* aTiming = nullptr) const
|
||||
{
|
||||
return GetComputedTimingAt(GetLocalTime(), aTiming ? *aTiming : mTiming);
|
||||
return GetComputedTimingAt(GetLocalTime(), aTiming ? *aTiming : Timing());
|
||||
}
|
||||
|
||||
void
|
||||
@ -386,7 +341,7 @@ protected:
|
||||
nsCOMPtr<Element> mTarget;
|
||||
RefPtr<Animation> mAnimation;
|
||||
|
||||
AnimationTiming mTiming;
|
||||
OwningNonNull<AnimationEffectTimingReadOnly> mTiming;
|
||||
nsCSSPseudoElements::Type mPseudoType;
|
||||
|
||||
InfallibleTArray<AnimationProperty> mProperties;
|
||||
|
@ -10,6 +10,7 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
|
||||
EXPORTS.mozilla.dom += [
|
||||
'Animation.h',
|
||||
'AnimationEffectReadOnly.h',
|
||||
'AnimationEffectTimingReadOnly.h',
|
||||
'AnimationTimeline.h',
|
||||
'DocumentTimeline.h',
|
||||
'KeyframeEffect.h',
|
||||
@ -29,6 +30,7 @@ EXPORTS.mozilla += [
|
||||
UNIFIED_SOURCES += [
|
||||
'Animation.cpp',
|
||||
'AnimationEffectReadOnly.cpp',
|
||||
'AnimationEffectTimingReadOnly.cpp',
|
||||
'AnimationTimeline.cpp',
|
||||
'AnimationUtils.cpp',
|
||||
'AnimValuesStyleRule.cpp',
|
||||
|
@ -128,6 +128,8 @@ var interfaceNamesInGlobalScope =
|
||||
{name: "Animation", release: false},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "AnimationEffectReadOnly", release: false},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "AnimationEffectTimingReadOnly", release: false},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"AnimationEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -46,9 +46,8 @@ dictionary ComputedTimingProperties : AnimationEffectTimingProperties {
|
||||
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
interface AnimationEffectReadOnly {
|
||||
// Not yet implemented:
|
||||
// readonly attribute AnimationEffectTimingReadOnly timing;
|
||||
|
||||
[Cached, Constant, BinaryName="timingAsObject"]
|
||||
readonly attribute AnimationEffectTimingReadOnly timing;
|
||||
[BinaryName="getComputedTimingAsDict"]
|
||||
ComputedTimingProperties getComputedTiming();
|
||||
};
|
||||
|
23
dom/webidl/AnimationEffectTimingReadOnly.webidl
Normal file
23
dom/webidl/AnimationEffectTimingReadOnly.webidl
Normal file
@ -0,0 +1,23 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://w3c.github.io/web-animations/#animationeffecttimingreadonly
|
||||
*
|
||||
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
interface AnimationEffectTimingReadOnly {
|
||||
readonly attribute double delay;
|
||||
readonly attribute double endDelay;
|
||||
readonly attribute FillMode fill;
|
||||
readonly attribute double iterationStart;
|
||||
readonly attribute unrestricted double iterations;
|
||||
readonly attribute (unrestricted double or DOMString) duration;
|
||||
readonly attribute PlaybackDirection direction;
|
||||
readonly attribute DOMString easing;
|
||||
};
|
@ -24,6 +24,7 @@ WEBIDL_FILES = [
|
||||
'Animatable.webidl',
|
||||
'Animation.webidl',
|
||||
'AnimationEffectReadOnly.webidl',
|
||||
'AnimationEffectTimingReadOnly.webidl',
|
||||
'AnimationEvent.webidl',
|
||||
'AnimationTimeline.webidl',
|
||||
'AnonymousContent.webidl',
|
||||
|
@ -169,7 +169,7 @@ protected:
|
||||
// Returns the duration from the start of the animation's source effect's
|
||||
// active interval to the point where the animation actually begins playback.
|
||||
// This is zero unless the animation's source effect has a negative delay in
|
||||
// which // case it is the absolute value of that delay.
|
||||
// which case it is the absolute value of that delay.
|
||||
// This is used for setting the elapsedTime member of CSS AnimationEvents.
|
||||
TimeDuration InitialAdvance() const {
|
||||
return mEffect ?
|
||||
|
@ -55,7 +55,7 @@ ElementPropertyTransition::CurrentValuePortion() const
|
||||
// causing us to get called *after* the animation interval. So, just in
|
||||
// case, we override the fill mode to 'both' to ensure the progress
|
||||
// is never null.
|
||||
AnimationTiming timingToUse = mTiming;
|
||||
AnimationTiming timingToUse = Timing();
|
||||
timingToUse.mFill = dom::FillMode::Both;
|
||||
ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user