Bug 1528644 - Internal value changes shouldn't change validity state. r=masayuki

Even less so on reframe, where it's just unsound to do so. I had to give a value
to eSetValue_Internal, since otherwise I cannot check for its presence. I can
further special-case the reframe case if you prefer.

Differential Revision: https://phabricator.services.mozilla.com/D20133
This commit is contained in:
Emilio Cobos Álvarez
2019-02-19 09:25:55 +00:00
parent b05ad17c18
commit 9506ad92d3
11 changed files with 70 additions and 33 deletions

View File

@@ -2604,8 +2604,10 @@ nsresult HTMLInputElement::SetValueInternal(const nsAString& aValue,
// If the caller won't dispatch "input" event via
// nsContentUtils::DispatchInputEvent(), we need to modify
// validationMessage value here.
if (aFlags & (nsTextEditorState::eSetValue_Internal |
nsTextEditorState::eSetValue_ByContent)) {
//
// FIXME(emilio): eSetValue_Internal is not supposed to change state,
// but maybe we could run this too?
if (aFlags & nsTextEditorState::eSetValue_ByContent) {
MaybeUpdateAllValidityStates();
}
} else {
@@ -2640,8 +2642,7 @@ nsresult HTMLInputElement::SetValueInternal(const nsAString& aValue,
}
}
if (mDoneCreating) {
OnValueChanged(/* aNotify = */ true,
/* aWasInteractiveUserChange = */ false);
OnValueChanged(/* aNotify = */ true, ValueChangeKind::Internal);
}
// else DoneCreatingElement calls us again once mDoneCreating is true
}
@@ -6753,8 +6754,10 @@ HTMLInputElement::InitializeKeyboardEventListeners() {
}
NS_IMETHODIMP_(void)
HTMLInputElement::OnValueChanged(bool aNotify, bool aWasInteractiveUserChange) {
mLastValueChangeWasInteractive = aWasInteractiveUserChange;
HTMLInputElement::OnValueChanged(bool aNotify, ValueChangeKind aKind) {
if (aKind != ValueChangeKind::Internal) {
mLastValueChangeWasInteractive = aKind == ValueChangeKind::UserInteraction;
}
UpdateAllValidityStates(aNotify);