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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 DEFINE_NODE_FACTORY(HTMLSlotElement); | 48 DEFINE_NODE_FACTORY(HTMLSlotElement); |
49 | 49 |
50 const WillBeHeapVector<RefPtrWillBeMember<Node>> HTMLSlotElement::getAssignedNod
esForBinding(const AssignedNodesOptions& options) | 50 const WillBeHeapVector<RefPtrWillBeMember<Node>> HTMLSlotElement::getAssignedNod
esForBinding(const AssignedNodesOptions& options) |
51 { | 51 { |
52 updateDistribution(); | 52 updateDistribution(); |
53 if (options.hasFlatten() && options.flatten()) | 53 if (options.hasFlatten() && options.flatten()) |
54 return getDistributedNodes(); | 54 return getDistributedNodes(); |
55 return m_assignedNodes; | 55 return m_assignedNodes; |
56 } | 56 } |
57 | 57 |
| 58 const WillBeHeapVector<RefPtrWillBeMember<Node>>& HTMLSlotElement::getDistribute
dNodes() |
| 59 { |
| 60 ASSERT(!needsDistributionRecalc()); |
| 61 if (isInShadowTree()) |
| 62 return m_distributedNodes; |
| 63 |
| 64 // A slot is unlikely to be used outside of a shadow tree. |
| 65 // We do not need to optimize this case in most cases. |
| 66 // TODO(hayato): If this path causes a performance issue, we should move |
| 67 // ShadowRootRaraDate::m_descendantSlots into TreeScopreRareData-ish and |
| 68 // update the distribution code so it considers a document tree too. |
| 69 clearDistribution(); |
| 70 for (Node& child : NodeTraversal::childrenOf(*this)) { |
| 71 if (isHTMLSlotElement(child)) |
| 72 m_distributedNodes.appendVector(toHTMLSlotElement(child).getDistribu
tedNodes()); |
| 73 else |
| 74 m_distributedNodes.append(&child); |
| 75 } |
| 76 return m_distributedNodes; |
| 77 } |
| 78 |
58 void HTMLSlotElement::appendAssignedNode(Node& node) | 79 void HTMLSlotElement::appendAssignedNode(Node& node) |
59 { | 80 { |
60 m_assignedNodes.append(&node); | 81 m_assignedNodes.append(&node); |
61 } | 82 } |
62 | 83 |
63 void HTMLSlotElement::appendDistributedNode(Node& node) | 84 void HTMLSlotElement::appendDistributedNode(Node& node) |
64 { | 85 { |
65 m_distributedNodes.append(&node); | 86 m_distributedNodes.append(&node); |
66 } | 87 } |
67 | 88 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 201 } |
181 | 202 |
182 DEFINE_TRACE(HTMLSlotElement) | 203 DEFINE_TRACE(HTMLSlotElement) |
183 { | 204 { |
184 visitor->trace(m_assignedNodes); | 205 visitor->trace(m_assignedNodes); |
185 visitor->trace(m_distributedNodes); | 206 visitor->trace(m_distributedNodes); |
186 HTMLElement::trace(visitor); | 207 HTMLElement::trace(visitor); |
187 } | 208 } |
188 | 209 |
189 } | 210 } |
OLD | NEW |