summaryrefslogtreecommitdiff
path: root/dom/base/ShadowRoot.h
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:10:54 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:10:54 -0400
commite31ed5b07466d4a579fe4b025f97c971003fbc3f (patch)
treeabd621b87578770973591fd03608993334f6af64 /dom/base/ShadowRoot.h
parent8beb65dd501cbdcfd6a793027b5de2a1fdfc7149 (diff)
downloaduxp-e31ed5b07466d4a579fe4b025f97c971003fbc3f.tar.gz
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
Diffstat (limited to 'dom/base/ShadowRoot.h')
-rw-r--r--dom/base/ShadowRoot.h33
1 files changed, 31 insertions, 2 deletions
diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h
index 5efff5be7c..c525ba8e8f 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<nsStringHashKey, nsTArray<mozilla::dom::HTMLSlotElement*>> mSlotMap;
+
nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
nsXBLPrototypeBinding* mProtoBinding;