| 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 7ba773eeecf9725bd28a2496d69507aed2ddaaac..f0b98b970c5743c2a82e53a2d1f64709898bd006 100644
|
| --- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp
|
| @@ -234,7 +234,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());
|
|
|
| @@ -322,10 +322,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);
|
| - RawPtr<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);
|
| + 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);
|
| +
|
| + 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());
|
|
|