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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSlotElement.cpp

Issue 2452473003: Do not use outdated m_distributedNodes of slots in non-shadow trees (Closed)
Patch Set: update Created 4 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 | « third_party/WebKit/Source/core/dom/Node.cpp ('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 * Copyright (C) 2015 Google Inc. All rights reserved. 2 * Copyright (C) 2015 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 child = NodeTraversal::next(*child, this); 90 child = NodeTraversal::next(*child, this);
91 } else { 91 } else {
92 m_distributedNodes.append(child); 92 m_distributedNodes.append(child);
93 child = NodeTraversal::nextSkippingChildren(*child, this); 93 child = NodeTraversal::nextSkippingChildren(*child, this);
94 } 94 }
95 } 95 }
96 } 96 }
97 97
98 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() { 98 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() {
99 DCHECK(!needsDistributionRecalc()); 99 DCHECK(!needsDistributionRecalc());
100 // m_distributedNodes of slots in non-shadow trees are not updated in recalc
101 // distribution flow.
100 if (!supportsDistribution()) 102 if (!supportsDistribution())
101 updateDistributedNodesManually(); 103 updateDistributedNodesManually();
102 return m_distributedNodes; 104 return m_distributedNodes;
103 } 105 }
104 106
105 void HTMLSlotElement::appendAssignedNode(Node& hostChild) { 107 void HTMLSlotElement::appendAssignedNode(Node& hostChild) {
106 DCHECK(hostChild.isSlotable()); 108 DCHECK(hostChild.isSlotable());
107 m_assignedNodes.append(&hostChild); 109 m_assignedNodes.append(&hostChild);
108 } 110 }
109 111
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (index == 0) 173 if (index == 0)
172 return nullptr; 174 return nullptr;
173 return m_distributedNodes[index - 1].get(); 175 return m_distributedNodes[index - 1].get();
174 } 176 }
175 177
176 AtomicString HTMLSlotElement::name() const { 178 AtomicString HTMLSlotElement::name() const {
177 return normalizeSlotName(fastGetAttribute(HTMLNames::nameAttr)); 179 return normalizeSlotName(fastGetAttribute(HTMLNames::nameAttr));
178 } 180 }
179 181
180 void HTMLSlotElement::attachLayoutTree(const AttachContext& context) { 182 void HTMLSlotElement::attachLayoutTree(const AttachContext& context) {
181 for (auto& node : m_distributedNodes) { 183 for (auto& node : getDistributedNodes()) {
182 if (node->needsAttach()) 184 if (node->needsAttach())
183 node->attachLayoutTree(context); 185 node->attachLayoutTree(context);
184 } 186 }
185 187
186 HTMLElement::attachLayoutTree(context); 188 HTMLElement::attachLayoutTree(context);
187 } 189 }
188 190
189 void HTMLSlotElement::detachLayoutTree(const AttachContext& context) { 191 void HTMLSlotElement::detachLayoutTree(const AttachContext& context) {
190 for (auto& node : m_distributedNodes) 192 for (auto& node : m_distributedNodes)
191 node->lazyReattachIfAttached(); 193 node->lazyReattachIfAttached();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 312 }
311 313
312 void HTMLSlotElement::enqueueSlotChangeEvent() { 314 void HTMLSlotElement::enqueueSlotChangeEvent() {
313 if (!m_slotchangeEventEnqueued) { 315 if (!m_slotchangeEventEnqueued) {
314 Microtask::enqueueMicrotask(WTF::bind( 316 Microtask::enqueueMicrotask(WTF::bind(
315 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this))); 317 &HTMLSlotElement::dispatchSlotChangeEvent, wrapPersistent(this)));
316 m_slotchangeEventEnqueued = true; 318 m_slotchangeEventEnqueued = true;
317 } 319 }
318 320
319 ShadowRoot* root = containingShadowRoot(); 321 ShadowRoot* root = containingShadowRoot();
322 // TODO(hayato): Relax this check if slots in non-shadow trees are well
323 // supported.
320 DCHECK(root); 324 DCHECK(root);
321 DCHECK(root->isV1()); 325 DCHECK(root->isV1());
322 root->owner()->setNeedsDistributionRecalc(); 326 root->owner()->setNeedsDistributionRecalc();
323 // Check slotchange recursively since this slotchange may cause another 327 // Check slotchange recursively since this slotchange may cause another
324 // slotchange. 328 // slotchange.
325 checkSlotChange(); 329 checkSlotChange();
326 } 330 }
327 331
328 bool HTMLSlotElement::hasAssignedNodesSlow() const { 332 bool HTMLSlotElement::hasAssignedNodesSlow() const {
329 ShadowRoot* root = containingShadowRoot(); 333 ShadowRoot* root = containingShadowRoot();
(...skipping 19 matching lines...) Expand all
349 353
350 DEFINE_TRACE(HTMLSlotElement) { 354 DEFINE_TRACE(HTMLSlotElement) {
351 visitor->trace(m_assignedNodes); 355 visitor->trace(m_assignedNodes);
352 visitor->trace(m_distributedNodes); 356 visitor->trace(m_distributedNodes);
353 visitor->trace(m_oldDistributedNodes); 357 visitor->trace(m_oldDistributedNodes);
354 visitor->trace(m_distributedIndices); 358 visitor->trace(m_distributedIndices);
355 HTMLElement::trace(visitor); 359 HTMLElement::trace(visitor);
356 } 360 }
357 361
358 } // namespace blink 362 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698