/work/obj-fuzz/dist/include/mozilla/dom/HTMLObjectElement.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_HTMLObjectElement_h |
8 | | #define mozilla_dom_HTMLObjectElement_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "nsGenericHTMLElement.h" |
12 | | #include "nsObjectLoadingContent.h" |
13 | | #include "nsIConstraintValidation.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | class HTMLFormSubmission; |
19 | | |
20 | | class HTMLObjectElement final : public nsGenericHTMLFormElement |
21 | | , public nsObjectLoadingContent |
22 | | , public nsIConstraintValidation |
23 | | { |
24 | | public: |
25 | | explicit HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, |
26 | | FromParser aFromParser = NOT_FROM_PARSER); |
27 | | |
28 | | // nsISupports |
29 | | NS_DECL_ISUPPORTS_INHERITED |
30 | | |
31 | | NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLObjectElement, object) |
32 | | virtual int32_t TabIndexDefault() override; |
33 | | |
34 | | #ifdef XP_MACOSX |
35 | | // EventTarget |
36 | | NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override; |
37 | | // Helper methods |
38 | | static void OnFocusBlurPlugin(Element* aElement, bool aFocus); |
39 | | static void HandleFocusBlurPlugin(Element* aElement, WidgetEvent* aEvent); |
40 | | static void HandlePluginCrashed(Element* aElement); |
41 | | static void HandlePluginInstantiated(Element* aElement); |
42 | | // Weak pointer. Null if last action was blur. |
43 | | static Element* sLastFocused; |
44 | | #endif |
45 | | |
46 | | // Element |
47 | | virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override; |
48 | | |
49 | | // EventTarget |
50 | | virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override; |
51 | | |
52 | | virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, |
53 | | nsIContent *aBindingParent) override; |
54 | | virtual void UnbindFromTree(bool aDeep = true, |
55 | | bool aNullParent = true) override; |
56 | | |
57 | | virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override; |
58 | | virtual IMEState GetDesiredIMEState() override; |
59 | | |
60 | | // Overriden nsIFormControl methods |
61 | | NS_IMETHOD Reset() override; |
62 | | NS_IMETHOD SubmitNamesValues(HTMLFormSubmission *aFormSubmission) override; |
63 | | |
64 | | virtual void DoneAddingChildren(bool aHaveNotified) override; |
65 | | virtual bool IsDoneAddingChildren() override; |
66 | | |
67 | | virtual bool ParseAttribute(int32_t aNamespaceID, |
68 | | nsAtom *aAttribute, |
69 | | const nsAString &aValue, |
70 | | nsIPrincipal* aMaybeScriptedPrincipal, |
71 | | nsAttrValue &aResult) override; |
72 | | virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override; |
73 | | NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom *aAttribute) const override; |
74 | | virtual EventStates IntrinsicState() const override; |
75 | | virtual void DestroyContent() override; |
76 | | |
77 | | // nsObjectLoadingContent |
78 | | virtual uint32_t GetCapabilities() const override; |
79 | | |
80 | | virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; |
81 | | |
82 | | nsresult CopyInnerTo(Element* aDest); |
83 | | |
84 | 0 | void StartObjectLoad() { StartObjectLoad(true, false); } |
85 | | |
86 | | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLObjectElement, |
87 | | nsGenericHTMLFormElement) |
88 | | |
89 | | // Web IDL binding methods |
90 | | void GetData(DOMString& aValue) |
91 | 0 | { |
92 | 0 | GetURIAttr(nsGkAtoms::data, nsGkAtoms::codebase, aValue); |
93 | 0 | } |
94 | | void SetData(const nsAString& aValue, ErrorResult& aRv) |
95 | 0 | { |
96 | 0 | SetHTMLAttr(nsGkAtoms::data, aValue, aRv); |
97 | 0 | } |
98 | | void GetType(DOMString& aValue) |
99 | 0 | { |
100 | 0 | GetHTMLAttr(nsGkAtoms::type, aValue); |
101 | 0 | } |
102 | | void SetType(const nsAString& aValue, ErrorResult& aRv) |
103 | 0 | { |
104 | 0 | SetHTMLAttr(nsGkAtoms::type, aValue, aRv); |
105 | 0 | } |
106 | | bool TypeMustMatch() |
107 | 0 | { |
108 | 0 | return GetBoolAttr(nsGkAtoms::typemustmatch); |
109 | 0 | } |
110 | | void SetTypeMustMatch(bool aValue, ErrorResult& aRv) |
111 | 0 | { |
112 | 0 | SetHTMLBoolAttr(nsGkAtoms::typemustmatch, aValue, aRv); |
113 | 0 | } |
114 | | void GetName(DOMString& aValue) |
115 | 0 | { |
116 | 0 | GetHTMLAttr(nsGkAtoms::name, aValue); |
117 | 0 | } |
118 | | void SetName(const nsAString& aValue, ErrorResult& aRv) |
119 | 0 | { |
120 | 0 | SetHTMLAttr(nsGkAtoms::name, aValue, aRv); |
121 | 0 | } |
122 | | void GetUseMap(DOMString& aValue) |
123 | 0 | { |
124 | 0 | GetHTMLAttr(nsGkAtoms::usemap, aValue); |
125 | 0 | } |
126 | | void SetUseMap(const nsAString& aValue, ErrorResult& aRv) |
127 | 0 | { |
128 | 0 | SetHTMLAttr(nsGkAtoms::usemap, aValue, aRv); |
129 | 0 | } |
130 | | using nsGenericHTMLFormElement::GetForm; |
131 | | void GetWidth(DOMString& aValue) |
132 | 0 | { |
133 | 0 | GetHTMLAttr(nsGkAtoms::width, aValue); |
134 | 0 | } |
135 | | void SetWidth(const nsAString& aValue, ErrorResult& aRv) |
136 | 0 | { |
137 | 0 | SetHTMLAttr(nsGkAtoms::width, aValue, aRv); |
138 | 0 | } |
139 | | void GetHeight(DOMString& aValue) |
140 | 0 | { |
141 | 0 | GetHTMLAttr(nsGkAtoms::height, aValue); |
142 | 0 | } |
143 | | void SetHeight(const nsAString& aValue, ErrorResult& aRv) |
144 | 0 | { |
145 | 0 | SetHTMLAttr(nsGkAtoms::height, aValue, aRv); |
146 | 0 | } |
147 | | using nsObjectLoadingContent::GetContentDocument; |
148 | | |
149 | | nsPIDOMWindowOuter* |
150 | | GetContentWindow(nsIPrincipal& aSubjectPrincipal); |
151 | | |
152 | | using nsIConstraintValidation::GetValidationMessage; |
153 | | using nsIConstraintValidation::SetCustomValidity; |
154 | | void GetAlign(DOMString& aValue) |
155 | 0 | { |
156 | 0 | GetHTMLAttr(nsGkAtoms::align, aValue); |
157 | 0 | } |
158 | | void SetAlign(const nsAString& aValue, ErrorResult& aRv) |
159 | 0 | { |
160 | 0 | SetHTMLAttr(nsGkAtoms::align, aValue, aRv); |
161 | 0 | } |
162 | | void GetArchive(DOMString& aValue) |
163 | 0 | { |
164 | 0 | GetHTMLAttr(nsGkAtoms::archive, aValue); |
165 | 0 | } |
166 | | void SetArchive(const nsAString& aValue, ErrorResult& aRv) |
167 | 0 | { |
168 | 0 | SetHTMLAttr(nsGkAtoms::archive, aValue, aRv); |
169 | 0 | } |
170 | | void GetCode(DOMString& aValue) |
171 | 0 | { |
172 | 0 | GetHTMLAttr(nsGkAtoms::code, aValue); |
173 | 0 | } |
174 | | void SetCode(const nsAString& aValue, ErrorResult& aRv) |
175 | 0 | { |
176 | 0 | SetHTMLAttr(nsGkAtoms::code, aValue, aRv); |
177 | 0 | } |
178 | | bool Declare() |
179 | 0 | { |
180 | 0 | return GetBoolAttr(nsGkAtoms::declare); |
181 | 0 | } |
182 | | void SetDeclare(bool aValue, ErrorResult& aRv) |
183 | 0 | { |
184 | 0 | SetHTMLBoolAttr(nsGkAtoms::declare, aValue, aRv); |
185 | 0 | } |
186 | | uint32_t Hspace() |
187 | 0 | { |
188 | 0 | return GetUnsignedIntAttr(nsGkAtoms::hspace, 0); |
189 | 0 | } |
190 | | void SetHspace(uint32_t aValue, ErrorResult& aRv) |
191 | 0 | { |
192 | 0 | SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, 0, aRv); |
193 | 0 | } |
194 | | void GetStandby(DOMString& aValue) |
195 | 0 | { |
196 | 0 | GetHTMLAttr(nsGkAtoms::standby, aValue); |
197 | 0 | } |
198 | | void SetStandby(const nsAString& aValue, ErrorResult& aRv) |
199 | 0 | { |
200 | 0 | SetHTMLAttr(nsGkAtoms::standby, aValue, aRv); |
201 | 0 | } |
202 | | uint32_t Vspace() |
203 | 0 | { |
204 | 0 | return GetUnsignedIntAttr(nsGkAtoms::vspace, 0); |
205 | 0 | } |
206 | | void SetVspace(uint32_t aValue, ErrorResult& aRv) |
207 | 0 | { |
208 | 0 | SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, 0, aRv); |
209 | 0 | } |
210 | | void GetCodeBase(DOMString& aValue) |
211 | 0 | { |
212 | 0 | GetURIAttr(nsGkAtoms::codebase, nullptr, aValue); |
213 | 0 | } |
214 | | void SetCodeBase(const nsAString& aValue, ErrorResult& aRv) |
215 | 0 | { |
216 | 0 | SetHTMLAttr(nsGkAtoms::codebase, aValue, aRv); |
217 | 0 | } |
218 | | void GetCodeType(DOMString& aValue) |
219 | 0 | { |
220 | 0 | GetHTMLAttr(nsGkAtoms::codetype, aValue); |
221 | 0 | } |
222 | | void SetCodeType(const nsAString& aValue, ErrorResult& aRv) |
223 | 0 | { |
224 | 0 | SetHTMLAttr(nsGkAtoms::codetype, aValue, aRv); |
225 | 0 | } |
226 | | void GetBorder(DOMString& aValue) |
227 | 0 | { |
228 | 0 | GetHTMLAttr(nsGkAtoms::border, aValue); |
229 | 0 | } |
230 | | void SetBorder(const nsAString& aValue, ErrorResult& aRv) |
231 | 0 | { |
232 | 0 | SetHTMLAttr(nsGkAtoms::border, aValue, aRv); |
233 | 0 | } |
234 | | |
235 | | nsIDocument* |
236 | | GetSVGDocument(nsIPrincipal& aSubjectPrincipal) |
237 | 0 | { |
238 | 0 | return GetContentDocument(aSubjectPrincipal); |
239 | 0 | } |
240 | | |
241 | | /** |
242 | | * Calls LoadObject with the correct arguments to start the plugin load. |
243 | | */ |
244 | | void StartObjectLoad(bool aNotify, bool aForceLoad); |
245 | | |
246 | | NS_FORWARD_NSIFRAMELOADEROWNER(nsObjectLoadingContent::) |
247 | | |
248 | | protected: |
249 | | // Override for nsImageLoadingContent. |
250 | 0 | nsIContent* AsContent() override { return this; } |
251 | | |
252 | | virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, |
253 | | const nsAttrValue* aValue, |
254 | | const nsAttrValue* aOldValue, |
255 | | nsIPrincipal* aSubjectPrincipal, |
256 | | bool aNotify) override; |
257 | | virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, |
258 | | const nsAttrValueOrString& aValue, |
259 | | bool aNotify) override; |
260 | | |
261 | | private: |
262 | | /** |
263 | | * Returns if the element is currently focusable regardless of it's tabindex |
264 | | * value. This is used to know the default tabindex value. |
265 | | */ |
266 | | bool IsFocusableForTabIndex(); |
267 | | |
268 | | nsContentPolicyType GetContentPolicyType() const override |
269 | 0 | { |
270 | 0 | return nsIContentPolicy::TYPE_INTERNAL_OBJECT; |
271 | 0 | } |
272 | | |
273 | | virtual ~HTMLObjectElement(); |
274 | | |
275 | | virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override; |
276 | | |
277 | | static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, |
278 | | MappedDeclarations&); |
279 | | |
280 | | /** |
281 | | * This function is called by AfterSetAttr and OnAttrSetButNotChanged. |
282 | | * This function will be called by AfterSetAttr whether the attribute is being |
283 | | * set or unset. |
284 | | * |
285 | | * @param aNamespaceID the namespace of the attr being set |
286 | | * @param aName the localname of the attribute being set |
287 | | * @param aNotify Whether we plan to notify document observers. |
288 | | */ |
289 | | nsresult AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, |
290 | | bool aNotify); |
291 | | |
292 | | bool mIsDoneAddingChildren; |
293 | | }; |
294 | | |
295 | | } // namespace dom |
296 | | } // namespace mozilla |
297 | | |
298 | | #endif // mozilla_dom_HTMLObjectElement_h |