зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1270310
- Part 3: Make string assignment in HTMLInputElement::GetValueInternal fallible. r=smaug
This makes the string assignment fallible and also adds checks for the return value from GetValueInternal and GetValue.
This commit is contained in:
Родитель
9f0aed4b73
Коммит
2b917eceb6
|
@ -2015,7 +2015,10 @@ HTMLInputElement::SetWidth(uint32_t aWidth)
|
|||
NS_IMETHODIMP
|
||||
HTMLInputElement::GetValue(nsAString& aValue)
|
||||
{
|
||||
GetValueInternal(aValue);
|
||||
nsresult rv = GetValueInternal(aValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Don't return non-sanitized value for types that are experimental on mobile.
|
||||
if (IsExperimentalMobileType(mType)) {
|
||||
|
@ -2032,8 +2035,8 @@ HTMLInputElement::GetValueInternal(nsAString& aValue) const
|
|||
case VALUE_MODE_VALUE:
|
||||
if (IsSingleLineTextControl(false)) {
|
||||
mInputData.mState->GetValue(aValue, true);
|
||||
} else {
|
||||
aValue.Assign(mInputData.mValue);
|
||||
} else if (!aValue.Assign(mInputData.mValue, fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
|
@ -2169,6 +2172,15 @@ HTMLInputElement::GetValueAsDecimal() const
|
|||
: decimalValue;
|
||||
}
|
||||
|
||||
void
|
||||
HTMLInputElement::GetValue(nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
nsresult rv = GetValue(aValue);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLInputElement::SetValue(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
|
@ -6314,9 +6326,12 @@ HTMLInputElement::SaveState()
|
|||
|
||||
inputState = new HTMLInputElementState();
|
||||
nsAutoString value;
|
||||
GetValue(value);
|
||||
nsresult rv =
|
||||
nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
nsresult rv = GetValue(value);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = nsLinebreakConverter::ConvertStringLineBreaks(
|
||||
value,
|
||||
nsLinebreakConverter::eLinebreakPlatform,
|
||||
nsLinebreakConverter::eLinebreakContent);
|
||||
|
|
|
@ -632,7 +632,7 @@ public:
|
|||
SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
|
||||
}
|
||||
|
||||
// XPCOM GetValue() is OK
|
||||
void GetValue(nsAString& aValue, ErrorResult& aRv);
|
||||
void SetValue(const nsAString& aValue, ErrorResult& aRv);
|
||||
|
||||
Nullable<Date> GetValueAsDate(ErrorResult& aRv);
|
||||
|
|
|
@ -86,7 +86,7 @@ interface HTMLInputElement : HTMLElement {
|
|||
attribute DOMString type;
|
||||
[Pure, SetterThrows]
|
||||
attribute DOMString defaultValue;
|
||||
[Pure, TreatNullAs=EmptyString, SetterThrows]
|
||||
[Pure, TreatNullAs=EmptyString, Throws]
|
||||
attribute DOMString value;
|
||||
[Throws, Pref="dom.experimental_forms"]
|
||||
attribute Date? valueAsDate;
|
||||
|
|
Загрузка…
Ссылка в новой задаче