diff options
-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 | ||||
-rw-r--r-- | testing/web-platform/meta/dom/interfaces.html.ini | 6 | ||||
-rw-r--r-- | testing/web-platform/meta/shadow-dom/Slotable-interface.html.ini | 4 |
9 files changed, 81 insertions, 9 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; diff --git a/testing/web-platform/meta/dom/interfaces.html.ini b/testing/web-platform/meta/dom/interfaces.html.ini index 2a0c6da04..988efdf97 100644 --- a/testing/web-platform/meta/dom/interfaces.html.ini +++ b/testing/web-platform/meta/dom/interfaces.html.ini @@ -27,9 +27,6 @@ [Element interface: operation attachShadow(ShadowRootInit)] expected: FAIL - [Element interface: attribute assignedSlot] - expected: FAIL - [Element interface: element must inherit property "slot" with the proper type (7)] expected: FAIL @@ -42,9 +39,6 @@ [Element interface: element must inherit property "assignedSlot" with the proper type (48)] expected: FAIL - [Text interface: attribute assignedSlot] - expected: FAIL - [Text interface: document.createTextNode("abc") must inherit property "assignedSlot" with the proper type (2)] expected: FAIL diff --git a/testing/web-platform/meta/shadow-dom/Slotable-interface.html.ini b/testing/web-platform/meta/shadow-dom/Slotable-interface.html.ini index 346edcd4f..6ef193dee 100644 --- a/testing/web-platform/meta/shadow-dom/Slotable-interface.html.ini +++ b/testing/web-platform/meta/shadow-dom/Slotable-interface.html.ini @@ -1,8 +1,6 @@ [Slotable-interface.html] type: testharness - [assignedSlot attribute must be defined on Element and Text interfaces] - expected: FAIL - + prefs: [dom.webcomponents.enabled:true] [assignedSlot must return null when the node does not have an assigned node] expected: FAIL |