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_HTMLTemplateElement_h
8 #define mozilla_dom_HTMLTemplateElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/ErrorResult.h"
12 #include "nsGenericHTMLElement.h"
13 #include "mozilla/dom/DocumentFragment.h"
14 #include "mozilla/dom/ShadowRootBinding.h"
15 #include "nsGkAtoms.h"
17 namespace mozilla::dom
{
19 class HTMLTemplateElement final
: public nsGenericHTMLElement
{
21 explicit HTMLTemplateElement(
22 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
25 NS_DECL_ISUPPORTS_INHERITED
27 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTemplateElement
, _template
);
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTemplateElement
,
32 void AfterSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
33 const nsAttrValue
* aValue
, const nsAttrValue
* aOldValue
,
34 nsIPrincipal
* aMaybeScriptedPrincipal
,
35 bool aNotify
) override
;
37 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
38 const nsAString
& aValue
,
39 nsIPrincipal
* aMaybeScriptedPrincipal
,
40 nsAttrValue
& aResult
) override
;
42 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
44 DocumentFragment
* Content() { return mContent
; }
45 void SetContent(DocumentFragment
* aContent
) { mContent
= aContent
; }
47 void GetShadowRootMode(nsAString
& aResult
) const {
48 GetEnumAttr(nsGkAtoms::shadowrootmode
, nullptr, aResult
);
50 void SetShadowRootMode(const nsAString
& aValue
) {
51 SetHTMLAttr(nsGkAtoms::shadowrootmode
, aValue
);
54 bool ShadowRootDelegatesFocus() const {
55 return GetBoolAttr(nsGkAtoms::shadowrootdelegatesfocus
);
57 void SetShadowRootDelegatesFocus(bool aValue
, ErrorResult
& aRv
) {
58 SetHTMLBoolAttr(nsGkAtoms::shadowrootdelegatesfocus
, aValue
, aRv
);
61 bool ShadowRootClonable() const {
62 return GetBoolAttr(nsGkAtoms::shadowrootclonable
);
64 void SetShadowRootClonable(bool aValue
, ErrorResult
& aRv
) {
65 SetHTMLBoolAttr(nsGkAtoms::shadowrootclonable
, aValue
, aRv
);
69 void SetHTMLUnsafe(const nsAString
& aHTML
) final
;
72 virtual ~HTMLTemplateElement();
74 virtual JSObject
* WrapNode(JSContext
* aCx
,
75 JS::Handle
<JSObject
*> aGivenProto
) override
;
77 RefPtr
<DocumentFragment
> mContent
;
78 Maybe
<ShadowRootMode
> mShadowRootMode
;
81 } // namespace mozilla::dom
83 #endif // mozilla_dom_HTMLTemplateElement_h