WebKit Bugzilla
Attachment 362591 Details for
Bug 194895
: Incorrect use of String::foldCase for font family names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194895-20190220215212.patch (text/plain), 6.52 KB, created by
Darin Adler
on 2019-02-20 21:52:13 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2019-02-20 21:52:13 PST
Size:
6.52 KB
patch
obsolete
>Subversion Revision: 241860 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 26277ea5e6422ed0ab34dfff421fa7cbc3266123..715cfabac42dac16a09241212fdcd17edb451b97 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,33 @@ >+2019-02-20 Darin Adler <darin@apple.com> >+ >+ Incorrect use of String::foldCase for font family names >+ https://bugs.webkit.org/show_bug.cgi?id=194895 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/graphics/FontCascadeDescription.cpp: >+ (WebCore::FontCascadeDescription::familiesEqualForTextAutoSizing): Use >+ familyNamesAreEqual instead of calling convertToASCIILowercase directly. >+ (WebCore::FontCascadeDescription::familyNamesAreEqual): Use AtomicString's >+ operator== when we want case sensitive family name comparisons. This is a special >+ case to accomodate CoreText, which uses "."-prefix names for internal fonts that >+ are treated case sensitively. (Ideally webpages would not use these fonts at all.) >+ (WebCore::FontCascadeDescription::familyNameHash): Use AtomicString's existingHash >+ when we want case sensitive family name hashing. >+ (WebCore::FontCascadeDescription::foldedFamilyName): Take a String instead of an >+ AtomicString so we can use this at an additional call site. Converting from an >+ AtomicString to a String if free and automatic at the existing call sites. Use >+ convertToASCIILowercase instead of foldCase for three reasons: 1) Other functions >+ here are folding only ASCII case by using ASCIICaseInsensitiveHash, and this one >+ must be consistent. 2) this is considerably faster, and 3) font family names don't >+ need arbitrary Unicode case folding, it's only A-Z that should be folded. >+ * platform/graphics/FontCascadeDescription.h: Take a String instead of AtomicString >+ in the foldedFamilyName function. >+ >+ * platform/graphics/cocoa/FontCacheCoreText.cpp: >+ (WebCore::FontDatabase::collectionForFamily): Instead of calling foldCase, use >+ FontCascadeDescription::foldedFamilyName to correctly fold font family names. >+ > 2019-02-20 Simon Fraser <simon.fraser@apple.com> > > REGRESSION (240698): Fixed position banners flicker and move when scrolling on iOS >diff --git a/Source/WebCore/platform/graphics/FontCascadeDescription.cpp b/Source/WebCore/platform/graphics/FontCascadeDescription.cpp >index f75547af48d6613b29e5c879ce69ab11b6d66dd4..3fc96bff9cdf3a57047d73180cdd931d3a8733d0 100644 >--- a/Source/WebCore/platform/graphics/FontCascadeDescription.cpp >+++ b/Source/WebCore/platform/graphics/FontCascadeDescription.cpp >@@ -63,6 +63,7 @@ FontCascadeDescription::FontCascadeDescription() > } > > #if !USE_PLATFORM_SYSTEM_FALLBACK_LIST >+ > unsigned FontCascadeDescription::effectiveFamilyCount() const > { > return familyCount(); >@@ -72,6 +73,7 @@ FontFamilySpecification FontCascadeDescription::effectiveFamilyAt(unsigned i) co > { > return familyAt(i); > } >+ > #endif > > FontSelectionValue FontCascadeDescription::lighterWeight(FontSelectionValue weight) >@@ -107,7 +109,7 @@ bool FontCascadeDescription::familiesEqualForTextAutoSizing(const FontCascadeDes > return false; > > for (unsigned i = 0; i < thisFamilyCount; ++i) { >- if (!equalIgnoringASCIICase(familyAt(i), other.familyAt(i))) >+ if (!familyNamesAreEqual(familyAt(i), other.familyAt(i))) > return false; > } > >@@ -118,29 +120,29 @@ bool FontCascadeDescription::familiesEqualForTextAutoSizing(const FontCascadeDes > > 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 PLATFORM(COCOA) > if (family1.startsWith('.')) >- return StringHash::equal(family1.string(), family2.string()); >+ return family1 == family2; >+#endif > 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 PLATFORM(COCOA) > if (family.startsWith('.')) >- return StringHash::hash(family.string()); >+ return family.existingHash(); >+#endif > return ASCIICaseInsensitiveHash::hash(family); > } > >-String FontCascadeDescription::foldedFamilyName(const AtomicString& family) >+String FontCascadeDescription::foldedFamilyName(const String& 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 PLATFORM(COCOA) > if (family.startsWith('.')) >- return family.string(); >- return family.string().foldCase(); >+ return family; >+#endif >+ return family.convertToASCIILowercase(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/platform/graphics/FontCascadeDescription.h b/Source/WebCore/platform/graphics/FontCascadeDescription.h >index 6fa8330db44330b38f993892584c45d6ec64da91..0d51c5a1819549b42f4563842c562b1561c9abda 100644 >--- a/Source/WebCore/platform/graphics/FontCascadeDescription.h >+++ b/Source/WebCore/platform/graphics/FontCascadeDescription.h >@@ -59,7 +59,7 @@ public: > > static bool familyNamesAreEqual(const AtomicString&, const AtomicString&); > static unsigned familyNameHash(const AtomicString&); >- static String foldedFamilyName(const AtomicString&); >+ static String foldedFamilyName(const String&); > > unsigned effectiveFamilyCount() const; > FontFamilySpecification effectiveFamilyAt(unsigned) const; >diff --git a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp b/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp >index 528528425b674f8afba311ced16e75f06284fc71..5778125c6c8700ffb3452d0660a6d85081d9ce81 100644 >--- a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp >+++ b/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp >@@ -887,7 +887,7 @@ public: > > const InstalledFontFamily& collectionForFamily(const String& familyName) > { >- auto folded = familyName.foldCase(); >+ auto folded = FontCascadeDescription::foldedFamilyName(familyName); > { > std::lock_guard<Lock> locker(m_familyNameToFontDescriptorsLock); > auto it = m_familyNameToFontDescriptors.find(folded);
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:
mmaxfield
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194895
:
362589
| 362591