| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 #endif | 171 #endif |
| 172 | 172 |
| 173 // This function is like Range::pastLastNode, except for the fact that it can cl
imb up out of shadow trees. | 173 // This function is like Range::pastLastNode, except for the fact that it can cl
imb up out of shadow trees. |
| 174 static Node* nextInPreOrderCrossingShadowBoundaries(Node* rangeEndContainer, int
rangeEndOffset) | 174 static Node* nextInPreOrderCrossingShadowBoundaries(Node* rangeEndContainer, int
rangeEndOffset) |
| 175 { | 175 { |
| 176 if (!rangeEndContainer) | 176 if (!rangeEndContainer) |
| 177 return 0; | 177 return 0; |
| 178 if (rangeEndOffset >= 0 && !rangeEndContainer->offsetInCharacters()) { | 178 if (rangeEndOffset >= 0 && !rangeEndContainer->offsetInCharacters()) { |
| 179 if (Node* next = rangeEndContainer->traverseToChildAt(rangeEndOffset)) | 179 if (Node* next = NodeTraversal::childAt(*rangeEndContainer, rangeEndOffs
et)) |
| 180 return next; | 180 return next; |
| 181 } | 181 } |
| 182 for (Node* node = rangeEndContainer; node; node = node->parentOrShadowHostNo
de()) { | 182 for (Node* node = rangeEndContainer; node; node = node->parentOrShadowHostNo
de()) { |
| 183 if (Node* next = node->nextSibling()) | 183 if (Node* next = node->nextSibling()) |
| 184 return next; | 184 return next; |
| 185 } | 185 } |
| 186 return 0; | 186 return 0; |
| 187 } | 187 } |
| 188 | 188 |
| 189 // -------- | 189 // -------- |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // the common ancestor tree scope. | 325 // the common ancestor tree scope. |
| 326 const TreeScope* commonAncestorTreeScope = startContainer->treeScope().commo
nAncestorTreeScope(endContainer->treeScope()); | 326 const TreeScope* commonAncestorTreeScope = startContainer->treeScope().commo
nAncestorTreeScope(endContainer->treeScope()); |
| 327 ASSERT(commonAncestorTreeScope); | 327 ASSERT(commonAncestorTreeScope); |
| 328 m_shadowDepth = 0; | 328 m_shadowDepth = 0; |
| 329 for (const TreeScope* treeScope = &startContainer->treeScope(); treeScope !=
commonAncestorTreeScope; treeScope = treeScope->parentTreeScope()) | 329 for (const TreeScope* treeScope = &startContainer->treeScope(); treeScope !=
commonAncestorTreeScope; treeScope = treeScope->parentTreeScope()) |
| 330 ++m_shadowDepth; | 330 ++m_shadowDepth; |
| 331 | 331 |
| 332 // Set up the current node for processing. | 332 // Set up the current node for processing. |
| 333 if (startContainer->offsetInCharacters()) | 333 if (startContainer->offsetInCharacters()) |
| 334 m_node = startContainer; | 334 m_node = startContainer; |
| 335 else if (Node* child = startContainer->traverseToChildAt(startOffset)) | 335 else if (Node* child = NodeTraversal::childAt(*startContainer, startOffset)) |
| 336 m_node = child; | 336 m_node = child; |
| 337 else if (!startOffset) | 337 else if (!startOffset) |
| 338 m_node = startContainer; | 338 m_node = startContainer; |
| 339 else | 339 else |
| 340 m_node = NodeTraversal::nextSkippingChildren(*startContainer); | 340 m_node = NodeTraversal::nextSkippingChildren(*startContainer); |
| 341 | 341 |
| 342 if (!m_node) | 342 if (!m_node) |
| 343 return; | 343 return; |
| 344 | 344 |
| 345 m_node->document().updateLayoutIgnorePendingStylesheets(); | 345 m_node->document().updateLayoutIgnorePendingStylesheets(); |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 RefPtrWillBeRawPtr<Range> textRange = range(); | 1207 RefPtrWillBeRawPtr<Range> textRange = range(); |
| 1208 if (!textRange) | 1208 if (!textRange) |
| 1209 return 0; | 1209 return 0; |
| 1210 | 1210 |
| 1211 Node* node = textRange->startContainer(); | 1211 Node* node = textRange->startContainer(); |
| 1212 if (!node) | 1212 if (!node) |
| 1213 return 0; | 1213 return 0; |
| 1214 if (node->offsetInCharacters()) | 1214 if (node->offsetInCharacters()) |
| 1215 return node; | 1215 return node; |
| 1216 | 1216 |
| 1217 return node->traverseToChildAt(textRange->startOffset()); | 1217 return NodeTraversal::childAt(*node, textRange->startOffset()); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 // -------- | 1220 // -------- |
| 1221 | 1221 |
| 1222 SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range* r,
TextIteratorBehaviorFlags behavior) | 1222 SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator(const Range* r,
TextIteratorBehaviorFlags behavior) |
| 1223 : m_node(nullptr) | 1223 : m_node(nullptr) |
| 1224 , m_offset(0) | 1224 , m_offset(0) |
| 1225 , m_handledNode(false) | 1225 , m_handledNode(false) |
| 1226 , m_handledChildren(false) | 1226 , m_handledChildren(false) |
| 1227 , m_startNode(nullptr) | 1227 , m_startNode(nullptr) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1248 return; | 1248 return; |
| 1249 | 1249 |
| 1250 Node* startNode = r->startContainer(); | 1250 Node* startNode = r->startContainer(); |
| 1251 if (!startNode) | 1251 if (!startNode) |
| 1252 return; | 1252 return; |
| 1253 Node* endNode = r->endContainer(); | 1253 Node* endNode = r->endContainer(); |
| 1254 int startOffset = r->startOffset(); | 1254 int startOffset = r->startOffset(); |
| 1255 int endOffset = r->endOffset(); | 1255 int endOffset = r->endOffset(); |
| 1256 | 1256 |
| 1257 if (!startNode->offsetInCharacters() && startOffset >= 0) { | 1257 if (!startNode->offsetInCharacters() && startOffset >= 0) { |
| 1258 // traverseToChildAt() will return 0 if the offset is out of range. We r
ely on this behavior | 1258 // NodeTraversal::childAt() will return 0 if the offset is out of range.
We rely on this behavior |
| 1259 // instead of calling countChildren() to avoid traversing the children t
wice. | 1259 // instead of calling countChildren() to avoid traversing the children t
wice. |
| 1260 if (Node* childAtOffset = startNode->traverseToChildAt(startOffset)) { | 1260 if (Node* childAtOffset = NodeTraversal::childAt(*startNode, startOffset
)) { |
| 1261 startNode = childAtOffset; | 1261 startNode = childAtOffset; |
| 1262 startOffset = 0; | 1262 startOffset = 0; |
| 1263 } | 1263 } |
| 1264 } | 1264 } |
| 1265 if (!endNode->offsetInCharacters() && endOffset > 0) { | 1265 if (!endNode->offsetInCharacters() && endOffset > 0) { |
| 1266 // traverseToChildAt() will return 0 if the offset is out of range. We r
ely on this behavior | 1266 // NodeTraversal::childAt() will return 0 if the offset is out of range.
We rely on this behavior |
| 1267 // instead of calling countChildren() to avoid traversing the children t
wice. | 1267 // instead of calling countChildren() to avoid traversing the children t
wice. |
| 1268 if (Node* childAtOffset = endNode->traverseToChildAt(endOffset - 1)) { | 1268 if (Node* childAtOffset = NodeTraversal::childAt(*endNode, endOffset - 1
)) { |
| 1269 endNode = childAtOffset; | 1269 endNode = childAtOffset; |
| 1270 endOffset = lastOffsetInNode(endNode); | 1270 endOffset = lastOffsetInNode(endNode); |
| 1271 } | 1271 } |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 m_node = endNode; | 1274 m_node = endNode; |
| 1275 setUpFullyClippedStack(m_fullyClippedStack, m_node); | 1275 setUpFullyClippedStack(m_fullyClippedStack, m_node); |
| 1276 m_offset = endOffset; | 1276 m_offset = endOffset; |
| 1277 m_handledNode = false; | 1277 m_handledNode = false; |
| 1278 m_handledChildren = !endOffset; | 1278 m_handledChildren = !endOffset; |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2220 resultEnd = collapseTo; | 2220 resultEnd = collapseTo; |
| 2221 return; | 2221 return; |
| 2222 } | 2222 } |
| 2223 } | 2223 } |
| 2224 | 2224 |
| 2225 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); | 2225 CharacterIterator computeRangeIterator(inputStart, inputEnd, iteratorFlagsFo
rFindPlainText); |
| 2226 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); | 2226 calculateCharacterSubrange(computeRangeIterator, matchStart, matchLength, re
sultStart, resultEnd); |
| 2227 } | 2227 } |
| 2228 | 2228 |
| 2229 } | 2229 } |
| OLD | NEW |