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 50c4d95d121410f20ccfe36e4d0942ff890e6f28..5409d6c9e65da85b3f6b1bfe18f834e6f821aa55 100644 |
--- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
+++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
@@ -248,7 +248,12 @@ bool InputMethodController::finishComposingText( |
return false; |
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. |
+ bool isHandleVisible = frame().selection().isHandleVisible(); |
yosin_UTC9
2017/01/25 03:49:08
s/bool/const bool/
Changwan Ryu
2017/02/08 00:40:33
Done.
|
+ EphemeralRange oldSelectionRange = |
yosin_UTC9
2017/01/25 03:49:08
s/EphemeralRange/const EphemeralRange&/
Changwan Ryu
2017/02/08 00:40:33
Done.
|
+ ephemeralRangeForOffsets(getSelectionOffsets()); |
+ |
Editor::RevealSelectionScope revealSelectionScope(&editor()); |
bool result = replaceComposition(composingText()); |
@@ -257,7 +262,15 @@ bool InputMethodController::finishComposingText( |
// needs to be audited. see http://crbug.com/590369 for more details. |
document().updateStyleAndLayoutIgnorePendingStylesheets(); |
- setSelectionOffsets(oldOffsets); |
+ if (oldSelectionRange.isNull()) |
+ return false; |
+ const SelectionInDOMTree& selection = |
+ SelectionInDOMTree::Builder() |
+ .setBaseAndExtent(oldSelectionRange) |
+ .setIsHandleVisible(isHandleVisible) |
+ .build(); |
+ |
+ frame().selection().setSelection(selection, FrameSelection::CloseTyping); |
yosin_UTC9
2017/01/25 03:49:08
We'll get rid of |CloseTyping| option[1]
[1] http
Changwan Ryu
2017/02/08 00:40:33
Acknowledged.
|
return result; |
} |
@@ -679,19 +692,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( |
yosin_UTC9
2017/01/25 03:49:08
It is not you due, but we miss comment for |bool|
Changwan Ryu
2017/02/08 00:40:33
Done.
|
+ const PlainTextRange& selectionOffsets, |
+ FrameSelection::SetSelectionOptions options) { |
+ const EphemeralRange range = ephemeralRangeForOffsets(selectionOffsets); |
if (range.isNull()) |
return false; |