diff --git a/content/svg/content/src/nsSVGPreserveAspectRatio.cpp b/content/svg/content/src/nsSVGPreserveAspectRatio.cpp index 8beedd77b57..5e60b36720d 100644 --- a/content/svg/content/src/nsSVGPreserveAspectRatio.cpp +++ b/content/svg/content/src/nsSVGPreserveAspectRatio.cpp @@ -202,6 +202,7 @@ nsSVGPreserveAspectRatio::SetBaseValueString(const nsAString &aValueAsString, } mAnimVal = mBaseVal = val; + aSVGElement->DidChangePreserveAspectRatio(aDoSetAttr); return NS_OK; } diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index 3ad5fddd621..ebbedf7ae42 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -1292,7 +1292,7 @@ nsSVGSVGElement::GetViewboxToViewportTransform(nsIDOMSVGMatrix **_retval) } nsSVGViewBoxRect viewbox; - if (HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox)) { + if (mViewBox.IsValid()) { viewbox = mViewBox.GetAnimValue(); } else { viewbox.x = viewbox.y = 0.0f; @@ -1461,7 +1461,7 @@ nsSVGSVGElement::GetLength(PRUint8 aCtxType) { float h, w; - if (HasAttr(kNameSpaceID_None, nsGkAtoms::viewBox)) { + if (mViewBox.IsValid()) { const nsSVGViewBoxRect& viewbox = mViewBox.GetAnimValue(); w = viewbox.width; h = viewbox.height; diff --git a/content/svg/content/src/nsSVGViewBox.cpp b/content/svg/content/src/nsSVGViewBox.cpp index d14afacca13..cd07b4b53d2 100644 --- a/content/svg/content/src/nsSVGViewBox.cpp +++ b/content/svg/content/src/nsSVGViewBox.cpp @@ -20,7 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Jonathan Watt (original author) + * Craig Topper (original author) * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -78,6 +78,7 @@ nsSVGViewBox::Init() { mBaseVal = nsSVGViewBoxRect(); mAnimVal = nsnull; + mHasBaseVal = PR_FALSE; } const nsSVGViewBoxRect& @@ -94,10 +95,8 @@ nsSVGViewBox::SetBaseValue(float aX, float aY, float aWidth, float aHeight, nsSVGElement *aSVGElement, PRBool aDoSetAttr) { mAnimVal = nsnull; - mBaseVal.x = aX; - mBaseVal.y = aY; - mBaseVal.width = aWidth; - mBaseVal.height = aHeight; + mBaseVal = nsSVGViewBoxRect(aX, aY, aWidth, aHeight); + mHasBaseVal = PR_TRUE; aSVGElement->DidChangeViewBox(aDoSetAttr); } @@ -128,11 +127,7 @@ nsSVGViewBox::SetBaseValueString(const nsAString& aValue, // there was a parse error. rv = NS_ERROR_FAILURE; } else { - mAnimVal = nsnull; - mBaseVal.x = vals[0]; - mBaseVal.y = vals[1]; - mBaseVal.width = vals[2]; - mBaseVal.height = vals[3]; + SetBaseValue(vals[0], vals[1], vals[2], vals[3], aSVGElement, aDoSetAttr); } nsMemory::Free(str); diff --git a/content/svg/content/src/nsSVGViewBox.h b/content/svg/content/src/nsSVGViewBox.h index eb1a93489fb..c37025a1a67 100644 --- a/content/svg/content/src/nsSVGViewBox.h +++ b/content/svg/content/src/nsSVGViewBox.h @@ -20,7 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Jonathan Watt (original author) + * Craig Topper (original author) * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -61,6 +61,10 @@ public: void Init(); + // Used by element to tell if viewbox is defined + PRBool IsValid() const + { return (mHasBaseVal || mAnimVal); } + const nsSVGViewBoxRect& GetBaseValue() const { return mBaseVal; } void SetBaseValue(float aX, float aY, float aWidth, float aHeight, @@ -80,6 +84,7 @@ private: nsSVGViewBoxRect mBaseVal; nsAutoPtr mAnimVal; + PRPackedBool mHasBaseVal; struct DOMBaseVal : public nsIDOMSVGRect {