зеркало из https://github.com/mozilla/pjs.git
Allow raw ParseIntValue to work with negative values (bug 198677), r=smontagu@netscape.com, sr=jst@netscape.com
This commit is contained in:
Родитель
75f7bbab47
Коммит
73fbdcf647
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) ||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче