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

Unified Diff: third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp

Issue 2674253004: [refactor] Remove WebWidget::applyReplacementRange (Closed)
Patch Set: Rebased 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
Index: third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp b/third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp
index d31d2ecc93bad0d4d442464510f362cee61074a4..e71d80d5d8556426845917e27bce3ba641692111 100644
--- a/third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp
+++ b/third_party/WebKit/Source/web/WebInputMethodControllerImpl.cpp
@@ -46,6 +46,7 @@ DEFINE_TRACE(WebInputMethodControllerImpl) {
bool WebInputMethodControllerImpl::setComposition(
const WebString& text,
const WebVector<WebCompositionUnderline>& underlines,
+ const WebRange& replacementRange,
int selectionStart,
int selectionEnd) {
if (WebPlugin* plugin = focusedPluginIfInputMethodSupported()) {
@@ -58,6 +59,10 @@ bool WebInputMethodControllerImpl::setComposition(
if (!frame()->editor().canEdit() && !inputMethodController().hasComposition())
return false;
+ // Select the range to be replaced with the composition later.
+ if (!replacementRange.isNull())
+ m_webLocalFrame->selectRange(replacementRange);
+
// We should verify the parent node of this IME composition node are
// editable because JavaScript may delete a parent node of the composition
// node. In this case, WebKit crashes while deleting texts from the parent
@@ -118,6 +123,7 @@ bool WebInputMethodControllerImpl::finishComposingText(
bool WebInputMethodControllerImpl::commitText(
const WebString& text,
const WebVector<WebCompositionUnderline>& underlines,
+ const WebRange& replacementRange,
int relativeCaretPosition) {
UserGestureIndicator gestureIndicator(DocumentUserGestureToken::create(
frame()->document(), UserGestureToken::NewGesture));
@@ -125,6 +131,10 @@ bool WebInputMethodControllerImpl::commitText(
if (WebPlugin* plugin = focusedPluginIfInputMethodSupported())
return plugin->commitText(text, underlines, relativeCaretPosition);
+ // Select the range to be replaced with the composition later.
+ if (!replacementRange.isNull())
+ m_webLocalFrame->selectRange(replacementRange);
+
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. See http://crbug.com/590369 for more details.
frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
« no previous file with comments | « third_party/WebKit/Source/web/WebInputMethodControllerImpl.h ('k') | third_party/WebKit/Source/web/WebViewFrameWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698