WebKit Bugzilla
Attachment 361078 Details for
Bug 187723
: [Cocoa] Ask platform for generic font family mappings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-187723-20190204113904.patch (text/plain), 35.60 KB, created by
Myles C. Maxfield
on 2019-02-04 11:39:05 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2019-02-04 11:39:05 PST
Size:
35.60 KB
patch
obsolete
>Subversion Revision: 240880 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7b8dc4ce5086afbfd26acaaceff92a35d3e0fb66..02ad70371f894552a05316b86d2fe3042d217216 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,56 @@ >+2019-02-04 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [Cocoa] Ask platform for generic font family mappings >+ https://bugs.webkit.org/show_bug.cgi?id=187723 >+ <rdar://problem/41892438> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ WebKit API allows setting the generic font families for the USCRIPT_COMMON script. >+ When trying to style a character with a generic font family, we first look to see if >+ we have a mapping for the particular script the character is rendered with, and if we >+ don't find a match, we then check USCRIPT_COMMON. >+ >+ In the Cocoa ports, the only way families get set for non-USCRIPT_COMMON scripts (aka >+ the only scripts which won't use the API families) is in >+ SettingsBase::initializeDefaultFontFamilies(). That function only sets the families >+ for the CJK scripts. >+ >+ The mappings inside SettingsBase are incorrect and conflict with our policy regarding >+ user-installed fonts. Instead, we should be consulting with the platform for some of >+ these mappings, by calling CTFontDescriptorCreateForCSSFamily(). However, the WebKit >+ API still has to work to set the mappings for untagged content. Therefore, we use the >+ system mappings for language-tagged content, and the API mappings for non-language-tagged >+ content. This is a good balance that makes sure we always have a good mapping for every >+ language, but API clients can still set the mappings, too. >+ >+ Test: fast/text/ja-sans-serif.html >+ >+ * css/CSSComputedStyleDeclaration.cpp: >+ * css/CSSFontSelector.cpp: >+ (WebCore::resolveGenericFamily): >+ * css/parser/CSSPropertyParser.cpp: >+ (WebCore::consumeFontFamily): >+ * page/cocoa/SettingsBaseCocoa.mm: >+ (WebCore::SettingsBase::initializeDefaultFontFamilies): >+ (WebCore::osakaMonoIsInstalled): Deleted. >+ * platform/graphics/FontDescription.cpp: >+ (WebCore::FontDescription::platformResolveGenericFamily): >+ * platform/graphics/FontDescription.h: >+ * platform/graphics/cocoa/FontDescriptionCocoa.cpp: >+ (WebCore::computeSpecializedChineseLocale): >+ (WebCore::cachedSpecializedChineseLocale): >+ (WebCore::languageChanged): >+ (WebCore::FontDescription::platformResolveGenericFamily): >+ * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp: >+ (WebCore::SystemFontDatabaseCoreText::clear): >+ (WebCore::SystemFontDatabaseCoreText::serifFamily): >+ (WebCore::SystemFontDatabaseCoreText::sansSerifFamily): >+ (WebCore::SystemFontDatabaseCoreText::cursiveFamily): >+ (WebCore::SystemFontDatabaseCoreText::fantasyFamily): >+ (WebCore::SystemFontDatabaseCoreText::monospaceFamily): >+ * platform/graphics/cocoa/SystemFontDatabaseCoreText.h: >+ > 2019-02-01 Chris Dumez <cdumez@apple.com> > > REGRESSION: Flaky ASSERTION FAILED: m_uncommittedState.state == State::Committed on http/tests/cookies/same-site/fetch-after-top-level-navigation-initiated-from-iframe-in-cross-origin-page.html >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index fbce47536ec4469687e2fbe073c2ab4abc46304c..eec57ff6d12d3260943f9b5991eba27360772dce 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,13 @@ >+2019-02-04 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [Cocoa] Ask platform for generic font family mappings >+ https://bugs.webkit.org/show_bug.cgi?id=187723 >+ <rdar://problem/41892438> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * pal/spi/cocoa/CoreTextSPI.h: >+ > 2019-01-30 Daniel Bates <dabates@apple.com> > > [iOS] Keyups for non-modifier keys identified as "Dead" when not focused in a content-editable element >diff --git a/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h b/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h >index 09af37dfd2295aaa33f82b01e3bd3cd0d40c9000..d62bb25d013017f9cbef8d83376733aaa6d12c38 100644 >--- a/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h >+++ b/Source/WebCore/PAL/pal/spi/cocoa/CoreTextSPI.h >@@ -79,6 +79,13 @@ extern const CFStringRef kCTFontPostScriptNameAttribute; > extern const CFStringRef kCTFontUserInstalledAttribute; > extern const CFStringRef kCTFontFallbackOptionAttribute; > >+extern const CFStringRef kCTFontCSSFamilySerif; >+extern const CFStringRef kCTFontCSSFamilySansSerif; >+extern const CFStringRef kCTFontCSSFamilyCursive; >+extern const CFStringRef kCTFontCSSFamilyFantasy; >+extern const CFStringRef kCTFontCSSFamilyMonospace; >+extern const CFStringRef kCTFontCSSFamilySystemUI; >+ > bool CTFontTransformGlyphs(CTFontRef, CGGlyph glyphs[], CGSize advances[], CFIndex count, CTFontTransformOptions); > > CGSize CTRunGetInitialAdvance(CTRunRef); >@@ -87,6 +94,7 @@ void CTRunGetBaseAdvancesAndOrigins(CTRunRef, CFRange, CGSize baseAdvances[], CG > CTTypesetterRef CTTypesetterCreateWithUniCharProviderAndOptions(CTUniCharProviderCallback, CTUniCharDisposeCallback, void* refCon, CFDictionaryRef options); > bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar characters[], CGGlyph glyphs[], CFIndex count); > void CTFontGetUnsummedAdvancesForGlyphsAndStyle(CTFontRef, CTFontOrientation, CGFontRenderingStyle, const CGGlyph[], CGSize advances[], CFIndex count); >+CTFontDescriptorRef CTFontDescriptorCreateForCSSFamily(CFStringRef cssFamily, CFStringRef language); > > CTFontDescriptorRef CTFontDescriptorCreateForUIType(CTFontUIFontType, CGFloat size, CFStringRef language); > CTFontDescriptorRef CTFontDescriptorCreateWithTextStyle(CFStringRef style, CFStringRef size, CFStringRef language); >diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >index 5aaae72fe550249bd0f6bd73580638f67da28a38..977eca3a41e17c7163c9f17af7c71476edceb89a 100644 >--- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >+++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp >@@ -1720,7 +1720,6 @@ bool ComputedStyleExtractor::useFixedFontDefaultSize() > return style->fontDescription().useFixedDefaultSize(); > } > >- > static CSSValueID identifierForFamily(const AtomicString& family) > { > if (family == cursiveFamily) >diff --git a/Source/WebCore/css/CSSFontSelector.cpp b/Source/WebCore/css/CSSFontSelector.cpp >index d55127bec949a99571c4eec9557f8e62926ccd07..4afb42eb8fe8cc0cfa728bd0a4e30c93255729ea 100644 >--- a/Source/WebCore/css/CSSFontSelector.cpp >+++ b/Source/WebCore/css/CSSFontSelector.cpp >@@ -274,8 +274,12 @@ void CSSFontSelector::fontCacheInvalidated() > dispatchInvalidationCallbacks(); > } > >-static const AtomicString& resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName) >+static AtomicString resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomicString& familyName) > { >+ auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.locale(), familyName); >+ if (!platformResult.isNull()) >+ return platformResult; >+ > if (!document) > return familyName; > >diff --git a/Source/WebCore/css/parser/CSSPropertyParser.cpp b/Source/WebCore/css/parser/CSSPropertyParser.cpp >index 2f536e97f3388ed484d2c94b3f4664fdcd81a3f3..8d38f95c98d7669973687709a2e6b7276df3eb9e 100644 >--- a/Source/WebCore/css/parser/CSSPropertyParser.cpp >+++ b/Source/WebCore/css/parser/CSSPropertyParser.cpp >@@ -1067,16 +1067,13 @@ static RefPtr<CSSValueList> consumeFontFamily(CSSParserTokenRange& range) > { > RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); > do { >- RefPtr<CSSValue> parsedValue = consumeGenericFamily(range); >- if (parsedValue) { >+ if (RefPtr<CSSValue> parsedValue = consumeGenericFamily(range)) > list->append(parsedValue.releaseNonNull()); >- } else { >- parsedValue = consumeFamilyName(range); >- if (parsedValue) { >+ else { >+ if (auto parsedValue = consumeFamilyName(range)) > list->append(parsedValue.releaseNonNull()); >- } else { >+ else > return nullptr; >- } > } > } while (consumeCommaIncludingWhitespace(range)); > return list; >diff --git a/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm b/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm >index 57f825df99559f0935738a38b36917bd8f9e28e7..89ca139b9ca6aead3928c9299bf45da40fff144b 100644 >--- a/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm >+++ b/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm >@@ -48,41 +48,12 @@ static inline const char* sansSerifSimplifiedHanFontFamily() > > #if PLATFORM(MAC) > >-static bool osakaMonoIsInstalled() >-{ >- int one = 1; >- RetainPtr<CFNumberRef> yes = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &one)); >- CFTypeRef keys[] = { kCTFontEnabledAttribute, kCTFontNameAttribute }; >- CFTypeRef values[] = { yes.get(), CFSTR("Osaka-Mono") }; >- RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(values), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); >- RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get())); >- RetainPtr<CFSetRef> mandatoryAttributes = adoptCF(CFSetCreate(kCFAllocatorDefault, keys, WTF_ARRAY_LENGTH(keys), &kCFTypeSetCallBacks)); >- return adoptCF(CTFontDescriptorCreateMatchingFontDescriptor(descriptor.get(), mandatoryAttributes.get())); >-} >- > void SettingsBase::initializeDefaultFontFamilies() > { > setStandardFontFamily("Songti TC", USCRIPT_TRADITIONAL_HAN); >- setSerifFontFamily("Songti TC", USCRIPT_TRADITIONAL_HAN); >- setFixedFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN); >- setSansSerifFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN); >- setCursiveFontFamily("Kaiti TC", USCRIPT_TRADITIONAL_HAN); >- > setStandardFontFamily("Songti SC", USCRIPT_SIMPLIFIED_HAN); >- setSerifFontFamily("Songti SC", USCRIPT_SIMPLIFIED_HAN); >- setFixedFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN); >- setSansSerifFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN); >- setCursiveFontFamily("Kaiti SC", USCRIPT_SIMPLIFIED_HAN); >- > setStandardFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- setFixedFontFamily(osakaMonoIsInstalled() ? "Osaka-Mono" : "Hiragino Sans", USCRIPT_KATAKANA_OR_HIRAGANA); >- setSerifFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- setSansSerifFontFamily("Hiragino Kaku Gothic ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- > setStandardFontFamily("AppleMyungjo", USCRIPT_HANGUL); >- setSerifFontFamily("AppleMyungjo", USCRIPT_HANGUL); >- setFixedFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL); >- setSansSerifFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL); > > setStandardFontFamily("Times", USCRIPT_COMMON); > setFixedFontFamily("Courier", USCRIPT_COMMON); >@@ -99,28 +70,10 @@ bool SettingsBase::platformDefaultMediaSourceEnabled() > > void SettingsBase::initializeDefaultFontFamilies() > { >- // There is no serif Chinese font in default iOS installation. > setStandardFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN); >- setSerifFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN); >- setFixedFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN); >- setSansSerifFontFamily(sansSerifTraditionalHanFontFamily(), USCRIPT_TRADITIONAL_HAN); >- >- // There is no serif Chinese font in default iOS installation. > setStandardFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN); >- setSerifFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN); >- setFixedFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN); >- setSansSerifFontFamily(sansSerifSimplifiedHanFontFamily(), USCRIPT_SIMPLIFIED_HAN); >- > setStandardFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- setFixedFontFamily("Hiragino Kaku Gothic ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- setSerifFontFamily("Hiragino Mincho ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- setSansSerifFontFamily("Hiragino Kaku Gothic ProN", USCRIPT_KATAKANA_OR_HIRAGANA); >- >- // There is no serif Korean font in default iOS installation. > setStandardFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL); >- setSerifFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL); >- setFixedFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL); >- setSansSerifFontFamily("Apple SD Gothic Neo", USCRIPT_HANGUL); > > setStandardFontFamily("Times", USCRIPT_COMMON); > setFixedFontFamily("Courier", USCRIPT_COMMON); >diff --git a/Source/WebCore/platform/graphics/FontDescription.cpp b/Source/WebCore/platform/graphics/FontDescription.cpp >index df590bb2c08c5463820c7558dbf609bbd7258522..b8b46e775cd91b1c6fee68c142298450ec2d60cf 100644 >--- a/Source/WebCore/platform/graphics/FontDescription.cpp >+++ b/Source/WebCore/platform/graphics/FontDescription.cpp >@@ -71,4 +71,11 @@ void FontDescription::setLocale(const AtomicString& locale) > m_script = localeToScriptCodeForFontSelection(m_locale); > } > >+#if !PLATFORM(COCOA) >+AtomicString FontDescription::platformResolveGenericFamily(UScriptCode, const AtomicString&, const AtomicString&) >+{ >+ return nullAtom(); >+} >+#endif >+ > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/FontDescription.h b/Source/WebCore/platform/graphics/FontDescription.h >index 99bd407f5fa6c960bf8b9b649c89662d22f3912a..cb05cf5aeb9557851b4f309be6edb4ce6328d05f 100644 >--- a/Source/WebCore/platform/graphics/FontDescription.h >+++ b/Source/WebCore/platform/graphics/FontDescription.h >@@ -133,6 +133,8 @@ public: > void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; } > void setShouldAllowUserInstalledFonts(AllowUserInstalledFonts shouldAllowUserInstalledFonts) { m_shouldAllowUserInstalledFonts = static_cast<unsigned>(shouldAllowUserInstalledFonts); } > >+ static AtomicString platformResolveGenericFamily(UScriptCode, const AtomicString& locale, const AtomicString& familyName); >+ > private: > // FIXME: Investigate moving these into their own object on the heap (to save memory). > FontFeatureSettings m_featureSettings; >diff --git a/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp b/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp >index 8a3309dbee70de03f9c5493a1f9598434a254f01..8e92f6c13d62f4225e9a840ac3a36c299b753b13 100644 >--- a/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp >+++ b/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp >@@ -27,6 +27,8 @@ > #include "FontDescription.h" > > #include "SystemFontDatabaseCoreText.h" >+#include <mutex> >+#include <wtf/Language.h> > > #if USE_PLATFORM_SYSTEM_FALLBACK_LIST > >@@ -138,6 +140,54 @@ FontFamilySpecification FontCascadeDescription::effectiveFamilyAt(unsigned index > return nullAtom(); > } > >+static String computeSpecializedChineseLocale() >+{ >+ const Vector<String>& preferredLanguages = userPreferredLanguages(); >+ for (auto& language : preferredLanguages) { >+ if (equalIgnoringASCIICase(language, "zh") || startsWithLettersIgnoringASCIICase(language, "zh-")) >+ return language; >+ } >+ return "zh-hans"_str; // We have no signal. Pick one option arbitrarily. >+} >+ >+static String& cachedSpecializedChineseLocale() >+{ >+ static NeverDestroyed<String> specializedChineseLocale; >+ return specializedChineseLocale.get(); >+} >+ >+static void languageChanged(void*) >+{ >+ cachedSpecializedChineseLocale() = computeSpecializedChineseLocale(); >+} >+ >+AtomicString FontDescription::platformResolveGenericFamily(UScriptCode script, const AtomicString& locale, const AtomicString& familyName) >+{ >+ if (script == USCRIPT_COMMON) >+ return nullAtom(); >+ >+ static std::once_flag onceFlag; >+ std::call_once(onceFlag, [&] { >+ addLanguageChangeObserver(const_cast<AtomicString*>(&locale), &languageChanged); // We will never remove the observer, so all we need is a non-null pointer. >+ languageChanged(nullptr); >+ }); >+ >+ auto& usedLocale = script == USCRIPT_HAN ? cachedSpecializedChineseLocale() : locale.string(); >+ >+ if (familyName == serifFamily) >+ return SystemFontDatabaseCoreText::singleton().serifFamily(usedLocale); >+ if (familyName == sansSerifFamily) >+ return SystemFontDatabaseCoreText::singleton().sansSerifFamily(usedLocale); >+ if (familyName == cursiveFamily) >+ return SystemFontDatabaseCoreText::singleton().cursiveFamily(usedLocale); >+ if (familyName == fantasyFamily) >+ return SystemFontDatabaseCoreText::singleton().fantasyFamily(usedLocale); >+ if (familyName == monospaceFamily) >+ return SystemFontDatabaseCoreText::singleton().monospaceFamily(usedLocale); >+ >+ return nullAtom(); >+} >+ > } > > #endif >diff --git a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp >index b4a396d058bd5937ac6569606dd4c420f6b4851c..4720a84b74166dfbd672cc1729b7144cd82f69b6 100644 >--- a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp >+++ b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp >@@ -80,6 +80,11 @@ Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(c > void SystemFontDatabaseCoreText::clear() > { > m_systemFontCache.clear(); >+ m_serifFamilies.clear(); >+ m_sansSeriferifFamilies.clear(); >+ m_cursiveFamilies.clear(); >+ m_fantasyFamilies.clear(); >+ m_monospaceFamilies.clear(); > } > > RetainPtr<CTFontRef> SystemFontDatabaseCoreText::applyWeightItalicsAndFallbackBehavior(CTFontRef font, CGFloat weight, bool italic, float size, AllowUserInstalledFonts allowUserInstalledFonts) >@@ -172,6 +177,56 @@ Vector<RetainPtr<CTFontDescriptorRef>> SystemFontDatabaseCoreText::cascadeList(c > return cascadeList(systemFontParameters(description, cssFamily, clientUse, allowUserInstalledFonts), clientUse); > } > >+String SystemFontDatabaseCoreText::serifFamily(const String& locale) >+{ >+ return m_serifFamilies.ensure(locale, [&] { >+ auto descriptor = adoptCF(CTFontDescriptorCreateForCSSFamily(kCTFontCSSFamilySerif, locale.createCFString().get())); >+ return adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontFamilyNameAttribute))).get(); >+ }).iterator->value; >+} >+ >+String SystemFontDatabaseCoreText::sansSerifFamily(const String& locale) >+{ >+ return m_sansSeriferifFamilies.ensure(locale, [&] { >+ auto descriptor = adoptCF(CTFontDescriptorCreateForCSSFamily(kCTFontCSSFamilySansSerif, locale.createCFString().get())); >+ return adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontFamilyNameAttribute))).get(); >+ }).iterator->value; >+} >+ >+String SystemFontDatabaseCoreText::cursiveFamily(const String& locale) >+{ >+ return m_cursiveFamilies.ensure(locale, [&] { >+ auto descriptor = adoptCF(CTFontDescriptorCreateForCSSFamily(kCTFontCSSFamilyCursive, locale.createCFString().get())); >+ return adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontFamilyNameAttribute))).get(); >+ }).iterator->value; >+} >+ >+String SystemFontDatabaseCoreText::fantasyFamily(const String& locale) >+{ >+ return m_fantasyFamilies.ensure(locale, [&] { >+ auto descriptor = adoptCF(CTFontDescriptorCreateForCSSFamily(kCTFontCSSFamilyFantasy, locale.createCFString().get())); >+ return adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontFamilyNameAttribute))).get(); >+ }).iterator->value; >+} >+ >+String SystemFontDatabaseCoreText::monospaceFamily(const String& locale) >+{ >+ return m_monospaceFamilies.ensure(locale, [&] { >+ auto descriptor = adoptCF(CTFontDescriptorCreateForCSSFamily(kCTFontCSSFamilyMonospace, locale.createCFString().get())); >+ String result = adoptCF(static_cast<CFStringRef>(CTFontDescriptorCopyAttribute(descriptor.get(), kCTFontFamilyNameAttribute))).get(); >+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 >+ // In general, CoreText uses Monaco for monospaced (see: Terminal.app and Xcode.app). >+ // For now, we want to use Courier for web compatibility, until we have more time to do compatibility testing. >+ if (equalLettersIgnoringASCIICase(result, "monaco")) >+ return "Courier"_str; >+#elif PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 >+ if (equalLettersIgnoringASCIICase(result, "courier new")) >+ return "Courier"_str; >+#endif >+ return result; >+ }).iterator->value; >+} >+ > } > > #endif >diff --git a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h >index 8359a4104aa50febb212fbc3209dfa873ce648d4..8c76a4f46e8609748512a81efa2b7f646169a459 100644 >--- a/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h >+++ b/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h >@@ -101,6 +101,13 @@ public: > enum class ClientUse { ForSystemUI, ForTextStyle }; > > Vector<RetainPtr<CTFontDescriptorRef>> cascadeList(const FontCascadeDescription&, const AtomicString& cssFamily, ClientUse, AllowUserInstalledFonts); >+ >+ String serifFamily(const String& locale); >+ String sansSerifFamily(const String& locale); >+ String cursiveFamily(const String& locale); >+ String fantasyFamily(const String& locale); >+ String monospaceFamily(const String& locale); >+ > void clear(); > > private: >@@ -114,6 +121,12 @@ private: > static CascadeListParameters systemFontParameters(const FontCascadeDescription&, const AtomicString& familyName, ClientUse, AllowUserInstalledFonts); > > HashMap<CascadeListParameters, Vector<RetainPtr<CTFontDescriptorRef>>, CascadeListParameters::CascadeListParametersHash, SimpleClassHashTraits<CascadeListParameters>> m_systemFontCache; >+ >+ HashMap<String, String> m_serifFamilies; >+ HashMap<String, String> m_sansSeriferifFamilies; >+ HashMap<String, String> m_cursiveFamilies; >+ HashMap<String, String> m_fantasyFamilies; >+ HashMap<String, String> m_monospaceFamilies; > }; > > } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 4bc80bd7b8f0088436f2fdc505bec002ebda6374..d741ddfced20f6c005e4c6bb7b10f50b1cfa38f1 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,18 @@ >+2019-02-04 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [Cocoa] Ask platform for generic font family mappings >+ https://bugs.webkit.org/show_bug.cgi?id=187723 >+ <rdar://problem/41892438> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Allow testing infrastructure to use fonts that are returned from CTFontDescriptorCreateForCSSFamily(). >+ >+ * DumpRenderTree/mac/DumpRenderTree.mm: >+ (allowedFontFamilySet): >+ * WebKitTestRunner/mac/TestControllerMac.mm: >+ (WTR::allowedFontFamilySet): >+ > 2019-02-01 Chris Dumez <cdumez@apple.com> > > REGRESSION: Flaky ASSERTION FAILED: m_uncommittedState.state == State::Committed on http/tests/cookies/same-site/fetch-after-top-level-navigation-initiated-from-iframe-in-cross-origin-page.html >diff --git a/Tools/DumpRenderTree/mac/DumpRenderTree.mm b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >index 255be2d6e02481c1ddfd667b399d39c4fc76cbf3..b052412b0fc3d1b9a9df1340f2f56cf8394bcf6a 100644 >--- a/Tools/DumpRenderTree/mac/DumpRenderTree.mm >+++ b/Tools/DumpRenderTree/mac/DumpRenderTree.mm >@@ -377,6 +377,7 @@ static NSSet *allowedFontFamilySet() > @"Hiragino Maru Gothic ProN", > @"Hiragino Mincho Pro", > @"Hiragino Mincho ProN", >+ @"Hiragino Sans", > @"Hiragino Sans GB", > @"Hoefler Text", > @"Impact", >@@ -386,6 +387,7 @@ static NSSet *allowedFontFamilySet() > @"Kokonor", > @"Krungthep", > @"KufiStandardGK", >+ @"Lao Sangam MN", > @"LastResort", > @"LiHei Pro", > @"LiSong Pro", >@@ -403,11 +405,15 @@ static NSSet *allowedFontFamilySet() > @"Papyrus", > @"PCMyungjo", > @"PilGi", >+ @"PingFang HK", >+ @"PingFang SC", >+ @"PingFang TC", > @"Plantagenet Cherokee", > @"Raanana", > @"Sathu", > @"Silom", > @"Skia", >+ @"Snell Roundhand", > @"Songti SC", > @"Songti TC", > @"STFangsong", >diff --git a/Tools/WebKitTestRunner/mac/TestControllerMac.mm b/Tools/WebKitTestRunner/mac/TestControllerMac.mm >index 583eed4f1968a7f58a003dff4d91b16e9691d6e5..000535cc2056031b85cb7a31dc65602277c05707 100644 >--- a/Tools/WebKitTestRunner/mac/TestControllerMac.mm >+++ b/Tools/WebKitTestRunner/mac/TestControllerMac.mm >@@ -222,6 +222,7 @@ static NSSet *allowedFontFamilySet() > @"Hiragino Maru Gothic ProN", > @"Hiragino Mincho Pro", > @"Hiragino Mincho ProN", >+ @"Hiragino Sans", > @"Hiragino Sans GB", > @"Hoefler Text", > @"Impact", >@@ -231,6 +232,7 @@ static NSSet *allowedFontFamilySet() > @"Kokonor", > @"Krungthep", > @"KufiStandardGK", >+ @"Lao Sangam MN", > @"LastResort", > @"LiHei Pro", > @"LiSong Pro", >@@ -248,11 +250,15 @@ static NSSet *allowedFontFamilySet() > @"Papyrus", > @"PCMyungjo", > @"PilGi", >+ @"PingFang HK", >+ @"PingFang SC", >+ @"PingFang TC", > @"Plantagenet Cherokee", > @"Raanana", > @"Sathu", > @"Silom", > @"Skia", >+ @"Snell Roundhand", > @"Songti SC", > @"Songti TC", > @"STFangsong", >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 395610b7ad685471edb317b14b82467a1fea5b41..0b9d2e9b2dc839de171ca3ad8216fb7051fbead8 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,25 @@ >+2019-02-04 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ [Cocoa] Ask platform for generic font family mappings >+ https://bugs.webkit.org/show_bug.cgi?id=187723 >+ <rdar://problem/41892438> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update the tests to work with this new model. >+ >+ * fast/text/international/font-fallback-to-common-script-expected.html: Removed. >+ * fast/text/international/font-fallback-to-common-script.html: Removed. This test is no longer testing >+ anything relevant. >+ * fast/text/international/lang-sensitive-fonts-expected.html: >+ * fast/text/international/lang-sensitive-fonts-xml-expected.html: >+ * fast/text/international/lang-sensitive-fonts-xml.xhtml: >+ * fast/text/international/lang-sensitive-fonts.html: >+ * fast/text/international/locale-sensitive-fonts-expected.html: >+ * fast/text/international/locale-sensitive-fonts.html: >+ * fast/text/ja-sans-serif-expected-mismatch.html: Added. >+ * fast/text/ja-sans-serif.html: Added. >+ > 2019-02-01 Antoine Quint <graouts@apple.com> > > Dispatch pointercancel events when content is panned or zoomed on iOS >diff --git a/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html b/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html >deleted file mode 100644 >index 02e21c4b2a506d7f629f81441a726ca2179a4d5d..0000000000000000000000000000000000000000 >--- a/LayoutTests/fast/text/international/font-fallback-to-common-script-expected.html >+++ /dev/null >@@ -1,8 +0,0 @@ >-<html> >-<body> >-<div style="font-size: 20px"> >-<div style="font-family: 'Ahem'">this is ahem font</div> >-<div style="font-family: 'Ahem'">this is ahem font</div> >-</div> >-</body> >-</html> >diff --git a/LayoutTests/fast/text/international/font-fallback-to-common-script.html b/LayoutTests/fast/text/international/font-fallback-to-common-script.html >deleted file mode 100644 >index e78a435c4e8f852bed4829b62e226a4fccb4e981..0000000000000000000000000000000000000000 >--- a/LayoutTests/fast/text/international/font-fallback-to-common-script.html >+++ /dev/null >@@ -1,26 +0,0 @@ >-<!DOCTYPE html> >-<html> >-<head> >-<script> >-if (window.internals) { >- window.internals.settings.setStandardFontFamily("Times", "Hans"); >- window.internals.settings.setStandardFontFamily("", "Hans"); >- window.internals.settings.setStandardFontFamily("Ahem", "Zyyy"); >- >- window.internals.settings.setSansSerifFontFamily("Ahem", "Zyyy"); >- >- window.internals.setUserPreferredLanguages("en", "zh-cn"); >-} >-</script> >-</head> >-<body> >-<!-- Test for font fallback to the common script when the per-script font setting is missing or the empty string. >-Bug 81329 <https://bugs.webkit.org/show_bug.cgi?id=81329> --> >-<div style="font-size: 20px"> >-<div lang="zh-CN">this is ahem font</div> >- >-<!-- Test fallback to common script when no setting is set. This assumes there is no setting for "Zxxx" (script code for unwritten languages). --> >-<div lang="und-Zxxx" style="font-family: sans-serif;">this is ahem font</div> >-</div> >-</body> >-</html> >diff --git a/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html b/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html >index 0060d2388ac637d6ba88a5ea4b3a24baed911483..7742f2fa81a1881fdb095ad21c43d0c0b3c70594 100644 >--- a/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html >+++ b/LayoutTests/fast/text/international/lang-sensitive-fonts-expected.html >@@ -4,7 +4,6 @@ > <div style="font-family: 'Ahem'">this is ahem font</div> > <div style="font-family: 'Ahem'">this is ahem font</div> > <div style="font-family: 'Ahem'">this is ahem font</div> >-<div style="font-family: 'Ahem'">this is ahem font</div> > <div>this is not ahem font</div> > </div> > </body> >diff --git a/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html b/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html >index 66159b48f896c921cca0e6ea9650032a712344dd..38ae2790fc667c043c3c0c039b078daf8ee0cdf6 100644 >--- a/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html >+++ b/LayoutTests/fast/text/international/lang-sensitive-fonts-xml-expected.html >@@ -5,7 +5,6 @@ > <div>this is ahem font</div> > <div>this is ahem font</div> > <div>this is ahem font</div> >-<div>this is ahem font</div> > </div> > </body> > </html> >diff --git a/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml b/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml >index 17c070805f0ab294671e1e3326f5bc125469e616..e7a874e4a93a6ec07045d571ae83678bceac2f30 100644 >--- a/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml >+++ b/LayoutTests/fast/text/international/lang-sensitive-fonts-xml.xhtml >@@ -21,14 +21,10 @@ font. > <div style="font-family: 'Ahem'">this is ahem font</div> > <div lang="zh-CN">this is ahem font</div> > <div id="target1" lang="ar">this is ahem font</div> >-<div id="target2" lang="ar" style="font-family: sans-serif">this is ahem font</div> > <div xml:lang="zh-CN">this is ahem font</div> > </div> > <script> > document.getElementById("target1").lang = "zh-CN"; >- >-document.getElementById("target2").lang = "zh-CN"; >-document.getElementById("target2").style.fontFamily = "fantasy"; > </script> > </body> > </html> >diff --git a/LayoutTests/fast/text/international/lang-sensitive-fonts.html b/LayoutTests/fast/text/international/lang-sensitive-fonts.html >index c7edd1c29b416be7cef4714b20939629e68b6583..92e832ee743a2e482163f0eaed3526a4ae0f2ddc 100644 >--- a/LayoutTests/fast/text/international/lang-sensitive-fonts.html >+++ b/LayoutTests/fast/text/international/lang-sensitive-fonts.html >@@ -20,14 +20,10 @@ font, except for the final div as xml:lang should be ignored in HTML. > <div style="font-family: 'Ahem'">this is ahem font</div> > <div lang="zh-CN">this is ahem font</div> > <div id="target1" lang="ar">this is ahem font</div> >-<div id="target2" lang="ar" style="font-family: sans-serif">this is ahem font</div> > <div xml:lang="zh-CN">this is not ahem font</div> > </div> > <script> > document.getElementById("target1").lang = "zh-CN"; >- >-document.getElementById("target2").lang = "zh-CN"; >-document.getElementById("target2").style.fontFamily = "fantasy"; > </script> > </body> > </html> >diff --git a/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html b/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html >index 64f91893b862248676e765f1e92bf72ad8fcbb7e..0810b6b1571df4760c7065a672a98330a232b4e3 100644 >--- a/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html >+++ b/LayoutTests/fast/text/international/locale-sensitive-fonts-expected.html >@@ -6,7 +6,6 @@ > <div style="font-size: 20px"> > <div style="font-family: 'Ahem'">this is ahem font</div> > <div style="font-family: 'Ahem'">this is ahem font</div> >-<div style="font-family: 'Ahem'">this is ahem font</div> > </div> > </body> > </html> >diff --git a/LayoutTests/fast/text/international/locale-sensitive-fonts.html b/LayoutTests/fast/text/international/locale-sensitive-fonts.html >index 4b40de485a74fc682843988d401d2c079b882237..66016a89e4687f4fd731ba26ab3c7e1d4fd13f0c 100644 >--- a/LayoutTests/fast/text/international/locale-sensitive-fonts.html >+++ b/LayoutTests/fast/text/international/locale-sensitive-fonts.html >@@ -16,7 +16,6 @@ fonts for Simplified Han are to Ahem font. So all divs should match. --> > <div style="font-size: 20px"> > <div style="font-family: 'Ahem'">this is ahem font</div> > <div style="-webkit-locale: 'zh_CN'">this is ahem font</div> >-<div style="-webkit-locale: 'zh_CN'; font-family: fantasy">this is ahem font</div> > </div> > </body> > </html> >diff --git a/LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html b/LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html >new file mode 100644 >index 0000000000000000000000000000000000000000..0b52aa73f0d9454a5a503778c156dc4072d5184b >--- /dev/null >+++ b/LayoutTests/fast/text/ja-sans-serif-expected-mismatch.html >@@ -0,0 +1,9 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset="utf-8"> >+</head> >+<body> >+<div lang="ja" style="font: 48px serif;">ãããããªã·</div> >+</body> >+</html> >diff --git a/LayoutTests/fast/text/ja-sans-serif.html b/LayoutTests/fast/text/ja-sans-serif.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b675fd9a249148296bbaf9f667c7ad32e4f18d7c >--- /dev/null >+++ b/LayoutTests/fast/text/ja-sans-serif.html >@@ -0,0 +1,9 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<meta charset="utf-8"> >+</head> >+<body> >+<div lang="ja" style="font: 48px sans-serif;">ãããããªã·</div> >+</body> >+</html> >diff --git a/LayoutTests/platform/ios/fast/block/float/016-expected.txt b/LayoutTests/platform/ios/fast/block/float/016-expected.txt >index 6b9eeac9911dc736ff29ae3aac422c9d79581691..14704bf7014eb49fcc943f1b0d54cd2f4dd560b7 100644 >--- a/LayoutTests/platform/ios/fast/block/float/016-expected.txt >+++ b/LayoutTests/platform/ios/fast/block/float/016-expected.txt >@@ -1,8 +1,8 @@ > layer at (0,0) size 800x600 > RenderView at (0,0) size 800x600 >-layer at (0,0) size 800x511 >- RenderBlock {HTML} at (0,0) size 800x512 >- RenderBody {BODY} at (8,8) size 784x488 >+layer at (0,0) size 800x512 >+ RenderBlock {HTML} at (0,0) size 800x513 >+ RenderBody {BODY} at (8,8) size 784x489 > RenderBlock {UL} at (185,0) size 414x192 > RenderListItem {LI} at (0,48) size 284x72 > RenderBlock {A} at (123,0) size 161x139 [color=#CCCCCC] >@@ -62,6 +62,6 @@ layer at (0,0) size 800x511 > RenderBlock {SPAN} at (8,61) size 144x21 [color=#000000] > RenderText {#text} at (59,0) size 26x20 > text run at (59,0) width 26: "exit" >- RenderBlock {P} at (0,403) size 784x85 >- RenderText {#text} at (327,32) size 130x19 >- text run at (327,32) width 130: "Ceci n'est pas Flash." >+ RenderBlock {P} at (0,403) size 784x86 >+ RenderText {#text} at (331,32) size 122x21 >+ text run at (331,32) width 122: "Ceci n'est pas Flash."
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
bfulgham
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 187723
:
345137
|
345200
|
345277
|
345301
|
346259
|
346260
|
346264
|
360532
|
360536
|
360538
|
360539
|
360540
|
360610
|
360624
|
360628
|
360631
|
360633
|
360654
|
360664
|
360665
|
360671
|
360679
|
360887
|
360901
|
360905
|
360909
|
360911
|
360917
|
360924
|
360932
|
360935
|
360968
|
360982
|
360985
|
360987
| 361078 |
361580
|
361737
|
361738