Bug 1040543 part 3 - Add Animation interface; r=bz

This patch adds the Animation interface and adds a 'source' attribute to
AnimationPlayer that refers to this class.
This commit is contained in:
Brian Birtles 2014-08-10 17:06:46 +10:00
parent d3002fb8dd
commit 30c27e5573
8 changed files with 94 additions and 0 deletions

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/Animation.h"
#include "mozilla/dom/AnimationBinding.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Animation, mDocument)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(Animation, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(Animation, Release)
JSObject*
Animation::WrapObject(JSContext* aCx)
{
return AnimationBinding::Wrap(aCx, this);
}
} // namespace dom
} // namespace mozilla

46
dom/animation/Animation.h Normal file
View File

@ -0,0 +1,46 @@
/* 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_Animation_h
#define mozilla_dom_Animation_h
#include "nsAutoPtr.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIDocument.h"
#include "nsWrapperCache.h"
#include "mozilla/Attributes.h"
struct JSContext;
namespace mozilla {
namespace dom {
class Animation MOZ_FINAL : public nsWrapperCache
{
public:
explicit Animation(nsIDocument* aDocument)
: mDocument(aDocument)
{
SetIsDOMBinding();
}
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(Animation)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(Animation)
nsIDocument* GetParentObject() const { return mDocument; }
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
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;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_Animation_h

View File

@ -12,6 +12,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
#include "mozilla/dom/Animation.h" // for Animation
#include "mozilla/dom/AnimationTimeline.h" // for AnimationTimeline
#include "nsCSSProperty.h" // for nsCSSProperty
#include "nsSMILKeySpline.h" // for nsSMILKeySpline
@ -145,6 +146,7 @@ public:
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
// AnimationPlayer methods
Animation* GetSource() const { return nullptr; }
AnimationTimeline* Timeline() const { return mTimeline; }
double StartTime() const;
double CurrentTime() const;

View File

@ -7,11 +7,13 @@
MOCHITEST_MANIFESTS += ['test/mochitest.ini']
EXPORTS.mozilla.dom += [
'Animation.h',
'AnimationPlayer.h',
'AnimationTimeline.h',
]
SOURCES += [
'Animation.cpp',
'AnimationPlayer.cpp',
'AnimationTimeline.cpp',
]

View File

@ -118,6 +118,8 @@ var interfaceNamesInGlobalScope =
"AnalyserNode",
// 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!
{name: "Animation", 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

@ -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-animation-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 Animation {
};

View File

@ -12,6 +12,8 @@
[Pref="dom.animations-api.core.enabled"]
interface AnimationPlayer {
// Bug 1049975: Per spec, this should be a writeable AnimationNode? member
[Pure] readonly attribute Animation? source;
readonly attribute AnimationTimeline timeline;
[Pure] readonly attribute double startTime;
readonly attribute double currentTime;

View File

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