[Cocoa] Make system-ui obey the user-installed-font policy
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Feb 2018 17:34:45 +0000 (17:34 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Feb 2018 17:34:45 +0000 (17:34 +0000)
commit5cfa74ff0b14ec6dddeed2503bdb9405ee1817f5
tree44a6b5cecf989acd74ffb55ad06722cbda17c85f
parent65c7cb8f082c2b1fb19ddb25f621dfca32fe8547
[Cocoa] Make system-ui obey the user-installed-font policy
https://bugs.webkit.org/show_bug.cgi?id=182860
<rdar://problem/36158249>

Reviewed by Antti Koivisto.

Source/WebCore:

We have a completely different codepath for system-ui which makes it follow the system's
font cascade list. This codepath (along with all the other relevant places which create
system fonts) needs to obey the AllowUserInstalledFonts enum. This patch is fairly
mechanical; we simply are hooking up the flag across SystemFontDatabase.

There are a few places which creates system fonts which this patch doesn't touch. This is
not a problem because all the remaining places either:
1) Simply pull out some attributes of the font (name, weight, size, etc.) and then throw
away the font object itself, or
2) Use the font in an environment where script cannot access the characters rendered (such
as DragImages or the fullscreen placeholder view or the inside of the attachment element).

Test: fast/text/user-installed-fonts/system-ui.html

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontDatabase::collectionForFamily):
(WebCore::FontDatabase::fontForPostScriptName):
(WebCore::fontWithFamily):
(WebCore::installedFontMandatoryAttributes):
(WebCore::createSpecificFontForInstalledFonts):
* platform/graphics/cocoa/FontCacheCoreText.h:
* platform/graphics/cocoa/FontDescriptionCocoa.cpp:
(WebCore::SystemFontDatabase::CoreTextCascadeListParameters::operator== const):
(WebCore::SystemFontDatabase::CoreTextCascadeListParameters::hash const):
(WebCore::SystemFontDatabase::systemFontCascadeList):
(WebCore::SystemFontDatabase::removeCascadeList):
(WebCore::SystemFontDatabase::computeCascadeList):
(WebCore::systemFontParameters):
(WebCore::systemFontCascadeList):
(WebCore::FontCascadeDescription::effectiveFamilyCount const):
(WebCore::FontCascadeDescription::effectiveFamilyAt const):
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::platformFontWithFamilySpecialCase):

Tools:

Create a font, FakeHelvetica-ArmenianCharacter.ttf, which supports a particular Armenian
character which isn't isn't supported by any other font on the system.

* WebKitTestRunner/FakeHelvetica-ArmenianCharacter.ttf:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:

LayoutTests:

FakeHelvetica-ArmenianCharacter.ttf is a font which supports a particular Armenian character which
isn't supported by any other font on the system. Installing this font will cause it to be added to
the 'system-ui' font cascade list. When we disable user-installed-fonts, this font should not be
used to render the character.

* fast/text/user-installed-fonts/system-ui-expected-mismatch.html:
* fast/text/user-installed-fonts/system-ui.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228877 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/user-installed-fonts/system-ui-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/system-ui.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
Source/WebCore/platform/graphics/mac/FontCacheMac.mm
Tools/ChangeLog
Tools/WebKitTestRunner/FakeHelvetica-ArmenianCharacter.ttf [new file with mode: 0644]
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj