mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-16 03:34:06 +00:00
making string conversions explicit
This commit is contained in:
parent
5b2b7c396e
commit
a3e01d96a8
@ -317,7 +317,7 @@ NS_IMETHODIMP nsDeviceContextMac :: GetSystemAttribute(nsSystemAttrID anID, Syst
|
||||
Style fontStyle;
|
||||
::GetThemeFont(fontID, smSystemScript, fontName, &fontSize, &fontStyle);
|
||||
fontName[fontName[0]+1] = 0;
|
||||
aInfo->mFont->name = (char*)&fontName[1];
|
||||
aInfo->mFont->name.AssignWithConversion( (char*)&fontName[1] );
|
||||
aInfo->mFont->size = fontSize;
|
||||
if (fontStyle & bold)
|
||||
aInfo->mFont->weight = NS_FONT_WEIGHT_BOLD;
|
||||
@ -328,7 +328,7 @@ NS_IMETHODIMP nsDeviceContextMac :: GetSystemAttribute(nsSystemAttrID anID, Syst
|
||||
}
|
||||
else
|
||||
{
|
||||
aInfo->mFont->name = "geneva";
|
||||
aInfo->mFont->name.AssignWithConversion( "geneva" );
|
||||
aInfo->mFont->size = 9;
|
||||
}
|
||||
float dev2app;
|
||||
@ -706,7 +706,7 @@ public:
|
||||
|
||||
FontNameKey::FontNameKey(const nsString& aString)
|
||||
{
|
||||
mString = aString;
|
||||
mString.Assign(aString);
|
||||
}
|
||||
|
||||
PRUint32 FontNameKey::HashValue(void) const
|
||||
@ -842,15 +842,15 @@ nsresult nsDeviceContextMac::CreateFontAliasTable()
|
||||
mFontAliasTable = new nsHashtable();
|
||||
if (nsnull != mFontAliasTable)
|
||||
{
|
||||
nsAutoString fontTimes("Times");
|
||||
nsAutoString fontTimesNewRoman("Times New Roman");
|
||||
nsAutoString fontTimesRoman("Times Roman");
|
||||
nsAutoString fontArial("Arial");
|
||||
nsAutoString fontHelvetica("Helvetica");
|
||||
nsAutoString fontCourier("Courier");
|
||||
nsAutoString fontCourierNew("Courier New");
|
||||
nsAutoString fontUnicode("Unicode");
|
||||
nsAutoString fontBitstreamCyberbit("Bitstream Cyberbit");
|
||||
nsAutoString fontTimes; fontTimes.AssignWithConversion("Times");
|
||||
nsAutoString fontTimesNewRoman; fontTimesNewRoman.AssignWithConversion("Times New Roman");
|
||||
nsAutoString fontTimesRoman; fontTimesRoman.AssignWithConversion("Times Roman");
|
||||
nsAutoString fontArial; fontArial.AssignWithConversion("Arial");
|
||||
nsAutoString fontHelvetica; fontHelvetica.AssignWithConversion("Helvetica");
|
||||
nsAutoString fontCourier; fontCourier.AssignWithConversion("Courier");
|
||||
nsAutoString fontCourierNew; fontCourierNew.AssignWithConversion("Courier New");
|
||||
nsAutoString fontUnicode; fontUnicode.AssignWithConversion("Unicode");
|
||||
nsAutoString fontBitstreamCyberbit; fontBitstreamCyberbit.AssignWithConversion("Bitstream Cyberbit");
|
||||
nsAutoString fontNullStr;
|
||||
|
||||
AliasFont(fontTimes, fontTimesNewRoman, fontTimesRoman, PR_FALSE);
|
||||
@ -1095,7 +1095,7 @@ nsFontEnumeratorMac::EnumerateFonts(const char* aLangGroup,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString GenName(aGeneric);
|
||||
nsAutoString GenName; GenName.AssignWithConversion(aGeneric);
|
||||
EnumerateFontInfo info = { array, 0 , 0, gUtil->MapLangGroupToScriptCode(aLangGroup) ,gUtil->MapGenericFontNameType(GenName) };
|
||||
list->Enumerate ( EnumerateFont, &info);
|
||||
if (!info.mIndex) {
|
||||
|
@ -120,8 +120,8 @@ nsUnicodeFontMappingMac* nsFontMetricsMac :: GetUnicodeFontMapping()
|
||||
// we should pass the documentCharset from the nsIDocument level and
|
||||
// the lang attribute from the tag level to here.
|
||||
// XXX hard code to some value till peterl pass them down.
|
||||
nsAutoString lang("");
|
||||
nsAutoString langGroup("ja");
|
||||
nsAutoString lang;
|
||||
nsAutoString langGroup; langGroup.AssignWithConversion("ja");
|
||||
if(mLangGroup)
|
||||
mLangGroup->ToString(langGroup);
|
||||
if(! mFontMapping)
|
||||
@ -136,27 +136,27 @@ static void MapGenericFamilyToFont(const nsString& aGenericFamily, nsString& aFo
|
||||
|
||||
if (aGenericFamily.EqualsIgnoreCase("serif"))
|
||||
{
|
||||
aFontFace = "Times";
|
||||
aFontFace.AssignWithConversion("Times");
|
||||
}
|
||||
else if (aGenericFamily.EqualsIgnoreCase("sans-serif"))
|
||||
{
|
||||
aFontFace="Helvetica";
|
||||
aFontFace.AssignWithConversion("Helvetica");
|
||||
}
|
||||
else if (aGenericFamily.EqualsIgnoreCase("cursive"))
|
||||
{
|
||||
aFontFace="Apple Chancery";
|
||||
aFontFace.AssignWithConversion("Apple Chancery");
|
||||
}
|
||||
else if (aGenericFamily.EqualsIgnoreCase("fantasy"))
|
||||
{
|
||||
aFontFace ="Gadget";
|
||||
aFontFace.AssignWithConversion("Gadget");
|
||||
}
|
||||
else if (aGenericFamily.EqualsIgnoreCase("monospace"))
|
||||
{
|
||||
aFontFace = "Courier";
|
||||
aFontFace.AssignWithConversion("Courier");
|
||||
}
|
||||
else if (aGenericFamily.EqualsIgnoreCase("-moz-fixed"))
|
||||
{
|
||||
aFontFace = "Courier";
|
||||
aFontFace.AssignWithConversion("Courier");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -313,9 +313,9 @@ nsUnicodeFontMappingMac* nsUnicodeFontMappingMac::GetCachedInstance(
|
||||
|
||||
nsUnicodeFontMappingMac* obj = nsnull;
|
||||
nsAutoString key = aFont->name;
|
||||
key.Append(":");
|
||||
key.AppendWithConversion(":");
|
||||
key.Append(aLangGroup);
|
||||
key.Append(":");
|
||||
key.AppendWithConversion(":");
|
||||
key.Append(aLANG);
|
||||
if(! gCache->Get ( key, &obj )){
|
||||
obj = new nsUnicodeFontMappingMac(aFont, aDeviceContext, aLangGroup, aLANG);
|
||||
|
@ -83,11 +83,11 @@ void nsUnicodeMappingUtil::InitGenericFontMapping()
|
||||
|
||||
// We probabaly should put the following info into resource ....
|
||||
// smRoman
|
||||
mGenericFontMapping[smRoman][kSerif] = new nsAutoString("Times");
|
||||
mGenericFontMapping[smRoman][kSansSerif] = new nsAutoString("Helvetica"); // note: MRJ use Geneva for Sans-Serif
|
||||
mGenericFontMapping[smRoman][kMonospace] = new nsAutoString("Courier");
|
||||
mGenericFontMapping[smRoman][kCursive] = new nsAutoString("Zapf Chancery");
|
||||
mGenericFontMapping[smRoman][kFantasy] = new nsAutoString("New Century Schlbk");
|
||||
mGenericFontMapping[smRoman][kSerif] = new nsAutoString( NS_ConvertToString("Times") );
|
||||
mGenericFontMapping[smRoman][kSansSerif] = new nsAutoString( NS_ConvertToString("Helvetica") ); // note: MRJ use Geneva for Sans-Serif
|
||||
mGenericFontMapping[smRoman][kMonospace] = new nsAutoString( NS_ConvertToString("Courier") );
|
||||
mGenericFontMapping[smRoman][kCursive] = new nsAutoString( NS_ConvertToString("Zapf Chancery") );
|
||||
mGenericFontMapping[smRoman][kFantasy] = new nsAutoString( NS_ConvertToString("New Century Schlbk") );
|
||||
|
||||
// smJapanese
|
||||
static PRUnichar jfontname1[] = {
|
||||
@ -105,14 +105,14 @@ void nsUnicodeMappingUtil::InitGenericFontMapping()
|
||||
mGenericFontMapping[smJapanese][kMonospace] = new nsAutoString(jfontname3);
|
||||
|
||||
// smTradChinese
|
||||
mGenericFontMapping[smTradChinese][kSerif] = new nsAutoString("Apple LiSung Light");
|
||||
mGenericFontMapping[smTradChinese][kSansSerif] = new nsAutoString("Apple LiGothic Medium");
|
||||
mGenericFontMapping[smTradChinese][kMonospace] = new nsAutoString("Apple LiGothic Medium");
|
||||
mGenericFontMapping[smTradChinese][kSerif] = new nsAutoString( NS_ConvertToString("Apple LiSung Light") );
|
||||
mGenericFontMapping[smTradChinese][kSansSerif] = new nsAutoString( NS_ConvertToString("Apple LiGothic Medium") );
|
||||
mGenericFontMapping[smTradChinese][kMonospace] = new nsAutoString( NS_ConvertToString("Apple LiGothic Medium") );
|
||||
|
||||
// smKorean
|
||||
mGenericFontMapping[smKorean][kSerif] = new nsAutoString("AppleMyungjo");
|
||||
mGenericFontMapping[smKorean][kSansSerif] = new nsAutoString("AppleGothic");
|
||||
mGenericFontMapping[smKorean][kMonospace] = new nsAutoString("AppleGothic");
|
||||
mGenericFontMapping[smKorean][kSerif] = new nsAutoString( NS_ConvertToString("AppleMyungjo") );
|
||||
mGenericFontMapping[smKorean][kSansSerif] = new nsAutoString( NS_ConvertToString("AppleGothic") );
|
||||
mGenericFontMapping[smKorean][kMonospace] = new nsAutoString( NS_ConvertToString("AppleGothic") );
|
||||
|
||||
// smArabic
|
||||
static PRUnichar afontname1[] = {
|
||||
@ -141,40 +141,40 @@ void nsUnicodeMappingUtil::InitGenericFontMapping()
|
||||
mGenericFontMapping[smHebrew][kMonospace] = new nsAutoString(hfontname2);
|
||||
|
||||
// smCyrillic
|
||||
mGenericFontMapping[smCyrillic][kSerif] = new nsAutoString("Latinski");
|
||||
mGenericFontMapping[smCyrillic][kSansSerif] = new nsAutoString("Pryamoy Prop");
|
||||
mGenericFontMapping[smCyrillic][kMonospace] = new nsAutoString("APC Courier");
|
||||
mGenericFontMapping[smCyrillic][kSerif] = new nsAutoString( NS_ConvertToString("Latinski") );
|
||||
mGenericFontMapping[smCyrillic][kSansSerif] = new nsAutoString( NS_ConvertToString("Pryamoy Prop") );
|
||||
mGenericFontMapping[smCyrillic][kMonospace] = new nsAutoString( NS_ConvertToString("APC Courier") );
|
||||
|
||||
// smDevanagari
|
||||
mGenericFontMapping[smDevanagari][kSerif] = new nsAutoString("Devanagari MT");
|
||||
mGenericFontMapping[smDevanagari][kSansSerif] = new nsAutoString("Devanagari MT");
|
||||
mGenericFontMapping[smDevanagari][kMonospace] = new nsAutoString("Devanagari MT");
|
||||
mGenericFontMapping[smDevanagari][kSerif] = new nsAutoString( NS_ConvertToString("Devanagari MT") );
|
||||
mGenericFontMapping[smDevanagari][kSansSerif] = new nsAutoString( NS_ConvertToString("Devanagari MT") );
|
||||
mGenericFontMapping[smDevanagari][kMonospace] = new nsAutoString( NS_ConvertToString("Devanagari MT") );
|
||||
|
||||
// smGurmukhi
|
||||
static nsAutoString gurukhiMT_str("Gurmukhi MT");
|
||||
mGenericFontMapping[smGurmukhi][kSerif] = new nsAutoString("Gurmukhi MT");
|
||||
mGenericFontMapping[smGurmukhi][kSansSerif] = new nsAutoString("Gurmukhi MT");
|
||||
mGenericFontMapping[smGurmukhi][kMonospace] = new nsAutoString("Gurmukhi MT");
|
||||
static nsAutoString gurukhiMT_str( NS_ConvertToString("Gurmukhi MT") );
|
||||
mGenericFontMapping[smGurmukhi][kSerif] = new nsAutoString( NS_ConvertToString("Gurmukhi MT") );
|
||||
mGenericFontMapping[smGurmukhi][kSansSerif] = new nsAutoString( NS_ConvertToString("Gurmukhi MT") );
|
||||
mGenericFontMapping[smGurmukhi][kMonospace] = new nsAutoString( NS_ConvertToString("Gurmukhi MT") );
|
||||
|
||||
// smGujarati
|
||||
mGenericFontMapping[smGujarati][kSerif] = new nsAutoString("Gujarati MT");
|
||||
mGenericFontMapping[smGujarati][kSansSerif] = new nsAutoString("Gujarati MT");
|
||||
mGenericFontMapping[smGujarati][kMonospace] = new nsAutoString("Gujarati MT");
|
||||
mGenericFontMapping[smGujarati][kSerif] = new nsAutoString( NS_ConvertToString("Gujarati MT") );
|
||||
mGenericFontMapping[smGujarati][kSansSerif] = new nsAutoString( NS_ConvertToString("Gujarati MT") );
|
||||
mGenericFontMapping[smGujarati][kMonospace] = new nsAutoString( NS_ConvertToString("Gujarati MT") );
|
||||
|
||||
// smThai
|
||||
mGenericFontMapping[smThai][kSerif] = new nsAutoString("Thonburi");
|
||||
mGenericFontMapping[smThai][kSansSerif] = new nsAutoString("Krungthep");
|
||||
mGenericFontMapping[smThai][kMonospace] = new nsAutoString("Ayuthaya");
|
||||
mGenericFontMapping[smThai][kSerif] = new nsAutoString( NS_ConvertToString("Thonburi") );
|
||||
mGenericFontMapping[smThai][kSansSerif] = new nsAutoString( NS_ConvertToString("Krungthep") );
|
||||
mGenericFontMapping[smThai][kMonospace] = new nsAutoString( NS_ConvertToString("Ayuthaya") );
|
||||
|
||||
// smSimpChinese
|
||||
mGenericFontMapping[smSimpChinese][kSerif] = new nsAutoString("Song");
|
||||
mGenericFontMapping[smSimpChinese][kSansSerif] = new nsAutoString("Hei");
|
||||
mGenericFontMapping[smSimpChinese][kMonospace] = new nsAutoString("Hei");
|
||||
mGenericFontMapping[smSimpChinese][kSerif] = new nsAutoString( NS_ConvertToString("Song") );
|
||||
mGenericFontMapping[smSimpChinese][kSansSerif] = new nsAutoString( NS_ConvertToString("Hei") );
|
||||
mGenericFontMapping[smSimpChinese][kMonospace] = new nsAutoString( NS_ConvertToString("Hei") );
|
||||
|
||||
// smCentralEuroRoman
|
||||
mGenericFontMapping[smCentralEuroRoman][kSerif] = new nsAutoString("Times CE");
|
||||
mGenericFontMapping[smCentralEuroRoman][kSansSerif] = new nsAutoString("Helvetica CE");
|
||||
mGenericFontMapping[smCentralEuroRoman][kMonospace] = new nsAutoString("Courier CE");
|
||||
mGenericFontMapping[smCentralEuroRoman][kSerif] = new nsAutoString( NS_ConvertToString("Times CE") );
|
||||
mGenericFontMapping[smCentralEuroRoman][kSansSerif] = new nsAutoString( NS_ConvertToString("Helvetica CE") );
|
||||
mGenericFontMapping[smCentralEuroRoman][kMonospace] = new nsAutoString( NS_ConvertToString("Courier CE") );
|
||||
}
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
@ -252,7 +252,8 @@ PrefEnumCallback(const char* aName, void* aClosure)
|
||||
if(script >= smUninterp)
|
||||
return;
|
||||
|
||||
nsGenericFontNameType type = Self->MapGenericFontNameType(genName);
|
||||
nsString genNameString; genNameString.AssignWithConversion(genName);
|
||||
nsGenericFontNameType type = Self->MapGenericFontNameType(genNameString);
|
||||
if(type >= kUknownGenericFontName)
|
||||
return;
|
||||
|
||||
|
@ -489,8 +489,7 @@ class FontAliasKey: public nsHashKey
|
||||
{
|
||||
public:
|
||||
FontAliasKey(const nsString& aString)
|
||||
: mString(aString)
|
||||
{}
|
||||
{mString.Assign(aString);}
|
||||
|
||||
virtual PRUint32 HashValue(void) const;
|
||||
virtual PRBool Equals(const nsHashKey *aKey) const;
|
||||
@ -529,15 +528,15 @@ nsresult DeviceContextImpl::CreateFontAliasTable()
|
||||
mFontAliasTable = new nsHashtable();
|
||||
if (nsnull != mFontAliasTable) {
|
||||
|
||||
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 times; times.AssignWithConversion("Times");
|
||||
nsAutoString timesNewRoman; timesNewRoman.AssignWithConversion("Times New Roman");
|
||||
nsAutoString timesRoman; timesRoman.AssignWithConversion("Times Roman");
|
||||
nsAutoString arial; arial.AssignWithConversion("Arial");
|
||||
nsAutoString helvetica; helvetica.AssignWithConversion("Helvetica");
|
||||
nsAutoString courier; courier.AssignWithConversion("Courier");
|
||||
nsAutoString courierNew; courierNew.AssignWithConversion("Courier New");
|
||||
nsAutoString unicode; unicode.AssignWithConversion("Unicode");
|
||||
nsAutoString bitstreamCyberbit; bitstreamCyberbit.AssignWithConversion("Bitstream Cyberbit");
|
||||
nsAutoString nullStr;
|
||||
|
||||
AliasFont(times, timesNewRoman, timesRoman, PR_FALSE);
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
nsFont::nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize)
|
||||
: name(aName)
|
||||
{
|
||||
name.AssignWithConversion(aName);
|
||||
style = aStyle;
|
||||
variant = aVariant;
|
||||
weight = aWeight;
|
||||
|
@ -195,15 +195,15 @@ FILE* operator<<(FILE* out, const nsRect& rect)
|
||||
nsAutoString tmp;
|
||||
|
||||
// Output the coordinates in fractional points so they're easier to read
|
||||
tmp.Append("{");
|
||||
tmp.Append(NSTwipsToFloatPoints(rect.x));
|
||||
tmp.Append(", ");
|
||||
tmp.Append(NSTwipsToFloatPoints(rect.y));
|
||||
tmp.Append(", ");
|
||||
tmp.Append(NSTwipsToFloatPoints(rect.width));
|
||||
tmp.Append(", ");
|
||||
tmp.Append(NSTwipsToFloatPoints(rect.height));
|
||||
tmp.Append("}");
|
||||
tmp.AppendWithConversion("{");
|
||||
tmp.AppendWithConversion(NSTwipsToFloatPoints(rect.x));
|
||||
tmp.AppendWithConversion(", ");
|
||||
tmp.AppendWithConversion(NSTwipsToFloatPoints(rect.y));
|
||||
tmp.AppendWithConversion(", ");
|
||||
tmp.AppendWithConversion(NSTwipsToFloatPoints(rect.width));
|
||||
tmp.AppendWithConversion(", ");
|
||||
tmp.AppendWithConversion(NSTwipsToFloatPoints(rect.height));
|
||||
tmp.AppendWithConversion("}");
|
||||
fputs(tmp, out);
|
||||
return out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user