diff --git a/content/base/src/nsHTMLValue.cpp b/content/base/src/nsHTMLValue.cpp
index 142aedb8ef1..64cf34d335a 100644
--- a/content/base/src/nsHTMLValue.cpp
+++ b/content/base/src/nsHTMLValue.cpp
@@ -430,10 +430,10 @@ nsHTMLValue::EnumValueToString(EnumTable* aTable,
* or proportional (n*)
*/
PRBool
-nsHTMLValue::ParseIntValue(const nsAString& aString,
- nsHTMLUnit aDefaultUnit,
- PRBool aCanBePercent,
- PRBool aCanBeProportional)
+nsHTMLValue::ParseSpecialIntValue(const nsAString& aString,
+ nsHTMLUnit aDefaultUnit,
+ PRBool aCanBePercent,
+ PRBool aCanBeProportional)
{
nsAutoString tmp(aString);
PRInt32 ec;
diff --git a/content/base/src/nsHTMLValue.h b/content/base/src/nsHTMLValue.h
index 7dfc1de5d60..3e1624a03e6 100644
--- a/content/base/src/nsHTMLValue.h
+++ b/content/base/src/nsHTMLValue.h
@@ -275,10 +275,22 @@ public:
PRBool EnumValueToString(EnumTable* aTable,
nsAString& aResult) const;
+ /**
+ * Parse a string value into an int or pixel HTMLValue.
+ *
+ * @param aString the string to parse
+ * @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
+ * @return whether the value could be parsed
+ */
+ PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit) {
+ return ParseIntWithBounds(aString, aDefaultUnit, PR_INT32_MIN, PR_INT32_MAX);
+ }
+
/**
* Parse a string value into an int or pixel HTMLValue with minimum
* value and maximum value (can optionally parse percent (n%) and
- * proportional (n%)
+ * proportional (n%). This method explicitly sets a lower bound of zero on
+ * the element, whether it be proportional or percent or raw integer.
*
* @param aString the string to parse
* @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
@@ -286,9 +298,9 @@ public:
* @param aCanBeProportional true if it can be a proportional value (*)
* @return whether the value could be parsed
*/
- PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit,
- PRBool aCanBePercent = PR_FALSE,
- PRBool aCanBeProportional = PR_FALSE);
+ PRBool ParseSpecialIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit,
+ PRBool aCanBePercent,
+ PRBool aCanBeProportional);
/**
* Parse a string value into an int or pixel HTMLValue with minimum
diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp
index e780d3e32f1..f93abafaa6c 100644
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -2998,7 +2998,7 @@ nsGenericHTMLElement::ParseImageAttribute(nsIAtom* aAttribute,
{
if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height)) {
- return aResult.ParseIntValue(aString, eHTMLUnit_Pixel, PR_TRUE);
+ return aResult.ParseSpecialIntValue(aString, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE);
}
else if ((aAttribute == nsHTMLAtoms::hspace) ||
(aAttribute == nsHTMLAtoms::vspace) ||
diff --git a/content/html/content/src/nsHTMLDivElement.cpp b/content/html/content/src/nsHTMLDivElement.cpp
index 9216595e535..88baa6d563c 100644
--- a/content/html/content/src/nsHTMLDivElement.cpp
+++ b/content/html/content/src/nsHTMLDivElement.cpp
@@ -183,7 +183,7 @@ nsHTMLDivElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::width) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLFrameElement.cpp b/content/html/content/src/nsHTMLFrameElement.cpp
index 8b8d3d7d2b7..3794ab3d0a0 100644
--- a/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/content/html/content/src/nsHTMLFrameElement.cpp
@@ -244,12 +244,12 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::marginwidth) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::marginheight) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLHRElement.cpp b/content/html/content/src/nsHTMLHRElement.cpp
index 8dc188f3440..29e3f371da3 100644
--- a/content/html/content/src/nsHTMLHRElement.cpp
+++ b/content/html/content/src/nsHTMLHRElement.cpp
@@ -173,7 +173,7 @@ nsHTMLHRElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::width) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLIFrameElement.cpp b/content/html/content/src/nsHTMLIFrameElement.cpp
index 53403a0a948..4b170ea3753 100644
--- a/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -373,22 +373,22 @@ nsHTMLIFrameElement::StringToAttribute(nsIAtom* aAttribute,
nsHTMLValue& aResult)
{
if (aAttribute == nsHTMLAtoms::marginwidth) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::marginheight) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::height) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp
index 9aba5f9836e..8ecbe99e381 100644
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -1855,12 +1855,12 @@ nsHTMLInputElement::StringToAttribute(nsIAtom* aAttribute,
return NS_CONTENT_ATTR_HAS_VALUE;
}
else if (aAttribute == nsHTMLAtoms::width) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::height) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLSharedElement.cpp b/content/html/content/src/nsHTMLSharedElement.cpp
index 38e1ec31a8f..00ef18d36d2 100644
--- a/content/html/content/src/nsHTMLSharedElement.cpp
+++ b/content/html/content/src/nsHTMLSharedElement.cpp
@@ -256,7 +256,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
}
} else if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height)) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLSharedLeafElement.cpp b/content/html/content/src/nsHTMLSharedLeafElement.cpp
index 38e1ec31a8f..00ef18d36d2 100644
--- a/content/html/content/src/nsHTMLSharedLeafElement.cpp
+++ b/content/html/content/src/nsHTMLSharedLeafElement.cpp
@@ -256,7 +256,7 @@ nsHTMLSharedLeafElement::StringToAttribute(nsIAtom* aAttribute,
}
} else if ((aAttribute == nsHTMLAtoms::width) ||
(aAttribute == nsHTMLAtoms::height)) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLTableCellElement.cpp b/content/html/content/src/nsHTMLTableCellElement.cpp
index 5337f6272d0..fff82a274c0 100644
--- a/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -360,14 +360,14 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* attributes that resolve to integers or percents */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLTableColElement.cpp b/content/html/content/src/nsHTMLTableColElement.cpp
index 466f46ee658..8f817685edd 100644
--- a/content/html/content/src/nsHTMLTableColElement.cpp
+++ b/content/html/content/src/nsHTMLTableColElement.cpp
@@ -194,7 +194,7 @@ nsHTMLTableColElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents or proportions */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_TRUE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp
index 4f66df76f24..99dd2117514 100644
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -971,7 +971,7 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
/* attributes that resolve to pixels, with min=0 */
if (aAttribute == nsHTMLAtoms::cellspacing ||
aAttribute == nsHTMLAtoms::cellpadding) {
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
@@ -998,14 +998,14 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* attributes that resolve to integers or percents */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents or proportions */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
// treat 0 width as auto
nsHTMLUnit unit = aResult.GetUnit();
if ((eHTMLUnit_Pixel == unit) && (0 == aResult.GetPixelValue())) {
diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp
index 933e814f2d8..97b9372764b 100644
--- a/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -535,14 +535,14 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* attributes that resolve to integers or percents */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/html/content/src/nsHTMLTableSectionElement.cpp b/content/html/content/src/nsHTMLTableSectionElement.cpp
index df4cfc8ca1d..58571674794 100644
--- a/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -299,7 +299,7 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::height) {
/* attributes that resolve to integers or percents */
- if (aResult.ParseIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE)) {
+ if (aResult.ParseSpecialIntValue(aValue, eHTMLUnit_Pixel, PR_TRUE, PR_FALSE)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}
diff --git a/content/shared/public/nsHTMLValue.h b/content/shared/public/nsHTMLValue.h
index 7dfc1de5d60..3e1624a03e6 100644
--- a/content/shared/public/nsHTMLValue.h
+++ b/content/shared/public/nsHTMLValue.h
@@ -275,10 +275,22 @@ public:
PRBool EnumValueToString(EnumTable* aTable,
nsAString& aResult) const;
+ /**
+ * Parse a string value into an int or pixel HTMLValue.
+ *
+ * @param aString the string to parse
+ * @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
+ * @return whether the value could be parsed
+ */
+ PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit) {
+ return ParseIntWithBounds(aString, aDefaultUnit, PR_INT32_MIN, PR_INT32_MAX);
+ }
+
/**
* Parse a string value into an int or pixel HTMLValue with minimum
* value and maximum value (can optionally parse percent (n%) and
- * proportional (n%)
+ * proportional (n%). This method explicitly sets a lower bound of zero on
+ * the element, whether it be proportional or percent or raw integer.
*
* @param aString the string to parse
* @param aDefaultUnit the unit to use (eHTMLUnit_Pixel or Integer)
@@ -286,9 +298,9 @@ public:
* @param aCanBeProportional true if it can be a proportional value (*)
* @return whether the value could be parsed
*/
- PRBool ParseIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit,
- PRBool aCanBePercent = PR_FALSE,
- PRBool aCanBeProportional = PR_FALSE);
+ PRBool ParseSpecialIntValue(const nsAString& aString, nsHTMLUnit aDefaultUnit,
+ PRBool aCanBePercent,
+ PRBool aCanBeProportional);
/**
* Parse a string value into an int or pixel HTMLValue with minimum
diff --git a/content/shared/src/nsHTMLValue.cpp b/content/shared/src/nsHTMLValue.cpp
index 142aedb8ef1..64cf34d335a 100644
--- a/content/shared/src/nsHTMLValue.cpp
+++ b/content/shared/src/nsHTMLValue.cpp
@@ -430,10 +430,10 @@ nsHTMLValue::EnumValueToString(EnumTable* aTable,
* or proportional (n*)
*/
PRBool
-nsHTMLValue::ParseIntValue(const nsAString& aString,
- nsHTMLUnit aDefaultUnit,
- PRBool aCanBePercent,
- PRBool aCanBeProportional)
+nsHTMLValue::ParseSpecialIntValue(const nsAString& aString,
+ nsHTMLUnit aDefaultUnit,
+ PRBool aCanBePercent,
+ PRBool aCanBeProportional)
{
nsAutoString tmp(aString);
PRInt32 ec;