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

Side by Side Diff: sky/engine/core/dom/shadow/ComposedTreeWalker.cpp

Issue 704413007: Remove HTMLShadowElement. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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 | « sky/engine/core/core.gni ('k') | sky/engine/core/dom/shadow/ElementShadow.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 /* 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 12 matching lines...) Expand all
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/html/HTMLShadowElement.h"
34 33
35 namespace blink { 34 namespace blink {
36 35
37 static inline ElementShadow* shadowFor(const Node* node) 36 static inline ElementShadow* shadowFor(const Node* node)
38 { 37 {
39 if (node && node->isElementNode()) 38 if (node && node->isElementNode())
40 return toElement(node)->shadow(); 39 return toElement(node)->shadow();
41 return 0; 40 return 0;
42 } 41 }
43 42
(...skipping 21 matching lines...) Expand all
65 } 64 }
66 65
67 Node* ComposedTreeWalker::traverseNode(const Node* node, TraversalDirection dire ction) 66 Node* ComposedTreeWalker::traverseNode(const Node* node, TraversalDirection dire ction)
68 { 67 {
69 ASSERT(node); 68 ASSERT(node);
70 if (!isActiveInsertionPoint(*node)) 69 if (!isActiveInsertionPoint(*node))
71 return const_cast<Node*>(node); 70 return const_cast<Node*>(node);
72 const InsertionPoint* insertionPoint = toInsertionPoint(node); 71 const InsertionPoint* insertionPoint = toInsertionPoint(node);
73 if (Node* found = traverseDistributedNodes(direction == TraversalDirectionFo rward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direct ion)) 72 if (Node* found = traverseDistributedNodes(direction == TraversalDirectionFo rward ? insertionPoint->first() : insertionPoint->last(), insertionPoint, direct ion))
74 return found; 73 return found;
75 ASSERT(isHTMLShadowElement(node) || (isHTMLContentElement(node) && !node->ha sChildren())); 74 ASSERT(isHTMLContentElement(node) && !node->hasChildren());
76 return 0; 75 return 0;
77 } 76 }
78 77
79 Node* ComposedTreeWalker::traverseDistributedNodes(const Node* node, const Inser tionPoint* insertionPoint, TraversalDirection direction) 78 Node* ComposedTreeWalker::traverseDistributedNodes(const Node* node, const Inser tionPoint* insertionPoint, TraversalDirection direction)
80 { 79 {
81 for (const Node* next = node; next; next = (direction == TraversalDirectionF orward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) { 80 for (const Node* next = node; next; next = (direction == TraversalDirectionF orward ? insertionPoint->nextTo(next) : insertionPoint->previousTo(next))) {
82 if (Node* found = traverseNode(next, direction)) 81 if (Node* found = traverseNode(next, direction))
83 return found; 82 return found;
84 } 83 }
85 return 0; 84 return 0;
(...skipping 20 matching lines...) Expand all
106 ASSERT(node); 105 ASSERT(node);
107 if (Node* found = traverseSiblings(direction == TraversalDirectionForward ? node->nextSibling() : node->previousSibling(), direction)) 106 if (Node* found = traverseSiblings(direction == TraversalDirectionForward ? node->nextSibling() : node->previousSibling(), direction))
108 return found; 107 return found;
109 if (Node* next = traverseBackToYoungerShadowRoot(node, direction)) 108 if (Node* next = traverseBackToYoungerShadowRoot(node, direction))
110 return next; 109 return next;
111 return 0; 110 return 0;
112 } 111 }
113 112
114 Node* ComposedTreeWalker::traverseBackToYoungerShadowRoot(const Node* node, Trav ersalDirection direction) 113 Node* ComposedTreeWalker::traverseBackToYoungerShadowRoot(const Node* node, Trav ersalDirection direction)
115 { 114 {
116 ASSERT(node); 115 // FIXME(sky): Remove this.
117 if (node->parentNode() && node->parentNode()->isShadowRoot()) {
118 ShadowRoot* parentShadowRoot = toShadowRoot(node->parentNode());
119 if (!parentShadowRoot->isYoungest()) {
120 HTMLShadowElement* assignedInsertionPoint = parentShadowRoot->shadow InsertionPointOfYoungerShadowRoot();
121 ASSERT(assignedInsertionPoint);
122 return traverseSiblingInCurrentTree(assignedInsertionPoint, directio n);
123 }
124 }
125 return 0; 116 return 0;
126 } 117 }
127 118
128 // FIXME: Use an iterative algorithm so that it can be inlined. 119 // FIXME: Use an iterative algorithm so that it can be inlined.
129 // https://bugs.webkit.org/show_bug.cgi?id=90415 120 // https://bugs.webkit.org/show_bug.cgi?id=90415
130 Node* ComposedTreeWalker::traverseParent(const Node* node, ParentTraversalDetail s* details) const 121 Node* ComposedTreeWalker::traverseParent(const Node* node, ParentTraversalDetail s* details) const
131 { 122 {
132 if (shadowWhereNodeCanBeDistributed(*node)) { 123 if (shadowWhereNodeCanBeDistributed(*node)) {
133 if (const InsertionPoint* insertionPoint = resolveReprojection(node)) { 124 if (const InsertionPoint* insertionPoint = resolveReprojection(node)) {
134 if (details) 125 if (details)
135 details->didTraverseInsertionPoint(insertionPoint); 126 details->didTraverseInsertionPoint(insertionPoint);
136 // The node is distributed. But the distribution was stopped at this insertion point. 127 // The node is distributed. But the distribution was stopped at this insertion point.
137 if (shadowWhereNodeCanBeDistributed(*insertionPoint)) 128 if (shadowWhereNodeCanBeDistributed(*insertionPoint))
138 return 0; 129 return 0;
139 return traverseParentOrHost(insertionPoint); 130 return traverseParentOrHost(insertionPoint);
140 } 131 }
141 return 0; 132 return 0;
142 } 133 }
143 return traverseParentOrHost(node); 134 return traverseParentOrHost(node);
144 } 135 }
145 136
146 inline Node* ComposedTreeWalker::traverseParentOrHost(const Node* node) const 137 inline Node* ComposedTreeWalker::traverseParentOrHost(const Node* node) const
147 { 138 {
148 Node* parent = node->parentNode(); 139 Node* parent = node->parentNode();
149 if (!parent) 140 if (!parent)
150 return 0; 141 return 0;
151 if (!parent->isShadowRoot()) 142 if (!parent->isShadowRoot())
152 return parent; 143 return parent;
153 ShadowRoot* shadowRoot = toShadowRoot(parent); 144 ShadowRoot* shadowRoot = toShadowRoot(parent);
154 ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot());
155 if (!shadowRoot->isYoungest()) 145 if (!shadowRoot->isYoungest())
156 return 0; 146 return 0;
157 return shadowRoot->host(); 147 return shadowRoot->host();
158 } 148 }
159 149
160 } // namespace 150 } // namespace
OLDNEW
« no previous file with comments | « sky/engine/core/core.gni ('k') | sky/engine/core/dom/shadow/ElementShadow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698