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