mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1408341 - Implement assignedSlot on Element and Text. r=smaug
This commit is contained in:
parent
0d6e66757d
commit
0d1588d9f7
@ -125,6 +125,7 @@
|
||||
#include "mozilla/CORSMode.h"
|
||||
|
||||
#include "mozilla/dom/ShadowRoot.h"
|
||||
#include "mozilla/dom/HTMLSlotElement.h"
|
||||
#include "mozilla/dom/HTMLTemplateElement.h"
|
||||
#include "mozilla/dom/SVGUseElement.h"
|
||||
|
||||
@ -698,6 +699,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));
|
||||
@ -745,6 +749,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) {
|
||||
@ -1215,6 +1220,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)
|
||||
{
|
||||
|
@ -155,6 +155,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;
|
||||
@ -297,6 +299,11 @@ public:
|
||||
*/
|
||||
nsTArray<nsIContent*> mDestInsertionPoints;
|
||||
|
||||
/**
|
||||
* The assigned slot associated with this element.
|
||||
*/
|
||||
RefPtr<mozilla::dom::HTMLSlotElement> mAssignedSlot;
|
||||
|
||||
/**
|
||||
* XBL binding installed on the element.
|
||||
*/
|
||||
|
@ -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"
|
||||
@ -739,6 +740,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
|
||||
{
|
||||
@ -829,6 +844,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
|
||||
@ -836,6 +854,7 @@ nsGenericDOMDataNode::nsDataSlots::Unlink()
|
||||
{
|
||||
mXBLInsertionParent = nullptr;
|
||||
mContainingShadow = nullptr;
|
||||
mAssignedSlot = nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -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
|
||||
@ -170,6 +176,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;
|
||||
@ -283,6 +291,11 @@ protected:
|
||||
* @see nsIContent::GetDestInsertionPoints
|
||||
*/
|
||||
nsTArray<nsIContent*> mDestInsertionPoints;
|
||||
|
||||
/**
|
||||
* @see nsIContent::GetAssignedSlot
|
||||
*/
|
||||
RefPtr<mozilla::dom::HTMLSlotElement> mAssignedSlot;
|
||||
};
|
||||
|
||||
// Override from nsINode
|
||||
|
@ -28,6 +28,7 @@ class EventChainPreVisitor;
|
||||
struct URLExtraData;
|
||||
namespace dom {
|
||||
class ShadowRoot;
|
||||
class HTMLSlotElement;
|
||||
} // namespace dom
|
||||
namespace widget {
|
||||
struct IMEState;
|
||||
@ -743,6 +744,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.
|
||||
|
@ -243,6 +243,8 @@ partial interface Element {
|
||||
NodeList getDestinationInsertionPoints();
|
||||
[Pref="dom.webcomponents.enabled"]
|
||||
readonly attribute ShadowRoot? shadowRoot;
|
||||
[Pref="dom.webcomponents.enabled"]
|
||||
readonly attribute HTMLSlotElement? assignedSlot;
|
||||
};
|
||||
|
||||
Element implements ChildNode;
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,6 @@
|
||||
[interfaces.html]
|
||||
type: testharness
|
||||
prefs: [dom.webcomponents.enabled:true]
|
||||
[Document interface: attribute origin]
|
||||
expected: FAIL
|
||||
bug: 931884
|
||||
@ -24,9 +25,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
|
||||
|
||||
@ -39,9 +37,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
|
||||
|
||||
@ -102,9 +97,3 @@
|
||||
[Element interface: element must inherit property "attachShadow(ShadowRootInit)" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Element interface: element must inherit property "assignedSlot" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Text interface: document.createTextNode("abc") must inherit property "assignedSlot" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
[interfaces.https.html]
|
||||
type: testharness
|
||||
prefs: [dom.webcomponents.enabled:true]
|
||||
[PaymentRequest interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
@ -276,12 +277,6 @@
|
||||
[Element interface: operation attachShadow(ShadowRootInit)]
|
||||
expected: FAIL
|
||||
|
||||
[Element interface: attribute assignedSlot]
|
||||
expected: FAIL
|
||||
|
||||
[Text interface: attribute assignedSlot]
|
||||
expected: FAIL
|
||||
|
||||
[PaymentRequest must be primary interface of new PaymentRequest([{supportedMethods: 'foo'}\], {total: {label: 'bar', amount: {currency: 'USD', value: '0'}} })]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user