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 // childNode() will return 0 if the offset is out of range. We rely on t
his behavior |
1188 startNode = startNode->childNode(startOffset); | 1188 // instead of calling childNodeCount() to avoid traversing the children
twice. |
| 1189 if (Node* childAtOffset = startNode->childNode(startOffset)) { |
| 1190 startNode = childAtOffset; |
1189 startOffset = 0; | 1191 startOffset = 0; |
1190 } | 1192 } |
1191 } | 1193 } |
1192 if (!endNode->offsetInCharacters()) { | 1194 if (!endNode->offsetInCharacters() && endOffset > 0) { |
1193 if (endOffset > 0 && endOffset <= static_cast<int>(endNode->childNodeCou
nt())) { | 1195 // childNode() will return 0 if the offset is out of range. We rely on t
his behavior |
1194 endNode = endNode->childNode(endOffset - 1); | 1196 // instead of calling childNodeCount() to avoid traversing the children
twice. |
| 1197 if (Node* childAtOffset = endNode->childNode(endOffset - 1)) { |
| 1198 endNode = childAtOffset; |
1195 endOffset = lastOffsetInNode(endNode); | 1199 endOffset = lastOffsetInNode(endNode); |
1196 } | 1200 } |
1197 } | 1201 } |
1198 | 1202 |
1199 m_node = endNode; | 1203 m_node = endNode; |
1200 setUpFullyClippedStack(m_fullyClippedStack, m_node); | 1204 setUpFullyClippedStack(m_fullyClippedStack, m_node); |
1201 m_offset = endOffset; | 1205 m_offset = endOffset; |
1202 m_handledNode = false; | 1206 m_handledNode = false; |
1203 m_handledChildren = !endOffset; | 1207 m_handledChildren = !endOffset; |
1204 | 1208 |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2077 if (!matchLength) | 2081 if (!matchLength) |
2078 return collapsedToBoundary(range, !(options & Backwards)); | 2082 return collapsedToBoundary(range, !(options & Backwards)); |
2079 } | 2083 } |
2080 | 2084 |
2081 // Then, find the document position of the start and the end of the text. | 2085 // Then, find the document position of the start and the end of the text. |
2082 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
| TextIteratorEntersAuthorShadowRoots); | 2086 CharacterIterator computeRangeIterator(range, TextIteratorEntersTextControls
| TextIteratorEntersAuthorShadowRoots); |
2083 return characterSubrange(computeRangeIterator, matchStart, matchLength); | 2087 return characterSubrange(computeRangeIterator, matchStart, matchLength); |
2084 } | 2088 } |
2085 | 2089 |
2086 } | 2090 } |
OLD | NEW |