Bug 1655413 [wpt PR 24763] - Make CSP default-src without 'unsafe-eval' block eval...
[gecko.git] / dom / html / HTMLSlotElement.h
blob136fa267af306eaf5604192ea6a64a72a8d549dc
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"
13 namespace mozilla {
14 namespace dom {
16 struct AssignedNodesOptions;
18 class HTMLSlotElement final : public nsGenericHTMLElement {
19 public:
20 explicit HTMLSlotElement(
21 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
22 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSlotElement, slot)
24 NS_DECL_ISUPPORTS_INHERITED
25 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSlotElement,
26 nsGenericHTMLElement)
27 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
29 // nsIContent
30 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
31 virtual void UnbindFromTree(bool aNullParent) override;
33 virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
34 const nsAttrValueOrString* aValue,
35 bool aNotify) override;
36 virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
37 const nsAttrValue* aValue,
38 const nsAttrValue* aOldValue,
39 nsIPrincipal* aSubjectPrincipal,
40 bool aNotify) override;
42 // WebIDL
43 void SetName(const nsAString& aName, ErrorResult& aRv) {
44 SetHTMLAttr(nsGkAtoms::name, aName, aRv);
47 void GetName(nsAString& aName) { GetHTMLAttr(nsGkAtoms::name, aName); }
49 void AssignedNodes(const AssignedNodesOptions& aOptions,
50 nsTArray<RefPtr<nsINode>>& aNodes);
52 void AssignedElements(const AssignedNodesOptions& aOptions,
53 nsTArray<RefPtr<Element>>& aNodes);
55 // Helper methods
56 const nsTArray<RefPtr<nsINode>>& AssignedNodes() const;
57 void InsertAssignedNode(uint32_t aIndex, nsIContent&);
58 void AppendAssignedNode(nsIContent&);
59 void RemoveAssignedNode(nsIContent&);
60 void ClearAssignedNodes();
62 void EnqueueSlotChangeEvent();
63 void RemovedFromSignalSlotList() {
64 MOZ_ASSERT(mInSignalSlotList);
65 mInSignalSlotList = false;
68 void FireSlotChangeEvent();
70 protected:
71 virtual ~HTMLSlotElement();
72 JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
74 nsTArray<RefPtr<nsINode>> mAssignedNodes;
76 // Whether we're in the signal slot list of our unit of related similar-origin
77 // browsing contexts.
79 // https://dom.spec.whatwg.org/#signal-slot-list
80 bool mInSignalSlotList = false;
83 } // namespace dom
84 } // namespace mozilla
86 #endif // mozilla_dom_HTMLSlotElement_h