Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/XSLTProcessorBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM XSLTProcessor.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "WrapperFactory.h"
4
#include "XSLTProcessorBinding.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/CustomElementRegistry.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/DocGroup.h"
10
#include "mozilla/dom/DocumentFragment.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/Nullable.h"
13
#include "mozilla/dom/PrimitiveConversions.h"
14
#include "mozilla/dom/XrayExpandoClass.h"
15
#include "nsContentUtils.h"
16
#include "nsIDocument.h"
17
#include "nsINode.h"
18
#include "nsIVariant.h"
19
#include "txMozillaXSLTProcessor.h"
20
21
namespace mozilla {
22
namespace dom {
23
24
namespace binding_detail {}; // Just to make sure it's known as a namespace
25
using namespace mozilla::dom::binding_detail;
26
27
28
namespace XSLTProcessor_Binding {
29
30
MOZ_CAN_RUN_SCRIPT static bool
31
importStylesheet(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
32
0
{
33
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.importStylesheet", DOM, cx);
34
0
35
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
36
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XSLTProcessor.importStylesheet");
37
0
  }
38
0
  NonNull<nsINode> arg0;
39
0
  if (args[0].isObject()) {
40
0
    {
41
0
      nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
42
0
      if (NS_FAILED(rv)) {
43
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XSLTProcessor.importStylesheet", "Node");
44
0
        return false;
45
0
      }
46
0
    }
47
0
  } else {
48
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XSLTProcessor.importStylesheet");
49
0
    return false;
50
0
  }
51
0
  FastErrorResult rv;
52
0
  self->ImportStylesheet(MOZ_KnownLive(NonNullHelper(arg0)), rv);
53
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
54
0
    return false;
55
0
  }
56
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
57
0
  args.rval().setUndefined();
58
0
  return true;
59
0
}
60
61
static const JSJitInfo importStylesheet_methodinfo = {
62
  { (JSJitGetterOp)importStylesheet },
63
  { prototypes::id::XSLTProcessor },
64
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
65
  JSJitInfo::Method,
66
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
67
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
68
  false,  /* isInfallible. False in setters. */
69
  false,  /* isMovable.  Not relevant for setters. */
70
  false, /* isEliminatable.  Not relevant for setters. */
71
  false, /* isAlwaysInSlot.  Only relevant for getters. */
72
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
73
  false,  /* isTypedMethod.  Only relevant for methods. */
74
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
75
};
76
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
77
static_assert(0 < 1, "There is no slot for us");
78
79
MOZ_CAN_RUN_SCRIPT static bool
80
transformToFragment(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
81
0
{
82
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.transformToFragment", DOM, cx);
83
0
84
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
85
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XSLTProcessor.transformToFragment");
86
0
  }
87
0
  NonNull<nsINode> arg0;
88
0
  if (args[0].isObject()) {
89
0
    {
90
0
      nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
91
0
      if (NS_FAILED(rv)) {
92
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XSLTProcessor.transformToFragment", "Node");
93
0
        return false;
94
0
      }
95
0
    }
96
0
  } else {
97
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XSLTProcessor.transformToFragment");
98
0
    return false;
99
0
  }
100
0
  NonNull<nsIDocument> arg1;
101
0
  if (args[1].isObject()) {
102
0
    {
103
0
      nsresult rv = UnwrapObject<prototypes::id::Document, nsIDocument>(args[1], arg1);
104
0
      if (NS_FAILED(rv)) {
105
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of XSLTProcessor.transformToFragment", "Document");
106
0
        return false;
107
0
      }
108
0
    }
109
0
  } else {
110
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of XSLTProcessor.transformToFragment");
111
0
    return false;
112
0
  }
113
0
  Maybe<AutoCEReaction> ceReaction;
114
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
115
0
    DocGroup* docGroup = self->GetDocGroup();
116
0
    if (docGroup) {
117
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
118
0
    }
119
0
  }
120
0
  FastErrorResult rv;
121
0
  auto result(StrongOrRawPtr<mozilla::dom::DocumentFragment>(self->TransformToFragment(MOZ_KnownLive(NonNullHelper(arg0)), MOZ_KnownLive(NonNullHelper(arg1)), rv)));
122
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
123
0
    return false;
124
0
  }
125
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
126
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
127
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
128
0
    return false;
129
0
  }
