Bug 1321428 - Put scroll-driven animations behind a pref, and restrict to nightly builds. r=birtles draft
authorBotond Ballo <botond@mozilla.com>
Fri, 02 Dec 2016 18:32:00 -0500
changeset 542203 ebc4cc22fc9cfccf6e1ba28e0249793d5b96cd59
parent 542202 af5a4d47d9fe6df1c1ef7a465ec9c486e6f9fa4c
child 542204 eedbefcca12df1855c726c75e603036a180b420e
push id50961
push userbballo@mozilla.com
push dateFri, 24 Mar 2017 22:03:27 +0000
reviewersbirtles
bugs1321428
milestone55.0a1
Bug 1321428 - Put scroll-driven animations behind a pref, and restrict to nightly builds. r=birtles MozReview-Commit-ID: ESHjTZz4Rh9
dom/base/nsDocument.cpp
dom/base/nsDocument.h
dom/webidl/ScrollTimeline.webidl
modules/libpref/init/all.js
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3170,16 +3170,34 @@ bool
 nsDocument::IsWebAnimationsEnabled(JSContext* aCx, JSObject* /*unused*/)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   return nsContentUtils::IsSystemCaller(aCx) ||
          Preferences::GetBool("dom.animations-api.core.enabled");
 }
 
+bool
+nsDocument::IsScrollDrivenAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
+{
+  MOZ_ASSERT(NS_IsMainThread());
+
+  // Scroll-driven animations are currently nightly-only *and* behind
+  // a pref, for both chrome and content callers.
+  // Reminder: when removing the nightly-only restriction, also remove
+  //           the corresponding 'skip-if(!isNightlyBuild)' annotation
+  //           of any reftests for scroll-driven animations.
+#ifdef NIGHTLY_BUILD
+  return Preferences::GetBool("dom.animations-api.core.enabled") &&
+         Preferences::GetBool("dom.animations-api.scroll-driven.enabled");
+#else
+  return false;
+#endif
+}
+
 DocumentTimeline*
 nsDocument::Timeline()
 {
   if (!mDocumentTimeline) {
     mDocumentTimeline = new DocumentTimeline(this, TimeDuration(0));
   }
 
   return mDocumentTimeline;
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -601,16 +601,17 @@ public:
                                              mozilla::StyleSetHandle aStyleSet)
     final;
   virtual void DeleteShell() override;
 
   virtual bool GetAllowPlugins() override;
 
   static bool IsElementAnimateEnabled(JSContext* aCx, JSObject* aObject);
   static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
+  static bool IsScrollDrivenAnimationsEnabled(JSContext* aCx, JSObject* aObject);
   virtual mozilla::dom::DocumentTimeline* Timeline() override;
   virtual void GetAnimations(
       nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) override;
   mozilla::LinkedList<mozilla::dom::DocumentTimeline>& Timelines() override
   {
     return mTimelines;
   }
   mozilla::LinkedList<mozilla::dom::ScrollTimeline>& ScrollTimelines() override
--- a/dom/webidl/ScrollTimeline.webidl
+++ b/dom/webidl/ScrollTimeline.webidl
@@ -18,17 +18,17 @@ dictionary ScrollTimelineOptions {
   Element scrollSource;
   ScrollDirection orientation;
   DOMString startScrollOffset = "auto";
   DOMString endScrollOffset = "auto";
   (double or ScrollTimelineAutoKeyword) timeRange = "auto";
   FillMode fillMode = "none";
 };
 
-[Func="nsDocument::IsWebAnimationsEnabled",
+[Func="nsDocument::IsScrollDrivenAnimationsEnabled",
  Constructor(optional ScrollTimelineOptions options)]
 interface ScrollTimeline : AnimationTimeline {
   readonly attribute Element sourceElement;
   readonly attribute ScrollDirection orientation;
   readonly attribute DOMString startScrollOffset;
   readonly attribute DOMString endScrollOffset;
   readonly attribute (double or ScrollTimelineAutoKeyword) timeRange;
   readonly attribute FillMode fill;
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2746,16 +2746,19 @@ pref("dom.animations-api.core.enabled", 
 #endif
 
 // Is support for the Element.animate() function (a subset of the Web Animations
 // API) enabled?
 // Note that if dom.animations-api.core.enabled is true, this preference is
 // ignored.
 pref("dom.animations-api.element-animate.enabled", true);
 
+// Is support for scroll-driven animations enabled?
+pref("dom.animations-api.scroll-driven.enabled", false);
+
 // Pref to throttle offsreen animations
 pref("dom.animations.offscreen-throttling", true);
 
 // Prefs to control the maximum area to pre-render when animating a large
 // element on the compositor.
 pref("layout.animation.prerender.partial", false);
 pref("layout.animation.prerender.viewport-ratio-limit-x", "1.125");
 pref("layout.animation.prerender.viewport-ratio-limit-y", "1.125");