Diff
Modified: trunk/LayoutTests/platform/mac/TestExpectations (227775 => 227776)
--- trunk/LayoutTests/platform/mac/TestExpectations 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2018-01-30 09:01:28 UTC (rev 227776)
@@ -1754,8 +1754,8 @@
# User-installed font infrastructure is ony present on certain OSes.
webkit.org/b/180062 [ ElCapitan Sierra HighSierra ] fast/text/user-installed-fonts/disable.html [ ImageOnlyFailure ]
-webkit.org/b/180062 [ ElCapitan Sierra HighSierra ] fast/text/user-installed-fonts/shadow-postscript.html [ ImageOnlyFailure ]
-webkit.org/b/180062 [ ElCapitan Sierra HighSierra ] fast/text/user-installed-fonts/shadow.html [ ImageOnlyFailure ]
+webkit.org/b/180062 fast/text/user-installed-fonts/shadow-postscript.html [ ImageOnlyFailure ]
+webkit.org/b/180062 fast/text/user-installed-fonts/shadow.html [ ImageOnlyFailure ]
webkit.org/b/180560 accessibility/mac/html5-input-number.html [ Pass Failure ]
Modified: trunk/Source/WebCore/ChangeLog (227775 => 227776)
--- trunk/Source/WebCore/ChangeLog 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/ChangeLog 2018-01-30 09:01:28 UTC (rev 227776)
@@ -1,3 +1,28 @@
+2018-01-30 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ A disallowed user-installed font may be used if its PostScript name is specified
+ https://bugs.webkit.org/show_bug.cgi?id=180951
+
+ Reviewed by Brent Fulgham.
+
+ This patch adds a new CoreText font attribute, kCTFontFallbackOptionAttribute, to the
+ fonts which WebKit creates. It also adds this attribute to web fonts, so that font
+ fallback will happen according to our rules about user-installed fonts. It also marks
+ these font attributes as "mandatory" so CoreText will be guaranteed to follow the
+ policy.
+
+ Test: fast/text/user-installed-fonts/disable.html
+
+ * platform/graphics/FontCache.h:
+ (WebCore::FontDescriptionKey::makeFlagsKey):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::FontDatabase::collectionForFamily):
+ (WebCore::FontDatabase::fontForPostScriptName):
+ (WebCore::addAttributesForUserInstalledFonts):
+ (WebCore::mandatoryAttributesForUserInstalledFonts):
+ * platform/graphics/mac/FontCustomPlatformData.cpp:
+ (WebCore::FontCustomPlatformData::fontPlatformData):
+
2018-01-29 Youenn Fablet <you...@apple.com>
Cache API should make sure to resolve caches.open promises in the same order as called
Modified: trunk/Source/WebCore/PAL/ChangeLog (227775 => 227776)
--- trunk/Source/WebCore/PAL/ChangeLog 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/PAL/ChangeLog 2018-01-30 09:01:28 UTC (rev 227776)
@@ -1,3 +1,12 @@
+2018-01-30 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ A disallowed user-installed font may be used if its PostScript name is specified
+ https://bugs.webkit.org/show_bug.cgi?id=180951
+
+ Reviewed by Brent Fulgham.
+
+ * pal/spi/cocoa/CoreTextSPI.h:
+
2018-01-29 Jiewen Tan <jiewen_...@apple.com>
[WebAuthN] Add a compile-time feature flag
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h (227775 => 227776)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h 2018-01-30 09:01:28 UTC (rev 227776)
@@ -55,6 +55,13 @@
kCTRunStatusHasOrigins = (1 << 4),
};
+typedef CF_OPTIONS(CFOptionFlags, CTFontFallbackOption) {
+ kCTFontFallbackOptionNone = 0,
+ kCTFontFallbackOptionSystem = 1 << 0,
+ kCTFontFallbackOptionUserInstalled = 1 << 1,
+ kCTFontFallbackOptionDefault = kCTFontFallbackOptionSystem | kCTFontFallbackOptionUserInstalled,
+};
+
#endif
WTF_EXTERN_C_BEGIN
@@ -66,6 +73,7 @@
extern const CFStringRef kCTFontOpticalSizeAttribute;
extern const CFStringRef kCTFontPostScriptNameAttribute;
extern const CFStringRef kCTFontUserInstalledAttribute;
+extern const CFStringRef kCTFontFallbackOptionAttribute;
bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions);
Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (227775 => 227776)
--- trunk/Source/WebCore/platform/graphics/FontCache.h 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h 2018-01-30 09:01:28 UTC (rev 227776)
@@ -124,7 +124,8 @@
private:
static std::array<unsigned, 2> makeFlagsKey(const FontDescription& description)
{
- unsigned first = static_cast<unsigned>(description.script()) << 13
+ unsigned first = static_cast<unsigned>(description.script()) << 14
+ | static_cast<unsigned>(description.shouldAllowUserInstalledFonts()) << 13
| static_cast<unsigned>(description.fontStyleAxis() == FontStyleAxis::slnt) << 12
| static_cast<unsigned>(description.opticalSizing()) << 11
| static_cast<unsigned>(description.textRenderingMode()) << 9
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (227775 => 227776)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2018-01-30 09:01:28 UTC (rev 227776)
@@ -889,21 +889,12 @@
auto folded = familyName.foldCase();
return m_familyNameToFontDescriptors.ensure(folded, [&] {
auto familyNameString = folded.createCFString();
- RetainPtr<CFDictionaryRef> attributes;
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
- if (m_allowUserInstalledFonts == AllowUserInstalledFonts::No) {
- CFTypeRef keys[] = { kCTFontFamilyNameAttribute, kCTFontUserInstalledAttribute };
- CFTypeRef values[] = { familyNameString.get(), kCFBooleanFalse };
- attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- } else
-#endif
- {
- CFTypeRef keys[] = { kCTFontFamilyNameAttribute };
- CFTypeRef values[] = { familyNameString.get() };
- attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- }
+ auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ CFDictionaryAddValue(attributes.get(), kCTFontFamilyNameAttribute, familyNameString.get());
+ addAttributesForUserInstalledFonts(attributes.get(), m_allowUserInstalledFonts);
auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
- if (auto matches = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptorToMatch.get(), nullptr))) {
+ RetainPtr<CFSetRef> mandatoryAttributes = mandatoryAttributesForUserInstalledFonts(m_allowUserInstalledFonts);
+ if (auto matches = adoptCF(CTFontDescriptorCreateMatchingFontDescriptors(fontDescriptorToMatch.get(), mandatoryAttributes.get()))) {
auto count = CFArrayGetCount(matches.get());
Vector<InstalledFont> result;
result.reserveInitialCapacity(count);
@@ -927,21 +918,13 @@
#else
CFStringRef nameAttribute = kCTFontNameAttribute;
#endif
- RetainPtr<CFDictionaryRef> attributes;
-#if CAN_DISALLOW_USER_INSTALLED_FONTS
- if (m_allowUserInstalledFonts == AllowUserInstalledFonts::No) {
- CFTypeRef keys[] = { kCTFontEnabledAttribute, nameAttribute, kCTFontUserInstalledAttribute };
- CFTypeRef values[] = { kCFBooleanTrue, postScriptNameString.get(), kCFBooleanFalse };
- attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- } else
-#endif
- {
- CFTypeRef keys[] = { kCTFontEnabledAttribute, nameAttribute };
- CFTypeRef values[] = { kCFBooleanTrue, postScriptNameString.get() };
- attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- }
+ auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ CFDictionaryAddValue(attributes.get(), kCTFontEnabledAttribute, kCFBooleanTrue);
+ CFDictionaryAddValue(attributes.get(), nameAttribute, postScriptNameString.get());
+ addAttributesForUserInstalledFonts(attributes.get(), m_allowUserInstalledFonts);
auto fontDescriptorToMatch = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
- auto match = adoptCF(static_cast<CTFontDescriptorRef>(CTFontDescriptorCreateMatchingFontDescriptor(fontDescriptorToMatch.get(), nullptr)));
+ RetainPtr<CFSetRef> mandatoryAttributes = mandatoryAttributesForUserInstalledFonts(m_allowUserInstalledFonts);
+ auto match = adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(fontDescriptorToMatch.get(), mandatoryAttributes.get()));
return InstalledFont(match.get());
}).iterator->value;
}
@@ -1430,4 +1413,32 @@
return nullAtom();
}
+void addAttributesForUserInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts allowUserInstalledFonts)
+{
+#if CAN_DISALLOW_USER_INSTALLED_FONTS
+ if (allowUserInstalledFonts == AllowUserInstalledFonts::No) {
+ CFDictionaryAddValue(attributes, kCTFontUserInstalledAttribute, kCFBooleanFalse);
+ CTFontFallbackOption fallbackOption = kCTFontFallbackOptionSystem;
+ auto fallbackOptionNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &fallbackOption));
+ CFDictionaryAddValue(attributes, kCTFontFallbackOptionAttribute, fallbackOptionNumber.get());
+ }
+#else
+ UNUSED_PARAM(attributes);
+ UNUSED_PARAM(allowUserInstalledFonts);
+#endif
}
+
+RetainPtr<CFSetRef> mandatoryAttributesForUserInstalledFonts(AllowUserInstalledFonts allowUserInstalledFonts)
+{
+#if CAN_DISALLOW_USER_INSTALLED_FONTS
+ if (allowUserInstalledFonts == AllowUserInstalledFonts::No) {
+ CFTypeRef mandatoryAttributesValues[] = { kCTFontUserInstalledAttribute, kCTFontFallbackOptionAttribute };
+ return adoptCF(CFSetCreate(kCFAllocatorDefault, mandatoryAttributesValues, WTF_ARRAY_LENGTH(mandatoryAttributesValues), &kCFTypeSetCallBacks));
+ }
+#else
+ UNUSED_PARAM(allowUserInstalledFonts);
+#endif
+ return nullptr;
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h (227775 => 227776)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.h 2018-01-30 09:01:28 UTC (rev 227776)
@@ -56,5 +56,7 @@
RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);
bool requiresCustomFallbackFont(UChar32 character);
FontSelectionCapabilities capabilitiesForFontDescriptor(CTFontDescriptorRef);
+void addAttributesForUserInstalledFonts(CFMutableDictionaryRef attributes, AllowUserInstalledFonts);
+RetainPtr<CFSetRef> mandatoryAttributesForUserInstalledFonts(AllowUserInstalledFonts);
}
Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (227775 => 227776)
--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp 2018-01-30 07:34:44 UTC (rev 227775)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp 2018-01-30 09:01:28 UTC (rev 227776)
@@ -22,6 +22,7 @@
#include "FontCustomPlatformData.h"
#include "FontCache.h"
+#include "FontCacheCoreText.h"
#include "FontDescription.h"
#include "FontPlatformData.h"
#include "SharedBuffer.h"
@@ -36,10 +37,17 @@
FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
{
+ auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ addAttributesForUserInstalledFonts(attributes.get(), fontDescription.shouldAllowUserInstalledFonts());
+ auto modifiedFontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithAttributes(m_fontDescriptor.get(), attributes.get()));
+ RetainPtr<CFSetRef> mandatoryAttributes = mandatoryAttributesForUserInstalledFonts(fontDescription.shouldAllowUserInstalledFonts());
+ auto matchingFontDescriptor = adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(modifiedFontDescriptor.get(), mandatoryAttributes.get()));
+ ASSERT(matchingFontDescriptor);
+
int size = fontDescription.computedPixelSize();
FontOrientation orientation = fontDescription.orientation();
FontWidthVariant widthVariant = fontDescription.widthVariant();
- RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
+ RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(matchingFontDescriptor.get(), size, nullptr));
font = preparePlatformFont(font.get(), fontDescription, &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.computedSize());
ASSERT(font);
return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());