OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/shadow/SlotAssignment.h" | 5 #include "core/dom/shadow/SlotAssignment.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
9 #include "core/dom/NodeTraversal.h" | 9 #include "core/dom/NodeTraversal.h" |
10 #include "core/dom/shadow/InsertionPoint.h" | 10 #include "core/dom/shadow/InsertionPoint.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 static void detachNotAssignedNode(Node& node) | 21 static void detachNotAssignedNode(Node& node) |
22 { | 22 { |
23 if (node.layoutObject()) | 23 if (node.layoutObject()) |
24 node.lazyReattachIfAttached(); | 24 node.lazyReattachIfAttached(); |
25 } | 25 } |
26 | 26 |
27 void SlotAssignment::resolveAssignment(const ShadowRoot& shadowRoot) | 27 void SlotAssignment::resolveAssignment(const ShadowRoot& shadowRoot) |
28 { | 28 { |
29 m_assignment.clear(); | 29 m_assignment.clear(); |
30 | 30 |
31 using Name2Slot = HashMap<AtomicString, HTMLSlotElement*>; | 31 using Name2Slot = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<HTMLSlo
tElement>>; |
32 Name2Slot name2slot; | 32 Name2Slot name2slot; |
33 HTMLSlotElement* defaultSlot = nullptr; | 33 HTMLSlotElement* defaultSlot = nullptr; |
34 Vector<HTMLSlotElement*> slots; | 34 WillBeHeapVector<RefPtrWillBeMember<HTMLSlotElement>> slots; |
35 | 35 |
36 // TODO(hayato): Cache slots elements so that we do not have to travese the
shadow tree. See ShadowRoot::descendantInsertionPoints() | 36 // TODO(hayato): Cache slots elements so that we do not have to travese the
shadow tree. See ShadowRoot::descendantInsertionPoints() |
37 for (HTMLSlotElement& slot : Traversal<HTMLSlotElement>::descendantsOf(shado
wRoot)) { | 37 for (HTMLSlotElement& slot : Traversal<HTMLSlotElement>::descendantsOf(shado
wRoot)) { |
38 slot.clearDistribution(); | 38 slot.clearDistribution(); |
39 | 39 |
40 slots.append(&slot); | 40 slots.append(&slot); |
41 | 41 |
42 AtomicString name = slot.fastGetAttribute(HTMLNames::nameAttr); | 42 AtomicString name = slot.fastGetAttribute(HTMLNames::nameAttr); |
43 if (name.isNull() || name.isEmpty()) { | 43 if (name.isNull() || name.isEmpty()) { |
44 if (!defaultSlot) | 44 if (!defaultSlot) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 DEFINE_TRACE(SlotAssignment) | 93 DEFINE_TRACE(SlotAssignment) |
94 { | 94 { |
95 #if ENABLE(OILPAN) | 95 #if ENABLE(OILPAN) |
96 visitor->trace(m_assignment); | 96 visitor->trace(m_assignment); |
97 #endif | 97 #endif |
98 } | 98 } |
99 | 99 |
100 } // namespace blink | 100 } // namespace blink |
OLD | NEW |