Bug 1315874 - Add check for attribute namespace ID when decided if it should animate as a CSS property or not; r=dholbert
This seems like an existing bug. If the content specifies
attributeType="yer:opacity", we should not try to animate it as a CSS property.
This patch adds a namespace check before we try to animate as a CSS property.
MozReview-Commit-ID: 1LpBa23ddqX
--- a/dom/smil/nsSMILCompositor.cpp
+++ b/dom/smil/nsSMILCompositor.cpp
@@ -119,23 +119,28 @@ nsSMILCompositor::ClearAnimationEffects(
if (!smilAttr) {
// Target attribute not found (or, out of memory)
return;
}
smilAttr->ClearAnimValue();
}
/*static*/ bool
-nsSMILCompositor::IsCSSPropertyAnimation(nsIAtom* aAttributeName,
+nsSMILCompositor::IsCSSPropertyAnimation(int32_t aAttributeNamespaceID,
+ nsIAtom* aAttributeName,
nsCSSPropertyID aPropID,
mozilla::dom::Element* aTargetElement)
{
MOZ_ASSERT(aAttributeName);
MOZ_ASSERT(aTargetElement);
+ if (aAttributeNamespaceID != kNameSpaceID_None) {
+ return false;
+ }
+
if (!nsSMILCSSProperty::IsPropertyAnimatable(aPropID)) {
return false;
}
// If we are animating the 'width' or 'height' of an outer SVG
// element we should animate it as a CSS property, but for other elements
// (e.g. <rect>) we should animate it as a length attribute.
// The easiest way to test for an outer SVG element, is to see if it is an
@@ -152,17 +157,18 @@ nsSMILCompositor::IsCSSPropertyAnimation
// --------------------------
UniquePtr<nsISMILAttr>
nsSMILCompositor::CreateSMILAttr()
{
nsCSSPropertyID propID =
nsCSSProps::LookupProperty(nsDependentAtomString(mKey.mAttributeName),
CSSEnabledState::eForAllContent);
- if (IsCSSPropertyAnimation(mKey.mAttributeName, propID, mKey.mElement)) {
+ if (IsCSSPropertyAnimation(mKey.mAttributeNamespaceID, mKey.mAttributeName,
+ propID, mKey.mElement)) {
return MakeUnique<nsSMILCSSProperty>(propID, mKey.mElement.get());
}
return mKey.mElement->GetAnimatedAttr(mKey.mAttributeNamespaceID,
mKey.mAttributeName);
}
uint32_t
--- a/dom/smil/nsSMILCompositor.h
+++ b/dom/smil/nsSMILCompositor.h
@@ -67,24 +67,25 @@ public:
// optimizations) when we hit ComposeAttribute.
void ToggleForceCompositing() { mForceCompositing = true; }
// Transfers |aOther|'s mCachedBaseValue to |this|
void StealCachedBaseValue(nsSMILCompositor* aOther) {
mCachedBaseValue = mozilla::Move(aOther->mCachedBaseValue);
}
- // Returns true if, given an attributeName and corresponding property ID,
- // an animation targetting |aTargetElement| will animate the corresponding CSS
- // property rather than an attribute.
+ // Returns true if, given an attributeName in a specified namespace and
+ // its corresponding property ID, an animation targetting |aTargetElement|
+ // will animate the corresponding CSS property rather than an attribute.
//
// (The property ID could be derived from |aAttributeName| but is passed as
// a separate argument here as an optimization since call sites of this
// method may require |aPropID| beyond the scope of this function.)
- static bool IsCSSPropertyAnimation(nsIAtom* aAttributeName,
+ static bool IsCSSPropertyAnimation(int32_t aAttributeNamespaceID,
+ nsIAtom* aAttributeName,
nsCSSPropertyID aPropID,
mozilla::dom::Element* aTargetElement);
private:
// Create a nsISMILAttr for my target, on the heap.
UniquePtr<nsISMILAttr> CreateSMILAttr();
// Finds the index of the first function that will affect our animation