Diff
Modified: trunk/Source/WTF/ChangeLog (266689 => 266690)
--- trunk/Source/WTF/ChangeLog 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WTF/ChangeLog 2020-09-07 01:33:30 UTC (rev 266690)
@@ -1,3 +1,12 @@
+2020-09-06 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ CTFontGetPhysicalSymbolicTraits() is faster than CTFontCopyPhysicalFont()/CTFontGetSymbolicTraits()
+ https://bugs.webkit.org/show_bug.cgi?id=215685
+
+ Reviewed by Darin Adler.
+
+ * wtf/PlatformHave.h:
+
2020-09-06 Darin Adler <da...@apple.com>
TextCodec refinements
Modified: trunk/Source/WTF/wtf/PlatformHave.h (266689 => 266690)
--- trunk/Source/WTF/wtf/PlatformHave.h 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2020-09-07 01:33:30 UTC (rev 266690)
@@ -739,3 +739,7 @@
|| (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 140000)
#define HAVE_CTFONTISSYSTEMUIFONT 1
#endif
+
+#if PLATFORM(COCOA) && !(PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500)
+#define HAVE_CTFONTGETPHYSICALSYMBOLICTRAITS 1
+#endif
Modified: trunk/Source/WebCore/ChangeLog (266689 => 266690)
--- trunk/Source/WebCore/ChangeLog 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WebCore/ChangeLog 2020-09-07 01:33:30 UTC (rev 266690)
@@ -1,3 +1,21 @@
+2020-09-06 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ CTFontGetPhysicalSymbolicTraits() is faster than CTFontCopyPhysicalFont()/CTFontGetSymbolicTraits()
+ https://bugs.webkit.org/show_bug.cgi?id=215685
+
+ Reviewed by Darin Adler.
+
+ Instead of making the two calls, we can make a single call that has the same effect.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::computeNecessarySynthesis):
+ (WebCore::FontCache::systemFallbackForCharacters):
+ * platform/graphics/cocoa/FontCacheCoreText.h:
+ * platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
+ (WebCore::FontFamilySpecificationCoreText::fontRanges const):
+
2020-09-06 Wenson Hsieh <wenson_hs...@apple.com>
[MotionMark - Multiply] Web process spends ~1% of total samples in PropertyCascade::resolveDirectionAndWritingMode
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h (266689 => 266690)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2020-09-07 01:33:30 UTC (rev 266690)
@@ -142,6 +142,7 @@
CTFontRef CTFontCreateForCharactersWithLanguage(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CFIndex *coveredLength);
CTFontRef CTFontCreateForCharactersWithLanguageAndOption(CTFontRef currentFont, const UTF16Char *characters, CFIndex length, CFStringRef language, CTFontFallbackOption option, CFIndex *coveredLength);
CTFontRef CTFontCopyPhysicalFont(CTFontRef);
+CTFontSymbolicTraits CTFontGetPhysicalSymbolicTraits(CTFontRef);
extern const CFStringRef kCTUIFontTextStyleShortHeadline;
extern const CFStringRef kCTUIFontTextStyleShortBody;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (266689 => 266690)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2020-09-07 01:33:30 UTC (rev 266690)
@@ -816,7 +816,7 @@
return traits;
}
-SynthesisPair computeNecessarySynthesis(CTFontRef font, const FontDescription& fontDescription, bool isPlatformFont)
+SynthesisPair computeNecessarySynthesis(CTFontRef font, const FontDescription& fontDescription, ShouldComputePhysicalTraits shouldComputePhysicalTraits, bool isPlatformFont)
{
if (CTFontIsAppleColorEmoji(font))
return SynthesisPair(false, false);
@@ -827,8 +827,19 @@
CTFontSymbolicTraits desiredTraits = computeTraits(fontDescription);
CTFontSymbolicTraits actualTraits = 0;
- if (isFontWeightBold(fontDescription.weight()) || isItalic(fontDescription.italic()))
- actualTraits = CTFontGetSymbolicTraits(font);
+ if (isFontWeightBold(fontDescription.weight()) || isItalic(fontDescription.italic())) {
+ if (shouldComputePhysicalTraits == ShouldComputePhysicalTraits::Yes) {
+#if HAVE(CTFONTGETPHYSICALSYMBOLICTRAITS)
+ actualTraits = CTFontGetPhysicalSymbolicTraits(font);
+#else
+ auto fontForSynthesisComputation = retainPtr(font);
+ if (auto physicalFont = adoptCF(CTFontCopyPhysicalFont(font)))
+ fontForSynthesisComputation = WTFMove(physicalFont);
+ actualTraits = CTFontGetSymbolicTraits(fontForSynthesisComputation.get());
+#endif
+ } else
+ actualTraits = CTFontGetSymbolicTraits(font);
+ }
bool needsSyntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && (desiredTraits & kCTFontTraitBold) && !(actualTraits & kCTFontTraitBold);
bool needsSyntheticOblique = (fontDescription.fontSynthesis() & FontSynthesisStyle) && (desiredTraits & kCTFontTraitItalic) && !(actualTraits & kCTFontTraitItalic);
@@ -1494,7 +1505,7 @@
// font pointer.
CTFontRef substituteFont = fallbackDedupSet().add(result).iterator->get();
- auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(substituteFont, description, isForPlatformFont == IsForPlatformFont::Yes).boldObliquePair();
+ auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(substituteFont, description, ShouldComputePhysicalTraits::No, isForPlatformFont == IsForPlatformFont::Yes).boldObliquePair();
FontPlatformData alternateFont(substituteFont, platformData.size(), syntheticBold, syntheticOblique, platformData.orientation(), platformData.widthVariant(), platformData.textRenderingMode());
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h (266689 => 266690)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2020-09-07 01:33:30 UTC (rev 266690)
@@ -51,7 +51,8 @@
};
RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, FontSelectionSpecifiedCapabilities fontFaceCapabilities, bool applyWeightWidthSlopeVariations = true);
-SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
+enum class ShouldComputePhysicalTraits : bool { No, Yes };
+SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, ShouldComputePhysicalTraits = ShouldComputePhysicalTraits::No, bool isPlatformFont = false);
RetainPtr<CTFontRef> platformFontWithFamily(const AtomString& family, FontSelectionRequest, TextRenderingMode, float size);
FontSelectionCapabilities capabilitiesForFontDescriptor(CTFontDescriptorRef);
void addAttributesForInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp (266689 => 266690)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp 2020-09-07 00:59:52 UTC (rev 266689)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp 2020-09-07 01:33:30 UTC (rev 266690)
@@ -102,13 +102,9 @@
auto font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
- auto fontForSynthesisComputation = font;
- if (auto physicalFont = adoptCF(CTFontCopyPhysicalFont(font.get())))
- fontForSynthesisComputation = physicalFont;
-
font = preparePlatformFont(font.get(), fontDescription, nullptr, { });
- auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(fontForSynthesisComputation.get(), fontDescription).boldObliquePair();
+ auto [syntheticBold, syntheticOblique] = computeNecessarySynthesis(font.get(), fontDescription, ShouldComputePhysicalTraits::Yes).boldObliquePair();
return makeUnique<FontPlatformData>(font.get(), size, false, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
}).iterator->value;