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