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 7aeb0d1f45878ec10d499195a6e38f8e40180923..5bd53f10d9d2bab988b3d1c97ea0533ac0c2595a 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
| @@ -231,7 +231,7 @@ void InputMethodController::cancelCompositionIfSelectionIsInvalid() |
| frame().chromeClient().didCancelCompositionOnSelectionChange(); |
| } |
| -void InputMethodController::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, unsigned selectionStart, unsigned selectionEnd) |
| +void InputMethodController::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, int selectionStart, int selectionEnd) |
| { |
| Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| @@ -319,10 +319,18 @@ void InputMethodController::setComposition(const String& text, const Vector<Comp |
| if (baseNode->layoutObject()) |
| baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); |
| - unsigned start = std::min(baseOffset + selectionStart, extentOffset); |
| - unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOffset); |
| - RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end); |
| - frame().selection().setSelectedRange(selectedRange.get(), TextAffinity::Downstream, SelectionDirectionalMode::NonDirectional, NotUserTriggered); |
| + // The case when cursor position exceeds left boundary is handled here |
| + int start = std::max(static_cast<int>(baseOffset) + selectionStart, 0); |
|
Changwan Ryu
2016/04/04 06:23:13
Why do you remove the logic around extentOffset?
yabinh
2016/04/04 08:31:51
extendoffset = length(text before composing region
|
| + int end = std::max(static_cast<int>(baseOffset) + selectionEnd, start); |
| + |
| + Element* rootEditableElement = frame().selection().rootEditableElement(); |
| + if (!rootEditableElement) |
| + return; |
| + |
| + // The case when cursor position exceeds right boundary is handled here |
| + const EphemeralRange selectedRange = PlainTextRange(start, end).createRange(*rootEditableElement); |
|
Changwan Ryu
2016/04/04 06:23:13
Why did you remove RefPtrWillberawPtr?
yabinh
2016/04/04 08:31:51
RefPtrWillberawPtr is only used to create selected
|
| + |
| + frame().selection().setSelectedRange(selectedRange, TextAffinity::Downstream, SelectionDirectionalMode::NonDirectional, NotUserTriggered); |
| if (underlines.isEmpty()) { |
| frame().document()->markers().addCompositionMarker(m_compositionRange->startPosition(), m_compositionRange->endPosition(), Color::black, false, LayoutTheme::theme().platformDefaultCompositionBackgroundColor()); |