Sort out the Web Animations API.
This commit is contained in:
parent
317673d504
commit
0688000585
|
@ -10,6 +10,7 @@
|
||||||
#include "mozilla/dom/AnimationEffectTiming.h"
|
#include "mozilla/dom/AnimationEffectTiming.h"
|
||||||
#include "mozilla/dom/KeyframeEffectBinding.h"
|
#include "mozilla/dom/KeyframeEffectBinding.h"
|
||||||
#include "mozilla/KeyframeUtils.h"
|
#include "mozilla/KeyframeUtils.h"
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
|
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
|
||||||
#include "nsIScriptError.h"
|
#include "nsIScriptError.h"
|
||||||
|
@ -135,9 +136,9 @@ void
|
||||||
KeyframeEffect::SetIterationComposite(
|
KeyframeEffect::SetIterationComposite(
|
||||||
const IterationCompositeOperation& aIterationComposite)
|
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.
|
// then the default value 'Replace' will be used.
|
||||||
if (!AnimationUtils::IsCoreAPIEnabledForCaller()) {
|
if (!Preferences::GetBool("dom.animations-api.compositing.enabled")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "mozilla/AnimationUtils.h"
|
#include "mozilla/AnimationUtils.h"
|
||||||
#include "mozilla/ErrorResult.h"
|
#include "mozilla/ErrorResult.h"
|
||||||
#include "mozilla/Move.h"
|
#include "mozilla/Move.h"
|
||||||
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/RangedArray.h"
|
#include "mozilla/RangedArray.h"
|
||||||
#include "mozilla/ServoBindings.h"
|
#include "mozilla/ServoBindings.h"
|
||||||
#include "mozilla/StyleAnimationValue.h"
|
#include "mozilla/StyleAnimationValue.h"
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
#include "nsCSSPropertyIDSet.h"
|
#include "nsCSSPropertyIDSet.h"
|
||||||
#include "nsCSSProps.h"
|
#include "nsCSSProps.h"
|
||||||
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
|
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
|
||||||
|
#include "nsDocument.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
#include <algorithm> // For std::stable_sort
|
#include <algorithm> // For std::stable_sort
|
||||||
|
|
||||||
|
@ -400,7 +402,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
|
HasImplicitKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
|
||||||
nsIDocument* aDocument);
|
nsIDocument* aDocument);
|
||||||
|
|
||||||
static void
|
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
|
// 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.
|
// 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
|
// 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)) {
|
if (!nsDocument::AreWebAnimationsImplicitKeyframesEnabled(aCx, nullptr) &&
|
||||||
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
|
HasImplicitKeyframeValues(keyframes, aDocument)) {
|
||||||
keyframes.Clear();
|
keyframes.Clear();
|
||||||
|
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyframes;
|
return keyframes;
|
||||||
|
@ -1330,10 +1334,16 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx,
|
||||||
// No animation values for this property.
|
// No animation values for this property.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (count == 1) {
|
if (!Preferences::GetBool("dom.animations-api.implicit-keyframes.enabled") &&
|
||||||
// We don't support additive values and so can't support an
|
count == 1) {
|
||||||
// animation that goes from the underlying value to this
|
// We don't support implicit keyframes by preference.
|
||||||
// specified value. Throw an exception until we do support this.
|
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);
|
aRv.Throw(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1374,7 +1384,7 @@ GetKeyframeListFromPropertyIndexedKeyframe(JSContext* aCx,
|
||||||
* try to detect where we have an invalid value at 0%/100%.
|
* try to detect where we have an invalid value at 0%/100%.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
RequiresAdditiveAnimation(const nsTArray<Keyframe>& aKeyframes,
|
HasImplicitKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
|
||||||
nsIDocument* aDocument)
|
nsIDocument* aDocument)
|
||||||
{
|
{
|
||||||
// We are looking to see if that every property referenced in |aKeyframes|
|
// 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
|
// a document which we might not always have at the point where we want to
|
||||||
// perform this check.
|
// 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
|
// 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.
|
// horrible in one of the cases we can't detect, it should be sufficient.
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
pref(dom.animations-api.core.enabled,true) load 1239889-1.html
|
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 1244595-1.html
|
||||||
pref(dom.animations-api.core.enabled,true) load 1216842-1.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) load 1216842-2.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) load 1216842-3.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) load 1216842-4.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) load 1216842-5.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) load 1216842-6.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-1.html
|
||||||
pref(dom.animations-api.core.enabled,true) load 1272475-2.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 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
|
pref(dom.animations-api.core.enabled,true) load 1290535-1.html
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
[DEFAULT]
|
[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
|
# Support files for chrome tests that we want to load over HTTP need
|
||||||
# to go in here, not chrome.ini.
|
# to go in here, not chrome.ini.
|
||||||
support-files =
|
support-files =
|
||||||
|
|
|
@ -2923,6 +2923,33 @@ nsDocument::IsWebAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
|
||||||
Preferences::GetBool("dom.animations-api.core.enabled");
|
Preferences::GetBool("dom.animations-api.core.enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsDocument::AreWebAnimationsTimelinesEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
return nsContentUtils::IsCallerChrome() ||
|
||||||
|
Preferences::GetBool("dom.animations-api.timelines.enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsDocument::AreWebAnimationsImplicitKeyframesEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
return nsContentUtils::IsCallerChrome() ||
|
||||||
|
Preferences::GetBool("dom.animations-api.implicit-keyframes.enabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsDocument::IsWebAnimationsGetAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
return nsContentUtils::IsCallerChrome() ||
|
||||||
|
Preferences::GetBool("dom.animations-api.getAnimations.enabled");
|
||||||
|
}
|
||||||
|
|
||||||
DocumentTimeline*
|
DocumentTimeline*
|
||||||
nsDocument::Timeline()
|
nsDocument::Timeline()
|
||||||
{
|
{
|
||||||
|
|
|
@ -433,6 +433,10 @@ public:
|
||||||
|
|
||||||
static bool IsElementAnimateEnabled(JSContext* aCx, JSObject* aObject);
|
static bool IsElementAnimateEnabled(JSContext* aCx, JSObject* aObject);
|
||||||
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
|
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
|
||||||
|
static bool AreWebAnimationsImplicitKeyframesEnabled(JSContext* aCx, JSObject* aObject);
|
||||||
|
static bool AreWebAnimationsTimelinesEnabled(JSContext* aCx, JSObject* aObject);
|
||||||
|
static bool IsWebAnimationsGetAnimationsEnabled(JSContext* aCx, JSObject* aObject);
|
||||||
|
|
||||||
virtual mozilla::dom::DocumentTimeline* Timeline() override;
|
virtual mozilla::dom::DocumentTimeline* Timeline() override;
|
||||||
virtual void GetAnimations(
|
virtual void GetAnimations(
|
||||||
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) override;
|
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) override;
|
||||||
|
|
|
@ -23,6 +23,6 @@ interface Animatable {
|
||||||
[Func="nsDocument::IsElementAnimateEnabled", Throws]
|
[Func="nsDocument::IsElementAnimateEnabled", Throws]
|
||||||
Animation animate(object? keyframes,
|
Animation animate(object? keyframes,
|
||||||
optional UnrestrictedDoubleOrKeyframeAnimationOptions options);
|
optional UnrestrictedDoubleOrKeyframeAnimationOptions options);
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
[Func="nsDocument::IsWebAnimationsGetAnimationsEnabled"]
|
||||||
sequence<Animation> getAnimations(optional AnimationFilter filter);
|
sequence<Animation> getAnimations(optional AnimationFilter filter);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ interface Animation : EventTarget {
|
||||||
attribute DOMString id;
|
attribute DOMString id;
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled", Pure]
|
[Func="nsDocument::IsWebAnimationsEnabled", Pure]
|
||||||
attribute AnimationEffectReadOnly? effect;
|
attribute AnimationEffectReadOnly? effect;
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
[Func="nsDocument::AreWebAnimationsTimelinesEnabled"]
|
||||||
attribute AnimationTimeline? timeline;
|
attribute AnimationTimeline? timeline;
|
||||||
[BinaryName="startTimeAsDouble"]
|
[BinaryName="startTimeAsDouble"]
|
||||||
attribute double? startTime;
|
attribute double? startTime;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* liability, trademark and document use rules apply.
|
* liability, trademark and document use rules apply.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
[Func="nsDocument::AreWebAnimationsTimelinesEnabled"]
|
||||||
interface AnimationTimeline {
|
interface AnimationTimeline {
|
||||||
[BinaryName="currentTimeAsDouble"]
|
[BinaryName="currentTimeAsDouble"]
|
||||||
readonly attribute double? currentTime;
|
readonly attribute double? currentTime;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
// this interface.
|
// this interface.
|
||||||
// What we implement here is a minimal subset of the two definitions which we
|
// What we implement here is a minimal subset of the two definitions which we
|
||||||
// ship behind a pref until the specification issues have been resolved.
|
// ship behind a pref until the specification issues have been resolved.
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
[Func="nsDocument::IsWebAnimationsGetAnimationsEnabled"]
|
||||||
interface CSSPseudoElement {
|
interface CSSPseudoElement {
|
||||||
readonly attribute DOMString type;
|
readonly attribute DOMString type;
|
||||||
readonly attribute Element parentElement;
|
readonly attribute Element parentElement;
|
||||||
|
|
|
@ -312,9 +312,9 @@ partial interface Document {
|
||||||
|
|
||||||
// http://w3c.github.io/web-animations/#extensions-to-the-document-interface
|
// http://w3c.github.io/web-animations/#extensions-to-the-document-interface
|
||||||
partial interface Document {
|
partial interface Document {
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
[Func="nsDocument::AreWebAnimationsTimelinesEnabled"]
|
||||||
readonly attribute DocumentTimeline timeline;
|
readonly attribute DocumentTimeline timeline;
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
[Func="nsDocument::IsWebAnimationsGetAnimationsEnabled"]
|
||||||
sequence<Animation> getAnimations();
|
sequence<Animation> getAnimations();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ dictionary DocumentTimelineOptions {
|
||||||
DOMHighResTimeStamp originTime = 0;
|
DOMHighResTimeStamp originTime = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
[Func="nsDocument::IsWebAnimationsEnabled",
|
[Func="nsDocument::AreWebAnimationsTimelinesEnabled",
|
||||||
Constructor (optional DocumentTimelineOptions options)]
|
Constructor (optional DocumentTimelineOptions options)]
|
||||||
interface DocumentTimeline : AnimationTimeline {
|
interface DocumentTimeline : AnimationTimeline {
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1135764
|
||||||
}
|
}
|
||||||
addLoadEvent(function() {
|
addLoadEvent(function() {
|
||||||
SpecialPowers.pushPrefEnv(
|
SpecialPowers.pushPrefEnv(
|
||||||
{ "set": [[ "dom.animations-api.core.enabled", true]] },
|
{ "set": [[ "dom.animations-api.timelines.enabled", true]] },
|
||||||
function() {
|
function() {
|
||||||
var ifr = document.querySelector("iframe");
|
var ifr = document.querySelector("iframe");
|
||||||
ifr.onload = function() {
|
ifr.onload = function() {
|
||||||
|
|
|
@ -15,6 +15,6 @@ test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-ch
|
||||||
test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-changing-effect.html stacking-context-animation-ref.html
|
test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-changing-effect.html stacking-context-animation-ref.html
|
||||||
test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-changing-display-property.html stacking-context-animation-ref.html
|
test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-changing-display-property.html stacking-context-animation-ref.html
|
||||||
test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-losing-css-animation-in-delay.html stacking-context-animation-ref.html
|
test-pref(dom.animations-api.core.enabled,true) == stacking-context-transform-losing-css-animation-in-delay.html stacking-context-animation-ref.html
|
||||||
test-pref(dom.animations-api.core.enabled,true) == style-updates-on-iteration-composition-changed-from-accumulate-to-replace.html style-updates-for-iteration-composite-ref.html
|
test-pref(dom.animations-api.core.enabled,true) test-pref(dom.animations-api.compositing.enabled,true) == style-updates-on-iteration-composition-changed-from-accumulate-to-replace.html style-updates-for-iteration-composite-ref.html
|
||||||
test-pref(dom.animations-api.core.enabled,true) == style-updates-on-iteration-composition-changed-from-replace-to-accumulate.html style-updates-for-iteration-composite-ref.html
|
test-pref(dom.animations-api.core.enabled,true) test-pref(dom.animations-api.compositing.enabled,true) == style-updates-on-iteration-composition-changed-from-replace-to-accumulate.html style-updates-for-iteration-composite-ref.html
|
||||||
test-pref(dom.animations-api.core.enabled,true) == style-updates-on-current-iteration-changed.html style-updates-for-iteration-composite-ref.html
|
test-pref(dom.animations-api.core.enabled,true) test-pref(dom.animations-api.compositing.enabled,true) == style-updates-on-current-iteration-changed.html style-updates-for-iteration-composite-ref.html
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
|
prefs =
|
||||||
|
dom.animations-api.core.enabled=true
|
||||||
|
dom.animations-api.timelines.enabled=true
|
||||||
support-files =
|
support-files =
|
||||||
animation_utils.js
|
animation_utils.js
|
||||||
ccd-quirks.html
|
ccd-quirks.html
|
||||||
|
|
|
@ -2710,14 +2710,12 @@ pref("layout.idle_period.required_quiescent_frames", 2);
|
||||||
pref("layout.idle_period.time_limit", 1);
|
pref("layout.idle_period.time_limit", 1);
|
||||||
|
|
||||||
// Is support for the Web Animations API enabled?
|
// Is support for the Web Animations API enabled?
|
||||||
// Before enabling this by default, make sure also CSSPseudoElement interface
|
|
||||||
// has been spec'ed properly, or we should add a separate pref for
|
|
||||||
// CSSPseudoElement interface. See Bug 1174575 for further details.
|
|
||||||
#ifdef RELEASE_OR_BETA
|
|
||||||
pref("dom.animations-api.core.enabled", false);
|
|
||||||
#else
|
|
||||||
pref("dom.animations-api.core.enabled", true);
|
pref("dom.animations-api.core.enabled", true);
|
||||||
#endif
|
|
||||||
|
pref("dom.animations-api.timelines.enabled", false);
|
||||||
|
pref("dom.animations-api.implicit-keyframes.enabled", false);
|
||||||
|
pref("dom.animations-api.compositing.enabled", false);
|
||||||
|
pref("dom.animations-api.getAnimations.enabled", false);
|
||||||
|
|
||||||
// Is support for the Element.animate() function (a subset of the Web Animations
|
// Is support for the Element.animate() function (a subset of the Web Animations
|
||||||
// API) enabled?
|
// API) enabled?
|
||||||
|
|
Loading…
Reference in New Issue