1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_HTMLSlotElement_h
8 #define mozilla_dom_HTMLSlotElement_h
10 #include "nsGenericHTMLElement.h"
12 #include "mozilla/dom/HTMLSlotElementBinding.h"
14 namespace mozilla::dom
{
16 class HTMLSlotElement final
: public nsGenericHTMLElement
{
18 explicit HTMLSlotElement(
19 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
20 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSlotElement
, slot
)
22 NS_DECL_ISUPPORTS_INHERITED
23 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSlotElement
,
25 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
28 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
29 void UnbindFromTree(UnbindContext
&) override
;
31 void BeforeSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
32 const nsAttrValue
* aValue
, bool aNotify
) override
;
33 void AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
34 const nsAttrValue
* aValue
, const nsAttrValue
* aOldValue
,
35 nsIPrincipal
* aSubjectPrincipal
, bool aNotify
) override
;
38 void SetName(const nsAString
& aName
, ErrorResult
& aRv
) {
39 SetHTMLAttr(nsGkAtoms::name
, aName
, aRv
);
42 void GetName(nsAString
& aName
) { GetHTMLAttr(nsGkAtoms::name
, aName
); }
44 void AssignedNodes(const AssignedNodesOptions
& aOptions
,
45 nsTArray
<RefPtr
<nsINode
>>& aNodes
);
47 void AssignedElements(const AssignedNodesOptions
& aOptions
,
48 nsTArray
<RefPtr
<Element
>>& aNodes
);
50 void Assign(const Sequence
<OwningElementOrText
>& aNodes
);
53 const nsTArray
<RefPtr
<nsINode
>>& AssignedNodes() const;
54 const nsTArray
<nsINode
*>& ManuallyAssignedNodes() const;
55 void InsertAssignedNode(uint32_t aIndex
, nsIContent
&);
56 void AppendAssignedNode(nsIContent
&);
57 void RemoveAssignedNode(nsIContent
&);
58 void ClearAssignedNodes();
60 void EnqueueSlotChangeEvent();
61 void RemovedFromSignalSlotList() {
62 MOZ_ASSERT(mInSignalSlotList
);
63 mInSignalSlotList
= false;
66 void FireSlotChangeEvent();
68 void RemoveManuallyAssignedNode(nsIContent
&);
71 virtual ~HTMLSlotElement();
72 JSObject
* WrapNode(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) final
;
74 nsTArray
<RefPtr
<nsINode
>> mAssignedNodes
;
75 nsTArray
<nsINode
*> mManuallyAssignedNodes
;
77 // Whether we're in the signal slot list of our unit of related similar-origin
80 // https://dom.spec.whatwg.org/#signal-slot-list
81 bool mInSignalSlotList
= false;
83 bool mInManualShadowRoot
= false;
86 } // namespace mozilla::dom
88 #endif // mozilla_dom_HTMLSlotElement_h