Bug 1842027 - Make <input type=number> localization faster. r=masayuki
Using the fast unlocalized parser first exposes a subtle difference between the ICU parser (which uses `double`), and Decimal::fromString (which has a larger range). Check for iee754 finiteness explicitly, matching our previous behavior, and the expectation of this subtest: https://searchfox.org/mozilla-central/rev/a3852ea8db25c759bc8b108aeec870d66c95452c/testing/web-platform/tests/html/semantics/forms/the-input-element/number.html#33 That check matches this Blink code: https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:third_party/blink/renderer/core/html/parser/html_parser_idioms.cc;l=103;drc=0d1bbe8de137aaae7c956a33249eb840a0191627 This patch avoids a bunch of number->string->number conversions in the common case where the value comes from the value attribute and thus parses fine without localization shenanigans. Differential Revision: https://phabricator.services.mozilla.com/D183254
This commit is contained in:
@@ -2532,18 +2532,16 @@ void TextControlState::GetValue(nsAString& aValue, bool aIgnoreWrap) const {
|
||||
} else {
|
||||
mBoundFrame->ClearCachedValue();
|
||||
}
|
||||
} else if (!mTextCtrlElement->ValueChanged() || mValue.IsVoid()) {
|
||||
// Use nsString to avoid copying string buffer at setting aValue.
|
||||
nsString value;
|
||||
mTextCtrlElement->GetDefaultValueFromContent(value);
|
||||
// TODO: We should make default value not include \r.
|
||||
nsContentUtils::PlatformToDOMLineBreaks(value);
|
||||
aValue = std::move(value);
|
||||
} else {
|
||||
if (!mTextCtrlElement->ValueChanged() || mValue.IsVoid()) {
|
||||
// Use nsString to avoid copying string buffer at setting aValue.
|
||||
nsString value;
|
||||
mTextCtrlElement->GetDefaultValueFromContent(value);
|
||||
// TODO: We should make default value not include \r.
|
||||
nsContentUtils::PlatformToDOMLineBreaks(value);
|
||||
aValue = value;
|
||||
} else {
|
||||
aValue = mValue;
|
||||
MOZ_ASSERT(aValue.FindChar(u'\r') == -1);
|
||||
}
|
||||
aValue = mValue;
|
||||
MOZ_ASSERT(aValue.FindChar(u'\r') == -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user