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

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

Issue 69543007: Have NodeTraversal::nextSkippingChildren() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on master 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 | « Source/core/dom/ElementTraversal.h ('k') | Source/core/dom/NodeTraversal.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // Like previous/previousSkippingChildren, but visits parents before their child ren. 58 // Like previous/previousSkippingChildren, but visits parents before their child ren.
59 Node* previousPostOrder(const Node&, const Node* stayWithin = 0); 59 Node* previousPostOrder(const Node&, const Node* stayWithin = 0);
60 Node* previousSkippingChildrenPostOrder(const Node&, const Node* stayWithin = 0) ; 60 Node* previousSkippingChildrenPostOrder(const Node&, const Node* stayWithin = 0) ;
61 61
62 // Pre-order traversal including the pseudo-elements. 62 // Pre-order traversal including the pseudo-elements.
63 Node* previousIncludingPseudo(const Node&, const Node* stayWithin = 0); 63 Node* previousIncludingPseudo(const Node&, const Node* stayWithin = 0);
64 Node* nextIncludingPseudo(const Node*, const Node* stayWithin = 0); 64 Node* nextIncludingPseudo(const Node*, const Node* stayWithin = 0);
65 Node* nextIncludingPseudoSkippingChildren(const Node*, const Node* stayWithin = 0); 65 Node* nextIncludingPseudoSkippingChildren(const Node*, const Node* stayWithin = 0);
66 66
67 Node* nextAncestorSibling(const Node*); 67 Node* nextAncestorSibling(const Node&);
68 Node* nextAncestorSibling(const Node*, const Node* stayWithin); 68 Node* nextAncestorSibling(const Node&, const Node* stayWithin);
69 69
70 template <class NodeType> 70 template <class NodeType>
71 inline Node* traverseNextTemplate(NodeType& current) 71 inline Node* traverseNextTemplate(NodeType& current)
72 { 72 {
73 if (current.firstChild()) 73 if (current.firstChild())
74 return current.firstChild(); 74 return current.firstChild();
75 if (current.nextSibling()) 75 if (current.nextSibling())
76 return current.nextSibling(); 76 return current.nextSibling();
77 return nextAncestorSibling(&current); 77 return nextAncestorSibling(current);
78 } 78 }
79 inline Node* next(const Node& current) { return traverseNextTemplate(current); } 79 inline Node* next(const Node& current) { return traverseNextTemplate(current); }
80 inline Node* next(const ContainerNode& current) { return traverseNextTemplate(cu rrent); } 80 inline Node* next(const ContainerNode& current) { return traverseNextTemplate(cu rrent); }
81 81
82 template <class NodeType> 82 template <class NodeType>
83 inline Node* traverseNextTemplate(NodeType& current, const Node* stayWithin) 83 inline Node* traverseNextTemplate(NodeType& current, const Node* stayWithin)
84 { 84 {
85 if (current.firstChild()) 85 if (current.firstChild())
86 return current.firstChild(); 86 return current.firstChild();
87 if (current == stayWithin) 87 if (current == stayWithin)
88 return 0; 88 return 0;
89 if (current.nextSibling()) 89 if (current.nextSibling())
90 return current.nextSibling(); 90 return current.nextSibling();
91 return nextAncestorSibling(&current, stayWithin); 91 return nextAncestorSibling(current, stayWithin);
92 } 92 }
93 inline Node* next(const Node& current, const Node* stayWithin) { return traverse NextTemplate(current, stayWithin); } 93 inline Node* next(const Node& current, const Node* stayWithin) { return traverse NextTemplate(current, stayWithin); }
94 inline Node* next(const ContainerNode& current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); } 94 inline Node* next(const ContainerNode& current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); }
95 95
96 template <class NodeType> 96 template <class NodeType>
97 inline Node* traverseNextSkippingChildrenTemplate(NodeType* current) 97 inline Node* traverseNextSkippingChildrenTemplate(NodeType& current)
98 { 98 {
99 if (current->nextSibling()) 99 if (current.nextSibling())
100 return current->nextSibling(); 100 return current.nextSibling();
101 return nextAncestorSibling(current); 101 return nextAncestorSibling(current);
102 } 102 }
103 inline Node* nextSkippingChildren(const Node* current) { return traverseNextSkip pingChildrenTemplate(current); } 103 inline Node* nextSkippingChildren(const Node& current) { return traverseNextSkip pingChildrenTemplate(current); }
104 inline Node* nextSkippingChildren(const ContainerNode* current) { return travers eNextSkippingChildrenTemplate(current); } 104 inline Node* nextSkippingChildren(const ContainerNode& current) { return travers eNextSkippingChildrenTemplate(current); }
105 105
106 template <class NodeType> 106 template <class NodeType>
107 inline Node* traverseNextSkippingChildrenTemplate(NodeType* current, const Node* stayWithin) 107 inline Node* traverseNextSkippingChildrenTemplate(NodeType& current, const Node* stayWithin)
108 { 108 {
109 if (current == stayWithin) 109 if (current == stayWithin)
110 return 0; 110 return 0;
111 if (current->nextSibling()) 111 if (current.nextSibling())
112 return current->nextSibling(); 112 return current.nextSibling();
113 return nextAncestorSibling(current, stayWithin); 113 return nextAncestorSibling(current, stayWithin);
114 } 114 }
115 inline Node* nextSkippingChildren(const Node* current, const Node* stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin); } 115 inline Node* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
116 inline Node* nextSkippingChildren(const ContainerNode* current, const Node* stay Within) { return traverseNextSkippingChildrenTemplate(current, stayWithin); } 116 inline Node* nextSkippingChildren(const ContainerNode& current, const Node* stay Within) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
117 117
118 } 118 }
119 119
120 } 120 }
121 121
122 #endif 122 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/ElementTraversal.h ('k') | Source/core/dom/NodeTraversal.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698