Bug 1606043 - Make TextControlState::SetValueWithoutTextEditor() notify the text control element of value changed before dispatching eEditorInput event r=smaug

I made `nsContentUtils::DispatchInputEvent()` update validity of event target
before dispatching `eEditorInput` event in bug 1584963.  However, this is not
enough because it updates validity only when the type of `<input>` element is
`mail`, but it's required for other types, for example, `<input required>`.

This patch reverts the hack added in bug 1584963, instead, makes
`TextControlState::SetValueWithoutTextEditor()` notifies `TextControlElement`
of value change before dispatching `eEditorInput` event because it may have made
damage to the performance if `nsContentUtils::DispatchInputEvent()` updated
**all** validity state of the event target.

Differential Revision: https://phabricator.services.mozilla.com/D60828
This commit is contained in:
Masayuki Nakano
2020-01-23 17:50:37 +00:00
parent 7c04a044b6
commit 040fac2942
3 changed files with 77 additions and 13 deletions

View File

@@ -3036,6 +3036,12 @@ bool TextControlState::SetValueWithoutTextEditor(
// event listener?
if (aHandlingSetValue.GetSetValueFlags() & eSetValue_BySetUserInput) {
MOZ_ASSERT(aHandlingSetValue.GetTextControlElement());
// Update validity state before dispatching "input" event for its
// listeners like `EditorBase::NotifyEditorObservers()`.
aHandlingSetValue.GetTextControlElement()->OnValueChanged(
true, ValueChangeKind::UserInteraction);
MOZ_ASSERT(!aHandlingSetValue.GetSettingValue().IsVoid());
DebugOnly<nsresult> rvIgnored = nsContentUtils::DispatchInputEvent(
MOZ_KnownLive(aHandlingSetValue.GetTextControlElement()),