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 e1d2f0fe18572803afa15c40bfe7af59a60e36ee..2f9b0a9d6f9273440ca3bcce839325b54851ef50 100644 |
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
@@ -172,6 +172,12 @@ bool InputMethodController::confirmComposition(const String& text, ConfirmCompos |
clear(); |
+ // According to spec 'beforeinput' should not be sent along with CompositionEnd, so |
ojan
2016/04/16 00:11:45
Nit: two spaces before CompositionEnd
chongz
2016/04/18 22:54:47
Done.
|
+ // dispatch after CompositionEnd if there is any update. |
+ // https://w3c.github.io/uievents/#h-events-composition-event-input-events |
ojan
2016/04/16 00:11:45
I believe the point of this part of the spec is th
chongz
2016/04/18 22:54:47
Yes we shouldn't modify DOM after 'compositionend'
|
+ if (dispatchBeforeInputInsertText(frame().document()->focusedElement(), text) != DispatchEventResult::NotCanceled) |
+ return false; |
+ |
insertTextForConfirmedComposition(text); |
return true; |
@@ -182,6 +188,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; |
} |
@@ -278,8 +288,13 @@ void InputMethodController::setComposition(const String& text, const Vector<Comp |
else |
event = CompositionEvent::create(EventTypeNames::compositionend, frame().domWindow(), text); |
} |
- if (event) |
+ if (event) { |
+ // TODO(chongz): Support canceling IME composition. |
+ // TODO(chongz): Should fire InsertText or DeleteComposedCharacter based on action. |
+ if (event->type() == EventTypeNames::compositionupdate) |
+ dispatchBeforeInputFromComposition(target, InputEvent::InputType::InsertText, text); |
chongz
2016/04/13 23:53:09
Based on discussion on GitHub DeleteComposedCharac
|
target->dispatchEvent(event); |
+ } |
} |
// If text is empty, then delete the old composition here. If text is non-empty, InsertTextCommand::input |
@@ -453,6 +468,8 @@ void InputMethodController::extendSelectionAndDelete(int before, int after) |
break; |
++before; |
} while (frame().selection().start() == frame().selection().end() && before <= static_cast<int>(selectionOffsets.start())); |
+ // TODO(chongz): According to spec |data| should be "forward" or "backward". |
ojan
2016/04/16 00:11:45
Shouldn't data be the text that's going to be dele
chongz
2016/04/18 22:54:47
Spec says:
```
6. If the user indicated deletion o
ojan
2016/04/20 16:58:57
Whoops. I forgot to respond to this. That behavior
|
+ dispatchBeforeInputEditorCommand(frame().document()->focusedElement(), InputEvent::InputType::DeleteContent); |
TypingCommand::deleteSelection(*frame().document()); |
} |