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"
12 using namespace mozilla
;
13 using namespace widget
;
15 void InfoObject::DefineProperty(const char* name
, int value
) {
18 mOk
= JS_DefineProperty(mCx
, mObj
, name
, value
, JSPROP_ENUMERATE
);
21 void InfoObject::DefineProperty(const char* name
, nsAString
& value
) {
24 const nsString
& flat
= PromiseFlatString(value
);
25 JS::Rooted
<JSString
*> string(
26 mCx
, JS_NewUCStringCopyN(mCx
, static_cast<const char16_t
*>(flat
.get()),
28 if (!string
) mOk
= false;
32 mOk
= JS_DefineProperty(mCx
, mObj
, name
, string
, JSPROP_ENUMERATE
);
35 void InfoObject::DefineProperty(const char* name
, const char* value
) {
36 nsAutoString string
= NS_ConvertASCIItoUTF16(value
);
37 DefineProperty(name
, string
);
40 InfoObject::InfoObject(JSContext
* aCx
) : mCx(aCx
), mObj(aCx
), mOk(true) {
41 mObj
= JS_NewPlainObject(aCx
);
42 if (!mObj
) mOk
= false;