Bug 764851 - Fix animations of the width/height of an outer SVG element. r=jwatt

This commit is contained in:
Robert Longson 2012-06-16 16:47:40 +01:00
parent 6651c36d9d
commit 5ccc8c4019
5 changed files with 42 additions and 15 deletions

View File

@ -765,9 +765,16 @@ nsSMILAnimationController::GetTargetIdentifierForAnimation(
bool isCSS = false;
if (attributeType == eSMILTargetAttrType_auto) {
if (attributeNamespaceID == kNameSpaceID_None) {
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(attributeName));
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
// width/height are special as they may be attributes or for
// outer-<svg> elements, mapped into style.
if (attributeName == nsGkAtoms::width ||
attributeName == nsGkAtoms::height) {
isCSS = targetElem->GetNameSpaceID() != kNameSpaceID_SVG;
} else {
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(attributeName));
isCSS = nsSMILCSSProperty::IsPropertyAnimatable(prop);
}
}
} else {
isCSS = (attributeType == eSMILTargetAttrType_CSS);

View File

@ -224,6 +224,7 @@ nsSMILCSSProperty::IsPropertyAnimatable(nsCSSProperty aPropID)
case eCSSProperty_font_style:
case eCSSProperty_font_variant:
case eCSSProperty_font_weight:
case eCSSProperty_height:
case eCSSProperty_image_rendering:
case eCSSProperty_letter_spacing:
case eCSSProperty_lighting_color:
@ -252,6 +253,7 @@ nsSMILCSSProperty::IsPropertyAnimatable(nsCSSProperty aPropID)
case eCSSProperty_text_decoration_line:
case eCSSProperty_text_rendering:
case eCSSProperty_vector_effect:
case eCSSProperty_width:
case eCSSProperty_visibility:
case eCSSProperty_word_spacing:
return true;

View File

@ -2444,6 +2444,23 @@ nsISMILAttr*
nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName)
{
if (aNamespaceID == kNameSpaceID_None) {
// We check mapped-into-style attributes first so that animations
// targeting width/height on outer-<svg> don't appear to be ignored
// because we returned a nsISMILAttr for the corresponding
// SVGAnimatedLength.
// Mapped attributes:
if (IsAttributeMapped(aName)) {
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(aName));
// Check IsPropertyAnimatable to avoid attributes that...
// - map to explicitly unanimatable properties (e.g. 'direction')
// - map to unsupported attributes (e.g. 'glyph-orientation-horizontal')
if (nsSMILCSSProperty::IsPropertyAnimatable(prop)) {
return new nsSMILMappedAttribute(prop, this);
}
}
// Transforms:
if (GetTransformListAttrName() == aName) {
SVGAnimatedTransformList* transformList = GetAnimatedTransformList();
@ -2591,18 +2608,6 @@ nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName)
}
}
}
// Mapped attributes:
if (IsAttributeMapped(aName)) {
nsCSSProperty prop =
nsCSSProps::LookupProperty(nsDependentAtomString(aName));
// Check IsPropertyAnimatable to avoid attributes that...
// - map to explicitly unanimatable properties (e.g. 'direction')
// - map to unsupported attributes (e.g. 'glyph-orientation-horizontal')
if (nsSMILCSSProperty::IsPropertyAnimatable(prop)) {
return new nsSMILMappedAttribute(prop, this);
}
}
}
// Strings

View File

@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="setTimeAndSnapshot(2, false)" width="0%" height="0%" viewBox="0 0 100 100" preserveAspectRatio="none">
<animate attributeName="height"
from="0%" to="100%" begin="0s" dur="2s" fill="freeze"/>
<animate attributeName="width"
from="0%" to="100%" begin="0s" dur="2s" fill="freeze"/>
<script xlink:href="smil-util.js" type="text/javascript"/>
<rect width="100" height="100" fill="lime"/>
</svg>

After

Width:  |  Height:  |  Size: 547 B

View File

@ -78,6 +78,7 @@ fails == anim-fillcolor-1.svg anim-standard-ref.svg # bug 436296
== anim-height-done-1a.svg anim-standard-ref.svg
== anim-height-done-1b.svg anim-standard-ref.svg
== anim-height-done-2.svg lime.svg
== anim-height-interp-1.svg anim-height-interp-1-ref.svg
== anim-height-interp-2.svg anim-height-interp-2-ref.svg
== anim-height-interp-3.svg anim-height-interp-3-ref.svg