Bug 970802 - part 4: Make TextControlState dispatch "beforeinput" event if there is no TextEditor r=smaug

If `TextControlState` does not have `TextEditor` and its `SetValue()` is called
from `SetUserInput()`, `TextControlState` itself needs to dispatch `beforeinput`
event.

If the value is modified by `beforeinput` event listener, it's intended that
`preventDefault()` is called by the web apps.  However, the behavior in this
case is not mentioned by UI Events nor Input Events spec.  We should just file
a spec issue instead of emulating Chrome's behavior for now because it requires
more changes, but this case must be an edge case.
The spec issue is: https://github.com/w3c/input-events/issues/106

Differential Revision: https://phabricator.services.mozilla.com/D58126
This commit is contained in:
Masayuki Nakano
2020-01-08 09:24:33 +00:00
parent 5c4adfac5d
commit 5f240193da
10 changed files with 371 additions and 47 deletions

View File

@@ -2223,6 +2223,8 @@ void HTMLInputElement::SetUserInput(const nsAString& aValue,
nsIEditor* HTMLInputElement::GetEditor() { return GetTextEditorFromState(); }
bool HTMLInputElement::HasEditor() { return !!GetTextEditorWithoutCreation(); }
TextEditor* HTMLInputElement::GetTextEditorFromState() {
TextControlState* state = GetEditorState();
if (state) {