Bug 537067. SMIL animation of <length> attributes does not work. r=roc

This commit is contained in:
Jonathan Watt 2010-01-15 14:21:06 +00:00
parent a26988ca29
commit 7f0675661a
8 changed files with 74 additions and 1 deletions

View File

@ -155,7 +155,7 @@ public:
virtual void DidChangePreserveAspectRatio(PRBool aDoSetAttr);
virtual void DidChangeString(PRUint8 aAttrEnum) {}
void DidAnimateLength(PRUint8 aAttrEnum);
virtual void DidAnimateLength(PRUint8 aAttrEnum);
virtual void DidAnimateNumber(PRUint8 aAttrEnum);
void GetAnimatedLengthValues(float *aFirst, ...);

View File

@ -37,6 +37,7 @@
#include "nsGkAtoms.h"
#include "nsCOMPtr.h"
#include "nsSVGFilterElement.h"
#include "nsSVGEffects.h"
nsSVGElement::LengthInfo nsSVGFilterElement::sLengthInfo[4] =
{
@ -236,3 +237,13 @@ nsSVGFilterElement::GetStringInfo()
return StringAttributesInfo(mStringAttributes, sStringInfo,
NS_ARRAY_LENGTH(sStringInfo));
}
void
nsSVGFilterElement::DidAnimateLength(PRUint8 aAttrEnum)
{
// nsSVGFilterFrame does not implement a useful AttributeChanged
nsIFrame* frame = GetPrimaryFrame();
if (frame) {
nsSVGEffects::InvalidateRenderingObservers(frame);
}
}

View File

@ -87,6 +87,8 @@ protected:
virtual EnumAttributesInfo GetEnumInfo();
virtual StringAttributesInfo GetStringInfo();
virtual void DidAnimateLength(PRUint8 aAttrEnum);
enum { X, Y, WIDTH, HEIGHT };
nsSVGLength2 mLengthAttributes[4];
static LengthInfo sLengthInfo[4];

View File

@ -302,6 +302,16 @@ nsSVGFE::GetLengthInfo()
NS_ARRAY_LENGTH(sLengthInfo));
}
void
nsSVGFE::DidAnimateLength(PRUint8 aAttrEnum)
{
// nsSVGLeafFrame doesn't implement AttributeChanged.
nsIFrame* frame = GetPrimaryFrame();
if (frame) {
nsSVGEffects::InvalidateRenderingObservers(frame);
}
}
void
nsSVGFE::DidAnimateNumber(PRUint8 aAttrEnum)
{

View File

@ -217,6 +217,7 @@ protected:
// nsSVGElement specializations:
virtual LengthAttributesInfo GetLengthInfo();
virtual void DidAnimateLength(PRUint8 aAttrEnum);
virtual void DidAnimateNumber(PRUint8 aAttrEnum);
// nsIDOMSVGFitlerPrimitiveStandardAttributes values

View File

@ -0,0 +1,23 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="setTimeAndSnapshot(1, true)">
<title>Test animation of the "width" and "height" attributes of a filter primitive element</title>
<script xlink:href="smil-util.js" type="text/javascript"/>
<filter id="flood_filter" x="0%" y="0%" width="100%" height="100%">
<feFlood width="0%" height="0%" flood-color="lime">
<animate attributeName="width"
calcMode="linear"
begin="0s" dur="2s"
from="0%" to="200%"
fill="freeze"/>
<animate attributeName="height"
calcMode="linear"
begin="0s" dur="1s"
from="0%" to="100%"
fill="freeze"/>
</feFlood>
</filter>
<rect width="100%" height="100%" fill="red"/>
<rect width="100%" height="100%" fill="red" filter="url(#flood_filter)"/>
</svg>

After

Width:  |  Height:  |  Size: 946 B

View File

@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
class="reftest-wait"
onload="setTimeAndSnapshot(1, true)">
<title>Test animation of the "width" and "height" attributes of the "filter" element</title>
<script xlink:href="smil-util.js" type="text/javascript"/>
<filter id="flood_filter" x="0%" y="0%" width="0%" height="0%">
<animate attributeName="width"
calcMode="linear"
begin="0s" dur="2s"
from="0%" to="200%"
fill="freeze"/>
<animate attributeName="height"
calcMode="linear"
begin="0s" dur="1s"
from="0%" to="100%"
fill="freeze"/>
<feFlood width="100%" height="100%" flood-color="lime"/>
</filter>
<rect width="100%" height="100%" fill="red"/>
<rect width="100%" height="100%" fill="red" filter="url(#flood_filter)"/>
</svg>

After

Width:  |  Height:  |  Size: 906 B

View File

@ -72,6 +72,10 @@ fails == anim-fillopacity-1xml.svg anim-standard-ref.svg # bug 534028
== anim-height-interp-5.svg anim-height-interp-5-ref.svg
== anim-height-interp-6.svg anim-height-interp-6-ref.svg
# animate some <length> attributes:
== anim-filter-primitive-size-01.svg lime.svg
== anim-filter-size-01.svg lime.svg
# animate some <number> attributes:
== anim-feOffset-01.svg lime.svg
== anim-offset-01.svg lime.svg