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 0d88e0f740a014a088b732b6340f8ca8bef0e15e..29568e1d15b4f94b1169e46d0417ee8468ff39ff 100644 |
| --- a/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
| +++ b/third_party/WebKit/Source/core/editing/InputMethodController.cpp |
| @@ -239,7 +239,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()); |
| @@ -332,8 +332,16 @@ 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); |
| + // In case of exceeding the left boundary. |
| + int start = std::max(static_cast<int>(baseOffset) + selectionStart, 0); |
| + int end = std::max(static_cast<int>(baseOffset) + selectionEnd, start); |
| + |
| + // In case of exceeding the right boundary. |
| + const EphemeralRange textRange = PlainTextRange(0, end).createRange(*(baseNode->parentElement())); |
| + int textEnd = textRange.endPosition().computeOffsetInContainerNode(); |
|
Changwan Ryu
2016/05/02 06:49:00
How about simply the following?
int textEnd = Pos
yabinh
2016/05/02 09:48:10
Do you mean:
int textEnd = EditingStrategy::lastOf
Changwan Ryu
2016/05/02 10:51:49
Ok, I couldn't find a better solution here. But ca
|
| + start = std::min(start, textEnd); |
| + end = std::min(end, textEnd); |
| + |
| Range* selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end); |
| frame().selection().setSelectedRange(selectedRange, TextAffinity::Downstream, SelectionDirectionalMode::NonDirectional, NotUserTriggered); |