From d3f830f49eb040774cb1f05a84523a6a80545b84 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Tue, 24 Nov 1998 02:39:36 +0000 Subject: [PATCH] fixed call to ToInteger() to respect the error code --- content/html/content/src/nsHTMLFontElement.cpp | 16 ++++++++++------ layout/html/content/src/nsHTMLFontElement.cpp | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/content/html/content/src/nsHTMLFontElement.cpp b/content/html/content/src/nsHTMLFontElement.cpp index 9dbe8b42c40..fe667511cba 100644 --- a/content/html/content/src/nsHTMLFontElement.cpp +++ b/content/html/content/src/nsHTMLFontElement.cpp @@ -142,12 +142,16 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, (aAttribute == nsHTMLAtoms::pointSize) || (aAttribute == nsHTMLAtoms::fontWeight)) { nsAutoString tmp(aValue); + //rickg: fixed flaw where ToInteger error code was not being checked. + // This caused wrong default value for font size. PRInt32 ec, v = tmp.ToInteger(&ec); - tmp.CompressWhitespace(PR_TRUE, PR_FALSE); - PRUnichar ch = tmp.First(); - aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ? - eHTMLUnit_Integer : eHTMLUnit_Enumerated); - return NS_CONTENT_ATTR_HAS_VALUE; + if(NS_SUCCEEDED(ec)){ + tmp.CompressWhitespace(PR_TRUE, PR_FALSE); + PRUnichar ch = tmp.First(); + aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ? + eHTMLUnit_Integer : eHTMLUnit_Enumerated); + return NS_CONTENT_ATTR_HAS_VALUE; + } } if (aAttribute == nsHTMLAtoms::color) { nsGenericHTMLElement::ParseColor(aValue, aResult); @@ -170,7 +174,7 @@ nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aValue.GetUnit() == eHTMLUnit_Integer) { - PRInt32 value = aValue.GetIntValue(); + PRInt32 value = aValue.GetIntValue(); if (value >= 0) { aResult.Append('+'); } diff --git a/layout/html/content/src/nsHTMLFontElement.cpp b/layout/html/content/src/nsHTMLFontElement.cpp index 9dbe8b42c40..fe667511cba 100644 --- a/layout/html/content/src/nsHTMLFontElement.cpp +++ b/layout/html/content/src/nsHTMLFontElement.cpp @@ -142,12 +142,16 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, (aAttribute == nsHTMLAtoms::pointSize) || (aAttribute == nsHTMLAtoms::fontWeight)) { nsAutoString tmp(aValue); + //rickg: fixed flaw where ToInteger error code was not being checked. + // This caused wrong default value for font size. PRInt32 ec, v = tmp.ToInteger(&ec); - tmp.CompressWhitespace(PR_TRUE, PR_FALSE); - PRUnichar ch = tmp.First(); - aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ? - eHTMLUnit_Integer : eHTMLUnit_Enumerated); - return NS_CONTENT_ATTR_HAS_VALUE; + if(NS_SUCCEEDED(ec)){ + tmp.CompressWhitespace(PR_TRUE, PR_FALSE); + PRUnichar ch = tmp.First(); + aResult.SetIntValue(v, ((ch == '+') || (ch == '-')) ? + eHTMLUnit_Integer : eHTMLUnit_Enumerated); + return NS_CONTENT_ATTR_HAS_VALUE; + } } if (aAttribute == nsHTMLAtoms::color) { nsGenericHTMLElement::ParseColor(aValue, aResult); @@ -170,7 +174,7 @@ nsHTMLFontElement::AttributeToString(nsIAtom* aAttribute, return NS_CONTENT_ATTR_HAS_VALUE; } else if (aValue.GetUnit() == eHTMLUnit_Integer) { - PRInt32 value = aValue.GetIntValue(); + PRInt32 value = aValue.GetIntValue(); if (value >= 0) { aResult.Append('+'); }