Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. |
| 3 * Copyright (C) 2005 Alexey Proskuryakov. | 3 * Copyright (C) 2005 Alexey Proskuryakov. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 if (!r) | 1176 if (!r) |
| 1177 return; | 1177 return; |
| 1178 | 1178 |
| 1179 Node* startNode = r->startContainer(); | 1179 Node* startNode = r->startContainer(); |
| 1180 if (!startNode) | 1180 if (!startNode) |
| 1181 return; | 1181 return; |
| 1182 Node* endNode = r->endContainer(); | 1182 Node* endNode = r->endContainer(); |
| 1183 int startOffset = r->startOffset(); | 1183 int startOffset = r->startOffset(); |
| 1184 int endOffset = r->endOffset(); | 1184 int endOffset = r->endOffset(); |
| 1185 | 1185 |
| 1186 if (!startNode->offsetInCharacters()) { | 1186 if (!startNode->offsetInCharacters() && startOffset >= 0) { |
| 1187 if (startOffset >= 0 && startOffset < static_cast<int>(startNode->childN odeCount())) { | 1187 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
| |
| 1188 startNode = startNode->childNode(startOffset); | 1188 startNode = childAtOffset; |
| 1189 startOffset = 0; | 1189 startOffset = 0; |
| 1190 } | 1190 } |
| 1191 } | 1191 } |
| 1192 if (!endNode->offsetInCharacters()) { | 1192 if (!endNode->offsetInCharacters() && endOffset > 0) { |
| 1193 if (endOffset > 0 && endOffset <= static_cast<int>(endNode->childNodeCou nt())) { | 1193 if (Node* childAtOffset = endNode->childNode(endOffset - 1)) { |
| 1194 endNode = endNode->childNode(endOffset - 1); | 1194 endNode = childAtOffset; |
| 1195 endOffset = lastOffsetInNode(endNode); | 1195 endOffset = lastOffsetInNode(endNode); |
| 1196 } | 1196 } |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 m_node = endNode; | 1199 m_node = endNode; |
| 1200 setUpFullyClippedStack(m_fullyClippedStack, m_node); | 1200 setUpFullyClippedStack(m_fullyClippedStack, m_node); |
| 1201 m_offset = endOffset; | 1201 m_offset = endOffset; |
| 1202 m_handledNode = false; | 1202 m_handledNode = false; |
| 1203 m_handledChildren = !endOffset; | 1203 m_handledChildren = !endOffset; |
| 1204 | 1204 |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2077 if (!matchLength) | 2077 if (!matchLength) |
| 2078 return collapsedToBoundary(range, !(options & Backwards)); | 2078 return collapsedToBoundary(range, !(options & Backwards)); |
| 2079 } | 2079 } |
| 2080 | 2080 |
| 2081 // Then, find the document position of the start and the end of the text. | 2081 // Then, find the document position of the start and the end of the text. |
| 2082 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls | TextIteratorEntersAuthorShadowRoots); | 2082 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls | TextIteratorEntersAuthorShadowRoots); |
| 2083 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2083 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
| 2084 } | 2084 } |
| 2085 | 2085 |
| 2086 } | 2086 } |
| OLD | NEW |