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

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

Issue 2675363003: [InputEvent] Fire "insertCompositionText" during IME (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6678945ae9d9f44b016017d717c74d0514d95c4c..b33a9464fd1e16ae5d2684ae8368e212f41a21c2 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -81,21 +81,19 @@ bool needsIncrementalInsertion(const LocalFrame& frame, const String& newText) {
return true;
}
-DispatchEventResult dispatchBeforeInputFromComposition(
- EventTarget* target,
- InputEvent::InputType inputType,
- const String& data,
- InputEvent::EventCancelable cancelable) {
+void dispatchBeforeInputFromComposition(EventTarget* target,
+ InputEvent::InputType inputType,
+ const String& data) {
if (!RuntimeEnabledFeatures::inputEventEnabled())
- return DispatchEventResult::NotCanceled;
+ return;
if (!target)
- return DispatchEventResult::NotCanceled;
+ return;
// TODO(chongz): Pass appropriate |ranges| after it's defined on spec.
// http://w3c.github.io/editing/input-events.html#dom-inputevent-inputtype
InputEvent* beforeInputEvent = InputEvent::createBeforeInput(
- inputType, data, cancelable, InputEvent::EventIsComposing::IsComposing,
- nullptr);
- return target->dispatchEvent(beforeInputEvent);
+ inputType, data, InputEvent::NotCancelable,
+ InputEvent::EventIsComposing::IsComposing, nullptr);
+ target->dispatchEvent(beforeInputEvent);
}
// Used to insert/replace text during composition update and confirm
@@ -127,21 +125,8 @@ void insertTextDuringCompositionWithEvents(
if (!target)
return;
- // TODO(chongz): Fire 'beforeinput' for the composed text being
- // replaced/deleted.
-
- // Only the last confirmed text is cancelable.
- InputEvent::EventCancelable beforeInputCancelable =
- (compositionType ==
- TypingCommand::TextCompositionType::TextCompositionUpdate)
- ? InputEvent::EventCancelable::NotCancelable
- : InputEvent::EventCancelable::IsCancelable;
- DispatchEventResult result = dispatchBeforeInputFromComposition(
- target, InputEvent::InputType::InsertText, text, beforeInputCancelable);
-
- if (beforeInputCancelable == InputEvent::EventCancelable::IsCancelable &&
- result != DispatchEventResult::NotCanceled)
- return;
+ dispatchBeforeInputFromComposition(
+ target, InputEvent::InputType::InsertCompositionText, text);
// 'beforeinput' event handler may destroy document.
if (!frame.document())
@@ -314,12 +299,6 @@ bool InputMethodController::replaceComposition(const String& text) {
if (!isAvailable())
return false;
- // If text is empty, then delete the old composition here. If text is
- // non-empty, InsertTextCommand::input will delete the old composition with
- // an optimized replace operation.
- if (text.isEmpty())
- TypingCommand::deleteSelection(document(), 0);
-
clear();
insertTextDuringCompositionWithEvents(
@@ -433,12 +412,6 @@ void InputMethodController::cancelComposition() {
clear();
- // TODO(chongz): Figure out which InputType should we use here.
- dispatchBeforeInputFromComposition(
- document().focusedElement(),
- InputEvent::InputType::DeleteComposedCharacterBackward, nullAtom,
- InputEvent::EventCancelable::NotCancelable);
- dispatchCompositionUpdateEvent(frame(), emptyString);
insertTextDuringCompositionWithEvents(
frame(), emptyString, 0,
TypingCommand::TextCompositionType::TextCompositionCancel);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698