зеркало из https://github.com/mozilla/gecko-dev.git
check into trunk for bug 87224
r=bstell sr=waterson move the converter cache from class static to global cache
This commit is contained in:
Родитель
d802539ea1
Коммит
6d05383d8d
|
@ -213,6 +213,7 @@ static nsHashtable* gCachedFFRESearches = nsnull;
|
||||||
static nsHashtable* gSpecialCharSets = nsnull;
|
static nsHashtable* gSpecialCharSets = nsnull;
|
||||||
static nsHashtable* gStretches = nsnull;
|
static nsHashtable* gStretches = nsnull;
|
||||||
static nsHashtable* gWeights = nsnull;
|
static nsHashtable* gWeights = nsnull;
|
||||||
|
nsISaveAsCharset* gFontSubConverter = nsnull;
|
||||||
|
|
||||||
static nsFontNodeArray* gGlobalList = nsnull;
|
static nsFontNodeArray* gGlobalList = nsnull;
|
||||||
|
|
||||||
|
@ -744,6 +745,7 @@ FreeGlobals(void)
|
||||||
NS_IF_RELEASE(gUserDefinedConverter);
|
NS_IF_RELEASE(gUserDefinedConverter);
|
||||||
NS_IF_RELEASE(gUsersLocale);
|
NS_IF_RELEASE(gUsersLocale);
|
||||||
NS_IF_RELEASE(gWesternLocale);
|
NS_IF_RELEASE(gWesternLocale);
|
||||||
|
NS_IF_RELEASE(gFontSubConverter);
|
||||||
if (gWeights) {
|
if (gWeights) {
|
||||||
delete gWeights;
|
delete gWeights;
|
||||||
gWeights = nsnull;
|
gWeights = nsnull;
|
||||||
|
@ -2087,25 +2089,15 @@ public:
|
||||||
PRUnichar* aDest, PRUint32 aDestLen);
|
PRUnichar* aDest, PRUint32 aDestLen);
|
||||||
|
|
||||||
nsFontGTK* mSubstituteFont;
|
nsFontGTK* mSubstituteFont;
|
||||||
|
|
||||||
static int gCount;
|
|
||||||
static nsISaveAsCharset* gConverter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int nsFontGTKSubstitute::gCount = 0;
|
|
||||||
nsISaveAsCharset* nsFontGTKSubstitute::gConverter = nsnull;
|
|
||||||
|
|
||||||
nsFontGTKSubstitute::nsFontGTKSubstitute(nsFontGTK* aFont)
|
nsFontGTKSubstitute::nsFontGTKSubstitute(nsFontGTK* aFont)
|
||||||
{
|
{
|
||||||
gCount++;
|
|
||||||
mSubstituteFont = aFont;
|
mSubstituteFont = aFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFontGTKSubstitute::~nsFontGTKSubstitute()
|
nsFontGTKSubstitute::~nsFontGTKSubstitute()
|
||||||
{
|
{
|
||||||
if (!--gCount) {
|
|
||||||
NS_IF_RELEASE(gConverter);
|
|
||||||
}
|
|
||||||
// Do not free mSubstituteFont here. It is owned by somebody else.
|
// Do not free mSubstituteFont here. It is owned by somebody else.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2114,24 +2106,24 @@ nsFontGTKSubstitute::Convert(const PRUnichar* aSrc, PRUint32 aSrcLen,
|
||||||
PRUnichar* aDest, PRUint32 aDestLen)
|
PRUnichar* aDest, PRUint32 aDestLen)
|
||||||
{
|
{
|
||||||
nsresult res;
|
nsresult res;
|
||||||
if (!gConverter) {
|
if (!gFontSubConverter) {
|
||||||
nsComponentManager::CreateInstance(kSaveAsCharsetCID, nsnull,
|
nsComponentManager::CreateInstance(kSaveAsCharsetCID, nsnull,
|
||||||
NS_GET_IID(nsISaveAsCharset), (void**) &gConverter);
|
NS_GET_IID(nsISaveAsCharset), (void**) &gFontSubConverter);
|
||||||
if (gConverter) {
|
if (gFontSubConverter) {
|
||||||
res = gConverter->Init("ISO-8859-1",
|
res = gFontSubConverter->Init("ISO-8859-1",
|
||||||
nsISaveAsCharset::attr_FallbackQuestionMark +
|
nsISaveAsCharset::attr_FallbackQuestionMark +
|
||||||
nsISaveAsCharset::attr_EntityBeforeCharsetConv,
|
nsISaveAsCharset::attr_EntityBeforeCharsetConv,
|
||||||
nsIEntityConverter::transliterate);
|
nsIEntityConverter::transliterate);
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
NS_RELEASE(gConverter);
|
NS_RELEASE(gFontSubConverter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gConverter) {
|
if (gFontSubConverter) {
|
||||||
nsAutoString tmp(aSrc, aSrcLen);
|
nsAutoString tmp(aSrc, aSrcLen);
|
||||||
char* conv = nsnull;
|
char* conv = nsnull;
|
||||||
res = gConverter->Convert(tmp.GetUnicode(), &conv);
|
res = gFontSubConverter->Convert(tmp.GetUnicode(), &conv);
|
||||||
if (NS_SUCCEEDED(res) && conv) {
|
if (NS_SUCCEEDED(res) && conv) {
|
||||||
char* p = conv;
|
char* p = conv;
|
||||||
PRUint32 i;
|
PRUint32 i;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче