Bug 1803406 - Backout 2 changesets (6a82f1f120aa, 87d83c56fbe5) due to regression reported in bug 1858869.

Differential Revision: https://phabricator.services.mozilla.com/D190908
This commit is contained in:
Jonathan Kew
2023-10-13 08:32:56 +00:00
parent 783c00b6ad
commit 15c0b46b45
8 changed files with 22 additions and 52 deletions

View File

@@ -112,8 +112,7 @@ already_AddRefed<NativeFontResourceMac> NativeFontResourceMac::Create(
// creating the CGFontRef via the CTFont avoids the data being held alive
// in a cache.
CTFontRef ctFont = CTFontCreateWithFontDescriptorAndOptions(
ctFontDesc, 0, NULL, kCTFontOptionsPreferSystemFont);
CTFontRef ctFont = CTFontCreateWithFontDescriptor(ctFontDesc, 0, NULL);
// Creating the CGFont from the CTFont prevents the font data from being
// held in the TDescriptorSource cache. This appears to be true even

View File

@@ -713,8 +713,8 @@ already_AddRefed<ScaledFont> UnscaledFontMac::CreateScaledFont(
*reinterpret_cast<const ScaledFontMac::InstanceData*>(aInstanceData);
RefPtr<ScaledFontMac> scaledFont;
if (mFontDesc) {
AutoRelease<CTFontRef> font(CTFontCreateWithFontDescriptorAndOptions(
mFontDesc, aGlyphSize, nullptr, kCTFontOptionsPreferSystemFont));
AutoRelease<CTFontRef> font(
CTFontCreateWithFontDescriptor(mFontDesc, aGlyphSize, nullptr));
if (aNumVariations > 0) {
AutoRelease<CFDictionaryRef> varDict(CreateVariationTagDictionaryOrNull(
font, aNumVariations, aVariations));
@@ -728,8 +728,7 @@ already_AddRefed<ScaledFont> UnscaledFontMac::CreateScaledFont(
if (!fontDesc) {
return nullptr;
}
font = CTFontCreateWithFontDescriptorAndOptions(
fontDesc, aGlyphSize, nullptr, kCTFontOptionsPreferSystemFont);
font = CTFontCreateWithFontDescriptor(fontDesc, aGlyphSize, nullptr);
}
}
scaledFont = new ScaledFontMac(

View File

@@ -1503,8 +1503,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) {
}
prevFace = faceDesc;
AutoCFRelease<CTFontRef> fontRef = CTFontCreateWithFontDescriptorAndOptions(
faceDesc, 0.0, nullptr, kCTFontOptionsPreferSystemFont);
AutoCFRelease<CTFontRef> fontRef =
CTFontCreateWithFontDescriptor(faceDesc, 0.0, nullptr);
if (!fontRef) {
NS_WARNING("failed to create a CTFontRef");
continue;

View File

@@ -34,10 +34,7 @@ class gfxMacPlatformFontList final : public CoreTextFontList {
friend class gfxPlatformMac;
gfxMacPlatformFontList();
virtual ~gfxMacPlatformFontList() {
// Don't leak the name that was cached during startup.
sSystemFontName.~nsCString();
}
virtual ~gfxMacPlatformFontList() = default;
// Special-case font faces treated as font families (set via prefs)
void InitSingleFaceList() MOZ_REQUIRES(mLock) override;
@@ -46,11 +43,6 @@ class gfxMacPlatformFontList final : public CoreTextFontList {
// initialize system fonts
void InitSystemFontNames() override MOZ_REQUIRES(mLock);
// Static, so that the startup RegisterFonts thread can call it before the
// platform font list is created, to initialize & cache the name.
static const nsCString& GetSystemFontName();
static nsCString sSystemFontName;
nsTArray<nsCString> mSingleFaceFonts;
};

View File

@@ -433,26 +433,18 @@ static NSString* GetRealFamilyName(NSFont* aFont) {
return [familyName autorelease];
}
/* static */
const nsCString& gfxMacPlatformFontList::GetSystemFontName() {
if (sSystemFontName.IsEmpty()) {
NSString* name = GetRealFamilyName([NSFont systemFontOfSize:0.0]);
nsAutoString familyName;
nsCocoaUtils::GetStringForNSString(name, familyName);
CopyUTF16toUTF8(familyName, sSystemFontName);
}
return sSystemFontName;
}
nsCString gfxMacPlatformFontList::sSystemFontName;
void gfxMacPlatformFontList::InitSystemFontNames() {
mSystemFontFamilyName = GetSystemFontName();
// text font family
NSFont* sys = [NSFont systemFontOfSize:0.0];
NSString* textFamilyName = GetRealFamilyName(sys);
nsAutoString familyName;
nsCocoaUtils::GetStringForNSString(textFamilyName, familyName);
CopyUTF16toUTF8(familyName, mSystemFontFamilyName);
// We store an in-process gfxFontFamily for the system font even if using the
// shared fontlist to manage "normal" fonts, because the hidden system fonts
// may be excluded from the font list altogether. This family will be
// populated based on the given NSFont.
NSFont* sys = [NSFont systemFontOfSize:0.0];
RefPtr<gfxFontFamily> fam = new gfxMacFontFamily(mSystemFontFamilyName, sys);
if (fam) {
nsAutoCString key;

View File

@@ -64,8 +64,6 @@ void gfxPlatformMac::FontRegistrationCallback(void* aUnused) {
for (const auto& dir : kLangFontsDirs) {
gfxMacPlatformFontList::ActivateFontsFromDir(dir);
}
gfxMacPlatformFontList::GetSystemFontName();
}
PRThread* gfxPlatformMac::sFontRegistrationThread = nullptr;
@@ -76,21 +74,12 @@ PRThread* gfxPlatformMac::sFontRegistrationThread = nullptr;
our font list. */
/* static */
void gfxPlatformMac::RegisterSupplementalFonts() {
switch (XRE_GetProcessType()) {
case GeckoProcessType_Default:
case GeckoProcessType_Content:
// TODO: figure out if this matters to any other processes (e.g. GPU?)
//
// We activate the fonts on a separate thread, to minimize the startup-
// time cost.
sFontRegistrationThread = PR_CreateThread(
PR_USER_THREAD, FontRegistrationCallback, nullptr, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
break;
default:
// Assume other process types don't actually need the full font list.
break;
// On Catalina+, it appears to be sufficient to activate fonts in the parent
// process; they are then also usable in child processes.
if (XRE_IsParentProcess()) {
sFontRegistrationThread = PR_CreateThread(
PR_USER_THREAD, FontRegistrationCallback, nullptr, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
}
}

View File

@@ -93,7 +93,6 @@ class gfxPlatformMac : public gfxPlatform {
static void FontRegistrationCallback(void* aUnused);
nsCString mSystemFontName;
uint32_t mFontAntiAliasingThreshold;
static PRThread* sFontRegistrationThread;

View File

@@ -18,7 +18,7 @@ use core_graphics::font::{CGFont, CGGlyph};
use core_graphics::geometry::{CGAffineTransform, CGPoint, CGSize};
use core_graphics::geometry::{CG_AFFINE_TRANSFORM_IDENTITY, CGRect};
use core_text;
use core_text::font::{CTFont, kCTFontOptionsPreferSystemFont};
use core_text::font::CTFont;
use core_text::font_descriptor::{CTFontDescriptor, kCTFontDefaultOrientation, kCTFontVariationAttribute};
use core_text::font_manager;
use euclid::default::Size2D;
@@ -206,7 +206,7 @@ fn get_glyph_metrics(
}
fn new_ct_font_with_variations(ct_font_desc: &CTFontDescriptor, size: f64, variations: &[FontVariation]) -> CTFont {
let ct_font = core_text::font::new_from_descriptor_and_options(ct_font_desc, size, kCTFontOptionsPreferSystemFont);
let ct_font = core_text::font::new_from_descriptor(ct_font_desc, size);
if variations.is_empty() {
return ct_font;
}
@@ -221,7 +221,7 @@ fn new_ct_font_with_variations(ct_font_desc: &CTFontDescriptor, size: f64, varia
let variation_attribute = unsafe { CFString::wrap_under_get_rule(kCTFontVariationAttribute) };
let attrs_dict = CFDictionary::from_CFType_pairs(&[(variation_attribute, vals_dict)]);
let ct_var_font_desc = ct_font.copy_descriptor().create_copy_with_attributes(attrs_dict.to_untyped()).unwrap();
core_text::font::new_from_descriptor_and_options(&ct_var_font_desc, size, kCTFontOptionsPreferSystemFont)
core_text::font::new_from_descriptor(&ct_var_font_desc, size)
}