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

Side by Side Diff: Source/core/dom/shadow/ComposedTreeTraversal.h

Issue 1071863002: Prefer ComposedTreeTraversal to NodeRenderingTraversal. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Composed tree version of |NodeTraversal::previousSkippingChildren()| 78 // Composed tree version of |NodeTraversal::previousSkippingChildren()|
79 // similar to |previous()| but skipping child nodes of the specified node. 79 // similar to |previous()| but skipping child nodes of the specified node.
80 static Node* previousSkippingChildren(const Node&); 80 static Node* previousSkippingChildren(const Node&);
81 81
82 // Composed tree version of |Node::isDescendantOf(other)|. This function 82 // Composed tree version of |Node::isDescendantOf(other)|. This function
83 // returns true if |other| contains |node|, otherwise returns 83 // returns true if |other| contains |node|, otherwise returns
84 // false. If |other| is |node|, this function returns false. 84 // false. If |other| is |node|, this function returns false.
85 static bool isDescendantOf(const Node& /*node*/, const Node& other); 85 static bool isDescendantOf(const Node& /*node*/, const Node& other);
86 86
87 static bool contains(const ContainerNode& container, const Node& node)
88 {
89 assertPrecondition(container);
90 assertPrecondition(node);
91 return container == node || isDescendantOf(node, container);
92 }
93
87 // Returns a common ancestor of |nodeA| and |nodeB| if exists, otherwise 94 // Returns a common ancestor of |nodeA| and |nodeB| if exists, otherwise
88 // returns |nullptr|. 95 // returns |nullptr|.
89 static Node* commonAncestor(const Node& nodeA, const Node& nodeB); 96 static Node* commonAncestor(const Node& nodeA, const Node& nodeB);
90 97
91 // Composed tree version of |Node::nodeIndex()|. This function returns a 98 // Composed tree version of |Node::nodeIndex()|. This function returns a
92 // zero base position number of the specified node in child nodes list, or 99 // zero base position number of the specified node in child nodes list, or
93 // zero if the specified node has no parent. 100 // zero if the specified node has no parent.
94 static unsigned index(const Node&); 101 static unsigned index(const Node&);
95 102
96 // Composed tree version of |ContainerNode::countChildren()|. This function 103 // Composed tree version of |ContainerNode::countChildren()|. This function
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 298 }
292 299
293 inline Node* ComposedTreeTraversal::traverseLastChild(const Node& node) 300 inline Node* ComposedTreeTraversal::traverseLastChild(const Node& node)
294 { 301 {
295 return traverseChild(node, TraversalDirectionBackward); 302 return traverseChild(node, TraversalDirectionBackward);
296 } 303 }
297 304
298 } // namespace 305 } // namespace
299 306
300 #endif 307 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698