diff options
author | Moonchild <moonchild@palemoon.org> | 2021-01-18 09:41:05 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-01-18 09:41:05 +0000 |
commit | c77d06c0c41e23e324ce1d82b1a57e29c2ecea13 (patch) | |
tree | 12d8a617475910fe624bdf9af0e9ba53b89988a9 /dom/animation | |
parent | 82fb08c6504ee0e271ed193ed2c0ef4ac27fbec2 (diff) | |
parent | b3d380b4ea683bd5a02198876333455b2cd3cb69 (diff) | |
download | UXP-c77d06c0c41e23e324ce1d82b1a57e29c2ecea13.tar UXP-c77d06c0c41e23e324ce1d82b1a57e29c2ecea13.tar.gz UXP-c77d06c0c41e23e324ce1d82b1a57e29c2ecea13.tar.lz UXP-c77d06c0c41e23e324ce1d82b1a57e29c2ecea13.tar.xz UXP-c77d06c0c41e23e324ce1d82b1a57e29c2ecea13.zip |
Merge pull request 'Selectively enable and pref the DOM Web Animations API' (#1714) from 1689 into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1714
Diffstat (limited to 'dom/animation')
-rw-r--r-- | dom/animation/KeyframeEffect.cpp | 5 | ||||
-rw-r--r-- | dom/animation/KeyframeUtils.cpp | 30 | ||||
-rw-r--r-- | dom/animation/test/crashtests/crashtests.list | 14 | ||||
-rw-r--r-- | dom/animation/test/mochitest.ini | 6 |
4 files changed, 36 insertions, 19 deletions
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/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 <algorithm> // For std::stable_sort @@ -400,7 +402,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx, ErrorResult& aRv); static bool -RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes, +HasImplicitKeyframeValues(const nsTArray<Keyframe>& 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<Keyframe>& aKeyframes, +HasImplicitKeyframeValues(const nsTArray<Keyframe>& aKeyframes, nsIDocument* aDocument) { // We are looking to see if that every property referenced in |aKeyframes| @@ -1385,7 +1395,7 @@ RequiresAdditiveAnimation(const nsTArray<Keyframe>& 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/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 diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index db6dffada..ecdb674fe 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -1,4 +1,10 @@ [DEFAULT] +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 # to go in here, not chrome.ini. support-files = |