Bug 1112422 - Turn on the Web Animations API by default for chrome callers; r=bz
authorBrian Birtles <birtles@gmail.com>
Thu, 08 Jan 2015 13:53:24 +0900
changeset 235615 00996e98fa624e9dc642f95d695814e9be1b6dbd
parent 235614 28bbffbcd08e6c15b6d8880d73adeba5dc31b1b6
child 235616 a3292d545bea6b9957ce0b1e293524fa816adce9
push id366
push usercmanchester@mozilla.com
push dateThu, 08 Jan 2015 16:40:24 +0000
reviewersbz
bugs1112422
milestone37.0a1
Bug 1112422 - Turn on the Web Animations API by default for chrome callers; r=bz
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/webidl/Animatable.webidl
dom/webidl/Animation.webidl
dom/webidl/AnimationEffect.webidl
dom/webidl/AnimationPlayer.webidl
dom/webidl/AnimationTimeline.webidl
dom/webidl/Document.webidl
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3277,16 +3277,25 @@ nsDocument::GetUndoManager()
   if (!mUndoManager) {
     mUndoManager = new UndoManager(rootElement);
   }
 
   nsRefPtr<UndoManager> undoManager = mUndoManager;
   return undoManager.forget();
 }
 
+bool
+nsDocument::IsWebAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  return nsContentUtils::IsCallerChrome() ||
+         Preferences::GetBool("dom.animations-api.core.enabled");
+}
+
 AnimationTimeline*
 nsDocument::Timeline()
 {
   if (!mAnimationTimeline) {
     mAnimationTimeline = new AnimationTimeline(this);
   }
 
   return mAnimationTimeline;
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -777,16 +777,17 @@ public:
                                                      nsViewManager* aViewManager,
                                                      nsStyleSet* aStyleSet) MOZ_OVERRIDE;
   virtual void DeleteShell() MOZ_OVERRIDE;
 
   virtual nsresult GetAllowPlugins(bool* aAllowPlugins) MOZ_OVERRIDE;
 
   virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager() MOZ_OVERRIDE;
 
+  static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
   virtual mozilla::dom::AnimationTimeline* Timeline() MOZ_OVERRIDE;
 
   virtual nsresult SetSubDocumentFor(Element* aContent,
                                      nsIDocument* aSubDoc) MOZ_OVERRIDE;
   virtual nsIDocument* GetSubDocumentFor(nsIContent* aContent) const MOZ_OVERRIDE;
   virtual Element* FindContentForSubDocument(nsIDocument *aDocument) const MOZ_OVERRIDE;
   virtual Element* GetRootElementInternal() const MOZ_OVERRIDE;
 
--- a/dom/webidl/Animatable.webidl
+++ b/dom/webidl/Animatable.webidl
@@ -7,11 +7,11 @@
  * http://dev.w3.org/fxtf/web-animations/#the-animatable-interface
  *
  * Copyright © 2014 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [NoInterfaceObject]
 interface Animatable {
-  [Pref="dom.animations-api.core.enabled"]
+  [Func="nsDocument::IsWebAnimationsEnabled"]
   sequence<AnimationPlayer> getAnimationPlayers();
 };
--- a/dom/webidl/Animation.webidl
+++ b/dom/webidl/Animation.webidl
@@ -5,17 +5,17 @@
  *
  * 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"]
+[Func="nsDocument::IsWebAnimationsEnabled"]
 interface Animation {
   // FIXME: |effect| should have type (AnimationEffect or EffectCallback)?
   // but we haven't implemented EffectCallback yet.
   [Cached,Pure]
   readonly attribute AnimationEffect? effect;
   // FIXME: This should be writeable (bug 1067769)
   readonly attribute Element?         target;
 };
--- a/dom/webidl/AnimationEffect.webidl
+++ b/dom/webidl/AnimationEffect.webidl
@@ -5,12 +5,12 @@
  *
  * 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"]
+[Func="nsDocument::IsWebAnimationsEnabled"]
 interface AnimationEffect {
   readonly attribute DOMString name;
 };
--- a/dom/webidl/AnimationPlayer.webidl
+++ b/dom/webidl/AnimationPlayer.webidl
@@ -7,17 +7,17 @@
  * http://dev.w3.org/fxtf/web-animations/#idl-def-AnimationPlayer
  *
  * Copyright © 2014 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 enum AnimationPlayState { "idle", "pending", "running", "paused", "finished" };
 
-[Pref="dom.animations-api.core.enabled"]
+[Func="nsDocument::IsWebAnimationsEnabled"]
 interface AnimationPlayer {
   // Bug 1049975
   //           attribute AnimationNode?     source;
   [Pure]
   readonly attribute Animation? source;
   readonly attribute AnimationTimeline timeline;
   [BinaryName="startTimeAsDouble"]
   readonly attribute double? startTime;
--- a/dom/webidl/AnimationTimeline.webidl
+++ b/dom/webidl/AnimationTimeline.webidl
@@ -5,16 +5,16 @@
  *
  * The origin of this IDL file is
  * 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"]
+[Func="nsDocument::IsWebAnimationsEnabled"]
 interface AnimationTimeline {
   [BinaryName="currentTimeAsDouble"]
   readonly attribute double? currentTime;
   // Not yet implemented:
   // AnimationPlayer            play (optional TimedItem? source = null);
   // sequence<AnimationPlayer>  getAnimationPlayers ();
 };
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -282,17 +282,17 @@ partial interface Document {
   NodeList  querySelectorAll(DOMString selectors);
 
   //(Not implemented)Element?  find(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
   //(Not implemented)NodeList  findAll(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
 };
 
 // http://dev.w3.org/fxtf/web-animations/#extensions-to-the-document-interface
 partial interface Document {
-  [Pref="dom.animations-api.core.enabled"]
+  [Func="nsDocument::IsWebAnimationsEnabled"]
   readonly attribute AnimationTimeline timeline;
 };
 
 //  Mozilla extensions of various sorts
 partial interface Document {
   // nsIDOMDocumentXBL.  Wish we could make these [ChromeOnly], but
   // that would likely break bindings running with the page principal.
   [Func="IsChromeOrXBL"]