130
0
  return true;
131
0
}
132
133
static const JSJitInfo transformToFragment_methodinfo = {
134
  { (JSJitGetterOp)transformToFragment },
135
  { prototypes::id::XSLTProcessor },
136
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
137
  JSJitInfo::Method,
138
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
139
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
140
  false,  /* isInfallible. False in setters. */
141
  false,  /* isMovable.  Not relevant for setters. */
142
  false, /* isEliminatable.  Not relevant for setters. */
143
  false, /* isAlwaysInSlot.  Only relevant for getters. */
144
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
145
  false,  /* isTypedMethod.  Only relevant for methods. */
146
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
147
};
148
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
149
static_assert(0 < 1, "There is no slot for us");
150
151
MOZ_CAN_RUN_SCRIPT static bool
152
transformToDocument(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
153
0
{
154
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.transformToDocument", DOM, cx);
155
0
156
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
157
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XSLTProcessor.transformToDocument");
158
0
  }
159
0
  NonNull<nsINode> arg0;
160
0
  if (args[0].isObject()) {
161
0
    {
162
0
      nsresult rv = UnwrapObject<prototypes::id::Node, nsINode>(args[0], arg0);
163
0
      if (NS_FAILED(rv)) {
164
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of XSLTProcessor.transformToDocument", "Node");
165
0
        return false;
166
0
      }
167
0
    }
168
0
  } else {
169
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of XSLTProcessor.transformToDocument");
170
0
    return false;
171
0
  }
172
0
  Maybe<AutoCEReaction> ceReaction;
173
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
174
0
    DocGroup* docGroup = self->GetDocGroup();
175
0
    if (docGroup) {
176
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
177
0
    }
178
0
  }
179
0
  FastErrorResult rv;
180
0
  auto result(StrongOrRawPtr<nsIDocument>(self->TransformToDocument(MOZ_KnownLive(NonNullHelper(arg0)), rv)));
181
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
182
0
    return false;
183
0
  }
184
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
185
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
186
0
    MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing");
187
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
188
0
    return false;
189
0
  }
190
0
  return true;
191
0
}
192
193
static const JSJitInfo transformToDocument_methodinfo = {
194
  { (JSJitGetterOp)transformToDocument },
195
  { prototypes::id::XSLTProcessor },
196
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
197
  JSJitInfo::Method,
198
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
199
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
200
  false,  /* isInfallible. False in setters. */
201
  false,  /* isMovable.  Not relevant for setters. */
202
  false, /* isEliminatable.  Not relevant for setters. */
203
  false, /* isAlwaysInSlot.  Only relevant for getters. */
204
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
205
  false,  /* isTypedMethod.  Only relevant for methods. */
206
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
207
};
208
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
209
static_assert(0 < 1, "There is no slot for us");
210
211
MOZ_CAN_RUN_SCRIPT static bool
212
setParameter(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
213
0
{
214
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.setParameter", DOM, cx);
215
0
216
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
217
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XSLTProcessor.setParameter");
218
0
  }
219
0
  binding_detail::FakeString arg0;
220
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
221
0
    return false;
222
0
  }
223
0
  binding_detail::FakeString arg1;
224
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
225
0
    return false;
226
0
  }
227
0
  JS::Rooted<JS::Value> arg2(cx);
228
0
  arg2 = args[2];
229
0
  FastErrorResult rv;
230
0
  self->SetParameter(cx, NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), arg2, rv);
231
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
232
0
    return false;
233
0
  }
234
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
235
0
  args.rval().setUndefined();
236
0
  return true;
237
0
}
238
239
static const JSJitInfo setParameter_methodinfo = {
240
  { (JSJitGetterOp)setParameter },
241
  { prototypes::id::XSLTProcessor },
242
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
243
  JSJitInfo::Method,
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
getParameter(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
259
0
{
260
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.getParameter", DOM, cx);
261
0
262
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
263
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XSLTProcessor.getParameter");
264
0
  }
265
0
  binding_detail::FakeString arg0;
266
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
267
0
    return false;
268
0
  }
269
0
  binding_detail::FakeString arg1;
270
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
271
0
    return false;
272
0
  }
273
0
  FastErrorResult rv;
274
0
  auto result(StrongOrRawPtr<nsIVariant>(self->GetParameter(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv)));
275
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
276
0
    return false;
277
0
  }
278
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
279
0
  if (!result) {
280
0
    args.rval().setNull();
281
0
    return true;
282
0
  }
283
0
  if (!WrapObject(cx, result, &NS_GET_IID(nsIVariant), args.rval())) {
284
0
    return false;
285
0
  }
286
0
  return true;
287
0
}
288
289
static const JSJitInfo getParameter_methodinfo = {
290
  { (JSJitGetterOp)getParameter },
291
  { prototypes::id::XSLTProcessor },
292
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
293
  JSJitInfo::Method,
294
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
295
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
296
  false,  /* isInfallible. False in setters. */
297
  false,  /* isMovable.  Not relevant for setters. */
298
  false, /* isEliminatable.  Not relevant for setters. */
299
  false, /* isAlwaysInSlot.  Only relevant for getters. */
300
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
301
  false,  /* isTypedMethod.  Only relevant for methods. */
302
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
303
};
304
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
305
static_assert(0 < 1, "There is no slot for us");
306
307
MOZ_CAN_RUN_SCRIPT static bool
308
removeParameter(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
309
0
{
310
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.removeParameter", DOM, cx);
311
0
312
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
313
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "XSLTProcessor.removeParameter");
314
0
  }
315
0
  binding_detail::FakeString arg0;
316
0
  if (!ConvertJSValueToString(cx, args[0], eEmpty, eStringify, arg0)) {
317
0
    return false;
318
0
  }
319
0
  binding_detail::FakeString arg1;
320
0
  if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
321
0
    return false;
322
0
  }
323
0
  FastErrorResult rv;
324
0
  self->RemoveParameter(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)), rv);
325
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
326
0
    return false;
327
0
  }
328
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
329
0
  args.rval().setUndefined();
330
0
  return true;
