Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLFormElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLFormElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLFormElementBinding.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/DOMJSProxyHandler.h"
11
#include "mozilla/dom/DocGroup.h"
12
#include "mozilla/dom/Element.h"
13
#include "mozilla/dom/HTMLFormElement.h"
14
#include "mozilla/dom/NonRefcountedDOMObject.h"
15
#include "mozilla/dom/PrimitiveConversions.h"
16
#include "mozilla/dom/XrayExpandoClass.h"
17
#include "nsContentList.h"
18
#include "nsISupports.h"
19
20
namespace mozilla {
21
namespace dom {
22
23
namespace binding_detail {}; // Just to make sure it's known as a namespace
24
using namespace mozilla::dom::binding_detail;
25
26
27
namespace HTMLFormElement_Binding {
28
29
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value,
30
              "Can't inherit from an interface with a different ownership model.");
31
32
MOZ_CAN_RUN_SCRIPT static bool
33
get_acceptCharset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
34
0
{
35
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.acceptCharset", DOM, cx);
36
0
37
0
  DOMString result;
38
0
  self->GetAcceptCharset(result);
39
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
40
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
41
0
    return false;
42
0
  }
43
0
  return true;
44
0
}
45
46
MOZ_CAN_RUN_SCRIPT static bool
47
set_acceptCharset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
48
0
{
49
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.acceptCharset", DOM, cx);
50
0
51
0
  binding_detail::FakeString arg0;
52
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
53
0
    return false;
54
0
  }
55
0
  Maybe<AutoCEReaction> ceReaction;
56
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
57
0
    DocGroup* docGroup = self->GetDocGroup();
58
0
    if (docGroup) {
59
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
60
0
    }
61
0
  }
62
0
  FastErrorResult rv;
63
0
  self->SetAcceptCharset(NonNullHelper(Constify(arg0)), rv);
64
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
65
0
    return false;
66
0
  }
67
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
68
0
69
0
  return true;
70
0
}
71
72
static const JSJitInfo acceptCharset_getterinfo = {
73
  { (JSJitGetterOp)get_acceptCharset },
74
  { prototypes::id::HTMLFormElement },
75
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
76
  JSJitInfo::Getter,
77
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
78
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
79
  false,  /* isInfallible. False in setters. */
80
  true,  /* isMovable.  Not relevant for setters. */
81
  true, /* isEliminatable.  Not relevant for setters. */
82
  false, /* isAlwaysInSlot.  Only relevant for getters. */
83
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
84
  false,  /* isTypedMethod.  Only relevant for methods. */
85
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
86
};
87
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
88
static_assert(0 < 1, "There is no slot for us");
89
static const JSJitInfo acceptCharset_setterinfo = {
90
  { (JSJitGetterOp)set_acceptCharset },
91
  { prototypes::id::HTMLFormElement },
92
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
93
  JSJitInfo::Setter,
94
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
95
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
96
  false,  /* isInfallible. False in setters. */
97
  false,  /* isMovable.  Not relevant for setters. */
98
  false, /* isEliminatable.  Not relevant for setters. */
99
  false, /* isAlwaysInSlot.  Only relevant for getters. */
100
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
101
  false,  /* isTypedMethod.  Only relevant for methods. */
102
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
103
};
104
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
105
static_assert(0 < 1, "There is no slot for us");
106
107
MOZ_CAN_RUN_SCRIPT static bool
108
get_action(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
109
0
{
110
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.action", DOM, cx);
111
0
112
0
  DOMString result;
113
0
  self->GetAction(result);
114
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
115
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
116
0
    return false;
117
0
  }
118
0
  return true;
119
0
}
120
121
MOZ_CAN_RUN_SCRIPT static bool
122
set_action(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
123
0
{
124
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.action", DOM, cx);
125
0
126
0
  binding_detail::FakeString arg0;
127
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
128
0
    return false;
129
0
  }
130
0
  Maybe<AutoCEReaction> ceReaction;
131
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
132
0
    DocGroup* docGroup = self->GetDocGroup();
133
0
    if (docGroup) {
134
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
135
0
    }
136
0
  }
137
0
  FastErrorResult rv;
138
0
  self->SetAction(NonNullHelper(Constify(arg0)), rv);
139
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
140
0
    return false;
141
0
  }
142
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
143
0
144
0
  return true;
145
0
}
146
147
static const JSJitInfo action_getterinfo = {
148
  { (JSJitGetterOp)get_action },
149
  { prototypes::id::HTMLFormElement },
150
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
151
  JSJitInfo::Getter,
152
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
153
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
154
  false,  /* isInfallible. False in setters. */
155
  true,  /* isMovable.  Not relevant for setters. */
156
  true, /* isEliminatable.  Not relevant for setters. */
157
  false, /* isAlwaysInSlot.  Only relevant for getters. */
158
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
159
  false,  /* isTypedMethod.  Only relevant for methods. */
160
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
161
};
162
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
163
static_assert(0 < 1, "There is no slot for us");
164
static const JSJitInfo action_setterinfo = {
165
  { (JSJitGetterOp)set_action },
166
  { prototypes::id::HTMLFormElement },
167
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
168
  JSJitInfo::Setter,
169
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
170
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
171
  false,  /* 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
MOZ_CAN_RUN_SCRIPT static bool
183
get_autocomplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
184
0
{
185
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.autocomplete", DOM, cx);
186
0
187
0
  DOMString result;
188
0
  self->GetAutocomplete(result);
189
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
190
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
191
0
    return false;
192
0
  }
193
0
  return true;
194
0
}
195
196
MOZ_CAN_RUN_SCRIPT static bool
197
set_autocomplete(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
198
0
{
199
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.autocomplete", DOM, cx);
200
0
201
0
  binding_detail::FakeString arg0;
202
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
203
0
    return false;
204
0
  }
205
0
  Maybe<AutoCEReaction> ceReaction;
206
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
207
0
    DocGroup* docGroup = self->GetDocGroup();
208
0
    if (docGroup) {
209
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
210
0
    }
211
0
  }
212
0
  FastErrorResult rv;
213
0
  self->SetAutocomplete(NonNullHelper(Constify(arg0)), rv);
214
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
215
0
    return false;
216
0
  }
217
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
218
0
219
0
  return true;
220
0
}
221
222
static const JSJitInfo autocomplete_getterinfo = {
223
  { (JSJitGetterOp)get_autocomplete },
224
  { prototypes::id::HTMLFormElement },
225
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
226
  JSJitInfo::Getter,
227
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
228
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
229
  false,  /* isInfallible. False in setters. */
230
  true,  /* isMovable.  Not relevant for setters. */
231
  true, /* isEliminatable.  Not relevant for setters. */
232
  false, /* isAlwaysInSlot.  Only relevant for getters. */
233
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
234
  false,  /* isTypedMethod.  Only relevant for methods. */
235
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
236
};
237
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
238
static_assert(0 < 1, "There is no slot for us");
239
static const JSJitInfo autocomplete_setterinfo = {
240
  { (JSJitGetterOp)set_autocomplete },
241
  { prototypes::id::HTMLFormElement },
242
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
243
  JSJitInfo::Setter,
244
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
245
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
246
  false,  /* isInfallible. False in setters. */
247
  false,  /* isMovable.  Not relevant for setters. */
248
  false, /* isEliminatable.  Not relevant for setters. */
249
  false, /* isAlwaysInSlot.  Only relevant for getters. */
250
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
251
  false,  /* isTypedMethod.  Only relevant for methods. */
252
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
253
};
254
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
255
static_assert(0 < 1, "There is no slot for us");
256
257
MOZ_CAN_RUN_SCRIPT static bool
258
get_enctype(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
259
0
{
260
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.enctype", DOM, cx);
261
0
262
0
  DOMString result;
263
0
  self->GetEnctype(result);
264
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
265
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
266
0
    return false;
267
0
  }
268
0
  return true;
269
0
}
270
271
MOZ_CAN_RUN_SCRIPT static bool
272
set_enctype(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
273
0
{
274
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.enctype", DOM, cx);
275
0
276
0
  binding_detail::FakeString arg0;
277
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
278
0
    return false;
279
0
  }
280
0
  Maybe<AutoCEReaction> ceReaction;
281
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
282
0
    DocGroup* docGroup = self->GetDocGroup();
283
0
    if (docGroup) {
284
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
285
0
    }
286
0
  }
287
0
  FastErrorResult rv;
288
0
  self->SetEnctype(NonNullHelper(Constify(arg0)), rv);
289
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
290
0
    return false;
291
0
  }
292
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
293
0
294
0
  return true;
295
0
}
296
297
static const JSJitInfo enctype_getterinfo = {
298
  { (JSJitGetterOp)get_enctype },
299
  { prototypes::id::HTMLFormElement },
300
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
301
  JSJitInfo::Getter,
302
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
303
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
304
  false,  /* isInfallible. False in setters. */
305
  true,  /* isMovable.  Not relevant for setters. */
306
  true, /* isEliminatable.  Not relevant for setters. */
307
  false, /* isAlwaysInSlot.  Only relevant for getters. */
308
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
309
  false,  /* isTypedMethod.  Only relevant for methods. */
310
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
311
};
312
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
313
static_assert(0 < 1, "There is no slot for us");
314
static const JSJitInfo enctype_setterinfo = {
315
  { (JSJitGetterOp)set_enctype },
316
  { prototypes::id::HTMLFormElement },
317
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
318
  JSJitInfo::Setter,
319
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
320
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
321
  false,  /* isInfallible. False in setters. */
322
  false,  /* isMovable.  Not relevant for setters. */
323
  false, /* isEliminatable.  Not relevant for setters. */
324
  false, /* isAlwaysInSlot.  Only relevant for getters. */
325
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
326
  false,  /* isTypedMethod.  Only relevant for methods. */
327
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
328
};
329
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
330
static_assert(0 < 1, "There is no slot for us");
331
332
MOZ_CAN_RUN_SCRIPT static bool
333
get_encoding(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
334
0
{
335
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.encoding", DOM, cx);
336
0
337
0
  DOMString result;
338
0
  self->GetEncoding(result);
339
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
340
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
341
0
    return false;
342
0
  }
343
0
  return true;
344
0
}
345
346
MOZ_CAN_RUN_SCRIPT static bool
347
set_encoding(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
348
0
{
349
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.encoding", DOM, cx);
350
0
351
0
  binding_detail::FakeString arg0;
352
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
353
0
    return false;
354
0
  }
355
0
  Maybe<AutoCEReaction> ceReaction;
356
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
357
0
    DocGroup* docGroup = self->GetDocGroup();
358
0
    if (docGroup) {
359
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
360
0
    }
361
0
  }
362
0
  FastErrorResult rv;
363
0
  self->SetEncoding(NonNullHelper(Constify(arg0)), rv);
364
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
365
0
    return false;
366
0
  }
367
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
368
0
369
0
  return true;
370
0
}
371
372
static const JSJitInfo encoding_getterinfo = {
373
  { (JSJitGetterOp)get_encoding },
374
  { prototypes::id::HTMLFormElement },
375
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
376
  JSJitInfo::Getter,
377
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
378
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
379
  false,  /* isInfallible. False in setters. */
380
  true,  /* isMovable.  Not relevant for setters. */
381
  true, /* isEliminatable.  Not relevant for setters. */
382
  false, /* isAlwaysInSlot.  Only relevant for getters. */
383
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
384
  false,  /* isTypedMethod.  Only relevant for methods. */
385
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
386
};
387
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
388
static_assert(0 < 1, "There is no slot for us");
389
static const JSJitInfo encoding_setterinfo = {
390
  { (JSJitGetterOp)set_encoding },
391
  { prototypes::id::HTMLFormElement },
392
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
393
  JSJitInfo::Setter,
394
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
395
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
396
  false,  /* isInfallible. False in setters. */
397
  false,  /* isMovable.  Not relevant for setters. */
398
  false, /* isEliminatable.  Not relevant for setters. */
399
  false, /* isAlwaysInSlot.  Only relevant for getters. */
400
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
401
  false,  /* isTypedMethod.  Only relevant for methods. */
402
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
403
};
404
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
405
static_assert(0 < 1, "There is no slot for us");
406
407
MOZ_CAN_RUN_SCRIPT static bool
408
get_method(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
409
0
{
410
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.method", DOM, cx);
411
0
412
0
  DOMString result;
413
0
  self->GetMethod(result);
414
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
415
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
416
0
    return false;
417
0
  }
418
0
  return true;
419
0
}
420
421
MOZ_CAN_RUN_SCRIPT static bool
422
set_method(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
423
0
{
424
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.method", DOM, cx);
425
0
426
0
  binding_detail::FakeString arg0;
427
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
428
0
    return false;
429
0
  }
430
0
  Maybe<AutoCEReaction> ceReaction;
431
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
432
0
    DocGroup* docGroup = self->GetDocGroup();
433
0
    if (docGroup) {
434
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
435
0
    }
436
0
  }
437
0
  FastErrorResult rv;
438
0
  self->SetMethod(NonNullHelper(Constify(arg0)), rv);
439
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
440
0
    return false;
441
0
  }
442
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
443
0
444
0
  return true;
445
0
}
446
447
static const JSJitInfo method_getterinfo = {
448
  { (JSJitGetterOp)get_method },
449
  { prototypes::id::HTMLFormElement },
450
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
451
  JSJitInfo::Getter,
452
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
453
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
454
  false,  /* isInfallible. False in setters. */
455
  true,  /* isMovable.  Not relevant for setters. */
456
  true, /* isEliminatable.  Not relevant for setters. */
457
  false, /* isAlwaysInSlot.  Only relevant for getters. */
458
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
459
  false,  /* isTypedMethod.  Only relevant for methods. */
460
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
461
};
462
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
463
static_assert(0 < 1, "There is no slot for us");
464
static const JSJitInfo method_setterinfo = {
465
  { (JSJitGetterOp)set_method },
466
  { prototypes::id::HTMLFormElement },
467
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
468
  JSJitInfo::Setter,
469
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
470
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
471
  false,  /* isInfallible. False in setters. */
472
  false,  /* isMovable.  Not relevant for setters. */
473
  false, /* isEliminatable.  Not relevant for setters. */
474
  false, /* isAlwaysInSlot.  Only relevant for getters. */
475
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
476
  false,  /* isTypedMethod.  Only relevant for methods. */
477
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
478
};
479
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
480
static_assert(0 < 1, "There is no slot for us");
481
482
MOZ_CAN_RUN_SCRIPT static bool
483
get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
484
0
{
485
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.name", DOM, cx);
486
0
487
0
  DOMString result;
488
0
  self->GetName(result);
489
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
490
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
491
0
    return false;
492
0
  }
493
0
  return true;
494
0
}
495
496
MOZ_CAN_RUN_SCRIPT static bool
497
set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
498
0
{
499
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.name", DOM, cx);
500
0
501
0
  binding_detail::FakeString arg0;
502
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
503
0
    return false;
504
0
  }
505
0
  Maybe<AutoCEReaction> ceReaction;
506
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
507
0
    DocGroup* docGroup = self->GetDocGroup();
508
0
    if (docGroup) {
509
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
510
0
    }
511
0
  }
512
0
  FastErrorResult rv;
513
0
  self->SetName(NonNullHelper(Constify(arg0)), rv);
514
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
515
0
    return false;
516
0
  }
517
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
518
0
519
0
  return true;
520
0
}
521
522
static const JSJitInfo name_getterinfo = {
523
  { (JSJitGetterOp)get_name },
524
  { prototypes::id::HTMLFormElement },
525
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
526
  JSJitInfo::Getter,
527
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
528
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
529
  false,  /* isInfallible. False in setters. */
530
  true,  /* isMovable.  Not relevant for setters. */
531
  true, /* isEliminatable.  Not relevant for setters. */
532
  false, /* isAlwaysInSlot.  Only relevant for getters. */
533
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
534
  false,  /* isTypedMethod.  Only relevant for methods. */
535
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
536
};
537
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
538
static_assert(0 < 1, "There is no slot for us");
539
static const JSJitInfo name_setterinfo = {
540
  { (JSJitGetterOp)set_name },
541
  { prototypes::id::HTMLFormElement },
542
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
543
  JSJitInfo::Setter,
544
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
545
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
546
  false,  /* isInfallible. False in setters. */
547
  false,  /* isMovable.  Not relevant for setters. */
548
  false, /* isEliminatable.  Not relevant for setters. */
549
  false, /* isAlwaysInSlot.  Only relevant for getters. */
550
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
551
  false,  /* isTypedMethod.  Only relevant for methods. */
552
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
553
};
554
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
555
static_assert(0 < 1, "There is no slot for us");
556
557
MOZ_CAN_RUN_SCRIPT static bool
558
get_noValidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
559
0
{
560
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.noValidate", DOM, cx);
561
0
562
0
  bool result(self->NoValidate());
563
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
564
0
  args.rval().setBoolean(result);
565
0
  return true;
566
0
}
567
568
MOZ_CAN_RUN_SCRIPT static bool
569
set_noValidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
570
0
{
571
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.noValidate", DOM, cx);
572
0
573
0
  bool arg0;
574
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
575
0
    return false;
576
0
  }
577
0
  Maybe<AutoCEReaction> ceReaction;
578
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
579
0
    DocGroup* docGroup = self->GetDocGroup();
580
0
    if (docGroup) {
581
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
582
0
    }
583
0
  }
584
0
  FastErrorResult rv;
585
0
  self->SetNoValidate(arg0, rv);
586
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
587
0
    return false;
588
0
  }
589
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
590
0
591
0
  return true;
592
0
}
593
594
static const JSJitInfo noValidate_getterinfo = {
595
  { (JSJitGetterOp)get_noValidate },
596
  { prototypes::id::HTMLFormElement },
597
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
598
  JSJitInfo::Getter,
599
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
600
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
601
  true,  /* isInfallible. False in setters. */
602
  true,  /* isMovable.  Not relevant for setters. */
603
  true, /* isEliminatable.  Not relevant for setters. */
604
  false, /* isAlwaysInSlot.  Only relevant for getters. */
605
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
606
  false,  /* isTypedMethod.  Only relevant for methods. */
607
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
608
};
609
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
610
static_assert(0 < 1, "There is no slot for us");
611
static const JSJitInfo noValidate_setterinfo = {
612
  { (JSJitGetterOp)set_noValidate },
613
  { prototypes::id::HTMLFormElement },
614
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
615
  JSJitInfo::Setter,
616
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
617
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
618
  false,  /* isInfallible. False in setters. */
619
  false,  /* isMovable.  Not relevant for setters. */
620
  false, /* isEliminatable.  Not relevant for setters. */
621
  false, /* isAlwaysInSlot.  Only relevant for getters. */
622
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
623
  false,  /* isTypedMethod.  Only relevant for methods. */
624
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
625
};
626
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
627
static_assert(0 < 1, "There is no slot for us");
628
629
MOZ_CAN_RUN_SCRIPT static bool
630
get_target(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
631
0
{
632
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.target", DOM, cx);
633
0
634
0
  DOMString result;
635
0
  self->GetTarget(result);
636
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
637
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
638
0
    return false;
639
0
  }
640
0
  return true;
641
0
}
642
643
MOZ_CAN_RUN_SCRIPT static bool
644
set_target(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitSetterCallArgs args)
645
0
{
646
0
  AUTO_PROFILER_LABEL_FAST("set HTMLFormElement.target", DOM, cx);
647
0
648
0
  binding_detail::FakeString arg0;
649
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
650
0
    return false;
651
0
  }
652
0
  Maybe<AutoCEReaction> ceReaction;
653
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
654
0
    DocGroup* docGroup = self->GetDocGroup();
655
0
    if (docGroup) {
656
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
657
0
    }
658
0
  }
659
0
  FastErrorResult rv;
660
0
  self->SetTarget(NonNullHelper(Constify(arg0)), rv);
661
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
662
0
    return false;
663
0
  }
664
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
665
0
666
0
  return true;
667
0
}
668
669
static const JSJitInfo target_getterinfo = {
670
  { (JSJitGetterOp)get_target },
671
  { prototypes::id::HTMLFormElement },
672
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
673
  JSJitInfo::Getter,
674
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
675
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
676
  false,  /* isInfallible. False in setters. */
677
  true,  /* isMovable.  Not relevant for setters. */
678
  true, /* isEliminatable.  Not relevant for setters. */
679
  false, /* isAlwaysInSlot.  Only relevant for getters. */
680
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
681
  false,  /* isTypedMethod.  Only relevant for methods. */
682
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
683
};
684
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
685
static_assert(0 < 1, "There is no slot for us");
686
static const JSJitInfo target_setterinfo = {
687
  { (JSJitGetterOp)set_target },
688
  { prototypes::id::HTMLFormElement },
689
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
690
  JSJitInfo::Setter,
691
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
692
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
693
  false,  /* isInfallible. False in setters. */
694
  false,  /* isMovable.  Not relevant for setters. */
695
  false, /* isEliminatable.  Not relevant for setters. */
696
  false, /* isAlwaysInSlot.  Only relevant for getters. */
697
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
698
  false,  /* isTypedMethod.  Only relevant for methods. */
699
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
700
};
701
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
702
static_assert(0 < 1, "There is no slot for us");
703
704
MOZ_CAN_RUN_SCRIPT static bool
705
get_elements(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
706
0
{
707
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.elements", DOM, cx);
708
0
709
0
  auto result(StrongOrRawPtr<nsIHTMLCollection>(self->Elements()));
710
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
711
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
712
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
713
0
    return false;
714
0
  }
715
0
  return true;
716
0
}
717
718
static const JSJitInfo elements_getterinfo = {
719
  { (JSJitGetterOp)get_elements },
720
  { prototypes::id::HTMLFormElement },
721
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
722
  JSJitInfo::Getter,
723
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
724
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
725
  false,  /* isInfallible. False in setters. */
726
  true,  /* isMovable.  Not relevant for setters. */
727
  true, /* isEliminatable.  Not relevant for setters. */
728
  false, /* isAlwaysInSlot.  Only relevant for getters. */
729
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
730
  false,  /* isTypedMethod.  Only relevant for methods. */
731
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
732
};
733
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
734
static_assert(0 < 1, "There is no slot for us");
735
736
MOZ_CAN_RUN_SCRIPT static bool
737
get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, JSJitGetterCallArgs args)
738
0
{
739
0
  AUTO_PROFILER_LABEL_FAST("get HTMLFormElement.length", DOM, cx);
740
0
741
0
  int32_t result(self->Length());
742
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
743
0
  args.rval().setInt32(int32_t(result));
744
0
  return true;
745
0
}
746
747
static const JSJitInfo length_getterinfo = {
748
  { (JSJitGetterOp)get_length },
749
  { prototypes::id::HTMLFormElement },
750
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
751
  JSJitInfo::Getter,
752
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
753
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
754
  true,  /* isInfallible. False in setters. */
755
  true,  /* isMovable.  Not relevant for setters. */
756
  true, /* isEliminatable.  Not relevant for setters. */
757
  false, /* isAlwaysInSlot.  Only relevant for getters. */
758
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
759
  false,  /* isTypedMethod.  Only relevant for methods. */
760
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
761
};
762
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
763
static_assert(0 < 1, "There is no slot for us");
764
765
MOZ_CAN_RUN_SCRIPT static bool
766
submit(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, const JSJitMethodCallArgs& args)
767
0
{
768
0
  AUTO_PROFILER_LABEL_FAST("HTMLFormElement.submit", DOM, cx);
769
0
770
0
  FastErrorResult rv;
771
0
  self->Submit(rv);
772
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
773
0
    return false;
774
0
  }
775
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
776
0
  args.rval().setUndefined();
777
0
  return true;
778
0
}
779
780
static const JSJitInfo submit_methodinfo = {
781
  { (JSJitGetterOp)submit },
782
  { prototypes::id::HTMLFormElement },
783
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
784
  JSJitInfo::Method,
785
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
786
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
787
  false,  /* isInfallible. False in setters. */
788
  false,  /* isMovable.  Not relevant for setters. */
789
  false, /* isEliminatable.  Not relevant for setters. */
790
  false, /* isAlwaysInSlot.  Only relevant for getters. */
791
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
792
  false,  /* isTypedMethod.  Only relevant for methods. */
793
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
794
};
795
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
796
static_assert(0 < 1, "There is no slot for us");
797
798
MOZ_CAN_RUN_SCRIPT static bool
799
reset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, const JSJitMethodCallArgs& args)
800
0
{
801
0
  AUTO_PROFILER_LABEL_FAST("HTMLFormElement.reset", DOM, cx);
802
0
803
0
  Maybe<AutoCEReaction> ceReaction;
804
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
805
0
    DocGroup* docGroup = self->GetDocGroup();
806
0
    if (docGroup) {
807
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
808
0
    }
809
0
  }
810
0
  self->Reset();
811
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
812
0
  args.rval().setUndefined();
813
0
  return true;
814
0
}
815
816
static const JSJitInfo reset_methodinfo = {
817
  { (JSJitGetterOp)reset },
818
  { prototypes::id::HTMLFormElement },
819
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
820
  JSJitInfo::Method,
821
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
822
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
823
  true,  /* isInfallible. False in setters. */
824
  false,  /* isMovable.  Not relevant for setters. */
825
  false, /* isEliminatable.  Not relevant for setters. */
826
  false, /* isAlwaysInSlot.  Only relevant for getters. */
827
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
828
  false,  /* isTypedMethod.  Only relevant for methods. */
829
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
830
};
831
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
832
static_assert(0 < 1, "There is no slot for us");
833
834
MOZ_CAN_RUN_SCRIPT static bool
835
checkValidity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, const JSJitMethodCallArgs& args)
836
0
{
837
0
  AUTO_PROFILER_LABEL_FAST("HTMLFormElement.checkValidity", DOM, cx);
838
0
839
0
  bool result(self->CheckValidity());
840
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
841
0
  args.rval().setBoolean(result);
842
0
  return true;
843
0
}
844
845
static const JSJitInfo checkValidity_methodinfo = {
846
  { (JSJitGetterOp)checkValidity },
847
  { prototypes::id::HTMLFormElement },
848
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
849
  JSJitInfo::Method,
850
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
851
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
852
  true,  /* isInfallible. False in setters. */
853
  false,  /* isMovable.  Not relevant for setters. */
854
  false, /* isEliminatable.  Not relevant for setters. */
855
  false, /* isAlwaysInSlot.  Only relevant for getters. */
856
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
857
  false,  /* isTypedMethod.  Only relevant for methods. */
858
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
859
};
860
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
861
static_assert(0 < 1, "There is no slot for us");
862
863
MOZ_CAN_RUN_SCRIPT static bool
864
reportValidity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLFormElement* self, const JSJitMethodCallArgs& args)
865
0
{
866
0
  AUTO_PROFILER_LABEL_FAST("HTMLFormElement.reportValidity", DOM, cx);
867
0
868
0
  bool result(self->ReportValidity());
869
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
870
0
  args.rval().setBoolean(result);
871
0
  return true;
872
0
}
873
874
static const JSJitInfo reportValidity_methodinfo = {
875
  { (JSJitGetterOp)reportValidity },
876
  { prototypes::id::HTMLFormElement },
877
  { PrototypeTraits<prototypes::id::HTMLFormElement>::Depth },
878
  JSJitInfo::Method,
879
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
880
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
881
  true,  /* isInfallible. False in setters. */
882
  false,  /* isMovable.  Not relevant for setters. */
883
  false, /* isEliminatable.  Not relevant for setters. */
884
  false, /* isAlwaysInSlot.  Only relevant for getters. */
885
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
886
  false,  /* isTypedMethod.  Only relevant for methods. */
887
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
888
};
889
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
890
static_assert(0 < 1, "There is no slot for us");
891
892
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
893
#if defined(__clang__)
894
#pragma clang diagnostic push
895
#pragma clang diagnostic ignored "-Wmissing-braces"
896
#endif
897
static const JSFunctionSpec sMethods_specs[] = {
898
  JS_FNSPEC("submit", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&submit_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
899
  JS_FNSPEC("reset", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&reset_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
900
  JS_FNSPEC("checkValidity", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&checkValidity_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
901
  JS_FNSPEC("reportValidity", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&reportValidity_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
902
  JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
903
  JS_FS_END
904
};
905
#if defined(__clang__)
906
#pragma clang diagnostic pop
907
#endif
908
909
910
static const Prefable<const JSFunctionSpec> sMethods[] = {
911
  { nullptr, &sMethods_specs[0] },
912
  { nullptr, nullptr }
913
};
914
915
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
916
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
917
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
918
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
919
920
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
921
#if defined(__clang__)
922
#pragma clang diagnostic push
923
#pragma clang diagnostic ignored "-Wmissing-braces"
924
#endif
925
static const JSPropertySpec sAttributes_specs[] = {
926
  { "acceptCharset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &acceptCharset_getterinfo, GenericSetter<NormalThisPolicy>, &acceptCharset_setterinfo },
927
  { "action", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &action_getterinfo, GenericSetter<NormalThisPolicy>, &action_setterinfo },
928
  { "autocomplete", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &autocomplete_getterinfo, GenericSetter<NormalThisPolicy>, &autocomplete_setterinfo },
929
  { "enctype", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &enctype_getterinfo, GenericSetter<NormalThisPolicy>, &enctype_setterinfo },
930
  { "encoding", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &encoding_getterinfo, GenericSetter<NormalThisPolicy>, &encoding_setterinfo },
931
  { "method", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &method_getterinfo, GenericSetter<NormalThisPolicy>, &method_setterinfo },
932
  { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, GenericSetter<NormalThisPolicy>, &name_setterinfo },
933
  { "noValidate", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &noValidate_getterinfo, GenericSetter<NormalThisPolicy>, &noValidate_setterinfo },
934
  { "target", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &target_getterinfo, GenericSetter<NormalThisPolicy>, &target_setterinfo },
935
  { "elements", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &elements_getterinfo, nullptr, nullptr },
936
  { "length", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &length_getterinfo, nullptr, nullptr },
937
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
938
};
939
#if defined(__clang__)
940
#pragma clang diagnostic pop
941
#endif
942
943
944
static const Prefable<const JSPropertySpec> sAttributes[] = {
945
  { nullptr, &sAttributes_specs[0] },
946
  { nullptr, nullptr }
947
};
948
949
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
950
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
951
static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
952
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
953
954
955
static uint16_t sNativeProperties_sortedPropertyIndices[16];
956
static PropertyInfo sNativeProperties_propertyInfos[16];
957
958
static const NativePropertiesN<2> sNativeProperties = {
959
  false, 0,
960
  false, 0,
961
  true,  0 /* sMethods */,
962
  true,  1 /* sAttributes */,
963
  false, 0,
964
  false, 0,
965
  false, 0,
966
  -1,
967
  16,
968
  sNativeProperties_sortedPropertyIndices,
969
  {
970
    { sMethods, &sNativeProperties_propertyInfos[0] },
971
    { sAttributes, &sNativeProperties_propertyInfos[5] }
972
  }
973
};
974
static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
975
    "We have a property info count that is oversized");
976
977
static bool
978
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
979
0
{
980
0
  AUTO_PROFILER_LABEL_FAST("HTMLFormElement constructor", DOM, cx);
981
0
982
0
  return HTMLConstructor(cx, argc, vp,
983
0
                         constructors::id::HTMLFormElement,
984
0
                         prototypes::id::HTMLFormElement,
985
0
                         CreateInterfaceObjects);
986
0
}
987
988
static const js::ClassOps sInterfaceObjectClassOps = {
989
    nullptr,               /* addProperty */
990
    nullptr,               /* delProperty */
991
    nullptr,               /* enumerate */
992
    nullptr,               /* newEnumerate */
993
    nullptr,               /* resolve */
994
    nullptr,               /* mayResolve */
995
    nullptr,               /* finalize */
996
    _constructor, /* call */
997
    nullptr,               /* hasInstance */
998
    _constructor, /* construct */
999
    nullptr,               /* trace */
1000
};
1001
1002
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1003
  {
1004
    "Function",
1005
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1006
    &sInterfaceObjectClassOps,
1007
    JS_NULL_CLASS_SPEC,
1008
    JS_NULL_CLASS_EXT,
1009
    &sInterfaceObjectClassObjectOps
1010
  },
1011
  eInterface,
1012
  true,
1013
  prototypes::id::HTMLFormElement,
1014
  PrototypeTraits<prototypes::id::HTMLFormElement>::Depth,
1015
  sNativePropertyHooks,
1016
  "function HTMLFormElement() {\n    [native code]\n}",
1017
  HTMLElement_Binding::GetConstructorObject
1018
};
1019
1020
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1021
  {
1022
    "HTMLFormElementPrototype",
1023
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1024
    JS_NULL_CLASS_OPS,
1025
    JS_NULL_CLASS_SPEC,
1026
    JS_NULL_CLASS_EXT,
1027
    JS_NULL_OBJECT_OPS
1028
  },
1029
  eInterfacePrototype,
1030
  false,
1031
  prototypes::id::HTMLFormElement,
1032
  PrototypeTraits<prototypes::id::HTMLFormElement>::Depth,
1033
  sNativePropertyHooks,
1034
  "[object HTMLFormElementPrototype]",
1035
  HTMLElement_Binding::GetProtoObject
1036
};
1037
1038
static_assert(IsBaseOf<nsISupports, mozilla::dom::HTMLFormElement >::value,
1039
                  "We don't support non-nsISupports native classes for "
1040
                  "proxy-based bindings yet");
1041
1042
1043
class DOMProxyHandler : public ShadowingDOMProxyHandler
1044
{
1045
public:
1046
  explicit constexpr DOMProxyHandler()
1047
0
  {
1048
0
  }
1049
1050
  virtual bool
1051
  getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
1052
1053
  virtual bool
1054
  defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
1055
1056
  using mozilla::dom::DOMProxyHandler::defineProperty;
1057
1058
  virtual bool
1059
  ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
1060
1061
  virtual bool
1062
  hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
1063
1064
  virtual bool
1065
  get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
1066
1067
  virtual const char*
1068
  className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
1069
1070
  virtual bool
1071
  finalizeInBackground(const JS::Value& priv) const override;
1072
1073
  virtual void
1074
  finalize(JSFreeOp* fop, JSObject* proxy) const override;
1075
1076
  static const DOMProxyHandler*
1077
  getInstance();
1078
1079
  virtual bool
1080
  delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
1081
1082
  virtual bool
1083
  getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
1084
1085
  virtual size_t
1086
  objectMoved(JSObject* obj, JSObject* old) const override;
1087
};
1088
1089
MOZ_ALWAYS_INLINE bool
1090
IsProxy(JSObject* obj)
1091
0
{
1092
0
  return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
1093
0
}
1094
1095
MOZ_ALWAYS_INLINE mozilla::dom::HTMLFormElement*
1096
UnwrapProxy(JSObject* obj)
1097
0
{
1098
0
  MOZ_ASSERT(js::IsProxy(obj));
1099
0
  if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
1100
0
    MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
1101
0
    obj = js::UncheckedUnwrap(obj);
1102
0
  }
1103
0
  MOZ_ASSERT(IsProxy(obj));
1104
0
  return static_cast<mozilla::dom::HTMLFormElement*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
1105
0
}
1106
1107
bool
1108
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
1109
0
{
1110
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
1111
0
  uint32_t index = GetArrayIndexFromId(cx, id);
1112
0
  if (IsArrayIndex(index)) {
1113
0
    mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1114
0
    bool found = false;
1115
0
    auto result(StrongOrRawPtr<mozilla::dom::Element>(self->IndexedGetter(index, found)));
1116
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1117
0
1118
0
    if (found) {
1119
0
      if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
1120
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
1121
0
        return false;
1122
0
      }
1123
0
      FillPropertyDescriptor(desc, proxy, true);
1124
0
      return true;
1125
0
    }
1126
0
  }
1127
0
1128
0
  JS::Rooted<JSObject*> expando(cx);
1129
0
  if (!isXray && (expando = GetExpandoObject(proxy))) {
1130
0
    if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
1131
0
      return false;
1132
0
    }
1133
0
    if (desc.object()) {
1134
0
      // Pretend the property lives on the wrapper.
1135
0
      desc.object().set(proxy);
1136
0
      return true;
1137
0
    }
1138
0
  }
1139
0
1140
0
  bool callNamedGetter = false;
1141
0
  if (!IsArrayIndex(index) && !ignoreNamedProps) {
1142
0
    if (!isXray) {
1143
0
      callNamedGetter = true;
1144
0
    } else {
1145
0
      bool hasOnProto;
1146
0
      if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) {
1147
0
        return false;
1148
0
      }
1149
0
      callNamedGetter = !hasOnProto;
1150
0
    }
1151
0
  }
1152
0
  if (callNamedGetter) {
1153
0
    FakeString name;
1154
0
    bool isSymbol;
1155
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
1156
0
      return false;
1157
0
    }
1158
0
    if (!isSymbol) {
1159
0
      mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1160
0
      bool found = false;
1161
0
      auto result(StrongOrRawPtr<nsISupports>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
1162
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
1163
0
1164
0
      if (found) {
1165
0
        if (!WrapObject(cx, result, desc.value())) {
1166
0
          return false;
1167
0
        }
1168
0
        FillPropertyDescriptor(desc, proxy, true, false);
1169
0
        return true;
1170
0
      }
1171
0
    }
1172
0
  }
1173
0
1174
0
  desc.object().set(nullptr);
1175
0
  return true;
1176
0
}
1177
1178
bool
1179
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
1180
0
{
1181
0
  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
1182
0
    *defined = true;
1183
0
    return opresult.failNoIndexedSetter();
1184
0
  }
1185
0
  bool found = false;
1186
0
  FakeString name;
1187
0
  bool isSymbol;
1188
0
  if (!ConvertIdToString(cx, id, name, isSymbol)) {
1189
0
    return false;
1190
0
  }
1191
0
  if (!isSymbol) {
1192
0
    mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1193
0
    auto result(StrongOrRawPtr<nsISupports>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
1194
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1195
0
    (void)result;
1196
0
  }
1197
0
1198
0
  if (found) {
1199
0
    *defined = true;
1200
0
    return opresult.failNoNamedSetter();
1201
0
  }
1202
0
  return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
1203
0
}
1204
1205
1206
bool
1207
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
1208
0
{
1209
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
1210
0
1211
0
  uint32_t length = UnwrapProxy(proxy)->Length();
1212
0
  MOZ_ASSERT(int32_t(length) >= 0);
1213
0
  for (int32_t i = 0; i < int32_t(length); ++i) {
1214
0
    if (!props.append(INT_TO_JSID(i))) {
1215
0
      return false;
1216
0
    }
1217
0
  }
1218
0
1219
0
  if (flags & JSITER_HIDDEN) {
1220
0
    nsTArray<nsString> names;
1221
0
    UnwrapProxy(proxy)->GetSupportedNames(names);
1222
0
    if (!AppendNamedPropertyIds(cx, proxy, names, !isXray, props)) {
1223
0
      return false;
1224
0
    }
1225
0
  }
1226
0
1227
0
  JS::Rooted<JSObject*> expando(cx);
1228
0
  if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
1229
0
      !js::GetPropertyKeys(cx, expando, flags, &props)) {
1230
0
    return false;
1231
0
  }
1232
0
1233
0
  return true;
1234
0
}
1235
1236
bool
1237
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
1238
0
{
1239
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1240
0
            "Should not have a XrayWrapper here");
1241
0
1242
0
  uint32_t index = GetArrayIndexFromId(cx, id);
1243
0
  if (IsArrayIndex(index)) {
1244
0
    bool found = false;
1245
0
    mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1246
0
    auto result(StrongOrRawPtr<mozilla::dom::Element>(self->IndexedGetter(index, found)));
1247
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1248
0
    (void)result;
1249
0
1250
0
    *bp = found;
1251
0
    return true;
1252
0
  }
1253
0
1254
0
1255
0
  JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
1256
0
  if (expando) {
1257
0
    bool b = true;
1258
0
    bool ok = JS_HasPropertyById(cx, expando, id, &b);
1259
0
    *bp = !!b;
1260
0
    if (!ok || *bp) {
1261
0
      return ok;
1262
0
    }
1263
0
  }
1264
0
1265
0
  bool found = false;
1266
0
  FakeString name;
1267
0
  bool isSymbol;
1268
0
  if (!ConvertIdToString(cx, id, name, isSymbol)) {
1269
0
    return false;
1270
0
  }
1271
0
  if (!isSymbol) {
1272
0
    mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1273
0
    auto result(StrongOrRawPtr<nsISupports>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
1274
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1275
0
    (void)result;
1276
0
  }
1277
0
1278
0
  *bp = found;
1279
0
1280
0
  return true;
1281
0
}
1282
1283
bool
1284
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
1285
0
{
1286
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1287
0
              "Should not have a XrayWrapper here");
1288
0
1289
0
  uint32_t index = GetArrayIndexFromId(cx, id);
1290
0
  if (IsArrayIndex(index)) {
1291
0
    mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1292
0
    bool found = false;
1293
0
    auto result(StrongOrRawPtr<mozilla::dom::Element>(self->IndexedGetter(index, found)));
1294
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1295
0
1296
0
    if (found) {
1297
0
      if (!GetOrCreateDOMReflector(cx, result, vp)) {
1298
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
1299
0
        return false;
1300
0
      }
1301
0
      return true;
1302
0
    }
1303
0
    // Even if we don't have this index, we don't forward the
1304
0
    // get on to our expando object.
1305
0
  } else {
1306
0
    { // Scope for expando
1307
0
      JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
1308
0
      if (expando) {
1309
0
        bool hasProp;
1310
0
        if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
1311
0
          return false;
1312
0
        }
1313
0
1314
0
        if (hasProp) {
1315
0
          // Forward the get to the expando object, but our receiver is whatever our
1316
0
          // receiver is.
1317
0
          return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
1318
0
        }
1319
0
      }
1320
0
    }
1321
0
  }
1322
0
1323
0
  if (!IsArrayIndex(index)) {
1324
0
    FakeString name;
1325
0
    bool isSymbol;
1326
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
1327
0
      return false;
1328
0
    }
1329
0
    if (!isSymbol) {
1330
0
      mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1331
0
      bool found = false;
1332
0
      auto result(StrongOrRawPtr<nsISupports>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
1333
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
1334
0
1335
0
      if (found) {
1336
0
        if (!WrapObject(cx, result, vp)) {
1337
0
          return false;
1338
0
        }
1339
0
        return true;
1340
0
      }
1341
0
    }
1342
0
  }
1343
0
1344
0
  bool foundOnPrototype;
1345
0
  if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
1346
0
    return false;
1347
0
  }
1348
0
1349
0
  if (foundOnPrototype) {
1350
0
    return true;
1351
0
  }
1352
0
1353
0
  vp.setUndefined();
1354
0
  return true;
1355
0
}
1356
1357
const char*
1358
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
1359
0
{
1360
0
  return "HTMLFormElement";
1361
0
}
1362
1363
bool
1364
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
1365
0
{
1366
0
  return false;
1367
0
}
1368
1369
void
1370
DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
1371
0
{
1372
0
  mozilla::dom::HTMLFormElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLFormElement>(proxy);
1373
0
  if (self) {
1374
0
    // Either our proxy created an expando object or not.  If it did,
1375
0
    // then we would have preserved ourselves, and hence if we're going
1376
0
    // away so is our C++ object and we should reset its expando value.
1377
0
    // It's possible that in this situation the C++ object's reflector
1378
0
    // pointer has been nulled out, but if not it's pointing to us.  If
1379
0
    // our proxy did _not_ create an expando object then it's possible
1380
0
    // that we're no longer the reflector for our C++ object (and
1381
0
    // incremental finalization is finally getting to us), and that in
1382
0
    // the meantime the new reflector has created an expando object.
1383
0
    // In that case we do NOT want to clear the expando pointer in the
1384
0
    // C++ object.
1385
0
    //
1386
0
    // It's important to do this before we ClearWrapper, of course.
1387
0
    JSObject* reflector = self->GetWrapperMaybeDead();
1388
0
    if (!reflector || reflector == proxy) {
1389
0
      self->mExpandoAndGeneration.expando = JS::UndefinedValue();
1390
0
    }
1391
0
    ClearWrapper(self, self, proxy);
1392
0
    AddForDeferredFinalization<mozilla::dom::HTMLFormElement>(self);
1393
0
  }
1394
0
}
1395
1396
const DOMProxyHandler*
1397
DOMProxyHandler::getInstance()
1398
0
{
1399
0
  static const DOMProxyHandler instance;
1400
0
  return &instance;
1401
0
}
1402
1403
bool
1404
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
1405
0
{
1406
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1407
0
            "Should not have a XrayWrapper here");
1408
0
1409
0
  uint32_t index = GetArrayIndexFromId(cx, id);
1410
0
  if (IsArrayIndex(index)) {
1411
0
    bool deleteSucceeded;
1412
0
    bool found = false;
1413
0
    mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1414
0
    auto result(StrongOrRawPtr<mozilla::dom::Element>(self->IndexedGetter(index, found)));
1415
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1416
0
    (void)result;
1417
0
    deleteSucceeded = !found;
1418
0
    return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
1419
0
  }
1420
0
  // Try named delete only if the named property visibility
1421
0
  // algorithm says the property is visible.
1422
0
  bool tryNamedDelete = true;
1423
0
  { // Scope for expando
1424
0
    JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
1425
0
    if (expando) {
1426
0
      bool hasProp;
1427
0
      if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
1428
0
        return false;
1429
0
      }
1430
0
      tryNamedDelete = !hasProp;
1431
0
    }
1432
0
  }
1433
0
  if (tryNamedDelete) {
1434
0
    bool found = false;
1435
0
    bool deleteSucceeded;
1436
0
    FakeString name;
1437
0
    bool isSymbol;
1438
0
    if (!ConvertIdToString(cx, id, name, isSymbol)) {
1439
0
      return false;
1440
0
    }
1441
0
    if (!isSymbol) {
1442
0
      mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1443
0
      auto result(StrongOrRawPtr<nsISupports>(self->NamedGetter(NonNullHelper(Constify(name)), found)));
1444
0
      MOZ_ASSERT(!JS_IsExceptionPending(cx));
1445
0
      (void)result;
1446
0
    }
1447
0
    deleteSucceeded = !found;
1448
0
    if (found) {
1449
0
      return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
1450
0
    }
1451
0
  }
1452
0
1453
0
  return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
1454
0
}
1455
1456
bool
1457
DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
1458
0
{
1459
0
  JS::Rooted<JS::Value> temp(cx);
1460
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1461
0
             "Should not have a XrayWrapper here");
1462
0
1463
0
  mozilla::dom::HTMLFormElement* self = UnwrapProxy(proxy);
1464
0
  uint32_t length = self->Length();
1465
0
  // Compute the end of the indices we'll get ourselves
1466
0
  uint32_t ourEnd = std::max(begin, std::min(end, length));
1467
0
1468
0
  for (uint32_t index = begin; index < ourEnd; ++index) {
1469
0
    bool found = false;
1470
0
    auto result(StrongOrRawPtr<mozilla::dom::Element>(self->IndexedGetter(index, found)));
1471
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
1472
0
1473
0
    MOZ_ASSERT(found);
1474
0
    if (!GetOrCreateDOMReflector(cx, result, &temp)) {
1475
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
1476
0
      return false;
1477
0
    }
1478
0
    if (!adder->append(cx, temp)) return false;
1479
0
    continue;
1480
0
  }
1481
0
1482
0
  if (end > ourEnd) {
1483
0
    JS::Rooted<JSObject*> proto(cx);
1484
0
    if (!js::GetObjectProto(cx, proxy, &proto)) {
1485
0
      return false;
1486
0
    }
1487
0
    return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
1488
0
  }
1489
0
1490
0
  return true;
1491
0
}
1492
1493
size_t
1494
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
1495
0
{
1496
0
  mozilla::dom::HTMLFormElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLFormElement>(obj);
1497
0
  if (self) {
1498
0
    UpdateWrapper(self, self, obj, old);
1499
0
  }
1500
0
1501
0
  return 0;
1502
0
}
1503
1504
static const DOMJSClass sClass = {
1505
  PROXY_CLASS_DEF("HTMLFormElement",
1506
                  JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
1507
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLFormElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1508
  IsBaseOf<nsISupports, mozilla::dom::HTMLFormElement >::value,
1509
  sNativePropertyHooks,
1510
  FindAssociatedGlobalForNative<mozilla::dom::HTMLFormElement>::Get,
1511
  GetProtoObjectHandle,
1512
  GetCCParticipant<mozilla::dom::HTMLFormElement>::Get()
1513
};
1514
1515
bool
1516
Wrap(JSContext* aCx, mozilla::dom::HTMLFormElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1517
0
{
1518
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLFormElement>::value,
1519
0
                "Shouldn't have wrappercached things that are not refcounted.");
1520
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLFormElement*>(aObject) ==
1521
0
             reinterpret_cast<mozilla::dom::HTMLFormElement*>(aObject),
1522
0
             "Multiple inheritance for mozilla::dom::HTMLFormElement is broken.");
1523
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
1524
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
1525
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
1526
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
1527
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
1528
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
1529
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
1530
0
             reinterpret_cast<nsINode*>(aObject),
1531
0
             "Multiple inheritance for nsINode is broken.");
1532
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1533
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1534
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1535
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1536
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1537
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1538
0
             "You should probably not be using Wrap() directly; use "
1539
0
             "GetOrCreateDOMReflector instead");
1540
0
1541
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1542
0
             "nsISupports must be on our primary inheritance chain");
1543
0
1544
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1545
0
  if (!global) {
1546
0
    return false;
1547
0
  }
1548
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1549
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1550
0
1551
0
  // That might have ended up wrapping us already, due to the wonders
1552
0
  // of XBL.  Check for that, and bail out as needed.
1553
0
  aReflector.set(aCache->GetWrapper());
1554
0
  if (aReflector) {
1555
#ifdef DEBUG
1556
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1557
#endif // DEBUG
1558
    return true;
1559
0
  }
1560
0
1561
0
  JSAutoRealm ar(aCx, global);
1562
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1563
0
  if (!canonicalProto) {
1564
0
    return false;
1565
0
  }
1566
0
  JS::Rooted<JSObject*> proto(aCx);
1567
0
  if (aGivenProto) {
1568
0
    proto = aGivenProto;
1569
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1570
0
    // coming in, we changed compartments to that of "parent" so may need
1571
0
    // to wrap the proto here.
1572
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1573
0
      if (!JS_WrapObject(aCx, &proto)) {
1574
0
        return false;
1575
0
      }
1576
0
    }
1577
0
  } else {
1578
0
    proto = canonicalProto;
1579
0
  }
1580
0
1581
0
  BindingJSObjectCreator<mozilla::dom::HTMLFormElement> creator(aCx);
1582
0
  aObject->mExpandoAndGeneration.expando.setUndefined();
1583
0
  JS::Rooted<JS::Value> expandoValue(aCx, JS::PrivateValue(&aObject->mExpandoAndGeneration));
1584
0
  creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
1585
0
                            proto, aObject, expandoValue, aReflector);
1586
0
  if (!aReflector) {
1587
0
    return false;
1588
0
  }
1589
0
1590
0
  aCache->SetWrapper(aReflector);
1591
0
  creator.InitializationSucceeded();
1592
0
1593
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1594
0
             aCache->GetWrapperPreserveColor() == aReflector);
1595
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1596
0
  // otherwise we won't be able to properly recreate it later, since
1597
0
  // we won't know what proto to use.  Note that we don't check
1598
0
  // aGivenProto here, since it's entirely possible (and even
1599
0
  // somewhat common) to have a non-null aGivenProto which is the
1600
0
  // same as canonicalProto.
1601
0
  if (proto != canonicalProto) {
1602
0
    PreserveWrapper(aObject);
1603
0
  }
1604
0
1605
0
  return true;
1606
0
}
1607
1608
static bool
1609
ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
1610
0
{
1611
0
  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
1612
0
}
1613
1614
static bool
1615
EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
1616
0
{
1617
0
  return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
1618
0
}
1619
1620
const NativePropertyHooks sNativePropertyHooks[] = { {
1621
  ResolveOwnProperty,
1622
  EnumerateOwnProperties,
1623
  nullptr,
1624
  { sNativeProperties.Upcast(), nullptr },
1625
  prototypes::id::HTMLFormElement,
1626
  constructors::id::HTMLFormElement,
1627
  HTMLElement_Binding::sNativePropertyHooks,
1628
  &DefaultXrayExpandoObjectClass
1629
} };
1630
1631
void
1632
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1633
0
{
1634
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
1635
0
  if (!parentProto) {
1636
0
    return;
1637
0
  }
1638
0
1639
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
1640
0
  if (!constructorProto) {
1641
0
    return;
1642
0
  }
1643
0
1644
0
  static bool sIdsInited = false;
1645
0
  if (!sIdsInited && NS_IsMainThread()) {
1646
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1647
0
      return;
1648
0
    }
1649
0
    sIdsInited = true;
1650
0
  }
1651
0
1652
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLFormElement);
1653
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLFormElement);
1654
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1655
0
                              &sPrototypeClass.mBase, protoCache,
1656
0
                              nullptr,
1657
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1658
0
                              interfaceCache,
1659
0
                              sNativeProperties.Upcast(),
1660
0
                              nullptr,
1661
0
                              "HTMLFormElement", aDefineOnGlobal,
1662
0
                              nullptr,
1663
0
                              false);
1664
0
}
1665
1666
JSObject*
1667
GetConstructorObject(JSContext* aCx)
1668
0
{
1669
0
  return GetConstructorObjectHandle(aCx);
1670
0
}
1671
1672
} // namespace HTMLFormElement_Binding
1673
1674
1675
1676
} // namespace dom
1677
} // namespace mozilla