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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/ComposedTreeTraversal.cpp

Issue 1649983003: Remove the forced layout in getComputedStyle for elements in Shadow DOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Look at ShadowRoots when walking up the tree in updateLayoutTreeForNodeIfNeeded. Created 4 years, 10 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
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ContainerNode* ComposedTreeTraversal::traverseParent(const Node& node, ParentTra versalDetails* details) 148 ContainerNode* ComposedTreeTraversal::traverseParent(const Node& node, ParentTra versalDetails* details)
149 { 149 {
150 // TODO(hayato): Stop this hack for a pseudo element because a pseudo elemen t is not a child of its parentOrShadowHostNode() in a composed tree. 150 // TODO(hayato): Stop this hack for a pseudo element because a pseudo elemen t is not a child of its parentOrShadowHostNode() in a composed tree.
151 if (node.isPseudoElement()) 151 if (node.isPseudoElement())
152 return node.parentOrShadowHostNode(); 152 return node.parentOrShadowHostNode();
153 153
154 if (node.isChildOfV1ShadowHost()) { 154 if (node.isChildOfV1ShadowHost()) {
155 HTMLSlotElement* slot = finalDestinationSlotFor(node); 155 HTMLSlotElement* slot = finalDestinationSlotFor(node);
156 if (!slot) 156 if (!slot)
157 return nullptr; 157 return nullptr;
158 return traverseParent(*slot); 158 return traverseParent(*slot, details);
159 } 159 }
160 160
161 Element* parent = node.parentElement(); 161 Element* parent = node.parentElement();
162 if (parent && isHTMLSlotElement(parent)) { 162 if (parent && isHTMLSlotElement(parent)) {
163 HTMLSlotElement& slot = toHTMLSlotElement(*parent); 163 HTMLSlotElement& slot = toHTMLSlotElement(*parent);
164 if (!slot.getAssignedNodes().isEmpty()) 164 if (!slot.getAssignedNodes().isEmpty())
165 return nullptr; 165 return nullptr;
166 return traverseParent(slot, details); 166 return traverseParent(slot, details);
167 } 167 }
168 168
169 if (canBeDistributedToInsertionPoint(node)) 169 if (canBeDistributedToInsertionPoint(node))
170 return traverseParentForV0(node, details); 170 return traverseParentForV0(node, details);
171 171
172 ASSERT(!shadowWhereNodeCanBeDistributed(node)); 172 ASSERT(!shadowWhereNodeCanBeDistributed(node));
173 return traverseParentOrHost(node); 173 return traverseParentOrHost(node, details);
174 } 174 }
175 175
176 ContainerNode* ComposedTreeTraversal::traverseParentForV0(const Node& node, Pare ntTraversalDetails* details) 176 ContainerNode* ComposedTreeTraversal::traverseParentForV0(const Node& node, Pare ntTraversalDetails* details)
177 { 177 {
178 if (shadowWhereNodeCanBeDistributed(node)) { 178 if (shadowWhereNodeCanBeDistributed(node)) {
179 if (const InsertionPoint* insertionPoint = resolveReprojection(&node)) { 179 if (const InsertionPoint* insertionPoint = resolveReprojection(&node)) {
180 if (details) 180 if (details)
181 details->didTraverseInsertionPoint(insertionPoint); 181 details->didTraverseInsertionPoint();
182 // The node is distributed. But the distribution was stopped at this insertion point. 182 // The node is distributed. But the distribution was stopped at this insertion point.
183 if (shadowWhereNodeCanBeDistributed(*insertionPoint)) 183 if (shadowWhereNodeCanBeDistributed(*insertionPoint))
184 return nullptr; 184 return nullptr;
185 return traverseParent(*insertionPoint); 185 return traverseParent(*insertionPoint, details);
186 } 186 }
187 return nullptr; 187 return nullptr;
188 } 188 }
189 ContainerNode* parent = traverseParentOrHost(node); 189 ContainerNode* parent = traverseParentOrHost(node, details);
190 if (isActiveInsertionPoint(*parent)) 190 if (isActiveInsertionPoint(*parent))
191 return nullptr; 191 return nullptr;
192 return parent; 192 return parent;
193 } 193 }
194 194
195 ContainerNode* ComposedTreeTraversal::traverseParentOrHost(const Node& node) 195 ContainerNode* ComposedTreeTraversal::traverseParentOrHost(const Node& node, Par entTraversalDetails* details)
196 { 196 {
197 ContainerNode* parent = node.parentNode(); 197 ContainerNode* parent = node.parentNode();
198 if (!parent) 198 if (!parent)
199 return nullptr; 199 return nullptr;
200 if (!parent->isShadowRoot()) 200 if (!parent->isShadowRoot())
201 return parent; 201 return parent;
202 ShadowRoot* shadowRoot = toShadowRoot(parent); 202 ShadowRoot* shadowRoot = toShadowRoot(parent);
203 if (details)
204 details->didTraverseShadowRoot(shadowRoot);
203 ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot()); 205 ASSERT(!shadowRoot->shadowInsertionPointOfYoungerShadowRoot());
204 if (!shadowRoot->isYoungest()) 206 if (!shadowRoot->isYoungest())
205 return nullptr; 207 return nullptr;
206 return shadowRoot->host(); 208 return shadowRoot->host();
207 } 209 }
208 210
209 Node* ComposedTreeTraversal::childAt(const Node& node, unsigned index) 211 Node* ComposedTreeTraversal::childAt(const Node& node, unsigned index)
210 { 212 {
211 assertPrecondition(node); 213 assertPrecondition(node);
212 Node* child = traverseFirstChild(node); 214 Node* child = traverseFirstChild(node);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 Node& ComposedTreeTraversal::lastWithinOrSelf(const Node& node) 354 Node& ComposedTreeTraversal::lastWithinOrSelf(const Node& node)
353 { 355 {
354 assertPrecondition(node); 356 assertPrecondition(node);
355 Node* lastDescendant = lastWithin(node); 357 Node* lastDescendant = lastWithin(node);
356 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node); 358 Node& result = lastDescendant ? *lastDescendant : const_cast<Node&>(node);
357 assertPostcondition(&result); 359 assertPostcondition(&result);
358 return result; 360 return result;
359 } 361 }
360 362
361 } // namespace blink 363 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698