| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |