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

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

Issue 2493703002: Make "compositionend" event fired after setting caret position (Closed)
Patch Set: Not able to listen to selectionchange event Created 4 years, 1 month 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 7bbbbd378e7aaf301e3a53951c205de3fd34f813..e061ed70d6774badff1b3dfaee285b9d0671a8f9 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -213,13 +213,18 @@ bool InputMethodController::finishComposingText(
PlainTextRange oldOffsets = getSelectionOffsets();
Editor::RevealSelectionScope revealSelectionScope(&editor());
- bool result = replaceComposition(composingText());
+ const String& composing = composingText();
+ bool result = replaceComposition(composing);
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. see http://crbug.com/590369 for more details.
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
setSelectionOffsets(oldOffsets);
+
+ // No DOM update after 'compositionend'.
+ dispatchCompositionEndEvent(frame(), composing);
+
return result;
}
@@ -276,9 +281,6 @@ bool InputMethodController::replaceComposition(const String& text) {
if (!frame().document())
return false;
- // No DOM update after 'compositionend'.
- dispatchCompositionEndEvent(frame(), text);
-
return true;
}
@@ -306,7 +308,13 @@ bool InputMethodController::replaceCompositionAndMoveCaret(
int absoluteCaretPosition = computeAbsoluteCaretPosition(
textStart, text.length(), relativeCaretPosition);
- return moveCaret(absoluteCaretPosition);
+ if (!moveCaret(absoluteCaretPosition))
+ return false;
+
+ // No DOM update after 'compositionend'.
+ dispatchCompositionEndEvent(frame(), text);
+
+ return true;
}
bool InputMethodController::insertText(const String& text) {
@@ -616,7 +624,9 @@ void InputMethodController::setComposition(
frame().document()->updateStyleAndLayoutIgnorePendingStylesheets();
setEditableSelectionOffsets(selectedRange);
- return;
+
+ // No DOM update after 'compositionend'.
+ return dispatchCompositionEndEvent(frame(), text);
}
// We should send a 'compositionstart' event only when the given text is not

Powered by Google App Engine
This is Rietveld 408576698