Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_HTMLScriptElement_h
8 : #define mozilla_dom_HTMLScriptElement_h
9 :
10 : #include "nsIDOMHTMLScriptElement.h"
11 : #include "nsGenericHTMLElement.h"
12 : #include "mozilla/Attributes.h"
13 : #include "mozilla/dom/ScriptElement.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class HTMLScriptElement final : public nsGenericHTMLElement,
19 : public nsIDOMHTMLScriptElement,
20 : public ScriptElement
21 : {
22 : public:
23 : using Element::GetText;
24 : using Element::SetText;
25 :
26 : HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
27 : FromParser aFromParser);
28 :
29 : // nsISupports
30 : NS_DECL_ISUPPORTS_INHERITED
31 :
32 : NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) override;
33 : using nsGenericHTMLElement::SetInnerHTML;
34 : virtual void SetInnerHTML(const nsAString& aInnerHTML,
35 : mozilla::ErrorResult& aError) override;
36 :
37 : // nsIDOMHTMLScriptElement
38 : NS_DECL_NSIDOMHTMLSCRIPTELEMENT
39 :
40 : // nsIScriptElement
41 : virtual bool GetScriptType(nsAString& type) override;
42 : virtual void GetScriptText(nsAString& text) override;
43 : virtual void GetScriptCharset(nsAString& charset) override;
44 : virtual void FreezeUriAsyncDefer() override;
45 : virtual CORSMode GetCORSMode() const override;
46 :
47 : // nsIContent
48 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
49 : nsIContent* aBindingParent,
50 : bool aCompileEventHandlers) override;
51 : virtual bool ParseAttribute(int32_t aNamespaceID,
52 : nsIAtom* aAttribute,
53 : const nsAString& aValue,
54 : nsAttrValue& aResult) override;
55 :
56 : virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
57 : bool aPreallocateChildren) const override;
58 :
59 : // Element
60 : virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
61 : const nsAttrValue* aValue,
62 : const nsAttrValue* aOldValue,
63 : bool aNotify) override;
64 :
65 : // WebIDL
66 : void SetText(const nsAString& aValue, ErrorResult& rv);
67 : void SetCharset(const nsAString& aCharset, ErrorResult& rv);
68 : void SetDefer(bool aDefer, ErrorResult& rv);
69 : bool Defer();
70 : void SetSrc(const nsAString& aSrc, ErrorResult& rv);
71 : void SetType(const nsAString& aType, ErrorResult& rv);
72 : void SetHtmlFor(const nsAString& aHtmlFor, ErrorResult& rv);
73 : void SetEvent(const nsAString& aEvent, ErrorResult& rv);
74 0 : void GetCrossOrigin(nsAString& aResult)
75 : {
76 : // Null for both missing and invalid defaults is ok, since we
77 : // always parse to an enum value, so we don't need an invalid
78 : // default, and we _want_ the missing default to be null.
79 0 : GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult);
80 0 : }
81 0 : void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError)
82 : {
83 0 : SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
84 0 : }
85 0 : void GetIntegrity(nsAString& aIntegrity)
86 : {
87 0 : GetHTMLAttr(nsGkAtoms::integrity, aIntegrity);
88 0 : }
89 0 : void SetIntegrity(const nsAString& aIntegrity, ErrorResult& rv)
90 : {
91 0 : SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, rv);
92 0 : }
93 : bool Async();
94 : void SetAsync(bool aValue, ErrorResult& rv);
95 : bool NoModule();
96 : void SetNoModule(bool aValue, ErrorResult& rv);
97 :
98 : protected:
99 : virtual ~HTMLScriptElement();
100 :
101 : virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
102 :
103 : // ScriptElement
104 : virtual bool HasScriptContent() override;
105 : };
106 :
107 : } // namespace dom
108 : } // namespace mozilla
109 :
110 : #endif // mozilla_dom_HTMLScriptElement_h
|