[Cocoa] Ask platform for generic font family mappings
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Feb 2019 03:42:23 +0000 (03:42 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 9 Feb 2019 03:42:23 +0000 (03:42 +0000)
commite30886d552658dac638eccf35bf2bc8505484b5d
treeb1be36b049d901d5999f62bbd5fd8194fcfe3d04
parentade671c2332a93451cfba29f64ddc27dfcfc1eb0
[Cocoa] Ask platform for generic font family mappings
https://bugs.webkit.org/show_bug.cgi?id=187723
<rdar://problem/41892438>

Reviewed by Brent Fulgham.

Source/WebCore:

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::SystemFontDatabaseCoreText::serifFamily):
(WebCore::SystemFontDatabaseCoreText::sansSerifFamily):
(WebCore::SystemFontDatabaseCoreText::cursiveFamily):
(WebCore::SystemFontDatabaseCoreText::fantasyFamily):
(WebCore::SystemFontDatabaseCoreText::monospaceFamily):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.h:

Source/WebCore/PAL:

* pal/spi/cocoa/CoreTextSPI.h:

Tools:

Allow testing infrastructure to use fonts that are returned from CTFontDescriptorCreateForCSSFamily().

* DumpRenderTree/mac/DumpRenderTree.mm:
(allowedFontFamilySet):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::allowedFontFamilySet):

LayoutTests:

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. This test is no longer testing
anything relevant.
* 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241229 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html [deleted file]
LayoutTests/fast/text/international/font-fallback-to-common-script.html [deleted file]
LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html
LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html
LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml
LayoutTests/fast/text/international/lang-sensitive-fonts.html
LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html
LayoutTests/fast/text/international/locale-sensitive-fonts.html
LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/ja-sans-serif.html [new file with mode: 0644]
LayoutTests/platform/ios/fast/block/float/016-expected.txt
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/page/cocoa/SettingsBaseCocoa.mm
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp
Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm