Title: [226172] trunk
Revision
226172
Author
[email protected]
Date
2017-12-19 19:24:15 -0800 (Tue, 19 Dec 2017)

Log Message

Refactor user-installed font setting for clarity
https://bugs.webkit.org/show_bug.cgi?id=181013

Reviewed by Simon Fraser.

Source/WebCore:

Pave the way for https://bugs.webkit.org/show_bug.cgi?id=180951.

This patch renames the Setting to not have so many grammatical negatives, and moves
some CoreText-specific FontCache function signatures into a new FontCacheCoreText.h
header file. It also uses the AllowUserInstalledFonts enum class in more places instead
of the old boolean we were using, and puts this enum class in the common TextFlags.h
header.

No new tests because there is no behavior change.

* WebCore.xcodeproj/project.pbxproj:
* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::initializeFontStyle):
* page/Settings.yaml:
* platform/graphics/FontCache.h:
(WebCore::SynthesisPair::SynthesisPair): Deleted.
(WebCore::SynthesisPair::boldObliquePair const): Deleted.
* platform/graphics/FontDescription.cpp:
(WebCore::m_shouldAllowUserInstalledFonts):
(WebCore::m_mayRepresentUserInstalledFont): Deleted.
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::shouldAllowUserInstalledFonts const):
(WebCore::FontDescription::setShouldAllowUserInstalledFonts):
(WebCore::FontDescription::operator== const):
(WebCore::FontDescription::mayRepresentUserInstalledFont const): Deleted.
(WebCore::FontDescription::setMayRepresentUserInstalledFont): Deleted.
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontDatabase::singleton):
(WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
(WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
(WebCore::FontDatabase::FontDatabase):
(WebCore::platformFontLookupWithFamily):
(WebCore::fontWithFamily):
* platform/graphics/cocoa/FontCacheCoreText.h: Added.
(WebCore::SynthesisPair::SynthesisPair):
(WebCore::SynthesisPair::boldObliquePair const):
* platform/text/TextFlags.h:
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):

Source/WebKit:

There are no clients of this SPI yet, so we can rename it to remove the
grammatical negative.

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

LayoutTests:

* 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-postscript-disable.html:
* fast/text/user-installed-fonts/shadow-postscript-family-disable.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226171 => 226172)


--- trunk/LayoutTests/ChangeLog	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/LayoutTests/ChangeLog	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1,3 +1,16 @@
+2017-12-19  Myles C. Maxfield  <[email protected]>
+
+        Refactor user-installed font setting for clarity
+        https://bugs.webkit.org/show_bug.cgi?id=181013
+
+        Reviewed by Simon Fraser.
+
+        * 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-postscript-disable.html:
+        * fast/text/user-installed-fonts/shadow-postscript-family-disable.html:
+
 2017-12-19  Brian Burg  <[email protected]>
 
         Web Inspector: InspectorTest.evaluateInPage should return a rejection if an error was thrown

Modified: trunk/LayoutTests/fast/text/user-installed-fonts/disable.html (226171 => 226172)


--- trunk/LayoutTests/fast/text/user-installed-fonts/disable.html	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/disable.html	2017-12-20 03:24:15 UTC (rev 226172)
@@ -3,7 +3,7 @@
 <head>
 <script>
 if (window.internals)
-    internals.settings.setShouldDisallowUserInstalledFonts(true);
+    internals.settings.setShouldAllowUserInstalledFonts(false);
 </script>
 </head>
 <body>

Modified: trunk/LayoutTests/fast/text/user-installed-fonts/shadow-disable.html (226171 => 226172)


--- trunk/LayoutTests/fast/text/user-installed-fonts/shadow-disable.html	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/shadow-disable.html	2017-12-20 03:24:15 UTC (rev 226172)
@@ -5,7 +5,7 @@
 if (window.testRunner)
     testRunner.installFakeHelvetica("Helvetica-400");
 if (window.internals)
-    internals.settings.setShouldDisallowUserInstalledFonts(true);
+    internals.settings.setShouldAllowUserInstalledFonts(false);
 </script>
 </head>
 <body>

Modified: trunk/LayoutTests/fast/text/user-installed-fonts/shadow-family-disable.html (226171 => 226172)


--- trunk/LayoutTests/fast/text/user-installed-fonts/shadow-family-disable.html	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/shadow-family-disable.html	2017-12-20 03:24:15 UTC (rev 226172)
@@ -5,7 +5,7 @@
 if (window.testRunner)
     testRunner.installFakeHelvetica("Helvetica-500");
 if (window.internals)
-    internals.settings.setShouldDisallowUserInstalledFonts(true);
+    internals.settings.setShouldAllowUserInstalledFonts(false);
 </script>
 </head>
 <body>

Modified: trunk/LayoutTests/fast/text/user-installed-fonts/shadow-postscript-disable.html (226171 => 226172)


--- trunk/LayoutTests/fast/text/user-installed-fonts/shadow-postscript-disable.html	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/shadow-postscript-disable.html	2017-12-20 03:24:15 UTC (rev 226172)
@@ -5,7 +5,7 @@
 if (window.testRunner)
     testRunner.installFakeHelvetica("Helvetica2-400");
 if (window.internals)
-    internals.settings.setShouldDisallowUserInstalledFonts(true);
+    internals.settings.setShouldAllowUserInstalledFonts(false);
 </script>
 </head>
 <body>

Modified: trunk/LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family-disable.html (226171 => 226172)


--- trunk/LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family-disable.html	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/LayoutTests/fast/text/user-installed-fonts/shadow-postscript-family-disable.html	2017-12-20 03:24:15 UTC (rev 226172)
@@ -5,7 +5,7 @@
 if (window.testRunner)
     testRunner.installFakeHelvetica("Helvetica2-500");
 if (window.internals)
-    internals.settings.setShouldDisallowUserInstalledFonts(true);
+    internals.settings.setShouldAllowUserInstalledFonts(false);
 </script>
 </head>
 <body>

Modified: trunk/Source/WebCore/ChangeLog (226171 => 226172)


--- trunk/Source/WebCore/ChangeLog	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/ChangeLog	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1,3 +1,52 @@
+2017-12-19  Myles C. Maxfield  <[email protected]>
+
+        Refactor user-installed font setting for clarity
+        https://bugs.webkit.org/show_bug.cgi?id=181013
+
+        Reviewed by Simon Fraser.
+
+        Pave the way for https://bugs.webkit.org/show_bug.cgi?id=180951.
+
+        This patch renames the Setting to not have so many grammatical negatives, and moves
+        some CoreText-specific FontCache function signatures into a new FontCacheCoreText.h
+        header file. It also uses the AllowUserInstalledFonts enum class in more places instead
+        of the old boolean we were using, and puts this enum class in the common TextFlags.h
+        header.
+
+        No new tests because there is no behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSFontFaceSet.cpp:
+        (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::initializeFontStyle):
+        * page/Settings.yaml:
+        * platform/graphics/FontCache.h:
+        (WebCore::SynthesisPair::SynthesisPair): Deleted.
+        (WebCore::SynthesisPair::boldObliquePair const): Deleted.
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::m_shouldAllowUserInstalledFonts):
+        (WebCore::m_mayRepresentUserInstalledFont): Deleted.
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::shouldAllowUserInstalledFonts const):
+        (WebCore::FontDescription::setShouldAllowUserInstalledFonts):
+        (WebCore::FontDescription::operator== const):
+        (WebCore::FontDescription::mayRepresentUserInstalledFont const): Deleted.
+        (WebCore::FontDescription::setMayRepresentUserInstalledFont): Deleted.
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::FontDatabase::singleton):
+        (WebCore::FontDatabase::singletonAllowingUserInstalledFonts):
+        (WebCore::FontDatabase::singletonDisallowingUserInstalledFonts):
+        (WebCore::FontDatabase::FontDatabase):
+        (WebCore::platformFontLookupWithFamily):
+        (WebCore::fontWithFamily):
+        * platform/graphics/cocoa/FontCacheCoreText.h: Added.
+        (WebCore::SynthesisPair::SynthesisPair):
+        (WebCore::SynthesisPair::boldObliquePair const):
+        * platform/text/TextFlags.h:
+        * style/StyleResolveForDocument.cpp:
+        (WebCore::Style::resolveForDocument):
+
 2017-12-19  Youenn Fablet  <[email protected]>
 
         UserMediaRequest should stop a request when Document is being stopped

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (226171 => 226172)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-12-20 03:24:15 UTC (rev 226172)
@@ -3722,6 +3722,7 @@
 		C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
 		C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */; };
 		C21DF2EA1D9E4E9900F5B24C /* CSSFontVariationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */; };
