[Cocoa] Add SPI to disallow user-installed fonts
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2017 20:29:03 +0000 (20:29 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2017 20:29:03 +0000 (20:29 +0000)
commite0050390d6625f15d3feb3b08fc6a03e8dd4321b
tree02f4b315d545558b5203b1aa053d28593d029fa3
parent9fd1ab662dacf56b79cf9c62c3059987caab31ee
[Cocoa] Add SPI to disallow user-installed fonts
https://bugs.webkit.org/show_bug.cgi?id=180062
<rdar://problem/35042408>

Reviewed by Simon Fraser.

Source/WebCore:

This hooks up a WK2 preference, ShouldDisallowUserInstalledFonts, to our font selection
code. This preference works by specifying an attribute to our font selection code which
will prohibit user-installed fonts from ever being selected. This works both to disallow
newly installed fonts, as well as disallowing user-installed fonts which "shadow" (or
have the same name as) existing fonts, so that the existing font is selected instead.

The goal of this setting is to decrease the fingerprinting surface area which trackers
can use to identify users on the open Web.

Tests: fast/text/user-installed-font.html
       fast/text/user-installed-fonts/disable.html
       fast/text/user-installed-fonts/shadow-disable.html
       fast/text/user-installed-fonts/shadow-family-disable.html
       fast/text/user-installed-fonts/shadow-family.html
       fast/text/user-installed-fonts/shadow-postscript-disable.html
       fast/text/user-installed-fonts/shadow-postscript-family-disable.html
       fast/text/user-installed-fonts/shadow-postscript-family.html
       fast/text/user-installed-fonts/shadow-postscript.html
       fast/text/user-installed-fonts/shadow.html

* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::initializeFontStyle):
* page/Settings.yaml:
* platform/graphics/FontCache.h:
* platform/graphics/FontDescription.cpp:
(WebCore::FontDescription::FontDescription):
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::mayRepresentUserInstalledFont const):
(WebCore::FontDescription::setMayRepresentUserInstalledFont):
(WebCore::FontDescription::operator== const):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontDatabase::singleton):
(WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
(WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
(WebCore::FontDatabase::collectionForFamily):
(WebCore::FontDatabase::fontForPostScriptName):
(WebCore::FontDatabase::FontDatabase):
(WebCore::FontCache::getFontSelectionCapabilitiesInFamily):
(WebCore::platformFontLookupWithFamily):
(WebCore::invalidateFontCache):
(WebCore::fontWithFamily):
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setShouldDisallowUserInstalledFonts):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:

Source/WebCore/PAL:

* pal/spi/cocoa/CoreTextSPI.h:

Source/WebKit:

* Shared/WebPreferences.yaml:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetShouldDisallowUserInstalledFonts):
(WKPreferencesGetShouldDisallowUserInstalledFonts):
* UIProcess/API/C/WKPreferencesRefPrivate.h:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _shouldDisallowUserInstalledFonts]):
(-[WKPreferences _setShouldDisallowUserInstalledFonts:]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:

Tools:

* WebKitTestRunner/InjectedBundle/ActivateFonts.h:
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::resetAfterTest):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
* WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
(WTR::resourcesDirectoryURL):
(WTR::activateFonts):
(WTR::installFakeHelvetica):
(WTR::uninstallFakeHelvetica):
* WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm:
(WTR::TestRunner::installFakeHelvetica):
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/fonts/FakeHelvetica-Helvetica-400.ttf: Added.
* WebKitTestRunner/fonts/FakeHelvetica-Helvetica-500.ttf: Added.
* WebKitTestRunner/fonts/FakeHelvetica-Helvetica2-400.ttf: Added.
* WebKitTestRunner/fonts/FakeHelvetica-Helvetica2-500.ttf: Added.

LayoutTests:

* fast/text/user-installed-font-expected.html: Added.
* fast/text/user-installed-font.html: Added.
* fast/text/user-installed-fonts/disable-expected-mismatch.html: Added.
* fast/text/user-installed-fonts/disable.html: Added.
* fast/text/user-installed-fonts/shadow-disable-expected-mismatch.html: Added.
* fast/text/user-installed-fonts/shadow-disable.html: Added.
* fast/text/user-installed-fonts/shadow-expected.html: Added.
* fast/text/user-installed-fonts/shadow-family-disable-expected-mismatch.html: Added.
* fast/text/user-installed-fonts/shadow-family-disable.html: Added.
* fast/text/user-installed-fonts/shadow-family-expected.html: Added.
* fast/text/user-installed-fonts/shadow-family.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-disable-expected-mismatch.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-disable.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-expected.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-family-disable-expected-mismatch.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-family-disable.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-family-expected.html: Added.
* fast/text/user-installed-fonts/shadow-postscript-family.html: Added.
* fast/text/user-installed-fonts/shadow-postscript.html: Added.
* fast/text/user-installed-fonts/shadow.html: Added.
* platform/gtk/TestExpectations:
* platform/ios-wk1/TestExpectations:
* platform/ios/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/mac/TestExpectations:
* platform/win/TestExpectations:
* platform/wpe/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225641 268f45cc-cd09-0410-ab3c-d52691b4dbfc
59 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/user-installed-font-expected.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-font.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/disable-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/disable.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-disable-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-disable.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-expected.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-family-disable-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-family-disable.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-family-expected.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-family.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-disable-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-disable.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-expected.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family-disable-expected-mismatch.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family-disable.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family-expected.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow-postscript.html [new file with mode: 0644]
LayoutTests/fast/text/user-installed-fonts/shadow.html [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios-wk1/TestExpectations
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wpe/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h
Source/WebCore/css/CSSFontFaceSet.cpp
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
Source/WebCore/platform/graphics/win/FontCacheWin.cpp
Source/WebCore/style/StyleResolveForDocument.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/C/WKPreferences.cpp
Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/ActivateFonts.h
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm
Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm
Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
Tools/WebKitTestRunner/fonts/FakeHelvetica-Helvetica-400.ttf [new file with mode: 0644]
Tools/WebKitTestRunner/fonts/FakeHelvetica-Helvetica-500.ttf [new file with mode: 0644]
Tools/WebKitTestRunner/fonts/FakeHelvetica-Helvetica2-400.ttf [new file with mode: 0644]
Tools/WebKitTestRunner/fonts/FakeHelvetica-Helvetica2-500.ttf [new file with mode: 0644]