Eliminate global constuctor dependency

This commit is contained in:
kipp%netscape.com 1999-02-25 16:41:54 +00:00
Родитель 2c87753eba
Коммит 2a07efa26c
2 изменённых файлов: 29 добавлений и 38 удалений

Просмотреть файл

@ -468,18 +468,6 @@ nsHashKey* FontAliasKey::Clone(void) const
{
return new FontAliasKey(mString);
}
static nsAutoString gTimes("Times");
static nsAutoString gTimesNewRoman("Times New Roman");
static nsAutoString gTimesRoman("Times Roman");
static nsAutoString gArial("Arial");
static nsAutoString gHelvetica("Helvetica");
static nsAutoString gCourier("Courier");
static nsAutoString gCourierNew("Courier New");
static nsAutoString gUnicode("Unicode");
static nsAutoString gBitstreamCyberbit("Bitstream Cyberbit");
static nsAutoString gNullStr;
nsresult DeviceContextImpl::CreateFontAliasTable()
{
nsresult result = NS_OK;
@ -487,14 +475,26 @@ nsresult DeviceContextImpl::CreateFontAliasTable()
if (nsnull == mFontAliasTable) {
mFontAliasTable = new nsHashtable();
if (nsnull != mFontAliasTable) {
AliasFont(gTimes, gTimesNewRoman, gTimesRoman, PR_FALSE);
AliasFont(gTimesRoman, gTimesNewRoman, gTimes, PR_FALSE);
AliasFont(gTimesNewRoman, gTimesRoman, gTimes, PR_FALSE);
AliasFont(gArial, gHelvetica, gNullStr, PR_FALSE);
AliasFont(gHelvetica, gArial, gNullStr, PR_FALSE);
AliasFont(gCourier, gCourierNew, gNullStr, PR_TRUE);
AliasFont(gCourierNew, gCourier, gNullStr, PR_FALSE);
AliasFont(gUnicode, gBitstreamCyberbit, gNullStr, PR_FALSE); // XXX ????
nsAutoString times("Times");
nsAutoString timesNewRoman("Times New Roman");
nsAutoString timesRoman("Times Roman");
nsAutoString arial("Arial");
nsAutoString helvetica("Helvetica");
nsAutoString courier("Courier");
nsAutoString courierNew("Courier New");
nsAutoString unicode("Unicode");
nsAutoString bitstreamCyberbit("Bitstream Cyberbit");
nsAutoString nullStr;
AliasFont(times, timesNewRoman, timesRoman, PR_FALSE);
AliasFont(timesRoman, timesNewRoman, times, PR_FALSE);
AliasFont(timesNewRoman, timesRoman, times, PR_FALSE);
AliasFont(arial, helvetica, nullStr, PR_FALSE);
AliasFont(helvetica, arial, nullStr, PR_FALSE);
AliasFont(courier, courierNew, nullStr, PR_TRUE);
AliasFont(courierNew, courier, nullStr, PR_FALSE);
AliasFont(unicode, bitstreamCyberbit, nullStr, PR_FALSE); // XXX ????
}
else {
result = NS_ERROR_OUT_OF_MEMORY;

Просмотреть файл

@ -113,23 +113,9 @@ ImageManagerImpl::GetImageType(const char *buf, PRInt32 length)
}
// The singleton image manager
// XXX make this a service
static ImageManagerImpl* gImageManager;
// Class to manage construction and destruction of the singleton
// image manager
struct ImageManagerInit {
ImageManagerInit() {
gImageManager = new ImageManagerImpl();
NS_ADDREF(gImageManager);
}
~ImageManagerInit() {
NS_RELEASE(gImageManager);
}
};
static ImageManagerInit imageManagerInit;
extern "C" NS_GFX_(nsresult)
NS_NewImageManager(nsIImageManager **aInstancePtrResult)
{
@ -137,7 +123,12 @@ NS_NewImageManager(nsIImageManager **aInstancePtrResult)
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
NS_ASSERTION(nsnull != gImageManager, "no image manager");
return gImageManager->QueryInterface(kIImageManagerIID, (void **)aInstancePtrResult);
if (nsnull == gImageManager) {
gImageManager = new ImageManagerImpl();
}
if (nsnull == gImageManager) {
return NS_ERROR_OUT_OF_MEMORY;
}
return gImageManager->QueryInterface(kIImageManagerIID,
(void **)aInstancePtrResult);
}