зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343037 part 5. Make <textarea> behave more like <input type=text> in terms of reset behavior. r=ehsan
In particular this ensures that our ValueChanged() is correctly set to false when we call SetValue() on our editor state with our default value. We will be relying on this very shortly. MozReview-Commit-ID: AIIIHwfQPQE
This commit is contained in:
Родитель
8d88c68a9d
Коммит
56f5644356
|
@ -324,11 +324,14 @@ nsresult
|
|||
HTMLTextAreaElement::SetValueInternal(const nsAString& aValue,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// Need to set the value changed flag here, so that
|
||||
// nsTextControlFrame::UpdateValueDisplay retrieves the correct value
|
||||
// if needed.
|
||||
SetValueChanged(true);
|
||||
aFlags |= nsTextEditorState::eSetValue_Notify;
|
||||
// Need to set the value changed flag here if our value has in fact changed
|
||||
// (i.e. if eSetValue_Notify is in aFlags), so that
|
||||
// nsTextControlFrame::UpdateValueDisplay retrieves the correct value if
|
||||
// needed.
|
||||
if (aFlags & nsTextEditorState::eSetValue_Notify) {
|
||||
SetValueChanged(true);
|
||||
}
|
||||
|
||||
if (!mState.SetValue(aValue, aFlags)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -350,7 +353,8 @@ HTMLTextAreaElement::SetValue(const nsAString& aValue)
|
|||
GetValueInternal(currentValue, true);
|
||||
|
||||
nsresult rv =
|
||||
SetValueInternal(aValue, nsTextEditorState::eSetValue_ByContent);
|
||||
SetValueInternal(aValue, nsTextEditorState::eSetValue_ByContent |
|
||||
nsTextEditorState::eSetValue_Notify);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mFocusedValue.Equals(currentValue)) {
|
||||
|
@ -363,7 +367,9 @@ HTMLTextAreaElement::SetValue(const nsAString& aValue)
|
|||
NS_IMETHODIMP
|
||||
HTMLTextAreaElement::SetUserInput(const nsAString& aValue)
|
||||
{
|
||||
return SetValueInternal(aValue, nsTextEditorState::eSetValue_BySetUserInput);
|
||||
return SetValueInternal(aValue,
|
||||
nsTextEditorState::eSetValue_BySetUserInput |
|
||||
nsTextEditorState::eSetValue_Notify);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1043,10 +1049,11 @@ HTMLTextAreaElement::Reset()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoString resetVal;
|
||||
GetDefaultValue(resetVal);
|
||||
rv = SetValue(resetVal);
|
||||
SetValueChanged(false);
|
||||
|
||||
rv = SetValueInternal(resetVal, nsTextEditorState::eSetValue_Internal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
SetValueChanged(false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче