Bug 1070745 part 2 - Update AnimationPlayer IDL to enable play() and pause(); r=bz
authorBrian Birtles <birtles@gmail.com>
Mon, 20 Oct 2014 13:55:43 +0900
changeset 211165 00ec97d72ebf458668ffe0a5ffba8073265ee02b
parent 211164 496e867cd2cd35bcac1adcae618273ddcf137c1d
child 211166 5a78f9e22770e8fc382e9d3d4405bc8ce30c0dcf
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs1070745
milestone36.0a1
Bug 1070745 part 2 - Update AnimationPlayer IDL to enable play() and pause(); r=bz We map play()/pause() to PlayFromJS/PauseFromJS internally so that internal users don't accidentally call Play()/Pause() which flush style.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
dom/bindings/Bindings.conf
dom/webidl/AnimationPlayer.webidl
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -29,16 +29,44 @@ AnimationPlayer::GetStartTime() const
 
 Nullable<double>
 AnimationPlayer::GetCurrentTime() const
 {
   return AnimationUtils::TimeDurationToDouble(GetCurrentTimeDuration());
 }
 
 void
+AnimationPlayer::Play()
+{
+  // TODO
+}
+
+void
+AnimationPlayer::Pause()
+{
+  // TODO
+}
+
+void
+AnimationPlayer::PlayFromJS()
+{
+  // TODO (flush styles etc.)
+
+  Play();
+}
+
+void
+AnimationPlayer::PauseFromJS()
+{
+  Play();
+
+  // TODO (flush styles etc.)
+}
+
+void
 AnimationPlayer::SetSource(Animation* aSource)
 {
   if (mSource) {
     mSource->SetParentTime(Nullable<TimeDuration>());
   }
   mSource = aSource;
   if (mSource) {
     mSource->SetParentTime(GetCurrentTimeDuration());
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -1,17 +1,16 @@
 /* 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_AnimationPlayer_h
 #define mozilla_dom_AnimationPlayer_h
 
-#include <algorithm> // for std::max
 #include "nsWrapperCache.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/Attributes.h"
 #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
 
@@ -44,18 +43,25 @@ public:
   AnimationTimeline* GetParentObject() const { return mTimeline; }
   virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
 
   // AnimationPlayer methods
   Animation* GetSource() const { return mSource; }
   AnimationTimeline* Timeline() const { return mTimeline; }
   Nullable<double> GetStartTime() const;
   Nullable<double> GetCurrentTime() const;
+  void Play();
+  void Pause();
   bool IsRunningOnCompositor() const { return mIsRunningOnCompositor; }
 
+  // Wrapper functions for performing extra steps such as flushing
+  // style when calling from JS.
+  void PauseFromJS();
+  void PlayFromJS();
+
   void SetSource(Animation* aSource);
   void Tick();
 
   const nsString& Name() const {
     return mSource ? mSource->Name() : EmptyString();
   }
 
   bool IsPaused() const {
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1,8 +1,10 @@
+# -*- Mode:Python; tab-width:8; indent-tabs-mode:nil; c-basic-offset:8 -*- */
+# vim: set ts=8 sts=4 et sw=4 tw=80: */
 # 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/.
 
 # DOM Bindings Configuration.
 #
 # The WebIDL interfaces are defined in dom/webidl. For each such interface, there
 # is a corresponding entry in the configuration table below. The configuration
--- a/dom/webidl/AnimationPlayer.webidl
+++ b/dom/webidl/AnimationPlayer.webidl
@@ -23,18 +23,22 @@ interface AnimationPlayer {
 
   /* Not yet implemented
            attribute double             playbackRate;
   readonly attribute AnimationPlayState playState;
   readonly attribute Promise            ready;
   readonly attribute Promise            finished;
   void cancel ();
   void finish ();
+  */
+  [BinaryName="playFromJS"]
   void play ();
+  [BinaryName="pauseFromJS"]
   void pause ();
+  /*
   void reverse ();
   */
 };
 
 // Non-standard extensions
 partial interface AnimationPlayer {
   [ChromeOnly] readonly attribute boolean isRunningOnCompositor;
 };