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..1db29aa05f7b914a40c966144643b758c0d9040a 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,9 +332,25 @@ 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); |
| - Range* selectedRange = Range::create(baseNode->document(), baseNode, start, baseNode, end); |
| + // In case of exceeding the left boundary. |
| + int start = std::max(static_cast<int>(getSelectionOffsets().start()) + selectionStart, 0); |
| + int end = std::max(static_cast<int>(getSelectionOffsets().start()) + selectionEnd, start); |
| + |
| + Element* rootEditableElement = frame().selection().rootEditableElement(); |
| + if (!rootEditableElement) |
| + return; |
| + |
| + // In case of exceeding the right boundary. |
| + const EphemeralRange startRange = PlainTextRange(0, start).createRange(*rootEditableElement); |
|
Changwan Ryu
2016/05/09 12:52:23
You can create only range to handle both:
const E
yabinh
2016/05/09 13:02:50
If both number1 and number2 exceed the right bound
|
| + const EphemeralRange endRange = PlainTextRange(0, end).createRange(*rootEditableElement); |
| + |
| + start = startRange.endPosition().computeOffsetInContainerNode(); |
| + Node* startNode = startRange.endPosition().computeContainerNode(); |
| + |
| + end = endRange.endPosition().computeOffsetInContainerNode(); |
| + Node* endNode = endRange.endPosition().computeContainerNode(); |
| + |
| + Range* selectedRange = Range::create(rootEditableElement->document(), startNode, start, endNode, end); |
| frame().selection().setSelectedRange(selectedRange, TextAffinity::Downstream, SelectionDirectionalMode::NonDirectional, NotUserTriggered); |
| if (underlines.isEmpty()) { |