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:
(WebCore::FontPlatformDataCacheKey::operator==): Use ASCIICaseInsensitiveHash.
(WebCore::FontPlatformDataCacheKeyHash::hash): Use ASCIICaseInsensitiveHash.
* 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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195928
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2016-01-31 Darin Adler <darin@apple.com>
+
+ 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-30 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r195911.
/*
- * 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
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.
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)
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)
}
+using WTF::ASCIICaseInsensitiveHash;
using WTF::AlreadyHashed;
-using WTF::CaseFoldingHash;
using WTF::StringHash;
#endif
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);
}
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;
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;
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;
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;
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)
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())
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)
ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; }
#endif
- WTF_EXPORT_STRING_API static const UChar latin1CaseFoldTable[256];
-
Ref<StringImpl> extractFoldedStringInSymbol()
{
ASSERT(isSymbol());
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*);
+2016-01-31 Darin Adler <darin@apple.com>
+
+ 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:
+ (WebCore::FontPlatformDataCacheKey::operator==): Use ASCIICaseInsensitiveHash.
+ (WebCore::FontPlatformDataCacheKeyHash::hash): Use ASCIICaseInsensitiveHash.
+
+ * 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-31 Gyuyoung Kim <gyuyoung.kim@webkit.org>
Reduce PassRefPtr uses in dom - 5
const String m_databaseInfoTableName;
- HashSet<String, CaseFoldingHash> m_whitelistedFunctions;
+ HashSet<String, ASCIICaseInsensitiveHash> m_whitelistedFunctions;
};
} // namespace WebCore
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;
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;
};
}
}
-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));
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;
using namespace HTMLNames;
-typedef HashSet<String, CaseFoldingHash> FeatureSet;
+typedef HashSet<String, ASCIICaseInsensitiveHash> FeatureSet;
static void addString(FeatureSet& set, const char* string)
{
HashSet<HTMLMediaElement*> m_allowsMediaDocumentInlinePlaybackElements;
#endif
- HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
+ HashMap<StringImpl*, Element*, ASCIICaseInsensitiveHash> m_elementsByAccessKey;
bool m_accessKeyMapValid;
DocumentOrderedMap m_imagesByUsemap;
// 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");
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;
// 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.
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)
namespace WebCore {
-typedef HashSet<String, CaseFoldingHash> HTTPHeaderSet;
+typedef HashSet<String, ASCIICaseInsensitiveHash> HTTPHeaderSet;
class HTTPHeaderMap;
enum class HTTPHeaderName;
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 {
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.
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()
{
namespace WebCore {
-typedef HashSet<String, CaseFoldingHash> URLSchemesMap;
+typedef HashSet<String, ASCIICaseInsensitiveHash> URLSchemesMap;
class SchemeRegistry {
public:
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({
return true;
if (m_family.isNull() || other.m_family.isNull())
return false;
- return CaseFoldingHash::equal(m_family, other.m_family);
+ return ASCIICaseInsensitiveHash::equal(m_family, other.m_family);
}
FontDescriptionKey m_fontDescriptionKey;
struct FontPlatformDataCacheKeyHash {
static unsigned hash(const FontPlatformDataCacheKey& fontKey)
{
- return pairIntHash(CaseFoldingHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash());
+ return pairIntHash(ASCIICaseInsensitiveHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash());
}
static bool equal(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b)
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;
{
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()
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;
return SynthesisPair(needsSyntheticBold, needsSyntheticOblique);
}
-typedef HashSet<String, CaseFoldingHash> Whitelist;
+typedef HashSet<String, ASCIICaseInsensitiveHash> Whitelist;
static Whitelist& fontWhitelist()
{
static NeverDestroyed<Whitelist> whitelist;
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:
}
#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();
&& noninherited_flags.floating() == other->noninherited_flags.floating()
&& rareNonInheritedData->textOverflow == other->rareNonInheritedData->textOverflow;
}
+
#endif // ENABLE(IOS_TEXT_AUTOSIZING)
bool RenderStyle::inheritedDataShared(const RenderStyle* other) const
+2016-01-31 Darin Adler <darin@apple.com>
+
+ 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-30 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r195911.
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));
fields.add("JavaScriptStackSize", static_cast<unsigned long long>(globalMemoryStats.stackBytes));
fields.add("JavaScriptJITSize", 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;
}
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;
}
+2016-01-31 Darin Adler <darin@apple.com>
+
+ 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-31 Gyuyoung Kim <gyuyoung.kim@webkit.org>
Use std::make_unique<> when creating an unique_ptr object.
using namespace WebKit;
@implementation WKWebViewContentProviderRegistry {
- HashMap<String, Class <WKWebViewContentProvider>, CaseFoldingHash> _contentProviderForMIMEType;
+ HashMap<String, Class <WKWebViewContentProvider>, ASCIICaseInsensitiveHash> _contentProviderForMIMEType;
HashCountedSet<WebPageProxy*> _pages;
}
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;
WebCore::Timer m_volatilityTimer;
#endif
- HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomContentProviders;
+ HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders;
WebCore::Color m_backgroundColor;
HashSet<unsigned> m_activeRenderingSuppressionTokens;
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);
+2016-01-31 Darin Adler <darin@apple.com>
+
+ 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 Commit Queue <commit-queue@webkit.org>
Unreviewed, rolling out r195911.
my $isDOMTypeRename = 0;
my %renames = (
# Renames go here in the form of:
- "deleteAllValues" => "deprecatedDeleteAllValues",
+ "CaseFoldingHash" => "ASCIICaseInsensitiveHash",
);
my %renamesContemplatedForTheFuture = (