+		C2458E631FE897B000594759 /* FontCacheCoreText.h in Headers */ = {isa = PBXBuildFile; fileRef = C2458E611FE8979E00594759 /* FontCacheCoreText.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		C26017A41C72DC9900F74A16 /* CSSFontFaceSet.h in Headers */ = {isa = PBXBuildFile; fileRef = C26017A21C72DC9900F74A16 /* CSSFontFaceSet.h */; };
 		C280833F1C6DC26F001451B6 /* JSFontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = C280833E1C6DC22C001451B6 /* JSFontFace.h */; };
 		C2AB0AF71E6B3C6C001348C5 /* FontSelectionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -12641,6 +12642,7 @@
 		C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; };
 		C21DF2E71D9E4E9900F5B24C /* CSSFontVariationValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontVariationValue.cpp; sourceTree = "<group>"; };
 		C21DF2E81D9E4E9900F5B24C /* CSSFontVariationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontVariationValue.h; sourceTree = "<group>"; };
+		C2458E611FE8979E00594759 /* FontCacheCoreText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontCacheCoreText.h; sourceTree = "<group>"; };
 		C26017A11C72DC9900F74A16 /* CSSFontFaceSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontFaceSet.cpp; sourceTree = "<group>"; };
 		C26017A21C72DC9900F74A16 /* CSSFontFaceSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFaceSet.h; sourceTree = "<group>"; };
 		C280833C1C6DB194001451B6 /* FontFace.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FontFace.idl; sourceTree = "<group>"; };
@@ -23009,6 +23011,7 @@
 			isa = PBXGroup;
 			children = (
 				1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */,
+				C2458E611FE8979E00594759 /* FontCacheCoreText.h */,
 				B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
 				7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
 				1C12AC2C1EE779950079E0A0 /* FontDescriptionCocoa.cpp */,
@@ -26994,6 +26997,7 @@
 				1AC2D89D1B1E291F00D52E87 /* FontAntialiasingStateSaver.h in Headers */,
 				BCB92D4F1293550B00C8387F /* FontBaseline.h in Headers */,
 				B2C3DA630D006CD600EF6F26 /* FontCache.h in Headers */,
+				C2458E631FE897B000594759 /* FontCacheCoreText.h in Headers */,
 				B2C3DA610D006CD600EF6F26 /* FontCascade.h in Headers */,
 				B2C3DA680D006CD600EF6F26 /* FontCascadeFonts.h in Headers */,
 				B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */,

Modified: trunk/Source/WebCore/css/CSSFontFaceSet.cpp (226171 => 226172)


--- trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2017-12-20 03:24:15 UTC (rev 226172)
@@ -104,9 +104,9 @@
     if (m_locallyInstalledFacesLookupTable.contains(familyName))
         return;
 
-    FontCache::AllowUserInstalledFonts allowUserInstalledFonts = FontCache::AllowUserInstalledFonts::Yes;
-    if (m_owningFontSelector->document() && m_owningFontSelector->document()->settings().shouldDisallowUserInstalledFonts())
-        allowUserInstalledFonts = FontCache::AllowUserInstalledFonts::No;
+    AllowUserInstalledFonts allowUserInstalledFonts = AllowUserInstalledFonts::Yes;
+    if (m_owningFontSelector->document())
+        allowUserInstalledFonts = m_owningFontSelector->document()->settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No;
     Vector<FontSelectionCapabilities> capabilities = FontCache::singleton().getFontSelectionCapabilitiesInFamily(familyName, allowUserInstalledFonts);
     if (capabilities.isEmpty())
         return;

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (226171 => 226172)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1788,7 +1788,7 @@
     fontDescription.setOneFamily(standardFamily);
     fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
     setFontSize(fontDescription, Style::fontSizeForKeyword(CSSValueMedium, false, document()));
-    fontDescription.setMayRepresentUserInstalledFont(!settings().shouldDisallowUserInstalledFonts());
+    fontDescription.setShouldAllowUserInstalledFonts(settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);
     setFontDescription(fontDescription);
 }
 

Modified: trunk/Source/WebCore/page/Settings.yaml (226171 => 226172)


--- trunk/Source/WebCore/page/Settings.yaml	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/page/Settings.yaml	2017-12-20 03:24:15 UTC (rev 226172)
@@ -661,8 +661,8 @@
   initial: SecurityOrigin::AllowAllStorage
   onChange: storageBlockingPolicyChanged
 
-shouldDisallowUserInstalledFonts:
-  initial: false
+shouldAllowUserInstalledFonts:
+  initial: true
   onChange: setNeedsRecalcStyleInAllFrames
 
 # Only set by Layout Tests.

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (226171 => 226172)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2017-12-20 03:24:15 UTC (rev 226172)
@@ -41,7 +41,7 @@
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(COCOA)
-#include <CoreText/CTFont.h>
+#include "FontCacheCoreText.h"
 #endif
 
 #if OS(WINDOWS)
@@ -200,10 +200,6 @@
     static IMultiLanguage* getMultiLanguageInterface();
 #endif
 
-    enum class AllowUserInstalledFonts {
-        Yes,
-        No
-    };
     // This function exists so CSSFontSelector can have a unified notion of preinstalled fonts and @font-face.
     // It comes into play when you create an @font-face which shares a family name as a preinstalled font.
     Vector<FontSelectionCapabilities> getFontSelectionCapabilitiesInFamily(const AtomicString&, AllowUserInstalledFonts);
@@ -270,33 +266,8 @@
     return createFontPlatformData(fontDescription, family, nullptr, nullptr, { });
 }
 
-#if PLATFORM(COCOA)
+#if !PLATFORM(COCOA)
 
-struct SynthesisPair {
-    SynthesisPair(bool needsSyntheticBold, bool needsSyntheticOblique)
-        : needsSyntheticBold(needsSyntheticBold)
-        , needsSyntheticOblique(needsSyntheticOblique)
-    {
-    }
-
-    std::pair<bool, bool> boldObliquePair() const
-    {
-        return std::make_pair(needsSyntheticBold, needsSyntheticOblique);
-    }
-
-    bool needsSyntheticBold;
-    bool needsSyntheticOblique;
-};
-
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size, bool applyWeightWidthSlopeVariations = true);
-SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
-RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size);
-RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);
-bool requiresCustomFallbackFont(UChar32 character);
-FontSelectionCapabilities capabilitiesForFontDescriptor(CTFontDescriptorRef);
-
-#else
-
 inline void FontCache::platformPurgeInactiveFontData()
 {
 }

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.cpp (226171 => 226172)


