Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 1752933002: [InputEvent] Fire 'beforeinput' during typing, pressing hot keys and IME composition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yosi's review Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/InputMethodController.cpp
diff --git a/third_party/WebKit/Source/core/editing/InputMethodController.cpp b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
index 7aeb0d1f45878ec10d499195a6e38f8e40180923..d6ace09dd986e0797011b1dc2899a3e5e01e448d 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -169,6 +169,12 @@ bool InputMethodController::confirmComposition(const String& text)
clear();
+ // According to spec 'beforeinput' should not be sent along with CompositionEnd, so
+ // dispatch after CompositionEnd if there is any update.
+ // https://w3c.github.io/uievents/#h-events-composition-event-input-events
+ if (dispatchBeforeInputInsertText(frame().document()->focusedElement(), text) != DispatchEventResult::NotCanceled)
+ return false;
+
insertTextForConfirmedComposition(text);
return true;
@@ -179,6 +185,10 @@ bool InputMethodController::confirmCompositionOrInsertText(const String& text, C
if (!hasComposition()) {
if (!text.length())
return false;
+
+ if (dispatchBeforeInputInsertText(frame().document()->focusedElement(), text) != DispatchEventResult::NotCanceled)
+ return false;
+
editor().insertText(text, 0);
return true;
}
@@ -275,8 +285,12 @@ void InputMethodController::setComposition(const String& text, const Vector<Comp
else
event = CompositionEvent::create(EventTypeNames::compositionend, frame().domWindow(), text);
}
- if (event.get())
+ if (event.get()) {
+ // TODO(chongz): Support canceling IME composition.
+ if (event->type() == EventTypeNames::compositionupdate)
+ dispatchBeforeInputCompositionUpdate(target, text);
target->dispatchEvent(event);
+ }
}
// If text is empty, then delete the old composition here. If text is non-empty, InsertTextCommand::input
yosin_UTC9 2016/03/16 01:46:51 We also dispatch "beforeInput" with "deleteCompose
chongz 2016/03/16 21:51:44 Acknowledged.
chongz 2016/04/13 00:34:28 Done. But I tried several keyboard layouts and Chi

Powered by Google App Engine
This is Rietveld 408576698