Bug 1142478 followup. Fix bogus test, and don't get the value of an invalid CheckedInt. Then we can reopen the CLOSED TREE.

This commit is contained in:
Boris Zbarsky 2015-03-12 22:59:00 -04:00
parent eef6c8bda6
commit ab8690b300
2 changed files with 9 additions and 6 deletions

View File

@ -1023,7 +1023,7 @@ nsContentUtils::ParseHTMLInteger(const nsAString& aValue,
result |= eParseHTMLInteger_Error | eParseHTMLInteger_ErrorNoValue;
}
if (negate) {
if (value.isValid() && negate) {
value = -value;
// Checking the special case of -0.
if (value == 0) {
@ -1031,7 +1031,8 @@ nsContentUtils::ParseHTMLInteger(const nsAString& aValue,
}
}
if (leadingZeros > 1 || (leadingZeros == 1 && !(value == 0))) {
if (value.isValid() &&
(leadingZeros > 1 || (leadingZeros == 1 && !(value == 0)))) {
result |= eParseHTMLInteger_NonStandard;
}
@ -1040,7 +1041,7 @@ nsContentUtils::ParseHTMLInteger(const nsAString& aValue,
}
*aResult = (ParseHTMLIntegerResultFlags)result;
return value.value();
return value.isValid() ? value.value() : 0;
}
#define SKIP_WHITESPACE(iter, end_iter, end_res) \

View File

@ -44,11 +44,13 @@ is(td.getAttribute("colspan"), "100", "Colspan attribute didn't store the origin
// Note, if colspan is negative, it is set to 1, because of backwards compatibility.
// @see nsHTMLTableCellElement::ParseAttribute
td.setAttribute("colspan", "-100k");
is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
is(td.getAttribute("colspan"), "-100k", "Colspan attribute didn't store the original value");
td.setAttribute("colspan", " -100 ");
is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
is(td.getAttribute("colspan"), " -100 ", "Colspan attribute didn't store the original value");
is(td.colSpan, 1, "Colspan reflection should be correct for ' -100 '");
td.setAttribute("colspan", "-100");
is(td.getAttribute("colspan"), "1", "Colspan attribute didn't store the original value");
is(td.getAttribute("colspan"), "-100", "Colspan attribute didn't store the original value");
is(td.colSpan, 1, "Colspan reflection should be correct for '-100'");
td.setAttribute("colspan", "foobar");