forked from mirrors/gecko-dev
Bug 1766378 - Add missing thread-safety-analysis annotations in Windows font-list classes. r=lsalzman
The warnings were almost all due to missing REQUIRES annotations on various method overrides; we were also failing to lock the mutex in the Windows impls of LookupLocalFont, so that's now fixed. Also cleaned up a bit of obsolete code in the GDI font backend (which we probably should be removing altogether, but that's for another time). Differential Revision: https://phabricator.services.mozilla.com/D144710
This commit is contained in:
parent
8033908b2d
commit
ddfacc1c2e
5 changed files with 57 additions and 69 deletions
|
|
@ -1116,6 +1116,7 @@ Family* FontList::FindFamily(const nsCString& aName, bool aPrimaryNameOnly) {
|
|||
// the "real" family names will have been found in AliasFamilies() above.
|
||||
if (aName.Contains(' ')) {
|
||||
auto pfl = gfxPlatformFontList::PlatformFontList();
|
||||
pfl->mLock.AssertCurrentThreadIn();
|
||||
if (header.mAliasCount) {
|
||||
// Aliases have been fully loaded by the parent process, so just discard
|
||||
// any stray mAliasTable and mLocalNameTable entries from earlier calls
|
||||
|
|
|
|||
|
|
@ -936,6 +936,8 @@ gfxFontEntry* gfxDWriteFontList::LookupLocalFont(
|
|||
nsPresContext* aPresContext, const nsACString& aFontName,
|
||||
WeightRange aWeightForEntry, StretchRange aStretchForEntry,
|
||||
SlantStyleRange aStyleForEntry) {
|
||||
AutoLock lock(mLock);
|
||||
|
||||
if (SharedFontList()) {
|
||||
return LookupInSharedFaceNameList(aPresContext, aFontName, aWeightForEntry,
|
||||
aStretchForEntry, aStyleForEntry);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ class gfxDWriteFontFamily final : public gfxFontFamily {
|
|||
mForceGDIClassic(false) {}
|
||||
virtual ~gfxDWriteFontFamily();
|
||||
|
||||
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) final;
|
||||
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
|
||||
REQUIRES(mLock) final;
|
||||
|
||||
void LocalizedName(nsACString& aLocalizedName) final;
|
||||
|
||||
|
|
@ -206,10 +207,10 @@ class gfxDWriteFontEntry final : public gfxFontEntry {
|
|||
void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
|
||||
bool GetForceGDIClassic() { return mForceGDIClassic; }
|
||||
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const override;
|
||||
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const override;
|
||||
|
||||
protected:
|
||||
friend class gfxDWriteFont;
|
||||
|
|
@ -374,8 +375,8 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
|
|||
}
|
||||
|
||||
// initialize font lists
|
||||
nsresult InitFontListForPlatform() override;
|
||||
void InitSharedFontListForPlatform() override;
|
||||
nsresult InitFontListForPlatform() REQUIRES(mLock) override;
|
||||
void InitSharedFontListForPlatform() REQUIRES(mLock) override;
|
||||
|
||||
FontVisibility GetVisibilityForFamily(const nsACString& aName) const;
|
||||
|
||||
|
|
@ -419,7 +420,8 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
|
|||
nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGeneric,
|
||||
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
|
||||
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
|
||||
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) override;
|
||||
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
|
||||
REQUIRES(mLock) override;
|
||||
|
||||
gfxFloat GetForceGDIClassicMaxFontSize() {
|
||||
return mForceGDIClassicMaxFontSize;
|
||||
|
|
@ -433,7 +435,8 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
|
|||
protected:
|
||||
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
|
||||
const gfxFontStyle* aStyle,
|
||||
nsAtom* aLanguage = nullptr) override;
|
||||
nsAtom* aLanguage = nullptr)
|
||||
REQUIRES(mLock) override;
|
||||
|
||||
// attempt to use platform-specific fallback for the given character,
|
||||
// return null if no usable result found
|
||||
|
|
@ -441,23 +444,25 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
|
|||
const uint32_t aCh,
|
||||
Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
FontFamily& aMatchedFamily) override;
|
||||
FontFamily& aMatchedFamily)
|
||||
REQUIRES(mLock) override;
|
||||
|
||||
private:
|
||||
friend class gfxDWriteFontFamily;
|
||||
|
||||
nsresult GetFontSubstitutes();
|
||||
nsresult GetFontSubstitutes() REQUIRES(mLock);
|
||||
|
||||
void GetDirectWriteSubstitutes();
|
||||
void GetDirectWriteSubstitutes() REQUIRES(mLock);
|
||||
|
||||
virtual bool UsesSystemFallback() { return true; }
|
||||
|
||||
void GetFontsFromCollection(IDWriteFontCollection* aCollection);
|
||||
void GetFontsFromCollection(IDWriteFontCollection* aCollection)
|
||||
REQUIRES(mLock);
|
||||
|
||||
void AppendFamiliesFromCollection(
|
||||
IDWriteFontCollection* aCollection,
|
||||
nsTArray<mozilla::fontlist::Family::InitData>& aFamilies,
|
||||
const nsTArray<nsCString>* aForceClassicFams = nullptr);
|
||||
const nsTArray<nsCString>* aForceClassicFams = nullptr) REQUIRES(mLock);
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
already_AddRefed<IDWriteFontCollection> CreateBundledFontsCollection(
|
||||
|
|
|
|||
|
|
@ -111,10 +111,7 @@ GDIFontEntry::GDIFontEntry(const nsACString& aFaceName,
|
|||
gfxWindowsFontType aFontType, SlantStyleRange aStyle,
|
||||
WeightRange aWeight, StretchRange aStretch,
|
||||
gfxUserFontData* aUserFontData)
|
||||
: gfxFontEntry(aFaceName),
|
||||
mFontType(aFontType),
|
||||
mForceGDI(false),
|
||||
mUnicodeRanges() {
|
||||
: gfxFontEntry(aFaceName), mFontType(aFontType), mForceGDI(false) {
|
||||
mUserFontData.reset(aUserFontData);
|
||||
mStyleRange = aStyle;
|
||||
mWeightRange = aWeight;
|
||||
|
|
@ -372,7 +369,7 @@ GDIFontEntry* GDIFontEntry::CreateFontEntry(const nsACString& aName,
|
|||
WeightRange aWeight,
|
||||
StretchRange aStretch,
|
||||
gfxUserFontData* aUserFontData) {
|
||||
// jtdfix - need to set charset, unicode ranges, pitch/family
|
||||
// jtdfix - need to set charset, pitch/family
|
||||
|
||||
return new GDIFontEntry(aName, aFontType, aStyle, aWeight, aStretch,
|
||||
aUserFontData);
|
||||
|
|
@ -403,10 +400,11 @@ static bool ShouldIgnoreItalicStyle(const nsACString& aName) {
|
|||
|
||||
int CALLBACK GDIFontFamily::FamilyAddStylesProc(
|
||||
const ENUMLOGFONTEXW* lpelfe, const NEWTEXTMETRICEXW* nmetrics,
|
||||
DWORD fontType, LPARAM data) {
|
||||
DWORD fontType, LPARAM data) NO_THREAD_SAFETY_ANALYSIS {
|
||||
const NEWTEXTMETRICW& metrics = nmetrics->ntmTm;
|
||||
LOGFONTW logFont = lpelfe->elfLogFont;
|
||||
GDIFontFamily* ff = reinterpret_cast<GDIFontFamily*>(data);
|
||||
MOZ_ASSERT(ff->mLock.LockedForWritingByCurrentThread());
|
||||
|
||||
if (logFont.lfItalic && ShouldIgnoreItalicStyle(ff->mName)) {
|
||||
return 1;
|
||||
|
|
@ -458,23 +456,8 @@ int CALLBACK GDIFontFamily::FamilyAddStylesProc(
|
|||
return 1;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(ff->mLock.LockedForWritingByCurrentThread());
|
||||
ff->AddFontEntryLocked(fe);
|
||||
|
||||
if (nmetrics->ntmFontSig.fsUsb[0] != 0x00000000 &&
|
||||
nmetrics->ntmFontSig.fsUsb[1] != 0x00000000 &&
|
||||
nmetrics->ntmFontSig.fsUsb[2] != 0x00000000 &&
|
||||
nmetrics->ntmFontSig.fsUsb[3] != 0x00000000) {
|
||||
// set the unicode ranges
|
||||
uint32_t x = 0;
|
||||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
DWORD range = nmetrics->ntmFontSig.fsUsb[i];
|
||||
for (uint32_t k = 0; k < 32; ++k) {
|
||||
fe->mUnicodeRanges.set(x++, (range & (1 << k)) != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (LOG_FONTLIST_ENABLED()) {
|
||||
LOG_FONTLIST(
|
||||
("(fontlist) added (%s) to family (%s)"
|
||||
|
|
@ -649,6 +632,7 @@ int CALLBACK gfxGDIFontList::EnumFontFamExProc(ENUMLOGFONTEXW* lpelfe,
|
|||
NS_ConvertUTF16toUTF8 key(name);
|
||||
|
||||
gfxGDIFontList* fontList = PlatformFontList();
|
||||
fontList->mLock.AssertCurrentThreadIn();
|
||||
|
||||
if (!fontList->mFontFamilies.Contains(key)) {
|
||||
NS_ConvertUTF16toUTF8 faceName(lf.lfFaceName);
|
||||
|
|
@ -683,9 +667,9 @@ gfxFontEntry* gfxGDIFontList::LookupLocalFont(nsPresContext* aPresContext,
|
|||
WeightRange aWeightForEntry,
|
||||
StretchRange aStretchForEntry,
|
||||
SlantStyleRange aStyleForEntry) {
|
||||
gfxFontEntry* lookup;
|
||||
AutoLock lock(mLock);
|
||||
|
||||
lookup = LookupInFaceNameLists(aFontName);
|
||||
gfxFontEntry* lookup = LookupInFaceNameLists(aFontName);
|
||||
if (!lookup) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,18 +129,14 @@ class GDIFontEntry final : public gfxFontEntry {
|
|||
mFontType == GFX_FONT_TYPE_TT_OPENTYPE);
|
||||
}
|
||||
|
||||
virtual bool SupportsRange(uint8_t range) {
|
||||
return mUnicodeRanges.test(range);
|
||||
}
|
||||
|
||||
virtual bool SkipDuringSystemFallback() {
|
||||
bool SkipDuringSystemFallback() override {
|
||||
return !HasCmapTable(); // explicitly skip non-SFNT fonts
|
||||
}
|
||||
|
||||
virtual bool TestCharacterMap(uint32_t aCh);
|
||||
bool TestCharacterMap(uint32_t aCh) override;
|
||||
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const override;
|
||||
|
||||
gfxFontEntry* Clone() const override;
|
||||
|
||||
|
|
@ -160,8 +156,6 @@ class GDIFontEntry final : public gfxFontEntry {
|
|||
gfxWindowsFontType mFontType;
|
||||
bool mForceGDI;
|
||||
|
||||
gfxSparseBitSet mUnicodeRanges;
|
||||
|
||||
protected:
|
||||
friend class gfxGDIFont;
|
||||
|
||||
|
|
@ -193,8 +187,8 @@ class GDIFontFamily final : public gfxFontFamily {
|
|||
mWindowsPitch(0),
|
||||
mCharset() {}
|
||||
|
||||
void FindStyleVariationsLocked(
|
||||
FontInfoData* aFontInfoData = nullptr) override;
|
||||
void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr)
|
||||
REQUIRES(mLock) override;
|
||||
|
||||
bool FilterForFontList(nsAtom* aLangGroup,
|
||||
const nsACString& aGeneric) const final {
|
||||
|
|
@ -300,7 +294,7 @@ class gfxGDIFontList final : public gfxPlatformFontList {
|
|||
}
|
||||
|
||||
// initialize font lists
|
||||
virtual nsresult InitFontListForPlatform() override;
|
||||
nsresult InitFontListForPlatform() REQUIRES(mLock) override;
|
||||
|
||||
gfxFontFamily* CreateFontFamily(const nsACString& aName,
|
||||
FontVisibility aVisibility) const override;
|
||||
|
|
@ -309,43 +303,45 @@ class gfxGDIFontList final : public gfxPlatformFontList {
|
|||
nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGeneric,
|
||||
const nsACString& aFamily, nsTArray<FamilyAndGeneric>* aOutput,
|
||||
FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr,
|
||||
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) override;
|
||||
nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0)
|
||||
REQUIRES(mLock) override;
|
||||
|
||||
virtual gfxFontEntry* LookupLocalFont(nsPresContext* aPresContext,
|
||||
const nsACString& aFontName,
|
||||
WeightRange aWeightForEntry,
|
||||
StretchRange aStretchForEntry,
|
||||
SlantStyleRange aStyleForEntry);
|
||||
gfxFontEntry* LookupLocalFont(nsPresContext* aPresContext,
|
||||
const nsACString& aFontName,
|
||||
WeightRange aWeightForEntry,
|
||||
StretchRange aStretchForEntry,
|
||||
SlantStyleRange aStyleForEntry) override;
|
||||
|
||||
virtual gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
|
||||
WeightRange aWeightForEntry,
|
||||
StretchRange aStretchForEntry,
|
||||
SlantStyleRange aStyleForEntry,
|
||||
const uint8_t* aFontData,
|
||||
uint32_t aLength);
|
||||
gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
|
||||
WeightRange aWeightForEntry,
|
||||
StretchRange aStretchForEntry,
|
||||
SlantStyleRange aStyleForEntry,
|
||||
const uint8_t* aFontData,
|
||||
uint32_t aLength) override;
|
||||
|
||||
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const override;
|
||||
void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const override;
|
||||
|
||||
protected:
|
||||
FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext,
|
||||
const gfxFontStyle* aStyle,
|
||||
nsAtom* aLanguage = nullptr) override;
|
||||
nsAtom* aLanguage = nullptr)
|
||||
REQUIRES(mLock) override;
|
||||
|
||||
private:
|
||||
friend class gfxWindowsPlatform;
|
||||
|
||||
gfxGDIFontList();
|
||||
|
||||
nsresult GetFontSubstitutes();
|
||||
nsresult GetFontSubstitutes() REQUIRES(mLock);
|
||||
|
||||
static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* lpelfe,
|
||||
NEWTEXTMETRICEXW* lpntme,
|
||||
DWORD fontType, LPARAM lParam);
|
||||
|
||||
virtual already_AddRefed<FontInfoData> CreateFontInfoData();
|
||||
already_AddRefed<FontInfoData> CreateFontInfoData() override;
|
||||
|
||||
#ifdef MOZ_BUNDLED_FONTS
|
||||
void ActivateBundledFonts();
|
||||
|
|
|
|||
Loading…
Reference in a new issue