/work/obj-fuzz/dom/bindings/HTMLHRElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM HTMLHRElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "HTMLElementBinding.h" |
4 | | #include "HTMLHRElementBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/CustomElementRegistry.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/DocGroup.h" |
11 | | #include "mozilla/dom/HTMLHRElement.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/PrimitiveConversions.h" |
14 | | #include "mozilla/dom/XrayExpandoClass.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
20 | | using namespace mozilla::dom::binding_detail; |
21 | | |
22 | | |
23 | | namespace HTMLHRElement_Binding { |
24 | | |
25 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value, |
26 | | "Can't inherit from an interface with a different ownership model."); |
27 | | |
28 | | MOZ_CAN_RUN_SCRIPT static bool |
29 | | get_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args) |
30 | 0 | { |
31 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLHRElement.align", DOM, cx); |
32 | 0 |
|
33 | 0 | DOMString result; |
34 | 0 | self->GetAlign(result); |
35 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
36 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
37 | 0 | return false; |
38 | 0 | } |
39 | 0 | return true; |
40 | 0 | } |
41 | | |
42 | | MOZ_CAN_RUN_SCRIPT static bool |
43 | | set_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args) |
44 | 0 | { |
45 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLHRElement.align", DOM, cx); |
46 | 0 |
|
47 | 0 | binding_detail::FakeString arg0; |
48 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
49 | 0 | return false; |
50 | 0 | } |
51 | 0 | Maybe<AutoCEReaction> ceReaction; |
52 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
53 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
54 | 0 | if (docGroup) { |
55 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
56 | 0 | } |
57 | 0 | } |
58 | 0 | FastErrorResult rv; |
59 | 0 | self->SetAlign(NonNullHelper(Constify(arg0)), rv); |
60 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
61 | 0 | return false; |
62 | 0 | } |
63 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
64 | 0 |
|
65 | 0 | return true; |
66 | 0 | } |
67 | | |
68 | | static const JSJitInfo align_getterinfo = { |
69 | | { (JSJitGetterOp)get_align }, |
70 | | { prototypes::id::HTMLHRElement }, |
71 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
72 | | JSJitInfo::Getter, |
73 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
74 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
75 | | false, /* isInfallible. False in setters. */ |
76 | | false, /* isMovable. Not relevant for setters. */ |
77 | | false, /* isEliminatable. Not relevant for setters. */ |
78 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
79 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
80 | | false, /* isTypedMethod. Only relevant for methods. */ |
81 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
82 | | }; |
83 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
84 | | static_assert(0 < 1, "There is no slot for us"); |
85 | | static const JSJitInfo align_setterinfo = { |
86 | | { (JSJitGetterOp)set_align }, |
87 | | { prototypes::id::HTMLHRElement }, |
88 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
89 | | JSJitInfo::Setter, |
90 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
91 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
92 | | false, /* isInfallible. False in setters. */ |
93 | | false, /* isMovable. Not relevant for setters. */ |
94 | | false, /* isEliminatable. Not relevant for setters. */ |
95 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
96 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
97 | | false, /* isTypedMethod. Only relevant for methods. */ |
98 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
99 | | }; |
100 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
101 | | static_assert(0 < 1, "There is no slot for us"); |
102 | | |
103 | | MOZ_CAN_RUN_SCRIPT static bool |
104 | | get_color(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args) |
105 | 0 | { |
106 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLHRElement.color", DOM, cx); |
107 | 0 |
|
108 | 0 | DOMString result; |
109 | 0 | self->GetColor(result); |
110 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
111 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
112 | 0 | return false; |
113 | 0 | } |
114 | 0 | return true; |
115 | 0 | } |
116 | | |
117 | | MOZ_CAN_RUN_SCRIPT static bool |
118 | | set_color(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args) |
119 | 0 | { |
120 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLHRElement.color", DOM, cx); |
121 | 0 |
|
122 | 0 | binding_detail::FakeString arg0; |
123 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
124 | 0 | return false; |
125 | 0 | } |
126 | 0 | Maybe<AutoCEReaction> ceReaction; |
127 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
128 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
129 | 0 | if (docGroup) { |
130 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
131 | 0 | } |
132 | 0 | } |
133 | 0 | FastErrorResult rv; |
134 | 0 | self->SetColor(NonNullHelper(Constify(arg0)), rv); |
135 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
136 | 0 | return false; |
137 | 0 | } |
138 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
139 | 0 |
|
140 | 0 | return true; |
141 | 0 | } |
142 | | |
143 | | static const JSJitInfo color_getterinfo = { |
144 | | { (JSJitGetterOp)get_color }, |
145 | | { prototypes::id::HTMLHRElement }, |
146 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
147 | | JSJitInfo::Getter, |
148 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
149 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
150 | | false, /* isInfallible. False in setters. */ |
151 | | false, /* isMovable. Not relevant for setters. */ |
152 | | false, /* isEliminatable. Not relevant for setters. */ |
153 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
154 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
155 | | false, /* isTypedMethod. Only relevant for methods. */ |
156 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
157 | | }; |
158 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
159 | | static_assert(0 < 1, "There is no slot for us"); |
160 | | static const JSJitInfo color_setterinfo = { |
161 | | { (JSJitGetterOp)set_color }, |
162 | | { prototypes::id::HTMLHRElement }, |
163 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
164 | | JSJitInfo::Setter, |
165 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
166 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
167 | | false, /* isInfallible. False in setters. */ |
168 | | false, /* isMovable. Not relevant for setters. */ |
169 | | false, /* isEliminatable. Not relevant for setters. */ |
170 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
171 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
172 | | false, /* isTypedMethod. Only relevant for methods. */ |
173 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
174 | | }; |
175 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
176 | | static_assert(0 < 1, "There is no slot for us"); |
177 | | |
178 | | MOZ_CAN_RUN_SCRIPT static bool |
179 | | get_noShade(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args) |
180 | 0 | { |
181 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLHRElement.noShade", DOM, cx); |
182 | 0 |
|
183 | 0 | bool result(self->NoShade()); |
184 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
185 | 0 | args.rval().setBoolean(result); |
186 | 0 | return true; |
187 | 0 | } |
188 | | |
189 | | MOZ_CAN_RUN_SCRIPT static bool |
190 | | set_noShade(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args) |
191 | 0 | { |
192 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLHRElement.noShade", DOM, cx); |
193 | 0 |
|
194 | 0 | bool arg0; |
195 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
196 | 0 | return false; |
197 | 0 | } |
198 | 0 | Maybe<AutoCEReaction> ceReaction; |
199 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
200 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
201 | 0 | if (docGroup) { |
202 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
203 | 0 | } |
204 | 0 | } |
205 | 0 | FastErrorResult rv; |
206 | 0 | self->SetNoShade(arg0, rv); |
207 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
208 | 0 | return false; |
209 | 0 | } |
210 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
211 | 0 |
|
212 | 0 | return true; |
213 | 0 | } |
214 | | |
215 | | static const JSJitInfo noShade_getterinfo = { |
216 | | { (JSJitGetterOp)get_noShade }, |
217 | | { prototypes::id::HTMLHRElement }, |
218 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
219 | | JSJitInfo::Getter, |
220 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
221 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
222 | | true, /* isInfallible. False in setters. */ |
223 | | false, /* isMovable. Not relevant for setters. */ |
224 | | false, /* isEliminatable. Not relevant for setters. */ |
225 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
226 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
227 | | false, /* isTypedMethod. Only relevant for methods. */ |
228 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
229 | | }; |
230 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
231 | | static_assert(0 < 1, "There is no slot for us"); |
232 | | static const JSJitInfo noShade_setterinfo = { |
233 | | { (JSJitGetterOp)set_noShade }, |
234 | | { prototypes::id::HTMLHRElement }, |
235 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
236 | | JSJitInfo::Setter, |
237 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
238 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
239 | | false, /* isInfallible. False in setters. */ |
240 | | false, /* isMovable. Not relevant for setters. */ |
241 | | false, /* isEliminatable. Not relevant for setters. */ |
242 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
243 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
244 | | false, /* isTypedMethod. Only relevant for methods. */ |
245 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
246 | | }; |
247 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
248 | | static_assert(0 < 1, "There is no slot for us"); |
249 | | |
250 | | MOZ_CAN_RUN_SCRIPT static bool |
251 | | get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args) |
252 | 0 | { |
253 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLHRElement.size", DOM, cx); |
254 | 0 |
|
255 | 0 | DOMString result; |
256 | 0 | self->GetSize(result); |
257 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
258 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
259 | 0 | return false; |
260 | 0 | } |
261 | 0 | return true; |
262 | 0 | } |
263 | | |
264 | | MOZ_CAN_RUN_SCRIPT static bool |
265 | | set_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args) |
266 | 0 | { |
267 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLHRElement.size", DOM, cx); |
268 | 0 |
|
269 | 0 | binding_detail::FakeString arg0; |
270 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
271 | 0 | return false; |
272 | 0 | } |
273 | 0 | Maybe<AutoCEReaction> ceReaction; |
274 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
275 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
276 | 0 | if (docGroup) { |
277 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
278 | 0 | } |
279 | 0 | } |
280 | 0 | FastErrorResult rv; |
281 | 0 | self->SetSize(NonNullHelper(Constify(arg0)), rv); |
282 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
283 | 0 | return false; |
284 | 0 | } |
285 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
286 | 0 |
|
287 | 0 | return true; |
288 | 0 | } |
289 | | |
290 | | static const JSJitInfo size_getterinfo = { |
291 | | { (JSJitGetterOp)get_size }, |
292 | | { prototypes::id::HTMLHRElement }, |
293 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
294 | | JSJitInfo::Getter, |
295 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
296 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
297 | | false, /* isInfallible. False in setters. */ |
298 | | false, /* isMovable. Not relevant for setters. */ |
299 | | false, /* isEliminatable. Not relevant for setters. */ |
300 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
301 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
302 | | false, /* isTypedMethod. Only relevant for methods. */ |
303 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
304 | | }; |
305 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
306 | | static_assert(0 < 1, "There is no slot for us"); |
307 | | static const JSJitInfo size_setterinfo = { |
308 | | { (JSJitGetterOp)set_size }, |
309 | | { prototypes::id::HTMLHRElement }, |
310 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
311 | | JSJitInfo::Setter, |
312 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
313 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
314 | | false, /* isInfallible. False in setters. */ |
315 | | false, /* isMovable. Not relevant for setters. */ |
316 | | false, /* isEliminatable. Not relevant for setters. */ |
317 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
318 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
319 | | false, /* isTypedMethod. Only relevant for methods. */ |
320 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
321 | | }; |
322 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
323 | | static_assert(0 < 1, "There is no slot for us"); |
324 | | |
325 | | MOZ_CAN_RUN_SCRIPT static bool |
326 | | get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitGetterCallArgs args) |
327 | 0 | { |
328 | 0 | AUTO_PROFILER_LABEL_FAST("get HTMLHRElement.width", DOM, cx); |
329 | 0 |
|
330 | 0 | DOMString result; |
331 | 0 | self->GetWidth(result); |
332 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
333 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
334 | 0 | return false; |
335 | 0 | } |
336 | 0 | return true; |
337 | 0 | } |
338 | | |
339 | | MOZ_CAN_RUN_SCRIPT static bool |
340 | | set_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLHRElement* self, JSJitSetterCallArgs args) |
341 | 0 | { |
342 | 0 | AUTO_PROFILER_LABEL_FAST("set HTMLHRElement.width", DOM, cx); |
343 | 0 |
|
344 | 0 | binding_detail::FakeString arg0; |
345 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
346 | 0 | return false; |
347 | 0 | } |
348 | 0 | Maybe<AutoCEReaction> ceReaction; |
349 | 0 | if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) { |
350 | 0 | DocGroup* docGroup = self->GetDocGroup(); |
351 | 0 | if (docGroup) { |
352 | 0 | ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); |
353 | 0 | } |
354 | 0 | } |
355 | 0 | FastErrorResult rv; |
356 | 0 | self->SetWidth(NonNullHelper(Constify(arg0)), rv); |
357 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
358 | 0 | return false; |
359 | 0 | } |
360 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
361 | 0 |
|
362 | 0 | return true; |
363 | 0 | } |
364 | | |
365 | | static const JSJitInfo width_getterinfo = { |
366 | | { (JSJitGetterOp)get_width }, |
367 | | { prototypes::id::HTMLHRElement }, |
368 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
369 | | JSJitInfo::Getter, |
370 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
371 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
372 | | false, /* isInfallible. False in setters. */ |
373 | | false, /* isMovable. Not relevant for setters. */ |
374 | | false, /* isEliminatable. Not relevant for setters. */ |
375 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
376 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
377 | | false, /* isTypedMethod. Only relevant for methods. */ |
378 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
379 | | }; |
380 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
381 | | static_assert(0 < 1, "There is no slot for us"); |
382 | | static const JSJitInfo width_setterinfo = { |
383 | | { (JSJitGetterOp)set_width }, |
384 | | { prototypes::id::HTMLHRElement }, |
385 | | { PrototypeTraits<prototypes::id::HTMLHRElement>::Depth }, |
386 | | JSJitInfo::Setter, |
387 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
388 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
389 | | false, /* isInfallible. False in setters. */ |
390 | | false, /* isMovable. Not relevant for setters. */ |
391 | | false, /* isEliminatable. Not relevant for setters. */ |
392 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
393 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
394 | | false, /* isTypedMethod. Only relevant for methods. */ |
395 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
396 | | }; |
397 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
398 | | static_assert(0 < 1, "There is no slot for us"); |
399 | | |
400 | | static bool |
401 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
402 | 0 | { |
403 | 0 | mozilla::dom::HTMLHRElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLHRElement>(obj); |
404 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
405 | 0 | // obviously can't preserve if we're not initialized. |
406 | 0 | if (self && self->GetWrapperPreserveColor()) { |
407 | 0 | PreserveWrapper(self); |
408 | 0 | } |
409 | 0 | return true; |
410 | 0 | } |
411 | | |
412 | | static void |
413 | | _finalize(js::FreeOp* fop, JSObject* obj) |
414 | 0 | { |
415 | 0 | mozilla::dom::HTMLHRElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLHRElement>(obj); |
416 | 0 | if (self) { |
417 | 0 | ClearWrapper(self, self, obj); |
418 | 0 | AddForDeferredFinalization<mozilla::dom::HTMLHRElement>(self); |
419 | 0 | } |
420 | 0 | } |
421 | | |
422 | | static size_t |
423 | | _objectMoved(JSObject* obj, JSObject* old) |
424 | 0 | { |
425 | 0 | mozilla::dom::HTMLHRElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLHRElement>(obj); |
426 | 0 | if (self) { |
427 | 0 | UpdateWrapper(self, self, obj, old); |
428 | 0 | } |
429 | 0 |
|
430 | 0 | return 0; |
431 | 0 | } |
432 | | |
433 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
434 | | #if defined(__clang__) |
435 | | #pragma clang diagnostic push |
436 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
437 | | #endif |
438 | | static const JSPropertySpec sAttributes_specs[] = { |
439 | | { "align", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &align_getterinfo, GenericSetter<NormalThisPolicy>, &align_setterinfo }, |
440 | | { "color", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &color_getterinfo, GenericSetter<NormalThisPolicy>, &color_setterinfo }, |
441 | | { "noShade", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &noShade_getterinfo, GenericSetter<NormalThisPolicy>, &noShade_setterinfo }, |
442 | | { "size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, GenericSetter<NormalThisPolicy>, &size_setterinfo }, |
443 | | { "width", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &width_getterinfo, GenericSetter<NormalThisPolicy>, &width_setterinfo }, |
444 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
445 | | }; |
446 | | #if defined(__clang__) |
447 | | #pragma clang diagnostic pop |
448 | | #endif |
449 | | |
450 | | |
451 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
452 | | { nullptr, &sAttributes_specs[0] }, |
453 | | { nullptr, nullptr } |
454 | | }; |
455 | | |
456 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
457 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
458 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
459 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
460 | | |
461 | | |
462 | | static uint16_t sNativeProperties_sortedPropertyIndices[5]; |
463 | | static PropertyInfo sNativeProperties_propertyInfos[5]; |
464 | | |
465 | | static const NativePropertiesN<1> sNativeProperties = { |
466 | | false, 0, |
467 | | false, 0, |
468 | | false, 0, |
469 | | true, 0 /* sAttributes */, |
470 | | false, 0, |
471 | | false, 0, |
472 | | false, 0, |
473 | | -1, |
474 | | 5, |
475 | | sNativeProperties_sortedPropertyIndices, |
476 | | { |
477 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
478 | | } |
479 | | }; |
480 | | static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
481 | | "We have a property info count that is oversized"); |
482 | | |
483 | | static bool |
484 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
485 | 0 | { |
486 | 0 | AUTO_PROFILER_LABEL_FAST("HTMLHRElement constructor", DOM, cx); |
487 | 0 |
|
488 | 0 | return HTMLConstructor(cx, argc, vp, |
489 | 0 | constructors::id::HTMLHRElement, |
490 | 0 | prototypes::id::HTMLHRElement, |
491 | 0 | CreateInterfaceObjects); |
492 | 0 | } |
493 | | |
494 | | static const js::ClassOps sInterfaceObjectClassOps = { |
495 | | nullptr, /* addProperty */ |
496 | | nullptr, /* delProperty */ |
497 | | nullptr, /* enumerate */ |
498 | | nullptr, /* newEnumerate */ |
499 | | nullptr, /* resolve */ |
500 | | nullptr, /* mayResolve */ |
501 | | nullptr, /* finalize */ |
502 | | _constructor, /* call */ |
503 | | nullptr, /* hasInstance */ |
504 | | _constructor, /* construct */ |
505 | | nullptr, /* trace */ |
506 | | }; |
507 | | |
508 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
509 | | { |
510 | | "Function", |
511 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
512 | | &sInterfaceObjectClassOps, |
513 | | JS_NULL_CLASS_SPEC, |
514 | | JS_NULL_CLASS_EXT, |
515 | | &sInterfaceObjectClassObjectOps |
516 | | }, |
517 | | eInterface, |
518 | | true, |
519 | | prototypes::id::HTMLHRElement, |
520 | | PrototypeTraits<prototypes::id::HTMLHRElement>::Depth, |
521 | | sNativePropertyHooks, |
522 | | "function HTMLHRElement() {\n [native code]\n}", |
523 | | HTMLElement_Binding::GetConstructorObject |
524 | | }; |
525 | | |
526 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
527 | | { |
528 | | "HTMLHRElementPrototype", |
529 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
530 | | JS_NULL_CLASS_OPS, |
531 | | JS_NULL_CLASS_SPEC, |
532 | | JS_NULL_CLASS_EXT, |
533 | | JS_NULL_OBJECT_OPS |
534 | | }, |
535 | | eInterfacePrototype, |
536 | | false, |
537 | | prototypes::id::HTMLHRElement, |
538 | | PrototypeTraits<prototypes::id::HTMLHRElement>::Depth, |
539 | | sNativePropertyHooks, |
540 | | "[object HTMLHRElementPrototype]", |
541 | | HTMLElement_Binding::GetProtoObject |
542 | | }; |
543 | | |
544 | | static const js::ClassOps sClassOps = { |
545 | | _addProperty, /* addProperty */ |
546 | | nullptr, /* delProperty */ |
547 | | nullptr, /* enumerate */ |
548 | | nullptr, /* newEnumerate */ |
549 | | nullptr, /* resolve */ |
550 | | nullptr, /* mayResolve */ |
551 | | _finalize, /* finalize */ |
552 | | nullptr, /* call */ |
553 | | nullptr, /* hasInstance */ |
554 | | nullptr, /* construct */ |
555 | | nullptr, /* trace */ |
556 | | }; |
557 | | |
558 | | static const js::ClassExtension sClassExtension = { |
559 | | nullptr, /* weakmapKeyDelegateOp */ |
560 | | _objectMoved /* objectMovedOp */ |
561 | | }; |
562 | | |
563 | | static const DOMJSClass sClass = { |
564 | | { "HTMLHRElement", |
565 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
566 | | &sClassOps, |
567 | | JS_NULL_CLASS_SPEC, |
568 | | &sClassExtension, |
569 | | JS_NULL_OBJECT_OPS |
570 | | }, |
571 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLHRElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
572 | | IsBaseOf<nsISupports, mozilla::dom::HTMLHRElement >::value, |
573 | | sNativePropertyHooks, |
574 | | FindAssociatedGlobalForNative<mozilla::dom::HTMLHRElement>::Get, |
575 | | GetProtoObjectHandle, |
576 | | GetCCParticipant<mozilla::dom::HTMLHRElement>::Get() |
577 | | }; |
578 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
579 | | "Must have the right minimal number of reserved slots."); |
580 | | static_assert(1 >= 1, |
581 | | "Must have enough reserved slots."); |
582 | | |
583 | | const JSClass* |
584 | | GetJSClass() |
585 | 0 | { |
586 | 0 | return sClass.ToJSClass(); |
587 | 0 | } |
588 | | |
589 | | bool |
590 | | Wrap(JSContext* aCx, mozilla::dom::HTMLHRElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
591 | 0 | { |
592 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLHRElement>::value, |
593 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
594 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::HTMLHRElement*>(aObject) == |
595 | 0 | reinterpret_cast<mozilla::dom::HTMLHRElement*>(aObject), |
596 | 0 | "Multiple inheritance for mozilla::dom::HTMLHRElement is broken."); |
597 | 0 | MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) == |
598 | 0 | reinterpret_cast<nsGenericHTMLElement*>(aObject), |
599 | 0 | "Multiple inheritance for nsGenericHTMLElement is broken."); |
600 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
601 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
602 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
603 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
604 | 0 | reinterpret_cast<nsINode*>(aObject), |
605 | 0 | "Multiple inheritance for nsINode is broken."); |
606 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
607 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
608 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
609 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
610 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
611 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
612 | 0 | "You should probably not be using Wrap() directly; use " |
613 | 0 | "GetOrCreateDOMReflector instead"); |
614 | 0 |
|
615 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
616 | 0 | "nsISupports must be on our primary inheritance chain"); |
617 | 0 |
|
618 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
619 | 0 | if (!global) { |
620 | 0 | return false; |
621 | 0 | } |
622 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
623 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
624 | 0 |
|
625 | 0 | // That might have ended up wrapping us already, due to the wonders |
626 | 0 | // of XBL. Check for that, and bail out as needed. |
627 | 0 | aReflector.set(aCache->GetWrapper()); |
628 | 0 | if (aReflector) { |
629 | | #ifdef DEBUG |
630 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
631 | | #endif // DEBUG |
632 | | return true; |
633 | 0 | } |
634 | 0 |
|
635 | 0 | JSAutoRealm ar(aCx, global); |
636 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
637 | 0 | if (!canonicalProto) { |
638 | 0 | return false; |
639 | 0 | } |
640 | 0 | JS::Rooted<JSObject*> proto(aCx); |
641 | 0 | if (aGivenProto) { |
642 | 0 | proto = aGivenProto; |
643 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
644 | 0 | // coming in, we changed compartments to that of "parent" so may need |
645 | 0 | // to wrap the proto here. |
646 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
647 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
648 | 0 | return false; |
649 | 0 | } |
650 | 0 | } |
651 | 0 | } else { |
652 | 0 | proto = canonicalProto; |
653 | 0 | } |
654 | 0 |
|
655 | 0 | BindingJSObjectCreator<mozilla::dom::HTMLHRElement> creator(aCx); |
656 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
657 | 0 | if (!aReflector) { |
658 | 0 | return false; |
659 | 0 | } |
660 | 0 | |
661 | 0 | aCache->SetWrapper(aReflector); |
662 | 0 | creator.InitializationSucceeded(); |
663 | 0 |
|
664 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
665 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
666 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
667 | 0 | // otherwise we won't be able to properly recreate it later, since |
668 | 0 | // we won't know what proto to use. Note that we don't check |
669 | 0 | // aGivenProto here, since it's entirely possible (and even |
670 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
671 | 0 | // same as canonicalProto. |
672 | 0 | if (proto != canonicalProto) { |
673 | 0 | PreserveWrapper(aObject); |
674 | 0 | } |
675 | 0 |
|
676 | 0 | return true; |
677 | 0 | } |
678 | | |
679 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
680 | | nullptr, |
681 | | nullptr, |
682 | | nullptr, |
683 | | { sNativeProperties.Upcast(), nullptr }, |
684 | | prototypes::id::HTMLHRElement, |
685 | | constructors::id::HTMLHRElement, |
686 | | HTMLElement_Binding::sNativePropertyHooks, |
687 | | &DefaultXrayExpandoObjectClass |
688 | | } }; |
689 | | |
690 | | void |
691 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
692 | 0 | { |
693 | 0 | JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx)); |
694 | 0 | if (!parentProto) { |
695 | 0 | return; |
696 | 0 | } |
697 | 0 | |
698 | 0 | JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx)); |
699 | 0 | if (!constructorProto) { |
700 | 0 | return; |
701 | 0 | } |
702 | 0 | |
703 | 0 | static bool sIdsInited = false; |
704 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
705 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
706 | 0 | return; |
707 | 0 | } |
708 | 0 | sIdsInited = true; |
709 | 0 | } |
710 | 0 |
|
711 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLHRElement); |
712 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLHRElement); |
713 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
714 | 0 | &sPrototypeClass.mBase, protoCache, |
715 | 0 | nullptr, |
716 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
717 | 0 | interfaceCache, |
718 | 0 | sNativeProperties.Upcast(), |
719 | 0 | nullptr, |
720 | 0 | "HTMLHRElement", aDefineOnGlobal, |
721 | 0 | nullptr, |
722 | 0 | false); |
723 | 0 | } |
724 | | |
725 | | JSObject* |
726 | | GetConstructorObject(JSContext* aCx) |
727 | 0 | { |
728 | 0 | return GetConstructorObjectHandle(aCx); |
729 | 0 | } |
730 | | |
731 | | } // namespace HTMLHRElement_Binding |
732 | | |
733 | | |
734 | | |
735 | | } // namespace dom |
736 | | } // namespace mozilla |