Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLSlotElement.h
blob1659ca96839ab129e629857306e1afdf438ec1da
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"
11 #include "nsTArray.h"
12 #include "mozilla/dom/HTMLSlotElementBinding.h"
14 namespace mozilla::dom {
16 class HTMLSlotElement final : public nsGenericHTMLElement {
17 public:
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,
24 nsGenericHTMLElement)
25 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
27 // nsIContent
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;
37 // WebIDL
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);
52 // Helper methods
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&);
70 protected:
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
78 // browsing contexts.
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