Bug 1321428 - Put scroll-driven animations behind a pref, and restrict to nightly builds. r=birtles
MozReview-Commit-ID: ESHjTZz4Rh9
--- 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");