331
0
}
332
333
static const JSJitInfo removeParameter_methodinfo = {
334
  { (JSJitGetterOp)removeParameter },
335
  { prototypes::id::XSLTProcessor },
336
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
337
  JSJitInfo::Method,
338
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
339
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
340
  false,  /* isInfallible. False in setters. */
341
  false,  /* isMovable.  Not relevant for setters. */
342
  false, /* isEliminatable.  Not relevant for setters. */
343
  false, /* isAlwaysInSlot.  Only relevant for getters. */
344
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
345
  false,  /* isTypedMethod.  Only relevant for methods. */
346
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
347
};
348
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
349
static_assert(0 < 1, "There is no slot for us");
350
351
MOZ_CAN_RUN_SCRIPT static bool
352
clearParameters(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
353
0
{
354
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.clearParameters", DOM, cx);
355
0
356
0
  self->ClearParameters();
357
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
358
0
  args.rval().setUndefined();
359
0
  return true;
360
0
}
361
362
static const JSJitInfo clearParameters_methodinfo = {
363
  { (JSJitGetterOp)clearParameters },
364
  { prototypes::id::XSLTProcessor },
365
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
366
  JSJitInfo::Method,
367
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
368
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
369
  true,  /* isInfallible. False in setters. */
370
  false,  /* isMovable.  Not relevant for setters. */
371
  false, /* isEliminatable.  Not relevant for setters. */
372
  false, /* isAlwaysInSlot.  Only relevant for getters. */
373
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
374
  false,  /* isTypedMethod.  Only relevant for methods. */
375
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
376
};
377
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
378
static_assert(0 < 1, "There is no slot for us");
379
380
MOZ_CAN_RUN_SCRIPT static bool
381
reset(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, const JSJitMethodCallArgs& args)
382
0
{
383
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor.reset", DOM, cx);
384
0
385
0
  self->Reset();
386
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
387
0
  args.rval().setUndefined();
388
0
  return true;
389
0
}
390
391
static const JSJitInfo reset_methodinfo = {
392
  { (JSJitGetterOp)reset },
393
  { prototypes::id::XSLTProcessor },
394
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
395
  JSJitInfo::Method,
396
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
397
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
398
  true,  /* isInfallible. False in setters. */
399
  false,  /* isMovable.  Not relevant for setters. */
400
  false, /* isEliminatable.  Not relevant for setters. */
401
  false, /* isAlwaysInSlot.  Only relevant for getters. */
402
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
403
  false,  /* isTypedMethod.  Only relevant for methods. */
404
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
405
};
406
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
407
static_assert(0 < 1, "There is no slot for us");
408
409
MOZ_CAN_RUN_SCRIPT static bool
410
get_flags(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, JSJitGetterCallArgs args)
411
0
{
412
0
  AUTO_PROFILER_LABEL_FAST("get XSLTProcessor.flags", DOM, cx);
413
0
414
0
  uint32_t result(self->Flags(SystemCallerGuarantee()));
415
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
416
0
  args.rval().setNumber(result);
417
0
  return true;
418
0
}
419
420
MOZ_CAN_RUN_SCRIPT static bool
421
set_flags(JSContext* cx, JS::Handle<JSObject*> obj, txMozillaXSLTProcessor* self, JSJitSetterCallArgs args)
422
0
{
423
0
  AUTO_PROFILER_LABEL_FAST("set XSLTProcessor.flags", DOM, cx);
424
0
425
0
  uint32_t arg0;
426
0
  if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
427
0
    return false;
428
0
  }
429
0
  self->SetFlags(arg0, SystemCallerGuarantee());
430
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
431
0
432
0
  return true;
433
0
}
434
435
static const JSJitInfo flags_getterinfo = {
436
  { (JSJitGetterOp)get_flags },
437
  { prototypes::id::XSLTProcessor },
438
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
439
  JSJitInfo::Getter,
440
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
441
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
442
  true,  /* isInfallible. False in setters. */
443
  false,  /* isMovable.  Not relevant for setters. */
444
  false, /* isEliminatable.  Not relevant for setters. */
445
  false, /* isAlwaysInSlot.  Only relevant for getters. */
446
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
447
  false,  /* isTypedMethod.  Only relevant for methods. */
448
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
449
};
450
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
451
static_assert(0 < 1, "There is no slot for us");
452
static const JSJitInfo flags_setterinfo = {
453
  { (JSJitGetterOp)set_flags },
454
  { prototypes::id::XSLTProcessor },
455
  { PrototypeTraits<prototypes::id::XSLTProcessor>::Depth },
456
  JSJitInfo::Setter,
457
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
458
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
459
  false,  /* isInfallible. False in setters. */
460
  false,  /* isMovable.  Not relevant for setters. */
461
  false, /* isEliminatable.  Not relevant for setters. */
462
  false, /* isAlwaysInSlot.  Only relevant for getters. */
463
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
464
  false,  /* isTypedMethod.  Only relevant for methods. */
465
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
466
};
467
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
468
static_assert(0 < 1, "There is no slot for us");
469
470
static bool
471
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
472
0
{
473
0
  txMozillaXSLTProcessor* self = UnwrapPossiblyNotInitializedDOMObject<txMozillaXSLTProcessor>(obj);
474
0
  // We don't want to preserve if we don't have a wrapper, and we
475
0
  // obviously can't preserve if we're not initialized.
476
0
  if (self && self->GetWrapperPreserveColor()) {
477
0
    PreserveWrapper(self);
478
0
  }
479
0
  return true;
480
0
}
481
482
static void
483
_finalize(js::FreeOp* fop, JSObject* obj)
484
0
{
485
0
  txMozillaXSLTProcessor* self = UnwrapPossiblyNotInitializedDOMObject<txMozillaXSLTProcessor>(obj);
486
0
  if (self) {
487
0
    ClearWrapper(self, self, obj);
488
0
    AddForDeferredFinalization<txMozillaXSLTProcessor>(self);
489
0
  }
490
0
}
491
492
static size_t
493
_objectMoved(JSObject* obj, JSObject* old)
494
0
{
495
0
  txMozillaXSLTProcessor* self = UnwrapPossiblyNotInitializedDOMObject<txMozillaXSLTProcessor>(obj);
496
0
  if (self) {
497
0
    UpdateWrapper(self, self, obj, old);
498
0
  }
499
0
500
0
  return 0;
501
0
}
502
503
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
504
#if defined(__clang__)
505
#pragma clang diagnostic push
506
#pragma clang diagnostic ignored "-Wmissing-braces"
507
#endif
508
static const JSFunctionSpec sMethods_specs[] = {
509
  JS_FNSPEC("importStylesheet", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&importStylesheet_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
510
  JS_FNSPEC("transformToFragment", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&transformToFragment_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
511
  JS_FNSPEC("transformToDocument", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&transformToDocument_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
512
  JS_FNSPEC("setParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setParameter_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
513
  JS_FNSPEC("getParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
514
  JS_FNSPEC("removeParameter", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeParameter_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
515
  JS_FNSPEC("clearParameters", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clearParameters_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
516
  JS_FNSPEC("reset", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&reset_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
517
  JS_FS_END
518
};
519
#if defined(__clang__)
520
#pragma clang diagnostic pop
521
#endif
522
523
524
static const Prefable<const JSFunctionSpec> sMethods[] = {
525
  { nullptr, &sMethods_specs[0] },
526
  { nullptr, nullptr }
527
};
528
529
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
530
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
531
static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
532
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
533
534
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
535
#if defined(__clang__)
536
#pragma clang diagnostic push
537
#pragma clang diagnostic ignored "-Wmissing-braces"
538
#endif
539
static const JSPropertySpec sChromeAttributes_specs[] = {
540
  { "flags", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &flags_getterinfo, GenericSetter<NormalThisPolicy>, &flags_setterinfo },
541
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
542
};
543
#if defined(__clang__)
544
#pragma clang diagnostic pop
545
#endif
546
547
548
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
549
  { nullptr, &sChromeAttributes_specs[0] },
550
  { nullptr, nullptr }
551
};
552
553
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
554
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
555
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
556
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
557
558
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
559
#if defined(__clang__)
560
#pragma clang diagnostic push
561
#pragma clang diagnostic ignored "-Wmissing-braces"
562
#endif
563
static const ConstantSpec sChromeConstants_specs[] = {
564
  { "DISABLE_ALL_LOADS", JS::NumberValue(1U) },
565
  { 0, JS::UndefinedValue() }
566
};
567
#if defined(__clang__)
568
#pragma clang diagnostic pop
569
#endif
570
571
572
static const Prefable<const ConstantSpec> sChromeConstants[] = {
573
  { nullptr, &sChromeConstants_specs[0] },
574
  { nullptr, nullptr }
575
};
576
577
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
578
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
579
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
580
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
581
582
583
static uint16_t sNativeProperties_sortedPropertyIndices[8];
584
static PropertyInfo sNativeProperties_propertyInfos[8];
585
586
static const NativePropertiesN<1> sNativeProperties = {
587
  false, 0,
588
  false, 0,
589
  true,  0 /* sMethods */,
590
  false, 0,
591
  false, 0,
592
  false, 0,
593
  false, 0,
594
  -1,
595
  8,
596
  sNativeProperties_sortedPropertyIndices,
597
  {
598
    { sMethods, &sNativeProperties_propertyInfos[0] }
599
  }
600
};
601
static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
602
    "We have a property info count that is oversized");
603
604
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2];
605
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2];
606
607
static const NativePropertiesN<2> sChromeOnlyNativeProperties = {
608
  false, 0,
609
  false, 0,
610
  false, 0,
611
  true,  0 /* sChromeAttributes */,
612
  false, 0,
613
  false, 0,
614
  true,  1 /* sChromeConstants */,
615
  -1,
616
  2,
617
  sChromeOnlyNativeProperties_sortedPropertyIndices,
618
  {
619
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] },
620
    { sChromeConstants, &sChromeOnlyNativeProperties_propertyInfos[1] }
621
  }
622
};
623
static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
624
    "We have a property info count that is oversized");
625
626
static bool
627
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
628
0
{
629
0
  AUTO_PROFILER_LABEL_FAST("XSLTProcessor constructor", DOM, cx);
630
0
631
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
632
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
633
0
  if (!args.isConstructing()) {
634
0
    // XXXbz wish I could get the name from the callee instead of
635
0
    // Adding more relocations
636
0
    return ThrowConstructorWithoutNew(cx, "XSLTProcessor");
637
0
  }
638
0
639
0
  JS::Rooted<JSObject*> desiredProto(cx);
640
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
641
0
    return false;
642
0
  }
643
0
644
0
  GlobalObject global(cx, obj);
645
0
  if (global.Failed()) {
646
0
    return false;
647
0
  }
648
0
649
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
650
0
  Maybe<JSAutoRealm> ar;
651
0
  if (objIsXray) {
652
0
    obj = js::CheckedUnwrap(obj);
653
0
    if (!obj) {
654
0
      return false;
655
0
    }
656
0
    ar.emplace(cx, obj);
657
0
    if (!JS_WrapObject(cx, &desiredProto)) {
658
0
      return false;
659
0
    }
660
0
  }
661
0
  FastErrorResult rv;
662
0
  auto result(StrongOrRawPtr<txMozillaXSLTProcessor>(txMozillaXSLTProcessor::Constructor(global, rv)));
663
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
664
0
    return false;
665
0
  }
