Bug 1494333 - index crons just like artifacts r=Callek
[gecko.git] / dom / html / HTMLScriptElement.h
blob4196d5b40b0fdc45a43ea297895f1eff4300ecb1
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_HTMLScriptElement_h
8 #define mozilla_dom_HTMLScriptElement_h
10 #include "nsGenericHTMLElement.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/ScriptElement.h"
14 namespace mozilla {
15 namespace dom {
17 class HTMLScriptElement final : public nsGenericHTMLElement,
18 public ScriptElement
20 public:
21 using Element::GetText;
23 HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
24 FromParser aFromParser);
26 // nsISupports
27 NS_DECL_ISUPPORTS_INHERITED
29 void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError) override;
30 virtual void SetInnerHTML(const nsAString& aInnerHTML,
31 nsIPrincipal* aSubjectPrincipal,
32 mozilla::ErrorResult& aError) override;
34 // nsIScriptElement
35 virtual bool GetScriptType(nsAString& type) override;
36 virtual void GetScriptText(nsAString& text) override;
37 virtual void GetScriptCharset(nsAString& charset) override;
38 virtual void FreezeExecutionAttrs(nsIDocument* aOwnerDoc) override;
39 virtual CORSMode GetCORSMode() const override;
41 // nsIContent
42 virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
43 nsIContent* aBindingParent) override;
44 virtual bool ParseAttribute(int32_t aNamespaceID,
45 nsAtom* aAttribute,
46 const nsAString& aValue,
47 nsIPrincipal* aMaybeScriptedPrincipal,
48 nsAttrValue& aResult) override;
50 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
52 // Element
53 virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
54 const nsAttrValue* aValue,
55 const nsAttrValue* aOldValue,
56 nsIPrincipal* aMaybeScriptedPrincipal,
57 bool aNotify) override;
59 // WebIDL
60 void GetText(nsAString& aValue, ErrorResult& aRv);
62 void SetText(const nsAString& aValue, ErrorResult& aRv);
64 void GetCharset(nsAString& aCharset)
66 GetHTMLAttr(nsGkAtoms::charset, aCharset);
68 void SetCharset(const nsAString& aCharset, ErrorResult& aRv)
70 SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv);
73 bool Defer()
75 return GetBoolAttr(nsGkAtoms::defer);
77 void SetDefer(bool aDefer, ErrorResult& aRv)
79 SetHTMLBoolAttr(nsGkAtoms::defer, aDefer, aRv);
82 void GetSrc(nsAString& aSrc)
84 GetURIAttr(nsGkAtoms::src, nullptr, aSrc);
86 void SetSrc(const nsAString& aSrc, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv)
88 SetHTMLAttr(nsGkAtoms::src, aSrc, aTriggeringPrincipal, aRv);
91 void GetType(nsAString& aType)
93 GetHTMLAttr(nsGkAtoms::type, aType);
95 void SetType(const nsAString& aType, ErrorResult& aRv)
97 SetHTMLAttr(nsGkAtoms::type, aType, aRv);
100 void GetHtmlFor(nsAString& aHtmlFor)
102 GetHTMLAttr(nsGkAtoms::_for, aHtmlFor);
104 void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& aRv)
106 SetHTMLAttr(nsGkAtoms::_for, aHtmlFor, aRv);
109 void GetEvent(nsAString& aEvent)
111 GetHTMLAttr(nsGkAtoms::event, aEvent);
113 void SetEvent(const nsAString& aEvent, ErrorResult& aRv)
115 SetHTMLAttr(nsGkAtoms::event, aEvent, aRv);
118 bool Async()
120 return mForceAsync || GetBoolAttr(nsGkAtoms::async);
123 void SetAsync(bool aValue, ErrorResult& aRv)
125 mForceAsync = false;
126 SetHTMLBoolAttr(nsGkAtoms::async, aValue, aRv);
129 bool NoModule()
131 return GetBoolAttr(nsGkAtoms::nomodule);
134 void SetNoModule(bool aValue, ErrorResult& aRv)
136 SetHTMLBoolAttr(nsGkAtoms::nomodule, aValue, aRv);
139 void GetCrossOrigin(nsAString& aResult)
141 // Null for both missing and invalid defaults is ok, since we
142 // always parse to an enum value, so we don't need an invalid
143 // default, and we _want_ the missing default to be null.
144 GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult);
146 void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError)
148 SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
150 void GetIntegrity(nsAString& aIntegrity)
152 GetHTMLAttr(nsGkAtoms::integrity, aIntegrity);
154 void SetIntegrity(const nsAString& aIntegrity, ErrorResult& aRv)
156 SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, aRv);
159 protected:
160 virtual ~HTMLScriptElement();
162 virtual bool GetAsyncState() override
164 return Async();
167 virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
169 // ScriptElement
170 virtual bool HasScriptContent() override;
173 } // namespace dom
174 } // namespace mozilla
176 #endif // mozilla_dom_HTMLScriptElement_h