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

Side by Side Diff: Source/core/dom/shadow/ComposedTreeWalker.cpp

Issue 60203009: ComposedTreeWalker does't have to return a node if an insertion point has no distributed nodes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix compile warnings 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/dom/shadow/composed-shadow-tree-walker-expected.txt ('k') | no next file » | 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 /* 2 /*
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 13 matching lines...) Expand all
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/dom/shadow/ComposedTreeWalker.h" 29 #include "core/dom/shadow/ComposedTreeWalker.h"
30 30
31 #include "core/dom/Element.h" 31 #include "core/dom/Element.h"
32 #include "core/dom/shadow/ElementShadow.h" 32 #include "core/dom/shadow/ElementShadow.h"
33 #include "core/dom/shadow/InsertionPoint.h" 33 #include "core/dom/shadow/InsertionPoint.h"
34 #include "core/html/shadow/HTMLContentElement.h"
34 #include "core/html/shadow/HTMLShadowElement.h" 35 #include "core/html/shadow/HTMLShadowElement.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
38 static inline ElementShadow* shadowFor(const Node* node) 39 static inline ElementShadow* shadowFor(const Node* node)
39 { 40 {
40 if (node && node->isElementNode()) 41 if (node && node->isElementNode())
41 return toElement(node)->shadow(); 42 return toElement(node)->shadow();
42 return 0; 43 return 0;
43 } 44 }
(...skipping 22 matching lines...) Expand all
66 } 67 }
67 68
68 Node* ComposedTreeWalker::traverseNode(const Node* node, TraversalDirection dire ction) 69 Node* ComposedTreeWalker::traverseNode(const Node* node, TraversalDirection dire ction)
69 { 70 {
70 ASSERT(node); 71 ASSERT(node);
71 if (!isActiveInsertionPoint(*node)) 72 if (!isActiveInsertionPoint(*node))
72 return const_cast<Node*>(node); 73 return const_cast<Node*>(node);
73 const InsertionPoint* insertionPoint = toInsertionPoint(node); 74 const InsertionPoint* insertionPoint = toInsertionPoint(node);
74 if (Node* found = traverseDistributedNodes(direction == TraversalDirectionFo rward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direct ion)) 75 if (Node* found = traverseDistributedNodes(direction == TraversalDirectionFo rward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direct ion))
75 return found; 76 return found;
76 return traverseLightChildren(node, direction); 77 ASSERT(isHTMLShadowElement(node) || (isHTMLContentElement(node) && !node->ha sChildNodes()));
78 return 0;
77 } 79 }
78 80
79 Node* ComposedTreeWalker::traverseDistributedNodes(const Node* node, const Inser tionPoint* insertionPoint, TraversalDirection direction) 81 Node* ComposedTreeWalker::traverseDistributedNodes(const Node* node, const Inser tionPoint* insertionPoint, TraversalDirection direction)
80 { 82 {
81 for (const Node* next = node; next; next = (direction == TraversalDirectionF orward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) { 83 for (const Node* next = node; next; next = (direction == TraversalDirectionF orward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) {
82 if (Node* found = traverseNode(next, direction)) 84 if (Node* found = traverseNode(next, direction))
83 return found; 85 return found;
84 } 86 }
85 return 0; 87 return 0;
86 } 88 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ShadowRoot* shadowRoot = toShadowRoot(parent); 158 ShadowRoot* shadowRoot = toShadowRoot(parent);
157 ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot()); 159 ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot());
158 if (!shadowRoot->isYoungest()) 160 if (!shadowRoot->isYoungest())
159 return 0; 161 return 0;
160 if (details) 162 if (details)
161 details->didTraverseShadowRoot(shadowRoot); 163 details->didTraverseShadowRoot(shadowRoot);
162 return shadowRoot->host(); 164 return shadowRoot->host();
163 } 165 }
164 166
165 } // namespace 167 } // namespace
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/shadow/composed-shadow-tree-walker-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698