Log Message
Replace CaseFoldingHash with ASCIICaseInsensitiveHash https://bugs.webkit.org/show_bug.cgi?id=153639
Reviewed by Filip Pizlo. Source/WebCore: * Modules/webdatabase/DatabaseAuthorizer.h: Use ASCIICaseInsensitiveHash for whitelisted functions. Function names are all ASCII. * accessibility/AccessibilityObject.cpp: Use ASCIICaseInsensitiveHash for ARIA roles. ARIA roles are all ASCII. * crypto/CryptoAlgorithmRegistry.h: Use ASCIICaseInsensitiveHash for crypto algorithm names. Algorithm names are all ASCII. * css/CSSFontSelector.cpp: (WebCore::registerLocalFontFacesForFamily): Use ASCIICaseInsensitiveHash for font faces. Face names should use ASCII case insensitive matching; there is no need for non-ASCII case folding. * css/CSSFontSelector.h: Ditto. * dom/DOMImplementation.cpp: Use ASCIICaseInsensitiveHash for the FeatureSet. The features are all ASCII. * dom/Document.h: Use ASCIICaseInsensitiveHash for the access key map. Access keys are all ASCII. * dom/ScriptElement.cpp: (WebCore::isLegacySupportedJavaScriptLanguage): Use ASCIICaseInsensitiveHash for the language set. These strings are all ASCII. * editing/EditorCommand.cpp: Use ASCIICaseInsensitiveHash for editor command names. These names are all ASCII. * html/HTMLObjectElement.cpp: (WebCore::HTMLObjectElement::parametersForPlugin): Use ASCIICaseInsensitiveHash for parameter names. These names are all ASCII. * html/InputType.cpp: Use ASCIICaseInsensitiveHash for the input types. The input types are all ASCII. * loader/CrossOriginAccessControl.h: Use ASCIICaseInsensitiveHash for HTTP header field names. These names are all ASCII. * loader/CrossOriginPreflightResultCache.h: Ditto. * loader/archive/ArchiveFactory.cpp: Use ASCIICaseInsensitiveHash for MIME types. MIME types are all ASCII. * platform/MIMETypeRegistry.cpp: (WebCore::initializeSupportedImageMIMETypes): Ditto. * platform/SchemeRegistry.h: Use ASCIICaseInsensitiveHas for URL schemes. URL schemes are all ASCII. * platform/URL.cpp: Ditto. * platform/graphics/FontCache.cpp: Reworked FontPlatformDataCacheKey struct: Made it a conventional struct with non-prefixed data members names. Removed the "==" operator since it was appropriate for hash table lookup but wasn't a true equality operator. Tightened the implementations of the constructors. (WebCore::FontPlatformDataCacheKeyHash::hash): Use ASCIICaseInsensitiveHash. (WebCore::FontPlatformDataCacheKeyHash::equal): Do the equality check here, not using the == operator. And use equalIgnoringASCIICase. (WebCore::FontPlatformDataCacheKeyTraits::isEmptyValue): Added this entire traits struct so we check empty values in a more efficient way. (WebCore::FontCache::getCachedFontPlatformData): Added comments and tweaked style in this function. * platform/graphics/FontCascade.cpp: (WebCore::keysMatch): Rename from operator== since this operation is not equality. Changed to equalIgnoringASCIICase and did a little streamlining. (WebCore::makeFontCascadeCacheKey): Use reserveInitialCapacity for slightly better memory use. (WebCore::computeFontCascadeCacheHash): Use IntegerHasher to make computing a hash more efficient by eliminating the overhead of building a vector and even possible heap allocation and deallocation. (WebCore::retrieveOrAddCachedFonts): Use keysMatch instead of ==. * platform/graphics/cocoa/FontCacheCoreText.cpp: Use ASCIICaseInsensitiveHash for font family names. These names should use ASCII case insensitive matching; there is no need for non-ASCII case folding. * platform/network/HTTPHeaderMap.h: Use ASCIICaseInsensitiveHash for HTTP header field names. These names are all ASCII. * rendering/style/RenderStyle.cpp: (WebCore::computeFontHash): Use IntegerHasher to avoid allocating memory just to compute a hash. Use ASCIICaseInsensitiveHash. Source/WebKit/win: * WebCoreStatistics.cpp: (WebCoreStatistics::memoryStatistics): Use ASCIICaseInsensitiveHash for field names. These names are all ASCII. * WebURLResponse.cpp: (WebURLResponse::allHeaderFields): Use ASCIICaseInsensitiveHash for HTTP header field names. These names are all ASCII. Source/WebKit2: * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use ASCIICaseInsensitiveHash for MIME types. MIME types are all ASCII. * UIProcess/Plugins/PlugInAutoStartProvider.h: Use ASCIICaseInsensitiveHash for origins. Origin strings should use ASCII case insensitive matching and should not fold non-ASCII case. * WebProcess/WebPage/WebPage.h: Use ASCIICaseInsensitiveHash for MIME types. MIME types are all ASCII. * WebProcess/WebProcess.cpp: (WebKit::addCaseFoldedCharacters): Use ASCIICaseInsensitiveHash to hash plug-in origin strings. (See rationale above.) (WebKit::hashForPlugInOrigin): Updated comment. Source/WTF: * wtf/text/StringHash.h: Renamed CaseFoldingHash to ASCIICaseInsensitiveHash. (WTF::ASCIICaseInsensitiveHash::foldCase): Use toASCIILower. (WTF::ASCIICaseInsensitiveHash::equal): Use equalIgnoringASCIICase. Also added some assertions. * wtf/text/StringImpl.cpp: Made the latin1CaseFoldTable private to this file, since it's no longer needed by CaseFoldingHash. Moved it up before its first use. (WTF::equalCompatibilityCaseless): Fixed typo in the name of this function. (WTF::equalCompatibiltyCaselessNonNull): Deleted. * wtf/text/StringImpl.h: Removed declarations of latin1CaseFoldTable and equalCompatibiltyCaselessNonNull Tools: * Scripts/do-webcore-rename: Use script to do this rename.
Modified Paths
- trunk/Source/WTF/ChangeLog
- trunk/Source/WTF/wtf/text/StringHash.h
- trunk/Source/WTF/wtf/text/StringImpl.cpp
- trunk/Source/WTF/wtf/text/StringImpl.h
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/Modules/webdatabase/DatabaseAuthorizer.h
- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
- trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.h
- trunk/Source/WebCore/css/CSSFontSelector.cpp
- trunk/Source/WebCore/css/CSSFontSelector.h
- trunk/Source/WebCore/dom/DOMImplementation.cpp
- trunk/Source/WebCore/dom/Document.h
- trunk/Source/WebCore/dom/ScriptElement.cpp
- trunk/Source/WebCore/editing/EditorCommand.cpp
- trunk/Source/WebCore/html/HTMLObjectElement.cpp
- trunk/Source/WebCore/html/InputType.cpp
- trunk/Source/WebCore/loader/CrossOriginAccessControl.h
- trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h
- trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp
- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
- trunk/Source/WebCore/platform/SchemeRegistry.h
- trunk/Source/WebCore/platform/URL.cpp
- trunk/Source/WebCore/platform/graphics/FontCache.cpp
- trunk/Source/WebCore/platform/graphics/FontCascade.cpp
- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
- trunk/Source/WebCore/platform/network/HTTPHeaderMap.h
- trunk/Source/WebCore/rendering/style/RenderStyle.cpp
- trunk/Source/WebKit/win/ChangeLog
- trunk/Source/WebKit/win/WebCoreStatistics.cpp
- trunk/Source/WebKit/win/WebURLResponse.cpp
- trunk/Source/WebKit2/ChangeLog
- trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h
- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
- trunk/Source/WebKit2/WebProcess/WebProcess.cpp
- trunk/Tools/ChangeLog
- trunk/Tools/Scripts/do-webcore-rename
Diff
Modified: trunk/Source/WTF/ChangeLog (195910 => 195911)
--- trunk/Source/WTF/ChangeLog 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WTF/ChangeLog 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1,3 +1,23 @@
+2016-01-30 Darin Adler <[email protected]>
+
+ Replace CaseFoldingHash with ASCIICaseInsensitiveHash
+ https://bugs.webkit.org/show_bug.cgi?id=153639
+
+ Reviewed by Filip Pizlo.
+
+ * wtf/text/StringHash.h: Renamed CaseFoldingHash to ASCIICaseInsensitiveHash.
+ (WTF::ASCIICaseInsensitiveHash::foldCase): Use toASCIILower.
+ (WTF::ASCIICaseInsensitiveHash::equal): Use equalIgnoringASCIICase.
+ Also added some assertions.
+
+ * wtf/text/StringImpl.cpp: Made the latin1CaseFoldTable private to this file,
+ since it's no longer needed by CaseFoldingHash. Moved it up before its first use.
+ (WTF::equalCompatibilityCaseless): Fixed typo in the name of this function.
+ (WTF::equalCompatibiltyCaselessNonNull): Deleted.
+
+ * wtf/text/StringImpl.h: Removed declarations of latin1CaseFoldTable and
+ equalCompatibiltyCaselessNonNull
+
2016-01-29 Ada Chan <[email protected]>
Enable VIDEO_PRESENTATION_MODE only in Debug and Release builds on Mac
Modified: trunk/Source/WTF/wtf/text/StringHash.h (195910 => 195911)
--- trunk/Source/WTF/wtf/text/StringHash.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WTF/wtf/text/StringHash.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007, 2008, 2012, 2013 Apple Inc. All rights reserved
+ * Copyright (C) 2006-2008, 2012-2013, 2016 Apple Inc. All rights reserved
* Copyright (C) Research In Motion Limited 2009. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@
return value.isNull();
}
- // The hash() functions on StringHash and CaseFoldingHash do not support
+ // The hash() functions on StringHash and ASCIICaseInsensitiveHash do not support
// null strings. get(), contains(), and add() on HashMap<String,..., StringHash>
// cause a null-pointer dereference when passed null strings.
@@ -71,14 +71,11 @@
static const bool safeToCompareToEmptyOrDeleted = false;
};
- class CaseFoldingHash {
+ class ASCIICaseInsensitiveHash {
public:
template<typename T> static inline UChar foldCase(T character)
{
- if (std::is_same<T, LChar>::value)
- return StringImpl::latin1CaseFoldTable[character];
-
- return u_foldCase(character, U_FOLD_CASE_DEFAULT);
+ return toASCIILower(character);
}
static unsigned hash(const UChar* data, unsigned length)
@@ -105,17 +102,23 @@
static inline unsigned hash(const char* data, unsigned length)
{
- return CaseFoldingHash::hash(reinterpret_cast<const LChar*>(data), length);
+ return hash(reinterpret_cast<const LChar*>(data), length);
}
+ static inline bool equal(const StringImpl& a, const StringImpl& b)
+ {
+ return equalIgnoringASCIICase(a, b);
+ }
static inline bool equal(const StringImpl* a, const StringImpl* b)
{
- return equalCompatibiltyCaselessNonNull(a, b);
+ ASSERT(a);
+ ASSERT(b);
+ return equal(*a, *b);
}
static unsigned hash(const RefPtr<StringImpl>& key)
{
- return hash(*key);
+ return hash(key.get());
}
static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b)
@@ -167,8 +170,8 @@
}
+using WTF::ASCIICaseInsensitiveHash;
using WTF::AlreadyHashed;
-using WTF::CaseFoldingHash;
using WTF::StringHash;
#endif
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (195910 => 195911)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -950,30 +950,50 @@
return charactersToFloat(characters16(), m_length, ok);
}
-static inline bool equalCompatibiltyCaseless(const LChar* a, const LChar* b, unsigned length)
+// Table is based on ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt
+static const UChar latin1CaseFoldTable[256] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
+ 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
+ 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
+ 0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
+ 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
+ 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x03bc, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00d7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00df,
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
+};
+
+static inline bool equalCompatibilityCaseless(const LChar* a, const LChar* b, unsigned length)
{
while (length--) {
- if (StringImpl::latin1CaseFoldTable[*a++] != StringImpl::latin1CaseFoldTable[*b++])
+ if (latin1CaseFoldTable[*a++] != latin1CaseFoldTable[*b++])
return false;
}
return true;
}
-static inline bool equalCompatibiltyCaseless(const UChar* a, const LChar* b, unsigned length)
+static inline bool equalCompatibilityCaseless(const UChar* a, const LChar* b, unsigned length)
{
while (length--) {
- if (u_foldCase(*a++, U_FOLD_CASE_DEFAULT) != StringImpl::latin1CaseFoldTable[*b++])
+ if (u_foldCase(*a++, U_FOLD_CASE_DEFAULT) != latin1CaseFoldTable[*b++])
return false;
}
return true;
}
-static inline bool equalCompatibiltyCaseless(const LChar* a, const UChar* b, unsigned length)
+static inline bool equalCompatibilityCaseless(const LChar* a, const UChar* b, unsigned length)
{
- return equalCompatibiltyCaseless(b, a, length);
+ return equalCompatibilityCaseless(b, a, length);
}
-static inline bool equalCompatibiltyCaseless(const UChar* a, const UChar* b, unsigned length)
+static inline bool equalCompatibilityCaseless(const UChar* a, const UChar* b, unsigned length)
{
return !u_memcasecmp(a, b, length, U_FOLD_CASE_DEFAULT);
}
@@ -1082,7 +1102,7 @@
const LChar* searchCharacters = characters8() + index;
unsigned i = 0;
- while (!equalCompatibiltyCaseless(searchCharacters + i, matchString, matchLength)) {
+ while (!equalCompatibilityCaseless(searchCharacters + i, matchString, matchLength)) {
if (i == delta)
return notFound;
++i;
@@ -1093,7 +1113,7 @@
const UChar* searchCharacters = characters16() + index;
unsigned i = 0;
- while (!equalCompatibiltyCaseless(searchCharacters + i, matchString, matchLength)) {
+ while (!equalCompatibilityCaseless(searchCharacters + i, matchString, matchLength)) {
if (i == delta)
return notFound;
++i;
@@ -1157,7 +1177,7 @@
unsigned i = 0;
// keep looping until we match
- while (!equalCompatibiltyCaseless(searchCharacters + i, matchCharacters, matchLength)) {
+ while (!equalCompatibilityCaseless(searchCharacters + i, matchCharacters, matchLength)) {
if (i == delta)
return notFound;
++i;
@@ -1298,7 +1318,7 @@
unsigned delta = std::min(index, length - matchLength);
// keep looping until we match
- while (!equalCompatibiltyCaseless(searchCharacters + delta, matchCharacters, matchLength)) {
+ while (!equalCompatibilityCaseless(searchCharacters + delta, matchCharacters, matchLength)) {
if (!delta)
return notFound;
--delta;
@@ -1344,8 +1364,8 @@
return equal(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
}
if (stringImpl->is8Bit())
- return equalCompatibiltyCaseless(stringImpl->characters8() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
- return equalCompatibiltyCaseless(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
+ return equalCompatibilityCaseless(stringImpl->characters8() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
+ return equalCompatibilityCaseless(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
}
ALWAYS_INLINE static bool equalInner(const StringImpl& stringImpl, unsigned startOffset, const StringImpl& matchString)
@@ -1918,30 +1938,6 @@
return equalCommon(a, b);
}
-bool equalCompatibiltyCaselessNonNull(const StringImpl* a, const StringImpl* b)
-{
- ASSERT(a);
- ASSERT(b);
- if (a == b)
- return true;
-
- unsigned length = a->length();
- if (length != b->length())
- return false;
-
- if (a->is8Bit()) {
- if (b->is8Bit())
- return equalCompatibiltyCaseless(a->characters8(), b->characters8(), length);
-
- return equalCompatibiltyCaseless(b->characters16(), a->characters8(), length);
- }
-
- if (b->is8Bit())
- return equalCompatibiltyCaseless(a->characters16(), b->characters8(), length);
-
- return equalCompatibiltyCaseless(a->characters16(), b->characters16(), length);
-}
-
bool equalIgnoringNullity(StringImpl* a, StringImpl* b)
{
if (!a && b && !b->length())
@@ -2141,26 +2137,6 @@
return utf8ForRange(0, length(), mode);
}
-// Table is based on ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt
-const UChar StringImpl::latin1CaseFoldTable[256] = {
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
- 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
- 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
- 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
- 0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
- 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
- 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
- 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x03bc, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00d7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00df,
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
-};
-
bool equalIgnoringNullity(const UChar* a, size_t aLength, StringImpl* b)
{
if (!b)
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (195910 => 195911)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -762,8 +762,6 @@
ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; }
#endif
- WTF_EXPORT_STRING_API static const UChar latin1CaseFoldTable[256];
-
Ref<StringImpl> extractFoldedStringInSymbol()
{
ASSERT(isSymbol());
@@ -946,9 +944,6 @@
inline bool equal(const char* a, StringImpl* b) { return equal(b, reinterpret_cast<const LChar*>(a)); }
WTF_EXPORT_STRING_API bool equal(const StringImpl& a, const StringImpl& b);
-// FIXME: Deprecated. Used only by CaseFoldingHash, which itself is soon to be deprecated and removed, replaced by ASCIICaseFoldingHash.
-WTF_EXPORT_STRING_API bool equalCompatibiltyCaselessNonNull(const StringImpl*, const StringImpl*);
-
WTF_EXPORT_STRING_API bool equalIgnoringNullity(StringImpl*, StringImpl*);
WTF_EXPORT_STRING_API bool equalIgnoringNullity(const UChar*, size_t length, StringImpl*);
Modified: trunk/Source/WebCore/ChangeLog (195910 => 195911)
--- trunk/Source/WebCore/ChangeLog 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/ChangeLog 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1,3 +1,91 @@
+2016-01-30 Darin Adler <[email protected]>
+
+ Replace CaseFoldingHash with ASCIICaseInsensitiveHash
+ https://bugs.webkit.org/show_bug.cgi?id=153639
+
+ Reviewed by Filip Pizlo.
+
+ * Modules/webdatabase/DatabaseAuthorizer.h: Use ASCIICaseInsensitiveHash
+ for whitelisted functions. Function names are all ASCII.
+
+ * accessibility/AccessibilityObject.cpp: Use ASCIICaseInsensitiveHash
+ for ARIA roles. ARIA roles are all ASCII.
+
+ * crypto/CryptoAlgorithmRegistry.h: Use ASCIICaseInsensitiveHash for
+ crypto algorithm names. Algorithm names are all ASCII.
+
+ * css/CSSFontSelector.cpp:
+ (WebCore::registerLocalFontFacesForFamily): Use ASCIICaseInsensitiveHash
+ for font faces. Face names should use ASCII case insensitive matching;
+ there is no need for non-ASCII case folding.
+ * css/CSSFontSelector.h: Ditto.
+
+ * dom/DOMImplementation.cpp: Use ASCIICaseInsensitiveHash for the
+ FeatureSet. The features are all ASCII.
+
+ * dom/Document.h: Use ASCIICaseInsensitiveHash for the access key
+ map. Access keys are all ASCII.
+
+ * dom/ScriptElement.cpp:
+ (WebCore::isLegacySupportedJavaScriptLanguage): Use ASCIICaseInsensitiveHash
+ for the language set. These strings are all ASCII.
+
+ * editing/EditorCommand.cpp: Use ASCIICaseInsensitiveHash for editor
+ command names. These names are all ASCII.
+
+ * html/HTMLObjectElement.cpp:
+ (WebCore::HTMLObjectElement::parametersForPlugin): Use ASCIICaseInsensitiveHash
+ for parameter names. These names are all ASCII.
+
+ * html/InputType.cpp: Use ASCIICaseInsensitiveHash for the input types.
+ The input types are all ASCII.
+
+ * loader/CrossOriginAccessControl.h: Use ASCIICaseInsensitiveHash for
+ HTTP header field names. These names are all ASCII.
+ * loader/CrossOriginPreflightResultCache.h: Ditto.
+
+ * loader/archive/ArchiveFactory.cpp: Use ASCIICaseInsensitiveHash for
+ MIME types. MIME types are all ASCII.
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::initializeSupportedImageMIMETypes): Ditto.
+
+ * platform/SchemeRegistry.h: Use ASCIICaseInsensitiveHas for URL schemes.
+ URL schemes are all ASCII.
+ * platform/URL.cpp: Ditto.
+
+ * platform/graphics/FontCache.cpp: Reworked FontPlatformDataCacheKey struct:
+ Made it a conventional struct with non-prefixed data members names. Removed
+ the "==" operator since it was appropriate for hash table lookup but wasn't
+ a true equality operator. Tightened the implementations of the constructors.
+ (WebCore::FontPlatformDataCacheKeyHash::hash): Use ASCIICaseInsensitiveHash.
+ (WebCore::FontPlatformDataCacheKeyHash::equal): Do the equality check here,
+ not using the == operator. And use equalIgnoringASCIICase.
+ (WebCore::FontPlatformDataCacheKeyTraits::isEmptyValue): Added this entire
+ traits struct so we check empty values in a more efficient way.
+ (WebCore::FontCache::getCachedFontPlatformData): Added comments and tweaked
+ style in this function.
+
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::keysMatch): Rename from operator== since this operation is not
+ equality. Changed to equalIgnoringASCIICase and did a little streamlining.
+ (WebCore::makeFontCascadeCacheKey): Use reserveInitialCapacity for slightly
+ better memory use.
+ (WebCore::computeFontCascadeCacheHash): Use IntegerHasher to make computing
+ a hash more efficient by eliminating the overhead of building a vector and
+ even possible heap allocation and deallocation.
+ (WebCore::retrieveOrAddCachedFonts): Use keysMatch instead of ==.
+
+ * platform/graphics/cocoa/FontCacheCoreText.cpp: Use ASCIICaseInsensitiveHash
+ for font family names. These names should use ASCII case insensitive matching;
+ there is no need for non-ASCII case folding.
+
+ * platform/network/HTTPHeaderMap.h: Use ASCIICaseInsensitiveHash for
+ HTTP header field names. These names are all ASCII.
+
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::computeFontHash): Use IntegerHasher to avoid allocating memory just
+ to compute a hash. Use ASCIICaseInsensitiveHash.
+
2016-01-30 Chris Dumez <[email protected]>
Unreviewed, rolling out r195871.
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseAuthorizer.h (195910 => 195911)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseAuthorizer.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseAuthorizer.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -117,7 +117,7 @@
const String m_databaseInfoTableName;
- HashSet<String, CaseFoldingHash> m_whitelistedFunctions;
+ HashSet<String, ASCIICaseInsensitiveHash> m_whitelistedFunctions;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (195910 => 195911)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1988,7 +1988,7 @@
return nullptr;
}
-typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap;
+typedef HashMap<String, AccessibilityRole, ASCIICaseInsensitiveHash> ARIARoleMap;
typedef HashMap<AccessibilityRole, String, DefaultHash<int>::Hash, WTF::UnsignedWithZeroKeyHashTraits<int>> ARIAReverseRoleMap;
static ARIARoleMap* gAriaRoleMap = nullptr;
Modified: trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.h (195910 => 195911)
--- trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -65,7 +65,7 @@
void registerAlgorithm(const String& name, CryptoAlgorithmIdentifier, CryptoAlgorithmConstructor);
- HashMap<String, CryptoAlgorithmIdentifier, CaseFoldingHash> m_nameToIdentifierMap;
+ HashMap<String, CryptoAlgorithmIdentifier, ASCIICaseInsensitiveHash> m_nameToIdentifierMap;
HashMap<unsigned, String> m_identifierToNameMap;
HashMap<unsigned, CryptoAlgorithmConstructor> m_identifierToConstructorMap;
};
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (195910 => 195911)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -224,7 +224,7 @@
}
}
-static void registerLocalFontFacesForFamily(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash>& locallyInstalledFontFaces)
+static void registerLocalFontFacesForFamily(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash>& locallyInstalledFontFaces)
{
ASSERT(!locallyInstalledFontFaces.contains(familyName));
Modified: trunk/Source/WebCore/css/CSSFontSelector.h (195910 => 195911)
--- trunk/Source/WebCore/css/CSSFontSelector.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/css/CSSFontSelector.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -86,9 +86,9 @@
void beginLoadTimerFired();
Document* m_document;
- HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash> m_fontFaces;
- HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash> m_locallyInstalledFontFaces;
- HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace>>, CaseFoldingHash> m_fonts;
+ HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_fontFaces;
+ HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_locallyInstalledFontFaces;
+ HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace>>, ASCIICaseInsensitiveHash> m_fonts;
HashSet<FontSelectorClient*> m_clients;
Vector<CachedResourceHandle<CachedFont>> m_fontsToBeginLoading;
Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (195910 => 195911)
--- trunk/Source/WebCore/dom/DOMImplementation.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -64,7 +64,7 @@
using namespace HTMLNames;
-typedef HashSet<String, CaseFoldingHash> FeatureSet;
+typedef HashSet<String, ASCIICaseInsensitiveHash> FeatureSet;
static void addString(FeatureSet& set, const char* string)
{
Modified: trunk/Source/WebCore/dom/Document.h (195910 => 195911)
--- trunk/Source/WebCore/dom/Document.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/dom/Document.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1613,7 +1613,7 @@
HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements;
#endif
- HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
+ HashMap<StringImpl*, Element*, ASCIICaseInsensitiveHash> m_elementsByAccessKey;
bool m_accessKeyMapValid;
DocumentOrderedMap m_imagesByUsemap;
Modified: trunk/Source/WebCore/dom/ScriptElement.cpp (195910 => 195911)
--- trunk/Source/WebCore/dom/ScriptElement.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/dom/ScriptElement.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -118,7 +118,7 @@
// We want to accept all the values that either of these browsers accept, but not other values.
// FIXME: This function is not HTML5 compliant. These belong in the MIME registry as "text/_javascript_<version>" entries.
- typedef HashSet<String, CaseFoldingHash> LanguageSet;
+ typedef HashSet<String, ASCIICaseInsensitiveHash> LanguageSet;
static NeverDestroyed<LanguageSet> languages;
if (languages.get().isEmpty()) {
languages.get().add("_javascript_");
Modified: trunk/Source/WebCore/editing/EditorCommand.cpp (195910 => 195911)
--- trunk/Source/WebCore/editing/EditorCommand.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/editing/EditorCommand.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -77,7 +77,7 @@
bool allowExecutionWhenDisabled;
};
-typedef HashMap<String, const EditorInternalCommand*, CaseFoldingHash> CommandMap;
+typedef HashMap<String, const EditorInternalCommand*, ASCIICaseInsensitiveHash> CommandMap;
static const bool notTextInsertion = false;
static const bool isTextInsertion = true;
Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (195910 => 195911)
--- trunk/Source/WebCore/html/HTMLObjectElement.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -166,7 +166,7 @@
// FIXME: This function should not deal with url or serviceType!
void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
{
- HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
+ HashSet<StringImpl*, ASCIICaseInsensitiveHash> uniqueParamNames;
String urlParameter;
// Scan the PARAM children and store their name/value pairs.
Modified: trunk/Source/WebCore/html/InputType.cpp (195910 => 195911)
--- trunk/Source/WebCore/html/InputType.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/html/InputType.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -86,7 +86,7 @@
typedef bool (RuntimeEnabledFeatures::*InputTypeConditionalFunction)() const;
typedef const AtomicString& (*InputTypeNameFunction)();
typedef std::unique_ptr<InputType> (*InputTypeFactoryFunction)(HTMLInputElement&);
-typedef HashMap<AtomicString, InputTypeFactoryFunction, CaseFoldingHash> InputTypeFactoryMap;
+typedef HashMap<AtomicString, InputTypeFactoryFunction, ASCIICaseInsensitiveHash> InputTypeFactoryMap;
template<class T>
static std::unique_ptr<InputType> createInputType(HTMLInputElement& element)
Modified: trunk/Source/WebCore/loader/CrossOriginAccessControl.h (195910 => 195911)
--- trunk/Source/WebCore/loader/CrossOriginAccessControl.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/loader/CrossOriginAccessControl.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -34,7 +34,7 @@
namespace WebCore {
-typedef HashSet<String, CaseFoldingHash> HTTPHeaderSet;
+typedef HashSet<String, ASCIICaseInsensitiveHash> HTTPHeaderSet;
class HTTPHeaderMap;
enum class HTTPHeaderName;
Modified: trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h (195910 => 195911)
--- trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -59,7 +59,7 @@
std::chrono::steady_clock::time_point m_absoluteExpiryTime;
StoredCredentials m_credentials;
HashSet<String> m_methods;
- HashSet<String, CaseFoldingHash> m_headers;
+ HashSet<String, ASCIICaseInsensitiveHash> m_headers;
};
class CrossOriginPreflightResultCache {
Modified: trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp (195910 => 195911)
--- trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -47,7 +47,7 @@
namespace WebCore {
typedef PassRefPtr<Archive> RawDataCreationFunction(const URL&, SharedBuffer*);
-typedef HashMap<String, RawDataCreationFunction*, CaseFoldingHash> ArchiveMIMETypesMap;
+typedef HashMap<String, RawDataCreationFunction*, ASCIICaseInsensitiveHash> ArchiveMIMETypesMap;
// The create functions in the archive classes return PassRefPtr to concrete subclasses
// of Archive. This adaptor makes the functions have a uniform return type.
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (195910 => 195911)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -150,7 +150,7 @@
static HashSet<String>* pdfAndPostScriptMIMETypes;
static HashSet<String>* unsupportedTextMIMETypes;
-typedef HashMap<String, Vector<String>*, CaseFoldingHash> MediaMIMETypeMap;
+typedef HashMap<String, Vector<String>*, ASCIICaseInsensitiveHash> MediaMIMETypeMap;
static void initializeSupportedImageMIMETypes()
{
Modified: trunk/Source/WebCore/platform/SchemeRegistry.h (195910 => 195911)
--- trunk/Source/WebCore/platform/SchemeRegistry.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/SchemeRegistry.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -32,7 +32,7 @@
namespace WebCore {
-typedef HashSet<String, CaseFoldingHash> URLSchemesMap;
+typedef HashSet<String, ASCIICaseInsensitiveHash> URLSchemesMap;
class SchemeRegistry {
public:
Modified: trunk/Source/WebCore/platform/URL.cpp (195910 => 195911)
--- trunk/Source/WebCore/platform/URL.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/URL.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1990,7 +1990,7 @@
return protocolIs("about");
}
-typedef HashMap<String, unsigned short, CaseFoldingHash> DefaultPortsMap;
+typedef HashMap<String, unsigned short, ASCIICaseInsensitiveHash> DefaultPortsMap;
static const DefaultPortsMap& defaultPortsMap()
{
static NeverDestroyed<const DefaultPortsMap> defaultPortsMap(DefaultPortsMap({
Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (195910 => 195911)
--- trunk/Source/WebCore/platform/graphics/FontCache.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -97,51 +97,47 @@
}
struct FontPlatformDataCacheKey {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- FontPlatformDataCacheKey() { }
- FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description)
- : m_fontDescriptionKey(description)
- , m_family(family)
- { }
+ AtomicString family;
+ FontDescriptionKey description;
- explicit FontPlatformDataCacheKey(HashTableDeletedValueType t)
- : m_fontDescriptionKey(t)
- { }
-
- bool isHashTableDeletedValue() const { return m_fontDescriptionKey.isHashTableDeletedValue(); }
-
- bool operator==(const FontPlatformDataCacheKey& other) const
+ FontPlatformDataCacheKey() = default;
+ FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description)
+ : family(family), description(description)
{
- if (m_fontDescriptionKey != other.m_fontDescriptionKey)
- return false;
- if (m_family.impl() == other.m_family.impl())
- return true;
- if (m_family.isNull() || other.m_family.isNull())
- return false;
- return CaseFoldingHash::equal(m_family, other.m_family);
}
- FontDescriptionKey m_fontDescriptionKey;
- AtomicString m_family;
+ explicit FontPlatformDataCacheKey(HashTableDeletedValueType)
+ : description(HashTableDeletedValue)
+ {
+ }
+ bool isHashTableDeletedValue() const
+ {
+ return description.isHashTableDeletedValue();
+ }
};
struct FontPlatformDataCacheKeyHash {
- static unsigned hash(const FontPlatformDataCacheKey& fontKey)
+ static unsigned hash(const FontPlatformDataCacheKey& key)
{
- return pairIntHash(CaseFoldingHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash());
+ return pairIntHash(ASCIICaseInsensitiveHash::hash(key.family), key.description.computeHash());
}
-
static bool equal(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b)
{
- return a == b;
+ return a.description == b.description && equalIgnoringASCIICase(a.family, b.family);
}
-
static const bool safeToCompareToEmptyOrDeleted = true;
};
-typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, WTF::SimpleClassHashTraits<FontPlatformDataCacheKey>> FontPlatformDataCache;
+struct FontPlatformDataCacheKeyTraits : SimpleClassHashTraits<FontPlatformDataCacheKey> {
+ static const bool hasIsEmptyValueFunction = true;
+ static bool isEmptyValue(const FontPlatformDataCacheKey& key)
+ {
+ return key.family.isNull();
+ }
+};
+typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
+
static FontPlatformDataCache& fontPlatformDataCache()
{
static NeverDestroyed<FontPlatformDataCache> cache;
@@ -207,9 +203,9 @@
return nullAtom;
}
-FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription,
- const AtomicString& passedFamilyName,
- bool checkingAlternateName)
+// FIXME: This function name should not have the word "get" in it for WebKit coding style.
+// FIXME: The boolean here is poor coding style. Easy to factor this into two functions so we don't need it.
+FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, const AtomicString& passedFamilyName, bool checkingAlternateName)
{
#if PLATFORM(IOS)
FontLocker fontLocker;
@@ -218,9 +214,9 @@
#if OS(WINDOWS) && ENABLE(OPENTYPE_VERTICAL)
// Leading "@" in the font name enables Windows vertical flow flag for the font.
// Because we do vertical flow by ourselves, we don't want to use the Windows feature.
- // IE disregards "@" regardless of the orientatoin, so we follow the behavior.
- const AtomicString& familyName = (passedFamilyName.isEmpty() || passedFamilyName[0] != '@') ?
- passedFamilyName : AtomicString(passedFamilyName.impl()->substring(1));
+ // IE disregards "@" regardless of the orientation, so we follow the behavior.
+ const AtomicString& familyName = passedFamilyName[0] != '@'
+ ? passedFamilyName : AtomicString(passedFamilyName.impl()->substring(1));
#else
const AtomicString& familyName = passedFamilyName;
#endif
@@ -237,14 +233,13 @@
FontPlatformDataCache::iterator it = addResult.iterator;
if (addResult.isNewEntry) {
it->value = createFontPlatformData(fontDescription, familyName);
-
if (!it->value && !checkingAlternateName) {
- // We were unable to find a font. We have a small set of fonts that we alias to other names,
- // e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
- const AtomicString alternateName = alternateFamilyName(familyName);
+ // We were unable to find a font. We have a small set of fonts that we alias to other names,
+ // e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
+ auto alternateName = alternateFamilyName(familyName);
if (!alternateName.isNull()) {
FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);
- // Lookup the key in the hash table again as the previous iterator may have
+ // Look up the key in the hash table again as the previous iterator may have
// been invalidated by the recursive call to getCachedFontPlatformData().
it = fontPlatformDataCache().find(key);
ASSERT(it != fontPlatformDataCache().end());
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (195910 => 195911)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -190,22 +190,20 @@
Ref<FontCascadeFonts> fonts;
};
+// FIXME: Should make hash traits for FontCascadeCacheKey instead of using a hash as the key (so we hash a hash).
typedef HashMap<unsigned, std::unique_ptr<FontCascadeCacheEntry>, AlreadyHashed> FontCascadeCache;
-static bool operator==(const FontCascadeCacheKey& a, const FontCascadeCacheKey& b)
+static bool keysMatch(const FontCascadeCacheKey& a, const FontCascadeCacheKey& b)
{
if (a.fontDescriptionKey != b.fontDescriptionKey)
return false;
if (a.fontSelectorId != b.fontSelectorId || a.fontSelectorVersion != b.fontSelectorVersion)
return false;
- if (a.families.size() != b.families.size())
+ unsigned size = a.families.size();
+ if (size != b.families.size())
return false;
- for (unsigned i = 0; i < a.families.size(); ++i) {
- auto* aImpl = a.families[i].impl();
- auto* bImpl = b.families[i].impl();
- if (aImpl == bImpl)
- continue;
- if (!aImpl || !bImpl || !CaseFoldingHash::equal(aImpl, bImpl))
+ for (unsigned i = 0; i < size; ++i) {
+ if (!equalIgnoringASCIICase(a.families[i], b.families[i]))
return false;
}
return true;
@@ -232,26 +230,27 @@
{
FontCascadeCacheKey key;
key.fontDescriptionKey = FontDescriptionKey(description);
- for (unsigned i = 0; i < description.familyCount(); ++i)
- key.families.append(description.familyAt(i));
+ unsigned familyCount = description.familyCount();
+ key.families.reserveInitialCapacity(familyCount);
+ for (unsigned i = 0; i < familyCount; ++i)
+ key.families.uncheckedAppend(description.familyAt(i));
key.fontSelectorId = fontSelector ? fontSelector->uniqueId() : 0;
key.fontSelectorVersion = fontSelector ? fontSelector->version() : 0;
return key;
}
-// FIXME: Why can't we just teach HashMap about FontCascadeCacheKey instead of hashing a hash?
static unsigned computeFontCascadeCacheHash(const FontCascadeCacheKey& key)
{
- Vector<unsigned, 7> hashCodes;
- hashCodes.reserveInitialCapacity(4 + key.families.size());
-
- hashCodes.uncheckedAppend(key.fontDescriptionKey.computeHash());
- hashCodes.uncheckedAppend(key.fontSelectorId);
- hashCodes.uncheckedAppend(key.fontSelectorVersion);
- for (unsigned i = 0; i < key.families.size(); ++i)
- hashCodes.uncheckedAppend(key.families[i].impl() ? CaseFoldingHash::hash(key.families[i]) : 0);
-
- return StringHasher::hashMemory(hashCodes.data(), hashCodes.size() * sizeof(unsigned));
+ // FIXME: Should hash the key and the family name characters rather than making a hash out of other hashes.
+ IntegerHasher hasher;
+ hasher.add(key.fontDescriptionKey.computeHash());
+ 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);
+ }
+ return hasher.hash();
}
void pruneUnreferencedEntriesFromFontCascadeCache()
@@ -272,8 +271,8 @@
auto key = makeFontCascadeCacheKey(fontDescription, fontSelector.get());
unsigned hash = computeFontCascadeCacheHash(key);
- auto addResult = fontCascadeCache().add(hash, std::unique_ptr<FontCascadeCacheEntry>());
- if (!addResult.isNewEntry && addResult.iterator->value->key == key)
+ auto addResult = fontCascadeCache().add(hash, nullptr);
+ if (!addResult.isNewEntry && keysMatch(addResult.iterator->value->key, key))
return addResult.iterator->value->fonts.get();
auto& newEntry = addResult.iterator->value;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (195910 => 195911)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -645,7 +645,7 @@
return SynthesisPair(needsSyntheticBold, needsSyntheticOblique);
}
-typedef HashSet<String, CaseFoldingHash> Whitelist;
+typedef HashSet<String, ASCIICaseInsensitiveHash> Whitelist;
static Whitelist& fontWhitelist()
{
static NeverDestroyed<Whitelist> whitelist;
Modified: trunk/Source/WebCore/platform/network/HTTPHeaderMap.h (195910 => 195911)
--- trunk/Source/WebCore/platform/network/HTTPHeaderMap.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/platform/network/HTTPHeaderMap.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -48,7 +48,7 @@
class HTTPHeaderMap {
public:
typedef HashMap<HTTPHeaderName, String, WTF::IntHash<HTTPHeaderName>, WTF::StrongEnumHashTraits<HTTPHeaderName>> CommonHeadersHashMap;
- typedef HashMap<String, String, CaseFoldingHash> UncommonHeadersHashMap;
+ typedef HashMap<String, String, ASCIICaseInsensitiveHash> UncommonHeadersHashMap;
class HTTPHeaderMapConstIterator {
public:
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (195910 => 195911)
--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -366,21 +366,19 @@
}
#if ENABLE(IOS_TEXT_AUTOSIZING)
-inline unsigned computeFontHash(const FontCascade& font)
+
+static inline unsigned computeFontHash(const FontCascade& font)
{
- unsigned hashCodes[2] = {
- CaseFoldingHash::hash(font.fontDescription().firstFamily().impl()),
- static_cast<unsigned>(font.fontDescription().specifiedSize())
- };
- return StringHasher::computeHash(reinterpret_cast<UChar*>(hashCodes), 2 * sizeof(unsigned) / sizeof(UChar));
+ IntegerHasher hasher;
+ hasher.add(ASCIICaseInsensitiveHash::hash(font.fontDescription().firstFamily()));
+ hasher.add(font.fontDescription().specifiedSize());
+ return hasher.hash();
}
-uint32_t RenderStyle::hashForTextAutosizing() const
+unsigned RenderStyle::hashForTextAutosizing() const
{
// FIXME: Not a very smart hash. Could be improved upon. See <https://bugs.webkit.org/show_bug.cgi?id=121131>.
- uint32_t hash = 0;
-
- hash ^= rareNonInheritedData->m_appearance;
+ unsigned hash = rareNonInheritedData->m_appearance;
hash ^= rareNonInheritedData->marginBeforeCollapse;
hash ^= rareNonInheritedData->marginAfterCollapse;
hash ^= rareNonInheritedData->lineClamp.value();
@@ -421,6 +419,7 @@
&& noninherited_flags.floating() == other->noninherited_flags.floating()
&& rareNonInheritedData->textOverflow == other->rareNonInheritedData->textOverflow;
}
+
#endif // ENABLE(IOS_TEXT_AUTOSIZING)
bool RenderStyle::inheritedDataShared(const RenderStyle* other) const
Modified: trunk/Source/WebKit/win/ChangeLog (195910 => 195911)
--- trunk/Source/WebKit/win/ChangeLog 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit/win/ChangeLog 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1,3 +1,18 @@
+2016-01-30 Darin Adler <[email protected]>
+
+ Replace CaseFoldingHash with ASCIICaseInsensitiveHash
+ https://bugs.webkit.org/show_bug.cgi?id=153639
+
+ Reviewed by Filip Pizlo.
+
+ * WebCoreStatistics.cpp:
+ (WebCoreStatistics::memoryStatistics): Use ASCIICaseInsensitiveHash for field names.
+ These names are all ASCII.
+
+ * WebURLResponse.cpp:
+ (WebURLResponse::allHeaderFields): Use ASCIICaseInsensitiveHash for HTTP header
+ field names. These names are all ASCII.
+
2016-01-29 Ryan Haddad <[email protected]>
Attempt to fix the Windows build after r195799
Modified: trunk/Source/WebKit/win/WebCoreStatistics.cpp (195910 => 195911)
--- trunk/Source/WebKit/win/WebCoreStatistics.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit/win/WebCoreStatistics.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -295,7 +295,7 @@
unsigned long long heapFree = JSDOMWindow::commonVM().heap.capacity() - heapSize;
GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
- HashMap<String, unsigned long long, CaseFoldingHash> fields;
+ HashMap<String, unsigned long long, ASCIICaseInsensitiveHash> fields;
fields.add("FastMallocReservedVMBytes", static_cast<unsigned long long>(fastMallocStatistics.reservedVMBytes));
fields.add("FastMallocCommittedVMBytes", static_cast<unsigned long long>(fastMallocStatistics.committedVMBytes));
fields.add("FastMallocFreeListBytes", static_cast<unsigned long long>(fastMallocStatistics.freeListBytes));
@@ -304,7 +304,7 @@
fields.add("_javascript_StackSize", static_cast<unsigned long long>(globalMemoryStats.stackBytes));
fields.add("_javascript_JITSize", static_cast<unsigned long long>(globalMemoryStats.JITBytes));
- *statistics = COMPropertyBag<unsigned long long, String, CaseFoldingHash>::adopt(fields);
+ *statistics = COMPropertyBag<unsigned long long, String, ASCIICaseInsensitiveHash>::adopt(fields);
return S_OK;
}
Modified: trunk/Source/WebKit/win/WebURLResponse.cpp (195910 => 195911)
--- trunk/Source/WebKit/win/WebURLResponse.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit/win/WebURLResponse.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -362,11 +362,11 @@
if (!headerFields)
return E_POINTER;
- HashMap<String, String, CaseFoldingHash> fields;
+ HashMap<String, String, ASCIICaseInsensitiveHash> fields;
for (const auto& keyValuePair : m_response.httpHeaderFields())
fields.add(keyValuePair.key, keyValuePair.value);
- *headerFields = COMPropertyBag<String, String, CaseFoldingHash>::adopt(fields);
+ *headerFields = COMPropertyBag<String, String, ASCIICaseInsensitiveHash>::adopt(fields);
return S_OK;
}
Modified: trunk/Source/WebKit2/ChangeLog (195910 => 195911)
--- trunk/Source/WebKit2/ChangeLog 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit2/ChangeLog 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1,3 +1,25 @@
+2016-01-30 Darin Adler <[email protected]>
+
+ Replace CaseFoldingHash with ASCIICaseInsensitiveHash
+ https://bugs.webkit.org/show_bug.cgi?id=153639
+
+ Reviewed by Filip Pizlo.
+
+ * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use ASCIICaseInsensitiveHash
+ for MIME types. MIME types are all ASCII.
+
+ * UIProcess/Plugins/PlugInAutoStartProvider.h: Use ASCIICaseInsensitiveHash for
+ origins. Origin strings should use ASCII case insensitive matching and should not
+ fold non-ASCII case.
+
+ * WebProcess/WebPage/WebPage.h: Use ASCIICaseInsensitiveHash for MIME types.
+ MIME types are all ASCII.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::addCaseFoldedCharacters): Use ASCIICaseInsensitiveHash to hash plug-in
+ origin strings. (See rationale above.)
+ (WebKit::hashForPlugInOrigin): Updated comment.
+
2016-01-30 Jeremy Huddleston Sequoia <[email protected]>
[GTK] Use configured python executable when executing generate-inspector-gresource-manifest.py
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm (195910 => 195911)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm 2016-01-30 21:53:47 UTC (rev 195911)
@@ -42,7 +42,7 @@
using namespace WebKit;
@implementation WKWebViewContentProviderRegistry {
- HashMap<String, Class <WKWebViewContentProvider>, CaseFoldingHash> _contentProviderForMIMEType;
+ HashMap<String, Class <WKWebViewContentProvider>, ASCIICaseInsensitiveHash> _contentProviderForMIMEType;
HashCountedSet<WebPageProxy*> _pages;
}
Modified: trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h (195910 => 195911)
--- trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -69,7 +69,7 @@
void setAutoStartOriginsTableWithItemsPassingTest(API::Dictionary&, std::function<bool(double expirationTimestamp)>);
- typedef HashMap<String, PlugInAutoStartOriginMap, CaseFoldingHash> AutoStartTable;
+ typedef HashMap<String, PlugInAutoStartOriginMap, ASCIICaseInsensitiveHash> AutoStartTable;
typedef HashMap<WebCore::SessionID, AutoStartTable> SessionAutoStartTable;
SessionAutoStartTable m_autoStartTable;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (195910 => 195911)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1393,7 +1393,7 @@
WebCore::Timer m_volatilityTimer;
#endif
- HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomContentProviders;
+ HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders;
WebCore::Color m_backgroundColor;
HashSet<unsigned> m_activeRenderingSuppressionTokens;
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (195910 => 195911)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2016-01-30 21:53:47 UTC (rev 195911)
@@ -721,16 +721,16 @@
if (string.isEmpty())
return;
if (string.is8Bit()) {
- hasher.addCharacters<LChar, CaseFoldingHash::foldCase<LChar>>(string.characters8(), string.length());
+ hasher.addCharacters<LChar, ASCIICaseInsensitiveHash::foldCase<LChar>>(string.characters8(), string.length());
return;
}
- hasher.addCharacters<UChar, CaseFoldingHash::foldCase<UChar>>(string.characters16(), string.length());
+ hasher.addCharacters<UChar, ASCIICaseInsensitiveHash::foldCase<UChar>>(string.characters16(), string.length());
}
static unsigned hashForPlugInOrigin(const String& pageOrigin, const String& pluginOrigin, const String& mimeType)
{
// We want to avoid concatenating the strings and then taking the hash, since that could lead to an expensive conversion.
- // We also want to avoid using the hash() function in StringImpl or CaseFoldingHash because that masks out bits for the use of flags.
+ // We also want to avoid using the hash() function in StringImpl or ASCIICaseInsensitiveHash because that masks out bits for the use of flags.
StringHasher hasher;
addCaseFoldedCharacters(hasher, pageOrigin);
hasher.addCharacter(0);
Modified: trunk/Tools/ChangeLog (195910 => 195911)
--- trunk/Tools/ChangeLog 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Tools/ChangeLog 2016-01-30 21:53:47 UTC (rev 195911)
@@ -1,3 +1,12 @@
+2016-01-30 Darin Adler <[email protected]>
+
+ Replace CaseFoldingHash with ASCIICaseInsensitiveHash
+ https://bugs.webkit.org/show_bug.cgi?id=153639
+
+ Reviewed by Filip Pizlo.
+
+ * Scripts/do-webcore-rename: Use script to do this rename.
+
2016-01-30 Ryosuke Niwa <[email protected]>
TouchList should be retargeted
Modified: trunk/Tools/Scripts/do-webcore-rename (195910 => 195911)
--- trunk/Tools/Scripts/do-webcore-rename 2016-01-30 21:49:31 UTC (rev 195910)
+++ trunk/Tools/Scripts/do-webcore-rename 2016-01-30 21:53:47 UTC (rev 195911)
@@ -98,7 +98,7 @@
my $isDOMTypeRename = 0;
my %renames = (
# Renames go here in the form of:
- "deleteAllValues" => "deprecatedDeleteAllValues",
+ "CaseFoldingHash" => "ASCIICaseInsensitiveHash",
);
my %renamesContemplatedForTheFuture = (
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