--- trunk/Source/WebCore/platform/graphics/FontDescription.cpp	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.cpp	2017-12-20 03:24:15 UTC (rev 226172)
@@ -80,7 +80,7 @@
     , m_variantEastAsianRuby(static_cast<unsigned>(FontVariantEastAsianRuby::Normal))
     , m_opticalSizing(static_cast<unsigned>(FontOpticalSizing::Enabled))
     , m_fontStyleAxis(FontCascadeDescription::initialFontStyleAxis() == FontStyleAxis::ital)
-    , m_mayRepresentUserInstalledFont(true)
+    , m_shouldAllowUserInstalledFonts(static_cast<unsigned>(AllowUserInstalledFonts::Yes))
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (226171 => 226172)


--- trunk/Source/WebCore/platform/graphics/FontDescription.h	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h	2017-12-20 03:24:15 UTC (rev 226172)
@@ -114,7 +114,7 @@
     }
     FontOpticalSizing opticalSizing() const { return static_cast<FontOpticalSizing>(m_opticalSizing); }
     FontStyleAxis fontStyleAxis() const { return m_fontStyleAxis ? FontStyleAxis::ital : FontStyleAxis::slnt; }
-    bool mayRepresentUserInstalledFont() const { return m_mayRepresentUserInstalledFont; }
+    AllowUserInstalledFonts shouldAllowUserInstalledFonts() const { return static_cast<AllowUserInstalledFonts>(m_shouldAllowUserInstalledFonts); }
 
     void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
     void setItalic(FontSelectionValue italic) { m_fontSelectionRequest.slope = italic; }
@@ -149,7 +149,7 @@
     void setVariantEastAsianRuby(FontVariantEastAsianRuby variant) { m_variantEastAsianRuby = static_cast<unsigned>(variant); }
     void setOpticalSizing(FontOpticalSizing sizing) { m_opticalSizing = static_cast<unsigned>(sizing); }
     void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; }
-    void setMayRepresentUserInstalledFont(bool mayRepresentUserInstalledFont) { m_mayRepresentUserInstalledFont = mayRepresentUserInstalledFont; }
+    void setShouldAllowUserInstalledFonts(AllowUserInstalledFonts shouldAllowUserInstalledFonts) { m_shouldAllowUserInstalledFonts = static_cast<unsigned>(shouldAllowUserInstalledFonts); }
 
     static void invalidateCaches();
 
@@ -185,7 +185,7 @@
     unsigned m_variantEastAsianRuby : 1; // FontVariantEastAsianRuby
     unsigned m_opticalSizing : 1; // FontOpticalSizing
     unsigned m_fontStyleAxis : 1; // Whether "font-style: italic" or "font-style: oblique 20deg" was specified
-    unsigned m_mayRepresentUserInstalledFont : 1; // If this description is allowed to match a user-installed font
+    unsigned m_shouldAllowUserInstalledFonts : 1; // AllowUserInstalledFonts: If this description is allowed to match a user-installed font
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -220,7 +220,7 @@
         && m_variantEastAsianRuby == other.m_variantEastAsianRuby
         && m_opticalSizing == other.m_opticalSizing
         && m_fontStyleAxis == other.m_fontStyleAxis
-        && m_mayRepresentUserInstalledFont == other.m_mayRepresentUserInstalledFont;
+        && m_shouldAllowUserInstalledFonts == other.m_shouldAllowUserInstalledFonts;
 }
 
 // FIXME: Move to a file of its own.

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (226171 => 226172)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-12-20 03:24:15 UTC (rev 226172)
@@ -833,7 +833,7 @@
 #if !CAN_DISALLOW_USER_INSTALLED_FONTS
     static FontDatabase& singleton()
     {
-        static NeverDestroyed<FontDatabase> database(FontCache::AllowUserInstalledFonts::Yes);
+        static NeverDestroyed<FontDatabase> database(AllowUserInstalledFonts::Yes);
         return database;
     }
 #endif
@@ -841,7 +841,7 @@
     static FontDatabase& singletonAllowingUserInstalledFonts()
     {
 #if CAN_DISALLOW_USER_INSTALLED_FONTS
-        static NeverDestroyed<FontDatabase> database(FontCache::AllowUserInstalledFonts::Yes);
+        static NeverDestroyed<FontDatabase> database(AllowUserInstalledFonts::Yes);
         return database;
 #else
         return singleton();
@@ -851,7 +851,7 @@
     static FontDatabase& singletonDisallowingUserInstalledFonts()
     {
 #if CAN_DISALLOW_USER_INSTALLED_FONTS
-        static NeverDestroyed<FontDatabase> database(FontCache::AllowUserInstalledFonts::No);
+        static NeverDestroyed<FontDatabase> database(AllowUserInstalledFonts::No);
         return database;
 #else
         return singleton();
@@ -974,7 +974,7 @@
 private:
     friend class NeverDestroyed<FontDatabase>;
 
-    FontDatabase(FontCache::AllowUserInstalledFonts allowUserInstalledFonts)
+    FontDatabase(AllowUserInstalledFonts allowUserInstalledFonts)
         : m_allowUserInstalledFonts(allowUserInstalledFonts)
     {
     }
@@ -981,7 +981,7 @@
 
     HashMap<String, InstalledFontFamily> m_familyNameToFontDescriptors;
     HashMap<String, InstalledFont> m_postScriptNameToFontDescriptors;
-    FontCache::AllowUserInstalledFonts m_allowUserInstalledFonts;
+    AllowUserInstalledFonts m_allowUserInstalledFonts;
 };
 
 // Because this struct holds intermediate values which may be in the compressed -1 - 1 GX range, we don't want to use the relatively large
@@ -1190,7 +1190,7 @@
     bool createdFromPostScriptName { false };
 };
 
-static FontLookup platformFontLookupWithFamily(const AtomicString& family, FontSelectionRequest request, float size, bool mayRepresentUserInstalledFont)
+static FontLookup platformFontLookupWithFamily(const AtomicString& family, FontSelectionRequest request, float size, AllowUserInstalledFonts allowUserInstalledFonts)
 {
     const auto& whitelist = fontWhitelist();
     if (!isSystemFont(family) && whitelist.size() && !whitelist.contains(family))
@@ -1197,11 +1197,11 @@
         return { nullptr };
 
 #if SHOULD_USE_CORE_TEXT_FONT_LOOKUP
-    UNUSED_PARAM(mayRepresentUserInstalledFont);
+    UNUSED_PARAM(allowUserInstalledFonts);
     CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
     return { adoptCF(CTFontCreateForCSS(family.string().createCFString().get(), static_cast<float>(request.weight), traits, size)) };
 #else
-    auto& fontDatabase = mayRepresentUserInstalledFont ? FontDatabase::singletonAllowingUserInstalledFonts() : FontDatabase::singletonDisallowingUserInstalledFonts();
+    auto& fontDatabase = allowUserInstalledFonts == AllowUserInstalledFonts::Yes ? FontDatabase::singletonAllowingUserInstalledFonts() : FontDatabase::singletonDisallowingUserInstalledFonts();
     const auto& familyFonts = fontDatabase.collectionForFamily(family.string());
     if (familyFonts.isEmpty()) {
         // The CSS spec states that font-family only accepts a name of an actual font family. However, in WebKit, we claim to also
@@ -1265,7 +1265,7 @@
     FontLookup fontLookup;
     fontLookup.result = platformFontWithFamilySpecialCase(family, request, size);
     if (!fontLookup.result)
-        fontLookup = platformFontLookupWithFamily(family, request, size, fontDescription.mayRepresentUserInstalledFont());
+        fontLookup = platformFontLookupWithFamily(family, request, size, fontDescription.shouldAllowUserInstalledFonts());
     return preparePlatformFont(fontLookup.result.get(), fontDescription, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, size, !fontLookup.createdFromPostScriptName);
 }
 

Added: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h (0 => 226172)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h	2017-12-20 03:24:15 UTC (rev 226172)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2017 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "FontDescription.h"
+
+#include <CoreText/CTFont.h>
+
+namespace WebCore {
+
+struct SynthesisPair {
+    SynthesisPair(bool needsSyntheticBold, bool needsSyntheticOblique)
+        : needsSyntheticBold(needsSyntheticBold)
+        , needsSyntheticOblique(needsSyntheticOblique)
+    {
+    }
+
+    std::pair<bool, bool> boldObliquePair() const
+    {
+        return std::make_pair(needsSyntheticBold, needsSyntheticOblique);
+    }
+
+    bool needsSyntheticBold;
+    bool needsSyntheticOblique;
+};
+
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, const FontDescription&, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, float size, bool applyWeightWidthSlopeVariations = true);
+SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
+RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size);
+RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);
+bool requiresCustomFallbackFont(UChar32 character);
+FontSelectionCapabilities capabilitiesForFontDescriptor(CTFontDescriptorRef);
+
+}
Property changes on: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Author Date Id Rev URL \ No newline at end of property

Modified: trunk/Source/WebCore/platform/text/TextFlags.h (226171 => 226172)


--- trunk/Source/WebCore/platform/text/TextFlags.h	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/platform/text/TextFlags.h	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006 Apple Inc.  All rights reserved.
+ * Copyright (C) 2003, 2006, 2017 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -362,4 +362,9 @@
     ital
 };
 
+enum class AllowUserInstalledFonts {
+    No,
+    Yes
+};
+
 }

Modified: trunk/Source/WebCore/style/StyleResolveForDocument.cpp (226171 => 226172)


--- trunk/Source/WebCore/style/StyleResolveForDocument.cpp	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebCore/style/StyleResolveForDocument.cpp	2017-12-20 03:24:15 UTC (rev 226172)
@@ -109,7 +109,7 @@
     fontDescription.setLocale(document.contentLanguage());
     fontDescription.setRenderingMode(settings.fontRenderingMode());
     fontDescription.setOneFamily(standardFamily);
-    fontDescription.setMayRepresentUserInstalledFont(!settings.shouldDisallowUserInstalledFonts());
+    fontDescription.setShouldAllowUserInstalledFonts(settings.shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);
 
     fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
     int size = fontSizeForKeyword(CSSValueMedium, false, document);

Modified: trunk/Source/WebKit/ChangeLog (226171 => 226172)


--- trunk/Source/WebKit/ChangeLog	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebKit/ChangeLog	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1,3 +1,27 @@
+2017-12-19  Myles C. Maxfield  <[email protected]>
+
+        Refactor user-installed font setting for clarity
+        https://bugs.webkit.org/show_bug.cgi?id=181013
+
+        Reviewed by Simon Fraser.
+
+        There are no clients of this SPI yet, so we can rename it to remove the
+        grammatical negative.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetShouldAllowUserInstalledFonts):
+        (WKPreferencesGetShouldAllowUserInstalledFonts):
+        (WKPreferencesSetShouldDisallowUserInstalledFonts): Deleted.
+        (WKPreferencesGetShouldDisallowUserInstalledFonts): Deleted.
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _shouldAllowUserInstalledFonts]):
+        (-[WKPreferences _setShouldAllowUserInstalledFonts:]):
+        (-[WKPreferences _shouldDisallowUserInstalledFonts]): Deleted.
+        (-[WKPreferences _setShouldDisallowUserInstalledFonts:]): Deleted.
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+
 2017-12-19  Eric Carlson  <[email protected]>
 
         [MediaStream] Clean up RealtimeMediaSource interfaces

Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (226171 => 226172)


--- trunk/Source/WebKit/Shared/WebPreferences.yaml	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1034,9 +1034,9 @@
   defaultValue: 0
   category: debug
 
-ShouldDisallowUserInstalledFonts:
+ShouldAllowUserInstalledFonts:
   type: bool
-  defaultValue: false
+  defaultValue: true
 
 
 # For experimental features:

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp (226171 => 226172)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferences.cpp	2017-12-20 03:24:15 UTC (rev 226172)
@@ -1920,12 +1920,12 @@
     return toImpl(preferencesRef)->accessibilityObjectModelEnabled();
 }
 
-void WKPreferencesSetShouldDisallowUserInstalledFonts(WKPreferencesRef preferencesRef, bool flag)
+void WKPreferencesSetShouldAllowUserInstalledFonts(WKPreferencesRef preferencesRef, bool flag)
 {
-    toImpl(preferencesRef)->setShouldDisallowUserInstalledFonts(flag);
+    toImpl(preferencesRef)->setShouldAllowUserInstalledFonts(flag);
 }
 
-bool WKPreferencesGetShouldDisallowUserInstalledFonts(WKPreferencesRef preferencesRef)
+bool WKPreferencesGetShouldAllowUserInstalledFonts(WKPreferencesRef preferencesRef)
 {
-    return toImpl(preferencesRef)->shouldDisallowUserInstalledFonts();
+    return toImpl(preferencesRef)->shouldAllowUserInstalledFonts();
 }

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h (226171 => 226172)


--- trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPreferencesRefPrivate.h	2017-12-20 03:24:15 UTC (rev 226172)
@@ -546,8 +546,8 @@
 WK_EXPORT bool WKPreferencesGetAccessibilityObjectModelEnabled(WKPreferencesRef);
 
 // Defaults to false.
-WK_EXPORT void WKPreferencesSetShouldDisallowUserInstalledFonts(WKPreferencesRef, bool flag);
-WK_EXPORT bool WKPreferencesGetShouldDisallowUserInstalledFonts(WKPreferencesRef);
+WK_EXPORT void WKPreferencesSetShouldAllowUserInstalledFonts(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetShouldAllowUserInstalledFonts(WKPreferencesRef);
     
 #ifdef __cplusplus
 }

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (226171 => 226172)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm	2017-12-20 03:24:15 UTC (rev 226172)
@@ -657,14 +657,14 @@
     _preferences->setJavaScriptCanAccessClipboard(_javascript_CanAccessClipboard);
 }
 
-- (BOOL)_shouldDisallowUserInstalledFonts
+- (BOOL)_shouldAllowUserInstalledFonts
 {
-    return _preferences->shouldDisallowUserInstalledFonts();
+    return _preferences->shouldAllowUserInstalledFonts();
 }
 
-- (void)_setShouldDisallowUserInstalledFonts:(BOOL)_shouldDisallowUserInstalledFonts
+- (void)_setShouldAllowUserInstalledFonts:(BOOL)_shouldAllowUserInstalledFonts
 {
-    _preferences->setShouldDisallowUserInstalledFonts(_shouldDisallowUserInstalledFonts);
+    _preferences->setShouldAllowUserInstalledFonts(_shouldAllowUserInstalledFonts);
 }
 
 #if PLATFORM(MAC)

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (226171 => 226172)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2017-12-20 03:17:24 UTC (rev 226171)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h	2017-12-20 03:24:15 UTC (rev 226172)
@@ -115,7 +115,7 @@
 @property (nonatomic, setter=_setJavaScriptCanAccessClipboard:) BOOL _javaScriptCanAccessClipboard WK_API_AVAILABLE(macosx(10.13), ios(11.0));
 @property (nonatomic, setter=_setDOMPasteAllowed:) BOOL _domPasteAllowed WK_API_AVAILABLE(macosx(10.13), ios(11.0));
 
-@property (nonatomic, setter=_setShouldDisallowUserInstalledFonts:) BOOL _shouldDisallowUserInstalledFonts WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setShouldAllowUserInstalledFonts:) BOOL _shouldAllowUserInstalledFonts WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature WK_API_AVAILABLE(macosx(10.12), ios(10.0));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to