mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-25 18:07:31 +09:00
Bug 1411878 - Support Element.shadowRoot and Element.assignedSlot / TextNode.assignedSlot on closed shadow root
Tag #1375
This commit is contained in:
parent
67c4d022dc
commit
31b26a24e3
8 changed files with 67 additions and 11 deletions
|
|
@ -1104,6 +1104,25 @@ Element::GetSlot(nsAString& aName)
|
||||||
GetAttr(kNameSpaceID_None, nsGkAtoms::slot, aName);
|
GetAttr(kNameSpaceID_None, nsGkAtoms::slot, aName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-element-shadowroot
|
||||||
|
ShadowRoot*
|
||||||
|
Element::GetShadowRootByMode() const
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 1. Let shadow be context object’s shadow root.
|
||||||
|
* 2. If shadow is null or its mode is "closed", then return null.
|
||||||
|
*/
|
||||||
|
ShadowRoot* shadowRoot = GetShadowRoot();
|
||||||
|
if (!shadowRoot || shadowRoot->IsClosed()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 3. Return shadow.
|
||||||
|
*/
|
||||||
|
return shadowRoot;
|
||||||
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-element-attachshadow
|
// https://dom.spec.whatwg.org/#dom-element-attachshadow
|
||||||
already_AddRefed<ShadowRoot>
|
already_AddRefed<ShadowRoot>
|
||||||
Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
|
Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
|
||||||
|
|
|
||||||
|
|
@ -927,6 +927,7 @@ public:
|
||||||
// Shadow DOM v1
|
// Shadow DOM v1
|
||||||
already_AddRefed<ShadowRoot> AttachShadow(const ShadowRootInit& aInit,
|
already_AddRefed<ShadowRoot> AttachShadow(const ShadowRootInit& aInit,
|
||||||
ErrorResult& aError);
|
ErrorResult& aError);
|
||||||
|
ShadowRoot* GetShadowRootByMode() const;
|
||||||
void SetSlot(const nsAString& aName, ErrorResult& aError);
|
void SetSlot(const nsAString& aName, ErrorResult& aError);
|
||||||
void GetSlot(nsAString& aName);
|
void GetSlot(nsAString& aName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,36 @@ nsIContent::FindFirstNonChromeOnlyAccessContent() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-slotable-assignedslot
|
||||||
|
HTMLSlotElement*
|
||||||
|
nsIContent::GetAssignedSlotByMode() const
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get slotable's assigned slot for the result of
|
||||||
|
* find a slot with open flag UNSET [1].
|
||||||
|
*
|
||||||
|
* [1] https://dom.spec.whatwg.org/#assign-a-slot
|
||||||
|
*/
|
||||||
|
HTMLSlotElement* slot = GetAssignedSlot();
|
||||||
|
if (!slot) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
MOZ_ASSERT(GetParent());
|
||||||
|
MOZ_ASSERT(GetParent()->GetShadowRoot());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional check for open flag SET:
|
||||||
|
* If slotable’s parent’s shadow root's mode is not "open",
|
||||||
|
* then return null.
|
||||||
|
*/
|
||||||
|
if (GetParent()->GetShadowRoot()->IsClosed()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
nsINode*
|
nsINode*
|
||||||
nsIContent::GetFlattenedTreeParentNodeInternal(FlattenedParentType aType) const
|
nsIContent::GetFlattenedTreeParentNodeInternal(FlattenedParentType aType) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,11 @@ public:
|
||||||
{
|
{
|
||||||
return mMode;
|
return mMode;
|
||||||
}
|
}
|
||||||
|
bool IsClosed()
|
||||||
|
{
|
||||||
|
return mMode == ShadowRootMode::Closed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// [deprecated] Shadow DOM v0
|
// [deprecated] Shadow DOM v0
|
||||||
void AddToIdTable(Element* aElement, nsIAtom* aId);
|
void AddToIdTable(Element* aElement, nsIAtom* aId);
|
||||||
|
|
|
||||||
|
|
@ -724,6 +724,15 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) = 0;
|
virtual void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the assigned slot associated with this content based on parent's
|
||||||
|
* shadow root mode. Returns null if parent's shadow root is "closed".
|
||||||
|
* https://dom.spec.whatwg.org/#dom-slotable-assignedslot
|
||||||
|
*
|
||||||
|
* @return The assigned slot element or null.
|
||||||
|
*/
|
||||||
|
mozilla::dom::HTMLSlotElement* GetAssignedSlotByMode() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the insertion parent element of the XBL binding.
|
* Gets the insertion parent element of the XBL binding.
|
||||||
* The insertion parent is our one true parent in the transformed DOM.
|
* The insertion parent is our one true parent in the transformed DOM.
|
||||||
|
|
|
||||||
|
|
@ -238,9 +238,9 @@ partial interface Element {
|
||||||
// Shadow DOM v1
|
// Shadow DOM v1
|
||||||
[Throws, Pref="nsDocument::IsWebComponentsEnabled"]
|
[Throws, Pref="nsDocument::IsWebComponentsEnabled"]
|
||||||
ShadowRoot attachShadow(ShadowRootInit shadowRootInitDict);
|
ShadowRoot attachShadow(ShadowRootInit shadowRootInitDict);
|
||||||
[Func="nsDocument::IsWebComponentsEnabled"]
|
[BinaryName="shadowRootByMode", Func="nsDocument::IsWebComponentsEnabled"]
|
||||||
readonly attribute ShadowRoot? shadowRoot;
|
readonly attribute ShadowRoot? shadowRoot;
|
||||||
[Pref="nsDocument::IsWebComponentsEnabled"]
|
[BinaryName="assignedSlotByMode", Pref="nsDocument::IsWebComponentsEnabled"]
|
||||||
readonly attribute HTMLSlotElement? assignedSlot;
|
readonly attribute HTMLSlotElement? assignedSlot;
|
||||||
[CEReactions, Unscopable, SetterThrows, Pref="nsDocument::IsWebComponentsEnabled"]
|
[CEReactions, Unscopable, SetterThrows, Pref="nsDocument::IsWebComponentsEnabled"]
|
||||||
attribute DOMString slot;
|
attribute DOMString slot;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ interface Text : CharacterData {
|
||||||
};
|
};
|
||||||
|
|
||||||
partial interface Text {
|
partial interface Text {
|
||||||
[Pref="dom.webcomponents.enabled"]
|
[BinaryName="assignedSlotByMode", Pref="dom.webcomponents.enabled"]
|
||||||
readonly attribute HTMLSlotElement? assignedSlot;
|
readonly attribute HTMLSlotElement? assignedSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
[Element-interface-shadowRoot-attribute.html]
|
|
||||||
type: testharness
|
|
||||||
[shadowRoot attribute must return the open shadow root associated with the element]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[shadowRoot attribute must return null if the shadow root attached to the element is closed]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue