Bug 97299: Store font names in lowercase. r=pavlov, sr=attinasi

This commit is contained in:
rjesup%wgate.com 2001-09-24 07:35:04 +00:00
Родитель 22a4b2a9f5
Коммит a230194a5b
13 изменённых файлов: 42 добавлений и 10 удалений

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

@ -1598,6 +1598,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
if (dc) { if (dc) {
nsAutoString familyList; nsAutoString familyList;
fontData.mFamily.GetStringValue(familyList); fontData.mFamily.GetStringValue(familyList);
familyList.ToLowerCase();
font->mFont.name = familyList; font->mFont.name = familyList;
nsAutoString face; nsAutoString face;
@ -1639,7 +1640,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
// find the correct font if we are usingDocumentFonts OR we are overriding for XUL // find the correct font if we are usingDocumentFonts OR we are overriding for XUL
// MJA: bug 31816 // MJA: bug 31816
PRBool isMozFixed = font->mFont.name.EqualsIgnoreCase("-moz-fixed"); PRBool isMozFixed = font->mFont.name.EqualsWithConversion("-moz-fixed");
if (chromeOverride || useDocumentFonts) { if (chromeOverride || useDocumentFonts) {
font->mFont.name += nsAutoString(NS_LITERAL_STRING(",")) + defaultFont.name; font->mFont.name += nsAutoString(NS_LITERAL_STRING(",")) + defaultFont.name;
font->mFixedFont.name += nsAutoString(NS_LITERAL_STRING(",")) + defaultFixedFont.name; font->mFixedFont.name += nsAutoString(NS_LITERAL_STRING(",")) + defaultFixedFont.name;

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

@ -222,7 +222,7 @@ PRInt32 nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFon
(aFont1.style == aFont2.style) && (aFont1.style == aFont2.style) &&
(aFont1.variant == aFont2.variant) && (aFont1.variant == aFont2.variant) &&
(aFont1.weight == aFont2.weight) && (aFont1.weight == aFont2.weight) &&
(aFont1.name == aFont2.name)) { (aFont1.name.Equals(aFont2.name))) {
if ((aFont1.decorations == aFont2.decorations)) { if ((aFont1.decorations == aFont2.decorations)) {
return NS_STYLE_HINT_NONE; return NS_STYLE_HINT_NONE;
} }

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

@ -34,8 +34,9 @@
typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData); typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
// Font structure. // Font structure.
struct NS_GFX nsFont { class nsFont {
// The family name of the font public:
// The family name of the font -- MUST be in lowercase!
nsString name; nsString name;
// The style of font (normal, italic, oblique) // The style of font (normal, italic, oblique)
@ -65,7 +66,12 @@ struct NS_GFX nsFont {
// Make a copy of the given font // Make a copy of the given font
nsFont(const nsFont& aFont); nsFont(const nsFont& aFont);
#ifdef DEBUG
// so we can set breakpoints on creation/deletion
nsFont();
~nsFont(); ~nsFont();
#endif
PRBool operator==(const nsFont& aOther) const { PRBool operator==(const nsFont& aOther) const {
return Equals(aOther); return Equals(aOther);

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

@ -615,6 +615,7 @@ nsDeviceContextGTK::GetSystemFontInfo( GdkFont* iFont, nsSystemAttrID anID, nsFo
{ {
fontName = XGetAtomName( fontPrivate->xdisplay, pr ); fontName = XGetAtomName( fontPrivate->xdisplay, pr );
aFont->name.AssignWithConversion( fontName ); aFont->name.AssignWithConversion( fontName );
aFont->name.ToLowerCase();
::XFree( fontName ); ::XFree( fontName );
} }

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

@ -27,6 +27,7 @@ nsFont::nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize) PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize)
{ {
name.AssignWithConversion(aName); name.AssignWithConversion(aName);
name.ToLowerCase();
style = aStyle; style = aStyle;
variant = aVariant; variant = aVariant;
weight = aWeight; weight = aWeight;
@ -38,6 +39,7 @@ nsFont::nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize) PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize)
: name(aName) : name(aName)
{ {
name.ToLowerCase();
style = aStyle; style = aStyle;
variant = aVariant; variant = aVariant;
weight = aWeight; weight = aWeight;
@ -48,6 +50,11 @@ nsFont::nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
nsFont::nsFont(const nsFont& aOther) nsFont::nsFont(const nsFont& aOther)
: name(aOther.name) : name(aOther.name)
{ {
// name should be lowercase already
#ifdef DEBUG
name.ToLowerCase();
NS_ASSERTION(name.Equals(aOther.name),"nsFont name wasn't lowercase");
#endif
style = aOther.style; style = aOther.style;
variant = aOther.variant; variant = aOther.variant;
weight = aOther.weight; weight = aOther.weight;
@ -55,9 +62,16 @@ nsFont::nsFont(const nsFont& aOther)
size = aOther.size; size = aOther.size;
} }
#ifdef DEBUG
// so we can set breakpoints on creation/deletion
nsFont::nsFont()
{
}
nsFont::~nsFont() nsFont::~nsFont()
{ {
} }
#endif
PRBool nsFont::Equals(const nsFont& aOther) const PRBool nsFont::Equals(const nsFont& aOther) const
{ {
@ -66,7 +80,7 @@ PRBool nsFont::Equals(const nsFont& aOther) const
(weight == aOther.weight) && (weight == aOther.weight) &&
(decorations == aOther.decorations) && (decorations == aOther.decorations) &&
(size == aOther.size) && (size == aOther.size) &&
name.EqualsIgnoreCase(aOther.name)) { name.Equals(aOther.name)) {
return PR_TRUE; return PR_TRUE;
} }
return PR_FALSE; return PR_FALSE;
@ -74,7 +88,12 @@ PRBool nsFont::Equals(const nsFont& aOther) const
nsFont& nsFont::operator=(const nsFont& aOther) nsFont& nsFont::operator=(const nsFont& aOther)
{ {
// name should be lowercase
name = aOther.name; name = aOther.name;
#ifdef DEBUG
name.ToLowerCase();
NS_ASSERTION(name.Equals(aOther.name),"nsFont name wasn't lowercase");
#endif
style = aOther.style; style = aOther.style;
variant = aOther.variant; variant = aOther.variant;
weight = aOther.weight; weight = aOther.weight;

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

@ -152,6 +152,7 @@ nsPrintOptions::SetFontNamePointSize(nsString& aFontName, PRInt32 aPointSize)
{ {
if (mDefaultFont != nsnull && aFontName.Length() > 0 && aPointSize > 0) { if (mDefaultFont != nsnull && aFontName.Length() > 0 && aPointSize > 0) {
mDefaultFont->name = aFontName; mDefaultFont->name = aFontName;
mDefaultFont->name.ToLowerCase();
mDefaultFont->size = NSIntPointsToTwips(aPointSize); mDefaultFont->size = NSIntPointsToTwips(aPointSize);
} }
return NS_OK; return NS_OK;

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

@ -331,6 +331,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetSystemAttribute(nsSystemAttrID anID, Syste
{ {
fontName = XGetAtomName(mDisplay, pr); fontName = XGetAtomName(mDisplay, pr);
aInfo->mFont->name.AssignWithConversion(fontName); aInfo->mFont->name.AssignWithConversion(fontName);
aInfo->mFont->name.ToLowerCase();
::XFree(fontName); ::XFree(fontName);
} }

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

@ -212,6 +212,7 @@ nsPresContext::GetFontPreferences()
mPrefs->CopyCharPref("font.default", &value); mPrefs->CopyCharPref("font.default", &value);
if (value) { if (value) {
mDefaultFont.name.AssignWithConversion(value); mDefaultFont.name.AssignWithConversion(value);
mDefaultFont.name.ToLowerCase();
nsMemory::Free(value); nsMemory::Free(value);
value = nsnull; value = nsnull;
} }

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

@ -212,6 +212,7 @@ nsPresContext::GetFontPreferences()
mPrefs->CopyCharPref("font.default", &value); mPrefs->CopyCharPref("font.default", &value);
if (value) { if (value) {
mDefaultFont.name.AssignWithConversion(value); mDefaultFont.name.AssignWithConversion(value);
mDefaultFont.name.ToLowerCase();
nsMemory::Free(value); nsMemory::Free(value);
value = nsnull; value = nsnull;
} }

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

@ -628,13 +628,13 @@ nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame,
aFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight aFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight
aFont.size = styleFont->mFont.size; // normal font size aFont.size = styleFont->mFont.size; // normal font size
if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) { if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) {
aFont.name = "Arial"; // XXX windows specific font aFont.name = "arial"; // XXX windows specific font
} }
} else { } else {
// use arial, scaled down one HTML size // use arial, scaled down one HTML size
// italics, decoration & variant(?) get used // italics, decoration & variant(?) get used
aFont = styleFont->mFont; aFont = styleFont->mFont;
aFont.name = "Arial"; // XXX windows specific font aFont.name = "arial"; // XXX windows specific font
aFont.weight = NS_FONT_WEIGHT_NORMAL; aFont.weight = NS_FONT_WEIGHT_NORMAL;
const nsFont& normal = aPresContext->GetDefaultFontDeprecated(); const nsFont& normal = aPresContext->GetDefaultFontDeprecated();
PRInt32 scaler; PRInt32 scaler;

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

@ -628,13 +628,13 @@ nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame,
aFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight aFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight
aFont.size = styleFont->mFont.size; // normal font size aFont.size = styleFont->mFont.size; // normal font size
if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) { if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) {
aFont.name = "Arial"; // XXX windows specific font aFont.name = "arial"; // XXX windows specific font
} }
} else { } else {
// use arial, scaled down one HTML size // use arial, scaled down one HTML size
// italics, decoration & variant(?) get used // italics, decoration & variant(?) get used
aFont = styleFont->mFont; aFont = styleFont->mFont;
aFont.name = "Arial"; // XXX windows specific font aFont.name = "arial"; // XXX windows specific font
aFont.weight = NS_FONT_WEIGHT_NORMAL; aFont.weight = NS_FONT_WEIGHT_NORMAL;
const nsFont& normal = aPresContext->GetDefaultFontDeprecated(); const nsFont& normal = aPresContext->GetDefaultFontDeprecated();
PRInt32 scaler; PRInt32 scaler;

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

@ -1276,6 +1276,7 @@ SetFirstFamily(nsFont& aFont, const nsString& aFamily)
{ {
// overwrite the old value of font-family: // overwrite the old value of font-family:
aFont.name.Assign(aFamily); aFont.name.Assign(aFamily);
aFont.name.ToLowerCase();
} }
nsresult nsresult

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

@ -222,7 +222,7 @@ PRInt32 nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFon
(aFont1.style == aFont2.style) && (aFont1.style == aFont2.style) &&
(aFont1.variant == aFont2.variant) && (aFont1.variant == aFont2.variant) &&
(aFont1.weight == aFont2.weight) && (aFont1.weight == aFont2.weight) &&
(aFont1.name == aFont2.name)) { (aFont1.name.Equals(aFont2.name))) {
if ((aFont1.decorations == aFont2.decorations)) { if ((aFont1.decorations == aFont2.decorations)) {
return NS_STYLE_HINT_NONE; return NS_STYLE_HINT_NONE;
} }