bug 97027 restrict the use of multilength parsing to cols and colgroups

r=karnaze sr= attinasi
This commit is contained in:
bernd.mielke%snafu.de 2001-10-22 04:05:34 +00:00
parent 2c5d465413
commit bd339535d6
4 changed files with 15 additions and 19 deletions

View File

@ -2815,13 +2815,7 @@ nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsAReadableString&
{
nsAutoString tmp(aString);
tmp.CompressWhitespace(PR_TRUE, PR_TRUE);
PRInt32 ec, val = tmp.ToInteger(&ec);
if ((NS_ERROR_ILLEGAL_VALUE == ec) && (tmp.Length() > 0)) {
// NOTE: we need to allow non-integer values for the '*' case,
// so we allow for the ILLEGAL_VALUE error and set val to 0
val = 0;
ec = NS_OK;
}
PRInt32 ec, val = tmp.ToInteger(&ec);
if (NS_OK == ec) {
if (val < 0) val = 0;
if (tmp.Length() && tmp.RFindChar('%') >= 0) {/* XXX not 100% compatible with ebina's code */
@ -2835,16 +2829,18 @@ nsGenericHTMLElement::ParseValueOrPercentOrProportional(const nsAReadableString&
val = 1;
}
aResult.SetIntValue(val, eHTMLUnit_Proportional); // proportional values are integers
} else {
if (eHTMLUnit_Pixel == aValueUnit) {
} else if (eHTMLUnit_Pixel == aValueUnit) {
aResult.SetPixelValue(val);
}
else {
aResult.SetIntValue(val, aValueUnit);
}
}
else {
aResult.SetIntValue(val, aValueUnit);
}
return PR_TRUE;
}
} else if (tmp.Length()==1 && tmp.Last()== '*') {
aResult.SetIntValue(1, eHTMLUnit_Proportional);
return PR_TRUE;
}
return PR_FALSE;
}

View File

@ -345,9 +345,9 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents or proportions */
/* attributes that resolve to integers or percents */
if (ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) {
if (ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}

View File

@ -996,7 +996,7 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute,
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents or proportions */
if (ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) {
if (ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) {
// treat 0 width as auto
nsHTMLUnit unit = aResult.GetUnit();
if ((eHTMLUnit_Pixel == unit) && (0 == aResult.GetPixelValue())) {

View File

@ -537,9 +537,9 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute,
}
}
else if (aAttribute == nsHTMLAtoms::width) {
/* attributes that resolve to integers or percents or proportions */
/* attributes that resolve to integers or percents */
if (ParseValueOrPercentOrProportional(aValue, aResult, eHTMLUnit_Pixel)) {
if (ParseValueOrPercent(aValue, aResult, eHTMLUnit_Pixel)) {
return NS_CONTENT_ATTR_HAS_VALUE;
}
}