- Revision
- 220009
- Author
- mmaxfi...@apple.com
- Date
- 2017-07-28 11:36:37 -0700 (Fri, 28 Jul 2017)
Log Message
[macOS] Reeder's defaults font is Times instead of San Francisco
https://bugs.webkit.org/show_bug.cgi?id=174885
<rdar://problem/33462483>
Reviewed by Simon Fraser.
Source/WebCore:
Reeder uses explicit dot-prefixed names in its source code. Within Core Text,
dot-prefixed names cannot be matched case insensitively. The solution is to
not case-fold these family names, and to make our caches case sensitive for
these special names.
Tests: fast/text/font-lookup-dot-prefix-case-sensitive-2.html
fast/text/font-lookup-dot-prefix-case-sensitive.html
* platform/graphics/FontCache.cpp:
(WebCore::FontPlatformDataCacheKey::operator==):
(WebCore::FontPlatformDataCacheKeyHash::hash):
* platform/graphics/FontCascade.cpp:
(WebCore::keysMatch):
(WebCore::computeFontCascadeCacheHash):
* platform/graphics/FontDescription.cpp:
(WebCore::FontCascadeDescription::familyNamesAreEqual):
(WebCore::FontCascadeDescription::familyNameHash):
(WebCore::FontCascadeDescription::foldedFamilyName):
* platform/graphics/FontDescription.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontDatabase::fontForPostScriptName):
LayoutTests:
* fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html: Added.
* fast/text/font-lookup-dot-prefix-case-sensitive-2.html: Added.
* fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html: Added.
* fast/text/font-lookup-dot-prefix-case-sensitive.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (220008 => 220009)
--- trunk/LayoutTests/ChangeLog 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/LayoutTests/ChangeLog 2017-07-28 18:36:37 UTC (rev 220009)
@@ -1,3 +1,16 @@
+2017-07-28 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [macOS] Reeder's defaults font is Times instead of San Francisco
+ https://bugs.webkit.org/show_bug.cgi?id=174885
+ <rdar://problem/33462483>
+
+ Reviewed by Simon Fraser.
+
+ * fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html: Added.
+ * fast/text/font-lookup-dot-prefix-case-sensitive-2.html: Added.
+ * fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html: Added.
+ * fast/text/font-lookup-dot-prefix-case-sensitive.html: Added.
+
2017-07-28 Devin Rousso <drou...@apple.com>
Web Inspector: Record actions performed on CanvasRenderingContext2D
Added: trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html (0 => 220009)
--- trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-2-expected.html 2017-07-28 18:36:37 UTC (rev 220009)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+ internals.invalidateFontCache();
+</script>
+</head>
+<body>
+<div style="font: 100px 'Times';">Hello</div>
+<div style="font: 100px '.AppleSystemUIFontMedium';">Hello</div>
+</body>
+</html>
+
Added: trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-2.html (0 => 220009)
--- trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-2.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-2.html 2017-07-28 18:36:37 UTC (rev 220009)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+ internals.invalidateFontCache();
+</script>
+</head>
+<body>
+<div style="font: 100px '.apPLesysTemUiFontMEDium';">Hello</div>
+<div style="font: 100px '.AppleSystemUIFontMedium';">Hello</div>
+</body>
+</html>
+
Added: trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html (0 => 220009)
--- trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive-expected-mismatch.html 2017-07-28 18:36:37 UTC (rev 220009)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+ internals.invalidateFontCache();
+</script>
+</head>
+<body>
+<div style="font: 100px 'Times';">Hello</div>
+</body>
+</html>
+
Added: trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive.html (0 => 220009)
--- trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-lookup-dot-prefix-case-sensitive.html 2017-07-28 18:36:37 UTC (rev 220009)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+ internals.invalidateFontCache();
+</script>
+</head>
+<body>
+<div style="font: 100px '.AppleSystemUIFontMedium';">Hello</div>
+</body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (220008 => 220009)
--- trunk/Source/WebCore/ChangeLog 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/Source/WebCore/ChangeLog 2017-07-28 18:36:37 UTC (rev 220009)
@@ -1,3 +1,33 @@
+2017-07-28 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [macOS] Reeder's defaults font is Times instead of San Francisco
+ https://bugs.webkit.org/show_bug.cgi?id=174885
+ <rdar://problem/33462483>
+
+ Reviewed by Simon Fraser.
+
+ Reeder uses explicit dot-prefixed names in its source code. Within Core Text,
+ dot-prefixed names cannot be matched case insensitively. The solution is to
+ not case-fold these family names, and to make our caches case sensitive for
+ these special names.
+
+ Tests: fast/text/font-lookup-dot-prefix-case-sensitive-2.html
+ fast/text/font-lookup-dot-prefix-case-sensitive.html
+
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontPlatformDataCacheKey::operator==):
+ (WebCore::FontPlatformDataCacheKeyHash::hash):
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::keysMatch):
+ (WebCore::computeFontCascadeCacheHash):
+ * platform/graphics/FontDescription.cpp:
+ (WebCore::FontCascadeDescription::familyNamesAreEqual):
+ (WebCore::FontCascadeDescription::familyNameHash):
+ (WebCore::FontCascadeDescription::foldedFamilyName):
+ * platform/graphics/FontDescription.h:
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::FontDatabase::fontForPostScriptName):
+
2017-07-28 Devin Rousso <drou...@apple.com>
Web Inspector: Record actions performed on CanvasRenderingContext2D
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (220008 => 220009)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2017-07-28 18:36:37 UTC (rev 220009)
@@ -127,7 +127,7 @@
return true;
if (m_family.isNull() || other.m_family.isNull())
return false;
- return ASCIICaseInsensitiveHash::equal(m_family, other.m_family);
+ return FontCascadeDescription::familyNamesAreEqual(m_family, other.m_family);
}
FontDescriptionKey m_fontDescriptionKey;
@@ -141,7 +141,7 @@
static unsigned hash(const FontPlatformDataCacheKey& fontKey)
{
IntegerHasher hasher;
- hasher.add(ASCIICaseInsensitiveHash::hash(fontKey.m_family));
+ hasher.add(FontCascadeDescription::familyNameHash(fontKey.m_family));
hasher.add(fontKey.m_fontDescriptionKey.computeHash());
hasher.add(fontKey.m_fontFaceFeatures.hash());
hasher.add(fontKey.m_fontFaceVariantSettings.uniqueValue());
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (220008 => 220009)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2017-07-28 18:36:37 UTC (rev 220009)
@@ -185,7 +185,7 @@
if (size != b.families.size())
return false;
for (unsigned i = 0; i < size; ++i) {
- if (!equalIgnoringASCIICase(a.families[i], b.families[i]))
+ if (!FontCascadeDescription::familyNamesAreEqual(a.families[i], b.families[i]))
return false;
}
return true;
@@ -229,8 +229,8 @@
hasher.add(key.fontSelectorId);
hasher.add(key.fontSelectorVersion);
for (unsigned i = 0; i < key.families.size(); ++i) {
- StringImpl* family = key.families[i].impl();
- hasher.add(family ? ASCIICaseInsensitiveHash::hash(family) : 0);
+ auto& family = key.families[i];
+ hasher.add(family.isNull() ? 0 : FontCascadeDescription::familyNameHash(family));
}
return hasher.hash();
}
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.cpp (220008 => 220009)
--- trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2017-07-28 18:36:37 UTC (rev 220009)
@@ -31,6 +31,7 @@
#include "FontDescription.h"
#include "LocaleToScriptMapping.h"
+#include <wtf/text/StringHash.h>
namespace WebCore {
@@ -155,4 +156,31 @@
#endif // ENABLE(TEXT_AUTOSIZING)
+bool FontCascadeDescription::familyNamesAreEqual(const AtomicString& family1, const AtomicString& family2)
+{
+ // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
+ // always take the case insensitive patch once this radar is fixed.
+ if (family1.startsWith('.'))
+ return StringHash::equal(family1.string(), family2.string());
+ return ASCIICaseInsensitiveHash::equal(family1, family2);
+}
+
+unsigned FontCascadeDescription::familyNameHash(const AtomicString& family)
+{
+ // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
+ // always take the case insensitive patch once this radar is fixed.
+ if (family.startsWith('.'))
+ return StringHash::hash(family.string());
+ return ASCIICaseInsensitiveHash::hash(family);
+}
+
+String FontCascadeDescription::foldedFamilyName(const AtomicString& family)
+{
+ // FIXME: <rdar://problem/33594253> CoreText matches dot-prefixed font names case sensitively. We should
+ // always take the case insensitive patch once this radar is fixed.
+ if (family.startsWith('.'))
+ return family.string();
+ return family.string().foldCase();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (220008 => 220009)
--- trunk/Source/WebCore/platform/graphics/FontDescription.h 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h 2017-07-28 18:36:37 UTC (rev 220009)
@@ -232,6 +232,10 @@
const AtomicString& familyAt(unsigned i) const { return m_families[i]; }
const RefCountedArray<AtomicString>& families() const { return m_families; }
+ static bool familyNamesAreEqual(const AtomicString&, const AtomicString&);
+ static unsigned familyNameHash(const AtomicString&);
+ static String foldedFamilyName(const AtomicString&);
+
unsigned effectiveFamilyCount() const;
FontFamilySpecification effectiveFamilyAt(unsigned) const;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (220008 => 220009)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2017-07-28 18:22:17 UTC (rev 220008)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2017-07-28 18:36:37 UTC (rev 220009)
@@ -907,7 +907,7 @@
const InstalledFont& fontForPostScriptName(const AtomicString& postScriptName)
{
- auto folded = postScriptName.string().foldCase();
+ const auto& folded = FontCascadeDescription::foldedFamilyName(postScriptName);
return m_postScriptNameToFontDescriptors.ensure(folded, [&] {
auto postScriptNameString = folded.createCFString();
#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300)