| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 Element* firstWithin(const Node*); | 36 Element* firstWithin(const Node*); |
| 37 Element* firstWithin(const ContainerNode*); | 37 Element* firstWithin(const ContainerNode*); |
| 38 | 38 |
| 39 // Pre-order traversal skipping non-element nodes. | 39 // Pre-order traversal skipping non-element nodes. |
| 40 Element* next(const Node&); | 40 Element* next(const Node&); |
| 41 Element* next(const Node&, const Node* stayWithin); | 41 Element* next(const Node&, const Node* stayWithin); |
| 42 Element* next(const ContainerNode&); | 42 Element* next(const ContainerNode&); |
| 43 Element* next(const ContainerNode&, const Node* stayWithin); | 43 Element* next(const ContainerNode&, const Node* stayWithin); |
| 44 | 44 |
| 45 // Like next, but skips children. | 45 // Like next, but skips children. |
| 46 Element* nextSkippingChildren(const Node*); | 46 Element* nextSkippingChildren(const Node&); |
| 47 Element* nextSkippingChildren(const Node*, const Node* stayWithin); | 47 Element* nextSkippingChildren(const Node&, const Node* stayWithin); |
| 48 Element* nextSkippingChildren(const ContainerNode*); | 48 Element* nextSkippingChildren(const ContainerNode&); |
| 49 Element* nextSkippingChildren(const ContainerNode*, const Node* stayWithin); | 49 Element* nextSkippingChildren(const ContainerNode&, const Node* stayWithin); |
| 50 | 50 |
| 51 // Pre-order traversal including the pseudo-elements. | 51 // Pre-order traversal including the pseudo-elements. |
| 52 Element* previousIncludingPseudo(const Node&, const Node* stayWithin = 0); | 52 Element* previousIncludingPseudo(const Node&, const Node* stayWithin = 0); |
| 53 Element* nextIncludingPseudo(const Node*, const Node* stayWithin = 0); | 53 Element* nextIncludingPseudo(const Node*, const Node* stayWithin = 0); |
| 54 Element* nextIncludingPseudoSkippingChildren(const Node*, const Node* stayWithin
= 0); | 54 Element* nextIncludingPseudoSkippingChildren(const Node*, const Node* stayWithin
= 0); |
| 55 | 55 |
| 56 // Utility function to traverse only the element and pseudo-element siblings of
a node. | 56 // Utility function to traverse only the element and pseudo-element siblings of
a node. |
| 57 Element* pseudoAwarePreviousSibling(const Node&); | 57 Element* pseudoAwarePreviousSibling(const Node&); |
| 58 | 58 |
| 59 template <class NodeType> | 59 template <class NodeType> |
| 60 inline Element* firstElementWithinTemplate(NodeType* current) | 60 inline Element* firstElementWithinTemplate(NodeType* current) |
| 61 { | 61 { |
| 62 // Except for the root containers, only elements can have element children. | 62 // Except for the root containers, only elements can have element children. |
| 63 Node* node = current->firstChild(); | 63 Node* node = current->firstChild(); |
| 64 while (node && !node->isElementNode()) | 64 while (node && !node->isElementNode()) |
| 65 node = node->nextSibling(); | 65 node = node->nextSibling(); |
| 66 return toElement(node); | 66 return toElement(node); |
| 67 } | 67 } |
| 68 inline Element* firstWithin(const ContainerNode* current) { return firstElementW
ithinTemplate(current); } | 68 inline Element* firstWithin(const ContainerNode* current) { return firstElementW
ithinTemplate(current); } |
| 69 inline Element* firstWithin(const Node* current) { return firstElementWithinTemp
late(current); } | 69 inline Element* firstWithin(const Node* current) { return firstElementWithinTemp
late(current); } |
| 70 | 70 |
| 71 template <class NodeType> | 71 template <class NodeType> |
| 72 inline Element* traverseNextElementTemplate(NodeType& current) | 72 inline Element* traverseNextElementTemplate(NodeType& current) |
| 73 { | 73 { |
| 74 Node* node = NodeTraversal::next(current); | 74 Node* node = NodeTraversal::next(current); |
| 75 while (node && !node->isElementNode()) | 75 while (node && !node->isElementNode()) |
| 76 node = NodeTraversal::nextSkippingChildren(node); | 76 node = NodeTraversal::nextSkippingChildren(*node); |
| 77 return toElement(node); | 77 return toElement(node); |
| 78 } | 78 } |
| 79 inline Element* next(const ContainerNode& current) { return traverseNextElementT
emplate(current); } | 79 inline Element* next(const ContainerNode& current) { return traverseNextElementT
emplate(current); } |
| 80 inline Element* next(const Node& current) { return traverseNextElementTemplate(c
urrent); } | 80 inline Element* next(const Node& current) { return traverseNextElementTemplate(c
urrent); } |
| 81 | 81 |
| 82 template <class NodeType> | 82 template <class NodeType> |
| 83 inline Element* traverseNextElementTemplate(NodeType& current, const Node* stayW
ithin) | 83 inline Element* traverseNextElementTemplate(NodeType& current, const Node* stayW
ithin) |
| 84 { | 84 { |
| 85 Node* node = NodeTraversal::next(current, stayWithin); | 85 Node* node = NodeTraversal::next(current, stayWithin); |
| 86 while (node && !node->isElementNode()) | 86 while (node && !node->isElementNode()) |
| 87 node = NodeTraversal::nextSkippingChildren(node, stayWithin); | 87 node = NodeTraversal::nextSkippingChildren(*node, stayWithin); |
| 88 return toElement(node); | 88 return toElement(node); |
| 89 } | 89 } |
| 90 inline Element* next(const ContainerNode& current, const Node* stayWithin) { ret
urn traverseNextElementTemplate(current, stayWithin); } | 90 inline Element* next(const ContainerNode& current, const Node* stayWithin) { ret
urn traverseNextElementTemplate(current, stayWithin); } |
| 91 inline Element* next(const Node& current, const Node* stayWithin) { return trave
rseNextElementTemplate(current, stayWithin); } | 91 inline Element* next(const Node& current, const Node* stayWithin) { return trave
rseNextElementTemplate(current, stayWithin); } |
| 92 | 92 |
| 93 template <class NodeType> | 93 template <class NodeType> |
| 94 inline Element* traverseNextElementSkippingChildrenTemplate(NodeType* current) | 94 inline Element* traverseNextElementSkippingChildrenTemplate(NodeType& current) |
| 95 { | 95 { |
| 96 Node* node = NodeTraversal::nextSkippingChildren(current); | 96 Node* node = NodeTraversal::nextSkippingChildren(current); |
| 97 while (node && !node->isElementNode()) | 97 while (node && !node->isElementNode()) |
| 98 node = NodeTraversal::nextSkippingChildren(node); | 98 node = NodeTraversal::nextSkippingChildren(*node); |
| 99 return toElement(node); | 99 return toElement(node); |
| 100 } | 100 } |
| 101 inline Element* nextSkippingChildren(const ContainerNode* current) { return trav
erseNextElementSkippingChildrenTemplate(current); } | 101 inline Element* nextSkippingChildren(const ContainerNode& current) { return trav
erseNextElementSkippingChildrenTemplate(current); } |
| 102 inline Element* nextSkippingChildren(const Node* current) { return traverseNextE
lementSkippingChildrenTemplate(current); } | 102 inline Element* nextSkippingChildren(const Node& current) { return traverseNextE
lementSkippingChildrenTemplate(current); } |
| 103 | 103 |
| 104 template <class NodeType> | 104 template <class NodeType> |
| 105 inline Element* traverseNextElementSkippingChildrenTemplate(NodeType* current, c
onst Node* stayWithin) | 105 inline Element* traverseNextElementSkippingChildrenTemplate(NodeType& current, c
onst Node* stayWithin) |
| 106 { | 106 { |
| 107 Node* node = NodeTraversal::nextSkippingChildren(current, stayWithin); | 107 Node* node = NodeTraversal::nextSkippingChildren(current, stayWithin); |
| 108 while (node && !node->isElementNode()) | 108 while (node && !node->isElementNode()) |
| 109 node = NodeTraversal::nextSkippingChildren(node, stayWithin); | 109 node = NodeTraversal::nextSkippingChildren(*node, stayWithin); |
| 110 return toElement(node); | 110 return toElement(node); |
| 111 } | 111 } |
| 112 inline Element* nextSkippingChildren(const ContainerNode* current, const Node* s
tayWithin) { return traverseNextElementSkippingChildrenTemplate(current, stayWit
hin); } | 112 inline Element* nextSkippingChildren(const ContainerNode& current, const Node* s
tayWithin) { return traverseNextElementSkippingChildrenTemplate(current, stayWit
hin); } |
| 113 inline Element* nextSkippingChildren(const Node* current, const Node* stayWithin
) { return traverseNextElementSkippingChildrenTemplate(current, stayWithin); } | 113 inline Element* nextSkippingChildren(const Node& current, const Node* stayWithin
) { return traverseNextElementSkippingChildrenTemplate(current, stayWithin); } |
| 114 | 114 |
| 115 inline Element* previousIncludingPseudo(const Node& current, const Node* stayWit
hin) | 115 inline Element* previousIncludingPseudo(const Node& current, const Node* stayWit
hin) |
| 116 { | 116 { |
| 117 Node* node = NodeTraversal::previousIncludingPseudo(current, stayWithin); | 117 Node* node = NodeTraversal::previousIncludingPseudo(current, stayWithin); |
| 118 while (node && !node->isElementNode()) | 118 while (node && !node->isElementNode()) |
| 119 node = NodeTraversal::previousIncludingPseudo(*node, stayWithin); | 119 node = NodeTraversal::previousIncludingPseudo(*node, stayWithin); |
| 120 return toElement(node); | 120 return toElement(node); |
| 121 } | 121 } |
| 122 | 122 |
| 123 inline Element* nextIncludingPseudo(const Node* current, const Node* stayWithin) | 123 inline Element* nextIncludingPseudo(const Node* current, const Node* stayWithin) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 142 while (node && !node->isElementNode()) | 142 while (node && !node->isElementNode()) |
| 143 node = node->pseudoAwarePreviousSibling(); | 143 node = node->pseudoAwarePreviousSibling(); |
| 144 return toElement(node); | 144 return toElement(node); |
| 145 } | 145 } |
| 146 | 146 |
| 147 } | 147 } |
| 148 | 148 |
| 149 } | 149 } |
| 150 | 150 |
| 151 #endif | 151 #endif |
| OLD | NEW |