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

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

Issue 1847583003: Fix setComposingText when newCursorPosition != 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some C++ unit tests. 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/PlainTextRange.cpp
diff --git a/third_party/WebKit/Source/core/editing/PlainTextRange.cpp b/third_party/WebKit/Source/core/editing/PlainTextRange.cpp
index 7cfb84d3ba034f28437dd9c0c45e3f34382c3cb6..d3e19cb91bf84086a49f30bf6fc4851147ff13ad 100644
--- a/third_party/WebKit/Source/core/editing/PlainTextRange.cpp
+++ b/third_party/WebKit/Source/core/editing/PlainTextRange.cpp
@@ -73,7 +73,7 @@ EphemeralRange PlainTextRange::createRangeFor(const ContainerNode& scope, GetRan
ASSERT(isNotNull());
size_t docTextPosition = 0;
- bool startRangeFound = false;
+ bool startOutOfBound = true;
Position textRunStartPosition;
Position textRunEndPosition;
@@ -119,8 +119,9 @@ EphemeralRange PlainTextRange::createRangeFor(const ContainerNode& scope, GetRan
}
}
- if (foundStart) {
- startRangeFound = true;
+ // resultStart should be assigned the first time foundStart is true.
Changwan Ryu 2016/04/07 11:46:19 I don't feel that this comment is needed here.
+ if (foundStart && startOutOfBound) {
Changwan Ryu 2016/04/07 11:46:19 no need to check startOutOfBound?
yabinh 2016/04/08 01:21:30 In "foundStart = start() >= docTextPosition && sta
yabinh 2016/04/11 05:53:25 I was wrong about it. I thought the selected range
+ startOutOfBound = false;
if (textRunStartPosition.computeContainerNode()->isTextNode()) {
int offset = start() - docTextPosition;
resultStart = Position(textRunStartPosition.computeContainerNode(), offset + textRunStartPosition.offsetInContainerNode());
@@ -148,8 +149,10 @@ EphemeralRange PlainTextRange::createRangeFor(const ContainerNode& scope, GetRan
docTextPosition += len;
}
- if (!startRangeFound)
- return EphemeralRange();
+ if (startOutOfBound) {
+ resultStart = textRunEndPosition;
+ resultEnd = textRunEndPosition;
+ }
if (length() && end() > docTextPosition) { // end() is out of bounds
resultEnd = textRunEndPosition;

Powered by Google App Engine
This is Rietveld 408576698