Bug 1153734 part 5 - Add AnimationEffectReadonly as a superinterface of KeyframeEffectReadonly; r=smaug

This patch also replaces some tabs with spaces in KeyframeEffect.h because I was
in the area.
This commit is contained in:
Brian Birtles 2015-04-15 08:48:21 +09:00
parent 0c9201c98b
commit b318248411
11 changed files with 114 additions and 19 deletions

View File

@ -0,0 +1,23 @@
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* 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/AnimationEffectReadonly.h"
#include "mozilla/dom/AnimationEffectReadonlyBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationEffectReadonly, mParent)
NS_IMPL_CYCLE_COLLECTING_ADDREF(AnimationEffectReadonly)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AnimationEffectReadonly)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AnimationEffectReadonly)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
} // namespace dom
} // namespace mozilla

View File

@ -0,0 +1,42 @@
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* 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_AnimationEffect_h
#define mozilla_dom_AnimationEffect_h
#include "nsISupports.h"
#include "nsWrapperCache.h"
#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
namespace mozilla {
namespace dom {
class AnimationEffectReadonly
: public nsISupports
, public nsWrapperCache
{
protected:
virtual ~AnimationEffectReadonly() { }
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationEffectReadonly)
explicit AnimationEffectReadonly(nsISupports* aParent)
: mParent(aParent)
{
}
nsISupports* GetParentObject() const { return mParent; }
protected:
nsCOMPtr<nsISupports> mParent;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_AnimationEffect_h

View File

@ -59,12 +59,19 @@ const double ComputedTiming::kNullTimeFraction = PositiveInfinity<double>();
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(KeyframeEffectReadonly,
mDocument,
mTarget)
NS_IMPL_CYCLE_COLLECTION_INHERITED(KeyframeEffectReadonly,
AnimationEffectReadonly,
mTarget)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(KeyframeEffectReadonly, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(KeyframeEffectReadonly, Release)
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(KeyframeEffectReadonly,
AnimationEffectReadonly)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(KeyframeEffectReadonly)
NS_INTERFACE_MAP_END_INHERITING(AnimationEffectReadonly)
NS_IMPL_ADDREF_INHERITED(KeyframeEffectReadonly, AnimationEffectReadonly)
NS_IMPL_RELEASE_INHERITED(KeyframeEffectReadonly, AnimationEffectReadonly)
JSObject*
KeyframeEffectReadonly::WrapObject(JSContext* aCx,

View File

@ -15,6 +15,7 @@
#include "mozilla/StickyTimeDuration.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/AnimationEffectReadonly.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Nullable.h"
#include "nsSMILKeySpline.h"
@ -117,8 +118,8 @@ public:
bool operator==(const ComputedTimingFunction& aOther) const {
return mType == aOther.mType &&
(mType == nsTimingFunction::Function ?
mTimingFunction == aOther.mTimingFunction :
mSteps == aOther.mSteps);
mTimingFunction == aOther.mTimingFunction :
mSteps == aOther.mSteps);
}
bool operator!=(const ComputedTimingFunction& aOther) const {
return !(*this == aOther);
@ -184,7 +185,7 @@ struct ElementPropertyTransition;
namespace dom {
class KeyframeEffectReadonly : public nsWrapperCache
class KeyframeEffectReadonly : public AnimationEffectReadonly
{
public:
KeyframeEffectReadonly(nsIDocument* aDocument,
@ -192,7 +193,7 @@ public:
nsCSSPseudoElements::Type aPseudoType,
const AnimationTiming &aTiming,
const nsSubstring& aName)
: mDocument(aDocument)
: AnimationEffectReadonly(aDocument)
, mTarget(aTarget)
, mTiming(aTiming)
, mName(aName)
@ -202,10 +203,10 @@ public:
MOZ_ASSERT(aTarget, "null animation target is not yet supported");
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(KeyframeEffectReadonly)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(KeyframeEffectReadonly)
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffectReadonly,
AnimationEffectReadonly)
nsIDocument* GetParentObject() const { return mDocument; }
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
@ -333,9 +334,6 @@ public:
protected:
virtual ~KeyframeEffectReadonly() { }
// We use a document for a parent object since the other likely candidate,
// the target element, can be empty.
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<Element> mTarget;
Nullable<TimeDuration> mParentTime;

View File

@ -8,6 +8,7 @@ MOCHITEST_MANIFESTS += ['test/mochitest.ini']
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
EXPORTS.mozilla.dom += [
'AnimationEffectReadonly.h',
'AnimationPlayer.h',
'AnimationTimeline.h',
'DocumentTimeline.h',
@ -20,6 +21,7 @@ EXPORTS.mozilla += [
]
UNIFIED_SOURCES += [
'AnimationEffectReadonly.cpp',
'AnimationPlayer.cpp',
'AnimationTimeline.cpp',
'DocumentTimeline.cpp',

View File

@ -88,6 +88,10 @@ DOMInterfaces = {
'concrete': False
},
'AnimationEffectReadonly': {
'concrete': False
},
'AnimationTimeline': {
'concrete': False
},

View File

@ -129,6 +129,8 @@ var interfaceNamesInGlobalScope =
{name: "AlarmsManager", pref: "dom.mozAlarms.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
"AnalyserNode",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "AnimationEffectReadonly", pref: "dom.animations-api.core.enabled"},
// 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!

View File

@ -0,0 +1,18 @@
/* -*- 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
* http://w3c.github.io/web-animations/#animationeffectreadonly
*
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[Func="nsDocument::IsWebAnimationsEnabled"]
interface AnimationEffectReadonly {
// Not yet implemented:
// readonly attribute AnimationEffectTimingReadonly timing;
// readonly attribute ComputedTimingProperties computedTiming;
};

View File

@ -15,10 +15,8 @@ enum AnimationPlayState { "idle", "pending", "running", "paused", "finished" };
[Func="nsDocument::IsWebAnimationsEnabled"]
interface AnimationPlayer {
// Bug 1049975: Make 'effect' writeable
// FIXME: In a later patch in this series we'll rename KeyframeEffectReadonly
// with AnimationEffectReadonly
[Pure]
readonly attribute KeyframeEffectReadonly? effect;
readonly attribute AnimationEffectReadonly? effect;
readonly attribute AnimationTimeline timeline;
[BinaryName="startTimeAsDouble"]
attribute double? startTime;

View File

@ -12,7 +12,7 @@
[HeaderFile="mozilla/dom/KeyframeEffect.h",
Func="nsDocument::IsWebAnimationsEnabled"]
interface KeyframeEffectReadonly {
interface KeyframeEffectReadonly : AnimationEffectReadonly {
readonly attribute Element? target;
readonly attribute DOMString name;
// Not yet implemented:

View File

@ -22,6 +22,7 @@ WEBIDL_FILES = [
'AlarmsManager.webidl',
'AnalyserNode.webidl',
'Animatable.webidl',
'AnimationEffectReadonly.webidl',
'AnimationEvent.webidl',
'AnimationPlayer.webidl',
'AnimationTimeline.webidl',