From b0fe759f033f36a9a85afd7cc358b4800def5013 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 14 Jan 2021 14:46:52 +0000 Subject: Issue #1689 - Part 1: Add pref for DOM Animation timelines API Default false, no intent to ship for web content. Always enabled for Chrome. --- dom/animation/test/crashtests/crashtests.list | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'dom/animation') diff --git a/dom/animation/test/crashtests/crashtests.list b/dom/animation/test/crashtests/crashtests.list index f61d7f876..29b18769a 100644 --- a/dom/animation/test/crashtests/crashtests.list +++ b/dom/animation/test/crashtests/crashtests.list @@ -1,13 +1,13 @@ pref(dom.animations-api.core.enabled,true) load 1239889-1.html pref(dom.animations-api.core.enabled,true) load 1244595-1.html -pref(dom.animations-api.core.enabled,true) load 1216842-1.html -pref(dom.animations-api.core.enabled,true) load 1216842-2.html -pref(dom.animations-api.core.enabled,true) load 1216842-3.html -pref(dom.animations-api.core.enabled,true) load 1216842-4.html -pref(dom.animations-api.core.enabled,true) load 1216842-5.html -pref(dom.animations-api.core.enabled,true) load 1216842-6.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-1.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-2.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-3.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-4.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-5.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1216842-6.html pref(dom.animations-api.core.enabled,true) load 1272475-1.html pref(dom.animations-api.core.enabled,true) load 1272475-2.html pref(dom.animations-api.core.enabled,true) load 1278485-1.html -pref(dom.animations-api.core.enabled,true) load 1277272-1.html +pref(dom.animations-api.core.enabled,true) pref(dom.animations-api.timelines.enabled,true) load 1277272-1.html pref(dom.animations-api.core.enabled,true) load 1290535-1.html -- cgit v1.2.3 From 407c86641a77a7d95db5f31b14f9f9f10c79d1e3 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 14 Jan 2021 16:05:53 +0000 Subject: Issue #1689 - Part 2: Add a preference for implicit keyframes This preference controls whether authors are allowed to specify animations without a 0% or 100% keyframe. We intend to ship this but it isn't implemented yet (needs a follow-up) but this preference acts as a safeguard in case we discover we need to disable it once it's implemented. --- dom/animation/KeyframeUtils.cpp | 30 ++++++++++++++++++++---------- dom/animation/test/mochitest.ini | 4 ++++ 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'dom/animation') diff --git a/dom/animation/KeyframeUtils.cpp b/dom/animation/KeyframeUtils.cpp index 166f6728a..540f892d5 100644 --- a/dom/animation/KeyframeUtils.cpp +++ b/dom/animation/KeyframeUtils.cpp @@ -7,6 +7,7 @@ #include "mozilla/AnimationUtils.h" #include "mozilla/ErrorResult.h" #include "mozilla/Move.h" +#include "mozilla/Preferences.h" #include "mozilla/RangedArray.h" #include "mozilla/ServoBindings.h" #include "mozilla/StyleAnimationValue.h" @@ -21,6 +22,7 @@ #include "nsCSSPropertyIDSet.h" #include "nsCSSProps.h" #include "nsCSSPseudoElements.h" // For CSSPseudoElementType +#include "nsDocument.h" #include "nsTArray.h" #include // For std::stable_sort @@ -400,7 +402,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx, ErrorResult& aRv); static bool -RequiresAdditiveAnimation(const nsTArray& aKeyframes, +HasImplicitKeyframeValues(const nsTArray& aKeyframes, nsIDocument* aDocument); static void @@ -467,11 +469,13 @@ KeyframeUtils::GetKeyframesFromObject(JSContext* aCx, // says that if you don't have a keyframe at offset 0 or 1, then you should // synthesize one using an additive zero value when you go to compose style. // Until we implement additive animations we just throw if we encounter any - // set of keyframes that would put us in that situation. + // set of keyframes that would put us in that situation and keyframes aren't + // explicitly force-enabled. - if (RequiresAdditiveAnimation(keyframes, aDocument)) { - aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR); + if (!nsDocument::AreWebAnimationsImplicitKeyframesEnabled(aCx, nullptr) && + HasImplicitKeyframeValues(keyframes, aDocument)) { keyframes.Clear(); + aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR); } return keyframes; @@ -1330,10 +1334,16 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx, // No animation values for this property. continue; } - if (count == 1) { - // We don't support additive values and so can't support an - // animation that goes from the underlying value to this - // specified value. Throw an exception until we do support this. + if (!Preferences::GetBool("dom.animations-api.implicit-keyframes.enabled") && + count == 1) { + // We don't support implicit keyframes by preference. + aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR); + return; + } else if (count == 1) { + // Implicit keyframes isn't implemented yet and so we can't + // support an animation that goes from the underlying value + // to this specified value. + // Throw an exception until we do support this. aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR); return; } @@ -1374,7 +1384,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx, * try to detect where we have an invalid value at 0%/100%. */ static bool -RequiresAdditiveAnimation(const nsTArray& aKeyframes, +HasImplicitKeyframeValues(const nsTArray& aKeyframes, nsIDocument* aDocument) { // We are looking to see if that every property referenced in |aKeyframes| @@ -1385,7 +1395,7 @@ RequiresAdditiveAnimation(const nsTArray& aKeyframes, // a document which we might not always have at the point where we want to // perform this check. // - // This is only a temporary measure until we implement additive animation. + // This is only a temporary measure until we implement implicit keyframes. // So as long as this check catches most cases, and we don't do anything // horrible in one of the cases we can't detect, it should be sufficient. diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index db6dffada..b56136d25 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -1,4 +1,8 @@ [DEFAULT] +prefs = + dom.animations-api.core.enabled=true + dom.animations-api.implicit-keyframes.enabled=true + dom.animations-api.timelines.enabled=true # Support files for chrome tests that we want to load over HTTP need # to go in here, not chrome.ini. support-files = -- cgit v1.2.3 From 931314ef61ce982ac4bae782c67477d48028fc56 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 14 Jan 2021 17:17:28 +0000 Subject: Issue #1689 - Part 3: Add a preference for animation composite modes. This feature should not be shipped until the various definitions of addition for each additive property are properly specified and then implemented accordingly. Unlike other patches in this series, compositing is not frequently used internally so there is no need to enable this by default for chrome callers. --- dom/animation/KeyframeEffect.cpp | 5 +++-- dom/animation/test/mochitest.ini | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'dom/animation') diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 90230a5b4..090c7019d 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -10,6 +10,7 @@ #include "mozilla/dom/AnimationEffectTiming.h" #include "mozilla/dom/KeyframeEffectBinding.h" #include "mozilla/KeyframeUtils.h" +#include "mozilla/Preferences.h" #include "nsContentUtils.h" #include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch #include "nsIScriptError.h" @@ -135,9 +136,9 @@ void KeyframeEffect::SetIterationComposite( const IterationCompositeOperation& aIterationComposite) { - // Ignore iterationComposite if the Web Animations API is not enabled, + // Ignore iterationComposite if the API is not enabled, // then the default value 'Replace' will be used. - if (!AnimationUtils::IsCoreAPIEnabledForCaller()) { + if (!Preferences::GetBool("dom.animations-api.compositing.enabled")) { return; } diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index b56136d25..fff62ac7c 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -1,5 +1,6 @@ [DEFAULT] prefs = + dom.animations-api.compositing.enabled=true dom.animations-api.core.enabled=true dom.animations-api.implicit-keyframes.enabled=true dom.animations-api.timelines.enabled=true -- cgit v1.2.3 From abc58d2ed0fd7739b31be78d6338ae79206ce879 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 14 Jan 2021 17:43:44 +0000 Subject: Issue #1689 - Part 4: Add a preference for {Document,Element}.getAnimations() This is probably the last thing we will ship (if ever) since it needs the most spec and implementation work for arbitrary use that is pretty far into a corner. --- dom/animation/test/mochitest.ini | 1 + 1 file changed, 1 insertion(+) (limited to 'dom/animation') diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index fff62ac7c..ecdb674fe 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -2,6 +2,7 @@ prefs = dom.animations-api.compositing.enabled=true dom.animations-api.core.enabled=true + dom.animations-api.getAnimations.enabled=true dom.animations-api.implicit-keyframes.enabled=true dom.animations-api.timelines.enabled=true # Support files for chrome tests that we want to load over HTTP need -- cgit v1.2.3