666
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
667
0
  static_assert(!IsPointer<decltype(result)>::value,
668
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
669
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
670
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
671
0
    return false;
672
0
  }
673
0
  return true;
674
0
}
675
676
static const js::ClassOps sInterfaceObjectClassOps = {
677
    nullptr,               /* addProperty */
678
    nullptr,               /* delProperty */
679
    nullptr,               /* enumerate */
680
    nullptr,               /* newEnumerate */
681
    nullptr,               /* resolve */
682
    nullptr,               /* mayResolve */
683
    nullptr,               /* finalize */
684
    _constructor, /* call */
685
    nullptr,               /* hasInstance */
686
    _constructor, /* construct */
687
    nullptr,               /* trace */
688
};
689
690
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
691
  {
692
    "Function",
693
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
694
    &sInterfaceObjectClassOps,
695
    JS_NULL_CLASS_SPEC,
696
    JS_NULL_CLASS_EXT,
697
    &sInterfaceObjectClassObjectOps
698
  },
699
  eInterface,
700
  true,
701
  prototypes::id::XSLTProcessor,
702
  PrototypeTraits<prototypes::id::XSLTProcessor>::Depth,
703
  sNativePropertyHooks,
704
  "function XSLTProcessor() {\n    [native code]\n}",
705
  JS::GetRealmFunctionPrototype
