Changeset 195911 in webkit


Ignore:
Timestamp:
Jan 30, 2016 1:53:47 PM (8 years ago)
Author:
Darin Adler
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.
Location:
trunk
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r195901 r195911  
     12016-01-30  Darin Adler  <darin@apple.com>
     2
     3        Replace CaseFoldingHash with ASCIICaseInsensitiveHash
     4        https://bugs.webkit.org/show_bug.cgi?id=153639
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * wtf/text/StringHash.h: Renamed CaseFoldingHash to ASCIICaseInsensitiveHash.
     9        (WTF::ASCIICaseInsensitiveHash::foldCase): Use toASCIILower.
     10        (WTF::ASCIICaseInsensitiveHash::equal): Use equalIgnoringASCIICase.
     11        Also added some assertions.
     12
     13        * wtf/text/StringImpl.cpp: Made the latin1CaseFoldTable private to this file,
     14        since it's no longer needed by CaseFoldingHash. Moved it up before its first use.
     15        (WTF::equalCompatibilityCaseless): Fixed typo in the name of this function.
     16        (WTF::equalCompatibiltyCaselessNonNull): Deleted.
     17
     18        * wtf/text/StringImpl.h: Removed declarations of latin1CaseFoldTable and
     19        equalCompatibiltyCaselessNonNull
     20
    1212016-01-29  Ada Chan  <adachan@apple.com>
    222
  • trunk/Source/WTF/wtf/text/StringHash.h

    r195743 r195911  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2012, 2013 Apple Inc. All rights reserved
     2 * Copyright (C) 2006-2008, 2012-2013, 2016 Apple Inc. All rights reserved
    33 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
    44 *
     
    3434    }
    3535
    36     // The hash() functions on StringHash and CaseFoldingHash do not support
     36    // The hash() functions on StringHash and ASCIICaseInsensitiveHash do not support
    3737    // null strings. get(), contains(), and add() on HashMap<String,..., StringHash>
    3838    // cause a null-pointer dereference when passed null strings.
     
    7272    };
    7373
    74     class CaseFoldingHash {
     74    class ASCIICaseInsensitiveHash {
    7575    public:
    7676        template<typename T> static inline UChar foldCase(T character)
    7777        {
    78             if (std::is_same<T, LChar>::value)
    79                 return StringImpl::latin1CaseFoldTable[character];
    80            
    81             return u_foldCase(character, U_FOLD_CASE_DEFAULT);
     78            return toASCIILower(character);
    8279        }
    8380
     
    106103        static inline unsigned hash(const char* data, unsigned length)
    107104        {
    108             return CaseFoldingHash::hash(reinterpret_cast<const LChar*>(data), length);
     105            return hash(reinterpret_cast<const LChar*>(data), length);
    109106        }
    110107       
     108        static inline bool equal(const StringImpl& a, const StringImpl& b)
     109        {
     110            return equalIgnoringASCIICase(a, b);
     111        }
    111112        static inline bool equal(const StringImpl* a, const StringImpl* b)
    112113        {
    113             return equalCompatibiltyCaselessNonNull(a, b);
     114            ASSERT(a);
     115            ASSERT(b);
     116            return equal(*a, *b);
    114117        }
    115118
    116119        static unsigned hash(const RefPtr<StringImpl>& key)
    117120        {
    118             return hash(*key);
     121            return hash(key.get());
    119122        }
    120123
     
    168171}
    169172
     173using WTF::ASCIICaseInsensitiveHash;
    170174using WTF::AlreadyHashed;
    171 using WTF::CaseFoldingHash;
    172175using WTF::StringHash;
    173176
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r195743 r195911  
    951951}
    952952
    953 static inline bool equalCompatibiltyCaseless(const LChar* a, const LChar* b, unsigned length)
     953// Table is based on ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt
     954static const UChar latin1CaseFoldTable[256] = {
     955    0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
     956    0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
     957    0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
     958    0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
     959    0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
     960    0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
     961    0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
     962    0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
     963    0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
     964    0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
     965    0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
     966    0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x03bc, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
     967    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
     968    0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00d7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00df,
     969    0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
     970    0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
     971};
     972
     973static inline bool equalCompatibilityCaseless(const LChar* a, const LChar* b, unsigned length)
    954974{
    955975    while (length--) {
    956         if (StringImpl::latin1CaseFoldTable[*a++] != StringImpl::latin1CaseFoldTable[*b++])
     976        if (latin1CaseFoldTable[*a++] != latin1CaseFoldTable[*b++])
    957977            return false;
    958978    }
     
    960980}
    961981
    962 static inline bool equalCompatibiltyCaseless(const UChar* a, const LChar* b, unsigned length)
     982static inline bool equalCompatibilityCaseless(const UChar* a, const LChar* b, unsigned length)
    963983{
    964984    while (length--) {
    965         if (u_foldCase(*a++, U_FOLD_CASE_DEFAULT) != StringImpl::latin1CaseFoldTable[*b++])
     985        if (u_foldCase(*a++, U_FOLD_CASE_DEFAULT) != latin1CaseFoldTable[*b++])
    966986            return false;
    967987    }
     
    969989}
    970990
    971 static inline bool equalCompatibiltyCaseless(const LChar* a, const UChar* b, unsigned length)
    972 {
    973     return equalCompatibiltyCaseless(b, a, length);
    974 }
    975 
    976 static inline bool equalCompatibiltyCaseless(const UChar* a, const UChar* b, unsigned length)
     991static inline bool equalCompatibilityCaseless(const LChar* a, const UChar* b, unsigned length)
     992{
     993    return equalCompatibilityCaseless(b, a, length);
     994}
     995
     996static inline bool equalCompatibilityCaseless(const UChar* a, const UChar* b, unsigned length)
    977997{
    978998    return !u_memcasecmp(a, b, length, U_FOLD_CASE_DEFAULT);
     
    10831103
    10841104        unsigned i = 0;
    1085         while (!equalCompatibiltyCaseless(searchCharacters + i, matchString, matchLength)) {
     1105        while (!equalCompatibilityCaseless(searchCharacters + i, matchString, matchLength)) {
    10861106            if (i == delta)
    10871107                return notFound;
     
    10941114
    10951115    unsigned i = 0;
    1096     while (!equalCompatibiltyCaseless(searchCharacters + i, matchString, matchLength)) {
     1116    while (!equalCompatibilityCaseless(searchCharacters + i, matchString, matchLength)) {
    10971117        if (i == delta)
    10981118            return notFound;
     
    11581178    unsigned i = 0;
    11591179    // keep looping until we match
    1160     while (!equalCompatibiltyCaseless(searchCharacters + i, matchCharacters, matchLength)) {
     1180    while (!equalCompatibilityCaseless(searchCharacters + i, matchCharacters, matchLength)) {
    11611181        if (i == delta)
    11621182            return notFound;
     
    12991319
    13001320    // keep looping until we match
    1301     while (!equalCompatibiltyCaseless(searchCharacters + delta, matchCharacters, matchLength)) {
     1321    while (!equalCompatibilityCaseless(searchCharacters + delta, matchCharacters, matchLength)) {
    13021322        if (!delta)
    13031323            return notFound;
     
    13451365    }
    13461366    if (stringImpl->is8Bit())
    1347         return equalCompatibiltyCaseless(stringImpl->characters8() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
    1348     return equalCompatibiltyCaseless(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
     1367        return equalCompatibilityCaseless(stringImpl->characters8() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
     1368    return equalCompatibilityCaseless(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
    13491369}
    13501370
     
    19191939}
    19201940
    1921 bool equalCompatibiltyCaselessNonNull(const StringImpl* a, const StringImpl* b)
    1922 {
    1923     ASSERT(a);
    1924     ASSERT(b);
    1925     if (a == b)
    1926         return true;
    1927 
    1928     unsigned length = a->length();
    1929     if (length != b->length())
    1930         return false;
    1931 
    1932     if (a->is8Bit()) {
    1933         if (b->is8Bit())
    1934             return equalCompatibiltyCaseless(a->characters8(), b->characters8(), length);
    1935 
    1936         return equalCompatibiltyCaseless(b->characters16(), a->characters8(), length);
    1937     }
    1938 
    1939     if (b->is8Bit())
    1940         return equalCompatibiltyCaseless(a->characters16(), b->characters8(), length);
    1941 
    1942     return equalCompatibiltyCaseless(a->characters16(), b->characters16(), length);
    1943 }
    1944 
    19451941bool equalIgnoringNullity(StringImpl* a, StringImpl* b)
    19461942{
     
    21422138}
    21432139
    2144 // Table is based on ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt
    2145 const UChar StringImpl::latin1CaseFoldTable[256] = {
    2146     0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
    2147     0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
    2148     0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
    2149     0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
    2150     0x0040, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
    2151     0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
    2152     0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
    2153     0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
    2154     0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
    2155     0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
    2156     0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
    2157     0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x03bc, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
    2158     0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
    2159     0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00d7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00df,
    2160     0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
    2161     0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
    2162 };
    2163 
    21642140bool equalIgnoringNullity(const UChar* a, size_t aLength, StringImpl* b)
    21652141{
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r195743 r195911  
    763763#endif
    764764
    765     WTF_EXPORT_STRING_API static const UChar latin1CaseFoldTable[256];
    766 
    767765    Ref<StringImpl> extractFoldedStringInSymbol()
    768766    {
     
    947945WTF_EXPORT_STRING_API bool equal(const StringImpl& a, const StringImpl& b);
    948946
    949 // FIXME: Deprecated. Used only by CaseFoldingHash, which itself is soon to be deprecated and removed, replaced by ASCIICaseFoldingHash.
    950 WTF_EXPORT_STRING_API bool equalCompatibiltyCaselessNonNull(const StringImpl*, const StringImpl*);
    951 
    952947WTF_EXPORT_STRING_API bool equalIgnoringNullity(StringImpl*, StringImpl*);
    953948WTF_EXPORT_STRING_API bool equalIgnoringNullity(const UChar*, size_t length, StringImpl*);
  • trunk/Source/WebCore/ChangeLog

    r195909 r195911  
     12016-01-30  Darin Adler  <darin@apple.com>
     2
     3        Replace CaseFoldingHash with ASCIICaseInsensitiveHash
     4        https://bugs.webkit.org/show_bug.cgi?id=153639
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * Modules/webdatabase/DatabaseAuthorizer.h: Use ASCIICaseInsensitiveHash
     9        for whitelisted functions. Function names are all ASCII.
     10
     11        * accessibility/AccessibilityObject.cpp: Use ASCIICaseInsensitiveHash
     12        for ARIA roles. ARIA roles are all ASCII.
     13
     14        * crypto/CryptoAlgorithmRegistry.h: Use ASCIICaseInsensitiveHash for
     15        crypto algorithm names. Algorithm names are all ASCII.
     16
     17        * css/CSSFontSelector.cpp:
     18        (WebCore::registerLocalFontFacesForFamily): Use ASCIICaseInsensitiveHash
     19        for font faces. Face names should use ASCII case insensitive matching;
     20        there is no need for non-ASCII case folding.
     21        * css/CSSFontSelector.h: Ditto.
     22
     23        * dom/DOMImplementation.cpp: Use ASCIICaseInsensitiveHash for the
     24        FeatureSet. The features are all ASCII.
     25
     26        * dom/Document.h: Use ASCIICaseInsensitiveHash for the access key
     27        map. Access keys are all ASCII.
     28
     29        * dom/ScriptElement.cpp:
     30        (WebCore::isLegacySupportedJavaScriptLanguage): Use ASCIICaseInsensitiveHash
     31        for the language set. These strings are all ASCII.
     32
     33        * editing/EditorCommand.cpp: Use ASCIICaseInsensitiveHash for editor
     34        command names. These names are all ASCII.
     35
     36        * html/HTMLObjectElement.cpp:
     37        (WebCore::HTMLObjectElement::parametersForPlugin): Use ASCIICaseInsensitiveHash
     38        for parameter names. These names are all ASCII.
     39
     40        * html/InputType.cpp: Use ASCIICaseInsensitiveHash for the input types.
     41        The input types are all ASCII.
     42
     43        * loader/CrossOriginAccessControl.h: Use ASCIICaseInsensitiveHash for
     44        HTTP header field names. These names are all ASCII.
     45        * loader/CrossOriginPreflightResultCache.h: Ditto.
     46
     47        * loader/archive/ArchiveFactory.cpp: Use ASCIICaseInsensitiveHash for
     48        MIME types. MIME types are all ASCII.
     49        * platform/MIMETypeRegistry.cpp:
     50        (WebCore::initializeSupportedImageMIMETypes): Ditto.
     51
     52        * platform/SchemeRegistry.h: Use ASCIICaseInsensitiveHas for URL schemes.
     53        URL schemes are all ASCII.
     54        * platform/URL.cpp: Ditto.
     55
     56        * platform/graphics/FontCache.cpp: Reworked FontPlatformDataCacheKey struct:
     57        Made it a conventional struct with non-prefixed data members names. Removed
     58        the "==" operator since it was appropriate for hash table lookup but wasn't
     59        a true equality operator. Tightened the implementations of the constructors.
     60        (WebCore::FontPlatformDataCacheKeyHash::hash): Use ASCIICaseInsensitiveHash.
     61        (WebCore::FontPlatformDataCacheKeyHash::equal): Do the equality check here,
     62        not using the == operator. And use equalIgnoringASCIICase.
     63        (WebCore::FontPlatformDataCacheKeyTraits::isEmptyValue): Added this entire
     64        traits struct so we check empty values in a more efficient way.
     65        (WebCore::FontCache::getCachedFontPlatformData): Added comments and tweaked
     66        style in this function.
     67
     68        * platform/graphics/FontCascade.cpp:
     69        (WebCore::keysMatch): Rename from operator== since this operation is not
     70        equality. Changed to equalIgnoringASCIICase and did a little streamlining.
     71        (WebCore::makeFontCascadeCacheKey): Use reserveInitialCapacity for slightly
     72        better memory use.
     73        (WebCore::computeFontCascadeCacheHash): Use IntegerHasher to make computing
     74        a hash more efficient by eliminating the overhead of building a vector and
     75        even possible heap allocation and deallocation.
     76        (WebCore::retrieveOrAddCachedFonts): Use keysMatch instead of ==.
     77
     78        * platform/graphics/cocoa/FontCacheCoreText.cpp: Use ASCIICaseInsensitiveHash
     79        for font family names. These names should use ASCII case insensitive matching;
     80        there is no need for non-ASCII case folding.
     81
     82        * platform/network/HTTPHeaderMap.h: Use ASCIICaseInsensitiveHash for
     83        HTTP header field names. These names are all ASCII.
     84
     85        * rendering/style/RenderStyle.cpp:
     86        (WebCore::computeFontHash): Use IntegerHasher to avoid allocating memory just
     87        to compute a hash. Use ASCIICaseInsensitiveHash.
     88
    1892016-01-30  Chris Dumez  <cdumez@apple.com>
    290
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseAuthorizer.h

    r177874 r195911  
    118118    const String m_databaseInfoTableName;
    119119
    120     HashSet<String, CaseFoldingHash> m_whitelistedFunctions;
     120    HashSet<String, ASCIICaseInsensitiveHash> m_whitelistedFunctions;
    121121};
    122122
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r195463 r195911  
    19891989}
    19901990
    1991 typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap;
     1991typedef HashMap<String, AccessibilityRole, ASCIICaseInsensitiveHash> ARIARoleMap;
    19921992typedef HashMap<AccessibilityRole, String, DefaultHash<int>::Hash, WTF::UnsignedWithZeroKeyHashTraits<int>> ARIAReverseRoleMap;
    19931993
  • trunk/Source/WebCore/crypto/CryptoAlgorithmRegistry.h

    r179409 r195911  
    6666    void registerAlgorithm(const String& name, CryptoAlgorithmIdentifier, CryptoAlgorithmConstructor);
    6767
    68     HashMap<String, CryptoAlgorithmIdentifier, CaseFoldingHash> m_nameToIdentifierMap;
     68    HashMap<String, CryptoAlgorithmIdentifier, ASCIICaseInsensitiveHash> m_nameToIdentifierMap;
    6969    HashMap<unsigned, String> m_identifierToNameMap;
    7070    HashMap<unsigned, CryptoAlgorithmConstructor> m_identifierToConstructorMap;
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r195523 r195911  
    225225}
    226226
    227 static void registerLocalFontFacesForFamily(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash>& locallyInstalledFontFaces)
     227static void registerLocalFontFacesForFamily(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash>& locallyInstalledFontFaces)
    228228{
    229229    ASSERT(!locallyInstalledFontFaces.contains(familyName));
  • trunk/Source/WebCore/css/CSSFontSelector.h

    r194923 r195911  
    8787
    8888    Document* m_document;
    89     HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash> m_fontFaces;
    90     HashMap<String, Vector<Ref<CSSFontFace>>, CaseFoldingHash> m_locallyInstalledFontFaces;
    91     HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace>>, CaseFoldingHash> m_fonts;
     89    HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_fontFaces;
     90    HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_locallyInstalledFontFaces;
     91    HashMap<String, HashMap<unsigned, RefPtr<CSSSegmentedFontFace>>, ASCIICaseInsensitiveHash> m_fonts;
    9292    HashSet<FontSelectorClient*> m_clients;
    9393
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r195520 r195911  
    6565using namespace HTMLNames;
    6666
    67 typedef HashSet<String, CaseFoldingHash> FeatureSet;
     67typedef HashSet<String, ASCIICaseInsensitiveHash> FeatureSet;
    6868
    6969static void addString(FeatureSet& set, const char* string)
  • trunk/Source/WebCore/dom/Document.h

    r195790 r195911  
    16141614#endif
    16151615
    1616     HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
     1616    HashMap<StringImpl*, Element*, ASCIICaseInsensitiveHash> m_elementsByAccessKey;
    16171617    bool m_accessKeyMapValid;
    16181618
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r195452 r195911  
    119119
    120120    // FIXME: This function is not HTML5 compliant. These belong in the MIME registry as "text/javascript<version>" entries.
    121     typedef HashSet<String, CaseFoldingHash> LanguageSet;
     121    typedef HashSet<String, ASCIICaseInsensitiveHash> LanguageSet;
    122122    static NeverDestroyed<LanguageSet> languages;
    123123    if (languages.get().isEmpty()) {
  • trunk/Source/WebCore/editing/EditorCommand.cpp

    r195452 r195911  
    7878};
    7979
    80 typedef HashMap<String, const EditorInternalCommand*, CaseFoldingHash> CommandMap;
     80typedef HashMap<String, const EditorInternalCommand*, ASCIICaseInsensitiveHash> CommandMap;
    8181
    8282static const bool notTextInsertion = false;
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r195452 r195911  
    167167void HTMLObjectElement::parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType)
    168168{
    169     HashSet<StringImpl*, CaseFoldingHash> uniqueParamNames;
     169    HashSet<StringImpl*, ASCIICaseInsensitiveHash> uniqueParamNames;
    170170    String urlParameter;
    171171   
  • trunk/Source/WebCore/html/InputType.cpp

    r195452 r195911  
    8787typedef const AtomicString& (*InputTypeNameFunction)();
    8888typedef std::unique_ptr<InputType> (*InputTypeFactoryFunction)(HTMLInputElement&);
    89 typedef HashMap<AtomicString, InputTypeFactoryFunction, CaseFoldingHash> InputTypeFactoryMap;
     89typedef HashMap<AtomicString, InputTypeFactoryFunction, ASCIICaseInsensitiveHash> InputTypeFactoryMap;
    9090
    9191template<class T>
  • trunk/Source/WebCore/loader/CrossOriginAccessControl.h

    r175231 r195911  
    3535namespace WebCore {
    3636
    37 typedef HashSet<String, CaseFoldingHash> HTTPHeaderSet;
     37typedef HashSet<String, ASCIICaseInsensitiveHash> HTTPHeaderSet;
    3838
    3939class HTTPHeaderMap;
  • trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h

    r179409 r195911  
    6060    StoredCredentials m_credentials;
    6161    HashSet<String> m_methods;
    62     HashSet<String, CaseFoldingHash> m_headers;
     62    HashSet<String, ASCIICaseInsensitiveHash> m_headers;
    6363};
    6464
  • trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp

    r191369 r195911  
    4848
    4949typedef PassRefPtr<Archive> RawDataCreationFunction(const URL&, SharedBuffer*);
    50 typedef HashMap<String, RawDataCreationFunction*, CaseFoldingHash> ArchiveMIMETypesMap;
     50typedef HashMap<String, RawDataCreationFunction*, ASCIICaseInsensitiveHash> ArchiveMIMETypesMap;
    5151
    5252// The create functions in the archive classes return PassRefPtr to concrete subclasses
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r194819 r195911  
    151151static HashSet<String>* unsupportedTextMIMETypes;
    152152
    153 typedef HashMap<String, Vector<String>*, CaseFoldingHash> MediaMIMETypeMap;
     153typedef HashMap<String, Vector<String>*, ASCIICaseInsensitiveHash> MediaMIMETypeMap;
    154154   
    155155static void initializeSupportedImageMIMETypes()
  • trunk/Source/WebCore/platform/SchemeRegistry.h

    r194880 r195911  
    3333namespace WebCore {
    3434
    35 typedef HashSet<String, CaseFoldingHash> URLSchemesMap;
     35typedef HashSet<String, ASCIICaseInsensitiveHash> URLSchemesMap;
    3636
    3737class SchemeRegistry {
  • trunk/Source/WebCore/platform/URL.cpp

    r195743 r195911  
    19911991}
    19921992
    1993 typedef HashMap<String, unsigned short, CaseFoldingHash> DefaultPortsMap;
     1993typedef HashMap<String, unsigned short, ASCIICaseInsensitiveHash> DefaultPortsMap;
    19941994static const DefaultPortsMap& defaultPortsMap()
    19951995{
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r195743 r195911  
    9898
    9999struct FontPlatformDataCacheKey {
    100     WTF_MAKE_FAST_ALLOCATED;
    101 public:
    102     FontPlatformDataCacheKey() { }
     100    AtomicString family;
     101    FontDescriptionKey description;
     102
     103    FontPlatformDataCacheKey() = default;
    103104    FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description)
    104         : m_fontDescriptionKey(description)
    105         , m_family(family)
    106     { }
    107 
    108     explicit FontPlatformDataCacheKey(HashTableDeletedValueType t)
    109         : m_fontDescriptionKey(t)
    110     { }
    111 
    112     bool isHashTableDeletedValue() const { return m_fontDescriptionKey.isHashTableDeletedValue(); }
    113 
    114     bool operator==(const FontPlatformDataCacheKey& other) const
    115     {
    116         if (m_fontDescriptionKey != other.m_fontDescriptionKey)
    117             return false;
    118         if (m_family.impl() == other.m_family.impl())
    119             return true;
    120         if (m_family.isNull() || other.m_family.isNull())
    121             return false;
    122         return CaseFoldingHash::equal(m_family, other.m_family);
    123     }
    124 
    125     FontDescriptionKey m_fontDescriptionKey;
    126     AtomicString m_family;
     105        : family(family), description(description)
     106    {
     107    }
     108
     109    explicit FontPlatformDataCacheKey(HashTableDeletedValueType)
     110        : description(HashTableDeletedValue)
     111    {
     112    }
     113    bool isHashTableDeletedValue() const
     114    {
     115        return description.isHashTableDeletedValue();
     116    }
    127117};
    128118
    129119struct FontPlatformDataCacheKeyHash {
    130     static unsigned hash(const FontPlatformDataCacheKey& fontKey)
    131     {
    132         return pairIntHash(CaseFoldingHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash());
    133     }
    134          
     120    static unsigned hash(const FontPlatformDataCacheKey& key)
     121    {
     122        return pairIntHash(ASCIICaseInsensitiveHash::hash(key.family), key.description.computeHash());
     123    }
    135124    static bool equal(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b)
    136125    {
    137         return a == b;
    138     }
    139 
     126        return a.description == b.description && equalIgnoringASCIICase(a.family, b.family);
     127    }
    140128    static const bool safeToCompareToEmptyOrDeleted = true;
    141129};
    142130
    143 typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, WTF::SimpleClassHashTraits<FontPlatformDataCacheKey>> FontPlatformDataCache;
     131struct FontPlatformDataCacheKeyTraits : SimpleClassHashTraits<FontPlatformDataCacheKey> {
     132    static const bool hasIsEmptyValueFunction = true;
     133    static bool isEmptyValue(const FontPlatformDataCacheKey& key)
     134    {
     135        return key.family.isNull();
     136    }
     137};
     138
     139typedef HashMap<FontPlatformDataCacheKey, std::unique_ptr<FontPlatformData>, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
    144140
    145141static FontPlatformDataCache& fontPlatformDataCache()
     
    208204}
    209205
    210 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription,
    211                                                        const AtomicString& passedFamilyName,
    212                                                       bool checkingAlternateName)
     206// FIXME: This function name should not have the word "get" in it for WebKit coding style.
     207// FIXME: The boolean here is poor coding style. Easy to factor this into two functions so we don't need it.
     208FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, const AtomicString& passedFamilyName, bool checkingAlternateName)
    213209{
    214210#if PLATFORM(IOS)
     
    219215    // Leading "@" in the font name enables Windows vertical flow flag for the font.
    220216    // Because we do vertical flow by ourselves, we don't want to use the Windows feature.
    221     // IE disregards "@" regardless of the orientatoin, so we follow the behavior.
    222     const AtomicString& familyName = (passedFamilyName.isEmpty() || passedFamilyName[0] != '@') ?
    223         passedFamilyName : AtomicString(passedFamilyName.impl()->substring(1));
     217    // IE disregards "@" regardless of the orientation, so we follow the behavior.
     218    const AtomicString& familyName = passedFamilyName[0] != '@'
     219        ? passedFamilyName : AtomicString(passedFamilyName.impl()->substring(1));
    224220#else
    225221    const AtomicString& familyName = passedFamilyName;
     
    238234    if (addResult.isNewEntry) {
    239235        it->value = createFontPlatformData(fontDescription, familyName);
    240 
    241236        if (!it->value && !checkingAlternateName) {
    242             // We were unable to find a font.  We have a small set of fonts that we alias to other names,
    243             // e.g., Arial/Helvetica, Courier/Courier New, etc.  Try looking up the font under the aliased name.
    244             const AtomicString alternateName = alternateFamilyName(familyName);
     237            // We were unable to find a font. We have a small set of fonts that we alias to other names,
     238            // e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
     239            auto alternateName = alternateFamilyName(familyName);
    245240            if (!alternateName.isNull()) {
    246241                FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);
    247                 // Lookup the key in the hash table again as the previous iterator may have
     242                // Look up the key in the hash table again as the previous iterator may have
    248243                // been invalidated by the recursive call to getCachedFontPlatformData().
    249244                it = fontPlatformDataCache().find(key);
  • trunk/Source/WebCore/platform/graphics/FontCascade.cpp

    r195743 r195911  
    191191};
    192192
     193// FIXME: Should make hash traits for FontCascadeCacheKey instead of using a hash as the key (so we hash a hash).
    193194typedef HashMap<unsigned, std::unique_ptr<FontCascadeCacheEntry>, AlreadyHashed> FontCascadeCache;
    194195
    195 static bool operator==(const FontCascadeCacheKey& a, const FontCascadeCacheKey& b)
     196static bool keysMatch(const FontCascadeCacheKey& a, const FontCascadeCacheKey& b)
    196197{
    197198    if (a.fontDescriptionKey != b.fontDescriptionKey)
     
    199200    if (a.fontSelectorId != b.fontSelectorId || a.fontSelectorVersion != b.fontSelectorVersion)
    200201        return false;
    201     if (a.families.size() != b.families.size())
    202         return false;
    203     for (unsigned i = 0; i < a.families.size(); ++i) {
    204         auto* aImpl = a.families[i].impl();
    205         auto* bImpl = b.families[i].impl();
    206         if (aImpl == bImpl)
    207             continue;
    208         if (!aImpl || !bImpl || !CaseFoldingHash::equal(aImpl, bImpl))
     202    unsigned size = a.families.size();
     203    if (size != b.families.size())
     204        return false;
     205    for (unsigned i = 0; i < size; ++i) {
     206        if (!equalIgnoringASCIICase(a.families[i], b.families[i]))
    209207            return false;
    210208    }
     
    233231    FontCascadeCacheKey key;
    234232    key.fontDescriptionKey = FontDescriptionKey(description);
    235     for (unsigned i = 0; i < description.familyCount(); ++i)
    236         key.families.append(description.familyAt(i));
     233    unsigned familyCount = description.familyCount();
     234    key.families.reserveInitialCapacity(familyCount);
     235    for (unsigned i = 0; i < familyCount; ++i)
     236        key.families.uncheckedAppend(description.familyAt(i));
    237237    key.fontSelectorId = fontSelector ? fontSelector->uniqueId() : 0;
    238238    key.fontSelectorVersion = fontSelector ? fontSelector->version() : 0;
     
    240240}
    241241
    242 // FIXME: Why can't we just teach HashMap about FontCascadeCacheKey instead of hashing a hash?
    243242static unsigned computeFontCascadeCacheHash(const FontCascadeCacheKey& key)
    244243{
    245     Vector<unsigned, 7> hashCodes;
    246     hashCodes.reserveInitialCapacity(4 + key.families.size());
    247 
    248     hashCodes.uncheckedAppend(key.fontDescriptionKey.computeHash());
    249     hashCodes.uncheckedAppend(key.fontSelectorId);
    250     hashCodes.uncheckedAppend(key.fontSelectorVersion);
    251     for (unsigned i = 0; i < key.families.size(); ++i)
    252         hashCodes.uncheckedAppend(key.families[i].impl() ? CaseFoldingHash::hash(key.families[i]) : 0);
    253 
    254     return StringHasher::hashMemory(hashCodes.data(), hashCodes.size() * sizeof(unsigned));
     244    // FIXME: Should hash the key and the family name characters rather than making a hash out of other hashes.
     245    IntegerHasher hasher;
     246    hasher.add(key.fontDescriptionKey.computeHash());
     247    hasher.add(key.fontSelectorId);
     248    hasher.add(key.fontSelectorVersion);
     249    for (unsigned i = 0; i < key.families.size(); ++i) {
     250        StringImpl* family = key.families[i].impl();
     251        hasher.add(family ? ASCIICaseInsensitiveHash::hash(family) : 0);
     252    }
     253    return hasher.hash();
    255254}
    256255
     
    273272
    274273    unsigned hash = computeFontCascadeCacheHash(key);
    275     auto addResult = fontCascadeCache().add(hash, std::unique_ptr<FontCascadeCacheEntry>());
    276     if (!addResult.isNewEntry && addResult.iterator->value->key == key)
     274    auto addResult = fontCascadeCache().add(hash, nullptr);
     275    if (!addResult.isNewEntry && keysMatch(addResult.iterator->value->key, key))
    277276        return addResult.iterator->value->fonts.get();
    278277
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r195452 r195911  
    646646}
    647647
    648 typedef HashSet<String, CaseFoldingHash> Whitelist;
     648typedef HashSet<String, ASCIICaseInsensitiveHash> Whitelist;
    649649static Whitelist& fontWhitelist()
    650650{
  • trunk/Source/WebCore/platform/network/HTTPHeaderMap.h

    r195530 r195911  
    4949public:
    5050    typedef HashMap<HTTPHeaderName, String, WTF::IntHash<HTTPHeaderName>, WTF::StrongEnumHashTraits<HTTPHeaderName>> CommonHeadersHashMap;
    51     typedef HashMap<String, String, CaseFoldingHash> UncommonHeadersHashMap;
     51    typedef HashMap<String, String, ASCIICaseInsensitiveHash> UncommonHeadersHashMap;
    5252
    5353    class HTTPHeaderMapConstIterator {
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r195892 r195911  
    367367
    368368#if ENABLE(IOS_TEXT_AUTOSIZING)
    369 inline unsigned computeFontHash(const FontCascade& font)
    370 {
    371     unsigned hashCodes[2] = {
    372         CaseFoldingHash::hash(font.fontDescription().firstFamily().impl()),
    373         static_cast<unsigned>(font.fontDescription().specifiedSize())
    374     };
    375     return StringHasher::computeHash(reinterpret_cast<UChar*>(hashCodes), 2 * sizeof(unsigned) / sizeof(UChar));
    376 }
    377 
    378 uint32_t RenderStyle::hashForTextAutosizing() const
     369
     370static inline unsigned computeFontHash(const FontCascade& font)
     371{
     372    IntegerHasher hasher;
     373    hasher.add(ASCIICaseInsensitiveHash::hash(font.fontDescription().firstFamily()));
     374    hasher.add(font.fontDescription().specifiedSize());
     375    return hasher.hash();
     376}
     377
     378unsigned RenderStyle::hashForTextAutosizing() const
    379379{
    380380    // FIXME: Not a very smart hash. Could be improved upon. See <https://bugs.webkit.org/show_bug.cgi?id=121131>.
    381     uint32_t hash = 0;
    382    
    383     hash ^= rareNonInheritedData->m_appearance;
     381    unsigned hash = rareNonInheritedData->m_appearance;
    384382    hash ^= rareNonInheritedData->marginBeforeCollapse;
    385383    hash ^= rareNonInheritedData->marginAfterCollapse;
     
    422420        && rareNonInheritedData->textOverflow == other->rareNonInheritedData->textOverflow;
    423421}
     422
    424423#endif // ENABLE(IOS_TEXT_AUTOSIZING)
    425424
  • trunk/Source/WebKit/win/ChangeLog

    r195828 r195911  
     12016-01-30  Darin Adler  <darin@apple.com>
     2
     3        Replace CaseFoldingHash with ASCIICaseInsensitiveHash
     4        https://bugs.webkit.org/show_bug.cgi?id=153639
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * WebCoreStatistics.cpp:
     9        (WebCoreStatistics::memoryStatistics): Use ASCIICaseInsensitiveHash for field names.
     10        These names are all ASCII.
     11
     12        * WebURLResponse.cpp:
     13        (WebURLResponse::allHeaderFields): Use ASCIICaseInsensitiveHash for HTTP header
     14        field names. These names are all ASCII.
     15
    1162016-01-29  Ryan Haddad  <ryanhaddad@apple.com>
    217
  • trunk/Source/WebKit/win/WebCoreStatistics.cpp

    r188662 r195911  
    296296    GlobalMemoryStatistics globalMemoryStats = globalMemoryStatistics();
    297297
    298     HashMap<String, unsigned long long, CaseFoldingHash> fields;
     298    HashMap<String, unsigned long long, ASCIICaseInsensitiveHash> fields;
    299299    fields.add("FastMallocReservedVMBytes", static_cast<unsigned long long>(fastMallocStatistics.reservedVMBytes));
    300300    fields.add("FastMallocCommittedVMBytes", static_cast<unsigned long long>(fastMallocStatistics.committedVMBytes));
     
    305305    fields.add("JavaScriptJITSize", static_cast<unsigned long long>(globalMemoryStats.JITBytes));
    306306
    307     *statistics = COMPropertyBag<unsigned long long, String, CaseFoldingHash>::adopt(fields);
     307    *statistics = COMPropertyBag<unsigned long long, String, ASCIICaseInsensitiveHash>::adopt(fields);
    308308
    309309    return S_OK;
  • trunk/Source/WebKit/win/WebURLResponse.cpp

    r188703 r195911  
    363363        return E_POINTER;
    364364
    365     HashMap<String, String, CaseFoldingHash> fields;
     365    HashMap<String, String, ASCIICaseInsensitiveHash> fields;
    366366    for (const auto& keyValuePair : m_response.httpHeaderFields())
    367367        fields.add(keyValuePair.key, keyValuePair.value);
    368368
    369     *headerFields = COMPropertyBag<String, String, CaseFoldingHash>::adopt(fields);
     369    *headerFields = COMPropertyBag<String, String, ASCIICaseInsensitiveHash>::adopt(fields);
    370370    return S_OK;
    371371}
  • trunk/Source/WebKit2/ChangeLog

    r195902 r195911  
     12016-01-30  Darin Adler  <darin@apple.com>
     2
     3        Replace CaseFoldingHash with ASCIICaseInsensitiveHash
     4        https://bugs.webkit.org/show_bug.cgi?id=153639
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use ASCIICaseInsensitiveHash
     9        for MIME types. MIME types are all ASCII.
     10
     11        * UIProcess/Plugins/PlugInAutoStartProvider.h: Use ASCIICaseInsensitiveHash for
     12        origins. Origin strings should use ASCII case insensitive matching and should not
     13        fold non-ASCII case.
     14
     15        * WebProcess/WebPage/WebPage.h: Use ASCIICaseInsensitiveHash for MIME types.
     16        MIME types are all ASCII.
     17
     18        * WebProcess/WebProcess.cpp:
     19        (WebKit::addCaseFoldedCharacters): Use ASCIICaseInsensitiveHash to hash plug-in
     20        origin strings. (See rationale above.)
     21        (WebKit::hashForPlugInOrigin): Updated comment.
     22
    1232016-01-30  Jeremy Huddleston Sequoia  <jeremyhu@apple.com>
    224
  • trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm

    r170570 r195911  
    4343
    4444@implementation WKWebViewContentProviderRegistry {
    45     HashMap<String, Class <WKWebViewContentProvider>, CaseFoldingHash> _contentProviderForMIMEType;
     45    HashMap<String, Class <WKWebViewContentProvider>, ASCIICaseInsensitiveHash> _contentProviderForMIMEType;
    4646    HashCountedSet<WebPageProxy*> _pages;
    4747}
  • trunk/Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h

    r183412 r195911  
    7070    void setAutoStartOriginsTableWithItemsPassingTest(API::Dictionary&, std::function<bool(double expirationTimestamp)>);
    7171
    72     typedef HashMap<String, PlugInAutoStartOriginMap, CaseFoldingHash> AutoStartTable;
     72    typedef HashMap<String, PlugInAutoStartOriginMap, ASCIICaseInsensitiveHash> AutoStartTable;
    7373    typedef HashMap<WebCore::SessionID, AutoStartTable> SessionAutoStartTable;
    7474    SessionAutoStartTable m_autoStartTable;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r195755 r195911  
    13941394#endif
    13951395
    1396     HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomContentProviders;
     1396    HashSet<String, ASCIICaseInsensitiveHash> m_mimeTypesWithCustomContentProviders;
    13971397    WebCore::Color m_backgroundColor;
    13981398
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r195589 r195911  
    722722        return;
    723723    if (string.is8Bit()) {
    724         hasher.addCharacters<LChar, CaseFoldingHash::foldCase<LChar>>(string.characters8(), string.length());
    725         return;
    726     }
    727     hasher.addCharacters<UChar, CaseFoldingHash::foldCase<UChar>>(string.characters16(), string.length());
     724        hasher.addCharacters<LChar, ASCIICaseInsensitiveHash::foldCase<LChar>>(string.characters8(), string.length());
     725        return;
     726    }
     727    hasher.addCharacters<UChar, ASCIICaseInsensitiveHash::foldCase<UChar>>(string.characters16(), string.length());
    728728}
    729729
     
    731731{
    732732    // We want to avoid concatenating the strings and then taking the hash, since that could lead to an expensive conversion.
    733     // We also want to avoid using the hash() function in StringImpl or CaseFoldingHash because that masks out bits for the use of flags.
     733    // We also want to avoid using the hash() function in StringImpl or ASCIICaseInsensitiveHash because that masks out bits for the use of flags.
    734734    StringHasher hasher;
    735735    addCaseFoldedCharacters(hasher, pageOrigin);
  • trunk/Tools/ChangeLog

    r195899 r195911  
     12016-01-30  Darin Adler  <darin@apple.com>
     2
     3        Replace CaseFoldingHash with ASCIICaseInsensitiveHash
     4        https://bugs.webkit.org/show_bug.cgi?id=153639
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * Scripts/do-webcore-rename: Use script to do this rename.
     9
    1102016-01-30  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/Tools/Scripts/do-webcore-rename

    r195743 r195911  
    9999my %renames = (
    100100    # Renames go here in the form of:
    101     "deleteAllValues" => "deprecatedDeleteAllValues",
     101    "CaseFoldingHash" => "ASCIICaseInsensitiveHash",
    102102);
    103103
Note: See TracChangeset for help on using the changeset viewer.