Bug 1040543 part 3 - Add Animation interface; r=bz
authorBrian Birtles <birtles@gmail.com>
Sun, 10 Aug 2014 17:06:46 +1000
changeset 198785 cc995232033eb474ca0ce46f27c2f43a849cdff1
parent 198784 daca3c0d2c85d6deaa0c9332150d9937988067be
child 198786 a50e04b3a69991cd592b394db8bd163ebe05c993
push id27286
push usernigelbabu@gmail.com
push dateMon, 11 Aug 2014 06:26:45 +0000
treeherdermozilla-central@8c4a1b3a2a8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1040543
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
dom/animation/Animation.cpp
dom/animation/Animation.h
dom/animation/AnimationPlayer.h
dom/animation/moz.build
dom/tests/mochitest/general/test_interfaces.html
dom/webidl/Animation.webidl
dom/webidl/AnimationPlayer.webidl
dom/webidl/moz.build
new file mode 100644
--- /dev/null
+++ b/dom/animation/Animation.cpp
@@ -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
new file mode 100644
--- /dev/null
+++ b/dom/animation/Animation.h
@@ -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
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -7,16 +7,17 @@
 #define mozilla_dom_AnimationPlayer_h
 
 #include <algorithm> // for std::max
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #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
 #include "nsStyleStruct.h" // for nsTimingFunction
 
 // X11 has a #define for CurrentTime.
 #ifdef CurrentTime
 #undef CurrentTime
@@ -140,16 +141,17 @@ public:
 
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationPlayer)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationPlayer)
 
   AnimationTimeline* GetParentObject() const { return mTimeline; }
   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;
 
   // FIXME: If we succeed in moving transition-specific code to a type of
   // AnimationEffect (as per the Web Animations API) we should remove these
   // virtual methods.
   virtual ElementPropertyTransition* AsTransition() { return nullptr; }
--- a/dom/animation/moz.build
+++ b/dom/animation/moz.build
@@ -2,20 +2,22 @@
 # vim: set filetype=python:
 # 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/.
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 
 EXPORTS.mozilla.dom += [
+    'Animation.h',
     'AnimationPlayer.h',
     'AnimationTimeline.h',
 ]
 
 SOURCES += [
+    'Animation.cpp',
     'AnimationPlayer.cpp',
     'AnimationTimeline.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 FINAL_LIBRARY = 'xul'
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -114,16 +114,18 @@ var interfaceNamesInGlobalScope =
   [
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {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!
     "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!
     {name: "AnimationTimeline", pref: "dom.animations-api.core.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Attr",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "Audio",
 // IMPORTANT: Do not change this list without review from a DOM peer!
new file mode 100644
--- /dev/null
+++ b/dom/webidl/Animation.webidl
@@ -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 {
+};
--- a/dom/webidl/AnimationPlayer.webidl
+++ b/dom/webidl/AnimationPlayer.webidl
@@ -7,12 +7,14 @@
  * http://dev.w3.org/fxtf/web-animations/#the-animationtimeline-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 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;
 };
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -16,16 +16,17 @@ PREPROCESSED_WEBIDL_FILES = [
 ]
 
 WEBIDL_FILES = [
     'AbstractWorker.webidl',
     'ActivityRequestHandler.webidl',
     'AlarmsManager.webidl',
     'AnalyserNode.webidl',
     'Animatable.webidl',
+    'Animation.webidl',
     'AnimationEvent.webidl',
     'AnimationPlayer.webidl',
     'AnimationTimeline.webidl',
     'AppInfo.webidl',
     'AppNotificationServiceOptions.webidl',
     'APZTestData.webidl',
     'ArchiveReader.webidl',
     'ArchiveRequest.webidl',