Bug 868874 - Remove Decimal::toString(char*, size_t). r=jwatt,dom-core,sefeng

Differential Revision: https://phabricator.services.mozilla.com/D216041
This commit is contained in:
Vincent Hilla
2024-10-22 13:21:56 +00:00
parent 257d5eb9f2
commit e68a44cb57
4 changed files with 4 additions and 28 deletions

View File

@@ -4855,10 +4855,7 @@ void HTMLInputElement::SanitizeValue(nsAString& aValue,
// For the <input type=number> value getter, we return the unlocalized
// value if it doesn't parse as StringToDecimal, for compat with other
// browsers.
char buf[32];
DebugOnly<bool> ok = result.mResult.toString(buf, ArrayLength(buf));
aValue.AssignASCII(buf);
MOZ_ASSERT(ok, "buf not big enough");
aValue.AssignASCII(result.mResult.toString().c_str());
break;
}
case SanitizationKind::ForDisplay:
@@ -4939,10 +4936,7 @@ void HTMLInputElement::SanitizeValue(nsAString& aValue,
}
if (needSanitization) {
char buf[32];
DebugOnly<bool> ok = value.toString(buf, ArrayLength(buf));
aValue.AssignASCII(buf);
MOZ_ASSERT(ok, "buf not big enough");
aValue.AssignASCII(value.toString().c_str());
}
} break;
case FormControlType::InputDate: {

View File

@@ -79,13 +79,9 @@ bool NumericInputTypeBase::ConvertNumberToString(
MOZ_ASSERT(aValue.isFinite(), "aValue must be a valid non-Infinite number.");
aResultString.Truncate();
aResultString.AssignASCII(aValue.toString().c_str());
char buf[32];
bool ok = aValue.toString(buf, ArrayLength(buf));
aResultString.AssignASCII(buf);
MOZ_ASSERT(ok, "buf not big enough");
return ok;
return true;
}
/* input type=number */

View File

@@ -974,19 +974,6 @@ String Decimal::toString() const
return builder.toString();
}
bool Decimal::toString(char* strBuf, size_t bufLength) const
{
ASSERT(bufLength > 0);
String str = toString();
size_t length = str.copy(strBuf, bufLength);
if (length < bufLength) {
strBuf[length] = '\0';
return true;
}
strBuf[bufLength - 1] = '\0';
return false;
}
Decimal Decimal::zero(Sign sign)
{
return Decimal(EncodedData(sign, EncodedData::ClassZero));

View File

@@ -222,7 +222,6 @@ public:
MFBT_API double toDouble() const;
// Note: toString method supports infinity and nan but fromString not.
MFBT_API std::string toString() const;
MFBT_API bool toString(char* strBuf, size_t bufLength) const;
static MFBT_API Decimal fromDouble(double);
// fromString supports following syntax EBNF: