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

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

Issue 2646963002: Stop dismissing selection handles when selection is kept (Closed)
Patch Set: rebased on amaralp@'s CLs 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/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 e144382666975d00c41e0f84d873f985e27f75c0..dc8800ec6cf9604b930ca65d6726958faeb6b78c 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
@@ -267,7 +267,11 @@ bool InputMethodController::finishComposingText(
const String& composing = composingText();
if (confirmBehavior == KeepSelection) {
- PlainTextRange oldOffsets = getSelectionOffsets();
+ // Do not dismiss handles even if we are moving selection, because we will
+ // eventually move back to the old selection offsets.
+ const bool isHandleVisible = frame().selection().isHandleVisible();
+
+ const PlainTextRange& oldOffsets = getSelectionOffsets();
Editor::RevealSelectionScope revealSelectionScope(&editor());
clear();
@@ -276,7 +280,17 @@ bool InputMethodController::finishComposingText(
// TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
// needs to be audited. see http://crbug.com/590369 for more details.
document().updateStyleAndLayoutIgnorePendingStylesheets();
- setSelectionOffsets(oldOffsets);
+
+ const EphemeralRange& oldSelectionRange =
+ ephemeralRangeForOffsets(oldOffsets);
+ if (oldSelectionRange.isNull())
+ return false;
+ const SelectionInDOMTree& selection =
+ SelectionInDOMTree::Builder()
+ .setBaseAndExtent(oldSelectionRange)
+ .setIsHandleVisible(isHandleVisible)
+ .build();
+ frame().selection().setSelection(selection, FrameSelection::CloseTyping);
return true;
}
@@ -713,19 +727,23 @@ PlainTextRange InputMethodController::getSelectionOffsets() const {
return PlainTextRange::create(*editable, range);
}
-bool InputMethodController::setSelectionOffsets(
- const PlainTextRange& selectionOffsets,
- FrameSelection::SetSelectionOptions options) {
- if (selectionOffsets.isNull())
- return false;
+EphemeralRange InputMethodController::ephemeralRangeForOffsets(
+ const PlainTextRange& offsets) const {
+ if (offsets.isNull())
+ return EphemeralRange();
Element* rootEditableElement = frame().selection().rootEditableElement();
if (!rootEditableElement)
- return false;
+ return EphemeralRange();
DCHECK(!document().needsLayoutTreeUpdate());
- const EphemeralRange range =
- selectionOffsets.createRange(*rootEditableElement);
+ return offsets.createRange(*rootEditableElement);
+}
+
+bool InputMethodController::setSelectionOffsets(
+ const PlainTextRange& selectionOffsets,
+ FrameSelection::SetSelectionOptions options) {
+ const EphemeralRange range = ephemeralRangeForOffsets(selectionOffsets);
if (range.isNull())
return false;
« no previous file with comments | « third_party/WebKit/Source/core/editing/InputMethodController.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698