/work/obj-fuzz/dist/include/mozilla/dom/HTMLLinkElement.h
Line | Count | Source (jump to first uncovered line) |
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_HTMLLinkElement_h |
8 | | #define mozilla_dom_HTMLLinkElement_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "mozilla/dom/Link.h" |
12 | | #include "nsGenericHTMLElement.h" |
13 | | #include "nsStyleLinkElement.h" |
14 | | |
15 | | namespace mozilla { |
16 | | class EventChainPostVisitor; |
17 | | class EventChainPreVisitor; |
18 | | namespace dom { |
19 | | |
20 | | class HTMLLinkElement final : public nsGenericHTMLElement, |
21 | | public nsStyleLinkElement, |
22 | | public Link |
23 | | { |
24 | | public: |
25 | | explicit HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); |
26 | | |
27 | | // nsISupports |
28 | | NS_DECL_ISUPPORTS_INHERITED |
29 | | |
30 | | // CC |
31 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLLinkElement, |
32 | | nsGenericHTMLElement) |
33 | | |
34 | | NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLinkElement, link); |
35 | | NS_DECL_ADDSIZEOFEXCLUDINGTHIS |
36 | | |
37 | | void LinkAdded(); |
38 | | void LinkRemoved(); |
39 | | |
40 | | // EventTarget |
41 | | void GetEventTargetParent(EventChainPreVisitor& aVisitor) override; |
42 | | virtual nsresult PostHandleEvent( |
43 | | EventChainPostVisitor& aVisitor) override; |
44 | | |
45 | | // nsINode |
46 | | virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; |
47 | | virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
48 | | |
49 | | // nsIContent |
50 | | virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
51 | | nsIContent* aBindingParent) override; |
52 | | virtual void UnbindFromTree(bool aDeep = true, |
53 | | bool aNullParent = true) override; |
54 | | virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, |
55 | | const nsAttrValueOrString* aValue, |
56 | | bool aNotify) override; |
57 | | virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, |
58 | | const nsAttrValue* aValue, |
59 | | const nsAttrValue* aOldValue, |
60 | | nsIPrincipal* aSubjectPrincipal, |
61 | | bool aNotify) override; |
62 | | virtual bool IsLink(nsIURI** aURI) const override; |
63 | | virtual already_AddRefed<nsIURI> GetHrefURI() const override; |
64 | | |
65 | | // Element |
66 | | virtual bool ParseAttribute(int32_t aNamespaceID, |
67 | | nsAtom* aAttribute, |
68 | | const nsAString& aValue, |
69 | | nsIPrincipal* aMaybeScriptedPrincipal, |
70 | | nsAttrValue& aResult) override; |
71 | | virtual void GetLinkTarget(nsAString& aTarget) override; |
72 | | virtual EventStates IntrinsicState() const override; |
73 | | |
74 | | void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName); |
75 | | |
76 | | virtual void OnDNSPrefetchDeferred() override; |
77 | | virtual void OnDNSPrefetchRequested() override; |
78 | | virtual bool HasDeferredDNSPrefetchRequest() override; |
79 | | |
80 | | // WebIDL |
81 | | bool Disabled(); |
82 | | void SetDisabled(bool aDisabled); |
83 | | |
84 | | void GetHref(nsAString& aValue) |
85 | 0 | { |
86 | 0 | GetURIAttr(nsGkAtoms::href, nullptr, aValue); |
87 | 0 | } |
88 | | void SetHref(const nsAString& aHref, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv) |
89 | 0 | { |
90 | 0 | SetHTMLAttr(nsGkAtoms::href, aHref, aTriggeringPrincipal, aRv); |
91 | 0 | } |
92 | | void SetHref(const nsAString& aHref, ErrorResult& aRv) |
93 | 0 | { |
94 | 0 | SetHTMLAttr(nsGkAtoms::href, aHref, aRv); |
95 | 0 | } |
96 | | void GetCrossOrigin(nsAString& aResult) |
97 | 0 | { |
98 | 0 | // Null for both missing and invalid defaults is ok, since we |
99 | 0 | // always parse to an enum value, so we don't need an invalid |
100 | 0 | // default, and we _want_ the missing default to be null. |
101 | 0 | GetEnumAttr(nsGkAtoms::crossorigin, nullptr, aResult); |
102 | 0 | } |
103 | | void SetCrossOrigin(const nsAString& aCrossOrigin, ErrorResult& aError) |
104 | 0 | { |
105 | 0 | SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError); |
106 | 0 | } |
107 | | // nsAString for WebBrowserPersistLocalDocument |
108 | | void GetRel(nsAString& aValue) |
109 | 0 | { |
110 | 0 | GetHTMLAttr(nsGkAtoms::rel, aValue); |
111 | 0 | } |
112 | | void SetRel(const nsAString& aRel, ErrorResult& aRv) |
113 | 0 | { |
114 | 0 | SetHTMLAttr(nsGkAtoms::rel, aRel, aRv); |
115 | 0 | } |
116 | | nsDOMTokenList* RelList(); |
117 | | void GetMedia(DOMString& aValue) |
118 | 0 | { |
119 | 0 | GetHTMLAttr(nsGkAtoms::media, aValue); |
120 | 0 | } |
121 | | void SetMedia(const nsAString& aMedia, ErrorResult& aRv) |
122 | 0 | { |
123 | 0 | SetHTMLAttr(nsGkAtoms::media, aMedia, aRv); |
124 | 0 | } |
125 | | void GetHreflang(DOMString& aValue) |
126 | 0 | { |
127 | 0 | GetHTMLAttr(nsGkAtoms::hreflang, aValue); |
128 | 0 | } |
129 | | void SetHreflang(const nsAString& aHreflang, ErrorResult& aRv) |
130 | 0 | { |
131 | 0 | SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv); |
132 | 0 | } |
133 | | void GetAs(nsAString& aResult); |
134 | | void SetAs(const nsAString& aAs, ErrorResult& aRv) |
135 | 0 | { |
136 | 0 | SetAttr(nsGkAtoms::as ,aAs, aRv); |
137 | 0 | } |
138 | | nsDOMTokenList* Sizes() |
139 | 0 | { |
140 | 0 | return GetTokenList(nsGkAtoms::sizes); |
141 | 0 | } |
142 | | void GetType(DOMString& aValue) |
143 | 0 | { |
144 | 0 | GetHTMLAttr(nsGkAtoms::type, aValue); |
145 | 0 | } |
146 | | void SetType(const nsAString& aType, ErrorResult& aRv) |
147 | 0 | { |
148 | 0 | SetHTMLAttr(nsGkAtoms::type, aType, aRv); |
149 | 0 | } |
150 | | void GetCharset(nsAString& aValue) override |
151 | 0 | { |
152 | 0 | GetHTMLAttr(nsGkAtoms::charset, aValue); |
153 | 0 | } |
154 | | void SetCharset(const nsAString& aCharset, ErrorResult& aRv) |
155 | 0 | { |
156 | 0 | SetHTMLAttr(nsGkAtoms::charset, aCharset, aRv); |
157 | 0 | } |
158 | | void GetRev(DOMString& aValue) |
159 | 0 | { |
160 | 0 | GetHTMLAttr(nsGkAtoms::rev, aValue); |
161 | 0 | } |
162 | | void SetRev(const nsAString& aRev, ErrorResult& aRv) |
163 | 0 | { |
164 | 0 | SetHTMLAttr(nsGkAtoms::rev, aRev, aRv); |
165 | 0 | } |
166 | | void GetTarget(DOMString& aValue) |
167 | 0 | { |
168 | 0 | GetHTMLAttr(nsGkAtoms::target, aValue); |
169 | 0 | } |
170 | | void SetTarget(const nsAString& aTarget, ErrorResult& aRv) |
171 | 0 | { |
172 | 0 | SetHTMLAttr(nsGkAtoms::target, aTarget, aRv); |
173 | 0 | } |
174 | | void GetIntegrity(nsAString& aIntegrity) const |
175 | 0 | { |
176 | 0 | GetHTMLAttr(nsGkAtoms::integrity, aIntegrity); |
177 | 0 | } |
178 | | void SetIntegrity(const nsAString& aIntegrity, ErrorResult& aRv) |
179 | 0 | { |
180 | 0 | SetHTMLAttr(nsGkAtoms::integrity, aIntegrity, aRv); |
181 | 0 | } |
182 | | void SetReferrerPolicy(const nsAString& aReferrer, ErrorResult& aError) |
183 | 0 | { |
184 | 0 | SetHTMLAttr(nsGkAtoms::referrerpolicy, aReferrer, aError); |
185 | 0 | } |
186 | | void GetReferrerPolicy(nsAString& aReferrer) |
187 | 0 | { |
188 | 0 | GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer); |
189 | 0 | } |
190 | | |
191 | | CORSMode GetCORSMode() const |
192 | 0 | { |
193 | 0 | return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); |
194 | 0 | } |
195 | | |
196 | | void NodeInfoChanged(nsIDocument* aOldDoc) final |
197 | 0 | { |
198 | 0 | ClearHasPendingLinkUpdate(); |
199 | 0 | nsGenericHTMLElement::NodeInfoChanged(aOldDoc); |
200 | 0 | } |
201 | | |
202 | | static bool CheckPreloadAttrs(const nsAttrValue& aAs, const nsAString& aType, |
203 | | const nsAString& aMedia, nsIDocument* aDocument); |
204 | | protected: |
205 | | virtual ~HTMLLinkElement(); |
206 | | |
207 | | // nsStyleLinkElement |
208 | | Maybe<SheetInfo> GetStyleSheetInfo() final; |
209 | | |
210 | | protected: |
211 | | RefPtr<nsDOMTokenList> mRelList; |
212 | | }; |
213 | | |
214 | | } // namespace dom |
215 | | } // namespace mozilla |
216 | | |
217 | | #endif // mozilla_dom_HTMLLinkElement_h |