1 /* vim: se cin sw=2 ts=2 et : */
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "GfxInfoCollector.h"
10 #include "js/PropertyAndElement.h" // JS_DefineProperty
13 using namespace mozilla
;
14 using namespace widget
;
16 void InfoObject::DefineProperty(const char* name
, int value
) {
19 mOk
= JS_DefineProperty(mCx
, mObj
, name
, value
, JSPROP_ENUMERATE
);
22 void InfoObject::DefineProperty(const char* name
, const nsAString
& value
) {
25 const nsString
& flat
= PromiseFlatString(value
);
26 JS::Rooted
<JSString
*> string(
27 mCx
, JS_NewUCStringCopyN(mCx
, static_cast<const char16_t
*>(flat
.get()),
29 if (!string
) mOk
= false;
33 mOk
= JS_DefineProperty(mCx
, mObj
, name
, string
, JSPROP_ENUMERATE
);
36 void InfoObject::DefineProperty(const char* name
, const char* value
) {
37 nsAutoString string
= NS_ConvertASCIItoUTF16(value
);
38 DefineProperty(name
, string
);
41 InfoObject::InfoObject(JSContext
* aCx
) : mCx(aCx
), mObj(aCx
), mOk(true) {
42 mObj
= JS_NewPlainObject(aCx
);
43 if (!mObj
) mOk
= false;