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..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; |