Title: [266667] trunk/Source
Revision
266667
Author
mmaxfi...@apple.com
Date
2020-09-05 11:21:20 -0700 (Sat, 05 Sep 2020)

Log Message

[Cocoa] CTFontIsSystemUIFont() is faster than CTFontDescriptorIsSystemUIFont()/CTFontCopyFontDescriptor()
https://bugs.webkit.org/show_bug.cgi?id=215687

Reviewed by Darin Adler.

Source/WebCore:

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/FontPlatformData.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::fontIsSystemFont):
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::primaryFontIsSystemFont const):
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::isSystemFont):

Source/WebCore/PAL:

* pal/spi/cocoa/CoreTextSPI.h:

Source/WTF:

* wtf/PlatformHave.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (266666 => 266667)


--- trunk/Source/WTF/ChangeLog	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WTF/ChangeLog	2020-09-05 18:21:20 UTC (rev 266667)
@@ -1,5 +1,14 @@
 2020-09-05  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        [Cocoa] CTFontIsSystemUIFont() is faster than CTFontDescriptorIsSystemUIFont()/CTFontCopyFontDescriptor()
+        https://bugs.webkit.org/show_bug.cgi?id=215687
+
+        Reviewed by Darin Adler.
+
+        * wtf/PlatformHave.h:
+
+2020-09-05  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         [Cocoa] Migrate off SPI in Font::platformWidthForGlyph()
         https://bugs.webkit.org/show_bug.cgi?id=215670
 

Modified: trunk/Source/WTF/wtf/PlatformHave.h (266666 => 266667)


--- trunk/Source/WTF/wtf/PlatformHave.h	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2020-09-05 18:21:20 UTC (rev 266667)
@@ -732,3 +732,10 @@
     || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 140000)
 #define HAVE_CFNETWORK_CNAME_AND_COOKIE_TRANSFORM_SPI 1
 #endif
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000) \
+    || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) \
+    || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 70000) \
+    || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 140000)
+#define HAVE_CTFONTISSYSTEMUIFONT 1
+#endif

Modified: trunk/Source/WebCore/ChangeLog (266666 => 266667)


--- trunk/Source/WebCore/ChangeLog	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/ChangeLog	2020-09-05 18:21:20 UTC (rev 266667)
@@ -1,5 +1,25 @@
 2020-09-05  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        [Cocoa] CTFontIsSystemUIFont() is faster than CTFontDescriptorIsSystemUIFont()/CTFontCopyFontDescriptor()
+        https://bugs.webkit.org/show_bug.cgi?id=215687
+
+        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/FontPlatformData.h:
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::fontIsSystemFont):
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::FontCascade::primaryFontIsSystemFont const):
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::isSystemFont):
+
+2020-09-05  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         [Cocoa] Migrate off SPI in Font::platformWidthForGlyph()
         https://bugs.webkit.org/show_bug.cgi?id=215670
 

Modified: trunk/Source/WebCore/PAL/ChangeLog (266666 => 266667)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-09-05 18:21:20 UTC (rev 266667)
@@ -1,3 +1,12 @@
+2020-09-05  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] CTFontIsSystemUIFont() is faster than CTFontDescriptorIsSystemUIFont()/CTFontCopyFontDescriptor()
+        https://bugs.webkit.org/show_bug.cgi?id=215687
+
+        Reviewed by Darin Adler.
+
+        * pal/spi/cocoa/CoreTextSPI.h:
+
 2020-09-04  Sihui Liu  <sihui_...@apple.com>
 
         Webpages flash when switching between windows

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h (266666 => 266667)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h	2020-09-05 18:21:20 UTC (rev 266667)
@@ -137,6 +137,7 @@
 extern const CFStringRef kCTFrameMaximumNumberOfLinesAttributeName;
 
 bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
+bool CTFontIsSystemUIFont(CTFontRef);
 CTFontRef CTFontCreateForCSS(CFStringRef name, uint16_t weight, CTFontSymbolicTraits, CGFloat size);
 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);

Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (266666 => 266667)


--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h	2020-09-05 18:21:20 UTC (rev 266667)
@@ -276,6 +276,10 @@
 #endif
 };
 
+#if PLATFORM(COCOA)
+bool isSystemFont(CTFontRef);
+#endif
+
 #if USE(APPKIT) && defined(__OBJC__)
 
 // NSFonts and CTFontRefs are toll-free-bridged.

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (266666 => 266667)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2020-09-05 18:21:20 UTC (rev 266667)
@@ -425,7 +425,7 @@
 
 static inline bool fontIsSystemFont(CTFontRef font)
 {
-    if (CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()))
+    if (isSystemFont(font))
         return true;
 
     auto name = adoptCF(CTFontCopyPostScriptName(font));

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (266666 => 266667)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2020-09-05 18:21:20 UTC (rev 266667)
@@ -316,7 +316,7 @@
 bool FontCascade::primaryFontIsSystemFont() const
 {
     const auto& fontData = primaryFont();
-    return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(fontData.platformData().ctFont())).get());
+    return isSystemFont(fontData.platformData().ctFont());
 }
 
 // FIXME: Use this on all ports.

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm (266666 => 266667)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2020-09-05 18:07:19 UTC (rev 266666)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm	2020-09-05 18:21:20 UTC (rev 266667)
@@ -35,6 +35,15 @@
 
 namespace WebCore {
 
+bool isSystemFont(CTFontRef font)
+{
+#if HAVE(CTFONTISSYSTEMUIFONT)
+    return CTFontIsSystemUIFont(font);
+#else
+    return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
+#endif
+}
+
 // These CoreText Text Spacing feature selectors are not defined in CoreText.
 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidth, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };
 
@@ -44,7 +53,7 @@
     ASSERT_ARG(font, font);
     m_font = font;
     m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFontTraitColorGlyphs;
-    m_isSystemFont = CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(m_font.get())).get());
+    m_isSystemFont = WebCore::isSystemFont(m_font.get());
     auto variations = adoptCF(static_cast<CFDictionaryRef>(CTFontCopyAttribute(font, kCTFontVariationAttribute)));
     m_hasVariations = variations && CFDictionaryGetCount(variations.get());
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to