diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 0521e6e2f6a8..3ef182b9b361 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -539,6 +539,16 @@ nsDOMTokenList* Element::ClassList() { return slots->mClassList; } +nsDOMTokenList* Element::Part() { + Element::nsDOMSlots* slots = DOMSlots(); + + if (!slots->mPart) { + slots->mPart = new nsDOMTokenList(this, nsGkAtoms::part); + } + + return slots->mPart; +} + void Element::GetAttributeNames(nsTArray& aResult) { uint32_t count = mAttrs.AttrCount(); for (uint32_t i = 0; i < count; ++i) { diff --git a/dom/base/Element.h b/dom/base/Element.h index 58cc122edbc5..5b9933513a72 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -1030,6 +1030,8 @@ class Element : public FragmentOrElement { } nsDOMTokenList* ClassList(); + nsDOMTokenList* Part(); + nsDOMAttributeMap* Attributes() { nsDOMSlots* slots = DOMSlots(); if (!slots->mAttributeMap) { diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index ca412df1f6f3..b5c5c1ca6fb7 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -597,6 +597,9 @@ void FragmentOrElement::nsDOMSlots::Traverse( NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mSlots->mClassList"); aCb.NoteXPCOMChild(mClassList.get()); + + NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mSlots->mPart"); + aCb.NoteXPCOMChild(mPart.get()); } void FragmentOrElement::nsDOMSlots::Unlink() { @@ -608,6 +611,7 @@ void FragmentOrElement::nsDOMSlots::Unlink() { } mChildrenList = nullptr; mClassList = nullptr; + mPart = nullptr; } size_t FragmentOrElement::nsDOMSlots::SizeOfIncludingThis( diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h index e6463a9db7e3..4a2d73528ecc 100644 --- a/dom/base/FragmentOrElement.h +++ b/dom/base/FragmentOrElement.h @@ -247,6 +247,11 @@ class FragmentOrElement : public nsIContent { * An object implementing the .classList property for this element. */ RefPtr mClassList; + + /** + * An object implementing the .part property for this element. + */ + RefPtr mPart; }; /** diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 3154323134e8..01bf7fefacc8 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -33,6 +33,10 @@ interface Element : Node { [Constant, PutForwards=value] readonly attribute DOMTokenList classList; + // https://drafts.csswg.org/css-shadow-parts/#idl + [SameObject, PutForwards=value, Pref="layout.css.shadow-parts.enabled"] + readonly attribute DOMTokenList part; + [SameObject] readonly attribute NamedNodeMap attributes; [Pure] diff --git a/testing/web-platform/meta/css/css-shadow-parts/invalidation-change-part-name-idl-domtokenlist.html.ini b/testing/web-platform/meta/css/css-shadow-parts/invalidation-change-part-name-idl-domtokenlist.html.ini deleted file mode 100644 index 0e040feabbb8..000000000000 --- a/testing/web-platform/meta/css/css-shadow-parts/invalidation-change-part-name-idl-domtokenlist.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[invalidation-change-part-name-idl-domtokenlist.html] - [Part in selected host changed color via part IDL DOMTokenList attribute.] - expected: FAIL - diff --git a/testing/web-platform/meta/css/css-shadow-parts/invalidation-change-part-name-idl-setter.html.ini b/testing/web-platform/meta/css/css-shadow-parts/invalidation-change-part-name-idl-setter.html.ini deleted file mode 100644 index 86a4234681e1..000000000000 --- a/testing/web-platform/meta/css/css-shadow-parts/invalidation-change-part-name-idl-setter.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[invalidation-change-part-name-idl-setter.html] - [Part in selected host changed color via part IDL attribute setter.] - expected: FAIL - diff --git a/testing/web-platform/meta/css/css-shadow-parts/part-name-idl.html.ini b/testing/web-platform/meta/css/css-shadow-parts/part-name-idl.html.ini deleted file mode 100644 index 3801e8071747..000000000000 --- a/testing/web-platform/meta/css/css-shadow-parts/part-name-idl.html.ini +++ /dev/null @@ -1,13 +0,0 @@ -[part-name-idl.html] - [Access to .part returns an empty DOMTokenList.] - expected: FAIL - - [Changes in DOMTokenList are refected in attribute.] - expected: FAIL - - [DOMTokenList created by access is persisted.] - expected: FAIL - - [Multiple names give a DOMTokenList with multiple entries.] - expected: FAIL -