diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:38:37 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 06:38:37 -0400 |
commit | 3758434680616e91edf696e546fe3cc3b1d4da9c (patch) | |
tree | 845788e5a7a90326c7026a7bd139bc222352a54f /dom | |
parent | 55d83ea6f9aa9d99963a4d1fb1f96a3b633ede49 (diff) | |
download | UXP-3758434680616e91edf696e546fe3cc3b1d4da9c.tar UXP-3758434680616e91edf696e546fe3cc3b1d4da9c.tar.gz UXP-3758434680616e91edf696e546fe3cc3b1d4da9c.tar.lz UXP-3758434680616e91edf696e546fe3cc3b1d4da9c.tar.xz UXP-3758434680616e91edf696e546fe3cc3b1d4da9c.zip |
Bug 1408341 - Implement assignedSlot on Element and Text
Tag #1375
Diffstat (limited to 'dom')
-rw-r--r-- | dom/base/FragmentOrElement.cpp | 19 | ||||
-rw-r--r-- | dom/base/FragmentOrElement.h | 7 | ||||
-rw-r--r-- | dom/base/nsGenericDOMDataNode.cpp | 19 | ||||
-rw-r--r-- | dom/base/nsGenericDOMDataNode.h | 13 | ||||
-rw-r--r-- | dom/base/nsIContent.h | 15 | ||||
-rw-r--r-- | dom/webidl/Element.webidl | 2 | ||||
-rw-r--r-- | dom/webidl/Text.webidl | 5 |
7 files changed, 80 insertions, 0 deletions
diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 592f5447d..486bbc88c 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -123,6 +123,7 @@ #include "mozilla/CORSMode.h" #include "mozilla/dom/ShadowRoot.h" +#include "mozilla/dom/HTMLSlotElement.h" #include "mozilla/dom/HTMLTemplateElement.h" #include "nsStyledElement.h" @@ -614,6 +615,9 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb) NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mContainingShadow"); cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mExtendedSlots->mContainingShadow)); + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mAssignedSlot"); + cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mExtendedSlots->mAssignedSlot.get())); + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mXBLBinding"); cb.NoteNativeChild(mExtendedSlots->mXBLBinding, NS_CYCLE_COLLECTION_PARTICIPANT(nsXBLBinding)); @@ -657,6 +661,7 @@ FragmentOrElement::nsDOMSlots::Unlink() mExtendedSlots->mLabelsList = nullptr; mExtendedSlots->mShadowRoot = nullptr; mExtendedSlots->mContainingShadow = nullptr; + mExtendedSlots->mAssignedSlot = nullptr; MOZ_ASSERT(!(mExtendedSlots->mXBLBinding)); mExtendedSlots->mXBLInsertionParent = nullptr; if (mExtendedSlots->mCustomElementData) { @@ -1126,6 +1131,20 @@ FragmentOrElement::GetExistingDestInsertionPoints() const return nullptr; } +HTMLSlotElement* +FragmentOrElement::GetAssignedSlot() const +{ + nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots(); + return slots ? slots->mAssignedSlot.get() : nullptr; +} + +void +FragmentOrElement::SetAssignedSlot(HTMLSlotElement* aSlot) +{ + nsExtendedDOMSlots* slots = ExtendedDOMSlots(); + slots->mAssignedSlot = aSlot; +} + void FragmentOrElement::SetXBLInsertionParent(nsIContent* aContent) { diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h index 07403cf39..df05bcb50 100644 --- a/dom/base/FragmentOrElement.h +++ b/dom/base/FragmentOrElement.h @@ -158,6 +158,8 @@ public: virtual nsTArray<nsIContent*> &DestInsertionPoints() override; virtual nsTArray<nsIContent*> *GetExistingDestInsertionPoints() const override; virtual void SetShadowRoot(ShadowRoot* aBinding) override; + virtual mozilla::dom::HTMLSlotElement* GetAssignedSlot() const override; + virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) override; virtual nsIContent *GetXBLInsertionParent() const override; virtual void SetXBLInsertionParent(nsIContent* aContent) override; virtual bool IsLink(nsIURI** aURI) const override; @@ -301,6 +303,11 @@ public: nsTArray<nsIContent*> mDestInsertionPoints; /** + * The assigned slot associated with this element. + */ + RefPtr<mozilla::dom::HTMLSlotElement> mAssignedSlot; + + /** * XBL binding installed on the element. */ RefPtr<nsXBLBinding> mXBLBinding; diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp index 73463ea5e..e5cc852d2 100644 --- a/dom/base/nsGenericDOMDataNode.cpp +++ b/dom/base/nsGenericDOMDataNode.cpp @@ -15,6 +15,7 @@ #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/MemoryReporting.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/HTMLSlotElement.h" #include "mozilla/dom/ShadowRoot.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" @@ -753,6 +754,20 @@ nsGenericDOMDataNode::GetExistingDestInsertionPoints() const return nullptr; } +HTMLSlotElement* +nsGenericDOMDataNode::GetAssignedSlot() const +{ + nsDataSlots *slots = GetExistingDataSlots(); + return slots ? slots->mAssignedSlot.get() : nullptr; +} + +void +nsGenericDOMDataNode::SetAssignedSlot(HTMLSlotElement* aSlot) +{ + nsDataSlots *slots = DataSlots(); + slots->mAssignedSlot = aSlot; +} + nsXBLBinding * nsGenericDOMDataNode::GetXBLBinding() const { @@ -843,6 +858,9 @@ nsGenericDOMDataNode::nsDataSlots::Traverse(nsCycleCollectionTraversalCallback & NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mContainingShadow"); cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mContainingShadow)); + + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mAssignedSlot"); + cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(nsIContent*, mAssignedSlot.get())); } void @@ -850,6 +868,7 @@ nsGenericDOMDataNode::nsDataSlots::Unlink() { mXBLInsertionParent = nullptr; mContainingShadow = nullptr; + mAssignedSlot = nullptr; } //---------------------------------------------------------------------- diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h index e8818b518..97bd79129 100644 --- a/dom/base/nsGenericDOMDataNode.h +++ b/dom/base/nsGenericDOMDataNode.h @@ -26,6 +26,12 @@ class nsIDocument; class nsIDOMText; +namespace mozilla { +namespace dom { +class HTMLSlotElement; +} // namespace dom +} // namespace mozilla + #define DATA_NODE_FLAG_BIT(n_) NODE_FLAG_BIT(NODE_TYPE_SPECIFIC_BITS_OFFSET + (n_)) // Data node specific flags @@ -157,6 +163,8 @@ public: virtual nsTArray<nsIContent*> &DestInsertionPoints() override; virtual nsTArray<nsIContent*> *GetExistingDestInsertionPoints() const override; virtual void SetShadowRoot(mozilla::dom::ShadowRoot* aShadowRoot) override; + virtual mozilla::dom::HTMLSlotElement* GetAssignedSlot() const override; + virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) override; virtual nsIContent *GetXBLInsertionParent() const override; virtual void SetXBLInsertionParent(nsIContent* aContent) override; virtual bool IsNodeOfType(uint32_t aFlags) const override; @@ -264,6 +272,11 @@ protected: * @see nsIContent::GetDestInsertionPoints */ nsTArray<nsIContent*> mDestInsertionPoints; + + /** + * @see nsIContent::GetAssignedSlot + */ + RefPtr<mozilla::dom::HTMLSlotElement> mAssignedSlot; }; // Override from nsINode diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 25b582abd..f368497f4 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -26,6 +26,7 @@ namespace mozilla { class EventChainPreVisitor; namespace dom { class ShadowRoot; +class HTMLSlotElement; } // namespace dom namespace widget { struct IMEState; @@ -710,6 +711,20 @@ public: virtual nsTArray<nsIContent*> *GetExistingDestInsertionPoints() const = 0; /** + * Gets the assigned slot associated with this content. + * + * @return The assigned slot element or null. + */ + virtual mozilla::dom::HTMLSlotElement* GetAssignedSlot() const = 0; + + /** + * Sets the assigned slot associated with this content. + * + * @param aSlot The assigned slot. + */ + virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) = 0; + + /** * Gets the insertion parent element of the XBL binding. * The insertion parent is our one true parent in the transformed DOM. * diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index a6b2bfdd5..7fc59d614 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -236,6 +236,8 @@ partial interface Element { NodeList getDestinationInsertionPoints(); [Func="nsDocument::IsWebComponentsEnabled"] readonly attribute ShadowRoot? shadowRoot; + [Pref="nsDocument::IsWebComponentsEnabled"] + readonly attribute HTMLSlotElement? assignedSlot; }; Element implements ChildNode; diff --git a/dom/webidl/Text.webidl b/dom/webidl/Text.webidl index dcd25cec3..f7bd1a971 100644 --- a/dom/webidl/Text.webidl +++ b/dom/webidl/Text.webidl @@ -18,4 +18,9 @@ interface Text : CharacterData { readonly attribute DOMString wholeText; }; +partial interface Text { + [Pref="dom.webcomponents.enabled"] + readonly attribute HTMLSlotElement? assignedSlot; +}; + Text implements GeometryUtils; |