Bug 1067769 - Part 2: Support nullable target in KeyframeEffect(ReadOnly) constructor. r=birtles

We set a null target only from Web Animations API, so make sure
KeyframeEffectReadOnly::ConstructKeyframeEffect() can handle null target
properly.

MozReview-Commit-ID: D6PoV7PGFj3

--HG--
extra : rebase_source : 4ba2d616d6b2cdfe7985ced29e4454e818d076b8
This commit is contained in:
Boris Chiou 2016-04-28 23:22:42 +08:00
parent ce16585e39
commit ea72ffdf23
3 changed files with 13 additions and 22 deletions

View File

@ -97,7 +97,6 @@ KeyframeEffectReadOnly::KeyframeEffectReadOnly(
, mInEffectOnLastAnimationTimingUpdate(false)
{
MOZ_ASSERT(aTiming);
MOZ_ASSERT(aTarget, "null animation target is not yet supported");
}
JSObject*
@ -737,28 +736,22 @@ KeyframeEffectReadOnly::ConstructKeyframeEffect(
return nullptr;
}
if (aTarget.IsNull()) {
// We don't support null targets yet.
aRv.Throw(NS_ERROR_DOM_ANIM_NO_TARGET_ERR);
return nullptr;
}
const ElementOrCSSPseudoElement& target = aTarget.Value();
MOZ_ASSERT(target.IsElement() || target.IsCSSPseudoElement(),
"Uninitialized target");
RefPtr<Element> targetElement;
CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
if (target.IsElement()) {
targetElement = &target.GetAsElement();
} else {
targetElement = target.GetAsCSSPseudoElement().ParentElement();
pseudoType = target.GetAsCSSPseudoElement().GetType();
if (!aTarget.IsNull()) {
const ElementOrCSSPseudoElement& target = aTarget.Value();
MOZ_ASSERT(target.IsElement() || target.IsCSSPseudoElement(),
"Uninitialized target");
if (target.IsElement()) {
targetElement = &target.GetAsElement();
} else {
targetElement = target.GetAsCSSPseudoElement().ParentElement();
pseudoType = target.GetAsCSSPseudoElement().GetType();
}
}
RefPtr<KeyframeEffectType> effect =
new KeyframeEffectType(targetElement->OwnerDoc(), targetElement,
pseudoType, timingParams);
new KeyframeEffectType(doc, targetElement, pseudoType, timingParams);
effect->SetFrames(aGlobal.Context(), aFrames, aRv);
if (aRv.Failed()) {
return nullptr;

View File

@ -118,7 +118,6 @@ DOM4_MSG_DEF(BtAuthRejectedError, "Authentication rejected", NS_ERROR_DOM_BLUET
/* Web Animations errors */
DOM4_MSG_DEF(NotSupportedError, "Animation to or from an underlying value is not yet supported.", NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR)
DOM4_MSG_DEF(NotSupportedError, "Animation with no target is not yet supported.", NS_ERROR_DOM_ANIM_NO_TARGET_ERR)
DOM4_MSG_DEF(NotSupportedError, "Animation with no timeline is not yet supported.", NS_ERROR_DOM_ANIM_NO_TIMELINE_ERR)
DOM4_MSG_DEF(NotSupportedError, "Animation with no effect is not yet supported.", NS_ERROR_DOM_ANIM_NO_EFFECT_ERR)

View File

@ -953,9 +953,8 @@
/* ======================================================================= */
#define MODULE NS_ERROR_MODULE_DOM_ANIM
ERROR(NS_ERROR_DOM_ANIM_MISSING_PROPS_ERR, FAILURE(1)),
ERROR(NS_ERROR_DOM_ANIM_NO_TARGET_ERR, FAILURE(2)),
ERROR(NS_ERROR_DOM_ANIM_NO_TIMELINE_ERR, FAILURE(3)),
ERROR(NS_ERROR_DOM_ANIM_NO_EFFECT_ERR, FAILURE(4)),
ERROR(NS_ERROR_DOM_ANIM_NO_TIMELINE_ERR, FAILURE(2)),
ERROR(NS_ERROR_DOM_ANIM_NO_EFFECT_ERR, FAILURE(3)),
#undef MODULE
/* ======================================================================= */