From e31ed5b07466d4a579fe4b025f97c971003fbc3f Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 17 Apr 2020 07:10:54 -0400 Subject: Bug 1409975 - Implement node distribution for shadow tree slots * Implementation for assignedNodes * Include slots in the flat tree * Fix event get-the-parent algorithm for a node * Update and add reftests for Shadow DOM v1 * Update web platform tests expectations Tag #1375 --- dom/base/ShadowRoot.h | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'dom/base/ShadowRoot.h') diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index 5efff5be7..c525ba8e8 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -21,6 +21,9 @@ class nsIContent; class nsXBLPrototypeBinding; namespace mozilla { + +class EventChainPreVisitor; + namespace dom { class Element; @@ -73,10 +76,26 @@ public: private: /** - * Redistributes a node of the pool, and returns whether the distribution + * Try to reassign an element to a slot and returns whether the assignment * changed. */ - bool RedistributeElement(Element*); + bool MaybeReassignElement(Element* aElement, const nsAttrValue* aOldValue); + + /** + * Try to assign aContent to a slot in the shadow tree, returns the assigned + * slot if found. + */ + const HTMLSlotElement* AssignSlotFor(nsIContent* aContent); + + /** + * Unassign aContent from the assigned slot in the shadow tree, returns the + * assigned slot if found. + * + * Note: slot attribute of aContent may have changed already, so pass slot + * name explicity here. + */ + const HTMLSlotElement* UnassignSlotFor(nsIContent* aContent, + const nsAString& aSlotName); /** * Called when we redistribute content after insertion points have changed. @@ -86,6 +105,9 @@ private: bool IsPooledNode(nsIContent* aChild) const; public: + void AddSlot(HTMLSlotElement* aSlot); + void RemoveSlot(HTMLSlotElement* aSlot); + void SetInsertionPointChanged() { mInsertionPointChanged = true; } void SetAssociatedBinding(nsXBLBinding* aBinding) { mAssociatedBinding = aBinding; } @@ -113,11 +135,18 @@ public: mIsComposedDocParticipant = aIsComposedDocParticipant; } + nsresult GetEventTargetParent(EventChainPreVisitor& aVisitor) override; + protected: virtual ~ShadowRoot(); ShadowRootMode mMode; + // Map from name of slot to an array of all slots in the shadow DOM with with + // the given name. The slots are stored as a weak pointer because the elements + // are in the shadow tree and should be kept alive by its parent. + nsClassHashtable> mSlotMap; + nsTHashtable mIdentifierMap; nsXBLPrototypeBinding* mProtoBinding; -- cgit v1.2.3