Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/GeometryUtilsBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM GeometryUtils.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "GeometryUtilsBinding.h"
5
#include "jsapi.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/Element.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/ScriptSettings.h"
11
#include "mozilla/dom/SimpleGlobalObject.h"
12
#include "mozilla/dom/UnionConversions.h"
13
#include "nsTextNode.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
namespace binding_detail {}; // Just to make sure it's known as a namespace
19
using namespace mozilla::dom::binding_detail;
20
21
22
namespace CSSBoxTypeValues {
23
extern const EnumEntry strings[5] = {
24
  {"margin", 6},
25
  {"border", 6},
26
  {"padding", 7},
27
  {"content", 7},
28
  { nullptr, 0 }
29
};
30
} // namespace CSSBoxTypeValues
31
32
bool
33
ToJSValue(JSContext* aCx, CSSBoxType aArgument, JS::MutableHandle<JS::Value> aValue)
34
0
{
35
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(CSSBoxTypeValues::strings));
36
0
  JSString* resultStr =
37
0
    JS_NewStringCopyN(aCx, CSSBoxTypeValues::strings[uint32_t(aArgument)].value,
38
0
                      CSSBoxTypeValues::strings[uint32_t(aArgument)].length);
39
0
  if (!resultStr) {
40
0
    return false;
41
0
  }
42
0
  aValue.setString(resultStr);
43
0
  return true;
44
0
}
45
46
47
void
48
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningTextOrElementOrDocument& aUnion, const char* aName, uint32_t aFlags)
49
0
{
50
0
  if (aUnion.IsText()) {
51
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsText(), "mText", aFlags);
52
0
  } else if (aUnion.IsElement()) {
53
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsElement(), "mElement", aFlags);
54
0
  } else if (aUnion.IsDocument()) {
55
0
    ImplCycleCollectionTraverse(aCallback, aUnion.GetAsDocument(), "mDocument", aFlags);
56
0
  }
57
0
}
58
59
60
void
61
ImplCycleCollectionUnlink(OwningTextOrElementOrDocument& aUnion)
62
0
{
63
0
  aUnion.Uninit();
64
0
}
65
66
67
68
ConvertCoordinateOptions::ConvertCoordinateOptions()
69
0
{
70
0
  // Safe to pass a null context if we pass a null value
71
0
  Init(nullptr, JS::NullHandleValue);
72
0
}
73
74
75
76
bool
77
ConvertCoordinateOptions::InitIds(JSContext* cx, ConvertCoordinateOptionsAtoms* atomsCache)
78
0
{
79
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
80
0
81
0
  // Initialize these in reverse order so that any failure leaves the first one
82
0
  // uninitialized.
83
0
  if (!atomsCache->toBox_id.init(cx, "toBox") ||
84
0
      !atomsCache->fromBox_id.init(cx, "fromBox")) {
85
0
    return false;
86
0
  }
87
0
  return true;
88
0
}
89
90
bool
91
ConvertCoordinateOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
92
0
{
93
0
  // Passing a null JSContext is OK only if we're initing from null,
94
0
  // Since in that case we will not have to do any property gets
95
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
96
0
  // checkers by static analysis tools
97
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
98
0
  ConvertCoordinateOptionsAtoms* atomsCache = nullptr;
99
0
  if (cx) {
100
0
    atomsCache = GetAtomCache<ConvertCoordinateOptionsAtoms>(cx);
101
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
102
0
      return false;
103
0
    }
104
0
  }
105
0
106
0
  if (!IsConvertibleToDictionary(val)) {
107
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
108
0
  }
109
0
110
0
  bool isNull = val.isNullOrUndefined();
111
0
  // We only need these if !isNull, in which case we have |cx|.
112
0
  Maybe<JS::Rooted<JSObject *> > object;
113
0
  Maybe<JS::Rooted<JS::Value> > temp;
114
0
  if (!isNull) {
115
0
    MOZ_ASSERT(cx);
116
0
    object.emplace(cx, &val.toObject());
117
0
    temp.emplace(cx);
118
0
  }
119
0
  if (!isNull) {
120
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->fromBox_id, temp.ptr())) {
121
0
      return false;
122
0
    }
123
0
  }
124
0
  if (!isNull && !temp->isUndefined()) {
125
0
    {
126
0
      int index;
127
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), CSSBoxTypeValues::strings, "CSSBoxType", "'fromBox' member of ConvertCoordinateOptions", &index)) {
128
0
        return false;
129
0
      }
130
0
      MOZ_ASSERT(index >= 0);
131
0
      mFromBox = static_cast<CSSBoxType>(index);
132
0
    }
133
0
  } else {
134
0
    mFromBox = CSSBoxType::Border;
135
0
  }
136
0
  mIsAnyMemberPresent = true;
137
0
138
0
  if (!isNull) {
139
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->toBox_id, temp.ptr())) {
140
0
      return false;
141
0
    }
142
0
  }
143
0
  if (!isNull && !temp->isUndefined()) {
144
0
    {
145
0
      int index;
146
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), CSSBoxTypeValues::strings, "CSSBoxType", "'toBox' member of ConvertCoordinateOptions", &index)) {
147
0
        return false;
148
0
      }
149
0
      MOZ_ASSERT(index >= 0);
150
0
      mToBox = static_cast<CSSBoxType>(index);
151
0
    }
152
0
  } else {
153
0
    mToBox = CSSBoxType::Border;
154
0
  }
155
0
  mIsAnyMemberPresent = true;
156
0
  return true;
157
0
}
158
159
bool
160
ConvertCoordinateOptions::Init(const nsAString& aJSON)
161
0
{
162
0
  AutoJSAPI jsapi;
163
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
164
0
  if (!cleanGlobal) {
165
0
    return false;
166
0
  }
167
0
  if (!jsapi.Init(cleanGlobal)) {
168
0
    return false;
169
0
  }
170
0
  JSContext* cx = jsapi.cx();
171
0
  JS::Rooted<JS::Value> json(cx);
172
0
  bool ok = ParseJSON(cx, aJSON, &json);
173
0
  NS_ENSURE_TRUE(ok, false);
174
0
  return Init(cx, json);
175
0
}
176
177
bool
178
ConvertCoordinateOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
179
0
{
180
0
  ConvertCoordinateOptionsAtoms* atomsCache = GetAtomCache<ConvertCoordinateOptionsAtoms>(cx);
181
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
182
0
    return false;
183
0
  }
184
0
185
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
186
0
  if (!obj) {
187
0
    return false;
188
0
  }
189
0
  rval.set(JS::ObjectValue(*obj));
190
0
191
0
  do {
192
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
193
0
    JS::Rooted<JS::Value> temp(cx);
194
0
    CSSBoxType const & currentValue = mFromBox;
195
0
    if (!ToJSValue(cx, currentValue, &temp)) {
196
0
      return false;
197
0
    }
198
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->fromBox_id, temp, JSPROP_ENUMERATE)) {
199
0
      return false;
200
0
    }
201
0
    break;
202
0
  } while(false);
203
0
204
0
  do {
205
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
206
0
    JS::Rooted<JS::Value> temp(cx);
207
0
    CSSBoxType const & currentValue = mToBox;
208
0
    if (!ToJSValue(cx, currentValue, &temp)) {
209
0
      return false;
210
0
    }
211
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->toBox_id, temp, JSPROP_ENUMERATE)) {
212
0
      return false;
213
0
    }
214
0
    break;
215
0
  } while(false);
216
0
217
0
  return true;
218
0
}
219
220
bool
221
ConvertCoordinateOptions::ToJSON(nsAString& aJSON) const
222
0
{
223
0
  AutoJSAPI jsapi;
224
0
  jsapi.Init();
225
0
  JSContext *cx = jsapi.cx();
226
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
227
0
  // because we'll only be creating objects, in ways that have no
228
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
229
0
  // which likewise guarantees no side-effects for the sorts of
230
0
  // things we will pass it.
231
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
232
0
  JS::Rooted<JS::Value> val(cx);
233
0
  if (!ToObjectInternal(cx, &val)) {
234
0
    return false;
235
0
  }
236
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
237
0
  return StringifyToJSON(cx, obj, aJSON);
238
0
}
239
240
void
241
ConvertCoordinateOptions::TraceDictionary(JSTracer* trc)
242
0
{
243
0
}
244
245
ConvertCoordinateOptions&
246
ConvertCoordinateOptions::operator=(const ConvertCoordinateOptions& aOther)
247
0
{
248
0
  DictionaryBase::operator=(aOther);
249
0
  mFromBox = aOther.mFromBox;
250
0
  mToBox = aOther.mToBox;
251
0
  return *this;
252
0
}
253
254
namespace binding_detail {
255
} // namespace binding_detail
256
257
258
bool
259
TextOrElementOrDocument::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
260
0
{
261
0
  switch (mType) {
262
0
    case eUninitialized: {
263
0
      return false;
264
0
      break;
265
0
    }
266
0
    case eText: {
267
0
      if (!GetOrCreateDOMReflector(cx, mValue.mText.Value(), rval)) {
268
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
269
0
        return false;
270
0
      }
271
0
      return true;
272
0
      break;
273
0
    }
274
0
    case eElement: {
275
0
      if (!GetOrCreateDOMReflector(cx, mValue.mElement.Value(), rval)) {
276
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
277
0
        return false;
278
0
      }
279
0
      return true;
280
0
      break;
281
0
    }
282
0
    case eDocument: {
283
0
      if (!GetOrCreateDOMReflector(cx, mValue.mDocument.Value(), rval)) {
284
0
        MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing");
285
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
286
0
        return false;
287
0
      }
288
0
      return true;
289
0
      break;
290
0
    }
291
0
    default: {
292
0
      return false;
293
0
      break;
294
0
    }
295
0
  }
296
0
297
0
  return false;
298
0
}
299
300
301
OwningNonNull<mozilla::dom::Text>&
302
OwningTextOrElementOrDocument::RawSetAsText()
303
0
{
304
0
  if (mType == eText) {
305
0
    return mValue.mText.Value();
306
0
  }
307
0
  MOZ_ASSERT(mType == eUninitialized);
308
0
  mType = eText;
309
0
  return mValue.mText.SetValue();
310
0
}
311
312
OwningNonNull<mozilla::dom::Text>&
313
OwningTextOrElementOrDocument::SetAsText()
314
0
{
315
0
  if (mType == eText) {
316
0
    return mValue.mText.Value();
317
0
  }
318
0
  Uninit();
319
0
  mType = eText;
320
0
  return mValue.mText.SetValue();
321
0
}
322
323
bool
324
OwningTextOrElementOrDocument::TrySetToText(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
325
0
{
326
0
  tryNext = false;
327
0
  { // scope for memberSlot
328
0
    OwningNonNull<mozilla::dom::Text>& memberSlot = RawSetAsText();
329
0
    static_assert(IsRefcounted<mozilla::dom::Text>::value, "We can only store refcounted classes.");{
330
0
      nsresult rv = UnwrapObject<prototypes::id::Text, mozilla::dom::Text>(value, memberSlot);
331
0
      if (NS_FAILED(rv)) {
332
0
        DestroyText();
333
0
        tryNext = true;
334
0
        return true;
335
0
      }
336
0
    }
337
0
  }
338
0
  return true;
339
0
}
340
341
void
342
OwningTextOrElementOrDocument::DestroyText()
343
0
{
344
0
  MOZ_ASSERT(IsText(), "Wrong type!");
345
0
  mValue.mText.Destroy();
346
0
  mType = eUninitialized;
347
0
}
348
349
350
351
352
OwningNonNull<mozilla::dom::Element>&
353
OwningTextOrElementOrDocument::RawSetAsElement()
354
0
{
355
0
  if (mType == eElement) {
356
0
    return mValue.mElement.Value();
357
0
  }
358
0
  MOZ_ASSERT(mType == eUninitialized);
359
0
  mType = eElement;
360
0
  return mValue.mElement.SetValue();
361
0
}
362
363
OwningNonNull<mozilla::dom::Element>&
364
OwningTextOrElementOrDocument::SetAsElement()
365
0
{
366
0
  if (mType == eElement) {
367
0
    return mValue.mElement.Value();
368
0
  }
369
0
  Uninit();
370
0
  mType = eElement;
371
0
  return mValue.mElement.SetValue();
372
0
}
373
374
bool
375
OwningTextOrElementOrDocument::TrySetToElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
376
0
{
377
0
  tryNext = false;
378
0
  { // scope for memberSlot
379
0
    OwningNonNull<mozilla::dom::Element>& memberSlot = RawSetAsElement();
380
0
    static_assert(IsRefcounted<mozilla::dom::Element>::value, "We can only store refcounted classes.");{
381
0
      nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(value, memberSlot);
382
0
      if (NS_FAILED(rv)) {
383
0
        DestroyElement();
384
0
        tryNext = true;
385
0
        return true;
386
0
      }
387
0
    }
388
0
  }
389
0
  return true;
390
0
}
391
392
void
393
OwningTextOrElementOrDocument::DestroyElement()
394
0
{
395
0
  MOZ_ASSERT(IsElement(), "Wrong type!");
396
0
  mValue.mElement.Destroy();
397
0
  mType = eUninitialized;
398
0
}
399
400
401
402
403
OwningNonNull<nsIDocument>&
404
OwningTextOrElementOrDocument::RawSetAsDocument()
405
0
{
406
0
  if (mType == eDocument) {
407
0
    return mValue.mDocument.Value();
408
0
  }
409
0
  MOZ_ASSERT(mType == eUninitialized);
410
0
  mType = eDocument;
411
0
  return mValue.mDocument.SetValue();
412
0
}
413
414
OwningNonNull<nsIDocument>&
415
OwningTextOrElementOrDocument::SetAsDocument()
416
0
{
417
0
  if (mType == eDocument) {
418
0
    return mValue.mDocument.Value();
419
0
  }
420
0
  Uninit();
421
0
  mType = eDocument;
422
0
  return mValue.mDocument.SetValue();
423
0
}
424
425
bool
426
OwningTextOrElementOrDocument::TrySetToDocument(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
427
0
{
428
0
  tryNext = false;
429
0
  { // scope for memberSlot
430
0
    OwningNonNull<nsIDocument>& memberSlot = RawSetAsDocument();
431
0
    static_assert(IsRefcounted<nsIDocument>::value, "We can only store refcounted classes.");{
432
0
      nsresult rv = UnwrapObject<prototypes::id::Document, nsIDocument>(value, memberSlot);
433
0
      if (NS_FAILED(rv)) {
434
0
        DestroyDocument();
435
0
        tryNext = true;
436
0
        return true;
437
0
      }
438
0
    }
439
0
  }
440
0
  return true;
441
0
}
442
443
void
444
OwningTextOrElementOrDocument::DestroyDocument()
445
0
{
446
0
  MOZ_ASSERT(IsDocument(), "Wrong type!");
447
0
  mValue.mDocument.Destroy();
448
0
  mType = eUninitialized;
449
0
}
450
451
452
453
454
void
455
OwningTextOrElementOrDocument::Uninit()
456
{
457
  switch (mType) {
458
    case eUninitialized: {
459
      break;
460
    }
461
    case eText: {
462
      DestroyText();
463
      break;
464
    }
465
    case eElement: {
466
      DestroyElement();
467
      break;
468
    }
469
    case eDocument: {
470
      DestroyDocument();
471
      break;
472
    }
473
  }
474
}
475
476
bool
477
OwningTextOrElementOrDocument::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
478
0
{
479
0
  switch (mType) {
480
0
    case eUninitialized: {
481
0
      return false;
482
0
      break;
483
0
    }
484
0
    case eText: {
485
0
      if (!GetOrCreateDOMReflector(cx, mValue.mText.Value(), rval)) {
486
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
487
0
        return false;
488
0
      }
489
0
      return true;
490
0
      break;
491
0
    }
492
0
    case eElement: {
493
0
      if (!GetOrCreateDOMReflector(cx, mValue.mElement.Value(), rval)) {
494
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
495
0
        return false;
496
0
      }
497
0
      return true;
498
0
      break;
499
0
    }
500
0
    case eDocument: {
501
0
      if (!GetOrCreateDOMReflector(cx, mValue.mDocument.Value(), rval)) {
502
0
        MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing");
503
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
504
0
        return false;
505
0
      }
506
0
      return true;
507
0
      break;
508
0
    }
509
0
    default: {
510
0
      return false;
511
0
      break;
512
0
    }
513
0
  }
514
0
515
0
  return false;
516
0
}
517
518
void
519
OwningTextOrElementOrDocument::TraceUnion(JSTracer* trc)
520
0
{
521
0
}
522
523
OwningTextOrElementOrDocument&
524
OwningTextOrElementOrDocument::operator=(const OwningTextOrElementOrDocument& aOther)
525
0
{
526
0
  switch (aOther.mType) {
527
0
    case eUninitialized: {
528
0
      MOZ_ASSERT(mType == eUninitialized,
529
0
                 "We need to destroy ourselves?");
530
0
      break;
531
0
    }
532
0
    case eText: {
533
0
      SetAsText() = aOther.GetAsText();
534
0
      break;
535
0
    }
536
0
    case eElement: {
537
0
      SetAsElement() = aOther.GetAsElement();
538
0
      break;
539
0
    }
540
0
    case eDocument: {
541
0
      SetAsDocument() = aOther.GetAsDocument();
542
0
      break;
543
0
    }
544
0
  }
545
0
  return *this;
546
0
}
547
548
549
550
BoxQuadOptions::BoxQuadOptions()
551
0
{
552
0
  // Safe to pass a null context if we pass a null value
553
0
  Init(nullptr, JS::NullHandleValue);
554
0
}
555
556
557
558
bool
559
BoxQuadOptions::InitIds(JSContext* cx, BoxQuadOptionsAtoms* atomsCache)
560
0
{
561
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
562
0
563
0
  // Initialize these in reverse order so that any failure leaves the first one
564
0
  // uninitialized.
565
0
  if (!atomsCache->relativeTo_id.init(cx, "relativeTo") ||
566
0
      !atomsCache->box_id.init(cx, "box")) {
567
0
    return false;
568
0
  }
569
0
  return true;
570
0
}
571
572
bool
573
BoxQuadOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
574
0
{
575
0
  // Passing a null JSContext is OK only if we're initing from null,
576
0
  // Since in that case we will not have to do any property gets
577
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
578
0
  // checkers by static analysis tools
579
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
580
0
  BoxQuadOptionsAtoms* atomsCache = nullptr;
581
0
  if (cx) {
582
0
    atomsCache = GetAtomCache<BoxQuadOptionsAtoms>(cx);
583
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
584
0
      return false;
585
0
    }
586
0
  }
587
0
588
0
  if (!IsConvertibleToDictionary(val)) {
589
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
590
0
  }
591
0
592
0
  bool isNull = val.isNullOrUndefined();
593
0
  // We only need these if !isNull, in which case we have |cx|.
594
0
  Maybe<JS::Rooted<JSObject *> > object;
595
0
  Maybe<JS::Rooted<JS::Value> > temp;
596
0
  if (!isNull) {
597
0
    MOZ_ASSERT(cx);
598
0
    object.emplace(cx, &val.toObject());
599
0
    temp.emplace(cx);
600
0
  }
601
0
  if (!isNull) {
602
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->box_id, temp.ptr())) {
603
0
      return false;
604
0
    }
605
0
  }
606
0
  if (!isNull && !temp->isUndefined()) {
607
0
    {
608
0
      int index;
609
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), CSSBoxTypeValues::strings, "CSSBoxType", "'box' member of BoxQuadOptions", &index)) {
610
0
        return false;
611
0
      }
612
0
      MOZ_ASSERT(index >= 0);
613
0
      mBox = static_cast<CSSBoxType>(index);
614
0
    }
615
0
  } else {
616
0
    mBox = CSSBoxType::Border;
617
0
  }
618
0
  mIsAnyMemberPresent = true;
619
0
620
0
  if (!isNull) {
621
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->relativeTo_id, temp.ptr())) {
622
0
      return false;
623
0
    }
624
0
  }
625
0
  if (!isNull && !temp->isUndefined()) {
626
0
    mRelativeTo.Construct();
627
0
    {
628
0
      bool done = false, failed = false, tryNext;
629
0
      if (temp.ref().isObject()) {
630
0
        done = (failed = !(mRelativeTo.Value()).TrySetToText(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext ||
631
0
               (failed = !(mRelativeTo.Value()).TrySetToElement(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext ||
632
0
               (failed = !(mRelativeTo.Value()).TrySetToDocument(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
633
0
634
0
      }
635
0
      if (failed) {
636
0
        return false;
637
0
      }
638
0
      if (!done) {
639
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'relativeTo' member of BoxQuadOptions", "Text, Element, Document");
640
0
        return false;
641
0
      }
642
0
    }
643
0
    mIsAnyMemberPresent = true;
644
0
  }
645
0
  return true;
646
0
}
647
648
bool
649
BoxQuadOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
650
0
{
651
0
  BoxQuadOptionsAtoms* atomsCache = GetAtomCache<BoxQuadOptionsAtoms>(cx);
652
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
653
0
    return false;
654
0
  }
655
0
656
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
657
0
  if (!obj) {
658
0
    return false;
659
0
  }
660
0
  rval.set(JS::ObjectValue(*obj));
661
0
662
0
  do {
663
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
664
0
    JS::Rooted<JS::Value> temp(cx);
665
0
    CSSBoxType const & currentValue = mBox;
666
0
    if (!ToJSValue(cx, currentValue, &temp)) {
667
0
      return false;
668
0
    }
669
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->box_id, temp, JSPROP_ENUMERATE)) {
670
0
      return false;
671
0
    }
672
0
    break;
673
0
  } while(false);
674
0
675
0
  if (mRelativeTo.WasPassed()) {
676
0
    do {
677
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
678
0
      JS::Rooted<JS::Value> temp(cx);
679
0
      OwningTextOrElementOrDocument const & currentValue = mRelativeTo.InternalValue();
680
0
      if (!currentValue.ToJSVal(cx, obj, &temp)) {
681
0
        return false;
682
0
      }
683
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->relativeTo_id, temp, JSPROP_ENUMERATE)) {
684
0
        return false;
685
0
      }
686
0
      break;
687
0
    } while(false);
688
0
  }
689
0
690
0
  return true;
691
0
}
692
693
void
694
BoxQuadOptions::TraceDictionary(JSTracer* trc)
695
0
{
696
0
}
697
698
699
700
BoxQuadOptions&
701
BoxQuadOptions::operator=(const BoxQuadOptions& aOther)
702
0
{
703
0
  DictionaryBase::operator=(aOther);
704
0
  mBox = aOther.mBox;
705
0
  mRelativeTo.Reset();
706
0
  if (aOther.mRelativeTo.WasPassed()) {
707
0
    mRelativeTo.Construct(aOther.mRelativeTo.Value());
708
0
  }
709
0
  return *this;
710
0
}
711
712
namespace binding_detail {
713
} // namespace binding_detail
714
715
716
} // namespace dom
717
} // namespace mozilla