From a25e40842a4e003ab88a7ad585338ce4e2db76eb Mon Sep 17 00:00:00 2001 From: "longsonr%gmail.com" Date: Mon, 19 Feb 2007 12:57:16 +0000 Subject: [PATCH] Bug 356901 - offset attribute not parsed correctly. r=tor,sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@220542 18797224-902f-48f8-a5cc-f745e15eee43 --- .../svg/content/src/nsSVGStopElement.cpp | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mozilla/content/svg/content/src/nsSVGStopElement.cpp b/mozilla/content/svg/content/src/nsSVGStopElement.cpp index 744b0306f1a..d776aeaa593 100644 --- a/mozilla/content/svg/content/src/nsSVGStopElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGStopElement.cpp @@ -41,6 +41,7 @@ #include "nsSVGAnimatedNumberList.h" #include "nsSVGNumber2.h" #include "nsGenericHTMLElement.h" +#include "prdtoa.h" typedef nsSVGStylableElement nsSVGStopElementBase; @@ -135,32 +136,28 @@ nsSVGStopElement::ParseAttribute(PRInt32 aNamespaceID, const nsAString& aValue, nsAttrValue& aResult) { - if (nsSVGElement::ParseAttribute(aNamespaceID, aAttribute, aValue, aResult)) { - return PR_TRUE; - } - if (aNamespaceID == kNameSpaceID_None) { - if (aAttribute == nsGkAtoms::offset) { - char percentSymbol, remainder; - float offset; - char *str; - str = ToNewCString(aValue); - int num = sscanf(str, "%f %c %c", &offset, &percentSymbol, &remainder); - if (num == 2 && percentSymbol == '%') { + if (aAttribute == nsGkAtoms::offset) { + NS_ConvertUTF16toUTF8 value(aValue); + const char *str = value.get(); + + char *rest; + float offset = NS_STATIC_CAST(float, PR_strtod(str, &rest)); + if (str != rest) { + if (*rest == '%') { offset /= 100; - } else if (num != 1) { - mOffset.SetBaseValue(0, this, PR_FALSE); - return PR_FALSE; + ++rest; + } + if (*rest == '\0') { + mOffset.SetBaseValue(offset, this, PR_FALSE); + aResult.SetTo(aValue); + return PR_TRUE; } - - mOffset.SetBaseValue(offset, this, PR_FALSE); - aResult.SetTo(aValue); - - nsMemory::Free(str); - return PR_TRUE; } } - return PR_FALSE; + } + return nsSVGElement::ParseAttribute(aNamespaceID, aAttribute, + aValue, aResult); } //----------------------------------------------------------------------