Title: [219054] trunk
Revision
219054
Author
mmaxfi...@apple.com
Date
2017-07-01 16:29:07 -0700 (Sat, 01 Jul 2017)

Log Message

REGRESSION(r218371): Reeder's default font is Times instead of San Francisco
https://bugs.webkit.org/show_bug.cgi?id=173617
<rdar://problem/32969819>

Reviewed by Simon Fraser.

Source/WebCore:

On systems where USE_PLATFORM_SYSTEM_FALLBACK_LIST is set to true, the code in
platformFontWithFamilySpecialCase() is still used when @font-face blocks specify
src:local(system-ui), which made the assertion erroneously fire.

Unfortunately, our architecture is such that an @font-face block represents a
single entry in the font-family fallback list, which means it would be quite
difficult to make local(system-ui) in an @font-face block expand at the level
of the font cascade. So, this patch simply reverts to the previous behavior for
local(system-ui) (which doesn't include the entire Core Text cascade list).
This means that "font-family: system-ui" and "src: local(system-ui)" have
different behavior, which is undesirable, but architecturally difficult to
solve. I've added some FIXMEs to the code in the relevant places and filed
https://bugs.webkit.org/show_bug.cgi?id=174023.

Test: fast/text/font-face-local-system.html

* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::FontCascadeDescription::effectiveFamilyAt):
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::systemFontDescriptor):
(WebCore::platformFontWithFamilySpecialCase):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase):

LayoutTests:

* fast/text/font-face-local-system-expected.html: Added.
* fast/text/font-face-local-system.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (219053 => 219054)


--- trunk/LayoutTests/ChangeLog	2017-07-01 21:42:43 UTC (rev 219053)
+++ trunk/LayoutTests/ChangeLog	2017-07-01 23:29:07 UTC (rev 219054)
@@ -1,3 +1,14 @@
+2017-07-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(r218371): Reeder's default font is Times instead of San Francisco
+        https://bugs.webkit.org/show_bug.cgi?id=173617
+        <rdar://problem/32969819>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/font-face-local-system-expected.html: Added.
+        * fast/text/font-face-local-system.html: Added.
+
 2017-06-30  Said Abou-Hallawa  <sabouhall...@apple.com>
 
         If an image appears more than once on a page, decoding for painting one instance repaints them all

Added: trunk/LayoutTests/fast/text/font-face-local-system-expected.html (0 => 219054)


--- trunk/LayoutTests/fast/text/font-face-local-system-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-local-system-expected.html	2017-07-01 23:29:07 UTC (rev 219054)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that local("system-ui") works in @font-face blocks. The test passes if the text below is drawn in the system font.
+<div style="font: 100px 'system-ui';">Hello</div>
+</body>
+</html>
+

Added: trunk/LayoutTests/fast/text/font-face-local-system.html (0 => 219054)


--- trunk/LayoutTests/fast/text/font-face-local-system.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-local-system.html	2017-07-01 23:29:07 UTC (rev 219054)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebFont";
+    src: local("system-ui");
+}
+</style>
+</head>
+<body>
+This test makes sure that local("system-ui") works in @font-face blocks. The test passes if the text below is drawn in the system font.
+<div style="font: 100px 'WebFont';">Hello</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (219053 => 219054)


--- trunk/Source/WebCore/ChangeLog	2017-07-01 21:42:43 UTC (rev 219053)
+++ trunk/Source/WebCore/ChangeLog	2017-07-01 23:29:07 UTC (rev 219054)
@@ -1,3 +1,35 @@
+2017-07-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(r218371): Reeder's default font is Times instead of San Francisco
+        https://bugs.webkit.org/show_bug.cgi?id=173617
+        <rdar://problem/32969819>
+
+        Reviewed by Simon Fraser.
+
+        On systems where USE_PLATFORM_SYSTEM_FALLBACK_LIST is set to true, the code in
+        platformFontWithFamilySpecialCase() is still used when @font-face blocks specify
+        src:local(system-ui), which made the assertion erroneously fire.
+
+        Unfortunately, our architecture is such that an @font-face block represents a
+        single entry in the font-family fallback list, which means it would be quite
+        difficult to make local(system-ui) in an @font-face block expand at the level
+        of the font cascade. So, this patch simply reverts to the previous behavior for
+        local(system-ui) (which doesn't include the entire Core Text cascade list).
+        This means that "font-family: system-ui" and "src: local(system-ui)" have
+        different behavior, which is undesirable, but architecturally difficult to
+        solve. I've added some FIXMEs to the code in the relevant places and filed
+        https://bugs.webkit.org/show_bug.cgi?id=174023.
+
+        Test: fast/text/font-face-local-system.html
+
+        * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+        (WebCore::FontCascadeDescription::effectiveFamilyAt):
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::systemFontDescriptor):
+        (WebCore::platformFontWithFamilySpecialCase):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::platformFontWithFamilySpecialCase):
+
 2017-07-01  Ryosuke Niwa  <rn...@webkit.org>
 
         Frame.h doesn't need to include FrameLoader.h, IntRect.h, and NavigationScheduler.h

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp (219053 => 219054)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp	2017-07-01 21:42:43 UTC (rev 219053)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp	2017-07-01 23:29:07 UTC (rev 219054)
@@ -315,6 +315,13 @@
 
 FontFamilySpecification FontCascadeDescription::effectiveFamilyAt(unsigned index) const
 {
+    // The special cases in this function need to match the behavior in FontCacheIOS.mm and FontCacheMac.mm. On systems
+    // where USE_PLATFORM_SYSTEM_FALLBACK_LIST is set to true, this code is used for regular (element style) lookups,
+    // and the code in FontDescriptionCocoa.cpp is used when src:local(special-cased-name) is specified inside an
+    // @font-face block.
+    // FIXME: Currently, an @font-face block corresponds to a single item in the font-family: fallback list, which
+    // means that "src:local(system-ui)" can't follow the Core Text cascade list (the way it does for regular lookups).
+    // These two behaviors should be unified, which would hopefully allow us to delete this duplicate code.
     for (unsigned i = 0; i < familyCount(); ++i) {
         const auto& cssFamily = familyAt(i);
         if (isSystemFontString(cssFamily)) {

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (219053 => 219054)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2017-07-01 21:42:43 UTC (rev 219053)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2017-07-01 23:29:07 UTC (rev 219054)
@@ -80,7 +80,6 @@
     return *fontForFamily(fontDescription, AtomicString(".PhoneFallback", AtomicString::ConstructFromLiteral));
 }
 
-#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST
 static RetainPtr<CTFontDescriptorRef> baseSystemFontDescriptor(FontSelectionValue weight, bool bold, float size)
 {
     CTFontUIFontType fontType = kCTFontUIFontSystem;
@@ -143,12 +142,11 @@
     return fontDescriptor;
 #endif
 }
-#endif
 
 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest request, float size)
 {
+    // FIXME: See comment in FontCascadeDescription::effectiveFamilyAt() in FontDescriptionCocoa.cpp
     if (family.startsWith("UICTFontTextStyle")) {
-#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST
         CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) || FontCache::singleton().shouldMockBoldSystemFontForAccessibility() ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
         RetainPtr<CFStringRef> familyNameStr = family.string().createCFString();
         RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(familyNameStr.get(), RenderThemeIOS::contentSizeCategory(), nullptr));
@@ -156,18 +154,10 @@
             fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithSymbolicTraits(fontDescriptor.get(), traits, traits));
 
         return adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr));
-#else
-        UNUSED_PARAM(request);
-        ASSERT_NOT_REACHED();
-#endif
     }
 
     if (equalLettersIgnoringASCIICase(family, "-webkit-system-font") || equalLettersIgnoringASCIICase(family, "-apple-system") || equalLettersIgnoringASCIICase(family, "-apple-system-font") || equalLettersIgnoringASCIICase(family, "system-ui")) {
-#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST
         return adoptCF(CTFontCreateWithFontDescriptor(systemFontDescriptor(request.weight, isFontWeightBold(request.weight), isItalic(request.slope), size).get(), size, nullptr));
-#else
-        ASSERT_NOT_REACHED();
-#endif
     }
 
     if (equalLettersIgnoringASCIICase(family, "-apple-system-monospaced-numbers")) {

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (219053 => 219054)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2017-07-01 21:42:43 UTC (rev 219053)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2017-07-01 23:29:07 UTC (rev 219054)
@@ -54,7 +54,6 @@
 
 #if PLATFORM(MAC)
 
-#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST
 static CGFloat toNSFontWeight(FontSelectionValue fontWeight)
 {
     if (fontWeight < FontSelectionValue(150))
@@ -75,12 +74,11 @@
         return NSFontWeightHeavy;
     return NSFontWeightBlack;
 }
-#endif
 
 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest request, float size)
 {
+    // FIXME: See comment in FontCascadeDescription::effectiveFamilyAt() in FontDescriptionCocoa.cpp
     if (equalLettersIgnoringASCIICase(family, "-webkit-system-font") || equalLettersIgnoringASCIICase(family, "-apple-system") || equalLettersIgnoringASCIICase(family, "-apple-system-font") || equalLettersIgnoringASCIICase(family, "system-ui")) {
-#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST
         RetainPtr<CTFontRef> result = toCTFont([NSFont systemFontOfSize:size weight:toNSFontWeight(request.weight)]);
         if (isItalic(request.slope)) {
             CTFontSymbolicTraits desiredTraits = kCTFontItalicTrait;
@@ -90,10 +88,6 @@
                 result = italicizedFont;
         }
         return result;
-#else
-        UNUSED_PARAM(request);
-        ASSERT_NOT_REACHED();
-#endif
     }
 
     if (equalLettersIgnoringASCIICase(family, "-apple-system-monospaced-numbers")) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to