| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 const HeapVector<Member<Node>> HTMLSlotElement::assignedNodesForBinding( | 67 const HeapVector<Member<Node>> HTMLSlotElement::assignedNodesForBinding( |
| 68 const AssignedNodesOptions& options) { | 68 const AssignedNodesOptions& options) { |
| 69 updateDistribution(); | 69 updateDistribution(); |
| 70 if (options.hasFlatten() && options.flatten()) | 70 if (options.hasFlatten() && options.flatten()) |
| 71 return getDistributedNodes(); | 71 return getDistributedNodes(); |
| 72 return m_assignedNodes; | 72 return m_assignedNodes; |
| 73 } | 73 } |
| 74 | 74 |
| 75 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() { | 75 void HTMLSlotElement::updateDistributedNodesManually() { |
| 76 DCHECK(!needsDistributionRecalc()); | 76 DCHECK(!supportsDistribution()); |
| 77 if (isInShadowTree()) | |
| 78 return m_distributedNodes; | |
| 79 | |
| 80 // A slot is unlikely to be used outside of a shadow tree. | 77 // A slot is unlikely to be used outside of a shadow tree. |
| 81 // We do not need to optimize this case in most cases. | 78 // We do not need to optimize this case in most cases. |
| 82 // TODO(hayato): If this path causes a performance issue, we should move | 79 // TODO(hayato): If this path causes a performance issue, we should move |
| 83 // ShadowRoot::m_slotAssignment into TreeScopreRareData-ish and | 80 // ShadowRoot::m_slotAssignment into TreeScopreRareData-ish and |
| 84 // update the distribution code so it considers a document tree too. | 81 // update the distribution code so it considers a document tree too. |
| 85 clearDistribution(); | 82 clearDistribution(); |
| 86 Node* child = NodeTraversal::firstChild(*this); | 83 Node* child = NodeTraversal::firstChild(*this); |
| 87 while (child) { | 84 while (child) { |
| 88 if (!child->isSlotable()) { | 85 if (!child->isSlotable()) { |
| 89 child = NodeTraversal::nextSkippingChildren(*child, this); | 86 child = NodeTraversal::nextSkippingChildren(*child, this); |
| 90 continue; | 87 continue; |
| 91 } | 88 } |
| 92 if (isHTMLSlotElement(child)) { | 89 if (isHTMLSlotElement(child)) { |
| 93 child = NodeTraversal::next(*child, this); | 90 child = NodeTraversal::next(*child, this); |
| 94 } else { | 91 } else { |
| 95 m_distributedNodes.append(child); | 92 m_distributedNodes.append(child); |
| 96 child = NodeTraversal::nextSkippingChildren(*child, this); | 93 child = NodeTraversal::nextSkippingChildren(*child, this); |
| 97 } | 94 } |
| 98 } | 95 } |
| 96 } |
| 97 |
| 98 const HeapVector<Member<Node>>& HTMLSlotElement::getDistributedNodes() { |
| 99 DCHECK(!needsDistributionRecalc()); |
| 100 if (!supportsDistribution()) |
| 101 updateDistributedNodesManually(); |
| 99 return m_distributedNodes; | 102 return m_distributedNodes; |
| 100 } | 103 } |
| 101 | 104 |
| 102 void HTMLSlotElement::appendAssignedNode(Node& hostChild) { | 105 void HTMLSlotElement::appendAssignedNode(Node& hostChild) { |
| 103 DCHECK(hostChild.isSlotable()); | 106 DCHECK(hostChild.isSlotable()); |
| 104 m_assignedNodes.append(&hostChild); | 107 m_assignedNodes.append(&hostChild); |
| 105 } | 108 } |
| 106 | 109 |
| 107 void HTMLSlotElement::resolveDistributedNodes() { | 110 void HTMLSlotElement::resolveDistributedNodes() { |
| 108 for (auto& node : m_assignedNodes) { | 111 for (auto& node : m_assignedNodes) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 349 |
| 347 DEFINE_TRACE(HTMLSlotElement) { | 350 DEFINE_TRACE(HTMLSlotElement) { |
| 348 visitor->trace(m_assignedNodes); | 351 visitor->trace(m_assignedNodes); |
| 349 visitor->trace(m_distributedNodes); | 352 visitor->trace(m_distributedNodes); |
| 350 visitor->trace(m_oldDistributedNodes); | 353 visitor->trace(m_oldDistributedNodes); |
| 351 visitor->trace(m_distributedIndices); | 354 visitor->trace(m_distributedIndices); |
| 352 HTMLElement::trace(visitor); | 355 HTMLElement::trace(visitor); |
| 353 } | 356 } |
| 354 | 357 |
| 355 } // namespace blink | 358 } // namespace blink |
| OLD | NEW |