OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> |
3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 return; | 247 return; |
248 | 248 |
249 for (Node* n = context->firstChild(); n; n = n->nextSibling()) | 249 for (Node* n = context->firstChild(); n; n = n->nextSibling()) |
250 if (nodeMatches(n, ChildAxis, m_nodeTest)) | 250 if (nodeMatches(n, ChildAxis, m_nodeTest)) |
251 nodes.append(n); | 251 nodes.append(n); |
252 return; | 252 return; |
253 case DescendantAxis: | 253 case DescendantAxis: |
254 if (context->isAttributeNode()) // In XPath model, attribute nodes d
o not have children. | 254 if (context->isAttributeNode()) // In XPath model, attribute nodes d
o not have children. |
255 return; | 255 return; |
256 | 256 |
257 for (Node* n = context->firstChild(); n; n = NodeTraversal::next(n,
context)) | 257 for (Node* n = context->firstChild(); n; n = NodeTraversal::next(*n,
context)) |
258 if (nodeMatches(n, DescendantAxis, m_nodeTest)) | 258 if (nodeMatches(n, DescendantAxis, m_nodeTest)) |
259 nodes.append(n); | 259 nodes.append(n); |
260 return; | 260 return; |
261 case ParentAxis: | 261 case ParentAxis: |
262 if (context->isAttributeNode()) { | 262 if (context->isAttributeNode()) { |
263 Element* n = toAttr(context)->ownerElement(); | 263 Element* n = toAttr(context)->ownerElement(); |
264 if (nodeMatches(n, ParentAxis, m_nodeTest)) | 264 if (nodeMatches(n, ParentAxis, m_nodeTest)) |
265 nodes.append(n); | 265 nodes.append(n); |
266 } else { | 266 } else { |
267 ContainerNode* n = context->parentNode(); | 267 ContainerNode* n = context->parentNode(); |
(...skipping 30 matching lines...) Expand all Loading... |
298 | 298 |
299 for (Node* n = context->previousSibling(); n; n = n->previousSibling
()) | 299 for (Node* n = context->previousSibling(); n; n = n->previousSibling
()) |
300 if (nodeMatches(n, PrecedingSiblingAxis, m_nodeTest)) | 300 if (nodeMatches(n, PrecedingSiblingAxis, m_nodeTest)) |
301 nodes.append(n); | 301 nodes.append(n); |
302 | 302 |
303 nodes.markSorted(false); | 303 nodes.markSorted(false); |
304 return; | 304 return; |
305 case FollowingAxis: | 305 case FollowingAxis: |
306 if (context->isAttributeNode()) { | 306 if (context->isAttributeNode()) { |
307 Node* p = toAttr(context)->ownerElement(); | 307 Node* p = toAttr(context)->ownerElement(); |
308 while ((p = NodeTraversal::next(p))) { | 308 while ((p = NodeTraversal::next(*p))) { |
309 if (nodeMatches(p, FollowingAxis, m_nodeTest)) | 309 if (nodeMatches(p, FollowingAxis, m_nodeTest)) |
310 nodes.append(p); | 310 nodes.append(p); |
311 } | 311 } |
312 } else { | 312 } else { |
313 for (Node* p = context; !isRootDomNode(p); p = p->parentNode())
{ | 313 for (Node* p = context; !isRootDomNode(p); p = p->parentNode())
{ |
314 for (Node* n = p->nextSibling(); n; n = n->nextSibling()) { | 314 for (Node* n = p->nextSibling(); n; n = n->nextSibling()) { |
315 if (nodeMatches(n, FollowingAxis, m_nodeTest)) | 315 if (nodeMatches(n, FollowingAxis, m_nodeTest)) |
316 nodes.append(n); | 316 nodes.append(n); |
317 for (Node* c = n->firstChild(); c; c = NodeTraversal::ne
xt(c, n)) | 317 for (Node* c = n->firstChild(); c; c = NodeTraversal::ne
xt(*c, n)) |
318 if (nodeMatches(c, FollowingAxis, m_nodeTest)) | 318 if (nodeMatches(c, FollowingAxis, m_nodeTest)) |
319 nodes.append(c); | 319 nodes.append(c); |
320 } | 320 } |
321 } | 321 } |
322 } | 322 } |
323 return; | 323 return; |
324 case PrecedingAxis: { | 324 case PrecedingAxis: { |
325 if (context->isAttributeNode()) | 325 if (context->isAttributeNode()) |
326 context = toAttr(context)->ownerElement(); | 326 context = toAttr(context)->ownerElement(); |
327 | 327 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 case SelfAxis: | 367 case SelfAxis: |
368 if (nodeMatches(context, SelfAxis, m_nodeTest)) | 368 if (nodeMatches(context, SelfAxis, m_nodeTest)) |
369 nodes.append(context); | 369 nodes.append(context); |
370 return; | 370 return; |
371 case DescendantOrSelfAxis: | 371 case DescendantOrSelfAxis: |
372 if (nodeMatches(context, DescendantOrSelfAxis, m_nodeTest)) | 372 if (nodeMatches(context, DescendantOrSelfAxis, m_nodeTest)) |
373 nodes.append(context); | 373 nodes.append(context); |
374 if (context->isAttributeNode()) // In XPath model, attribute nodes d
o not have children. | 374 if (context->isAttributeNode()) // In XPath model, attribute nodes d
o not have children. |
375 return; | 375 return; |
376 | 376 |
377 for (Node* n = context->firstChild(); n; n = NodeTraversal::next(n,
context)) | 377 for (Node* n = context->firstChild(); n; n = NodeTraversal::next(*n,
context)) |
378 if (nodeMatches(n, DescendantOrSelfAxis, m_nodeTest)) | 378 if (nodeMatches(n, DescendantOrSelfAxis, m_nodeTest)) |
379 nodes.append(n); | 379 nodes.append(n); |
380 return; | 380 return; |
381 case AncestorOrSelfAxis: { | 381 case AncestorOrSelfAxis: { |
382 if (nodeMatches(context, AncestorOrSelfAxis, m_nodeTest)) | 382 if (nodeMatches(context, AncestorOrSelfAxis, m_nodeTest)) |
383 nodes.append(context); | 383 nodes.append(context); |
384 Node* n = context; | 384 Node* n = context; |
385 if (context->isAttributeNode()) { | 385 if (context->isAttributeNode()) { |
386 n = toAttr(context)->ownerElement(); | 386 n = toAttr(context)->ownerElement(); |
387 if (nodeMatches(n, AncestorOrSelfAxis, m_nodeTest)) | 387 if (nodeMatches(n, AncestorOrSelfAxis, m_nodeTest)) |
388 nodes.append(n); | 388 nodes.append(n); |
389 } | 389 } |
390 for (n = n->parentNode(); n; n = n->parentNode()) | 390 for (n = n->parentNode(); n; n = n->parentNode()) |
391 if (nodeMatches(n, AncestorOrSelfAxis, m_nodeTest)) | 391 if (nodeMatches(n, AncestorOrSelfAxis, m_nodeTest)) |
392 nodes.append(n); | 392 nodes.append(n); |
393 | 393 |
394 nodes.markSorted(false); | 394 nodes.markSorted(false); |
395 return; | 395 return; |
396 } | 396 } |
397 } | 397 } |
398 ASSERT_NOT_REACHED(); | 398 ASSERT_NOT_REACHED(); |
399 } | 399 } |
400 | 400 |
401 | 401 |
402 } | 402 } |
403 } | 403 } |
OLD | NEW |