Diff
Modified: trunk/LayoutTests/ChangeLog (241287 => 241288)
--- trunk/LayoutTests/ChangeLog 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/ChangeLog 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,3 +1,25 @@
+2019-02-11 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Ask platform for generic font family mappings
+ https://bugs.webkit.org/show_bug.cgi?id=187723
+ <rdar://problem/41892438>
+
+ Reviewed by Brent Fulgham.
+
+ Update the tests to work with this new model.
+
+ * fast/text/international/font-fallback-to-common-script-expected.html: Removed.
+ * fast/text/international/font-fallback-to-common-script.html: Removed.
+ * fast/text/international/lang-sensitive-fonts-expected.html:
+ * fast/text/international/lang-sensitive-fonts-xml-expected.html:
+ * fast/text/international/lang-sensitive-fonts-xml.xhtml:
+ * fast/text/international/lang-sensitive-fonts.html:
+ * fast/text/international/locale-sensitive-fonts-expected.html:
+ * fast/text/international/locale-sensitive-fonts.html:
+ * fast/text/ja-sans-serif-expected-mismatch.html: Added.
+ * fast/text/ja-sans-serif.html: Added.
+ * platform/ios/fast/block/float/016-expected.txt:
+
2019-02-11 Shawn Roberts <srobe...@apple.com>
Updating for all of Mac WK2 for flaky test
Deleted: trunk/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,8 +0,0 @@
-<html>
-<body>
-<div style="font-size: 20px">
-<div style="font-family: 'Ahem'">this is ahem font</div>
-<div style="font-family: 'Ahem'">this is ahem font</div>
-</div>
-</body>
-</html>
Deleted: trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/font-fallback-to-common-script.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script>
-if (window.internals) {
- window.internals.settings.setStandardFontFamily("Times", "Hans");
- window.internals.settings.setStandardFontFamily("", "Hans");
- window.internals.settings.setStandardFontFamily("Ahem", "Zyyy");
-
- window.internals.settings.setSansSerifFontFamily("Ahem", "Zyyy");
-
- window.internals.setUserPreferredLanguages("en", "zh-cn");
-}
-</script>
-</head>
-<body>
-<!-- Test for font fallback to the common script when the per-script font setting is missing or the empty string.
-Bug 81329 <https://bugs.webkit.org/show_bug.cgi?id=81329> -->
-<div style="font-size: 20px">
-<div lang="zh-CN">this is ahem font</div>
-
-<!-- Test fallback to common script when no setting is set. This assumes there is no setting for "Zxxx" (script code for unwritten languages). -->
-<div lang="und-Zxxx" style="font-family: sans-serif;">this is ahem font</div>
-</div>
-</body>
-</html>
Modified: trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -4,7 +4,6 @@
<div style="font-family: 'Ahem'">this is ahem font</div>
<div style="font-family: 'Ahem'">this is ahem font</div>
<div style="font-family: 'Ahem'">this is ahem font</div>
-<div style="font-family: 'Ahem'">this is ahem font</div>
<div>this is not ahem font</div>
</div>
</body>
Modified: trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -5,7 +5,6 @@
<div>this is ahem font</div>
<div>this is ahem font</div>
<div>this is ahem font</div>
-<div>this is ahem font</div>
</div>
</body>
</html>
Modified: trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml 2019-02-12 02:19:19 UTC (rev 241288)
@@ -21,14 +21,10 @@
<div style="font-family: 'Ahem'">this is ahem font</div>
<div lang="zh-CN">this is ahem font</div>
<div id="target1" lang="ar">this is ahem font</div>
-<div id="target2" lang="ar" style="font-family: sans-serif">this is ahem font</div>
<div xml:lang="zh-CN">this is ahem font</div>
</div>
<script>
document.getElementById("target1").lang = "zh-CN";
-
-document.getElementById("target2").lang = "zh-CN";
-document.getElementById("target2").style.fontFamily = "fantasy";
</script>
</body>
</html>
Modified: trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/lang-sensitive-fonts.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -20,14 +20,10 @@
<div style="font-family: 'Ahem'">this is ahem font</div>
<div lang="zh-CN">this is ahem font</div>
<div id="target1" lang="ar">this is ahem font</div>
-<div id="target2" lang="ar" style="font-family: sans-serif">this is ahem font</div>
<div xml:lang="zh-CN">this is not ahem font</div>
</div>
<script>
document.getElementById("target1").lang = "zh-CN";
-
-document.getElementById("target2").lang = "zh-CN";
-document.getElementById("target2").style.fontFamily = "fantasy";
</script>
</body>
</html>
Modified: trunk/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -6,7 +6,6 @@
<div style="font-size: 20px">
<div style="font-family: 'Ahem'">this is ahem font</div>
<div style="font-family: 'Ahem'">this is ahem font</div>
-<div style="font-family: 'Ahem'">this is ahem font</div>
</div>
</body>
</html>
Modified: trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html (241287 => 241288)
--- trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/fast/text/international/locale-sensitive-fonts.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -16,7 +16,6 @@
<div style="font-size: 20px">
<div style="font-family: 'Ahem'">this is ahem font</div>
<div style="-webkit-locale: 'zh_CN'">this is ahem font</div>
-<div style="-webkit-locale: 'zh_CN'; font-family: fantasy">this is ahem font</div>
</div>
</body>
</html>
Added: trunk/LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html (0 => 241288)
--- trunk/LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html (rev 0)
+++ trunk/LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<div lang="ja" style="font: 48px serif;">かくれキリシ</div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/text/ja-sans-serif.html (0 => 241288)
--- trunk/LayoutTests/fast/text/ja-sans-serif.html (rev 0)
+++ trunk/LayoutTests/fast/text/ja-sans-serif.html 2019-02-12 02:19:19 UTC (rev 241288)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+<div lang="ja" style="font: 48px sans-serif;">かくれキリシ</div>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/ios/fast/block/float/016-expected.txt (241287 => 241288)
--- trunk/LayoutTests/platform/ios/fast/block/float/016-expected.txt 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/LayoutTests/platform/ios/fast/block/float/016-expected.txt 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,8 +1,8 @@
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
-layer at (0,0) size 800x511
- RenderBlock {HTML} at (0,0) size 800x512
- RenderBody {BODY} at (8,8) size 784x488
+layer at (0,0) size 800x512
+ RenderBlock {HTML} at (0,0) size 800x513
+ RenderBody {BODY} at (8,8) size 784x489
RenderBlock {UL} at (185,0) size 414x192
RenderListItem {LI} at (0,48) size 284x72
RenderBlock {A} at (123,0) size 161x139 [color=#CCCCCC]
@@ -62,6 +62,6 @@
RenderBlock {SPAN} at (8,61) size 144x21 [color=#000000]
RenderText {#text} at (59,0) size 26x20
text run at (59,0) width 26: "exit"
- RenderBlock {P} at (0,403) size 784x85
- RenderText {#text} at (327,32) size 130x19
- text run at (327,32) width 130: "Ceci n'est pas Flash."
+ RenderBlock {P} at (0,403) size 784x86
+ RenderText {#text} at (331,32) size 122x21
+ text run at (331,32) width 122: "Ceci n'est pas Flash."
Modified: trunk/Source/WTF/ChangeLog (241287 => 241288)
--- trunk/Source/WTF/ChangeLog 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WTF/ChangeLog 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,3 +1,15 @@
+2019-02-11 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Ask platform for generic font family mappings
+ https://bugs.webkit.org/show_bug.cgi?id=187723
+ <rdar://problem/41892438>
+
+ Reviewed by Brent Fulgham.
+
+ Add an ENABLE in Platform.
+
+ * wtf/Platform.h:
+
2019-02-11 Truitt Savell <tsav...@apple.com>
Unreviewed, rolling out r241229.
Modified: trunk/Source/WTF/wtf/Platform.h (241287 => 241288)
--- trunk/Source/WTF/wtf/Platform.h 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WTF/wtf/Platform.h 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1498,3 +1498,9 @@
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
#define HAVE_CSCHECKFIXDISABLE 1
#endif
+
+#if PLATFORM(MAC)
+#define ENABLE_MONOSPACE_FONT_EXCEPTION (__MAC_OS_X_VERSION_MIN_REQUIRED < 101500)
+#elif PLATFORM(IOS_FAMILY)
+#define ENABLE_MONOSPACE_FONT_EXCEPTION (__IPHONE_OS_VERSION_MIN_REQUIRED < 130000)
+#endif
Modified: trunk/Source/WebCore/ChangeLog (241287 => 241288)
--- trunk/Source/WebCore/ChangeLog 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/ChangeLog 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,3 +1,57 @@
+2019-02-11 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Ask platform for generic font family mappings
+ https://bugs.webkit.org/show_bug.cgi?id=187723
+ <rdar://problem/41892438>
+
+ Reviewed by Brent Fulgham.
+
+ WebKit API allows setting the generic font families for the USCRIPT_COMMON script.
+ When trying to style a character with a generic font family, we first look to see if
+ we have a mapping for the particular script the character is rendered with, and if we
+ don't find a match, we then check USCRIPT_COMMON.
+
+ In the Cocoa ports, the only way families get set for non-USCRIPT_COMMON scripts (aka
+ the only scripts which won't use the API families) is in
+ SettingsBase::initializeDefaultFontFamilies(). That function only sets the families
+ for the CJK scripts.
+
+ The mappings inside SettingsBase are incorrect and conflict with our policy regarding
+ user-installed fonts. Instead, we should be consulting with the platform for some of
+ these mappings, by calling CTFontDescriptorCreateForCSSFamily(). However, the WebKit
+ API still has to work to set the mappings for untagged content. Therefore, we use the
+ system mappings for language-tagged content, and the API mappings for non-language-tagged
+ content. This is a good balance that makes sure we always have a good mapping for every
+ language, but API clients can still set the mappings, too.
+
+ Test: fast/text/ja-sans-serif.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ * css/CSSFontSelector.cpp:
+ (WebCore::resolveGenericFamily):
+ * css/parser/CSSPropertyParser.cpp:
+ (WebCore::consumeFontFamily):
+ * page/cocoa/SettingsBaseCocoa.mm:
+ (WebCore::SettingsBase::initializeDefaultFontFamilies):
+ (WebCore::osakaMonoIsInstalled): Deleted.
+ * platform/graphics/FontDescription.cpp:
+ (WebCore::FontDescription::platformResolveGenericFamily):
+ * platform/graphics/FontDescription.h:
+ * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+ (WebCore::computeSpecializedChineseLocale):
+ (WebCore::cachedSpecializedChineseLocale):
+ (WebCore::languageChanged):
+ (WebCore::FontDescription::platformResolveGenericFamily):
+ * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
+ (WebCore::SystemFontDatabaseCoreText::clear):
+ (WebCore::genericFamily):
+ (WebCore::SystemFontDatabaseCoreText::serifFamily):
+ (WebCore::SystemFontDatabaseCoreText::sansSerifFamily):
+ (WebCore::SystemFontDatabaseCoreText::cursiveFamily):
+ (WebCore::SystemFontDatabaseCoreText::fantasyFamily):
+ (WebCore::SystemFontDatabaseCoreText::monospaceFamily):
+ * platform/graphics/cocoa/SystemFontDatabaseCoreText.h:
+
2019-02-11 Adrian Perez de Castro <ape...@igalia.com>
[GTK][WPE] Add content extensions support in WKTR and unskip layout tests
Modified: trunk/Source/WebCore/PAL/ChangeLog (241287 => 241288)
--- trunk/Source/WebCore/PAL/ChangeLog 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/PAL/ChangeLog 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,3 +1,13 @@
+2019-02-11 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Ask platform for generic font family mappings
+ https://bugs.webkit.org/show_bug.cgi?id=187723
+ <rdar://problem/41892438>
+
+ Reviewed by Brent Fulgham.
+
+ * pal/spi/cocoa/CoreTextSPI.h:
+
2019-02-11 Jer Noble <jer.no...@apple.com>
[Cocoa] Notify AVSystemController of our presenting PID before registering as a Now Playing app.
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h (241287 => 241288)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2019-02-12 02:19:19 UTC (rev 241288)
@@ -79,6 +79,13 @@
extern const CFStringRef kCTFontUserInstalledAttribute;
extern const CFStringRef kCTFontFallbackOptionAttribute;
+extern const CFStringRef kCTFontCSSFamilySerif;
+extern const CFStringRef kCTFontCSSFamilySansSerif;
+extern const CFStringRef kCTFontCSSFamilyCursive;
+extern const CFStringRef kCTFontCSSFamilyFantasy;
+extern const CFStringRef kCTFontCSSFamilyMonospace;
+extern const CFStringRef kCTFontCSSFamilySystemUI;
+
bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions);
CGSize CTRunGetInitialAdvance(CTRunRef);
@@ -87,6 +94,7 @@
CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions(CTUniCharProviderCallback, CTUniCharDisposeCallback, void* refCon, CFDictionaryRef options);
bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar characters[], CGGlyph glyphs[], CFIndex count);
void CTFontGetUnsummedAdvancesForGlyphsAndStyle(CTFontRef, CTFontOrientation, CGFontRenderingStyle, const CGGlyph[], CGSize advances[], CFIndex count);
+CTFontDescriptorRef CTFontDescriptorCreateForCSSFamily(CFStringRef cssFamily, CFStringRef language);
CTFontDescriptorRef CTFontDescriptorCreateForUIType(CTFontUIFontType, CGFloat size, CFStringRef language);
CTFontDescriptorRef CTFontDescriptorCreateWithTextStyle(CFStringRef style, CFStringRef size, CFStringRef language);
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (241287 => 241288)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1720,7 +1720,6 @@
return style->fontDescription().useFixedDefaultSize();
}
-
static CSSValueID identifierForFamily(const AtomicString& family)
{
if (family == cursiveFamily)
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (241287 => 241288)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2019-02-12 02:19:19 UTC (rev 241288)
@@ -274,8 +274,12 @@
dispatchInvalidationCallbacks();
}
-static const AtomicString& resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
+static AtomicString resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName)
{
+ auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.locale(), familyName);
+ if (!platformResult.isNull())
+ return platformResult;
+
if (!document)
return familyName;
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp (241287 => 241288)
--- trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1067,16 +1067,13 @@
{
RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
do {
- RefPtr<CSSValue> parsedValue = consumeGenericFamily(range);
- if (parsedValue) {
+ if (auto parsedValue = consumeGenericFamily(range))
list->append(parsedValue.releaseNonNull());
- } else {
- parsedValue = consumeFamilyName(range);
- if (parsedValue) {
+ else {
+ if (auto parsedValue = consumeFamilyName(range))
list->append(parsedValue.releaseNonNull());
- } else {
+ else
return nullptr;
- }
}
} while (consumeCommaIncludingWhitespace(range));
return list;
Modified: trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm (241287 => 241288)
--- trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm 2019-02-12 02:19:19 UTC (rev 241288)
@@ -48,41 +48,12 @@
#if PLATFORM(MAC)
-static bool osakaMonoIsInstalled()
-{
- int _one_ = 1;
- RetainPtr<CFNumberRef> yes = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &one));
- CFTypeRef keys[] = { kCTFontEnabledAttribute, kCTFontNameAttribute };
- CFTypeRef values[] = { yes.get(), CFSTR("Osaka-Mono") };
- RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(values), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
- RetainPtr<CFSetRef> mandatoryAttributes = adoptCF(CFSetCreate(kCFAllocatorDefault, keys, WTF_ARRAY_LENGTH(keys), &kCFTypeSetCallBacks));
- return adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(descriptor.get(), mandatoryAttributes.get()));
-}
-
void SettingsBase::initializeDefaultFontFamilies()
{
setStandardFontFamily("Songti TC", USCRIPT_TRADITIONAL_HAN);
- setSerifFontFamily("Songti TC", USCRIPT_TRADITIONAL_HAN);
- setFixedFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN);
- setSansSerifFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN);
- setCursiveFontFamily("Kaiti TC", USCRIPT_TRADITIONAL_HAN);
-
setStandardFontFamily("Songti SC", USCRIPT_SIMPLIFIED_HAN);
- setSerifFontFamily("Songti SC", USCRIPT_SIMPLIFIED_HAN);
- setFixedFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN);
- setSansSerifFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN);
- setCursiveFontFamily("Kaiti SC", USCRIPT_SIMPLIFIED_HAN);
-
setStandardFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
- setFixedFontFamily(osakaMonoIsInstalled() ? "Osaka-Mono" : "Hiragino Sans", USCRIPT_KATAKANA_OR_HIRAGANA);
- setSerifFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
- setSansSerifFontFamily("Hiragino Kaku Gothic ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
-
setStandardFontFamily("AppleMyungjo", USCRIPT_HANGUL);
- setSerifFontFamily("AppleMyungjo", USCRIPT_HANGUL);
- setFixedFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL);
- setSansSerifFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL);
setStandardFontFamily("Times", USCRIPT_COMMON);
setFixedFontFamily("Courier", USCRIPT_COMMON);
@@ -99,28 +70,10 @@
void SettingsBase::initializeDefaultFontFamilies()
{
- // There is no serif Chinese font in default iOS installation.
setStandardFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN);
- setSerifFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN);
- setFixedFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN);
- setSansSerifFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN);
-
- // There is no serif Chinese font in default iOS installation.
setStandardFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN);
- setSerifFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN);
- setFixedFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN);
- setSansSerifFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN);
-
setStandardFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
- setFixedFontFamily("Hiragino Kaku Gothic ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
- setSerifFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
- setSansSerifFontFamily("Hiragino Kaku Gothic ProN", USCRIPT_KATAKANA_OR_HIRAGANA);
-
- // There is no serif Korean font in default iOS installation.
setStandardFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL);
- setSerifFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL);
- setFixedFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL);
- setSansSerifFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL);
setStandardFontFamily("Times", USCRIPT_COMMON);
setFixedFontFamily("Courier", USCRIPT_COMMON);
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.cpp (241287 => 241288)
--- trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2019-02-12 02:19:19 UTC (rev 241288)
@@ -71,4 +71,11 @@
m_script = localeToScriptCodeForFontSelection(m_locale);
}
+#if !PLATFORM(COCOA)
+AtomicString FontDescription::platformResolveGenericFamily(UScriptCode, const AtomicString&, const AtomicString&)
+{
+ return nullAtom();
+}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (241287 => 241288)
--- trunk/Source/WebCore/platform/graphics/FontDescription.h 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h 2019-02-12 02:19:19 UTC (rev 241288)
@@ -133,6 +133,8 @@
void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; }
void setShouldAllowUserInstalledFonts(AllowUserInstalledFonts shouldAllowUserInstalledFonts) { m_shouldAllowUserInstalledFonts = static_cast<unsigned>(shouldAllowUserInstalledFonts); }
+ static AtomicString platformResolveGenericFamily(UScriptCode, const AtomicString& locale, const AtomicString& familyName);
+
private:
// FIXME: Investigate moving these into their own object on the heap (to save memory).
FontFeatureSettings m_featureSettings;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp (241287 => 241288)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp 2019-02-12 02:19:19 UTC (rev 241288)
@@ -27,11 +27,13 @@
#include "FontDescription.h"
#include "SystemFontDatabaseCoreText.h"
+#include <mutex>
+#include <wtf/Language.h>
+namespace WebCore {
+
#if USE_PLATFORM_SYSTEM_FALLBACK_LIST
-namespace WebCore {
-
static inline bool isSystemFontString(const AtomicString& string)
{
return equalLettersIgnoringASCIICase(string, "-webkit-system-font")
@@ -138,7 +140,58 @@
return nullAtom();
}
+#endif // USE_PLATFORM_SYSTEM_FALLBACK_LIST
+
+static String computeSpecializedChineseLocale()
+{
+ const Vector<String>& preferredLanguages = userPreferredLanguages();
+ for (auto& language : preferredLanguages) {
+ if (equalIgnoringASCIICase(language, "zh") || startsWithLettersIgnoringASCIICase(language, "zh-"))
+ return language;
+ }
+ return "zh-hans"_str; // We have no signal. Pick one option arbitrarily.
}
-#endif
+static String& cachedSpecializedChineseLocale()
+{
+ static NeverDestroyed<String> specializedChineseLocale;
+ return specializedChineseLocale.get();
+}
+static void languageChanged(void*)
+{
+ cachedSpecializedChineseLocale() = computeSpecializedChineseLocale();
+}
+
+AtomicString FontDescription::platformResolveGenericFamily(UScriptCode script, const AtomicString& locale, const AtomicString& familyName)
+{
+ if (script == USCRIPT_COMMON)
+ return nullAtom();
+
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [&] {
+ static char dummy;
+ addLanguageChangeObserver(&dummy, &languageChanged); // We will never remove the observer, so all we need is a non-null pointer.
+ languageChanged(nullptr);
+ });
+
+ // FIXME: Delete this once <rdar://problem/47682577> is fixed.
+ auto& usedLocale = script == USCRIPT_HAN ? cachedSpecializedChineseLocale() : locale.string();
+
+ // FIXME: Use the system font database to handle standardFamily
+ if (familyName == serifFamily)
+ return SystemFontDatabaseCoreText::singleton().serifFamily(usedLocale);
+ if (familyName == sansSerifFamily)
+ return SystemFontDatabaseCoreText::singleton().sansSerifFamily(usedLocale);
+ if (familyName == cursiveFamily)
+ return SystemFontDatabaseCoreText::singleton().cursiveFamily(usedLocale);
+ if (familyName == fantasyFamily)
+ return SystemFontDatabaseCoreText::singleton().fantasyFamily(usedLocale);
+ if (familyName == monospaceFamily)
+ return SystemFontDatabaseCoreText::singleton().monospaceFamily(usedLocale);
+
+ return nullAtom();
+}
+
+}
+
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp (241287 => 241288)
--- trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp 2019-02-12 02:19:19 UTC (rev 241288)
@@ -26,8 +26,6 @@
#include "config.h"
#include "SystemFontDatabaseCoreText.h"
-#if USE_PLATFORM_SYSTEM_FALLBACK_LIST
-
#include "FontCache.h"
#include "FontCascadeDescription.h"
@@ -47,6 +45,8 @@
{
}
+#if USE_PLATFORM_SYSTEM_FALLBACK_LIST
+
Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(const CascadeListParameters& parameters, ClientUse clientUse)
{
ASSERT(!parameters.fontName.isNull());
@@ -80,6 +80,11 @@
void SystemFontDatabaseCoreText::clear()
{
m_systemFontCache.clear();
+ m_serifFamilies.clear();
+ m_sansSeriferifFamilies.clear();
+ m_cursiveFamilies.clear();
+ m_fantasyFamilies.clear();
+ m_monospaceFamilies.clear();
}
RetainPtr<CTFontRef> SystemFontDatabaseCoreText::applyWeightItalicsAndFallbackBehavior(CTFontRef font, CGFloat weight, bool italic, float size, AllowUserInstalledFonts allowUserInstalledFonts)
@@ -172,6 +177,49 @@
return cascadeList(systemFontParameters(description, cssFamily, clientUse, allowUserInstalledFonts), clientUse);
}
+#endif // USE_PLATFORM_SYSTEM_FALLBACK_LIST
+
+static String genericFamily(const String& locale, HashMap<String, String>& map, CFStringRef ctKey)
+{
+ return map.ensure(locale, [&] {
+ auto descriptor = adoptCF(CTFontDescriptorCreateForCSSFamily(ctKey, locale.createCFString().get()));
+ return adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontFamilyNameAttribute))).get();
+ }).iterator->value;
}
+String SystemFontDatabaseCoreText::serifFamily(const String& locale)
+{
+ return genericFamily(locale, m_serifFamilies, kCTFontCSSFamilySerif);
+}
+
+String SystemFontDatabaseCoreText::sansSerifFamily(const String& locale)
+{
+ return genericFamily(locale, m_sansSeriferifFamilies, kCTFontCSSFamilySansSerif);
+}
+
+String SystemFontDatabaseCoreText::cursiveFamily(const String& locale)
+{
+ return genericFamily(locale, m_cursiveFamilies, kCTFontCSSFamilyCursive);
+}
+
+String SystemFontDatabaseCoreText::fantasyFamily(const String& locale)
+{
+ return genericFamily(locale, m_fantasyFamilies, kCTFontCSSFamilyFantasy);
+}
+
+String SystemFontDatabaseCoreText::monospaceFamily(const String& locale)
+{
+ auto result = genericFamily(locale, m_monospaceFamilies, kCTFontCSSFamilyMonospace);
+#if PLATFORM(MAC) && ENABLE(MONOSPACE_FONT_EXCEPTION)
+ // In general, CoreText uses Monaco for monospaced (see: Terminal.app and Xcode.app).
+ // For now, we want to use Courier for web compatibility, until we have more time to do compatibility testing.
+ if (equalLettersIgnoringASCIICase(result, "monaco"))
+ return "Courier"_str;
+#elif PLATFORM(IOS_FAMILY) && ENABLE(MONOSPACE_FONT_EXCEPTION)
+ if (equalLettersIgnoringASCIICase(result, "courier new"))
+ return "Courier"_str;
#endif
+ return result;
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h (241287 => 241288)
--- trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h 2019-02-12 02:19:19 UTC (rev 241288)
@@ -32,8 +32,6 @@
#include <wtf/text/AtomicString.h>
#include <wtf/text/AtomicStringHash.h>
-#if USE_PLATFORM_SYSTEM_FALLBACK_LIST
-
namespace WebCore {
class SystemFontDatabaseCoreText {
@@ -101,6 +99,13 @@
enum class ClientUse { ForSystemUI, ForTextStyle };
Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontCascadeDescription&, const AtomicString& cssFamily, ClientUse, AllowUserInstalledFonts);
+
+ String serifFamily(const String& locale);
+ String sansSerifFamily(const String& locale);
+ String cursiveFamily(const String& locale);
+ String fantasyFamily(const String& locale);
+ String monospaceFamily(const String& locale);
+
void clear();
private:
@@ -114,8 +119,12 @@
static CascadeListParameters systemFontParameters(const FontCascadeDescription&, const AtomicString& familyName, ClientUse, AllowUserInstalledFonts);
HashMap<CascadeListParameters, Vector<RetainPtr<CTFontDescriptorRef>>, CascadeListParameters::CascadeListParametersHash, SimpleClassHashTraits<CascadeListParameters>> m_systemFontCache;
+
+ HashMap<String, String> m_serifFamilies;
+ HashMap<String, String> m_sansSeriferifFamilies;
+ HashMap<String, String> m_cursiveFamilies;
+ HashMap<String, String> m_fantasyFamilies;
+ HashMap<String, String> m_monospaceFamilies;
};
}
-
-#endif
Modified: trunk/Tools/ChangeLog (241287 => 241288)
--- trunk/Tools/ChangeLog 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Tools/ChangeLog 2019-02-12 02:19:19 UTC (rev 241288)
@@ -1,3 +1,18 @@
+2019-02-11 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Cocoa] Ask platform for generic font family mappings
+ https://bugs.webkit.org/show_bug.cgi?id=187723
+ <rdar://problem/41892438>
+
+ Reviewed by Brent Fulgham.
+
+ Allow testing infrastructure to use fonts that are returned from CTFontDescriptorCreateForCSSFamily().
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (allowedFontFamilySet):
+ * WebKitTestRunner/mac/TestControllerMac.mm:
+ (WTR::allowedFontFamilySet):
+
2019-02-11 Adrian Perez de Castro <ape...@igalia.com>
[GTK][WPE] Add content extensions support in WKTR and unskip layout tests
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (241287 => 241288)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2019-02-12 02:19:19 UTC (rev 241288)
@@ -377,6 +377,7 @@
@"Hiragino Maru Gothic ProN",
@"Hiragino Mincho Pro",
@"Hiragino Mincho ProN",
+ @"Hiragino Sans",
@"Hiragino Sans GB",
@"Hoefler Text",
@"Impact",
@@ -386,6 +387,7 @@
@"Kokonor",
@"Krungthep",
@"KufiStandardGK",
+ @"Lao Sangam MN",
@"LastResort",
@"LiHei Pro",
@"LiSong Pro",
@@ -403,11 +405,15 @@
@"Papyrus",
@"PCMyungjo",
@"PilGi",
+ @"PingFang HK",
+ @"PingFang SC",
+ @"PingFang TC",
@"Plantagenet Cherokee",
@"Raanana",
@"Sathu",
@"Silom",
@"Skia",
+ @"Snell Roundhand",
@"Songti SC",
@"Songti TC",
@"STFangsong",
Modified: trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm (241287 => 241288)
--- trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2019-02-12 01:50:34 UTC (rev 241287)
+++ trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2019-02-12 02:19:19 UTC (rev 241288)
@@ -226,6 +226,7 @@
@"Hiragino Maru Gothic ProN",
@"Hiragino Mincho Pro",
@"Hiragino Mincho ProN",
+ @"Hiragino Sans",
@"Hiragino Sans GB",
@"Hoefler Text",
@"Impact",
@@ -235,6 +236,7 @@
@"Kokonor",
@"Krungthep",
@"KufiStandardGK",
+ @"Lao Sangam MN",
@"LastResort",
@"LiHei Pro",
@"LiSong Pro",
@@ -252,11 +254,15 @@
@"Papyrus",
@"PCMyungjo",
@"PilGi",
+ @"PingFang HK",
+ @"PingFang SC",
+ @"PingFang TC",
@"Plantagenet Cherokee",
@"Raanana",
@"Sathu",
@"Silom",
@"Skia",
+ @"Snell Roundhand",
@"Songti SC",
@"Songti TC",
@"STFangsong",