Backed out changeset 33c17daf66bf (bug 879963)

This commit is contained in:
Ed Morley 2013-07-17 17:07:30 +01:00
parent b5f2102f6f
commit 01e793a3a4
3 changed files with 10 additions and 89 deletions

View File

@ -45,7 +45,7 @@ static uint64_t sFontSetGeneration = 0;
gfxProxyFontEntry::gfxProxyFontEntry(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
@ -60,8 +60,6 @@ gfxProxyFontEntry::gfxProxyFontEntry(const nsTArray<gfxFontFaceSrc>& aFontFaceSr
mSrcIndex = 0;
mWeight = aWeight;
mStretch = aStretch;
// XXX Currently, we don't distinguish 'italic' and 'oblique' styles;
// we need to fix this. (Bug 543715)
mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0;
mFeatureSettings.AppendElements(aFeatureSettings);
mLanguageOverride = aLanguageOverride;
@ -72,29 +70,6 @@ gfxProxyFontEntry::~gfxProxyFontEntry()
{
}
bool
gfxProxyFontEntry::Matches(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges)
{
// XXX font entries don't distinguish italic from oblique (bug 543715)
bool isItalic =
(aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0;
return mWeight == aWeight &&
mStretch == aStretch &&
mItalic == isItalic &&
mFeatureSettings == aFeatureSettings &&
mLanguageOverride == aLanguageOverride &&
mSrcList == aFontFaceSrcList;
// XXX once we support unicode-range (bug 475891),
// we'll need to compare that here as well
}
gfxFont*
gfxProxyFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold)
{
@ -116,12 +91,14 @@ gfxFontEntry*
gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
const nsString& aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges)
{
gfxProxyFontEntry *proxyEntry = nullptr;
nsAutoString key(aFamilyName);
ToLowerCase(key);
@ -138,42 +115,10 @@ gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
mFontFamilies.Put(key, family);
}
// construct a new face and add it into the family
uint32_t languageOverride =
gfxFontStyle::ParseFontLanguageOverride(aLanguageOverride);
// If there's already a proxy in the family whose descriptors all match,
// we can just move it to the end of the list instead of adding a new
// face that will always "shadow" the old one.
// Note that we can't do this for "real" (non-proxy) entries, even if the
// style descriptors match, as they might have had a different source list,
// but we no longer have the old source list available to check.
nsTArray<nsRefPtr<gfxFontEntry> >& fontList = family->GetFontList();
for (uint32_t i = 0, count = fontList.Length(); i < count; i++) {
if (!fontList[i]->mIsProxy) {
continue;
}
gfxProxyFontEntry *existingProxyEntry =
static_cast<gfxProxyFontEntry*>(fontList[i].get());
if (!existingProxyEntry->Matches(aFontFaceSrcList,
aWeight, aStretch, aItalicStyle,
aFeatureSettings, languageOverride,
aUnicodeRanges)) {
continue;
}
// We've found an entry that matches the new face exactly, so advance
// it to the end of the list.
// (Hold a strong reference while doing this, in case the only thing
// keeping the proxyFontEntry alive is the reference from family!)
nsRefPtr<gfxFontEntry> ref(existingProxyEntry);
family->RemoveFontEntry(existingProxyEntry);
family->AddFontEntry(existingProxyEntry);
return existingProxyEntry;
}
// construct a new face and add it into the family
gfxProxyFontEntry *proxyEntry =
proxyEntry =
new gfxProxyFontEntry(aFontFaceSrcList, aWeight, aStretch,
aItalicStyle,
aFeatureSettings,

View File

@ -41,20 +41,6 @@ struct gfxFontFaceSrc {
nsCOMPtr<nsIPrincipal> mOriginPrincipal; // principal if url
};
inline bool
operator==(const gfxFontFaceSrc& a, const gfxFontFaceSrc& b)
{
bool equals;
return (a.mIsLocal && b.mIsLocal &&
a.mLocalName == b.mLocalName) ||
(!a.mIsLocal && !b.mIsLocal &&
a.mUseOriginPrincipal == b.mUseOriginPrincipal &&
a.mFormatFlags == b.mFormatFlags &&
NS_SUCCEEDED(a.mURI->Equals(b.mURI, &equals)) && equals &&
NS_SUCCEEDED(a.mReferrer->Equals(b.mReferrer, &equals)) && equals &&
a.mOriginPrincipal->Equals(b.mOriginPrincipal));
}
// Subclassed to store platform-specific code cleaned out when font entry is
// deleted.
// Lifetime: from when platform font is created until it is deactivated.
@ -182,14 +168,13 @@ public:
// add in a font face
// weight - 0 == unknown, [100, 900] otherwise (multiples of 100)
// stretch = [NS_FONT_STRETCH_ULTRA_CONDENSED, NS_FONT_STRETCH_ULTRA_EXPANDED]
// weight, stretch - 0 == unknown, [1, 9] otherwise
// italic style = constants in gfxFontConstants.h, e.g. NS_FONT_STYLE_NORMAL
// TODO: support for unicode ranges not yet implemented
gfxFontEntry *AddFontFace(const nsAString& aFamilyName,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
const nsString& aLanguageOverride,
@ -443,7 +428,7 @@ class gfxProxyFontEntry : public gfxFontEntry {
public:
gfxProxyFontEntry(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
@ -451,15 +436,6 @@ public:
virtual ~gfxProxyFontEntry();
// Return whether the entry matches the given list of attributes
bool Matches(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges);
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
// note that code depends on the ordering of these values!

View File

@ -530,7 +530,7 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule *aRule, uint8_t aSheetType,
// this is a new rule:
uint32_t weight = NS_STYLE_FONT_WEIGHT_NORMAL;
int32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL;
uint32_t stretch = NS_STYLE_FONT_STRETCH_NORMAL;
uint32_t italicStyle = NS_STYLE_FONT_STYLE_NORMAL;
nsString languageOverride;