Chromium Code Reviews| Index: Source/core/editing/TextIterator.cpp |
| diff --git a/Source/core/editing/TextIterator.cpp b/Source/core/editing/TextIterator.cpp |
| index b85b148eaf9608052ac88662b451df18dd732357..ca94a641bb2847e5baefe03230aa92da7ef916c5 100644 |
| --- a/Source/core/editing/TextIterator.cpp |
| +++ b/Source/core/editing/TextIterator.cpp |
| @@ -1183,15 +1183,15 @@ SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range* r, |
| int startOffset = r->startOffset(); |
| int endOffset = r->endOffset(); |
| - if (!startNode->offsetInCharacters()) { |
| - if (startOffset >= 0 && startOffset < static_cast<int>(startNode->childNodeCount())) { |
| - startNode = startNode->childNode(startOffset); |
| + if (!startNode->offsetInCharacters() && startOffset >= 0) { |
| + if (Node* childAtOffset = startNode->childNode(startOffset)) { |
|
Inactive
2014/02/19 04:13:33
ContainerNode::childNode(index) will return 0 if t
eseidel
2014/02/19 05:39:54
This seems like rather odd behavior to depend on.
Inactive
2014/02/19 14:28:15
Yes, I don't have a better proposal than this at t
|
| + startNode = childAtOffset; |
| startOffset = 0; |
| } |
| } |
| - if (!endNode->offsetInCharacters()) { |
| - if (endOffset > 0 && endOffset <= static_cast<int>(endNode->childNodeCount())) { |
| - endNode = endNode->childNode(endOffset - 1); |
| + if (!endNode->offsetInCharacters() && endOffset > 0) { |
| + if (Node* childAtOffset = endNode->childNode(endOffset - 1)) { |
| + endNode = childAtOffset; |
| endOffset = lastOffsetInNode(endNode); |
| } |
| } |