Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / dom / svg / SVGScriptElement.h
blob5f318eb0a519eff75db1868ca80454f851fc8dbd
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 {
25 protected:
26 friend nsresult(::NS_NewSVGScriptElement(
27 nsIContent** aResult,
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;
36 public:
37 // interfaces:
39 NS_DECL_ISUPPORTS_INHERITED
41 // nsIScriptElement
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;
46 FetchPriority GetFetchPriority() const override;
48 // ScriptElement
49 bool HasScriptContent() override;
51 // nsIContent specializations:
52 nsresult BindToTree(BindContext&, nsINode& aParent) override;
53 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
54 const nsAString& aValue,
55 nsIPrincipal* aMaybeScriptedPrincipal,
56 nsAttrValue& aResult) override;
58 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
60 // WebIDL
61 void GetType(nsAString& aType);
62 void SetType(const nsAString& aType, ErrorResult& rv);
63 bool Async() { return mForceAsync || GetBoolAttr(nsGkAtoms::async); }
64 void SetAsync(bool aValue) {
65 mForceAsync = false;
66 SetBoolAttr(nsGkAtoms::async, aValue);
68 bool Defer() { return GetBoolAttr(nsGkAtoms::defer); }
69 void SetDefer(bool aDefer) { SetBoolAttr(nsGkAtoms::defer, aDefer); }
70 void GetCrossOrigin(nsAString& aCrossOrigin);
71 void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError);
72 already_AddRefed<DOMSVGAnimatedString> Href();
74 protected:
75 ~SVGScriptElement() = default;
77 StringAttributesInfo GetStringInfo() override;
79 // SVG Script elements don't have the ability to set async properties on
80 // themselves, so this will always return false.
81 bool GetAsyncState() override { return false; }
83 nsIContent* GetAsContent() override { return this; }
85 enum { HREF, XLINK_HREF };
86 SVGAnimatedString mStringAttributes[2];
87 static StringInfo sStringInfo[2];
90 } // namespace mozilla::dom
92 #endif // DOM_SVG_SVGSCRIPTELEMENT_H_