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 #ifndef SlotAssignment_h | 5 #ifndef SlotAssignment_h |
6 #define SlotAssignment_h | 6 #define SlotAssignment_h |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class HTMLSlotElement; | 12 class HTMLSlotElement; |
13 class Node; | 13 class Node; |
14 class ShadowRoot; | 14 class ShadowRoot; |
15 | 15 |
16 class SlotAssignment final : public GarbageCollected<SlotAssignment> { | 16 class SlotAssignment final : public GarbageCollected<SlotAssignment> { |
17 public: | 17 public: |
18 static SlotAssignment* create() | 18 static SlotAssignment* create() |
19 { | 19 { |
20 return new SlotAssignment; | 20 return new SlotAssignment; |
21 } | 21 } |
22 | 22 |
23 HTMLSlotElement* assignedSlotFor(const Node&) const; | 23 HTMLSlotElement* assignedSlotFor(const Node&) const; |
24 void resolveAssignment(ShadowRoot&); | 24 void resolveAssignment(ShadowRoot&); |
25 void resolveDistribution(ShadowRoot&); | 25 void resolveDistribution(ShadowRoot&); |
26 | 26 |
| 27 void didAddSlot() { ++m_descendantSlotCount; } |
| 28 void didRemoveSlot() { DCHECK_GT(m_descendantSlotCount, 0u); --m_descendantS
lotCount; } |
| 29 unsigned descendantSlotCount() const { return m_descendantSlotCount; } |
| 30 |
| 31 const HeapVector<Member<HTMLSlotElement>>& descendantSlots() const { return
m_descendantSlots; } |
| 32 |
| 33 void setDescendantSlots(HeapVector<Member<HTMLSlotElement>>& slots) { m_desc
endantSlots.swap(slots); } |
| 34 void clearDescendantSlots() { m_descendantSlots.clear(); } |
| 35 |
27 DECLARE_TRACE(); | 36 DECLARE_TRACE(); |
28 | 37 |
29 private: | 38 private: |
30 SlotAssignment() { } | 39 SlotAssignment() { }; |
31 | 40 |
32 void assign(Node&, HTMLSlotElement&); | 41 void assign(Node&, HTMLSlotElement&); |
33 void distribute(Node&, HTMLSlotElement&); | 42 void distribute(Node&, HTMLSlotElement&); |
| 43 |
| 44 unsigned m_descendantSlotCount = 0; |
| 45 HeapVector<Member<HTMLSlotElement>> m_descendantSlots; |
34 HeapHashMap<Member<Node>, Member<HTMLSlotElement>> m_assignment; | 46 HeapHashMap<Member<Node>, Member<HTMLSlotElement>> m_assignment; |
35 }; | 47 }; |
36 | 48 |
37 } // namespace blink | 49 } // namespace blink |
38 | 50 |
39 #endif // HTMLSlotAssignment_h | 51 #endif // HTMLSlotAssignment_h |
OLD | NEW |