Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/SlotAssignment.h

Issue 1995203002: Rewrite Shadow DOM distribution engine to support partial synchronous distribution for v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "core/dom/DocumentOrderedList.h"
9 #include "core/dom/DocumentOrderedMap.h"
8 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 #include "wtf/HashMap.h"
12 #include "wtf/text/AtomicString.h"
13 #include "wtf/text/AtomicStringHash.h"
9 14
10 namespace blink { 15 namespace blink {
11 16
12 class HTMLSlotElement; 17 class HTMLSlotElement;
13 class Node; 18 class Node;
14 class ShadowRoot; 19 class ShadowRoot;
15 20
21 // TODO(hayato): Support SlotAssignment for non-shadow trees, e.g. a document tr ee.
16 class SlotAssignment final : public GarbageCollected<SlotAssignment> { 22 class SlotAssignment final : public GarbageCollected<SlotAssignment> {
17 public: 23 public:
18 static SlotAssignment* create() 24 static SlotAssignment* create(ShadowRoot& owner)
19 { 25 {
20 return new SlotAssignment; 26 return new SlotAssignment(owner);
21 } 27 }
22 28
23 HTMLSlotElement* assignedSlotFor(const Node&) const; 29 // Relevant DOM Standard: https://dom.spec.whatwg.org/#find-a-slot
24 void resolveAssignment(ShadowRoot&); 30 HTMLSlotElement* findSlot(const Node&);
25 void resolveDistribution(ShadowRoot&); 31 HTMLSlotElement* findSlotByName(const AtomicString& slotName);
26 32
27 void didAddSlot() { ++m_descendantSlotCount; } 33 // DOM Standaard defines these two procedures:
28 void didRemoveSlot() { DCHECK_GT(m_descendantSlotCount, 0u); --m_descendantS lotCount; } 34 // 1. https://dom.spec.whatwg.org/#assign-a-slot
29 unsigned descendantSlotCount() const { return m_descendantSlotCount; } 35 // void assignSlot(const Node& slottable);
36 // 2. https://dom.spec.whatwg.org/#assign-slotables
37 // void assignSlotables(HTMLSlotElement&);
38 // As an optimization, Blink does not implement these literally.
39 // Instead, provide alternative, HTMLSlotElement::hasAssignedNodesSlow()
40 // so that slotchange can be detected.
30 41
31 const HeapVector<Member<HTMLSlotElement>>& descendantSlots() const { return m_descendantSlots; } 42 void resolveDistribution();
43 const HeapVector<Member<HTMLSlotElement>>& slots();
32 44
33 void setDescendantSlots(HeapVector<Member<HTMLSlotElement>>& slots) { m_desc endantSlots.swap(slots); } 45 void slotAdded(HTMLSlotElement&);
34 void clearDescendantSlots() { m_descendantSlots.clear(); } 46 void slotRemoved(HTMLSlotElement&);
47 void slotRenamed(const AtomicString& oldName, HTMLSlotElement&);
48 void hostChildSlotNameChanged(const AtomicString& oldValue, const AtomicStri ng& newValue);
49
50 bool findHostChildBySlotName(const AtomicString& slotName) const;
35 51
36 DECLARE_TRACE(); 52 DECLARE_TRACE();
37 53
38 private: 54 private:
39 SlotAssignment() { }; 55 explicit SlotAssignment(ShadowRoot& owner);
40 56
41 void assign(Node&, HTMLSlotElement&); 57 void collectSlots();
42 void distribute(Node&, HTMLSlotElement&);
43 58
44 unsigned m_descendantSlotCount = 0; 59 void resolveAssignment();
45 HeapVector<Member<HTMLSlotElement>> m_descendantSlots; 60 void distributeTo(Node&, HTMLSlotElement&);
46 HeapHashMap<Member<Node>, Member<HTMLSlotElement>> m_assignment; 61
62 HeapVector<Member<HTMLSlotElement>> m_slots;
63 Member<DocumentOrderedMap> m_slotMap;
64 WeakMember<ShadowRoot> m_owner;
65 unsigned m_needsCollectSlots : 1;
66 unsigned m_slotCount : 31;
47 }; 67 };
48 68
49 } // namespace blink 69 } // namespace blink
50 70
51 #endif // HTMLSlotAssignment_h 71 #endif // HTMLSlotAssignment_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698