Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM ProfileTimelineMarker.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "ProfileTimelineMarkerBinding.h"
5 : #include "jsapi.h"
6 : #include "mozilla/FloatingPoint.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/NonRefcountedDOMObject.h"
10 : #include "mozilla/dom/PrimitiveConversions.h"
11 : #include "mozilla/dom/ScriptSettings.h"
12 : #include "mozilla/dom/SimpleGlobalObject.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : namespace ProfileTimelineMessagePortOperationTypeValues {
18 : extern const EnumEntry strings[3] = {
19 : {"serializeData", 13},
20 : {"deserializeData", 15},
21 : { nullptr, 0 }
22 : };
23 : } // namespace ProfileTimelineMessagePortOperationTypeValues
24 :
25 : bool
26 0 : ToJSValue(JSContext* aCx, ProfileTimelineMessagePortOperationType aArgument, JS::MutableHandle<JS::Value> aValue)
27 : {
28 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ProfileTimelineMessagePortOperationTypeValues::strings));
29 : JSString* resultStr =
30 0 : JS_NewStringCopyN(aCx, ProfileTimelineMessagePortOperationTypeValues::strings[uint32_t(aArgument)].value,
31 0 : ProfileTimelineMessagePortOperationTypeValues::strings[uint32_t(aArgument)].length);
32 0 : if (!resultStr) {
33 0 : return false;
34 : }
35 0 : aValue.setString(resultStr);
36 0 : return true;
37 : }
38 :
39 :
40 : namespace ProfileTimelineWorkerOperationTypeValues {
41 : extern const EnumEntry strings[5] = {
42 : {"serializeDataOffMainThread", 26},
43 : {"serializeDataOnMainThread", 25},
44 : {"deserializeDataOffMainThread", 28},
45 : {"deserializeDataOnMainThread", 27},
46 : { nullptr, 0 }
47 : };
48 : } // namespace ProfileTimelineWorkerOperationTypeValues
49 :
50 : bool
51 0 : ToJSValue(JSContext* aCx, ProfileTimelineWorkerOperationType aArgument, JS::MutableHandle<JS::Value> aValue)
52 : {
53 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ProfileTimelineWorkerOperationTypeValues::strings));
54 : JSString* resultStr =
55 0 : JS_NewStringCopyN(aCx, ProfileTimelineWorkerOperationTypeValues::strings[uint32_t(aArgument)].value,
56 0 : ProfileTimelineWorkerOperationTypeValues::strings[uint32_t(aArgument)].length);
57 0 : if (!resultStr) {
58 0 : return false;
59 : }
60 0 : aValue.setString(resultStr);
61 0 : return true;
62 : }
63 :
64 :
65 :
66 0 : ProfileTimelineLayerRect::ProfileTimelineLayerRect()
67 : {
68 : // Safe to pass a null context if we pass a null value
69 0 : Init(nullptr, JS::NullHandleValue);
70 0 : }
71 :
72 :
73 :
74 : bool
75 0 : ProfileTimelineLayerRect::InitIds(JSContext* cx, ProfileTimelineLayerRectAtoms* atomsCache)
76 : {
77 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
78 :
79 : // Initialize these in reverse order so that any failure leaves the first one
80 : // uninitialized.
81 0 : if (!atomsCache->y_id.init(cx, "y") ||
82 0 : !atomsCache->x_id.init(cx, "x") ||
83 0 : !atomsCache->width_id.init(cx, "width") ||
84 0 : !atomsCache->height_id.init(cx, "height")) {
85 0 : return false;
86 : }
87 0 : return true;
88 : }
89 :
90 : bool
91 0 : ProfileTimelineLayerRect::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
92 : {
93 : // Passing a null JSContext is OK only if we're initing from null,
94 : // Since in that case we will not have to do any property gets
95 : // Also evaluate isNullOrUndefined in order to avoid false-positive
96 : // checkers by static analysis tools
97 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
98 0 : ProfileTimelineLayerRectAtoms* atomsCache = nullptr;
99 0 : if (cx) {
100 0 : atomsCache = GetAtomCache<ProfileTimelineLayerRectAtoms>(cx);
101 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
102 0 : return false;
103 : }
104 : }
105 :
106 0 : if (!IsConvertibleToDictionary(val)) {
107 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
108 : }
109 :
110 0 : bool isNull = val.isNullOrUndefined();
111 : // 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 : }
119 0 : if (!isNull) {
120 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->height_id, temp.ptr())) {
121 0 : return false;
122 : }
123 : }
124 0 : if (!isNull && !temp->isUndefined()) {
125 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mHeight)) {
126 0 : return false;
127 : }
128 : } else {
129 0 : mHeight = 0;
130 : }
131 0 : mIsAnyMemberPresent = true;
132 :
133 0 : if (!isNull) {
134 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->width_id, temp.ptr())) {
135 0 : return false;
136 : }
137 : }
138 0 : if (!isNull && !temp->isUndefined()) {
139 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mWidth)) {
140 0 : return false;
141 : }
142 : } else {
143 0 : mWidth = 0;
144 : }
145 0 : mIsAnyMemberPresent = true;
146 :
147 0 : if (!isNull) {
148 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->x_id, temp.ptr())) {
149 0 : return false;
150 : }
151 : }
152 0 : if (!isNull && !temp->isUndefined()) {
153 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mX)) {
154 0 : return false;
155 : }
156 : } else {
157 0 : mX = 0;
158 : }
159 0 : mIsAnyMemberPresent = true;
160 :
161 0 : if (!isNull) {
162 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->y_id, temp.ptr())) {
163 0 : return false;
164 : }
165 : }
166 0 : if (!isNull && !temp->isUndefined()) {
167 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mY)) {
168 0 : return false;
169 : }
170 : } else {
171 0 : mY = 0;
172 : }
173 0 : mIsAnyMemberPresent = true;
174 0 : return true;
175 : }
176 :
177 : bool
178 0 : ProfileTimelineLayerRect::Init(const nsAString& aJSON)
179 : {
180 0 : AutoJSAPI jsapi;
181 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
182 0 : if (!cleanGlobal) {
183 0 : return false;
184 : }
185 0 : if (!jsapi.Init(cleanGlobal)) {
186 0 : return false;
187 : }
188 0 : JSContext* cx = jsapi.cx();
189 0 : JS::Rooted<JS::Value> json(cx);
190 0 : bool ok = ParseJSON(cx, aJSON, &json);
191 0 : NS_ENSURE_TRUE(ok, false);
192 0 : return Init(cx, json);
193 : }
194 :
195 : bool
196 0 : ProfileTimelineLayerRect::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
197 : {
198 0 : ProfileTimelineLayerRectAtoms* atomsCache = GetAtomCache<ProfileTimelineLayerRectAtoms>(cx);
199 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
200 0 : return false;
201 : }
202 :
203 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
204 0 : if (!obj) {
205 0 : return false;
206 : }
207 0 : rval.set(JS::ObjectValue(*obj));
208 :
209 : do {
210 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
211 0 : JS::Rooted<JS::Value> temp(cx);
212 0 : int32_t const & currentValue = mHeight;
213 0 : temp.setInt32(int32_t(currentValue));
214 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->height_id, temp, JSPROP_ENUMERATE)) {
215 0 : return false;
216 : }
217 0 : break;
218 : } while(0);
219 :
220 : do {
221 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
222 0 : JS::Rooted<JS::Value> temp(cx);
223 0 : int32_t const & currentValue = mWidth;
224 0 : temp.setInt32(int32_t(currentValue));
225 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->width_id, temp, JSPROP_ENUMERATE)) {
226 0 : return false;
227 : }
228 0 : break;
229 : } while(0);
230 :
231 : do {
232 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
233 0 : JS::Rooted<JS::Value> temp(cx);
234 0 : int32_t const & currentValue = mX;
235 0 : temp.setInt32(int32_t(currentValue));
236 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->x_id, temp, JSPROP_ENUMERATE)) {
237 0 : return false;
238 : }
239 0 : break;
240 : } while(0);
241 :
242 : do {
243 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
244 0 : JS::Rooted<JS::Value> temp(cx);
245 0 : int32_t const & currentValue = mY;
246 0 : temp.setInt32(int32_t(currentValue));
247 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->y_id, temp, JSPROP_ENUMERATE)) {
248 0 : return false;
249 : }
250 0 : break;
251 : } while(0);
252 :
253 0 : return true;
254 : }
255 :
256 : bool
257 0 : ProfileTimelineLayerRect::ToJSON(nsAString& aJSON) const
258 : {
259 0 : AutoJSAPI jsapi;
260 0 : jsapi.Init();
261 0 : JSContext *cx = jsapi.cx();
262 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
263 : // because we'll only be creating objects, in ways that have no
264 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
265 : // which likewise guarantees no side-effects for the sorts of
266 : // things we will pass it.
267 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
268 0 : JS::Rooted<JS::Value> val(cx);
269 0 : if (!ToObjectInternal(cx, &val)) {
270 0 : return false;
271 : }
272 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
273 0 : return StringifyToJSON(cx, obj, aJSON);
274 : }
275 :
276 : void
277 0 : ProfileTimelineLayerRect::TraceDictionary(JSTracer* trc)
278 : {
279 0 : }
280 :
281 : ProfileTimelineLayerRect&
282 0 : ProfileTimelineLayerRect::operator=(const ProfileTimelineLayerRect& aOther)
283 : {
284 0 : mHeight = aOther.mHeight;
285 0 : mWidth = aOther.mWidth;
286 0 : mX = aOther.mX;
287 0 : mY = aOther.mY;
288 0 : return *this;
289 : }
290 :
291 : namespace binding_detail {
292 : } // namespace binding_detail
293 :
294 :
295 :
296 0 : ProfileTimelineStackFrame::ProfileTimelineStackFrame()
297 : : mAsyncParent(nullptr),
298 0 : mParent(nullptr)
299 : {
300 : // Safe to pass a null context if we pass a null value
301 0 : Init(nullptr, JS::NullHandleValue);
302 0 : }
303 :
304 :
305 : bool
306 0 : ProfileTimelineStackFrame::InitIds(JSContext* cx, ProfileTimelineStackFrameAtoms* atomsCache)
307 : {
308 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
309 :
310 : // Initialize these in reverse order so that any failure leaves the first one
311 : // uninitialized.
312 0 : if (!atomsCache->source_id.init(cx, "source") ||
313 0 : !atomsCache->parent_id.init(cx, "parent") ||
314 0 : !atomsCache->line_id.init(cx, "line") ||
315 0 : !atomsCache->functionDisplayName_id.init(cx, "functionDisplayName") ||
316 0 : !atomsCache->column_id.init(cx, "column") ||
317 0 : !atomsCache->asyncParent_id.init(cx, "asyncParent") ||
318 0 : !atomsCache->asyncCause_id.init(cx, "asyncCause")) {
319 0 : return false;
320 : }
321 0 : return true;
322 : }
323 :
324 : bool
325 0 : ProfileTimelineStackFrame::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
326 : {
327 : // Passing a null JSContext is OK only if we're initing from null,
328 : // Since in that case we will not have to do any property gets
329 : // Also evaluate isNullOrUndefined in order to avoid false-positive
330 : // checkers by static analysis tools
331 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
332 0 : ProfileTimelineStackFrameAtoms* atomsCache = nullptr;
333 0 : if (cx) {
334 0 : atomsCache = GetAtomCache<ProfileTimelineStackFrameAtoms>(cx);
335 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
336 0 : return false;
337 : }
338 : }
339 :
340 0 : if (!IsConvertibleToDictionary(val)) {
341 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
342 : }
343 :
344 0 : bool isNull = val.isNullOrUndefined();
345 : // We only need these if !isNull, in which case we have |cx|.
346 0 : Maybe<JS::Rooted<JSObject *> > object;
347 0 : Maybe<JS::Rooted<JS::Value> > temp;
348 0 : if (!isNull) {
349 0 : MOZ_ASSERT(cx);
350 0 : object.emplace(cx, &val.toObject());
351 0 : temp.emplace(cx);
352 : }
353 0 : if (!isNull) {
354 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->asyncCause_id, temp.ptr())) {
355 0 : return false;
356 : }
357 : }
358 0 : if (!isNull && !temp->isUndefined()) {
359 0 : mAsyncCause.Construct();
360 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mAsyncCause.Value()))) {
361 0 : return false;
362 : }
363 0 : mIsAnyMemberPresent = true;
364 : }
365 :
366 0 : if (!isNull) {
367 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->asyncParent_id, temp.ptr())) {
368 0 : return false;
369 : }
370 : }
371 0 : if (!isNull && !temp->isUndefined()) {
372 0 : if (temp.ref().isObject()) {
373 : #ifdef __clang__
374 : #pragma clang diagnostic push
375 : #pragma clang diagnostic ignored "-Wunreachable-code"
376 : #pragma clang diagnostic ignored "-Wunreachable-code-return"
377 : #endif // __clang__
378 0 : if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
379 0 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'asyncParent' member of ProfileTimelineStackFrame");
380 0 : return false;
381 : }
382 : #ifdef __clang__
383 : #pragma clang diagnostic pop
384 : #endif // __clang__
385 0 : mAsyncParent = &temp.ref().toObject();
386 0 : } else if (temp.ref().isNullOrUndefined()) {
387 0 : mAsyncParent = nullptr;
388 : } else {
389 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'asyncParent' member of ProfileTimelineStackFrame");
390 0 : return false;
391 : }
392 : } else {
393 0 : mAsyncParent = nullptr;
394 : }
395 0 : mIsAnyMemberPresent = true;
396 :
397 0 : if (!isNull) {
398 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->column_id, temp.ptr())) {
399 0 : return false;
400 : }
401 : }
402 0 : if (!isNull && !temp->isUndefined()) {
403 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &mColumn)) {
404 0 : return false;
405 : }
406 : } else {
407 0 : mColumn = 0;
408 : }
409 0 : mIsAnyMemberPresent = true;
410 :
411 0 : if (!isNull) {
412 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->functionDisplayName_id, temp.ptr())) {
413 0 : return false;
414 : }
415 : }
416 0 : if (!isNull && !temp->isUndefined()) {
417 0 : mFunctionDisplayName.Construct();
418 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mFunctionDisplayName.Value()))) {
419 0 : return false;
420 : }
421 0 : mIsAnyMemberPresent = true;
422 : }
423 :
424 0 : if (!isNull) {
425 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->line_id, temp.ptr())) {
426 0 : return false;
427 : }
428 : }
429 0 : if (!isNull && !temp->isUndefined()) {
430 0 : mLine.Construct();
431 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), &(mLine.Value()))) {
432 0 : return false;
433 : }
434 0 : mIsAnyMemberPresent = true;
435 : }
436 :
437 0 : if (!isNull) {
438 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->parent_id, temp.ptr())) {
439 0 : return false;
440 : }
441 : }
442 0 : if (!isNull && !temp->isUndefined()) {
443 0 : if (temp.ref().isObject()) {
444 : #ifdef __clang__
445 : #pragma clang diagnostic push
446 : #pragma clang diagnostic ignored "-Wunreachable-code"
447 : #pragma clang diagnostic ignored "-Wunreachable-code-return"
448 : #endif // __clang__
449 0 : if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
450 0 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'parent' member of ProfileTimelineStackFrame");
451 0 : return false;
452 : }
453 : #ifdef __clang__
454 : #pragma clang diagnostic pop
455 : #endif // __clang__
456 0 : mParent = &temp.ref().toObject();
457 0 : } else if (temp.ref().isNullOrUndefined()) {
458 0 : mParent = nullptr;
459 : } else {
460 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'parent' member of ProfileTimelineStackFrame");
461 0 : return false;
462 : }
463 : } else {
464 0 : mParent = nullptr;
465 : }
466 0 : mIsAnyMemberPresent = true;
467 :
468 0 : if (!isNull) {
469 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->source_id, temp.ptr())) {
470 0 : return false;
471 : }
472 : }
473 0 : if (!isNull && !temp->isUndefined()) {
474 0 : mSource.Construct();
475 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mSource.Value()))) {
476 0 : return false;
477 : }
478 0 : mIsAnyMemberPresent = true;
479 : }
480 0 : return true;
481 : }
482 :
483 : bool
484 0 : ProfileTimelineStackFrame::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
485 : {
486 0 : ProfileTimelineStackFrameAtoms* atomsCache = GetAtomCache<ProfileTimelineStackFrameAtoms>(cx);
487 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
488 0 : return false;
489 : }
490 :
491 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
492 0 : if (!obj) {
493 0 : return false;
494 : }
495 0 : rval.set(JS::ObjectValue(*obj));
496 :
497 0 : if (mAsyncCause.WasPassed()) {
498 : do {
499 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
500 0 : JS::Rooted<JS::Value> temp(cx);
501 0 : nsString const & currentValue = mAsyncCause.InternalValue();
502 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
503 0 : return false;
504 : }
505 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->asyncCause_id, temp, JSPROP_ENUMERATE)) {
506 0 : return false;
507 : }
508 0 : break;
509 : } while(0);
510 : }
511 :
512 : do {
513 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
514 0 : JS::Rooted<JS::Value> temp(cx);
515 0 : JSObject* const & currentValue = mAsyncParent;
516 0 : if (currentValue) {
517 0 : JS::ExposeObjectToActiveJS(currentValue);
518 : }
519 0 : temp.setObjectOrNull(currentValue);
520 0 : if (!MaybeWrapObjectOrNullValue(cx, &temp)) {
521 0 : return false;
522 : }
523 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->asyncParent_id, temp, JSPROP_ENUMERATE)) {
524 0 : return false;
525 : }
526 0 : break;
527 : } while(0);
528 :
529 : do {
530 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
531 0 : JS::Rooted<JS::Value> temp(cx);
532 0 : int32_t const & currentValue = mColumn;
533 0 : temp.setInt32(int32_t(currentValue));
534 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->column_id, temp, JSPROP_ENUMERATE)) {
535 0 : return false;
536 : }
537 0 : break;
538 : } while(0);
539 :
540 0 : if (mFunctionDisplayName.WasPassed()) {
541 : do {
542 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
543 0 : JS::Rooted<JS::Value> temp(cx);
544 0 : nsString const & currentValue = mFunctionDisplayName.InternalValue();
545 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
546 0 : return false;
547 : }
548 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->functionDisplayName_id, temp, JSPROP_ENUMERATE)) {
549 0 : return false;
550 : }
551 0 : break;
552 : } while(0);
553 : }
554 :
555 0 : if (mLine.WasPassed()) {
556 : do {
557 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
558 0 : JS::Rooted<JS::Value> temp(cx);
559 0 : int32_t const & currentValue = mLine.InternalValue();
560 0 : temp.setInt32(int32_t(currentValue));
561 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->line_id, temp, JSPROP_ENUMERATE)) {
562 0 : return false;
563 : }
564 0 : break;
565 : } while(0);
566 : }
567 :
568 : do {
569 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
570 0 : JS::Rooted<JS::Value> temp(cx);
571 0 : JSObject* const & currentValue = mParent;
572 0 : if (currentValue) {
573 0 : JS::ExposeObjectToActiveJS(currentValue);
574 : }
575 0 : temp.setObjectOrNull(currentValue);
576 0 : if (!MaybeWrapObjectOrNullValue(cx, &temp)) {
577 0 : return false;
578 : }
579 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->parent_id, temp, JSPROP_ENUMERATE)) {
580 0 : return false;
581 : }
582 0 : break;
583 : } while(0);
584 :
585 0 : if (mSource.WasPassed()) {
586 : do {
587 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
588 0 : JS::Rooted<JS::Value> temp(cx);
589 0 : nsString const & currentValue = mSource.InternalValue();
590 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
591 0 : return false;
592 : }
593 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->source_id, temp, JSPROP_ENUMERATE)) {
594 0 : return false;
595 : }
596 0 : break;
597 : } while(0);
598 : }
599 :
600 0 : return true;
601 : }
602 :
603 : void
604 0 : ProfileTimelineStackFrame::TraceDictionary(JSTracer* trc)
605 : {
606 0 : if (mAsyncParent) {
607 0 : JS::UnsafeTraceRoot(trc, &mAsyncParent, "ProfileTimelineStackFrame.mAsyncParent");
608 : }
609 :
610 0 : if (mParent) {
611 0 : JS::UnsafeTraceRoot(trc, &mParent, "ProfileTimelineStackFrame.mParent");
612 : }
613 0 : }
614 :
615 : namespace binding_detail {
616 : } // namespace binding_detail
617 :
618 :
619 :
620 0 : ProfileTimelineMarker::ProfileTimelineMarker()
621 : : mEndStack(nullptr),
622 0 : mStack(nullptr)
623 : {
624 : // Safe to pass a null context if we pass a null value
625 0 : Init(nullptr, JS::NullHandleValue);
626 0 : }
627 :
628 :
629 : bool
630 0 : ProfileTimelineMarker::InitIds(JSContext* cx, ProfileTimelineMarkerAtoms* atomsCache)
631 : {
632 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
633 :
634 : // Initialize these in reverse order so that any failure leaves the first one
635 : // uninitialized.
636 0 : if (!atomsCache->workerOperation_id.init(cx, "workerOperation") ||
637 0 : !atomsCache->unixTime_id.init(cx, "unixTime") ||
638 0 : !atomsCache->type_id.init(cx, "type") ||
639 0 : !atomsCache->start_id.init(cx, "start") ||
640 0 : !atomsCache->stack_id.init(cx, "stack") ||
641 0 : !atomsCache->rectangles_id.init(cx, "rectangles") ||
642 0 : !atomsCache->processType_id.init(cx, "processType") ||
643 0 : !atomsCache->name_id.init(cx, "name") ||
644 0 : !atomsCache->messagePortOperation_id.init(cx, "messagePortOperation") ||
645 0 : !atomsCache->isOffMainThread_id.init(cx, "isOffMainThread") ||
646 0 : !atomsCache->isAnimationOnly_id.init(cx, "isAnimationOnly") ||
647 0 : !atomsCache->eventPhase_id.init(cx, "eventPhase") ||
648 0 : !atomsCache->endStack_id.init(cx, "endStack") ||
649 0 : !atomsCache->end_id.init(cx, "end") ||
650 0 : !atomsCache->causeName_id.init(cx, "causeName")) {
651 0 : return false;
652 : }
653 0 : return true;
654 : }
655 :
656 : bool
657 0 : ProfileTimelineMarker::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
658 : {
659 : // Passing a null JSContext is OK only if we're initing from null,
660 : // Since in that case we will not have to do any property gets
661 : // Also evaluate isNullOrUndefined in order to avoid false-positive
662 : // checkers by static analysis tools
663 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
664 0 : ProfileTimelineMarkerAtoms* atomsCache = nullptr;
665 0 : if (cx) {
666 0 : atomsCache = GetAtomCache<ProfileTimelineMarkerAtoms>(cx);
667 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
668 0 : return false;
669 : }
670 : }
671 :
672 0 : if (!IsConvertibleToDictionary(val)) {
673 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
674 : }
675 :
676 0 : bool isNull = val.isNullOrUndefined();
677 : // We only need these if !isNull, in which case we have |cx|.
678 0 : Maybe<JS::Rooted<JSObject *> > object;
679 0 : Maybe<JS::Rooted<JS::Value> > temp;
680 0 : if (!isNull) {
681 0 : MOZ_ASSERT(cx);
682 0 : object.emplace(cx, &val.toObject());
683 0 : temp.emplace(cx);
684 : }
685 0 : if (!isNull) {
686 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->causeName_id, temp.ptr())) {
687 0 : return false;
688 : }
689 : }
690 0 : if (!isNull && !temp->isUndefined()) {
691 0 : mCauseName.Construct();
692 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mCauseName.Value()))) {
693 0 : return false;
694 : }
695 0 : mIsAnyMemberPresent = true;
696 : }
697 :
698 0 : if (!isNull) {
699 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->end_id, temp.ptr())) {
700 0 : return false;
701 : }
702 : }
703 0 : if (!isNull && !temp->isUndefined()) {
704 0 : if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mEnd)) {
705 0 : return false;
706 0 : } else if (!mozilla::IsFinite(mEnd)) {
707 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "'end' member of ProfileTimelineMarker");
708 0 : return false;
709 : }
710 : } else {
711 0 : mEnd = 0.0;
712 : }
713 0 : mIsAnyMemberPresent = true;
714 :
715 0 : if (!isNull) {
716 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->endStack_id, temp.ptr())) {
717 0 : return false;
718 : }
719 : }
720 0 : if (!isNull && !temp->isUndefined()) {
721 0 : if (temp.ref().isObject()) {
722 : #ifdef __clang__
723 : #pragma clang diagnostic push
724 : #pragma clang diagnostic ignored "-Wunreachable-code"
725 : #pragma clang diagnostic ignored "-Wunreachable-code-return"
726 : #endif // __clang__
727 0 : if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
728 0 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'endStack' member of ProfileTimelineMarker");
729 0 : return false;
730 : }
731 : #ifdef __clang__
732 : #pragma clang diagnostic pop
733 : #endif // __clang__
734 0 : mEndStack = &temp.ref().toObject();
735 0 : } else if (temp.ref().isNullOrUndefined()) {
736 0 : mEndStack = nullptr;
737 : } else {
738 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'endStack' member of ProfileTimelineMarker");
739 0 : return false;
740 : }
741 : } else {
742 0 : mEndStack = nullptr;
743 : }
744 0 : mIsAnyMemberPresent = true;
745 :
746 0 : if (!isNull) {
747 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->eventPhase_id, temp.ptr())) {
748 0 : return false;
749 : }
750 : }
751 0 : if (!isNull && !temp->isUndefined()) {
752 0 : mEventPhase.Construct();
753 0 : if (!ValueToPrimitive<uint16_t, eDefault>(cx, temp.ref(), &(mEventPhase.Value()))) {
754 0 : return false;
755 : }
756 0 : mIsAnyMemberPresent = true;
757 : }
758 :
759 0 : if (!isNull) {
760 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->isAnimationOnly_id, temp.ptr())) {
761 0 : return false;
762 : }
763 : }
764 0 : if (!isNull && !temp->isUndefined()) {
765 0 : mIsAnimationOnly.Construct();
766 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mIsAnimationOnly.Value()))) {
767 0 : return false;
768 : }
769 0 : mIsAnyMemberPresent = true;
770 : }
771 :
772 0 : if (!isNull) {
773 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->isOffMainThread_id, temp.ptr())) {
774 0 : return false;
775 : }
776 : }
777 0 : if (!isNull && !temp->isUndefined()) {
778 0 : mIsOffMainThread.Construct();
779 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mIsOffMainThread.Value()))) {
780 0 : return false;
781 : }
782 0 : mIsAnyMemberPresent = true;
783 : }
784 :
785 0 : if (!isNull) {
786 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->messagePortOperation_id, temp.ptr())) {
787 0 : return false;
788 : }
789 : }
790 0 : if (!isNull && !temp->isUndefined()) {
791 0 : mMessagePortOperation.Construct();
792 : {
793 : int index;
794 0 : if (!FindEnumStringIndex<true>(cx, temp.ref(), ProfileTimelineMessagePortOperationTypeValues::strings, "ProfileTimelineMessagePortOperationType", "'messagePortOperation' member of ProfileTimelineMarker", &index)) {
795 0 : return false;
796 : }
797 0 : MOZ_ASSERT(index >= 0);
798 0 : (mMessagePortOperation.Value()) = static_cast<ProfileTimelineMessagePortOperationType>(index);
799 : }
800 0 : mIsAnyMemberPresent = true;
801 : }
802 :
803 0 : if (!isNull) {
804 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
805 0 : return false;
806 : }
807 : }
808 0 : if (!isNull && !temp->isUndefined()) {
809 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
810 0 : return false;
811 : }
812 : } else {
813 : static const char16_t data[] = { 0 };
814 0 : mName.Rebind(data, ArrayLength(data) - 1);
815 : }
816 0 : mIsAnyMemberPresent = true;
817 :
818 0 : if (!isNull) {
819 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->processType_id, temp.ptr())) {
820 0 : return false;
821 : }
822 : }
823 0 : if (!isNull && !temp->isUndefined()) {
824 0 : mProcessType.Construct();
825 0 : if (!ValueToPrimitive<uint16_t, eDefault>(cx, temp.ref(), &(mProcessType.Value()))) {
826 0 : return false;
827 : }
828 0 : mIsAnyMemberPresent = true;
829 : }
830 :
831 0 : if (!isNull) {
832 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->rectangles_id, temp.ptr())) {
833 0 : return false;
834 : }
835 : }
836 0 : if (!isNull && !temp->isUndefined()) {
837 0 : mRectangles.Construct();
838 0 : if (temp.ref().isObject()) {
839 0 : JS::ForOfIterator iter(cx);
840 0 : if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
841 0 : return false;
842 : }
843 0 : if (!iter.valueIsIterable()) {
844 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'rectangles' member of ProfileTimelineMarker");
845 0 : return false;
846 : }
847 0 : Sequence<ProfileTimelineLayerRect> &arr = (mRectangles.Value());
848 0 : JS::Rooted<JS::Value> temp(cx);
849 : while (true) {
850 : bool done;
851 0 : if (!iter.next(&temp, &done)) {
852 0 : return false;
853 : }
854 0 : if (done) {
855 0 : break;
856 : }
857 0 : ProfileTimelineLayerRect* slotPtr = arr.AppendElement(mozilla::fallible);
858 0 : if (!slotPtr) {
859 0 : JS_ReportOutOfMemory(cx);
860 0 : return false;
861 : }
862 0 : ProfileTimelineLayerRect& slot = *slotPtr;
863 0 : if (!slot.Init(cx, temp, "Element of 'rectangles' member of ProfileTimelineMarker", passedToJSImpl)) {
864 0 : return false;
865 : }
866 0 : }
867 : } else {
868 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'rectangles' member of ProfileTimelineMarker");
869 0 : return false;
870 : }
871 0 : mIsAnyMemberPresent = true;
872 : }
873 :
874 0 : if (!isNull) {
875 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->stack_id, temp.ptr())) {
876 0 : return false;
877 : }
878 : }
879 0 : if (!isNull && !temp->isUndefined()) {
880 0 : if (temp.ref().isObject()) {
881 : #ifdef __clang__
882 : #pragma clang diagnostic push
883 : #pragma clang diagnostic ignored "-Wunreachable-code"
884 : #pragma clang diagnostic ignored "-Wunreachable-code-return"
885 : #endif // __clang__
886 0 : if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
887 0 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "'stack' member of ProfileTimelineMarker");
888 0 : return false;
889 : }
890 : #ifdef __clang__
891 : #pragma clang diagnostic pop
892 : #endif // __clang__
893 0 : mStack = &temp.ref().toObject();
894 0 : } else if (temp.ref().isNullOrUndefined()) {
895 0 : mStack = nullptr;
896 : } else {
897 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'stack' member of ProfileTimelineMarker");
898 0 : return false;
899 : }
900 : } else {
901 0 : mStack = nullptr;
902 : }
903 0 : mIsAnyMemberPresent = true;
904 :
905 0 : if (!isNull) {
906 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->start_id, temp.ptr())) {
907 0 : return false;
908 : }
909 : }
910 0 : if (!isNull && !temp->isUndefined()) {
911 0 : if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mStart)) {
912 0 : return false;
913 0 : } else if (!mozilla::IsFinite(mStart)) {
914 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "'start' member of ProfileTimelineMarker");
915 0 : return false;
916 : }
917 : } else {
918 0 : mStart = 0.0;
919 : }
920 0 : mIsAnyMemberPresent = true;
921 :
922 0 : if (!isNull) {
923 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->type_id, temp.ptr())) {
924 0 : return false;
925 : }
926 : }
927 0 : if (!isNull && !temp->isUndefined()) {
928 0 : mType.Construct();
929 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mType.Value()))) {
930 0 : return false;
931 : }
932 0 : mIsAnyMemberPresent = true;
933 : }
934 :
935 0 : if (!isNull) {
936 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->unixTime_id, temp.ptr())) {
937 0 : return false;
938 : }
939 : }
940 0 : if (!isNull && !temp->isUndefined()) {
941 0 : mUnixTime.Construct();
942 0 : if (!ValueToPrimitive<uint64_t, eDefault>(cx, temp.ref(), &(mUnixTime.Value()))) {
943 0 : return false;
944 : }
945 0 : mIsAnyMemberPresent = true;
946 : }
947 :
948 0 : if (!isNull) {
949 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->workerOperation_id, temp.ptr())) {
950 0 : return false;
951 : }
952 : }
953 0 : if (!isNull && !temp->isUndefined()) {
954 0 : mWorkerOperation.Construct();
955 : {
956 : int index;
957 0 : if (!FindEnumStringIndex<true>(cx, temp.ref(), ProfileTimelineWorkerOperationTypeValues::strings, "ProfileTimelineWorkerOperationType", "'workerOperation' member of ProfileTimelineMarker", &index)) {
958 0 : return false;
959 : }
960 0 : MOZ_ASSERT(index >= 0);
961 0 : (mWorkerOperation.Value()) = static_cast<ProfileTimelineWorkerOperationType>(index);
962 : }
963 0 : mIsAnyMemberPresent = true;
964 : }
965 0 : return true;
966 : }
967 :
968 : bool
969 0 : ProfileTimelineMarker::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
970 : {
971 0 : ProfileTimelineMarkerAtoms* atomsCache = GetAtomCache<ProfileTimelineMarkerAtoms>(cx);
972 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
973 0 : return false;
974 : }
975 :
976 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
977 0 : if (!obj) {
978 0 : return false;
979 : }
980 0 : rval.set(JS::ObjectValue(*obj));
981 :
982 0 : if (mCauseName.WasPassed()) {
983 : do {
984 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
985 0 : JS::Rooted<JS::Value> temp(cx);
986 0 : nsString const & currentValue = mCauseName.InternalValue();
987 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
988 0 : return false;
989 : }
990 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->causeName_id, temp, JSPROP_ENUMERATE)) {
991 0 : return false;
992 : }
993 0 : break;
994 : } while(0);
995 : }
996 :
997 : do {
998 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
999 0 : JS::Rooted<JS::Value> temp(cx);
1000 0 : double const & currentValue = mEnd;
1001 0 : temp.set(JS_NumberValue(double(currentValue)));
1002 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->end_id, temp, JSPROP_ENUMERATE)) {
1003 0 : return false;
1004 : }
1005 0 : break;
1006 : } while(0);
1007 :
1008 : do {
1009 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1010 0 : JS::Rooted<JS::Value> temp(cx);
1011 0 : JSObject* const & currentValue = mEndStack;
1012 0 : if (currentValue) {
1013 0 : JS::ExposeObjectToActiveJS(currentValue);
1014 : }
1015 0 : temp.setObjectOrNull(currentValue);
1016 0 : if (!MaybeWrapObjectOrNullValue(cx, &temp)) {
1017 0 : return false;
1018 : }
1019 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->endStack_id, temp, JSPROP_ENUMERATE)) {
1020 0 : return false;
1021 : }
1022 0 : break;
1023 : } while(0);
1024 :
1025 0 : if (mEventPhase.WasPassed()) {
1026 : do {
1027 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1028 0 : JS::Rooted<JS::Value> temp(cx);
1029 0 : uint16_t const & currentValue = mEventPhase.InternalValue();
1030 0 : temp.setInt32(int32_t(currentValue));
1031 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->eventPhase_id, temp, JSPROP_ENUMERATE)) {
1032 0 : return false;
1033 : }
1034 0 : break;
1035 : } while(0);
1036 : }
1037 :
1038 0 : if (mIsAnimationOnly.WasPassed()) {
1039 : do {
1040 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1041 0 : JS::Rooted<JS::Value> temp(cx);
1042 0 : bool const & currentValue = mIsAnimationOnly.InternalValue();
1043 0 : temp.setBoolean(currentValue);
1044 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->isAnimationOnly_id, temp, JSPROP_ENUMERATE)) {
1045 0 : return false;
1046 : }
1047 0 : break;
1048 : } while(0);
1049 : }
1050 :
1051 0 : if (mIsOffMainThread.WasPassed()) {
1052 : do {
1053 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1054 0 : JS::Rooted<JS::Value> temp(cx);
1055 0 : bool const & currentValue = mIsOffMainThread.InternalValue();
1056 0 : temp.setBoolean(currentValue);
1057 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->isOffMainThread_id, temp, JSPROP_ENUMERATE)) {
1058 0 : return false;
1059 : }
1060 0 : break;
1061 : } while(0);
1062 : }
1063 :
1064 0 : if (mMessagePortOperation.WasPassed()) {
1065 : do {
1066 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1067 0 : JS::Rooted<JS::Value> temp(cx);
1068 0 : ProfileTimelineMessagePortOperationType const & currentValue = mMessagePortOperation.InternalValue();
1069 0 : if (!ToJSValue(cx, currentValue, &temp)) {
1070 0 : return false;
1071 : }
1072 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->messagePortOperation_id, temp, JSPROP_ENUMERATE)) {
1073 0 : return false;
1074 : }
1075 0 : break;
1076 : } while(0);
1077 : }
1078 :
1079 : do {
1080 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1081 0 : JS::Rooted<JS::Value> temp(cx);
1082 0 : nsString const & currentValue = mName;
1083 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1084 0 : return false;
1085 : }
1086 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
1087 0 : return false;
1088 : }
1089 0 : break;
1090 : } while(0);
1091 :
1092 0 : if (mProcessType.WasPassed()) {
1093 : do {
1094 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1095 0 : JS::Rooted<JS::Value> temp(cx);
1096 0 : uint16_t const & currentValue = mProcessType.InternalValue();
1097 0 : temp.setInt32(int32_t(currentValue));
1098 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->processType_id, temp, JSPROP_ENUMERATE)) {
1099 0 : return false;
1100 : }
1101 0 : break;
1102 : } while(0);
1103 : }
1104 :
1105 0 : if (mRectangles.WasPassed()) {
1106 : do {
1107 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1108 0 : JS::Rooted<JS::Value> temp(cx);
1109 0 : Sequence<ProfileTimelineLayerRect> const & currentValue = mRectangles.InternalValue();
1110 :
1111 0 : uint32_t length = currentValue.Length();
1112 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
1113 0 : if (!returnArray) {
1114 0 : return false;
1115 : }
1116 : // Scope for 'tmp'
1117 : {
1118 0 : JS::Rooted<JS::Value> tmp(cx);
1119 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1120 : // Control block to let us common up the JS_DefineElement calls when there
1121 : // are different ways to succeed at wrapping the object.
1122 : do {
1123 0 : if (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
1124 0 : return false;
1125 : }
1126 0 : break;
1127 : } while (0);
1128 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1129 : JSPROP_ENUMERATE)) {
1130 0 : return false;
1131 : }
1132 : }
1133 : }
1134 0 : temp.setObject(*returnArray);
1135 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->rectangles_id, temp, JSPROP_ENUMERATE)) {
1136 0 : return false;
1137 : }
1138 0 : break;
1139 : } while(0);
1140 : }
1141 :
1142 : do {
1143 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1144 0 : JS::Rooted<JS::Value> temp(cx);
1145 0 : JSObject* const & currentValue = mStack;
1146 0 : if (currentValue) {
1147 0 : JS::ExposeObjectToActiveJS(currentValue);
1148 : }
1149 0 : temp.setObjectOrNull(currentValue);
1150 0 : if (!MaybeWrapObjectOrNullValue(cx, &temp)) {
1151 0 : return false;
1152 : }
1153 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->stack_id, temp, JSPROP_ENUMERATE)) {
1154 0 : return false;
1155 : }
1156 0 : break;
1157 : } while(0);
1158 :
1159 : do {
1160 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1161 0 : JS::Rooted<JS::Value> temp(cx);
1162 0 : double const & currentValue = mStart;
1163 0 : temp.set(JS_NumberValue(double(currentValue)));
1164 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->start_id, temp, JSPROP_ENUMERATE)) {
1165 0 : return false;
1166 : }
1167 0 : break;
1168 : } while(0);
1169 :
1170 0 : if (mType.WasPassed()) {
1171 : do {
1172 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1173 0 : JS::Rooted<JS::Value> temp(cx);
1174 0 : nsString const & currentValue = mType.InternalValue();
1175 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
1176 0 : return false;
1177 : }
1178 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->type_id, temp, JSPROP_ENUMERATE)) {
1179 0 : return false;
1180 : }
1181 0 : break;
1182 : } while(0);
1183 : }
1184 :
1185 0 : if (mUnixTime.WasPassed()) {
1186 : do {
1187 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1188 0 : JS::Rooted<JS::Value> temp(cx);
1189 0 : uint64_t const & currentValue = mUnixTime.InternalValue();
1190 0 : temp.set(JS_NumberValue(double(currentValue)));
1191 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->unixTime_id, temp, JSPROP_ENUMERATE)) {
1192 0 : return false;
1193 : }
1194 0 : break;
1195 : } while(0);
1196 : }
1197 :
1198 0 : if (mWorkerOperation.WasPassed()) {
1199 : do {
1200 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1201 0 : JS::Rooted<JS::Value> temp(cx);
1202 0 : ProfileTimelineWorkerOperationType const & currentValue = mWorkerOperation.InternalValue();
1203 0 : if (!ToJSValue(cx, currentValue, &temp)) {
1204 0 : return false;
1205 : }
1206 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->workerOperation_id, temp, JSPROP_ENUMERATE)) {
1207 0 : return false;
1208 : }
1209 0 : break;
1210 : } while(0);
1211 : }
1212 :
1213 0 : return true;
1214 : }
1215 :
1216 : void
1217 0 : ProfileTimelineMarker::TraceDictionary(JSTracer* trc)
1218 : {
1219 0 : if (mEndStack) {
1220 0 : JS::UnsafeTraceRoot(trc, &mEndStack, "ProfileTimelineMarker.mEndStack");
1221 : }
1222 :
1223 0 : if (mStack) {
1224 0 : JS::UnsafeTraceRoot(trc, &mStack, "ProfileTimelineMarker.mStack");
1225 : }
1226 0 : }
1227 :
1228 : namespace binding_detail {
1229 : } // namespace binding_detail
1230 :
1231 :
1232 : } // namespace dom
1233 : } // namespace mozilla
|