Chromium Code Reviews| 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..46a923c76949e4a1c31cc9adb84eb6fd4e0bea50 100644 |
| --- a/third_party/WebKit/Source/core/editing/PlainTextRange.cpp |
| +++ b/third_party/WebKit/Source/core/editing/PlainTextRange.cpp |
| @@ -148,8 +148,16 @@ EphemeralRange PlainTextRange::createRangeFor(const ContainerNode& scope, GetRan |
| docTextPosition += len; |
| } |
| - if (!startRangeFound) |
| - return EphemeralRange(); |
| + if (!startRangeFound) { |
| + // startRangeFound = start() >= docTextPosition && start() <= docTextPosition + len. |
| + // The former condition is related to the left boundary, and the latter to the right boundary. |
| + // Since we assert that end()>=start()>=0, and docTextPosition==0 before the loop starts, |
| + // so startRangeFound is false if and only if new cursor position exceeds the right boundary. |
| + // In that case, the cursor should stay at the right boundary, because EditText, the component |
| + // in Android, behaves in that way. |
|
Changwan Ryu
2016/04/05 07:50:37
how about renaming startRangeFound as startOutOfBo
yabinh
2016/04/05 08:06:41
Acknowledged.
|
| + resultStart = textRunEndPosition; |
| + resultEnd = textRunEndPosition; |
| + } |
| if (length() && end() > docTextPosition) { // end() is out of bounds |
| resultEnd = textRunEndPosition; |