[Cocoa] Add ui-sans-serif as a sibling to ui-serif, ui-monospace, and ui-rounded
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Nov 2019 22:29:44 +0000 (22:29 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Nov 2019 22:29:44 +0000 (22:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204188

Reviewed by Simon Fraser.

Source/WebCore:

As per https://github.com/w3c/csswg-drafts/commit/cd0059a32a74c5a48630ce7c77292642dac70fd9#diff-dd2d54c50c872e1e303daebd4794d642

Test: fast/text/design-system-ui-sans-serif.html

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::fontWithFamilySpecialCase):
* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::matchSystemFontUse):

LayoutTests:

* fast/text/design-system-ui-sans-serif-expected.html: Added.
* fast/text/design-system-ui-sans-serif.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252710 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/design-system-ui-sans-serif-expected.html [new file with mode: 0644]
LayoutTests/fast/text/design-system-ui-sans-serif.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp

index ea560a1..0e1dbb1 100644 (file)
@@ -1,3 +1,13 @@
+2019-11-20  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Add ui-sans-serif as a sibling to ui-serif, ui-monospace, and ui-rounded
+        https://bugs.webkit.org/show_bug.cgi?id=204188
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/design-system-ui-sans-serif-expected.html: Added.
+        * fast/text/design-system-ui-sans-serif.html: Added.
+
 2019-11-20  Truitt Savell  <tsavell@apple.com>
 
         Add platform specific expectations for High Sierra and Mojave for svg/custom/glyph-selection-arabic-forms.svg
diff --git a/LayoutTests/fast/text/design-system-ui-sans-serif-expected.html b/LayoutTests/fast/text/design-system-ui-sans-serif-expected.html
new file mode 100644 (file)
index 0000000..c32cc3b
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebFont";
+    src: local("system-ui");
+}
+</style>
+</head>
+<body>
+This test makes sure that <code>ui-sans-serif</code> matches <code>system-ui</code>.
+<div style="font: 72px system-ui;">HeJllo</div>
+<div style="font: 72px WebFont;">HeJllo</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/design-system-ui-sans-serif.html b/LayoutTests/fast/text/design-system-ui-sans-serif.html
new file mode 100644 (file)
index 0000000..5872a46
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebFont";
+    src: local("ui-sans-serif");
+}
+</style>
+</head>
+<body>
+This test makes sure that <code>ui-sans-serif</code> matches <code>system-ui</code>.
+<div style="font: 72px ui-sans-serif;">HeJllo</div>
+<div style="font: 72px WebFont;">HeJllo</div>
+</body>
+</html>
index 59c00cc..5fb65d4 100644 (file)
@@ -1,3 +1,19 @@
+2019-11-20  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [Cocoa] Add ui-sans-serif as a sibling to ui-serif, ui-monospace, and ui-rounded
+        https://bugs.webkit.org/show_bug.cgi?id=204188
+
+        Reviewed by Simon Fraser.
+
+        As per https://github.com/w3c/csswg-drafts/commit/cd0059a32a74c5a48630ce7c77292642dac70fd9#diff-dd2d54c50c872e1e303daebd4794d642
+
+        Test: fast/text/design-system-ui-sans-serif.html
+
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::fontWithFamilySpecialCase):
+        * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+        (WebCore::matchSystemFontUse):
+
 2019-11-19  Brian Burg  <bburg@apple.com>
 
         [Cocoa] Add _WKRemoteWebInspectorViewController SPI to set diagnostic logging delegate
index c02ea4b..5b18118 100644 (file)
@@ -1269,26 +1269,27 @@ static void invalidateFontCache()
 
 static RetainPtr<CTFontRef> fontWithFamilySpecialCase(const AtomString& family, const FontDescription& fontDescription, float size, AllowUserInstalledFonts allowUserInstalledFonts)
 {
-#if HAVE(DESIGN_SYSTEM_UI_FONTS)
     Optional<SystemFontDatabaseCoreText::ClientUse> designSystemUI;
+
+#if HAVE(DESIGN_SYSTEM_UI_FONTS)
     if (equalLettersIgnoringASCIICase(family, "ui-serif"))
         designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUISerif;
     else if (equalLettersIgnoringASCIICase(family, "ui-monospace"))
         designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIMonospace;
     else if (equalLettersIgnoringASCIICase(family, "ui-rounded"))
         designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUIRounded;
+#endif
+
+    if (equalLettersIgnoringASCIICase(family, "ui-sans-serif")) {
+        ASSERT(!designSystemUI);
+        designSystemUI = SystemFontDatabaseCoreText::ClientUse::ForSystemUI;
+    }
 
     if (designSystemUI) {
         auto cascadeList = SystemFontDatabaseCoreText::singleton().cascadeList(fontDescription, family, *designSystemUI, allowUserInstalledFonts);
         if (!cascadeList.isEmpty())
             return createFontForInstalledFonts(cascadeList[0].get(), size, allowUserInstalledFonts);
     }
-#else
-    UNUSED_PARAM(family);
-    UNUSED_PARAM(fontDescription);
-    UNUSED_PARAM(size);
-    UNUSED_PARAM(allowUserInstalledFonts);
-#endif
 
     return nullptr;
 }
index 9171d85..0d88169 100644 (file)
@@ -52,7 +52,8 @@ static inline Optional<SystemFontDatabaseCoreText::ClientUse> matchSystemFontUse
     if (equalLettersIgnoringASCIICase(string, "-webkit-system-font")
         || equalLettersIgnoringASCIICase(string, "-apple-system")
         || equalLettersIgnoringASCIICase(string, "-apple-system-font")
-        || equalLettersIgnoringASCIICase(string, "system-ui"))
+        || equalLettersIgnoringASCIICase(string, "system-ui")
+        || equalLettersIgnoringASCIICase(string, "ui-sans-serif"))
         return SystemFontDatabaseCoreText::ClientUse::ForSystemUI;
 
 #if HAVE(DESIGN_SYSTEM_UI_FONTS)