Chromium Code Reviews| 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
|