mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1270310
- Part 3: Make string assignment in HTMLInputElement::GetValueInternal fallible. r=peterv
This makes the string assignment fallible and also adds checks for the return value from GetValueInternal and GetValue.
This commit is contained in:
parent
99b5f4dce2
commit
e69bdc29f2
@ -1527,7 +1527,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)) {
|
||||
@ -1544,8 +1547,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;
|
||||
|
||||
@ -1681,6 +1684,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)
|
||||
{
|
||||
@ -5763,9 +5775,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);
|
||||
|
@ -623,7 +623,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;
|
||||
|
Loading…
Reference in New Issue
Block a user