Changeset 225641 in webkit
- Timestamp:
- Dec 7, 2017 12:29:03 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 25 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225640 r225641 1 2017-12-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Add SPI to disallow user-installed fonts 4 https://bugs.webkit.org/show_bug.cgi?id=180062 5 <rdar://problem/35042408> 6 7 Reviewed by Simon Fraser. 8 9 * fast/text/user-installed-font-expected.html: Added. 10 * fast/text/user-installed-font.html: Added. 11 * fast/text/user-installed-fonts/disable-expected-mismatch.html: Added. 12 * fast/text/user-installed-fonts/disable.html: Added. 13 * fast/text/user-installed-fonts/shadow-disable-expected-mismatch.html: Added. 14 * fast/text/user-installed-fonts/shadow-disable.html: Added. 15 * fast/text/user-installed-fonts/shadow-expected.html: Added. 16 * fast/text/user-installed-fonts/shadow-family-disable-expected-mismatch.html: Added. 17 * fast/text/user-installed-fonts/shadow-family-disable.html: Added. 18 * fast/text/user-installed-fonts/shadow-family-expected.html: Added. 19 * fast/text/user-installed-fonts/shadow-family.html: Added. 20 * fast/text/user-installed-fonts/shadow-postscript-disable-expected-mismatch.html: Added. 21 * fast/text/user-installed-fonts/shadow-postscript-disable.html: Added. 22 * fast/text/user-installed-fonts/shadow-postscript-expected.html: Added. 23 * fast/text/user-installed-fonts/shadow-postscript-family-disable-expected-mismatch.html: Added. 24 * fast/text/user-installed-fonts/shadow-postscript-family-disable.html: Added. 25 * fast/text/user-installed-fonts/shadow-postscript-family-expected.html: Added. 26 * fast/text/user-installed-fonts/shadow-postscript-family.html: Added. 27 * fast/text/user-installed-fonts/shadow-postscript.html: Added. 28 * fast/text/user-installed-fonts/shadow.html: Added. 29 * platform/gtk/TestExpectations: 30 * platform/ios-wk1/TestExpectations: 31 * platform/ios/TestExpectations: 32 * platform/mac-wk1/TestExpectations: 33 * platform/mac/TestExpectations: 34 * platform/win/TestExpectations: 35 * platform/wpe/TestExpectations: 36 1 37 2017-12-07 John Wilander <wilander@apple.com> 2 38 -
trunk/LayoutTests/platform/gtk/TestExpectations
r225626 r225641 3358 3358 webkit.org/b/180371 fast/attachment/attachment-without-appearance.html [ ImageOnlyFailure ] 3359 3359 3360 webkit.org/b/180062 fast/text/user-installed-fonts [ ImageOnlyFailure ] 3361 3360 3362 #//////////////////////////////////////////////////////////////////////////////////////// 3361 3363 # End of non-crashing, non-flaky tests failing -
trunk/LayoutTests/platform/ios-wk1/TestExpectations
r225426 r225641 1904 1904 # FIXME: For some reason EventSender.keyDown() does not work. 1905 1905 webkit.org/b/178490 fast/text/scroll-text-overflow-ellipsis.html [ Skip ] 1906 1907 # User-installed fonts test infrastructure is not present in WK1 1908 webkit.org/b/180062 fast/text/user-installed-fonts [ ImageOnlyFailure ] -
trunk/LayoutTests/platform/ios/TestExpectations
r225640 r225641 3309 3309 # Requries AVFoundation support <rdar://problem/34502208> 3310 3310 http/tests/images/image-supports-video.html 3311 3312 # User-installed font infrastructure is ony present on certain OSes. 3313 webkit.org/b/180062 fast/text/user-installed-fonts/disable.html [ ImageOnlyFailure ] 3314 webkit.org/b/180062 fast/text/user-installed-fonts/shadow-family.html [ ImageOnlyFailure ] 3315 webkit.org/b/180062 fast/text/user-installed-fonts/shadow-postscript.html [ ImageOnlyFailure ] 3316 webkit.org/b/180062 fast/text/user-installed-fonts/shadow.html [ ImageOnlyFailure ] -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r225511 r225641 475 475 476 476 webkit.org/b/179500 accessibility/mac/AOM-relation-property.html [ Skip ] 477 478 # User-installed fonts test infrastructure is not present in WK1 479 webkit.org/b/180062 fast/text/user-installed-fonts [ ImageOnlyFailure ] -
trunk/LayoutTests/platform/mac/TestExpectations
r225638 r225641 1758 1758 webkit.org/b/176693 storage/indexeddb/modern/idbtransaction-objectstore-failures-private.html [ Pass Failure ] 1759 1759 1760 # User-installed font infrastructure is ony present on certain OSes. 1761 webkit.org/b/180062 [ ElCapitan Sierra HighSierra ] fast/text/user-installed-fonts/disable.html [ ImageOnlyFailure ] 1762 webkit.org/b/180062 [ ElCapitan Sierra HighSierra ] fast/text/user-installed-fonts/shadow-postscript.html [ ImageOnlyFailure ] 1763 webkit.org/b/180062 [ ElCapitan Sierra HighSierra ] fast/text/user-installed-fonts/shadow.html [ ImageOnlyFailure ] -
trunk/LayoutTests/platform/win/TestExpectations
r225527 r225641 3833 3833 3834 3834 webkit.org/b/179767 http/wpt/offscreen-canvas/getContext-webgl.html [ Failure ] 3835 3836 # User-installed font infrastructure is ony present on certain OSes. 3837 webkit.org/b/180062 fast/text/user-installed-fonts [ ImageOnlyFailure ] -
trunk/LayoutTests/platform/wpe/TestExpectations
r225626 r225641 1109 1109 webkit.org/b/180134 webanimations/opacity-animation-no-longer-composited-upon-completion.html [ Failure ] 1110 1110 webkit.org/b/180134 webanimations/width-and-opacity-separate-animation-yields-no-compositing.html [ Failure ] 1111 1112 # User-installed font infrastructure is ony present on certain OSes. 1113 webkit.org/b/180062 fast/text/user-installed-fonts/ [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r225639 r225641 1 2017-12-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Add SPI to disallow user-installed fonts 4 https://bugs.webkit.org/show_bug.cgi?id=180062 5 <rdar://problem/35042408> 6 7 Reviewed by Simon Fraser. 8 9 This hooks up a WK2 preference, ShouldDisallowUserInstalledFonts, to our font selection 10 code. This preference works by specifying an attribute to our font selection code which 11 will prohibit user-installed fonts from ever being selected. This works both to disallow 12 newly installed fonts, as well as disallowing user-installed fonts which "shadow" (or 13 have the same name as) existing fonts, so that the existing font is selected instead. 14 15 The goal of this setting is to decrease the fingerprinting surface area which trackers 16 can use to identify users on the open Web. 17 18 Tests: fast/text/user-installed-font.html 19 fast/text/user-installed-fonts/disable.html 20 fast/text/user-installed-fonts/shadow-disable.html 21 fast/text/user-installed-fonts/shadow-family-disable.html 22 fast/text/user-installed-fonts/shadow-family.html 23 fast/text/user-installed-fonts/shadow-postscript-disable.html 24 fast/text/user-installed-fonts/shadow-postscript-family-disable.html 25 fast/text/user-installed-fonts/shadow-postscript-family.html 26 fast/text/user-installed-fonts/shadow-postscript.html 27 fast/text/user-installed-fonts/shadow.html 28 29 * css/CSSFontFaceSet.cpp: 30 (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered): 31 * css/StyleResolver.cpp: 32 (WebCore::StyleResolver::initializeFontStyle): 33 * page/Settings.yaml: 34 * platform/graphics/FontCache.h: 35 * platform/graphics/FontDescription.cpp: 36 (WebCore::FontDescription::FontDescription): 37 * platform/graphics/FontDescription.h: 38 (WebCore::FontDescription::mayRepresentUserInstalledFont const): 39 (WebCore::FontDescription::setMayRepresentUserInstalledFont): 40 (WebCore::FontDescription::operator== const): 41 * platform/graphics/cocoa/FontCacheCoreText.cpp: 42 (WebCore::FontDatabase::singleton): 43 (WebCore::FontDatabase::singletonAllowingUserInstalledFonts): 44 (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts): 45 (WebCore::FontDatabase::collectionForFamily): 46 (WebCore::FontDatabase::fontForPostScriptName): 47 (WebCore::FontDatabase::FontDatabase): 48 (WebCore::FontCache::getFontSelectionCapabilitiesInFamily): 49 (WebCore::platformFontLookupWithFamily): 50 (WebCore::invalidateFontCache): 51 (WebCore::fontWithFamily): 52 * style/StyleResolveForDocument.cpp: 53 (WebCore::Style::resolveForDocument): 54 * testing/InternalSettings.cpp: 55 (WebCore::InternalSettings::setShouldDisallowUserInstalledFonts): 56 * testing/InternalSettings.h: 57 * testing/InternalSettings.idl: 58 1 59 2017-12-07 David Quesada <david_quesada@apple.com> 2 60 -
trunk/Source/WebCore/PAL/ChangeLog
r225618 r225641 1 2017-12-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Add SPI to disallow user-installed fonts 4 https://bugs.webkit.org/show_bug.cgi?id=180062 5 <rdar://problem/35042408> 6 7 Reviewed by Simon Fraser. 8 9 * pal/spi/cocoa/CoreTextSPI.h: 10 1 11 2017-12-02 Darin Adler <darin@apple.com> 2 12 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h
r221950 r225641 66 66 extern const CFStringRef kCTFontOpticalSizeAttribute; 67 67 extern const CFStringRef kCTFontPostScriptNameAttribute; 68 extern const CFStringRef kCTFontUserInstalledAttribute; 68 69 69 70 bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions); -
trunk/Source/WebCore/css/CSSFontFaceSet.cpp
r225414 r225641 29 29 #include "CSSFontFaceSource.h" 30 30 #include "CSSFontFamily.h" 31 #include "CSSFontSelector.h" 31 32 #include "CSSFontStyleValue.h" 32 33 #include "CSSParser.h" … … 104 105 return; 105 106 106 Vector<FontSelectionCapabilities> capabilities = FontCache::singleton().getFontSelectionCapabilitiesInFamily(familyName); 107 FontCache::AllowUserInstalledFonts allowUserInstalledFonts = FontCache::AllowUserInstalledFonts::Yes; 108 if (m_owningFontSelector->document() && m_owningFontSelector->document()->settings().shouldDisallowUserInstalledFonts()) 109 allowUserInstalledFonts = FontCache::AllowUserInstalledFonts::No; 110 Vector<FontSelectionCapabilities> capabilities = FontCache::singleton().getFontSelectionCapabilitiesInFamily(familyName, allowUserInstalledFonts); 107 111 if (capabilities.isEmpty()) 108 112 return; -
trunk/Source/WebCore/css/StyleResolver.cpp
r225485 r225641 1793 1793 fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium); 1794 1794 setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueMedium, false, document())); 1795 fontDescription.setMayRepresentUserInstalledFont(!settings().shouldDisallowUserInstalledFonts()); 1795 1796 setFontDescription(fontDescription); 1796 1797 } -
trunk/Source/WebCore/page/Settings.yaml
r225103 r225641 662 662 onChange: storageBlockingPolicyChanged 663 663 664 shouldDisallowUserInstalledFonts: 665 initial: false 666 onChange: setNeedsRecalcStyleInAllFrames 667 664 668 # Only set by Layout Tests. 665 669 mediaTypeOverride: -
trunk/Source/WebCore/platform/graphics/FontCache.h
r221408 r225641 201 201 #endif 202 202 203 enum class AllowUserInstalledFonts { 204 Yes, 205 No 206 }; 203 207 // This function exists so CSSFontSelector can have a unified notion of preinstalled fonts and @font-face. 204 208 // It comes into play when you create an @font-face which shares a family name as a preinstalled font. 205 Vector<FontSelectionCapabilities> getFontSelectionCapabilitiesInFamily(const AtomicString& );209 Vector<FontSelectionCapabilities> getFontSelectionCapabilitiesInFamily(const AtomicString&, AllowUserInstalledFonts); 206 210 207 211 WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const AtomicString&, const FontFeatureSettings* fontFaceFeatures = nullptr, const FontVariantSettings* fontFaceVariantSettings = nullptr, FontSelectionSpecifiedCapabilities fontFaceCapabilities = { }, bool checkingAlternateName = false); -
trunk/Source/WebCore/platform/graphics/FontDescription.cpp
r220009 r225641 81 81 , m_opticalSizing(static_cast<unsigned>(FontOpticalSizing::Enabled)) 82 82 , m_fontStyleAxis(FontCascadeDescription::initialFontStyleAxis() == FontStyleAxis::ital) 83 , m_mayRepresentUserInstalledFont(true) 83 84 { 84 85 } -
trunk/Source/WebCore/platform/graphics/FontDescription.h
r220009 r225641 115 115 FontOpticalSizing opticalSizing() const { return static_cast<FontOpticalSizing>(m_opticalSizing); } 116 116 FontStyleAxis fontStyleAxis() const { return m_fontStyleAxis ? FontStyleAxis::ital : FontStyleAxis::slnt; } 117 bool mayRepresentUserInstalledFont() const { return m_mayRepresentUserInstalledFont; } 117 118 118 119 void setComputedSize(float s) { m_computedSize = clampToFloat(s); } … … 149 150 void setOpticalSizing(FontOpticalSizing sizing) { m_opticalSizing = static_cast<unsigned>(sizing); } 150 151 void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; } 152 void setMayRepresentUserInstalledFont(bool mayRepresentUserInstalledFont) { m_mayRepresentUserInstalledFont = mayRepresentUserInstalledFont; } 151 153 152 154 static void invalidateCaches(); … … 184 186 unsigned m_opticalSizing : 1; // FontOpticalSizing 185 187 unsigned m_fontStyleAxis : 1; // Whether "font-style: italic" or "font-style: oblique 20deg" was specified 188 unsigned m_mayRepresentUserInstalledFont : 1; // If this description is allowed to match a user-installed font 186 189 }; 187 190 … … 217 220 && m_variantEastAsianRuby == other.m_variantEastAsianRuby 218 221 && m_opticalSizing == other.m_opticalSizing 219 && m_fontStyleAxis == other.m_fontStyleAxis; 222 && m_fontStyleAxis == other.m_fontStyleAxis 223 && m_mayRepresentUserInstalledFont == other.m_mayRepresentUserInstalledFont; 220 224 } 221 225 -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r225470 r225641 38 38 #define SHOULD_USE_CORE_TEXT_FONT_LOOKUP (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101200) 39 39 #define HAS_CORE_TEXT_WIDTH_ATTRIBUTE ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)) 40 #define CAN_DISALLOW_USER_INSTALLED_FONTS ((PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400)) 40 41 41 42 namespace WebCore { … … 830 831 class FontDatabase { 831 832 public: 833 #if !CAN_DISALLOW_USER_INSTALLED_FONTS 832 834 static FontDatabase& singleton() 833 835 { 834 static NeverDestroyed<FontDatabase> database ;836 static NeverDestroyed<FontDatabase> database(FontCache::AllowUserInstalledFonts::Yes); 835 837 return database; 838 } 839 #endif 840 841 static FontDatabase& singletonAllowingUserInstalledFonts() 842 { 843 #if CAN_DISALLOW_USER_INSTALLED_FONTS 844 static NeverDestroyed<FontDatabase> database(FontCache::AllowUserInstalledFonts::Yes); 845 return database; 846 #else 847 return singleton(); 848 #endif 849 } 850 851 static FontDatabase& singletonDisallowingUserInstalledFonts() 852 { 853 #if CAN_DISALLOW_USER_INSTALLED_FONTS 854 static NeverDestroyed<FontDatabase> database(FontCache::AllowUserInstalledFonts::No); 855 return database; 856 #else 857 return singleton(); 858 #endif 836 859 } 837 860 … … 886 909 return m_familyNameToFontDescriptors.ensure(folded, [&] { 887 910 auto familyNameString = folded.createCFString(); 888 CFTypeRef keys[] = { kCTFontFamilyNameAttribute }; 889 CFTypeRef values[] = { familyNameString.get() }; 890 auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 911 RetainPtr<CFDictionaryRef> attributes; 912 #if CAN_DISALLOW_USER_INSTALLED_FONTS 913 if (m_allowUserInstalledFonts == FontCache::AllowUserInstalledFonts::No) { 914 CFTypeRef keys[] = { kCTFontFamilyNameAttribute, kCTFontUserInstalledAttribute }; 915 CFTypeRef values[] = { familyNameString.get(), kCFBooleanFalse }; 916 attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 917 } else 918 #endif 919 { 920 CFTypeRef keys[] = { kCTFontFamilyNameAttribute }; 921 CFTypeRef values[] = { familyNameString.get() }; 922 attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 923 } 891 924 auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); 892 925 if (auto matches = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptorToMatch.get(), nullptr))) { … … 914 947 CFStringRef nameAttribute = kCTFontNameAttribute; 915 948 #endif 916 CFTypeRef keys[] = { kCTFontEnabledAttribute, nameAttribute }; 917 CFTypeRef values[] = { kCFBooleanTrue, postScriptNameString.get() }; 918 auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 949 RetainPtr<CFDictionaryRef> attributes; 950 #if CAN_DISALLOW_USER_INSTALLED_FONTS 951 if (m_allowUserInstalledFonts == FontCache::AllowUserInstalledFonts::No) { 952 CFTypeRef keys[] = { kCTFontEnabledAttribute, nameAttribute, kCTFontUserInstalledAttribute }; 953 CFTypeRef values[] = { kCFBooleanTrue, postScriptNameString.get(), kCFBooleanFalse }; 954 attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 955 } else 956 #endif 957 { 958 CFTypeRef keys[] = { kCTFontEnabledAttribute, nameAttribute }; 959 CFTypeRef values[] = { kCFBooleanTrue, postScriptNameString.get() }; 960 attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 961 } 919 962 auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); 920 963 auto match = adoptCF(static_cast<CTFontDescriptorRef>(CTFontDescriptorCreateMatchingFontDescriptor(fontDescriptorToMatch.get(), nullptr))); … … 932 975 friend class NeverDestroyed<FontDatabase>; 933 976 934 FontDatabase() = default; 977 FontDatabase(FontCache::AllowUserInstalledFonts allowUserInstalledFonts) 978 : m_allowUserInstalledFonts(allowUserInstalledFonts) 979 { 980 } 935 981 936 982 HashMap<String, InstalledFontFamily> m_familyNameToFontDescriptors; 937 983 HashMap<String, InstalledFont> m_postScriptNameToFontDescriptors; 984 FontCache::AllowUserInstalledFonts m_allowUserInstalledFonts; 938 985 }; 939 986 … … 1125 1172 #endif 1126 1173 1127 Vector<FontSelectionCapabilities> FontCache::getFontSelectionCapabilitiesInFamily(const AtomicString& familyName) 1128 { 1129 const auto& fonts = FontDatabase::singleton().collectionForFamily(familyName.string()); 1174 Vector<FontSelectionCapabilities> FontCache::getFontSelectionCapabilitiesInFamily(const AtomicString& familyName, AllowUserInstalledFonts allowUserInstalledFonts) 1175 { 1176 auto& fontDatabase = allowUserInstalledFonts == AllowUserInstalledFonts::Yes ? FontDatabase::singletonAllowingUserInstalledFonts() : FontDatabase::singletonDisallowingUserInstalledFonts(); 1177 const auto& fonts = fontDatabase.collectionForFamily(familyName.string()); 1130 1178 if (fonts.isEmpty()) 1131 1179 return { }; … … 1143 1191 }; 1144 1192 1145 static FontLookup platformFontLookupWithFamily(const AtomicString& family, FontSelectionRequest request, float size )1193 static FontLookup platformFontLookupWithFamily(const AtomicString& family, FontSelectionRequest request, float size, bool mayRepresentUserInstalledFont) 1146 1194 { 1147 1195 const auto& whitelist = fontWhitelist(); … … 1150 1198 1151 1199 #if SHOULD_USE_CORE_TEXT_FONT_LOOKUP 1200 UNUSED_PARAM(mayRepresentUserInstalledFont); 1152 1201 CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0); 1153 1202 return { adoptCF(CTFontCreateForCSS(family.string().createCFString().get(), static_cast<float>(request.weight), traits, size)) }; 1154 1203 #else 1155 const auto& familyFonts = FontDatabase::singleton().collectionForFamily(family.string()); 1204 auto& fontDatabase = mayRepresentUserInstalledFont ? FontDatabase::singletonAllowingUserInstalledFonts() : FontDatabase::singletonDisallowingUserInstalledFonts(); 1205 const auto& familyFonts = fontDatabase.collectionForFamily(family.string()); 1156 1206 if (familyFonts.isEmpty()) { 1157 1207 // The CSS spec states that font-family only accepts a name of an actual font family. However, in WebKit, we claim to also … … 1162 1212 // if content simply states "font-family: PostScriptName;" without specifying the other font properties, it will be honored, 1163 1213 // but if a <b> appears as a descendent element, it will be honored too. 1164 const auto& postScriptFont = FontDatabase::singleton().fontForPostScriptName(family);1214 const auto& postScriptFont = fontDatabase.fontForPostScriptName(family); 1165 1215 if (!postScriptFont.fontDescriptor) 1166 1216 return { nullptr }; … … 1170 1220 if (!postScriptFamilyName) 1171 1221 return { nullptr }; 1172 const auto& familyFonts = FontDatabase::singleton().collectionForFamily(String(postScriptFamilyName.get()));1222 const auto& familyFonts = fontDatabase.collectionForFamily(String(postScriptFamilyName.get())); 1173 1223 if (familyFonts.isEmpty()) 1174 1224 return { nullptr }; … … 1201 1251 FontDescription::invalidateCaches(); 1202 1252 1203 FontDatabase::singleton().clear(); 1253 FontDatabase::singletonAllowingUserInstalledFonts().clear(); 1254 FontDatabase::singletonDisallowingUserInstalledFonts().clear(); 1204 1255 1205 1256 FontCache::singleton().invalidate(); … … 1215 1266 fontLookup.result = platformFontWithFamilySpecialCase(family, request, size); 1216 1267 if (!fontLookup.result) 1217 fontLookup = platformFontLookupWithFamily(family, request, size );1268 fontLookup = platformFontLookupWithFamily(family, request, size, fontDescription.mayRepresentUserInstalledFont()); 1218 1269 return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, size, !fontLookup.createdFromPostScriptName); 1219 1270 } -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r222800 r225641 140 140 } 141 141 142 Vector<FontSelectionCapabilities> FontCache::getFontSelectionCapabilitiesInFamily(const AtomicString& )142 Vector<FontSelectionCapabilities> FontCache::getFontSelectionCapabilitiesInFamily(const AtomicString&, AllowUserInstalledFonts) 143 143 { 144 144 return { }; -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r221583 r225641 588 588 } 589 589 590 Vector<FontSelectionCapabilities> FontCache::getFontSelectionCapabilitiesInFamily(const AtomicString& familyName )590 Vector<FontSelectionCapabilities> FontCache::getFontSelectionCapabilitiesInFamily(const AtomicString& familyName, AllowUserInstalledFonts) 591 591 { 592 592 HWndDC hdc(0); -
trunk/Source/WebCore/style/StyleResolveForDocument.cpp
r222575 r225641 110 110 fontDescription.setRenderingMode(settings.fontRenderingMode()); 111 111 fontDescription.setOneFamily(standardFamily); 112 fontDescription.setMayRepresentUserInstalledFont(!settings.shouldDisallowUserInstalledFonts()); 112 113 113 114 fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium); -
trunk/Source/WebKit/ChangeLog
r225639 r225641 1 2017-12-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Add SPI to disallow user-installed fonts 4 https://bugs.webkit.org/show_bug.cgi?id=180062 5 <rdar://problem/35042408> 6 7 Reviewed by Simon Fraser. 8 9 * Shared/WebPreferences.yaml: 10 * UIProcess/API/C/WKPreferences.cpp: 11 (WKPreferencesSetShouldDisallowUserInstalledFonts): 12 (WKPreferencesGetShouldDisallowUserInstalledFonts): 13 * UIProcess/API/C/WKPreferencesRefPrivate.h: 14 * UIProcess/API/Cocoa/WKPreferences.mm: 15 (-[WKPreferences _shouldDisallowUserInstalledFonts]): 16 (-[WKPreferences _setShouldDisallowUserInstalledFonts:]): 17 * UIProcess/API/Cocoa/WKPreferencesPrivate.h: 18 1 19 2017-12-07 David Quesada <david_quesada@apple.com> 2 20 -
trunk/Source/WebKit/Shared/WebPreferences.yaml
r225103 r225641 1034 1034 defaultValue: 0 1035 1035 category: debug 1036 1037 ShouldDisallowUserInstalledFonts: 1038 type: bool 1039 defaultValue: false 1036 1040 1037 1041 -
trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp
r224871 r225641 1920 1920 return toImpl(preferencesRef)->accessibilityObjectModelEnabled(); 1921 1921 } 1922 1923 void WKPreferencesSetShouldDisallowUserInstalledFonts(WKPreferencesRef preferencesRef, bool flag) 1924 { 1925 toImpl(preferencesRef)->setShouldDisallowUserInstalledFonts(flag); 1926 } 1927 1928 bool WKPreferencesGetShouldDisallowUserInstalledFonts(WKPreferencesRef preferencesRef) 1929 { 1930 return toImpl(preferencesRef)->shouldDisallowUserInstalledFonts(); 1931 } -
trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h
r224871 r225641 545 545 WK_EXPORT void WKPreferencesSetAccessibilityObjectModelEnabled(WKPreferencesRef, bool flag); 546 546 WK_EXPORT bool WKPreferencesGetAccessibilityObjectModelEnabled(WKPreferencesRef); 547 548 // Defaults to false. 549 WK_EXPORT void WKPreferencesSetShouldDisallowUserInstalledFonts(WKPreferencesRef, bool flag); 550 WK_EXPORT bool WKPreferencesGetShouldDisallowUserInstalledFonts(WKPreferencesRef); 547 551 548 552 #ifdef __cplusplus -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
r223988 r225641 658 658 } 659 659 660 - (BOOL)_shouldDisallowUserInstalledFonts 661 { 662 return _preferences->shouldDisallowUserInstalledFonts(); 663 } 664 665 - (void)_setShouldDisallowUserInstalledFonts:(BOOL)_shouldDisallowUserInstalledFonts 666 { 667 _preferences->setShouldDisallowUserInstalledFonts(_shouldDisallowUserInstalledFonts); 668 } 669 660 670 #if PLATFORM(MAC) 661 671 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
r223988 r225641 116 116 @property (nonatomic, setter=_setDOMPasteAllowed:) BOOL _domPasteAllowed WK_API_AVAILABLE(macosx(10.13), ios(11.0)); 117 117 118 @property (nonatomic, setter=_setShouldDisallowUserInstalledFonts:) BOOL _shouldDisallowUserInstalledFonts WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 119 118 120 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures WK_API_AVAILABLE(macosx(10.12), ios(10.0)); 119 121 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0)); -
trunk/Tools/ChangeLog
r225639 r225641 1 2017-12-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Add SPI to disallow user-installed fonts 4 https://bugs.webkit.org/show_bug.cgi?id=180062 5 <rdar://problem/35042408> 6 7 Reviewed by Simon Fraser. 8 9 * WebKitTestRunner/InjectedBundle/ActivateFonts.h: 10 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 11 * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: 12 (WTR::InjectedBundlePage::resetAfterTest): 13 * WebKitTestRunner/InjectedBundle/TestRunner.h: 14 * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm: 15 (WTR::resourcesDirectoryURL): 16 (WTR::activateFonts): 17 (WTR::installFakeHelvetica): 18 (WTR::uninstallFakeHelvetica): 19 * WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm: 20 (WTR::TestRunner::installFakeHelvetica): 21 * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: 22 * WebKitTestRunner/fonts/FakeHelvetica-Helvetica-400.ttf: Added. 23 * WebKitTestRunner/fonts/FakeHelvetica-Helvetica-500.ttf: Added. 24 * WebKitTestRunner/fonts/FakeHelvetica-Helvetica2-400.ttf: Added. 25 * WebKitTestRunner/fonts/FakeHelvetica-Helvetica2-500.ttf: Added. 26 1 27 2017-12-07 David Quesada <david_quesada@apple.com> 2 28 -
trunk/Tools/WebKitTestRunner/InjectedBundle/ActivateFonts.h
r63187 r225641 30 30 31 31 void activateFonts(); 32 void installFakeHelvetica(WKStringRef configuration); 33 void uninstallFakeHelvetica(); 32 34 33 35 } // namespace WTR -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r225622 r225641 310 310 311 311 void getApplicationManifestThen(object callback); 312 313 void installFakeHelvetica(DOMString configuration); 312 314 }; -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp
r223413 r225641 27 27 #include "InjectedBundlePage.h" 28 28 29 #include "ActivateFonts.h" 29 30 #include "InjectedBundle.h" 30 31 #include "StringFunctions.h" … … 436 437 // User scripts need to be removed after the test and before loading about:blank, as otherwise they would run in about:blank, and potentially leak results into a subsequest test. 437 438 WKBundlePageRemoveAllUserContent(m_page); 439 440 uninstallFakeHelvetica(); 438 441 } 439 442 -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r225622 r225641 411 411 void didGetApplicationManifest(); 412 412 413 void installFakeHelvetica(JSStringRef configuration); 414 413 415 private: 414 416 TestRunner(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm
r212876 r225641 29 29 #import <CoreFoundation/CoreFoundation.h> 30 30 #import <CoreText/CTFontManager.h> 31 #import <WebKit/WKStringCF.h> 32 #import <wtf/NeverDestroyed.h> 31 33 #import <wtf/ObjcRuntimeExtras.h> 32 34 #import <wtf/RetainPtr.h> … … 43 45 44 46 namespace WTR { 47 48 static NSURL *resourcesDirectoryURL() 49 { 50 static NeverDestroyed<RetainPtr<NSURL *>> resourcesDirectory([[NSBundle bundleForClass:[WKTRFontActivatorDummyClass class]] resourceURL]); 51 return resourcesDirectory.get().get(); 52 } 45 53 46 54 #if USE(APPKIT) … … 109 117 110 118 NSMutableArray *fontURLs = [NSMutableArray array]; 111 NSURL *resourcesDirectory = [[NSBundle bundleForClass:[WKTRFontActivatorDummyClass class]] resourceURL];112 119 for (unsigned i = 0; fontFileNames[i]; ++i) { 113 NSURL *fontURL = [resourcesDirectory URLByAppendingPathComponent:[NSString stringWithUTF8String:fontFileNames[i]]];120 NSURL *fontURL = [resourcesDirectoryURL() URLByAppendingPathComponent:[NSString stringWithUTF8String:fontFileNames[i]]]; 114 121 [fontURLs addObject:[fontURL absoluteURL]]; 115 122 } … … 127 134 } 128 135 136 void installFakeHelvetica(WKStringRef configuration) 137 { 138 RetainPtr<CFStringRef> configurationString = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, configuration)); 139 NSURL *resourceURL = [resourcesDirectoryURL() URLByAppendingPathComponent:[NSString stringWithFormat:@"FakeHelvetica-%@.ttf", configurationString.get()]]; 140 CFErrorRef error = nullptr; 141 CTFontManagerRegisterFontsForURL(static_cast<CFURLRef>(resourceURL), kCTFontManagerScopeProcess, &error); 129 142 } 130 143 144 void uninstallFakeHelvetica() 145 { 146 NSFileManager *defaultManager = [NSFileManager defaultManager]; 147 NSError *nsError = nil; 148 NSArray *urls = [defaultManager contentsOfDirectoryAtURL:resourcesDirectoryURL() includingPropertiesForKeys:@[NSURLNameKey] options:NSDirectoryEnumerationSkipsSubdirectoryDescendants | NSDirectoryEnumerationSkipsPackageDescendants | NSDirectoryEnumerationSkipsHiddenFiles error:&nsError]; 149 ASSERT(urls && !nsError); 150 if (!urls || nsError) 151 return; 152 NSMutableArray *fontsToRemove = [NSMutableArray array]; 153 for (NSURL *url in urls) { 154 if ([[url lastPathComponent] hasPrefix:@"FakeHelvetica"]) 155 [fontsToRemove addObject:url]; 156 } 157 CFArrayRef errors = nullptr; 158 CTFontManagerUnregisterFontsForURLs(static_cast<CFArrayRef>(fontsToRemove), kCTFontManagerScopeProcess, &errors); 159 } 160 161 } 162 -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm
r219191 r225641 27 27 #import "TestRunner.h" 28 28 29 #import "ActivateFonts.h" 29 30 #import "InjectedBundle.h" 30 31 #import <JavaScriptCore/JSStringRefCF.h> … … 92 93 } 93 94 95 void TestRunner::installFakeHelvetica(JSStringRef configuration) 96 { 97 WTR::installFakeHelvetica(toWK(configuration).get()); 98 } 99 94 100 } // namespace WTR -
trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj
r222890 r225641 51 51 1CA211C91BCA107300B2101F /* FontWithFeatures.otf in Resources */ = {isa = PBXBuildFile; fileRef = 1CA211C71BCA107300B2101F /* FontWithFeatures.otf */; }; 52 52 1CA211CA1BCA107300B2101F /* FontWithFeatures.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1CA211C81BCA107300B2101F /* FontWithFeatures.ttf */; }; 53 1CBA02961FD87DEC00179C7D /* FakeHelvetica-Helvetica2-500.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1CBA02951FD86EA100179C7D /* FakeHelvetica-Helvetica2-500.ttf */; }; 54 1CBA02971FD87DEE00179C7D /* FakeHelvetica-Helvetica2-400.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1CBA02921FD86EA100179C7D /* FakeHelvetica-Helvetica2-400.ttf */; }; 55 1CBA02981FD87DF000179C7D /* FakeHelvetica-Helvetica-500.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1CBA02931FD86EA100179C7D /* FakeHelvetica-Helvetica-500.ttf */; }; 56 1CBA02991FD87DF300179C7D /* FakeHelvetica-Helvetica-400.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1CBA02941FD86EA100179C7D /* FakeHelvetica-Helvetica-400.ttf */; }; 53 57 29210EAE144CACB700835BB5 /* AccessibilityUIElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA9144CACB200835BB5 /* AccessibilityUIElement.cpp */; }; 54 58 29210EB0144CACBD00835BB5 /* AccessibilityController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29210EA2144CAAA500835BB5 /* AccessibilityController.cpp */; }; … … 219 223 1CA211C71BCA107300B2101F /* FontWithFeatures.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = FontWithFeatures.otf; sourceTree = "<group>"; }; 220 224 1CA211C81BCA107300B2101F /* FontWithFeatures.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = FontWithFeatures.ttf; sourceTree = "<group>"; }; 225 1CBA02921FD86EA100179C7D /* FakeHelvetica-Helvetica2-400.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "FakeHelvetica-Helvetica2-400.ttf"; path = "fonts/FakeHelvetica-Helvetica2-400.ttf"; sourceTree = "<group>"; }; 226 1CBA02931FD86EA100179C7D /* FakeHelvetica-Helvetica-500.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "FakeHelvetica-Helvetica-500.ttf"; path = "fonts/FakeHelvetica-Helvetica-500.ttf"; sourceTree = "<group>"; }; 227 1CBA02941FD86EA100179C7D /* FakeHelvetica-Helvetica-400.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "FakeHelvetica-Helvetica-400.ttf"; path = "fonts/FakeHelvetica-Helvetica-400.ttf"; sourceTree = "<group>"; }; 228 1CBA02951FD86EA100179C7D /* FakeHelvetica-Helvetica2-500.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "FakeHelvetica-Helvetica2-500.ttf"; path = "fonts/FakeHelvetica-Helvetica2-500.ttf"; sourceTree = "<group>"; }; 221 229 26D758E5160BECDC00268472 /* GeolocationProviderMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationProviderMock.cpp; sourceTree = "<group>"; }; 222 230 26D758E6160BECDD00268472 /* GeolocationProviderMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationProviderMock.h; sourceTree = "<group>"; }; … … 697 705 children = ( 698 706 6510A77711EC643800410867 /* AHEM____.TTF */, 707 1CBA02941FD86EA100179C7D /* FakeHelvetica-Helvetica-400.ttf */, 708 1CBA02931FD86EA100179C7D /* FakeHelvetica-Helvetica-500.ttf */, 709 1CBA02921FD86EA100179C7D /* FakeHelvetica-Helvetica2-400.ttf */, 710 1CBA02951FD86EA100179C7D /* FakeHelvetica-Helvetica2-500.ttf */, 699 711 1CA211C71BCA107300B2101F /* FontWithFeatures.otf */, 700 712 1CA211C81BCA107300B2101F /* FontWithFeatures.ttf */, … … 949 961 files = ( 950 962 6510A78211EC643800410867 /* AHEM____.TTF in Resources */, 963 1CBA02991FD87DF300179C7D /* FakeHelvetica-Helvetica-400.ttf in Resources */, 964 1CBA02981FD87DF000179C7D /* FakeHelvetica-Helvetica-500.ttf in Resources */, 965 1CBA02971FD87DEE00179C7D /* FakeHelvetica-Helvetica2-400.ttf in Resources */, 966 1CBA02961FD87DEC00179C7D /* FakeHelvetica-Helvetica2-500.ttf in Resources */, 951 967 1CA211C91BCA107300B2101F /* FontWithFeatures.otf in Resources */, 952 968 1CA211CA1BCA107300B2101F /* FontWithFeatures.ttf in Resources */,
Note: See TracChangeset
for help on using the changeset viewer.