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 DOM_SVG_SVGSCRIPTELEMENT_H_
8 #define DOM_SVG_SVGSCRIPTELEMENT_H_
10 #include "SVGAnimatedString.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "mozilla/dom/ScriptElement.h"
13 #include "mozilla/dom/SVGElement.h"
15 nsresult
NS_NewSVGScriptElement(
16 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
,
17 mozilla::dom::FromParser aFromParser
);
19 namespace mozilla::dom
{
21 using SVGScriptElementBase
= SVGElement
;
23 class SVGScriptElement final
: public SVGScriptElementBase
,
24 public ScriptElement
{
26 friend nsresult(::NS_NewSVGScriptElement(
28 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
,
29 mozilla::dom::FromParser aFromParser
));
30 SVGScriptElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
,
31 FromParser aFromParser
);
33 JSObject
* WrapNode(JSContext
* aCx
,
34 JS::Handle
<JSObject
*> aGivenProto
) override
;
39 NS_DECL_ISUPPORTS_INHERITED
42 void GetScriptText(nsAString
& text
) const override
;
43 void GetScriptCharset(nsAString
& charset
) override
;
44 void FreezeExecutionAttrs(const Document
* aOwnerDoc
) override
;
45 CORSMode
GetCORSMode() const override
;
48 bool HasScriptContent() override
;
50 // nsIContent specializations:
51 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
52 bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
53 const nsAString
& aValue
,
54 nsIPrincipal
* aMaybeScriptedPrincipal
,
55 nsAttrValue
& aResult
) override
;
57 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
60 void GetType(nsAString
& aType
);
61 void SetType(const nsAString
& aType
, ErrorResult
& rv
);
62 bool Async() { return mForceAsync
|| GetBoolAttr(nsGkAtoms::async
); }
63 void SetAsync(bool aValue
) {
65 SetBoolAttr(nsGkAtoms::async
, aValue
);
67 bool Defer() { return GetBoolAttr(nsGkAtoms::defer
); }
68 void SetDefer(bool aDefer
) { SetBoolAttr(nsGkAtoms::defer
, aDefer
); }
69 void GetCrossOrigin(nsAString
& aCrossOrigin
);
70 void SetCrossOrigin(const nsAString
& aCrossOrigin
, ErrorResult
& aError
);
71 already_AddRefed
<DOMSVGAnimatedString
> Href();
74 ~SVGScriptElement() = default;
76 StringAttributesInfo
GetStringInfo() override
;
78 // SVG Script elements don't have the ability to set async properties on
79 // themselves, so this will always return false.
80 bool GetAsyncState() override
{ return false; }
82 nsIContent
* GetAsContent() override
{ return this; }
84 enum { HREF
, XLINK_HREF
};
85 SVGAnimatedString mStringAttributes
[2];
86 static StringInfo sStringInfo
[2];
89 } // namespace mozilla::dom
91 #endif // DOM_SVG_SVGSCRIPTELEMENT_H_