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

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

Issue 133993004: Fix mac bot specific performance regression by reverting set of patches (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/dom/Node.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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #ifndef NodeTraversal_h 25 #ifndef NodeTraversal_h
26 #define NodeTraversal_h 26 #define NodeTraversal_h
27 27
28 #include "core/dom/Node.h" 28 #include "core/dom/Node.h"
29 #include "wtf/TreeNode.h"
30 29
31 namespace WebCore { 30 namespace WebCore {
32 31
33 namespace NodeTraversal { 32 namespace NodeTraversal {
34 33
35 // Does a pre-order traversal of the tree to find the next node after this one. 34 // Does a pre-order traversal of the tree to find the next node after this one.
36 // This uses the same order that tags appear in the source file. If the stayWith in 35 // This uses the same order that tags appear in the source file. If the stayWith in
37 // argument is non-null, the traversal will stop once the specified node is reac hed. 36 // argument is non-null, the traversal will stop once the specified node is reac hed.
38 // This can be used to restrict traversal to a particular sub-tree. 37 // This can be used to restrict traversal to a particular sub-tree.
39 Node* next(const Node&); 38 Node* next(const Node&);
(...skipping 17 matching lines...) Expand all
57 Node* nextPostOrder(const Node&, const Node* stayWithin = 0); 56 Node* nextPostOrder(const Node&, const Node* stayWithin = 0);
58 57
59 // Like previous, but visits parents before their children. 58 // Like previous, but visits parents before their children.
60 Node* previousPostOrder(const Node&, const Node* stayWithin = 0); 59 Node* previousPostOrder(const Node&, const Node* stayWithin = 0);
61 60
62 // Pre-order traversal including the pseudo-elements. 61 // Pre-order traversal including the pseudo-elements.
63 Node* previousIncludingPseudo(const Node&, const Node* stayWithin = 0); 62 Node* previousIncludingPseudo(const Node&, const Node* stayWithin = 0);
64 Node* nextIncludingPseudo(const Node&, const Node* stayWithin = 0); 63 Node* nextIncludingPseudo(const Node&, const Node* stayWithin = 0);
65 Node* nextIncludingPseudoSkippingChildren(const Node&, const Node* stayWithin = 0); 64 Node* nextIncludingPseudoSkippingChildren(const Node&, const Node* stayWithin = 0);
66 65
67 inline Node* next(const Node& current) { return traverseNext<Node>(current); } 66 Node* nextAncestorSibling(const Node&);
68 inline Node* next(const ContainerNode& current) { return traverseNext<Node, Cont ainerNode>(current); } 67 Node* nextAncestorSibling(const Node&, const Node* stayWithin);
69 68
70 inline Node* next(const Node& current, const Node* stayWithin) { return traverse Next<Node>(current, stayWithin); } 69 template <class NodeType>
71 inline Node* next(const ContainerNode& current, const Node* stayWithin) { return traverseNext<Node, ContainerNode>(current, stayWithin); } 70 inline Node* traverseNextTemplate(NodeType& current)
71 {
72 if (current.firstChild())
73 return current.firstChild();
74 if (current.nextSibling())
75 return current.nextSibling();
76 return nextAncestorSibling(current);
77 }
78 inline Node* next(const Node& current) { return traverseNextTemplate(current); }
79 inline Node* next(const ContainerNode& current) { return traverseNextTemplate(cu rrent); }
72 80
73 inline Node* nextSkippingChildren(const Node& current) { return traverseNextSkip pingChildren<Node>(current); } 81 template <class NodeType>
74 inline Node* nextSkippingChildren(const ContainerNode& current) { return travers eNextSkippingChildren<Node, ContainerNode>(current); } 82 inline Node* traverseNextTemplate(NodeType& current, const Node* stayWithin)
83 {
84 if (current.firstChild())
85 return current.firstChild();
86 if (current == stayWithin)
87 return 0;
88 if (current.nextSibling())
89 return current.nextSibling();
90 return nextAncestorSibling(current, stayWithin);
91 }
92 inline Node* next(const Node& current, const Node* stayWithin) { return traverse NextTemplate(current, stayWithin); }
93 inline Node* next(const ContainerNode& current, const Node* stayWithin) { return traverseNextTemplate(current, stayWithin); }
75 94
76 inline Node* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextSkippingChildren<Node>(current, stayWithin); } 95 template <class NodeType>
77 inline Node* nextSkippingChildren(const ContainerNode& current, const Node* stay Within) { return traverseNextSkippingChildren<Node, ContainerNode>(current, stay Within); } 96 inline Node* traverseNextSkippingChildrenTemplate(NodeType& current)
97 {
98 if (current.nextSibling())
99 return current.nextSibling();
100 return nextAncestorSibling(current);
101 }
102 inline Node* nextSkippingChildren(const Node& current) { return traverseNextSkip pingChildrenTemplate(current); }
103 inline Node* nextSkippingChildren(const ContainerNode& current) { return travers eNextSkippingChildrenTemplate(current); }
104
105 template <class NodeType>
106 inline Node* traverseNextSkippingChildrenTemplate(NodeType& current, const Node* stayWithin)
107 {
108 if (current == stayWithin)
109 return 0;
110 if (current.nextSibling())
111 return current.nextSibling();
112 return nextAncestorSibling(current, stayWithin);
113 }
114 inline Node* nextSkippingChildren(const Node& current, const Node* stayWithin) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
115 inline Node* nextSkippingChildren(const ContainerNode& current, const Node* stay Within) { return traverseNextSkippingChildrenTemplate(current, stayWithin); }
78 116
79 } 117 }
80 118
81 } 119 }
82 120
83 #endif 121 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/NodeTraversal.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698