706
};
707
708
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
709
  {
710
    "XSLTProcessorPrototype",
711
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
712
    JS_NULL_CLASS_OPS,
713
    JS_NULL_CLASS_SPEC,
714
    JS_NULL_CLASS_EXT,
715
    JS_NULL_OBJECT_OPS
716
  },
717
  eInterfacePrototype,
718
  false,
719
  prototypes::id::XSLTProcessor,
720
  PrototypeTraits<prototypes::id::XSLTProcessor>::Depth,
721
  sNativePropertyHooks,
722
  "[object XSLTProcessorPrototype]",
723
  JS::GetRealmObjectPrototype
724
};
725
726
static const js::ClassOps sClassOps = {
727
  _addProperty, /* addProperty */
728
  nullptr,               /* delProperty */
729
  nullptr,               /* enumerate */
730
  nullptr, /* newEnumerate */
731
  nullptr, /* resolve */
732
  nullptr, /* mayResolve */
733
  _finalize, /* finalize */
734
  nullptr, /* call */
735
  nullptr,               /* hasInstance */
736
  nullptr,               /* construct */
737
  nullptr, /* trace */
738
};
739
740
static const js::ClassExtension sClassExtension = {
741
  nullptr, /* weakmapKeyDelegateOp */
742
  _objectMoved /* objectMovedOp */
743
};
744
745
static const DOMJSClass sClass = {
746
  { "XSLTProcessor",
747
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
748
    &sClassOps,
749
    JS_NULL_CLASS_SPEC,
750
    &sClassExtension,
751
    JS_NULL_OBJECT_OPS
752
  },
753
  { prototypes::id::XSLTProcessor, 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 },
754
  IsBaseOf<nsISupports, txMozillaXSLTProcessor >::value,
755
  sNativePropertyHooks,
756
  FindAssociatedGlobalForNative<txMozillaXSLTProcessor>::Get,
757
  GetProtoObjectHandle,
758
  GetCCParticipant<txMozillaXSLTProcessor>::Get()
759
};
760
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
761
              "Must have the right minimal number of reserved slots.");
762
static_assert(1 >= 1,
763
              "Must have enough reserved slots.");
764
765
const JSClass*
766
GetJSClass()
767
0
{
768
0
  return sClass.ToJSClass();
769
0
}
770
771
bool
772
Wrap(JSContext* aCx, txMozillaXSLTProcessor* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
773
0
{
774
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, txMozillaXSLTProcessor>::value,
775
0
                "Shouldn't have wrappercached things that are not refcounted.");
776
0
  MOZ_ASSERT(static_cast<txMozillaXSLTProcessor*>(aObject) ==
777
0
             reinterpret_cast<txMozillaXSLTProcessor*>(aObject),
778
0
             "Multiple inheritance for txMozillaXSLTProcessor is broken.");
779
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
780
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
781
0
  MOZ_ASSERT(!aCache->GetWrapper(),
782
0
             "You should probably not be using Wrap() directly; use "
783
0
             "GetOrCreateDOMReflector instead");
784
0
785
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
786
0
             "nsISupports must be on our primary inheritance chain");
787
0
788
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
789
0
  if (!global) {
790
0
    return false;
791
0
  }
792
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
793
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
794
0
795
0
  // That might have ended up wrapping us already, due to the wonders
796
0
  // of XBL.  Check for that, and bail out as needed.
797
0
  aReflector.set(aCache->GetWrapper());
798
0
  if (aReflector) {
799
#ifdef DEBUG
800
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
801
#endif // DEBUG
802
    return true;
803
0
  }
804
0
805
0
  JSAutoRealm ar(aCx, global);
806
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
807
0
  if (!canonicalProto) {
808
0
    return false;
809
0
  }
810
0
  JS::Rooted<JSObject*> proto(aCx);
811
0
  if (aGivenProto) {
812
0
    proto = aGivenProto;
813
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
814
0
    // coming in, we changed compartments to that of "parent" so may need
815
0
    // to wrap the proto here.
816
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
817
0
      if (!JS_WrapObject(aCx, &proto)) {
818
0
        return false;
819
0
      }
820
0
    }
821
0
  } else {
822
0
    proto = canonicalProto;
823
0
  }
824
0
825
0
  BindingJSObjectCreator<txMozillaXSLTProcessor> creator(aCx);
826
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
827
0
  if (!aReflector) {
828
0
    return false;
829
0
  }
830
0
831
0
  aCache->SetWrapper(aReflector);
832
0
  creator.InitializationSucceeded();
833
0
834
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
835
0
             aCache->GetWrapperPreserveColor() == aReflector);
836
0
  // If proto != canonicalProto, we have to preserve our wrapper;
837
0
  // otherwise we won't be able to properly recreate it later, since
838
0
  // we won't know what proto to use.  Note that we don't check
839
0
  // aGivenProto here, since it's entirely possible (and even
840
0
  // somewhat common) to have a non-null aGivenProto which is the
841
0
  // same as canonicalProto.
842
0
  if (proto != canonicalProto) {
843
0
    PreserveWrapper(aObject);
844
0
  }
845
0
846
0
  return true;
847
0
}
848
849
const NativePropertyHooks sNativePropertyHooks[] = { {
850
  nullptr,
851
  nullptr,
852
  nullptr,
853
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
854
  prototypes::id::XSLTProcessor,
855
  constructors::id::XSLTProcessor,
856
  nullptr,
857
  &DefaultXrayExpandoObjectClass
858
} };
859
860
void
861
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
862
0
{
863
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
864
0
  if (!parentProto) {
865
0
    return;
866
0
  }
867
0
868
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
869
0
  if (!constructorProto) {
870
0
    return;
871
0
  }
872
0
873
0
  static bool sIdsInited = false;
874
0
  if (!sIdsInited && NS_IsMainThread()) {
875
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
876
0
      return;
877
0
    }
878
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
879
0
      return;
880
0
    }
881
0
    sIdsInited = true;
882
0
  }
883
0
884
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::XSLTProcessor);
885
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::XSLTProcessor);
886
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
887
0
                              &sPrototypeClass.mBase, protoCache,
888
0
                              nullptr,
889
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
890
0
                              interfaceCache,
891
0
                              sNativeProperties.Upcast(),
892
0
                              sChromeOnlyNativeProperties.Upcast(),
893
0
                              "XSLTProcessor", aDefineOnGlobal,
894
0
                              nullptr,
895
0
                              false);
896
0
}
897
898
JSObject*
899
GetConstructorObject(JSContext* aCx)
900
0
{
901
0
  return GetConstructorObjectHandle(aCx);
902
0
}
903
904
} // namespace XSLTProcessor_Binding
905
906
907
908
} // namespace dom
909
} // namespace mozilla