Bug 975460 - avoid CTFontCopyTable on OSX 10.6 to avoid crash. r=smichaud

This commit is contained in:
John Daggett 2014-03-28 14:40:42 +09:00
parent c0da567b5b
commit 30312de3dd
3 changed files with 31 additions and 17 deletions

View File

@ -61,6 +61,7 @@
#include "nsDirectoryServiceDefs.h"
#include "nsISimpleEnumerator.h"
#include "nsCharTraits.h"
#include "nsCocoaFeatures.h"
#include "gfxFontConstants.h"
#include "mozilla/MemoryReporting.h"
@ -1059,13 +1060,39 @@ public:
virtual void Load() {
nsAutoreleasePool localPool;
FontInfoData::Load();
// bug 975460 - to disable async font loader on 10.6, bump version
if (nsCocoaFeatures::OSXVersion() >= 0x1060) {
FontInfoData::Load();
}
}
// loads font data for all members of a given family
virtual void LoadFontFamilyData(const nsAString& aFamilyName);
};
static CFDataRef
LoadFontTable(CTFontRef aFontRef, CTFontTableTag aTableTag)
{
CFDataRef fontTable = nullptr;
if (!aFontRef) {
return nullptr;
}
if (nsCocoaFeatures::OnLionOrLater()) {
fontTable = CTFontCopyTable(aFontRef, aTableTag,
kCTFontTableOptionNoOptions);
} else {
// bug 975460 - special case 10.6 to avoid CTFontCopyTable
CGFontRef cgFont = CTFontCopyGraphicsFont(aFontRef, nullptr);
if (cgFont) {
fontTable = CGFontCopyTableForTag(cgFont, aTableTag);
CFRelease(cgFont);
}
}
return fontTable;
}
void
MacFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
{
@ -1122,8 +1149,7 @@ MacFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
// load the cmap data
FontFaceData fontData;
CFDataRef cmapTable = CTFontCopyTable(fontRef, kCTFontTableCmap,
kCTFontTableOptionNoOptions);
CFDataRef cmapTable = LoadFontTable(fontRef, kCTFontTableCmap);
if (cmapTable) {
bool unicodeFont = false, symbolFont = false; // ignored
const uint8_t *cmapData =
@ -1149,8 +1175,7 @@ MacFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
}
if (mLoadOtherNames && hasOtherFamilyNames) {
CFDataRef nameTable = CTFontCopyTable(fontRef, kCTFontTableName,
kCTFontTableOptionNoOptions);
CFDataRef nameTable = LoadFontTable(fontRef, kCTFontTableName);
if (nameTable) {
const char *nameData = (const char*)CFDataGetBytePtr(nameTable);
uint32_t nameLen = CFDataGetLength(nameTable);

View File

@ -337,13 +337,6 @@ gfxPlatformMac::GetCommonFallbackFonts(const uint32_t aCh,
aFontList.AppendElement(kFontArialUnicodeMS);
}
int32_t
gfxPlatformMac::OSXVersion()
{
return nsCocoaFeatures::OSXVersion();
}
uint32_t
gfxPlatformMac::ReadAntiAliasingThreshold()
{
@ -423,7 +416,7 @@ bool
gfxPlatformMac::UseAcceleratedCanvas()
{
// Lion or later is required
return OSXVersion() >= 0x1070 && Preferences::GetBool("gfx.canvas.azure.accelerated", false);
return nsCocoaFeatures::OnLionOrLater() && Preferences::GetBool("gfx.canvas.azure.accelerated", false);
}
bool

View File

@ -69,10 +69,6 @@ public:
int32_t aRunScript,
nsTArray<const char*>& aFontList);
// Returns the OS X version as returned from Gestalt(gestaltSystemVersion, ...)
// Ex: Mac OS X 10.4.x ==> 0x104x
int32_t OSXVersion();
bool UseAcceleratedCanvas();
// lower threshold on font anti-aliasing