Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: Source/core/dom/ElementTraversal.h

Issue 68523014: Update remaining NodeTraversal / ElementTraversal methods to take references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix build Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/core/dom/Node.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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())
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)
124 { 124 {
125 Node* node = NodeTraversal::nextIncludingPseudo(current, stayWithin); 125 Node* node = NodeTraversal::nextIncludingPseudo(current, stayWithin);
126 while (node && !node->isElementNode()) 126 while (node && !node->isElementNode())
127 node = NodeTraversal::nextIncludingPseudo(node, stayWithin); 127 node = NodeTraversal::nextIncludingPseudo(*node, stayWithin);
128 return toElement(node); 128 return toElement(node);
129 } 129 }
130 130
131 inline Element* nextIncludingPseudoSkippingChildren(const Node* current, const N ode* stayWithin) 131 inline Element* nextIncludingPseudoSkippingChildren(const Node& current, const N ode* stayWithin)
132 { 132 {
133 Node* node = NodeTraversal::nextIncludingPseudoSkippingChildren(current, sta yWithin); 133 Node* node = NodeTraversal::nextIncludingPseudoSkippingChildren(current, sta yWithin);
134 while (node && !node->isElementNode()) 134 while (node && !node->isElementNode())
135 node = NodeTraversal::nextIncludingPseudoSkippingChildren(node, stayWith in); 135 node = NodeTraversal::nextIncludingPseudoSkippingChildren(*node, stayWit hin);
136 return toElement(node); 136 return toElement(node);
137 } 137 }
138 138
139 inline Element* pseudoAwarePreviousSibling(const Node& current) 139 inline Element* pseudoAwarePreviousSibling(const Node& current)
140 { 140 {
141 Node* node = current.pseudoAwarePreviousSibling(); 141 Node* node = current.pseudoAwarePreviousSibling();
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
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698