mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 918330 - GfxInfoCollector.h should not include jsapi.h - r=ehsan
This commit is contained in:
parent
12410f1623
commit
fda7de8752
@ -18,6 +18,7 @@
|
||||
#include "GfxInfoCollector.h"
|
||||
#include "nsIGfxInfoDebug.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "js/Value.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
|
53
widget/xpwidgets/GfxInfoCollector.cpp
Normal file
53
widget/xpwidgets/GfxInfoCollector.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/* vim: se cin sw=2 ts=2 et : */
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "GfxInfoCollector.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace widget;
|
||||
|
||||
void
|
||||
InfoObject::DefineProperty(const char *name, int value)
|
||||
{
|
||||
if (!mOk)
|
||||
return;
|
||||
|
||||
mOk = JS_DefineProperty(mCx, mObj, name, INT_TO_JSVAL(value), NULL, NULL, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
void
|
||||
InfoObject::DefineProperty(const char *name, nsAString &value)
|
||||
{
|
||||
if (!mOk)
|
||||
return;
|
||||
|
||||
const nsString &flat = PromiseFlatString(value);
|
||||
JSString *string = JS_NewUCStringCopyN(mCx, static_cast<const jschar*>(flat.get()), flat.Length());
|
||||
if (!string)
|
||||
mOk = false;
|
||||
|
||||
if (!mOk)
|
||||
return;
|
||||
|
||||
mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
void
|
||||
InfoObject::DefineProperty(const char *name, const char *value)
|
||||
{
|
||||
nsAutoString string = NS_ConvertASCIItoUTF16(value);
|
||||
DefineProperty(name, string);
|
||||
}
|
||||
|
||||
InfoObject::InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(true)
|
||||
{
|
||||
mObj = JS_NewObject(mCx, NULL, NULL, NULL);
|
||||
if (!mObj)
|
||||
mOk = false;
|
||||
}
|
@ -8,8 +8,9 @@
|
||||
#ifndef __mozilla_widget_GfxInfoCollector_h__
|
||||
#define __mozilla_widget_GfxInfoCollector_h__
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsStringFwd.h"
|
||||
#include "js/RootingAPI.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace widget {
|
||||
@ -22,44 +23,13 @@ class MOZ_STACK_CLASS InfoObject
|
||||
friend class GfxInfoBase;
|
||||
|
||||
public:
|
||||
void DefineProperty(const char *name, int value)
|
||||
{
|
||||
if (!mOk)
|
||||
return;
|
||||
|
||||
mOk = JS_DefineProperty(mCx, mObj, name, INT_TO_JSVAL(value), NULL, NULL, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
void DefineProperty(const char *name, nsAString &value)
|
||||
{
|
||||
if (!mOk)
|
||||
return;
|
||||
|
||||
const nsString &flat = PromiseFlatString(value);
|
||||
JSString *string = JS_NewUCStringCopyN(mCx, static_cast<const jschar*>(flat.get()), flat.Length());
|
||||
if (!string)
|
||||
mOk = false;
|
||||
|
||||
if (!mOk)
|
||||
return;
|
||||
|
||||
mOk = JS_DefineProperty(mCx, mObj, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
void DefineProperty(const char *name, const char *value)
|
||||
{
|
||||
nsAutoString string = NS_ConvertASCIItoUTF16(value);
|
||||
DefineProperty(name, string);
|
||||
}
|
||||
void DefineProperty(const char *name, int value);
|
||||
void DefineProperty(const char *name, nsAString &value);
|
||||
void DefineProperty(const char *name, const char *value);
|
||||
|
||||
private:
|
||||
// We need to ensure that this object lives on the stack so that GC sees it properly
|
||||
InfoObject(JSContext *aCx) : mCx(aCx), mObj(aCx), mOk(true)
|
||||
{
|
||||
mObj = JS_NewObject(mCx, NULL, NULL, NULL);
|
||||
if (!mObj)
|
||||
mOk = false;
|
||||
}
|
||||
InfoObject(JSContext *aCx);
|
||||
InfoObject(InfoObject&);
|
||||
|
||||
JSContext *mCx;
|
||||
|
@ -15,6 +15,7 @@ CPP_SOURCES += [
|
||||
'APZCCallbackHelper.cpp',
|
||||
'GfxDriverInfo.cpp',
|
||||
'GfxInfoBase.cpp',
|
||||
'GfxInfoCollector.cpp',
|
||||
'GfxInfoWebGL.cpp',
|
||||
'InputData.cpp',
|
||||
'PuppetWidget.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user