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..59ef222a21947ce1e9f86bbfdce6aa95e0dc1228 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
| @@ -34,6 +34,7 @@ |
| #include "core/editing/commands/TypingCommand.h" |
| #include "core/editing/markers/DocumentMarkerController.h" |
| #include "core/events/CompositionEvent.h" |
| +#include "core/events/InputEvent.h" |
| #include "core/frame/LocalFrame.h" |
| #include "core/html/HTMLTextAreaElement.h" |
| #include "core/input/EventHandler.h" |
| @@ -156,6 +157,16 @@ bool InputMethodController::confirmComposition(const String& text) |
| if (frame().selection().isNone()) |
| return false; |
| + if (RuntimeEnabledFeatures::inputEventEnabled()) { |
|
dtapuska
2016/03/01 21:49:51
This seems to be a repeated pattern in this class.
|
| + if (Element* target = frame().document()->focusedElement()) { |
| + // Dispatch 'beforeinput' before CompositionEvent |
| + RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createBeforeInput("insertText", text); |
|
chongz
2016/03/01 20:41:10
https://developer.mozilla.org/en-US/docs/Web/API/D
|
| + DispatchEventResult dispatchResult = target->dispatchEvent(beforeInputEvent); |
| + if (dispatchResult != DispatchEventResult::NotCanceled) |
| + return false; |
| + } |
| + } |
| + |
| dispatchCompositionEndEvent(frame(), text); |
| if (!frame().document()) |
| @@ -179,6 +190,16 @@ bool InputMethodController::confirmCompositionOrInsertText(const String& text, C |
| if (!hasComposition()) { |
| if (!text.length()) |
| return false; |
| + |
| + if (RuntimeEnabledFeatures::inputEventEnabled()) { |
| + if (Element* target = frame().document()->focusedElement()) { |
| + // Dispatch 'beforeinput' before insertText |
| + RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createBeforeInput("insertText", text); |
| + DispatchEventResult dispatchResult = target->dispatchEvent(beforeInputEvent); |
| + if (dispatchResult != DispatchEventResult::NotCanceled) |
| + return false; |
| + } |
| + } |
| editor().insertText(text, 0); |
| return true; |
| } |
| @@ -246,6 +267,14 @@ void InputMethodController::setComposition(const String& text, const Vector<Comp |
| return; |
| if (Element* target = frame().document()->focusedElement()) { |
| + if (RuntimeEnabledFeatures::inputEventEnabled()) { |
| + // Dispatch 'beforeinput' before CompositionEvent |
| + RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::createBeforeInput("replaceContent", text); |
|
chongz
2016/03/01 20:41:10
'replaceContent' is mentioned here http://w3c.gith
dtapuska
2016/03/01 21:49:51
Let us leave it with replace text for now and see
|
| + DispatchEventResult dispatchResult = target->dispatchEvent(beforeInputEvent); |
| + if (dispatchResult != DispatchEventResult::NotCanceled) |
| + return; |
| + } |
| + |
| // Dispatch an appropriate composition event to the focused node. |
| // We check the composition status and choose an appropriate composition event since this |
| // function is used for three purposes: |