Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodController.cpp

Issue 1847583003: Fix setComposingText when newCursorPosition != 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Without changing PlainTextRange Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698