зеркало из https://github.com/mozilla/gecko-dev.git
Bug 97299: Store font names in lowercase. r=pavlov, sr=attinasi
This commit is contained in:
Родитель
22a4b2a9f5
Коммит
a230194a5b
|
@ -1598,6 +1598,7 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
|
|||
if (dc) {
|
||||
nsAutoString familyList;
|
||||
fontData.mFamily.GetStringValue(familyList);
|
||||
familyList.ToLowerCase();
|
||||
font->mFont.name = familyList;
|
||||
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
|
||||
// MJA: bug 31816
|
||||
PRBool isMozFixed = font->mFont.name.EqualsIgnoreCase("-moz-fixed");
|
||||
PRBool isMozFixed = font->mFont.name.EqualsWithConversion("-moz-fixed");
|
||||
if (chromeOverride || useDocumentFonts) {
|
||||
font->mFont.name += nsAutoString(NS_LITERAL_STRING(",")) + defaultFont.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.variant == aFont2.variant) &&
|
||||
(aFont1.weight == aFont2.weight) &&
|
||||
(aFont1.name == aFont2.name)) {
|
||||
(aFont1.name.Equals(aFont2.name))) {
|
||||
if ((aFont1.decorations == aFont2.decorations)) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,9 @@
|
|||
typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
|
||||
|
||||
// Font structure.
|
||||
struct NS_GFX nsFont {
|
||||
// The family name of the font
|
||||
class nsFont {
|
||||
public:
|
||||
// The family name of the font -- MUST be in lowercase!
|
||||
nsString name;
|
||||
|
||||
// The style of font (normal, italic, oblique)
|
||||
|
@ -65,7 +66,12 @@ struct NS_GFX nsFont {
|
|||
// Make a copy of the given font
|
||||
nsFont(const nsFont& aFont);
|
||||
|
||||
#ifdef DEBUG
|
||||
// so we can set breakpoints on creation/deletion
|
||||
nsFont();
|
||||
|
||||
~nsFont();
|
||||
#endif
|
||||
|
||||
PRBool operator==(const nsFont& aOther) const {
|
||||
return Equals(aOther);
|
||||
|
|
|
@ -615,6 +615,7 @@ nsDeviceContextGTK::GetSystemFontInfo( GdkFont* iFont, nsSystemAttrID anID, nsFo
|
|||
{
|
||||
fontName = XGetAtomName( fontPrivate->xdisplay, pr );
|
||||
aFont->name.AssignWithConversion( fontName );
|
||||
aFont->name.ToLowerCase();
|
||||
::XFree( fontName );
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ nsFont::nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
|||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize)
|
||||
{
|
||||
name.AssignWithConversion(aName);
|
||||
name.ToLowerCase();
|
||||
style = aStyle;
|
||||
variant = aVariant;
|
||||
weight = aWeight;
|
||||
|
@ -38,6 +39,7 @@ nsFont::nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
|||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize)
|
||||
: name(aName)
|
||||
{
|
||||
name.ToLowerCase();
|
||||
style = aStyle;
|
||||
variant = aVariant;
|
||||
weight = aWeight;
|
||||
|
@ -48,6 +50,11 @@ nsFont::nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
|||
nsFont::nsFont(const nsFont& aOther)
|
||||
: 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;
|
||||
variant = aOther.variant;
|
||||
weight = aOther.weight;
|
||||
|
@ -55,9 +62,16 @@ nsFont::nsFont(const nsFont& aOther)
|
|||
size = aOther.size;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// so we can set breakpoints on creation/deletion
|
||||
nsFont::nsFont()
|
||||
{
|
||||
}
|
||||
|
||||
nsFont::~nsFont()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool nsFont::Equals(const nsFont& aOther) const
|
||||
{
|
||||
|
@ -66,7 +80,7 @@ PRBool nsFont::Equals(const nsFont& aOther) const
|
|||
(weight == aOther.weight) &&
|
||||
(decorations == aOther.decorations) &&
|
||||
(size == aOther.size) &&
|
||||
name.EqualsIgnoreCase(aOther.name)) {
|
||||
name.Equals(aOther.name)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
|
@ -74,7 +88,12 @@ PRBool nsFont::Equals(const nsFont& aOther) const
|
|||
|
||||
nsFont& nsFont::operator=(const nsFont& aOther)
|
||||
{
|
||||
// name should be lowercase
|
||||
name = aOther.name;
|
||||
#ifdef DEBUG
|
||||
name.ToLowerCase();
|
||||
NS_ASSERTION(name.Equals(aOther.name),"nsFont name wasn't lowercase");
|
||||
#endif
|
||||
style = aOther.style;
|
||||
variant = aOther.variant;
|
||||
weight = aOther.weight;
|
||||
|
|
|
@ -152,6 +152,7 @@ nsPrintOptions::SetFontNamePointSize(nsString& aFontName, PRInt32 aPointSize)
|
|||
{
|
||||
if (mDefaultFont != nsnull && aFontName.Length() > 0 && aPointSize > 0) {
|
||||
mDefaultFont->name = aFontName;
|
||||
mDefaultFont->name.ToLowerCase();
|
||||
mDefaultFont->size = NSIntPointsToTwips(aPointSize);
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -331,6 +331,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetSystemAttribute(nsSystemAttrID anID, Syste
|
|||
{
|
||||
fontName = XGetAtomName(mDisplay, pr);
|
||||
aInfo->mFont->name.AssignWithConversion(fontName);
|
||||
aInfo->mFont->name.ToLowerCase();
|
||||
::XFree(fontName);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,6 +212,7 @@ nsPresContext::GetFontPreferences()
|
|||
mPrefs->CopyCharPref("font.default", &value);
|
||||
if (value) {
|
||||
mDefaultFont.name.AssignWithConversion(value);
|
||||
mDefaultFont.name.ToLowerCase();
|
||||
nsMemory::Free(value);
|
||||
value = nsnull;
|
||||
}
|
||||
|
|
|
@ -212,6 +212,7 @@ nsPresContext::GetFontPreferences()
|
|||
mPrefs->CopyCharPref("font.default", &value);
|
||||
if (value) {
|
||||
mDefaultFont.name.AssignWithConversion(value);
|
||||
mDefaultFont.name.ToLowerCase();
|
||||
nsMemory::Free(value);
|
||||
value = nsnull;
|
||||
}
|
||||
|
|
|
@ -628,13 +628,13 @@ nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame,
|
|||
aFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight
|
||||
aFont.size = styleFont->mFont.size; // normal font size
|
||||
if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) {
|
||||
aFont.name = "Arial"; // XXX windows specific font
|
||||
aFont.name = "arial"; // XXX windows specific font
|
||||
}
|
||||
} else {
|
||||
// use arial, scaled down one HTML size
|
||||
// italics, decoration & variant(?) get used
|
||||
aFont = styleFont->mFont;
|
||||
aFont.name = "Arial"; // XXX windows specific font
|
||||
aFont.name = "arial"; // XXX windows specific font
|
||||
aFont.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
const nsFont& normal = aPresContext->GetDefaultFontDeprecated();
|
||||
PRInt32 scaler;
|
||||
|
|
|
@ -628,13 +628,13 @@ nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame,
|
|||
aFont.weight = NS_FONT_WEIGHT_NORMAL; // always normal weight
|
||||
aFont.size = styleFont->mFont.size; // normal font size
|
||||
if (0 == (styleFont->mFlags & NS_STYLE_FONT_FACE_EXPLICIT)) {
|
||||
aFont.name = "Arial"; // XXX windows specific font
|
||||
aFont.name = "arial"; // XXX windows specific font
|
||||
}
|
||||
} else {
|
||||
// use arial, scaled down one HTML size
|
||||
// italics, decoration & variant(?) get used
|
||||
aFont = styleFont->mFont;
|
||||
aFont.name = "Arial"; // XXX windows specific font
|
||||
aFont.name = "arial"; // XXX windows specific font
|
||||
aFont.weight = NS_FONT_WEIGHT_NORMAL;
|
||||
const nsFont& normal = aPresContext->GetDefaultFontDeprecated();
|
||||
PRInt32 scaler;
|
||||
|
|
|
@ -1276,6 +1276,7 @@ SetFirstFamily(nsFont& aFont, const nsString& aFamily)
|
|||
{
|
||||
// overwrite the old value of font-family:
|
||||
aFont.name.Assign(aFamily);
|
||||
aFont.name.ToLowerCase();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -222,7 +222,7 @@ PRInt32 nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFon
|
|||
(aFont1.style == aFont2.style) &&
|
||||
(aFont1.variant == aFont2.variant) &&
|
||||
(aFont1.weight == aFont2.weight) &&
|
||||
(aFont1.name == aFont2.name)) {
|
||||
(aFont1.name.Equals(aFont2.name))) {
|
||||
if ((aFont1.decorations == aFont2.decorations)) {
|
||||
return NS_STYLE_HINT_NONE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче