Bug 1045993 part 1 - Add AnimationEffect interface and Animation.effect member; r=dbaron, r=bz

This commit is contained in:
Brian Birtles 2014-08-22 13:42:47 +01:00
parent 85736e031c
commit 29081b3bb1
9 changed files with 104 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/AnimationBinding.h"
#include "mozilla/dom/AnimationEffect.h"
#include "mozilla/FloatingPoint.h"
namespace mozilla {
@ -68,6 +69,13 @@ Animation::WrapObject(JSContext* aCx)
return AnimationBinding::Wrap(aCx, this);
}
already_AddRefed<AnimationEffect>
Animation::GetEffect()
{
nsRefPtr<AnimationEffect> effect = new AnimationEffect(this);
return effect.forget();
}
void
Animation::SetParentTime(Nullable<TimeDuration> aParentTime)
{

View File

@ -120,6 +120,8 @@ struct ElementPropertyTransition;
namespace dom {
class AnimationEffect;
class Animation : public nsWrapperCache
{
public:
@ -146,6 +148,11 @@ public:
return nullptr;
}
// Animation interface
// This currently returns a new object each time when used from C++ but is
// cached when used from JS.
already_AddRefed<AnimationEffect> GetEffect();
void SetParentTime(Nullable<TimeDuration> aParentTime);
const AnimationTiming& Timing() const {

View File

@ -0,0 +1,24 @@
/* 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/AnimationEffect.h"
#include "mozilla/dom/AnimationEffectBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationEffect, mAnimation)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationEffect, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationEffect, Release)
JSObject*
AnimationEffect::WrapObject(JSContext* aCx)
{
return AnimationEffectBinding::Wrap(aCx, this);
}
} // 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 "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/Animation.h"
struct JSContext;
namespace mozilla {
namespace dom {
class AnimationEffect MOZ_FINAL : public nsWrapperCache
{
public:
AnimationEffect(Animation* aAnimation)
: mAnimation(aAnimation)
{
SetIsDOMBinding();
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationEffect)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationEffect)
Animation* GetParentObject() const { return mAnimation; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
private:
~AnimationEffect() { }
nsRefPtr<Animation> mAnimation;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_AnimationEffect_h

View File

@ -9,12 +9,14 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
EXPORTS.mozilla.dom += [
'Animation.h',
'AnimationEffect.h',
'AnimationPlayer.h',
'AnimationTimeline.h',
]
SOURCES += [
'Animation.cpp',
'AnimationEffect.cpp',
'AnimationPlayer.cpp',
'AnimationTimeline.cpp',
]

View File

@ -121,6 +121,8 @@ var interfaceNamesInGlobalScope =
"AnimationEvent",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "Animation", pref: "dom.animations-api.core.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "AnimationEffect", pref: "dom.animations-api.core.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "AnimationPlayer", pref: "dom.animations-api.core.enabled"},
// IMPORTANT: Do not change this list without review from a DOM peer!

View File

@ -12,4 +12,7 @@
[Pref="dom.animations-api.core.enabled"]
interface Animation {
// FIXME: |effect| should have type (AnimationEffect or EffectCallback)?
// but we haven't implemented EffectCallback yet.
[Cached,Pure] readonly attribute AnimationEffect? effect;
};

View File

@ -0,0 +1,15 @@
/* -*- 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://dev.w3.org/fxtf/web-animations/#the-animationeffect-interface
*
* Copyright © 2014 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
[Pref="dom.animations-api.core.enabled"]
interface AnimationEffect {
};

View File

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