Bug 1062058 part 2 - rename userfont classes and adjust flags. r=heycam

This commit is contained in:
John Daggett 2014-09-08 16:23:20 +09:00
parent 6a628f87a7
commit 4152f3896a
12 changed files with 226 additions and 222 deletions

View File

@ -114,7 +114,6 @@ public:
mWeight = aWeight;
mStretch = aStretch;
mItalic = aItalic;
mIsUserFont = true;
mIsLocalUserFont = true;
mIsCJK = UNINITIALIZED_VALUE;
}
@ -139,7 +138,7 @@ public:
mWeight = aWeight;
mStretch = aStretch;
mItalic = aItalic;
mIsUserFont = true;
mIsDataUserFont = true;
mIsCJK = UNINITIALIZED_VALUE;
}

View File

@ -276,7 +276,7 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
NS_Free((void*)aFontData);
return nullptr;
}
// Create our FT2FontEntry, which inherits the name of the proxy
// Create our FT2FontEntry, which inherits the name of the userfont entry
// as it's not guaranteed that the face has valid names (bug 737315)
FT2FontEntry* fe =
FT2FontEntry::CreateFontEntry(face, nullptr, 0, aFontName,
@ -285,7 +285,7 @@ FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
fe->mItalic = aItalic;
fe->mWeight = aWeight;
fe->mStretch = aStretch;
fe->mIsUserFont = true;
fe->mIsDataUserFont = true;
}
return fe;
}
@ -1529,7 +1529,7 @@ gfxFT2FontList::LookupLocalFont(const nsAString& aFontName,
}
// Clone the font entry so that we can then set its style descriptors
// from the proxy rather than the actual font.
// from the userfont entry rather than the actual font.
// Ensure existence of mFTFace in the original entry
data.mFontEntry->CairoFontFace();
@ -1546,7 +1546,7 @@ gfxFT2FontList::LookupLocalFont(const nsAString& aFontName,
fe->mItalic = aItalic;
fe->mWeight = aWeight;
fe->mStretch = aStretch;
fe->mIsUserFont = fe->mIsLocalUserFont = true;
fe->mIsLocalUserFont = true;
}
return fe;

View File

@ -111,9 +111,10 @@ gfxCharacterMap::NotifyReleased()
gfxFontEntry::gfxFontEntry() :
mItalic(false), mFixedPitch(false),
mIsProxy(false), mIsValid(true),
mIsValid(true),
mIsBadUnderlineFont(false),
mIsUserFont(false),
mIsUserFontContainer(false),
mIsDataUserFont(false),
mIsLocalUserFont(false),
mStandardFace(false),
mSymbolFont(false),
@ -146,8 +147,10 @@ gfxFontEntry::gfxFontEntry() :
gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) :
mName(aName), mItalic(false), mFixedPitch(false),
mIsProxy(false), mIsValid(true),
mIsBadUnderlineFont(false), mIsUserFont(false),
mIsValid(true),
mIsBadUnderlineFont(false),
mIsUserFontContainer(false),
mIsDataUserFont(false),
mIsLocalUserFont(false), mStandardFace(aIsStandardFace),
mSymbolFont(false),
mIgnoreGDEF(false),
@ -196,7 +199,7 @@ gfxFontEntry::~gfxFontEntry()
// For downloaded fonts, we need to tell the user font cache that this
// entry is being deleted.
if (!mIsProxy && IsUserFont() && !IsLocalUserFont()) {
if (mIsDataUserFont) {
gfxUserFontSet::UserFontCache::ForgetFont(this);
}
@ -1797,7 +1800,7 @@ gfxFontFamily::ReadAllCMAPs(FontInfoData *aFontInfoData)
for (i = 0; i < numFonts; i++) {
gfxFontEntry *fe = mAvailableFonts[i];
// don't try to load cmaps for downloadable fonts not yet loaded
if (!fe || fe->mIsProxy) {
if (!fe || fe->mIsUserFontContainer) {
continue;
}
fe->ReadCMAP(aFontInfoData);

View File

@ -288,7 +288,7 @@ public:
uint16_t Weight() const { return mWeight; }
int16_t Stretch() const { return mStretch; }
bool IsUserFont() const { return mIsUserFont; }
bool IsUserFont() const { return mIsDataUserFont || mIsLocalUserFont; }
bool IsLocalUserFont() const { return mIsLocalUserFont; }
bool IsFixedPitch() const { return mFixedPitch; }
bool IsItalic() const { return mItalic; }
@ -337,7 +337,7 @@ public:
nsresult InitializeUVSMap();
uint16_t GetUVSGlyph(uint32_t aCh, uint32_t aVS);
// All concrete gfxFontEntry subclasses (except gfxProxyFontEntry) need
// All concrete gfxFontEntry subclasses (except gfxUserFontEntry) need
// to override this, otherwise the font will never be used as it will
// be considered to support no characters.
// ReadCMAP() must *always* set the mCharacterMap pointer to a valid
@ -555,11 +555,11 @@ public:
bool mItalic : 1;
bool mFixedPitch : 1;
bool mIsProxy : 1;
bool mIsValid : 1;
bool mIsBadUnderlineFont : 1;
bool mIsUserFont : 1;
bool mIsLocalUserFont : 1;
bool mIsUserFontContainer : 1;
bool mIsDataUserFont : 1;
bool mIsLocalUserFont : 1;
bool mStandardFace : 1;
bool mSymbolFont : 1;
bool mIgnoreGDEF : 1;

View File

@ -140,7 +140,7 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
mStretch = aStretch;
if (IsType1())
mForceGDI = true;
mIsUserFont = aUserFontData != nullptr;
mIsDataUserFont = aUserFontData != nullptr;
InitLogFont(aFaceName, aFontType);
}
@ -229,7 +229,7 @@ GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, bool aNeedsBold
bool useClearType = isXP && !aFontStyle->systemFont &&
(gfxWindowsPlatform::GetPlatform()->UseClearTypeAlways() ||
(mIsUserFont && !mIsLocalUserFont &&
(mIsDataUserFont &&
gfxWindowsPlatform::GetPlatform()->UseClearTypeForDownloadableFonts()));
return new gfxGDIFont(this, aFontStyle, aNeedsBold,
@ -291,7 +291,7 @@ GDIFontEntry::FillLogFont(LOGFONTW *aLogFont,
// if the face is described as italic, we should use it as-is,
// and if it's not, but then the element is styled italic, we'll use
// a cairo transform to create fake italic (oblique)
if (IsUserFont() && !IsLocalUserFont()) {
if (mIsDataUserFont) {
aLogFont->lfItalic = 0;
}
@ -751,10 +751,9 @@ gfxGDIFontList::LookupLocalFont(const nsAString& aFontName,
if (!fe)
return nullptr;
fe->mIsUserFont = true;
fe->mIsLocalUserFont = true;
// make the new font entry match the proxy entry style characteristics
// make the new font entry match the userfont entry style characteristics
fe->mWeight = (aWeight == 0 ? 400 : aWeight);
fe->mItalic = aItalic;
@ -832,7 +831,7 @@ gfxGDIFontList::MakePlatformFont(const nsAString& aFontName,
if (!fe)
return fe;
fe->mIsUserFont = true;
fe->mIsDataUserFont = true;
// Uniscribe doesn't place CFF fonts loaded privately
// via AddFontMemResourceEx on XP/Vista

View File

@ -33,7 +33,7 @@ public:
// for use with data fonts
MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle,
bool aIsUserFont, bool aIsLocal);
bool aIsDataUserFont, bool aIsLocal);
virtual ~MacOSFontEntry() {
::CGFontRelease(mFontRef);

View File

@ -291,7 +291,8 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
CGFontRef aFontRef,
uint16_t aWeight, uint16_t aStretch,
uint32_t aItalicStyle,
bool aIsUserFont, bool aIsLocal)
bool aIsDataUserFont,
bool aIsLocalUserFont)
: gfxFontEntry(aPostscriptName, false),
mFontRef(NULL),
mFontRefInitialized(false),
@ -307,8 +308,11 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
mStretch = aStretch;
mFixedPitch = false; // xxx - do we need this for downloaded fonts?
mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0;
mIsUserFont = aIsUserFont;
mIsLocalUserFont = aIsLocal;
NS_ASSERTION(!(aIsDataUserFont && aIsLocalUserFont),
"userfont is either a data font or a local font");
mIsDataUserFont = aIsDataUserFont;
mIsLocalUserFont = aIsLocalUserFont;
}
CGFontRef
@ -742,8 +746,7 @@ gfxMacPlatformFontList::InitSingleFaceList()
if (!mFontFamilies.GetWeak(key)) {
gfxFontFamily *familyEntry =
new gfxSingleFaceMacFontFamily(familyName);
// LookupLocalFont sets these to true, need to clear
fontEntry->mIsUserFont = false;
// LookupLocalFont sets this, need to clear
fontEntry->mIsLocalUserFont = false;
familyEntry->AddFontEntry(fontEntry);
familyEntry->SetHasStyles(true);
@ -933,7 +936,7 @@ gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName,
aWeight, aStretch,
aItalic ?
NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL,
true, true);
false, true);
::CFRelease(fontRef);
return newFontEntry;

View File

@ -335,7 +335,6 @@ protected:
mItalic = aItalic;
mWeight = aWeight;
mStretch = aStretch;
mIsUserFont = true;
}
// Helper function to change a pattern so that it matches the CSS style
@ -458,6 +457,7 @@ public:
mFontData(aData), mFace(aFace)
{
NS_PRECONDITION(aFace != nullptr, "aFace is NULL!");
mIsDataUserFont = true;
InitPattern();
}

View File

@ -111,7 +111,7 @@ private:
// TODO: support for unicode ranges not yet implemented
gfxProxyFontEntry::gfxProxyFontEntry(gfxUserFontSet *aFontSet,
gfxUserFontEntry::gfxUserFontEntry(gfxUserFontSet *aFontSet,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
@ -119,13 +119,13 @@ gfxProxyFontEntry::gfxProxyFontEntry(gfxUserFontSet *aFontSet,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges)
: gfxFontEntry(NS_LITERAL_STRING("Proxy")),
: gfxFontEntry(NS_LITERAL_STRING("userfont")),
mLoadingState(NOT_LOADING),
mUnsupportedFormat(false),
mLoader(nullptr),
mFontSet(aFontSet)
{
mIsProxy = true;
mIsUserFontContainer = true;
mSrcList = aFontFaceSrcList;
mSrcIndex = 0;
mWeight = aWeight;
@ -135,21 +135,20 @@ gfxProxyFontEntry::gfxProxyFontEntry(gfxUserFontSet *aFontSet,
mItalic = (aItalicStyle & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE)) != 0;
mFeatureSettings.AppendElements(aFeatureSettings);
mLanguageOverride = aLanguageOverride;
mIsUserFont = true;
}
gfxProxyFontEntry::~gfxProxyFontEntry()
gfxUserFontEntry::~gfxUserFontEntry()
{
}
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)
gfxUserFontEntry::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 =
@ -166,16 +165,16 @@ gfxProxyFontEntry::Matches(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
}
gfxFont*
gfxProxyFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold)
gfxUserFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold)
{
// cannot create an actual font for a proxy entry
// userfont entry is a container, can't create font from the container
return nullptr;
}
class gfxOTSContext : public ots::OTSContext {
public:
gfxOTSContext(gfxMixedFontFamily *aFamily, gfxProxyFontEntry *aProxy)
: mFamily(aFamily), mProxy(aProxy) {}
gfxOTSContext(gfxUserFontFamily *aFamily, gfxUserFontEntry *aUserFontEntry)
: mFamily(aFamily), mUserFontEntry(aUserFontEntry) {}
virtual ots::TableAction GetTableAction(uint32_t aTag) MOZ_OVERRIDE {
// preserve Graphite, color glyph and SVG tables
@ -203,22 +202,22 @@ public:
va_end(va);
mProxy->mFontSet->LogMessage(mFamily, mProxy, buf);
mUserFontEntry->mFontSet->LogMessage(mFamily, mUserFontEntry, buf);
}
private:
gfxMixedFontFamily *mFamily;
gfxProxyFontEntry *mProxy;
gfxUserFontFamily *mFamily;
gfxUserFontEntry *mUserFontEntry;
};
// Call the OTS library to sanitize an sfnt before attempting to use it.
// Returns a newly-allocated block, or nullptr in case of fatal errors.
const uint8_t*
gfxProxyFontEntry::SanitizeOpenTypeData(gfxMixedFontFamily *aFamily,
const uint8_t* aData,
uint32_t aLength,
uint32_t& aSaneLength,
bool aIsCompressed)
gfxUserFontEntry::SanitizeOpenTypeData(gfxUserFontFamily *aFamily,
const uint8_t* aData,
uint32_t aLength,
uint32_t& aSaneLength,
bool aIsCompressed)
{
// limit output/expansion to 256MB
ExpandingMemoryStream output(aIsCompressed ? aLength * 2 : aLength,
@ -236,11 +235,11 @@ gfxProxyFontEntry::SanitizeOpenTypeData(gfxMixedFontFamily *aFamily,
}
void
gfxProxyFontEntry::StoreUserFontData(gfxFontEntry* aFontEntry,
bool aPrivate,
const nsAString& aOriginalName,
FallibleTArray<uint8_t>* aMetadata,
uint32_t aMetaOrigLen)
gfxUserFontEntry::StoreUserFontData(gfxFontEntry* aFontEntry,
bool aPrivate,
const nsAString& aOriginalName,
FallibleTArray<uint8_t>* aMetadata,
uint32_t aMetaOrigLen)
{
if (!aFontEntry->mUserFontData) {
aFontEntry->mUserFontData = new gfxUserFontData;
@ -310,9 +309,9 @@ CopyWOFFMetadata(const uint8_t* aFontData,
*aMetaOrigLen = woff->metaOrigLen;
}
gfxProxyFontEntry::LoadStatus
gfxProxyFontEntry::LoadNext(gfxMixedFontFamily *aFamily,
bool& aLocalRulesUsed)
gfxUserFontEntry::LoadStatus
gfxUserFontEntry::LoadNext(gfxUserFontFamily *aFamily,
bool& aLocalRulesUsed)
{
uint32_t numSrc = mSrcList.Length();
@ -469,8 +468,8 @@ gfxProxyFontEntry::LoadNext(gfxMixedFontFamily *aFamily,
}
gfxFontEntry*
gfxProxyFontEntry::LoadFont(gfxMixedFontFamily *aFamily,
const uint8_t* aFontData, uint32_t &aLength)
gfxUserFontEntry::LoadFont(gfxUserFontFamily *aFamily,
const uint8_t* aFontData, uint32_t &aLength)
{
gfxFontEntry *fe = nullptr;
@ -525,7 +524,7 @@ gfxProxyFontEntry::LoadFont(gfxMixedFontFamily *aFamily,
CopyWOFFMetadata(aFontData, aLength, &metadata, &metaOrigLen);
}
// copy OpenType feature/language settings from the proxy to the
// copy OpenType feature/language settings from the userfont entry to the
// newly-created font entry
fe->mFeatureSettings.AppendElements(mFeatureSettings);
fe->mLanguageOverride = mLanguageOverride;
@ -582,7 +581,7 @@ gfxUserFontSet::~gfxUserFontSet()
}
}
already_AddRefed<gfxProxyFontEntry>
already_AddRefed<gfxUserFontEntry>
gfxUserFontSet::FindOrCreateFontFace(
const nsAString& aFamilyName,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
@ -593,19 +592,20 @@ gfxUserFontSet::FindOrCreateFontFace(
uint32_t aLanguageOverride,
gfxSparseBitSet* aUnicodeRanges)
{
nsRefPtr<gfxProxyFontEntry> entry;
nsRefPtr<gfxUserFontEntry> entry;
// If there's already a proxy in the family whose descriptors all match,
// If there's already a userfont entry 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
// Note that we can't do this for platform font 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.
gfxMixedFontFamily* family = LookupFamily(aFamilyName);
gfxUserFontFamily* family = LookupFamily(aFamilyName);
if (family) {
entry = FindExistingProxyEntry(family, aFontFaceSrcList, aWeight,
aStretch, aItalicStyle, aFeatureSettings,
aLanguageOverride, aUnicodeRanges);
entry = FindExistingUserFontEntry(family, aFontFaceSrcList, aWeight,
aStretch, aItalicStyle,
aFeatureSettings, aLanguageOverride,
aUnicodeRanges);
}
if (!entry) {
@ -629,7 +629,7 @@ gfxUserFontSet::FindOrCreateFontFace(
return entry.forget();
}
already_AddRefed<gfxProxyFontEntry>
already_AddRefed<gfxUserFontEntry>
gfxUserFontSet::CreateFontFace(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
@ -641,16 +641,16 @@ gfxUserFontSet::CreateFontFace(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
MOZ_ASSERT(aWeight != 0,
"aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead");
nsRefPtr<gfxProxyFontEntry> proxyEntry =
new gfxProxyFontEntry(this, aFontFaceSrcList, aWeight,
nsRefPtr<gfxUserFontEntry> userFontEntry =
new gfxUserFontEntry(this, aFontFaceSrcList, aWeight,
aStretch, aItalicStyle, aFeatureSettings,
aLanguageOverride, aUnicodeRanges);
return proxyEntry.forget();
return userFontEntry.forget();
}
gfxProxyFontEntry*
gfxUserFontSet::FindExistingProxyEntry(
gfxMixedFontFamily* aFamily,
gfxUserFontEntry*
gfxUserFontSet::FindExistingUserFontEntry(
gfxUserFontFamily* aFamily,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
@ -665,20 +665,20 @@ gfxUserFontSet::FindExistingProxyEntry(
nsTArray<nsRefPtr<gfxFontEntry>>& fontList = aFamily->GetFontList();
for (size_t i = 0, count = fontList.Length(); i < count; i++) {
if (!fontList[i]->mIsProxy) {
if (!fontList[i]->mIsUserFontContainer) {
continue;
}
gfxProxyFontEntry* existingProxyEntry =
static_cast<gfxProxyFontEntry*>(fontList[i].get());
if (!existingProxyEntry->Matches(aFontFaceSrcList,
aWeight, aStretch, aItalicStyle,
aFeatureSettings, aLanguageOverride,
aUnicodeRanges)) {
gfxUserFontEntry* existingUserFontEntry =
static_cast<gfxUserFontEntry*>(fontList[i].get());
if (!existingUserFontEntry->Matches(aFontFaceSrcList,
aWeight, aStretch, aItalicStyle,
aFeatureSettings, aLanguageOverride,
aUnicodeRanges)) {
continue;
}
return existingProxyEntry;
return existingUserFontEntry;
}
return nullptr;
@ -688,7 +688,7 @@ void
gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
gfxFontEntry *aFontEntry)
{
gfxMixedFontFamily* family = GetFamily(aFamilyName);
gfxUserFontFamily* family = GetFamily(aFamilyName);
family->AddFontEntry(aFontEntry);
#ifdef PR_LOGGING
@ -706,41 +706,41 @@ gfxUserFontSet::FindFontEntry(gfxFontFamily *aFamily,
bool& aWaitForUserFont)
{
aWaitForUserFont = false;
gfxMixedFontFamily *family = static_cast<gfxMixedFontFamily*>(aFamily);
gfxUserFontFamily *family = static_cast<gfxUserFontFamily*>(aFamily);
gfxFontEntry* fe = family->FindFontForStyle(aFontStyle, aNeedsBold);
// if not a proxy, font has already been loaded
if (!fe->mIsProxy) {
// if not a userfont entry, font has already been loaded
if (!fe->mIsUserFontContainer) {
return fe;
}
gfxProxyFontEntry *proxyEntry = static_cast<gfxProxyFontEntry*> (fe);
gfxUserFontEntry *userFontEntry = static_cast<gfxUserFontEntry*> (fe);
// if currently loading, return null for now
if (proxyEntry->mLoadingState > gfxProxyFontEntry::NOT_LOADING) {
if (userFontEntry->mLoadingState > gfxUserFontEntry::NOT_LOADING) {
aWaitForUserFont =
(proxyEntry->mLoadingState < gfxProxyFontEntry::LOADING_SLOWLY);
(userFontEntry->mLoadingState < gfxUserFontEntry::LOADING_SLOWLY);
return nullptr;
}
// hasn't been loaded yet, start the load process
gfxProxyFontEntry::LoadStatus status;
gfxUserFontEntry::LoadStatus status;
// NOTE that if all sources in the entry fail, this will delete proxyEntry,
// NOTE that if all sources in the entry fail, this will delete userFontEntry,
// so we cannot use it again if status==STATUS_END_OF_LIST
status = proxyEntry->LoadNext(family, mLocalRulesUsed);
status = userFontEntry->LoadNext(family, mLocalRulesUsed);
// if the load succeeded immediately, the font entry was replaced so
// search again
if (status == gfxProxyFontEntry::STATUS_LOADED) {
if (status == gfxUserFontEntry::STATUS_LOADED) {
return family->FindFontForStyle(aFontStyle, aNeedsBold);
}
// check whether we should wait for load to complete before painting
// a fallback font -- but not if all sources failed (bug 633500)
aWaitForUserFont = (status != gfxProxyFontEntry::STATUS_END_OF_LIST) &&
(proxyEntry->mLoadingState < gfxProxyFontEntry::LOADING_SLOWLY);
aWaitForUserFont = (status != gfxUserFontEntry::STATUS_END_OF_LIST) &&
(userFontEntry->mLoadingState < gfxUserFontEntry::LOADING_SLOWLY);
// if either loading or an error occurred, return null
return nullptr;
@ -750,18 +750,18 @@ gfxUserFontSet::FindFontEntry(gfxFontFamily *aFamily,
// Ownership of aFontData passes in here, and the font set must
// ensure that it is eventually deleted via NS_Free().
bool
gfxUserFontSet::OnLoadComplete(gfxMixedFontFamily *aFamily,
gfxProxyFontEntry *aProxy,
gfxUserFontSet::OnLoadComplete(gfxUserFontFamily *aFamily,
gfxUserFontEntry *aUserFontEntry,
const uint8_t* aFontData, uint32_t aLength,
nsresult aDownloadStatus)
{
// forget about the loader, as we no longer potentially need to cancel it
// if the entry is obsoleted
aProxy->mLoader = nullptr;
aUserFontEntry->mLoader = nullptr;
// download successful, make platform font using font data
if (NS_SUCCEEDED(aDownloadStatus)) {
gfxFontEntry *fe = aProxy->LoadFont(aFamily, aFontData, aLength);
gfxFontEntry *fe = aUserFontEntry->LoadFont(aFamily, aFontData, aLength);
aFontData = nullptr;
if (fe) {
@ -771,7 +771,7 @@ gfxUserFontSet::OnLoadComplete(gfxMixedFontFamily *aFamily,
} else {
// download failed
LogMessage(aFamily, aProxy,
LogMessage(aFamily, aUserFontEntry,
"download failed", nsIScriptError::errorFlag,
aDownloadStatus);
}
@ -781,7 +781,7 @@ gfxUserFontSet::OnLoadComplete(gfxMixedFontFamily *aFamily,
}
// error occurred, load next src
(void)aProxy->LoadNext(aFamily, mLocalRulesUsed);
(void)aUserFontEntry->LoadNext(aFamily, mLocalRulesUsed);
// We ignore the status returned by LoadNext();
// even if loading failed, we need to bump the font-set generation
@ -809,7 +809,7 @@ gfxUserFontSet::RebuildLocalRules()
}
}
gfxMixedFontFamily*
gfxUserFontFamily*
gfxUserFontSet::LookupFamily(const nsAString& aFamilyName) const
{
nsAutoString key(aFamilyName);
@ -818,15 +818,15 @@ gfxUserFontSet::LookupFamily(const nsAString& aFamilyName) const
return mFontFamilies.GetWeak(key);
}
gfxMixedFontFamily*
gfxUserFontFamily*
gfxUserFontSet::GetFamily(const nsAString& aFamilyName)
{
nsAutoString key(aFamilyName);
ToLowerCase(key);
gfxMixedFontFamily* family = mFontFamilies.GetWeak(key);
gfxUserFontFamily* family = mFontFamilies.GetWeak(key);
if (!family) {
family = new gfxMixedFontFamily(aFamilyName);
family = new gfxUserFontFamily(aFamilyName);
mFontFamilies.Put(key, family);
}
return family;
@ -838,9 +838,9 @@ struct FindFamilyCallbackData {
};
static PLDHashOperator
FindFamilyCallback(const nsAString& aName,
gfxMixedFontFamily* aFamily,
void* aUserArg)
FindFamilyCallback(const nsAString& aName,
gfxUserFontFamily* aFamily,
void* aUserArg)
{
FindFamilyCallbackData *d = static_cast<FindFamilyCallbackData*>(aUserArg);
if (aFamily->ContainsFace(d->mFontEntry)) {
@ -1056,7 +1056,7 @@ gfxUserFontSet::UserFontCache::ForgetFont(gfxFontEntry *aFontEntry)
gfxFontEntry*
gfxUserFontSet::UserFontCache::GetFont(nsIURI *aSrcURI,
nsIPrincipal *aPrincipal,
gfxProxyFontEntry *aProxy,
gfxUserFontEntry *aUserFontEntry,
bool aPrivate)
{
if (!sUserFonts) {
@ -1071,7 +1071,7 @@ gfxUserFontSet::UserFontCache::GetFont(nsIURI *aSrcURI,
principal = aPrincipal;
}
Entry* entry = sUserFonts->GetEntry(Key(aSrcURI, principal, aProxy,
Entry* entry = sUserFonts->GetEntry(Key(aSrcURI, principal, aUserFontEntry,
aPrivate));
if (entry) {
return entry->GetFontEntry();
@ -1096,7 +1096,7 @@ gfxUserFontSet::UserFontCache::GetFont(nsIURI *aSrcURI,
zipentry->GetCRC32(&crc32);
zipentry->GetRealSize(&length);
entry = sUserFonts->GetEntry(Key(crc32, length, aProxy, aPrivate));
entry = sUserFonts->GetEntry(Key(crc32, length, aUserFontEntry, aPrivate));
if (entry) {
return entry->GetFontEntry();
}

View File

@ -79,17 +79,17 @@ public:
bool mPrivate; // whether font belongs to a private window
};
// initially contains a set of proxy font entry objects, replaced with
// initially contains a set of userfont font entry objects, replaced with
// platform/user fonts as downloaded
class gfxMixedFontFamily : public gfxFontFamily {
class gfxUserFontFamily : public gfxFontFamily {
public:
friend class gfxUserFontSet;
explicit gfxMixedFontFamily(const nsAString& aName)
explicit gfxUserFontFamily(const nsAString& aName)
: gfxFontFamily(aName) { }
virtual ~gfxMixedFontFamily() { }
virtual ~gfxUserFontFamily() { }
// Add the given font entry to the end of the family's list.
// Any earlier occurrence is removed, so this has the effect of "advancing"
@ -120,15 +120,15 @@ public:
ResetCharacterMap();
}
// Replace aProxyFontEntry in the family's list with aRealFontEntry.
void ReplaceFontEntry(gfxFontEntry *aProxyFontEntry,
// Replace userfont entry in the family's list with aRealFontEntry.
void ReplaceFontEntry(gfxFontEntry *aUserFontEntry,
gfxFontEntry *aRealFontEntry) {
uint32_t numFonts = mAvailableFonts.Length();
uint32_t i;
for (i = 0; i < numFonts; i++) {
gfxFontEntry *fe = mAvailableFonts[i];
if (fe == aProxyFontEntry) {
// Note that this may delete aProxyFontEntry, if there's no
if (fe == aUserFontEntry) {
// Note that this may delete aUserFontEntry, if there's no
// other reference to it except from its family.
mAvailableFonts[i] = aRealFontEntry;
if (aRealFontEntry->mFamilyName.IsEmpty()) {
@ -155,11 +155,11 @@ public:
}
};
class gfxProxyFontEntry;
class gfxUserFontEntry;
class gfxOTSContext;
class gfxUserFontSet {
friend class gfxProxyFontEntry;
friend class gfxUserFontEntry;
friend class gfxOTSContext;
public:
@ -190,7 +190,7 @@ public:
// italic style = constants in gfxFontConstants.h, e.g. NS_FONT_STYLE_NORMAL
// language override = result of calling gfxFontStyle::ParseFontLanguageOverride
// TODO: support for unicode ranges not yet implemented
already_AddRefed<gfxProxyFontEntry> CreateFontFace(
already_AddRefed<gfxUserFontEntry> CreateFontFace(
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
@ -201,7 +201,7 @@ public:
// creates a font face for the specified family, or returns an existing
// matching entry on the family if there is one
already_AddRefed<gfxProxyFontEntry> FindOrCreateFontFace(
already_AddRefed<gfxUserFontEntry> FindOrCreateFontFace(
const nsAString& aFamilyName,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
@ -220,9 +220,9 @@ public:
return LookupFamily(aFamilyName) != nullptr;
}
// Look up and return the gfxMixedFontFamily in mFontFamilies with
// Look up and return the gfxUserFontFamily in mFontFamilies with
// the given name
gfxMixedFontFamily* LookupFamily(const nsAString& aName) const;
gfxUserFontFamily* LookupFamily(const nsAString& aName) const;
// Lookup a font entry for a given style, returns null if not loaded.
// aFamily must be a family returned by our LookupFamily method.
@ -246,8 +246,8 @@ public:
// initialize the process that loads external font data, which upon
// completion will call OnLoadComplete method
virtual nsresult StartLoad(gfxMixedFontFamily *aFamily,
gfxProxyFontEntry *aProxy,
virtual nsresult StartLoad(gfxUserFontFamily *aFamily,
gfxUserFontEntry *aUserFontEntry,
const gfxFontFaceSrc *aFontFaceSrc) = 0;
// when download has been completed, pass back data here
@ -256,16 +256,16 @@ public:
// reference was next in line)
// Ownership of aFontData is passed in here; the font set must
// ensure that it is eventually deleted with NS_Free().
bool OnLoadComplete(gfxMixedFontFamily *aFamily,
gfxProxyFontEntry *aProxy,
bool OnLoadComplete(gfxUserFontFamily *aFamily,
gfxUserFontEntry *aUserFontEntry,
const uint8_t* aFontData, uint32_t aLength,
nsresult aDownloadStatus);
// Replace a proxy with a real fontEntry; this is implemented in
// Replace a userfont entry with a real fontEntry; this is implemented in
// nsUserFontSet in order to keep track of the entry corresponding
// to each @font-face rule.
virtual void ReplaceFontEntry(gfxMixedFontFamily *aFamily,
gfxProxyFontEntry *aProxy,
virtual void ReplaceFontEntry(gfxUserFontFamily *aFamily,
gfxUserFontEntry *aUserFontEntry,
gfxFontEntry *aFontEntry) = 0;
// generation - each time a face is loaded, generation is
@ -301,14 +301,14 @@ public:
static void ForgetFont(gfxFontEntry *aFontEntry);
// Return the gfxFontEntry corresponding to a given URI and principal,
// and the features of the given proxy, or nullptr if none is available.
// and the features of the given userfont entry, or nullptr if none is available.
// The aPrivate flag is set for requests coming from private windows,
// so we can avoid leaking fonts cached in private windows mode out to
// normal windows.
static gfxFontEntry* GetFont(nsIURI *aSrcURI,
nsIPrincipal *aPrincipal,
gfxProxyFontEntry *aProxy,
bool aPrivate);
static gfxFontEntry* GetFont(nsIURI *aSrcURI,
nsIPrincipal *aPrincipal,
gfxUserFontEntry *aUserFontEntry,
bool aPrivate);
// Clear everything so that we don't leak URIs and Principals.
static void Shutdown();
@ -334,7 +334,7 @@ public:
// Note that key comparison does *not* use the mFontEntry field
// as a whole; it only compares specific fields within the entry
// (weight/width/style/features) that could affect font selection
// or rendering, and that must match between a font-set's proxy
// or rendering, and that must match between a font-set's userfont
// entry and the corresponding "real" font entry.
struct Key {
nsCOMPtr<nsIURI> mURI;
@ -472,14 +472,14 @@ protected:
virtual bool GetPrivateBrowsing() = 0;
// parse data for a data URL
virtual nsresult SyncLoadFontData(gfxProxyFontEntry *aFontToLoad,
virtual nsresult SyncLoadFontData(gfxUserFontEntry *aFontToLoad,
const gfxFontFaceSrc *aFontFaceSrc,
uint8_t* &aBuffer,
uint32_t &aBufferLength) = 0;
// report a problem of some kind (implemented in nsUserFontSet)
virtual nsresult LogMessage(gfxMixedFontFamily *aFamily,
gfxProxyFontEntry *aProxy,
virtual nsresult LogMessage(gfxUserFontFamily *aFamily,
gfxUserFontEntry *aUserFontEntry,
const char *aMessage,
uint32_t aFlags = nsIScriptError::errorFlag,
nsresult aStatus = NS_OK) = 0;
@ -488,8 +488,8 @@ protected:
virtual void DoRebuildUserFontSet() = 0;
// helper method for FindOrCreateFontFace
gfxProxyFontEntry* FindExistingProxyEntry(
gfxMixedFontFamily* aFamily,
gfxUserFontEntry* FindExistingUserFontEntry(
gfxUserFontFamily* aFamily,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
@ -498,12 +498,12 @@ protected:
uint32_t aLanguageOverride,
gfxSparseBitSet* aUnicodeRanges);
// creates a new gfxMixedFontFamily in mFontFamilies, or returns an existing
// creates a new gfxUserFontFamily in mFontFamilies, or returns an existing
// family if there is one
gfxMixedFontFamily* GetFamily(const nsAString& aFamilyName);
gfxUserFontFamily* GetFamily(const nsAString& aFamilyName);
// font families defined by @font-face rules
nsRefPtrHashtable<nsStringHashKey, gfxMixedFontFamily> mFontFamilies;
nsRefPtrHashtable<nsStringHashKey, gfxUserFontFamily> mFontFamilies;
uint64_t mGeneration;
@ -515,7 +515,7 @@ protected:
// acts a placeholder until the real font is downloaded
class gfxProxyFontEntry : public gfxFontEntry {
class gfxUserFontEntry : public gfxFontEntry {
friend class gfxUserFontSet;
friend class nsUserFontSet;
friend class nsFontFaceLoader;
@ -530,16 +530,16 @@ public:
STATUS_END_OF_LIST
};
gfxProxyFontEntry(gfxUserFontSet *aFontSet,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges);
gfxUserFontEntry(gfxUserFontSet *aFontSet,
const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
uint32_t aWeight,
int32_t aStretch,
uint32_t aItalicStyle,
const nsTArray<gfxFontFeature>& aFeatureSettings,
uint32_t aLanguageOverride,
gfxSparseBitSet *aUnicodeRanges);
virtual ~gfxProxyFontEntry();
virtual ~gfxUserFontEntry();
// Return whether the entry matches the given list of attributes
bool Matches(const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
@ -553,7 +553,7 @@ public:
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
protected:
const uint8_t* SanitizeOpenTypeData(gfxMixedFontFamily *aFamily,
const uint8_t* SanitizeOpenTypeData(gfxUserFontFamily *aFamily,
const uint8_t* aData,
uint32_t aLength,
uint32_t& aSaneLength,
@ -562,14 +562,14 @@ protected:
// Attempt to load the next resource in the src list.
// aLocalRules is set to true if an attempt was made to load a
// local() font was loaded, and left as it is otherwise.
LoadStatus LoadNext(gfxMixedFontFamily *aFamily,
LoadStatus LoadNext(gfxUserFontFamily *aFamily,
bool& aLocalRulesUsed);
// helper method for creating a platform font
// returns font entry if platform font creation successful
// Ownership of aFontData is passed in here; the font must
// ensure that it is eventually deleted with NS_Free().
gfxFontEntry* LoadFont(gfxMixedFontFamily *aFamily,
gfxFontEntry* LoadFont(gfxUserFontFamily *aFamily,
const uint8_t* aFontData, uint32_t &aLength);
// store metadata and src details for current src into aFontEntry
@ -595,7 +595,7 @@ protected:
nsTArray<gfxFontFaceSrc> mSrcList;
uint32_t mSrcIndex; // index of loading src item
nsFontFaceLoader *mLoader; // current loader for this entry, if any
gfxUserFontSet *mFontSet; // font-set to which the proxy belongs
gfxUserFontSet *mFontSet; // font-set to which the userfont entry belongs
nsCOMPtr<nsIPrincipal> mPrincipal;
};

View File

@ -55,13 +55,13 @@ GetFontDownloaderLog()
#define LOG_ENABLED() PR_LOG_TEST(GetFontDownloaderLog(), PR_LOG_DEBUG)
nsFontFaceLoader::nsFontFaceLoader(gfxMixedFontFamily* aFontFamily,
gfxProxyFontEntry* aProxy,
nsFontFaceLoader::nsFontFaceLoader(gfxUserFontFamily* aFontFamily,
gfxUserFontEntry* aUserFontEntry,
nsIURI* aFontURI,
nsUserFontSet* aFontSet,
nsIChannel* aChannel)
: mFontFamily(aFontFamily),
mFontEntry(aProxy),
mFontEntry(aUserFontEntry),
mFontURI(aFontURI),
mFontSet(aFontSet),
mChannel(aChannel)
@ -96,7 +96,7 @@ nsFontFaceLoader::StartedLoading(nsIStreamLoader* aStreamLoader)
nsITimer::TYPE_ONE_SHOT);
}
} else {
mFontEntry->mLoadingState = gfxProxyFontEntry::LOADING_SLOWLY;
mFontEntry->mLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
}
mStreamLoader = aStreamLoader;
}
@ -111,12 +111,12 @@ nsFontFaceLoader::LoadTimerCallback(nsITimer* aTimer, void* aClosure)
return;
}
gfxProxyFontEntry* pe = loader->mFontEntry.get();
gfxUserFontEntry* ufe = loader->mFontEntry.get();
bool updateUserFontSet = true;
// If the entry is loading, check whether it's >75% done; if so,
// we allow another timeout period before showing a fallback font.
if (pe->mLoadingState == gfxProxyFontEntry::LOADING_STARTED) {
if (ufe->mLoadingState == gfxUserFontEntry::LOADING_STARTED) {
int64_t contentLength;
uint32_t numBytesRead;
if (NS_SUCCEEDED(loader->mChannel->GetContentLength(&contentLength)) &&
@ -128,7 +128,7 @@ nsFontFaceLoader::LoadTimerCallback(nsITimer* aTimer, void* aClosure)
// More than 3/4 the data has been downloaded, so allow 50% extra
// time and hope the remainder will arrive before the additional
// time expires.
pe->mLoadingState = gfxProxyFontEntry::LOADING_ALMOST_DONE;
ufe->mLoadingState = gfxUserFontEntry::LOADING_ALMOST_DONE;
uint32_t delay;
loader->mLoadTimer->GetDelay(&delay);
loader->mLoadTimer->InitWithFuncCallback(LoadTimerCallback,
@ -144,7 +144,7 @@ nsFontFaceLoader::LoadTimerCallback(nsITimer* aTimer, void* aClosure)
// before, we mark this entry as "loading slowly", so the fallback
// font will be used in the meantime, and tell the context to refresh.
if (updateUserFontSet) {
pe->mLoadingState = gfxProxyFontEntry::LOADING_SLOWLY;
ufe->mLoadingState = gfxUserFontEntry::LOADING_SLOWLY;
gfxUserFontSet* fontSet = loader->mFontSet;
nsPresContext* ctx = loader->mFontSet->GetPresContext();
NS_ASSERTION(ctx, "userfontset doesn't have a presContext?");
@ -239,7 +239,7 @@ nsFontFaceLoader::OnStreamComplete(nsIStreamLoader* aLoader,
void
nsFontFaceLoader::Cancel()
{
mFontEntry->mLoadingState = gfxProxyFontEntry::NOT_LOADING;
mFontEntry->mLoadingState = gfxUserFontEntry::NOT_LOADING;
mFontEntry->mLoader = nullptr;
mFontSet = nullptr;
if (mLoadTimer) {
@ -319,8 +319,8 @@ nsUserFontSet::RemoveLoader(nsFontFaceLoader* aLoader)
}
nsresult
nsUserFontSet::StartLoad(gfxMixedFontFamily* aFamily,
gfxProxyFontEntry* aProxy,
nsUserFontSet::StartLoad(gfxUserFontFamily* aFamily,
gfxUserFontEntry* aUserFontEntry,
const gfxFontFaceSrc* aFontFaceSrc)
{
nsresult rv;
@ -336,7 +336,7 @@ nsUserFontSet::StartLoad(gfxMixedFontFamily* aFamily,
// get Content Security Policy from principal to pass into channel
nsCOMPtr<nsIChannelPolicy> channelPolicy;
nsCOMPtr<nsIContentSecurityPolicy> csp;
rv = aProxy->mPrincipal->GetCsp(getter_AddRefs(csp));
rv = aUserFontEntry->mPrincipal->GetCsp(getter_AddRefs(csp));
NS_ENSURE_SUCCESS(rv, rv);
if (csp) {
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
@ -354,7 +354,7 @@ nsUserFontSet::StartLoad(gfxMixedFontFamily* aFamily,
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsFontFaceLoader> fontLoader =
new nsFontFaceLoader(aFamily, aProxy, aFontFaceSrc->mURI, this, channel);
new nsFontFaceLoader(aFamily, aUserFontEntry, aFontFaceSrc->mURI, this, channel);
if (!fontLoader)
return NS_ERROR_OUT_OF_MEMORY;
@ -396,7 +396,7 @@ nsUserFontSet::StartLoad(gfxMixedFontFamily* aFamily,
rv = channel->AsyncOpen(streamLoader, nullptr);
} else {
nsRefPtr<nsCORSListenerProxy> listener =
new nsCORSListenerProxy(streamLoader, aProxy->mPrincipal, false);
new nsCORSListenerProxy(streamLoader, aUserFontEntry->mPrincipal, false);
rv = listener->Init(channel);
if (NS_SUCCEEDED(rv)) {
rv = channel->AsyncOpen(listener, nullptr);
@ -409,15 +409,15 @@ nsUserFontSet::StartLoad(gfxMixedFontFamily* aFamily,
if (NS_SUCCEEDED(rv)) {
mLoaders.PutEntry(fontLoader);
fontLoader->StartedLoading(streamLoader);
aProxy->mLoader = fontLoader; // let the font entry remember the loader,
// in case we need to cancel it
aUserFontEntry->mLoader = fontLoader; // let the font entry remember the
// loader, in case we need to cancel it
}
return rv;
}
static PLDHashOperator DetachFontEntries(const nsAString& aKey,
nsRefPtr<gfxMixedFontFamily>& aFamily,
nsRefPtr<gfxUserFontFamily>& aFamily,
void* aUserArg)
{
aFamily->DetachFontEntries();
@ -425,7 +425,7 @@ static PLDHashOperator DetachFontEntries(const nsAString& aKey,
}
static PLDHashOperator RemoveIfEmpty(const nsAString& aKey,
nsRefPtr<gfxMixedFontFamily>& aFamily,
nsRefPtr<gfxUserFontFamily>& aFamily,
void* aUserArg)
{
return aFamily->GetFontList().Length() ? PL_DHASH_NEXT : PL_DHASH_REMOVE;
@ -475,11 +475,11 @@ nsUserFontSet::UpdateRules(const nsTArray<nsFontFaceRuleContainer>& aRules)
size_t count = oldRules.Length();
for (size_t i = 0; i < count; ++i) {
gfxFontEntry* fe = oldRules[i].mFontEntry;
if (!fe->mIsProxy) {
if (!fe->mIsUserFontContainer) {
continue;
}
gfxProxyFontEntry* proxy = static_cast<gfxProxyFontEntry*>(fe);
nsFontFaceLoader* loader = proxy->mLoader;
gfxUserFontEntry* userFontEntry = static_cast<gfxUserFontEntry*>(fe);
nsFontFaceLoader* loader = userFontEntry->mLoader;
if (loader) {
loader->Cancel();
RemoveLoader(loader);
@ -578,10 +578,10 @@ nsUserFontSet::InsertRule(nsCSSFontFaceRule* aRule, uint8_t aSheetType,
ruleRec.mContainer.mRule = aRule;
ruleRec.mContainer.mSheetType = aSheetType;
// Add the entry to the end of the list. If an existing proxy entry was
// Add the entry to the end of the list. If an existing userfont entry was
// returned by FindOrCreateFontFaceFromRule that was already stored on the
// family, gfxMixedFontFamily::AddFontEntry(), which AddFontFace calls,
// will automatically remove the earlier occurrence of the same proxy.
// family, gfxUserFontFamily::AddFontEntry(), which AddFontFace calls,
// will automatically remove the earlier occurrence of the same userfont entry.
AddFontFace(fontfamily, ruleRec.mFontEntry);
mRules.AppendElement(ruleRec);
@ -752,7 +752,7 @@ nsUserFontSet::FindOrCreateFontFaceFromRule(const nsAString& aFamilyName,
return nullptr;
}
nsRefPtr<gfxProxyFontEntry> entry =
nsRefPtr<gfxUserFontEntry> entry =
FindOrCreateFontFace(aFamilyName, srcArray, weight, stretch, italicStyle,
featureSettings, languageOverride,
nullptr /* aUnicodeRanges */);
@ -760,20 +760,20 @@ nsUserFontSet::FindOrCreateFontFaceFromRule(const nsAString& aFamilyName,
}
void
nsUserFontSet::ReplaceFontEntry(gfxMixedFontFamily* aFamily,
gfxProxyFontEntry* aProxy,
nsUserFontSet::ReplaceFontEntry(gfxUserFontFamily* aFamily,
gfxUserFontEntry* aUserFontEntry,
gfxFontEntry* aFontEntry)
{
// aProxy is being supplanted by the "real" font aFontEntry, so we need to
// aUserFontEntry is being supplanted by the "real" font aFontEntry, so we need to
// update any rules that refer to it. Note that there may be multiple rules
// that refer to the same proxy - e.g. if a stylesheet was loaded multiple
// that refer to the same userfont entry - e.g. if a stylesheet was loaded multiple
// times, so that several identical @font-face rules are present.
for (uint32_t i = 0; i < mRules.Length(); ++i) {
if (mRules[i].mFontEntry == aProxy) {
if (mRules[i].mFontEntry == aUserFontEntry) {
mRules[i].mFontEntry = aFontEntry;
}
}
aFamily->ReplaceFontEntry(aProxy, aFontEntry);
aFamily->ReplaceFontEntry(aUserFontEntry, aFontEntry);
}
nsCSSFontFaceRule*
@ -788,8 +788,8 @@ nsUserFontSet::FindRuleForEntry(gfxFontEntry* aFontEntry)
}
nsresult
nsUserFontSet::LogMessage(gfxMixedFontFamily* aFamily,
gfxProxyFontEntry* aProxy,
nsUserFontSet::LogMessage(gfxUserFontFamily* aFamily,
gfxUserFontEntry* aUserFontEntry,
const char* aMessage,
uint32_t aFlags,
nsresult aStatus)
@ -800,13 +800,13 @@ nsUserFontSet::LogMessage(gfxMixedFontFamily* aFamily,
return NS_ERROR_NOT_AVAILABLE;
}
NS_ConvertUTF16toUTF8 familyName(aProxy->mFamilyName);
NS_ConvertUTF16toUTF8 familyName(aUserFontEntry->mFamilyName);
nsAutoCString fontURI;
if (aProxy->mSrcIndex == aProxy->mSrcList.Length()) {
if (aUserFontEntry->mSrcIndex == aUserFontEntry->mSrcList.Length()) {
fontURI.AppendLiteral("(end of source list)");
} else {
if (aProxy->mSrcList[aProxy->mSrcIndex].mURI) {
aProxy->mSrcList[aProxy->mSrcIndex].mURI->GetSpec(fontURI);
if (aUserFontEntry->mSrcList[aUserFontEntry->mSrcIndex].mURI) {
aUserFontEntry->mSrcList[aUserFontEntry->mSrcIndex].mURI->GetSpec(fontURI);
} else {
fontURI.AppendLiteral("(invalid URI)");
}
@ -815,12 +815,12 @@ nsUserFontSet::LogMessage(gfxMixedFontFamily* aFamily,
char weightKeywordBuf[8]; // plenty to sprintf() a uint16_t
const char* weightKeyword;
const nsAFlatCString& weightKeywordString =
nsCSSProps::ValueToKeyword(aProxy->Weight(),
nsCSSProps::ValueToKeyword(aUserFontEntry->Weight(),
nsCSSProps::kFontWeightKTable);
if (weightKeywordString.Length() > 0) {
weightKeyword = weightKeywordString.get();
} else {
sprintf(weightKeywordBuf, "%u", aProxy->Weight());
sprintf(weightKeywordBuf, "%u", aUserFontEntry->Weight());
weightKeyword = weightKeywordBuf;
}
@ -829,11 +829,11 @@ nsUserFontSet::LogMessage(gfxMixedFontFamily* aFamily,
"(font-family: \"%s\" style:%s weight:%s stretch:%s src index:%d)",
aMessage,
familyName.get(),
aProxy->IsItalic() ? "italic" : "normal",
aUserFontEntry->IsItalic() ? "italic" : "normal",
weightKeyword,
nsCSSProps::ValueToKeyword(aProxy->Stretch(),
nsCSSProps::ValueToKeyword(aUserFontEntry->Stretch(),
nsCSSProps::kFontStretchKTable).get(),
aProxy->mSrcIndex);
aUserFontEntry->mSrcIndex);
if (NS_FAILED(aStatus)) {
message.AppendLiteral(": ");
@ -861,7 +861,7 @@ nsUserFontSet::LogMessage(gfxMixedFontFamily* aFamily,
#endif
// try to give the user an indication of where the rule came from
nsCSSFontFaceRule* rule = FindRuleForEntry(aProxy);
nsCSSFontFaceRule* rule = FindRuleForEntry(aUserFontEntry);
nsString href;
nsString text;
nsresult rv;
@ -950,7 +950,7 @@ nsUserFontSet::CheckFontLoad(const gfxFontFaceSrc* aFontFaceSrc,
}
nsresult
nsUserFontSet::SyncLoadFontData(gfxProxyFontEntry* aFontToLoad,
nsUserFontSet::SyncLoadFontData(gfxUserFontEntry* aFontToLoad,
const gfxFontFaceSrc* aFontFaceSrc,
uint8_t*& aBuffer,
uint32_t& aBufferLength)

View File

@ -34,8 +34,8 @@ public:
// starts loading process, creating and initializing a nsFontFaceLoader obj
// returns whether load process successfully started or not
nsresult StartLoad(gfxMixedFontFamily* aFamily,
gfxProxyFontEntry* aFontToLoad,
nsresult StartLoad(gfxUserFontFamily* aFamily,
gfxUserFontEntry* aFontToLoad,
const gfxFontFaceSrc* aFontFaceSrc) MOZ_OVERRIDE;
// Called by nsFontFaceLoader when the loader has completed normally.
@ -46,8 +46,8 @@ public:
nsPresContext* GetPresContext() { return mPresContext; }
virtual void ReplaceFontEntry(gfxMixedFontFamily* aFamily,
gfxProxyFontEntry* aProxy,
virtual void ReplaceFontEntry(gfxUserFontFamily* aFamily,
gfxUserFontEntry* aUserFontEntry,
gfxFontEntry* aFontEntry) MOZ_OVERRIDE;
nsCSSFontFaceRule* FindRuleForEntry(gfxFontEntry* aFontEntry);
@ -75,8 +75,8 @@ protected:
nsCSSFontFaceRule* aRule,
uint8_t aSheetType);
virtual nsresult LogMessage(gfxMixedFontFamily* aFamily,
gfxProxyFontEntry* aProxy,
virtual nsresult LogMessage(gfxUserFontFamily* aFamily,
gfxUserFontEntry* aUserFontEntry,
const char* aMessage,
uint32_t aFlags = nsIScriptError::errorFlag,
nsresult aStatus = NS_OK) MOZ_OVERRIDE;
@ -85,7 +85,7 @@ protected:
nsIPrincipal** aPrincipal,
bool* aBypassCache) MOZ_OVERRIDE;
virtual nsresult SyncLoadFontData(gfxProxyFontEntry* aFontToLoad,
virtual nsresult SyncLoadFontData(gfxUserFontEntry* aFontToLoad,
const gfxFontFaceSrc* aFontFaceSrc,
uint8_t*& aBuffer,
uint32_t& aBufferLength) MOZ_OVERRIDE;
@ -107,8 +107,8 @@ protected:
class nsFontFaceLoader : public nsIStreamLoaderObserver
{
public:
nsFontFaceLoader(gfxMixedFontFamily* aFontFamily,
gfxProxyFontEntry* aFontToLoad, nsIURI* aFontURI,
nsFontFaceLoader(gfxUserFontFamily* aFontFamily,
gfxUserFontEntry* aFontToLoad, nsIURI* aFontURI,
nsUserFontSet* aFontSet, nsIChannel* aChannel);
NS_DECL_ISUPPORTS
@ -133,8 +133,8 @@ protected:
virtual ~nsFontFaceLoader();
private:
nsRefPtr<gfxMixedFontFamily> mFontFamily;
nsRefPtr<gfxProxyFontEntry> mFontEntry;
nsRefPtr<gfxUserFontFamily> mFontFamily;
nsRefPtr<gfxUserFontEntry> mFontEntry;
nsCOMPtr<nsIURI> mFontURI;
nsRefPtr<nsUserFontSet> mFontSet;
nsCOMPtr<nsIChannel> mChannel;