Chromium Code Reviews| 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..054b5099d83c4989aa9a644421483e78a859962f 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(); |
| + EphemeralRange oldSelectionRange = |
| + ephemeralRangeForOffsets(getSelectionOffsets()); |
| + |
| Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| bool result = replaceComposition(composingText()); |
| @@ -257,7 +262,16 @@ bool InputMethodController::finishComposingText( |
| // needs to be audited. see http://crbug.com/590369 for more details. |
| document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| - setSelectionOffsets(oldOffsets); |
| + if (oldSelectionRange.isNull()) |
| + return false; |
| + SelectionInDOMTree::Builder& selectionBuilder = |
| + SelectionInDOMTree::Builder().setBaseAndExtent(oldSelectionRange); |
| + |
| + if (isHandleVisible) |
|
yosin_UTC9
2017/01/20 07:54:07
This line should be include in L268. One of benefi
Changwan Ryu
2017/01/24 06:38:45
Done.
|
| + selectionBuilder.setIsHandleVisible(true); |
| + |
| + frame().selection().setSelection(selectionBuilder.build(), |
| + FrameSelection::CloseTyping); |
| return result; |
| } |
| @@ -679,19 +693,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) { |
|
yosin_UTC9
2017/01/20 07:54:07
Please avoid to use FrameSelection::SetSelectionOp
Changwan Ryu
2017/01/24 06:38:45
Hmm... Most cases passing CloseTyping is necessary
yosin_UTC9
2017/01/24 07:58:27
I see.
|
| + const EphemeralRange range = ephemeralRangeForOffsets(selectionOffsets); |
| if (range.isNull()) |
| return false; |