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

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

Issue 2558643003: [InputEvent] Move 'beforeinput' logic into |CompositeEditCommand::willApplyEditing()| (3/3) (Closed)
Patch Set: yosin's review, fix nits Created 4 years 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 bae3cea1d0ff453dbdafaf3f688cb67b036bec9d..bd98afe18c73a05804450c48113c650c37701c1a 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -71,11 +71,9 @@ void dispatchCompositionEndEvent(LocalFrame& frame, const String& text) {
// Used to insert/replace text during composition update and confirm
// composition.
// Procedure:
-// 1. Fire 'beforeinput' event for (TODO(chongz): deleted composed text) and
-// inserted text
-// 2. Fire 'compositionupdate' event
-// 3. Fire TextEvent and modify DOM
-// TODO(chongz): 4. Fire 'input' event
+// 1. Fire 'compositionupdate' event
Xiaocheng 2016/12/19 03:25:44 This patch switches the ordering of compositionupd
chongz 2016/12/19 20:53:43 Sorry for not pointing it out in advance. I've re
+// 2. Use TextEvent or TypingCommand to modify DOM, which will fire
+// 'beforeinput' and 'input'
void insertTextDuringCompositionWithEvents(
LocalFrame& frame,
const String& text,
@@ -93,33 +91,9 @@ void insertTextDuringCompositionWithEvents(
if (!frame.document())
return;
- Element* target = frame.document()->focusedElement();
- 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;
-
- // 'beforeinput' event handler may destroy document.
- if (!frame.document())
- return;
-
dispatchCompositionUpdateEvent(frame, text);
// 'compositionupdate' event handler may destroy document.
- if (!frame.document())
+ if (!frame.document() || frame.document()->frame() != &frame)
return;
switch (compositionType) {
@@ -138,7 +112,6 @@ void insertTextDuringCompositionWithEvents(
default:
NOTREACHED();
}
- // TODO(chongz): Fire 'input' event.
}
AtomicString getInputModeAttribute(Element* element) {
@@ -339,9 +312,6 @@ bool InputMethodController::replaceCompositionAndMoveCaret(
}
bool InputMethodController::insertText(const String& text) {
- if (dispatchBeforeInputInsertText(document().focusedElement(), text) !=
- DispatchEventResult::NotCanceled)
- return false;
editor().insertText(text, 0);
return true;
}
@@ -374,11 +344,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,
@@ -915,10 +880,6 @@ void InputMethodController::extendSelectionAndDelete(int before, int after) {
++before;
} while (frame().selection().start() == frame().selection().end() &&
before <= static_cast<int>(selectionOffsets.start()));
- // TODO(chongz): Find a way to distinguish Forward and Backward.
- dispatchBeforeInputEditorCommand(
- document().focusedElement(), InputEvent::InputType::DeleteContentBackward,
- new RangeVector(1, m_frame->selection().firstRange()));
TypingCommand::deleteSelection(document());
}

Powered by Google App Engine
This is Rietveld 408576698