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

Unified 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: wip Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/shadow/SlotAssignment.h
diff --git a/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.h b/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.h
index 50c5b48a22efd4a09e0ac9469521c5a90d07e80f..46742a1b8d60d7c2e30c673a4e0e26ffa1fa145b 100644
--- a/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.h
+++ b/third_party/WebKit/Source/core/dom/shadow/SlotAssignment.h
@@ -5,7 +5,11 @@
#ifndef SlotAssignment_h
#define SlotAssignment_h
+#include "core/dom/DocumentOrderedList.h"
#include "platform/heap/Handle.h"
+#include "wtf/HashMap.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/AtomicStringHash.h"
namespace blink {
@@ -13,37 +17,70 @@ class HTMLSlotElement;
class Node;
class ShadowRoot;
+class SlotEntry final : public GarbageCollected<SlotEntry> {
+public:
+ static SlotEntry* create()
+ {
+ return new SlotEntry;
+ }
+ void add(HTMLSlotElement&);
+ void remove(HTMLSlotElement&);
+ HTMLSlotElement* firstSlot() const;
+
+private:
+ unsigned size() const { return m_slots.size(); }
+ DocumentOrderedList m_slots;
+ DECLARE_TRACE();
esprehn 2016/05/23 06:41:00 I don't think traces are usually private?
+};
+
+// TODO(hayato): Support SlotAssignment for non-shadow trees, e.g. a document tree.
class SlotAssignment final : public GarbageCollected<SlotAssignment> {
public:
- static SlotAssignment* create()
+ static SlotAssignment* create(ShadowRoot& owner)
{
- return new SlotAssignment;
+ return new SlotAssignment(owner);
}
- HTMLSlotElement* assignedSlotFor(const Node&) const;
- void resolveAssignment(ShadowRoot&);
- void resolveDistribution(ShadowRoot&);
+ // Relevant DOM Standard: https://dom.spec.whatwg.org/#find-a-slot
+ HTMLSlotElement* findSlot(const Node&);
esprehn 2016/05/23 06:41:00 what does the first one do? How does it find a slo
hayato 2016/05/24 13:23:39 It uses the node's slot attribute. I chose this me
+ HTMLSlotElement* findSlotByName(const AtomicString& slotName);
- void didAddSlot() { ++m_descendantSlotCount; }
- void didRemoveSlot() { DCHECK_GT(m_descendantSlotCount, 0u); --m_descendantSlotCount; }
- unsigned descendantSlotCount() const { return m_descendantSlotCount; }
+ // DOM Standaard defines these two procedures:
+ // 1. https://dom.spec.whatwg.org/#assignTo-slotables
kochi 2016/05/23 06:08:43 Can't navigate to this URL hash.
hayato 2016/05/24 13:23:39 Fixed
+ // void assignSlot(const Node& slottable);
+ // 2. https://dom.spec.whatwg.org/#assignTo-a-slot
kochi 2016/05/23 06:08:43 Ditto. (the 2 merged to https://dom.spec.whatwg.or
hayato 2016/05/24 13:23:39 Fixed
+ // void assignSlotables(HTMLSlotElement&);
+ // As an optimization, Blink does not implement these literally.
+ // Instead, provide alternative, HTMLSlotElement::isAssignedNodesEmptySynchronoulsy
kochi 2016/05/23 06:08:42 nit: s/Synchronoulsy/Synchronously/
+ // so that slotchange can be detected.
- const HeapVector<Member<HTMLSlotElement>>& descendantSlots() const { return m_descendantSlots; }
+ void resolveDistribution();
+ const HeapVector<Member<HTMLSlotElement>>& slots();
- void setDescendantSlots(HeapVector<Member<HTMLSlotElement>>& slots) { m_descendantSlots.swap(slots); }
- void clearDescendantSlots() { m_descendantSlots.clear(); }
+ void slotAdded(HTMLSlotElement&);
+ void slotRemoved(HTMLSlotElement&);
+ void slotRenamed(const AtomicString& oldName, HTMLSlotElement&);
+ void hostChildSlotNameChanged(const AtomicString& oldValue, const AtomicString& newValue);
+
+ bool findHostChildBySlotName(const AtomicString& slotName) const;
DECLARE_TRACE();
private:
- SlotAssignment() { };
+ SlotAssignment(ShadowRoot& owner);
esprehn 2016/05/23 06:41:00 explicit, even private constructors need it or you
+
+ SlotEntry& entry(const AtomicString&);
+ void collectSlots();
- void assign(Node&, HTMLSlotElement&);
- void distribute(Node&, HTMLSlotElement&);
+ void resolveAssignment();
+ void assignTo(Node&, HTMLSlotElement&);
+ void distributeTo(Node&, HTMLSlotElement&);
- unsigned m_descendantSlotCount = 0;
- HeapVector<Member<HTMLSlotElement>> m_descendantSlots;
- HeapHashMap<Member<Node>, Member<HTMLSlotElement>> m_assignment;
+ HeapVector<Member<HTMLSlotElement>> m_slots;
+ HeapHashMap<AtomicString, Member<SlotEntry>> m_slotEntryMap;
+ WeakMember<ShadowRoot> m_owner;
+ bool m_needsCollectSlots = false;
+ unsigned m_slotCount = 0;
esprehn 2016/05/23 06:41:00 we could combine these together to make this thing
hayato 2016/05/24 13:23:39 Done
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698