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

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

Issue 2883073002: Remove selected text when committing empty text (Closed)
Patch Set: Created 3 years, 7 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/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 44f92b3607e303fab9453b0ad085824833f8065b..093c43bed412992bc65c6290b38e5737b25652ec 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -409,13 +409,6 @@ bool InputMethodController::CommitText(
underlines);
}
- // We should do nothing in this case, because:
- // 1. No need to insert text when text is empty.
- // 2. Shouldn't move caret when relativeCaretPosition == 0 to avoid
- // duplicate selection change event.
- if (!text.length() && !relative_caret_position)
- return false;
-
return InsertTextAndMoveCaret(text, relative_caret_position, underlines);
}
@@ -527,18 +520,15 @@ bool InputMethodController::InsertTextAndMoveCaret(
return false;
int text_start = selection_range.Start();
- if (text.length()) {
- if (!InsertText(text))
- return false;
-
- Element* root_editable_element =
- GetFrame()
- .Selection()
- .ComputeVisibleSelectionInDOMTreeDeprecated()
- .RootEditableElement();
- if (root_editable_element) {
- AddCompositionUnderlines(underlines, root_editable_element, text_start);
- }
+ if (!InsertText(text))
+ return false;
+ Element* root_editable_element =
+ GetFrame()
+ .Selection()
+ .ComputeVisibleSelectionInDOMTreeDeprecated()
+ .RootEditableElement();
+ if (root_editable_element) {
+ AddCompositionUnderlines(underlines, root_editable_element, text_start);
}
int absolute_caret_position = ComputeAbsoluteCaretPosition(

Powered by Google App Engine
This is Rietveld 408576698