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

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

Issue 428533006: Use ContainerNode::hasChildren() instead of firstChild() in conditionals (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: build fix Created 6 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/dom/Position.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 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 7 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 private: 69 private:
70 template <class NodeType> 70 template <class NodeType>
71 static Node* traverseNextTemplate(NodeType&); 71 static Node* traverseNextTemplate(NodeType&);
72 template <class NodeType> 72 template <class NodeType>
73 static Node* traverseNextTemplate(NodeType&, const Node* stayWithin); 73 static Node* traverseNextTemplate(NodeType&, const Node* stayWithin);
74 }; 74 };
75 75
76 template <class NodeType> 76 template <class NodeType>
77 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current) 77 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current)
78 { 78 {
79 if (current.firstChild()) 79 if (current.hasChildren())
80 return current.firstChild(); 80 return current.firstChild();
81 if (current.nextSibling()) 81 if (current.nextSibling())
82 return current.nextSibling(); 82 return current.nextSibling();
83 return nextAncestorSibling(current); 83 return nextAncestorSibling(current);
84 } 84 }
85 85
86 template <class NodeType> 86 template <class NodeType>
87 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current, const Node* stayWithin) 87 inline Node* NodeTraversal::traverseNextTemplate(NodeType& current, const Node* stayWithin)
88 { 88 {
89 if (current.firstChild()) 89 if (current.hasChildren())
90 return current.firstChild(); 90 return current.firstChild();
91 if (current == stayWithin) 91 if (current == stayWithin)
92 return 0; 92 return 0;
93 if (current.nextSibling()) 93 if (current.nextSibling())
94 return current.nextSibling(); 94 return current.nextSibling();
95 return nextAncestorSibling(current, stayWithin); 95 return nextAncestorSibling(current, stayWithin);
96 } 96 }
97 97
98 inline Node* NodeTraversal::nextSkippingChildren(const Node& current) 98 inline Node* NodeTraversal::nextSkippingChildren(const Node& current)
99 { 99 {
100 if (current.nextSibling()) 100 if (current.nextSibling())
101 return current.nextSibling(); 101 return current.nextSibling();
102 return nextAncestorSibling(current); 102 return nextAncestorSibling(current);
103 } 103 }
104 104
105 inline Node* NodeTraversal::nextSkippingChildren(const Node& current, const Node * stayWithin) 105 inline Node* NodeTraversal::nextSkippingChildren(const Node& current, const Node * stayWithin)
106 { 106 {
107 if (current == stayWithin) 107 if (current == stayWithin)
108 return 0; 108 return 0;
109 if (current.nextSibling()) 109 if (current.nextSibling())
110 return current.nextSibling(); 110 return current.nextSibling();
111 return nextAncestorSibling(current, stayWithin); 111 return nextAncestorSibling(current, stayWithin);
112 } 112 }
113 113
114 } // namespace blink 114 } // namespace blink
115 115
116 #endif 116 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/dom/Position.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698