Changeset 196223 in webkit


Ignore:
Timestamp:
Feb 6, 2016 3:18:47 PM (8 years ago)
Author:
Darin Adler
Message:

Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
https://bugs.webkit.org/show_bug.cgi?id=153905

Reviewed by Sam Weinig.

Source/JavaScriptCore:

  • runtime/IntlObject.cpp:

(JSC::canonicalLangTag): Use converToASCIIUppercase on the language tag.

  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncToLowerCase): Tweak style and update for name change.
(JSC::stringProtoFuncToUpperCase): Ditto.

Source/WebCore:

  • Modules/mediasource/MediaSource.cpp:

(WebCore::MediaSource::isTypeSupported): Use convertToASCIILowercase on MIME type.

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::selectText): Use new names for lower and upper. Also
tweaked style a tiny bit and used u_toupper rather than converting an entire
string to uppercase.

  • dom/Document.cpp:

(WebCore::Document::addImageElementByCaseFoldedUsemap): Renamed to reflect the use
of case folding rather than lowercasing.
(WebCore::Document::removeImageElementByCaseFoldedUsemap): Ditto.
(WebCore::Document::imageElementByCaseFoldedUsemap): Ditto.

  • dom/Document.h: Ditto.
  • dom/DocumentOrderedMap.cpp:

(WebCore::DocumentOrderedMap::getElementByCaseFoldedMapName): Ditto.
(WebCore::DocumentOrderedMap::getElementByCaseFoldedUsemap): Ditto.

  • dom/DocumentOrderedMap.h: Ditto.
  • dom/TreeScope.cpp:

(WebCore::TreeScope::getImageMap): Removed unneeded special case for null string.
Simplified logic for cases where the URL does not have a "#" character in it.
Use case folding instead of lowercase.

  • editing/cocoa/HTMLConverter.mm:

(HTMLConverter::_processText): Removed unneded special case for the empty string.
Use makCapitalized instead of Cocoa function for "capitalize". Use upper and lower
functions by their new names.

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::parseAttribute): Use case folding instead of
lowerasing for the usemap attribute.
(WebCore::HTMLImageElement::insertedInto): Ditto.
(WebCore::HTMLImageElement::removedFrom): Ditto.
(WebCore::HTMLImageElement::matchesCaseFoldedUsemap): Ditto.

  • html/HTMLImageElement.h: Rename since usemap is case folded now, not lowercased.
  • html/HTMLMapElement.cpp:

(WebCore::HTMLMapElement::imageElement): Use case folding instead of lowercasing
for usemap.
(WebCore::HTMLMapElement::parseAttribute): Ditto.

  • platform/Language.cpp:

(WebCore::canonicalLanguageIdentifier): Use convertToASCIILowercase for language code.
(WebCore::indexOfBestMatchingLanguageInList): Ditto.

  • platform/graphics/harfbuzz/HarfBuzzShaper.cpp:

(WebCore::HarfBuzzShaper::shapeHarfBuzzRuns): Use new name for the upper function.

  • platform/network/HTTPParsers.cpp:

(WebCore::parseContentTypeOptionsHeader): Use equalLettersIgnoringASCIICase instead
of lowercasing to check for a specific header value.

  • platform/network/MIMEHeader.cpp:

(WebCore::retrieveKeyValuePairs): Use convertToASCIILowercase for MIME header name.
(WebCore::MIMEHeader::parseContentTransferEncoding): Use equalLettersIgnoringASCIICase
instead of lowercasing.

  • platform/network/cf/ResourceHandleCFNet.cpp:

(WebCore::allowsAnyHTTPSCertificateHosts): Make this hash ASCII case-insensitive.
(WebCore::clientCertificates): Ditto.
(WebCore::ResourceHandle::createCFURLConnection): Remove call to lower since the
set is now ASCII case-insensitive.
(WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Ditto.
(WebCore::ResourceHandle::setClientCertificate): Ditto.

  • platform/network/curl/CookieJarCurl.cpp:

(WebCore::getNetscapeCookieFormat): Use equalLettersIgnoringASCIICase instead of
lowercasing.

  • platform/network/curl/MultipartHandle.cpp:

(WebCore::MultipartHandle::didReceiveResponse): Use convertToASCIILowercase to
make a MIME type lowercase.

  • platform/network/curl/ResourceHandleCurl.cpp:

(WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Removed unneeded
conversion to lowercase now that the set is ASCII case-insensitive.
(WebCore::ResourceHandle::setClientCertificate): Removed code that populates a map
that is then never used for anything.

  • platform/network/curl/ResourceHandleManager.cpp:

(WebCore::headerCallback): Use convertToASCIILowercase for MIME type.

  • platform/network/curl/SSLHandle.cpp: Made hash maps keyed by host names

ASCII case-insensitive.
(WebCore::addAllowedClientCertificate): Removed lowercasing since the map itself
is now ASCII case insensitve.
(WebCore::setSSLClientCertificate): Ditto. Also use auto for iterator type so we
don't have to write out the map type.
(WebCore::sslIgnoreHTTPSCertificate): Ditto.
(WebCore::certVerifyCallback): Ditto.

  • platform/network/soup/ResourceHandleSoup.cpp: Made hash maps keyed by host names

ASCII case-insensitive.
(WebCore::allowsAnyHTTPSCertificateHosts): Ditto.
(WebCore::handleUnignoredTLSErrors): Ditto.
(WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Ditto.
(WebCore::ResourceHandle::setClientCertificate): Ditto.

  • platform/text/LocaleToScriptMappingDefault.cpp: Made hash maps keyed by script

names ASCII case-insensitive. USE WTF_ARRAY_LENGTH as appropriate.
(WebCore::scriptNameToCode): Use modern style to initialize the map. Removed
unnecessary lowercasing of the script name before looking at the map.
(WebCore::localeToScriptCodeForFontSelection): Ditto.

  • platform/text/win/LocaleWin.cpp:

(WebCore::convertLocaleNameToLCID): Made map ASCII case-insensitive and removed
unneeded lowercasing.

  • platform/win/PasteboardWin.cpp:

(WebCore::clipboardTypeFromMIMEType): Use equalLettersIgnoringASCIICase instead
of lowercasing.

  • rendering/RenderText.cpp:

(WebCore::applyTextTransform): Use new names for the upper and lower functions.

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::responseIsXML): Remove unneeded lowercasing, since
DOMImplementation now has ASCII case-insensitive handling of MIME types.

Source/WebKit/mac:

  • Plugins/WebBasePluginPackage.mm:

(-[WebBasePluginPackage getPluginInfoFromPLists]): Use modern for loops.
(-[WebBasePluginPackage supportsExtension:]): Use convertToASCIILowercase for extension assert.
Also use modern for loop.
(-[WebBasePluginPackage supportsMIMEType:]): Ditto.
(-[WebBasePluginPackage MIMETypeForExtension:]): Ditto.

Source/WebKit/win:

  • Plugins/PluginDatabase.cpp:

(WebCore::PluginDatabase::pluginForMIMEType): Use ASCII case-insensitive map rather
than lowercasing the MIME type.
(WebCore::PluginDatabase::setPreferredPluginForMIMEType): Ditto.

  • Plugins/PluginDatabase.h: Make m_preferredPlugins use an ASCII case-insensitive hash.
  • Plugins/PluginPackage.h: Use ASCII case-insensitive hash for maps keyed by MIME type.
  • Plugins/PluginPackageWin.cpp:

(WebCore::PluginPackage::fetchInfo): Use convertToASCIILowercase to lowercase a MIME type.

Source/WebKit2:

  • NetworkProcess/CustomProtocols/CustomProtocolManager.h: Use ASCII case-insensitive hash

for set of registered schemes.

  • Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:

(WebKit::getPluginInfoFromPropertyLists): Use convertToASCIILowercase for MIME type and
for file extensions.

  • Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:

(WebKit::NetscapePluginModule::parseMIMEDescription): Use convertToASCIILowercase for
MIME description.

  • UIProcess/API/efl/ewk_context.cpp:

(ewk_context_preferred_languages_set): Use convertToASCIILowercase for language.

  • UIProcess/API/gtk/WebKitWebContext.cpp:

(webkit_web_context_set_preferred_languages): Use convertToASCIILowercase for language.

  • UIProcess/Plugins/PluginInfoStore.cpp:

(WebKit::PluginInfoStore::findPluginForExtension): Use Vector::contains instead of
writing it out using std::find.
(WebKit::pathExtension): Lowercase the result with convertToASCIILowercase instead of
leaving that to the caller.
(WebKit::PluginInfoStore::findPlugin): Removed call to lower since pathExtension
handles that now.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::findPlugin): Use convertToASCIILowercase for MIME type.

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::globalURLSchemesWithCustomProtocolHandlers): Use
an ASCII case-insensitive hash.
(WebKit::WebProcessPool::registerGlobalURLSchemeAsHavingCustomProtocolHandlers):
Remove lowercasing, since the hash is now ASCII case-insensitive.
(WebKit::WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers):
Ditto.

  • UIProcess/WebProcessPool.h: Use an ASCII case-insensitive hash.
  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::initialize): Use convertToASCIILowercase on parameter names
and values.

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::pluginSupportsExtension): Use convertToASCIILowercase for extension assertion.
Also use a modern for loop.
(WebKit::WebFrameLoaderClient::objectContentType): Make the checks for empty MIME types
a little less redundant. Reordered logic to avoid checking the list of supported MIME
types extra times, and to eliminate the need for a boolean. Use convertToASCIILowercase
on the extension.

Source/WTF:

  • wtf/text/AtomicString.cpp:

(WTF::AtomicString::lower): Deleted.

  • wtf/text/AtomicString.h: Deleted the lower function.
  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::convertToLowercaseWithoutLocale): Renamed from lower.
(WTF::StringImpl::convertToUppercaseWithoutLocale): Renamed from upper.
(WTF::StringImpl::convertToLowercaseWithLocale): Renamed from lower.
(WTF::StringImpl::convertToUppercaseWithLocale): Renamed from upper.
(WTF::StringImpl::foldCase): Added fast cases for ASCII since this is
now used in some more-performance-critical code.

  • wtf/text/StringImpl.h: Renamed lower and upper.
  • wtf/text/WTFString.cpp:

(WTF::String::convertToLowercaseWithoutLocale): Renamed from lower.
(WTF::String::convertToUppercaseWithoutLocale): Renamed from upper.
(WTF::String::convertToLowercaseWithLocale): Renamed from lower.
(WTF::String::convertToUppercaseWithLocale): Renamed from upper.

  • wtf/text/WTFString.h: Renamed lower and upper. Removed unneeded comment.
Location:
trunk/Source
Files:
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r196220 r196223  
     12016-02-06  Darin Adler  <darin@apple.com>
     2
     3        Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
     4        https://bugs.webkit.org/show_bug.cgi?id=153905
     5
     6        Reviewed by Sam Weinig.
     7
     8        * runtime/IntlObject.cpp:
     9        (JSC::canonicalLangTag): Use converToASCIIUppercase on the language tag.
     10
     11        * runtime/StringPrototype.cpp:
     12        (JSC::stringProtoFuncToLowerCase): Tweak style and update for name change.
     13        (JSC::stringProtoFuncToUpperCase): Ditto.
     14
    1152016-02-06  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/JavaScriptCore/runtime/IntlObject.cpp

    r194387 r196223  
    323323            ++currentIndex;
    324324            canonical.append('-');
    325             canonical.append(region.upper());
     325            canonical.append(region.convertToASCIIUppercase());
    326326        }
    327327    }
  • trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp

    r195528 r196223  
    14071407    JSString* sVal = thisValue.toString(exec);
    14081408    const String& s = sVal->value(exec);
    1409 
    1410     int sSize = s.length();
    1411     if (!sSize)
     1409    String lowercasedString = s.convertToLowercaseWithoutLocale();
     1410    if (lowercasedString.impl() == s.impl())
    14121411        return JSValue::encode(sVal);
    1413     RELEASE_ASSERT(sSize >= 0);
    1414 
    1415     StringImpl* ourImpl = s.impl();
    1416     RefPtr<StringImpl> lower = ourImpl->lower();
    1417     if (ourImpl == lower)
    1418         return JSValue::encode(sVal);
    1419     return JSValue::encode(jsString(exec, String(lower.release())));
     1412    return JSValue::encode(jsString(exec, lowercasedString));
    14201413}
    14211414
     
    14271420    JSString* sVal = thisValue.toString(exec);
    14281421    const String& s = sVal->value(exec);
    1429 
    1430     int sSize = s.length();
    1431     if (!sSize)
     1422    String uppercasedString = s.convertToUppercaseWithoutLocale();
     1423    if (uppercasedString.impl() == s.impl())
    14321424        return JSValue::encode(sVal);
    1433 
    1434     StringImpl* sImpl = s.impl();
    1435     RefPtr<StringImpl> upper = sImpl->upper();
    1436     if (sImpl == upper)
    1437         return JSValue::encode(sVal);
    1438     return JSValue::encode(jsString(exec, String(upper.release())));
     1425    return JSValue::encode(jsString(exec, uppercasedString));
    14391426}
    14401427
  • trunk/Source/WTF/ChangeLog

    r196080 r196223  
     12016-02-06  Darin Adler  <darin@apple.com>
     2
     3        Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
     4        https://bugs.webkit.org/show_bug.cgi?id=153905
     5
     6        Reviewed by Sam Weinig.
     7
     8        * wtf/text/AtomicString.cpp:
     9        (WTF::AtomicString::lower): Deleted.
     10        * wtf/text/AtomicString.h: Deleted the lower function.
     11
     12        * wtf/text/StringImpl.cpp:
     13        (WTF::StringImpl::convertToLowercaseWithoutLocale): Renamed from lower.
     14        (WTF::StringImpl::convertToUppercaseWithoutLocale): Renamed from upper.
     15        (WTF::StringImpl::convertToLowercaseWithLocale): Renamed from lower.
     16        (WTF::StringImpl::convertToUppercaseWithLocale): Renamed from upper.
     17        (WTF::StringImpl::foldCase): Added fast cases for ASCII since this is
     18        now used in some more-performance-critical code.
     19        * wtf/text/StringImpl.h: Renamed lower and upper.
     20
     21        * wtf/text/WTFString.cpp:
     22        (WTF::String::convertToLowercaseWithoutLocale): Renamed from lower.
     23        (WTF::String::convertToUppercaseWithoutLocale): Renamed from upper.
     24        (WTF::String::convertToLowercaseWithLocale): Renamed from lower.
     25        (WTF::String::convertToUppercaseWithLocale): Renamed from upper.
     26        * wtf/text/WTFString.h: Renamed lower and upper. Removed unneeded comment.
     27
    1282016-02-03  Darin Adler  <darin@apple.com>
    229
  • trunk/Source/WTF/wtf/text/AtomicString.cpp

    r195501 r196223  
    3232
    3333namespace WTF {
    34 
    35 AtomicString AtomicString::lower() const
    36 {
    37     // Note: This is a hot function in the Dromaeo benchmark.
    38     StringImpl* impl = this->impl();
    39     if (UNLIKELY(!impl))
    40         return AtomicString();
    41 
    42     RefPtr<StringImpl> lowercasedString = impl->lower();
    43     if (LIKELY(lowercasedString == impl))
    44         return *this;
    45 
    46     AtomicString result;
    47     result.m_string = AtomicStringImpl::add(lowercasedString.get());
    48     return result;
    49 }
    5034
    5135template<AtomicString::CaseConvertType type>
  • trunk/Source/WTF/wtf/text/AtomicString.h

    r195946 r196223  
    156156    WTF_EXPORT_STRING_API AtomicString convertToASCIILowercase() const;
    157157    WTF_EXPORT_STRING_API AtomicString convertToASCIIUppercase() const;
    158     WTF_EXPORT_STRING_API AtomicString lower() const;
    159158
    160159    int toInt(bool* ok = 0) const { return m_string.toInt(ok); }
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r195928 r196223  
    362362}
    363363
    364 Ref<StringImpl> StringImpl::lower()
    365 {
    366     // Note: This is a hot function in the Dromaeo benchmark, specifically the
     364Ref<StringImpl> StringImpl::convertToLowercaseWithoutLocale()
     365{
     366    // Note: At one time this was a hot function in the Dromaeo benchmark, specifically the
    367367    // no-op code path up through the first 'return' statement.
    368368
     
    443443}
    444444
    445 Ref<StringImpl> StringImpl::upper()
    446 {
    447     // This function could be optimized for no-op cases the way lower() is,
    448     // but in empirical testing, few actual calls to upper() are no-ops, so
    449     // it wouldn't be worth the extra time for pre-scanning.
     445Ref<StringImpl> StringImpl::convertToUppercaseWithoutLocale()
     446{
     447    // This function could be optimized for no-op cases the way
     448    // convertToLowercaseWithoutLocale() is, but in empirical testing,
     449    // few actual calls to upper() are no-ops, so it wouldn't be worth
     450    // the extra time for pre-scanning.
    450451
    451452    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
     
    478479
    479480        // There are two special cases.
    480         //  1. latin-1 characters when converted to upper case are 16 bit characters.
     481        //  1. Some Latin-1 characters when converted to upper case are 16 bit characters.
    481482        //  2. Lower case sharp-S converts to "SS" (two characters)
    482483        for (int32_t i = 0; i < length; ++i) {
     
    486487            ASSERT(u_toupper(c) <= 0xFFFF);
    487488            UChar upper = u_toupper(c);
    488             if (UNLIKELY(upper > 0xff)) {
     489            if (UNLIKELY(upper > 0xFF)) {
    489490                // Since this upper-cased character does not fit in an 8-bit string, we need to take the 16-bit path.
    490491                goto upconvert;
     
    555556}
    556557
    557 Ref<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier)
     558Ref<StringImpl> StringImpl::convertToLowercaseWithLocale(const AtomicString& localeIdentifier)
    558559{
    559560    // Use the more-optimized code path most of the time.
     
    562563    // that have locale-specific lowercasing. There are only three of them.
    563564    if (!needsTurkishCasingRules(localeIdentifier))
    564         return lower();
     565        return convertToLowercaseWithoutLocale();
    565566
    566567    // FIXME: Could share more code with the main StringImpl::lower by factoring out
     
    591592}
    592593
    593 Ref<StringImpl> StringImpl::upper(const AtomicString& localeIdentifier)
     594Ref<StringImpl> StringImpl::convertToUppercaseWithLocale(const AtomicString& localeIdentifier)
    594595{
    595596    // Use the more-optimized code path most of the time.
     
    597598    // and that the only affected character is lowercase "i".
    598599    if (!needsTurkishCasingRules(localeIdentifier) || find('i') == notFound)
    599         return upper();
     600        return convertToUppercaseWithoutLocale();
    600601
    601602    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
     
    624625Ref<StringImpl> StringImpl::foldCase()
    625626{
    626     // FIXME: Why doesn't this function have a preflight like the one in StringImpl::lower?
     627    if (is8Bit()) {
     628        unsigned failingIndex;
     629        for (unsigned i = 0; i < m_length; ++i) {
     630            auto character = m_data8[i];
     631            if (UNLIKELY(!isASCII(character) || isASCIIUpper(character))) {
     632                failingIndex = i;
     633                goto SlowPath;
     634            }
     635        }
     636        // String was all ASCII and no uppercase, so just return as-is.
     637        return *this;
     638
     639SlowPath:
     640        bool need16BitCharacters = false;
     641        for (unsigned i = failingIndex; i < m_length; ++i) {
     642            auto character = m_data8[i];
     643            if (character == 0xB5 || character == 0xDF) {
     644                need16BitCharacters = true;
     645                break;
     646            }
     647        }
     648
     649        if (!need16BitCharacters) {
     650            LChar* data8;
     651            auto folded = createUninitializedInternalNonEmpty(m_length, data8);
     652            for (unsigned i = 0; i < failingIndex; ++i)
     653                data8[i] = m_data8[i];
     654            for (unsigned i = failingIndex; i < m_length; ++i) {
     655                auto character = m_data8[i];
     656                if (isASCII(character))
     657                    data8[i] = toASCIILower(character);
     658                else {
     659                    ASSERT(u_foldCase(character, U_FOLD_CASE_DEFAULT) <= 0xFF);
     660                    data8[i] = static_cast<LChar>(u_foldCase(character, U_FOLD_CASE_DEFAULT));
     661                }
     662            }
     663            return folded;
     664        }
     665    } else {
     666        // FIXME: Unclear why we use goto in the 8-bit case, and a different approach in the 16-bit case.
     667        bool noUpper = true;
     668        unsigned ored = 0;
     669        for (unsigned i = 0; i < m_length; ++i) {
     670            UChar character = m_data16[i];
     671            if (UNLIKELY(isASCIIUpper(character)))
     672                noUpper = false;
     673            ored |= character;
     674        }
     675        if (!(ored & ~0x7F)) {
     676            if (noUpper) {
     677                // String was all ASCII and no uppercase, so just return as-is.
     678                return *this;
     679            }
     680            UChar* data16;
     681            auto folded = createUninitializedInternalNonEmpty(m_length, data16);
     682            for (unsigned i = 0; i < m_length; ++i)
     683                data16[i] = toASCIILower(m_data16[i]);
     684            return folded;
     685        }
     686    }
    627687
    628688    if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max()))
    629689        CRASH();
     690
     691    auto upconvertedCharacters = StringView(*this).upconvertedCharacters();
     692
     693    UChar* data;
     694    auto folded = createUninitializedInternalNonEmpty(m_length, data);
    630695    int32_t length = m_length;
    631 
    632     if (is8Bit()) {
    633         // Do a faster loop for the case where all the characters are ASCII.
    634         LChar* data;
    635         auto newImpl = createUninitialized(m_length, data);
    636         LChar ored = 0;
    637 
    638         for (int32_t i = 0; i < length; ++i) {
    639             LChar c = m_data8[i];
    640             data[i] = toASCIILower(c);
    641             ored |= c;
    642         }
    643 
    644         if (!(ored & ~0x7F))
    645             return newImpl;
    646 
    647         // Do a slower implementation for cases that include non-ASCII Latin-1 characters.
    648         // FIXME: Shouldn't this use u_foldCase instead of u_tolower?
    649         for (int32_t i = 0; i < length; ++i) {
    650             ASSERT(u_tolower(m_data8[i]) <= 0xFF);
    651             data[i] = static_cast<LChar>(u_tolower(m_data8[i]));
    652         }
    653 
    654         return newImpl;
    655     }
    656 
    657     // Do a faster loop for the case where all the characters are ASCII.
    658     UChar* data;
    659     RefPtr<StringImpl> newImpl = createUninitialized(m_length, data);
    660     UChar ored = 0;
    661     for (int32_t i = 0; i < length; ++i) {
    662         UChar c = m_data16[i];
    663         ored |= c;
    664         data[i] = toASCIILower(c);
    665     }
    666     if (!(ored & ~0x7F))
    667         return newImpl.releaseNonNull();
    668 
    669     // Do a slower implementation for cases that include non-ASCII characters.
    670696    UErrorCode status = U_ZERO_ERROR;
    671     int32_t realLength = u_strFoldCase(data, length, m_data16, m_length, U_FOLD_CASE_DEFAULT, &status);
     697    int32_t realLength = u_strFoldCase(data, length, upconvertedCharacters, length, U_FOLD_CASE_DEFAULT, &status);
    672698    if (U_SUCCESS(status) && realLength == length)
    673         return newImpl.releaseNonNull();
    674     newImpl = createUninitialized(realLength, data);
     699        return folded;
     700    ASSERT(realLength > length);
     701    folded = createUninitializedInternalNonEmpty(realLength, data);
    675702    status = U_ZERO_ERROR;
    676     u_strFoldCase(data, realLength, m_data16, m_length, U_FOLD_CASE_DEFAULT, &status);
     703    u_strFoldCase(data, realLength, upconvertedCharacters, length, U_FOLD_CASE_DEFAULT, &status);
    677704    if (U_FAILURE(status))
    678705        return *this;
    679     return newImpl.releaseNonNull();
     706    return folded;
    680707}
    681708
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r195928 r196223  
    682682    WTF_EXPORT_STRING_API Ref<StringImpl> convertToASCIILowercase();
    683683    WTF_EXPORT_STRING_API Ref<StringImpl> convertToASCIIUppercase();
    684     WTF_EXPORT_STRING_API Ref<StringImpl> lower();
    685     WTF_EXPORT_STRING_API Ref<StringImpl> upper();
    686     WTF_EXPORT_STRING_API Ref<StringImpl> lower(const AtomicString& localeIdentifier);
    687     WTF_EXPORT_STRING_API Ref<StringImpl> upper(const AtomicString& localeIdentifier);
     684    WTF_EXPORT_STRING_API Ref<StringImpl> convertToLowercaseWithoutLocale();
     685    WTF_EXPORT_STRING_API Ref<StringImpl> convertToUppercaseWithoutLocale();
     686    WTF_EXPORT_STRING_API Ref<StringImpl> convertToLowercaseWithLocale(const AtomicString& localeIdentifier);
     687    WTF_EXPORT_STRING_API Ref<StringImpl> convertToUppercaseWithLocale(const AtomicString& localeIdentifier);
    688688
    689689    Ref<StringImpl> foldCase();
  • trunk/Source/WTF/wtf/text/WTFString.cpp

    r195501 r196223  
    352352}
    353353
    354 String String::lower() const
    355 {
    356     if (!m_impl)
    357         return String();
    358     return m_impl->lower();
    359 }
    360 
    361 String String::upper() const
    362 {
    363     if (!m_impl)
    364         return String();
    365     return m_impl->upper();
    366 }
    367 
    368 String String::lower(const AtomicString& localeIdentifier) const
    369 {
    370     if (!m_impl)
    371         return String();
    372     return m_impl->lower(localeIdentifier);
    373 }
    374 
    375 String String::upper(const AtomicString& localeIdentifier) const
    376 {
    377     if (!m_impl)
    378         return String();
    379     return m_impl->upper(localeIdentifier);
     354String String::convertToLowercaseWithoutLocale() const
     355{
     356    if (!m_impl)
     357        return String();
     358    return m_impl->convertToLowercaseWithoutLocale();
     359}
     360
     361String String::convertToUppercaseWithoutLocale() const
     362{
     363    if (!m_impl)
     364        return String();
     365    return m_impl->convertToUppercaseWithoutLocale();
     366}
     367
     368String String::convertToLowercaseWithLocale(const AtomicString& localeIdentifier) const
     369{
     370    if (!m_impl)
     371        return String();
     372    return m_impl->convertToLowercaseWithLocale(localeIdentifier);
     373}
     374
     375String String::convertToUppercaseWithLocale(const AtomicString& localeIdentifier) const
     376{
     377    if (!m_impl)
     378        return String();
     379    return m_impl->convertToUppercaseWithLocale(localeIdentifier);
    380380}
    381381
  • trunk/Source/WTF/wtf/text/WTFString.h

    r195743 r196223  
    332332    String right(unsigned len) const { return substring(length() - len, len); }
    333333
    334     // Returns a lowercase/uppercase version of the string.
    335     // The convertToASCIILowercase is useful in many contexts such as HTML where we don't
    336     // want to do any conversion for non-ASCII letters.
    337334    WTF_EXPORT_STRING_API String convertToASCIILowercase() const;
    338     WTF_EXPORT_STRING_API String lower() const;
    339335    WTF_EXPORT_STRING_API String convertToASCIIUppercase() const;
    340     WTF_EXPORT_STRING_API String upper() const;
    341 
    342     WTF_EXPORT_STRING_API String lower(const AtomicString& localeIdentifier) const;
    343     WTF_EXPORT_STRING_API String upper(const AtomicString& localeIdentifier) const;
     336    WTF_EXPORT_STRING_API String convertToLowercaseWithoutLocale() const;
     337    WTF_EXPORT_STRING_API String convertToUppercaseWithoutLocale() const;
     338    WTF_EXPORT_STRING_API String convertToLowercaseWithLocale(const AtomicString& localeIdentifier) const;
     339    WTF_EXPORT_STRING_API String convertToUppercaseWithLocale(const AtomicString& localeIdentifier) const;
    344340
    345341    WTF_EXPORT_STRING_API String stripWhiteSpace() const;
  • trunk/Source/WebCore/ChangeLog

    r196222 r196223  
     12016-02-06  Darin Adler  <darin@apple.com>
     2
     3        Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
     4        https://bugs.webkit.org/show_bug.cgi?id=153905
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Modules/mediasource/MediaSource.cpp:
     9        (WebCore::MediaSource::isTypeSupported): Use convertToASCIILowercase on MIME type.
     10
     11        * accessibility/AccessibilityObject.cpp:
     12        (WebCore::AccessibilityObject::selectText): Use new names for lower and upper. Also
     13        tweaked style a tiny bit and used u_toupper rather than converting an entire
     14        string to uppercase.
     15
     16        * dom/Document.cpp:
     17        (WebCore::Document::addImageElementByCaseFoldedUsemap): Renamed to reflect the use
     18        of case folding rather than lowercasing.
     19        (WebCore::Document::removeImageElementByCaseFoldedUsemap): Ditto.
     20        (WebCore::Document::imageElementByCaseFoldedUsemap): Ditto.
     21        * dom/Document.h: Ditto.
     22        * dom/DocumentOrderedMap.cpp:
     23        (WebCore::DocumentOrderedMap::getElementByCaseFoldedMapName): Ditto.
     24        (WebCore::DocumentOrderedMap::getElementByCaseFoldedUsemap): Ditto.
     25        * dom/DocumentOrderedMap.h: Ditto.
     26
     27        * dom/TreeScope.cpp:
     28        (WebCore::TreeScope::getImageMap): Removed unneeded special case for null string.
     29        Simplified logic for cases where the URL does not have a "#" character in it.
     30        Use case folding instead of lowercase.
     31
     32        * editing/cocoa/HTMLConverter.mm:
     33        (HTMLConverter::_processText): Removed unneded special case for the empty string.
     34        Use makCapitalized instead of Cocoa function for "capitalize". Use upper and lower
     35        functions by their new names.
     36
     37        * html/HTMLImageElement.cpp:
     38        (WebCore::HTMLImageElement::parseAttribute): Use case folding instead of
     39        lowerasing for the usemap attribute.
     40        (WebCore::HTMLImageElement::insertedInto): Ditto.
     41        (WebCore::HTMLImageElement::removedFrom): Ditto.
     42        (WebCore::HTMLImageElement::matchesCaseFoldedUsemap): Ditto.
     43        * html/HTMLImageElement.h: Rename since usemap is case folded now, not lowercased.
     44
     45        * html/HTMLMapElement.cpp:
     46        (WebCore::HTMLMapElement::imageElement): Use case folding instead of lowercasing
     47        for usemap.
     48        (WebCore::HTMLMapElement::parseAttribute): Ditto.
     49
     50        * platform/Language.cpp:
     51        (WebCore::canonicalLanguageIdentifier): Use convertToASCIILowercase for language code.
     52        (WebCore::indexOfBestMatchingLanguageInList): Ditto.
     53
     54        * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
     55        (WebCore::HarfBuzzShaper::shapeHarfBuzzRuns): Use new name for the upper function.
     56
     57        * platform/network/HTTPParsers.cpp:
     58        (WebCore::parseContentTypeOptionsHeader): Use equalLettersIgnoringASCIICase instead
     59        of lowercasing to check for a specific header value.
     60
     61        * platform/network/MIMEHeader.cpp:
     62        (WebCore::retrieveKeyValuePairs): Use convertToASCIILowercase for MIME header name.
     63        (WebCore::MIMEHeader::parseContentTransferEncoding): Use equalLettersIgnoringASCIICase
     64        instead of lowercasing.
     65
     66        * platform/network/cf/ResourceHandleCFNet.cpp:
     67        (WebCore::allowsAnyHTTPSCertificateHosts): Make this hash ASCII case-insensitive.
     68        (WebCore::clientCertificates): Ditto.
     69        (WebCore::ResourceHandle::createCFURLConnection): Remove call to lower since the
     70        set is now ASCII case-insensitive.
     71        (WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Ditto.
     72        (WebCore::ResourceHandle::setClientCertificate): Ditto.
     73
     74        * platform/network/curl/CookieJarCurl.cpp:
     75        (WebCore::getNetscapeCookieFormat): Use equalLettersIgnoringASCIICase instead of
     76        lowercasing.
     77
     78        * platform/network/curl/MultipartHandle.cpp:
     79        (WebCore::MultipartHandle::didReceiveResponse): Use convertToASCIILowercase to
     80        make a MIME type lowercase.
     81
     82        * platform/network/curl/ResourceHandleCurl.cpp:
     83        (WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Removed unneeded
     84        conversion to lowercase now that the set is ASCII case-insensitive.
     85        (WebCore::ResourceHandle::setClientCertificate): Removed code that populates a map
     86        that is then never used for anything.
     87
     88        * platform/network/curl/ResourceHandleManager.cpp:
     89        (WebCore::headerCallback): Use convertToASCIILowercase for MIME type.
     90
     91        * platform/network/curl/SSLHandle.cpp: Made hash maps keyed by host names
     92        ASCII case-insensitive.
     93        (WebCore::addAllowedClientCertificate): Removed lowercasing since the map itself
     94        is now ASCII case insensitve.
     95        (WebCore::setSSLClientCertificate): Ditto. Also use auto for iterator type so we
     96        don't have to write out the map type.
     97        (WebCore::sslIgnoreHTTPSCertificate): Ditto.
     98        (WebCore::certVerifyCallback): Ditto.
     99
     100        * platform/network/soup/ResourceHandleSoup.cpp: Made hash maps keyed by host names
     101        ASCII case-insensitive.
     102        (WebCore::allowsAnyHTTPSCertificateHosts): Ditto.
     103        (WebCore::handleUnignoredTLSErrors): Ditto.
     104        (WebCore::ResourceHandle::setHostAllowsAnyHTTPSCertificate): Ditto.
     105        (WebCore::ResourceHandle::setClientCertificate): Ditto.
     106
     107        * platform/text/LocaleToScriptMappingDefault.cpp: Made hash maps keyed by script
     108        names ASCII case-insensitive. USE WTF_ARRAY_LENGTH as appropriate.
     109        (WebCore::scriptNameToCode): Use modern style to initialize the map. Removed
     110        unnecessary lowercasing of the script name before looking at the map.
     111        (WebCore::localeToScriptCodeForFontSelection): Ditto.
     112
     113        * platform/text/win/LocaleWin.cpp:
     114        (WebCore::convertLocaleNameToLCID): Made map ASCII case-insensitive and removed
     115        unneeded lowercasing.
     116
     117        * platform/win/PasteboardWin.cpp:
     118        (WebCore::clipboardTypeFromMIMEType): Use equalLettersIgnoringASCIICase instead
     119        of lowercasing.
     120
     121        * rendering/RenderText.cpp:
     122        (WebCore::applyTextTransform): Use new names for the upper and lower functions.
     123
     124        * xml/XMLHttpRequest.cpp:
     125        (WebCore::XMLHttpRequest::responseIsXML): Remove unneeded lowercasing, since
     126        DOMImplementation now has ASCII case-insensitive handling of MIME types.
     127
    11282016-02-06  Zalan Bujtas  <zalan@apple.com>
    2129
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp

    r195951 r196223  
    734734
    735735    // FIXME: Why do we convert to lowercase here, but not in MediaSource::addSourceBuffer?
    736     ContentType contentType(type.lower());
     736    ContentType contentType(type.convertToASCIILowercase());
    737737    String codecs = contentType.parameter("codecs");
    738738
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r195928 r196223  
    762762        if (frame->selection().setSelectedRange(closestStringRange.get(), DOWNSTREAM, true)) {
    763763            switch (activity) {
    764             case FindAndCapitalize: {
     764            case FindAndCapitalize:
    765765                replacementString = closestString;
    766766                makeCapitalized(&replacementString, 0);
    767767                replaceSelection = true;
    768768                break;
    769             }
    770769            case FindAndUppercase:
    771                 replacementString = closestString.upper();
     770                replacementString = closestString.convertToUppercaseWithoutLocale(); // FIXME: Needs locale to work correctly.
    772771                replaceSelection = true;
    773772                break;
    774773            case FindAndLowercase:
    775                 replacementString = closestString.lower();
     774                replacementString = closestString.convertToLowercaseWithoutLocale(); // FIXME: Needs locale to work correctly.
    776775                replaceSelection = true;
    777776                break;
    778777            case FindAndReplaceActivity: {
    779778                replaceSelection = true;
    780                
    781779                // When applying find and replace activities, we want to match the capitalization of the replaced text,
    782780                // (unless we're replacing with an abbreviation.)
    783                 String uppercaseReplacementString = replacementString.upper();
    784                 if (closestString.length() > 0 && replacementString.length() > 2 && replacementString != uppercaseReplacementString) {
    785                     if (closestString[0] == closestString.upper()[0])
     781                if (closestString.length() > 0 && replacementString.length() > 2 && replacementString != replacementString.convertToUppercaseWithoutLocale()) {
     782                    if (closestString[0] == u_toupper(closestString[0]))
    786783                        makeCapitalized(&replacementString, 0);
    787784                    else
    788                         replacementString = replacementString.lower();
     785                        replacementString = replacementString.convertToLowercaseWithoutLocale(); // FIXME: Needs locale to work correctly.
    789786                }
    790787                break;
  • trunk/Source/WebCore/dom/Document.cpp

    r196135 r196223  
    767767}
    768768
    769 void Document::addImageElementByLowercasedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)
     769void Document::addImageElementByCaseFoldedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)
    770770{
    771771    return m_imagesByUsemap.add(name, element, *this);
    772772}
    773773
    774 void Document::removeImageElementByLowercasedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)
     774void Document::removeImageElementByCaseFoldedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)
    775775{
    776776    return m_imagesByUsemap.remove(name, element);
    777777}
    778778
    779 HTMLImageElement* Document::imageElementByLowercasedUsemap(const AtomicStringImpl& name) const
    780 {
    781     return m_imagesByUsemap.getElementByLowercasedUsemap(name, *this);
     779HTMLImageElement* Document::imageElementByCaseFoldedUsemap(const AtomicStringImpl& name) const
     780{
     781    return m_imagesByUsemap.getElementByCaseFoldedUsemap(name, *this);
    782782}
    783783
  • trunk/Source/WebCore/dom/Document.h

    r195951 r196223  
    351351    void invalidateAccessKeyMap();
    352352
    353     void addImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
    354     void removeImageElementByLowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);
    355     HTMLImageElement* imageElementByLowercasedUsemap(const AtomicStringImpl&) const;
     353    void addImageElementByCaseFoldedUsemap(const AtomicStringImpl&, HTMLImageElement&);
     354    void removeImageElementByCaseFoldedUsemap(const AtomicStringImpl&, HTMLImageElement&);
     355    HTMLImageElement* imageElementByCaseFoldedUsemap(const AtomicStringImpl&) const;
    356356
    357357    SelectorQuery* selectorQueryForString(const String&, ExceptionCode&);
  • trunk/Source/WebCore/dom/DocumentOrderedMap.cpp

    r190097 r196223  
    148148}
    149149
    150 HTMLMapElement* DocumentOrderedMap::getElementByLowercasedMapName(const AtomicStringImpl& key, const TreeScope& scope) const
     150HTMLMapElement* DocumentOrderedMap::getElementByCaseFoldedMapName(const AtomicStringImpl& key, const TreeScope& scope) const
    151151{
    152152    return downcast<HTMLMapElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) {
    153         return is<HTMLMapElement>(element) && downcast<HTMLMapElement>(element).getName().lower().impl() == &key;
    154     }));
    155 }
    156 
    157 HTMLImageElement* DocumentOrderedMap::getElementByLowercasedUsemap(const AtomicStringImpl& key, const TreeScope& scope) const
     153        return is<HTMLMapElement>(element) && equal(downcast<HTMLMapElement>(element).getName().string().foldCase().impl(), &key);
     154    }));
     155}
     156
     157HTMLImageElement* DocumentOrderedMap::getElementByCaseFoldedUsemap(const AtomicStringImpl& key, const TreeScope& scope) const
    158158{
    159159    return downcast<HTMLImageElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) {
    160160        // FIXME: HTML5 specification says we should match both image and object elements.
    161         return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element).matchesLowercasedUsemap(key);
     161        return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element).matchesCaseFoldedUsemap(key);
    162162    }));
    163163}
  • trunk/Source/WebCore/dom/DocumentOrderedMap.h

    r191955 r196223  
    6161    Element* getElementByName(const AtomicStringImpl&, const TreeScope&) const;
    6262    HTMLMapElement* getElementByMapName(const AtomicStringImpl&, const TreeScope&) const;
    63     HTMLMapElement* getElementByLowercasedMapName(const AtomicStringImpl&, const TreeScope&) const;
    64     HTMLImageElement* getElementByLowercasedUsemap(const AtomicStringImpl&, const TreeScope&) const;
     63    HTMLMapElement* getElementByCaseFoldedMapName(const AtomicStringImpl&, const TreeScope&) const;
     64    HTMLImageElement* getElementByCaseFoldedUsemap(const AtomicStringImpl&, const TreeScope&) const;
    6565    HTMLLabelElement* getElementByLabelForAttribute(const AtomicStringImpl&, const TreeScope&) const;
    6666    Element* getElementByWindowNamedItem(const AtomicStringImpl&, const TreeScope&) const;
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r195743 r196223  
    202202HTMLMapElement* TreeScope::getImageMap(const String& url) const
    203203{
    204     if (url.isNull())
    205         return nullptr;
    206204    if (!m_imageMapsByName)
    207205        return nullptr;
    208     size_t hashPos = url.find('#');
    209     String name = (hashPos == notFound ? String() : url.substring(hashPos + 1)).impl();
     206    auto hashPosition = url.find('#');
     207    if (hashPosition == notFound)
     208        return nullptr;
     209    String name = url.substring(hashPosition + 1);
    210210    if (name.isEmpty())
    211211        return nullptr;
    212     if (m_rootNode.document().isHTMLDocument()) {
    213         AtomicString lowercasedName = name.lower();
    214         return m_imageMapsByName->getElementByLowercasedMapName(*lowercasedName.impl(), *this);
    215     }
     212    if (m_rootNode.document().isHTMLDocument())
     213        return m_imageMapsByName->getElementByCaseFoldedMapName(*AtomicString(name.foldCase()).impl(), *this);
    216214    return m_imageMapsByName->getElementByMapName(*AtomicString(name).impl(), *this);
    217215}
  • trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm

    r195946 r196223  
    5757#import "RGBColor.h"
    5858#import "RenderImage.h"
     59#import "RenderText.h"
    5960#import "SoftLinking.h"
    6061#import "StyleProperties.h"
     
    22792280    if (outputString.length()) {
    22802281        String textTransform = _caches->propertyValueForNode(characterData, CSSPropertyTextTransform);
    2281         if (textTransform.length()) {
    2282             if (textTransform == "capitalize") {// FIXME: This is extremely inefficient.
    2283                 NSString *temporaryString = outputString;
    2284                 outputString = [temporaryString capitalizedString];
    2285             } else if (textTransform == "uppercase")
    2286                 outputString = outputString.upper();
    2287             else if (textTransform == "lowercase")
    2288                 outputString = outputString.lower();
    2289         }
     2282        if (textTransform == "capitalize")
     2283            makeCapitalized(&outputString, 0); // FIXME: Needs to take locale into account to work correctly.
     2284        else if (textTransform == "uppercase")
     2285            outputString = outputString.convertToUppercaseWithoutLocale(); // FIXME: Needs locale to work correctly.
     2286        else if (textTransform == "lowercase")
     2287            outputString = outputString.convertToLowercaseWithoutLocale(); // FIXME: Needs locale to work correctly.
    22902288
    22912289        [_attrStr replaceCharactersInRange:rangeToReplace withString:outputString];
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r196080 r196223  
    202202        selectImageSource();
    203203    else if (name == usemapAttr) {
    204         if (inDocument() && !m_lowercasedUsemap.isNull())
    205             document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
     204        if (inDocument() && !m_caseFoldedUsemap.isNull())
     205            document().removeImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this);
    206206
    207207        // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning, which has to be stripped off.
    208208        // FIXME: We should check that the first character is '#'.
    209         // FIXME: HTML5 specification says we should strip any leading string before '#'.
    210         // FIXME: HTML5 specification says we should ignore usemap attributes without #.
     209        // FIXME: HTML specification says we should strip any leading string before '#'.
     210        // FIXME: HTML specification says we should ignore usemap attributes without '#'.
    211211        if (value.length() > 1)
    212             m_lowercasedUsemap = value.string().substring(1).lower();
     212            m_caseFoldedUsemap = value.string().substring(1).foldCase();
    213213        else
    214             m_lowercasedUsemap = nullAtom;
    215 
    216         if (inDocument() && !m_lowercasedUsemap.isNull())
    217             document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
     214            m_caseFoldedUsemap = nullAtom;
     215
     216        if (inDocument() && !m_caseFoldedUsemap.isNull())
     217            document().addImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this);
    218218    } else if (name == compositeAttr) {
    219219        // FIXME: images don't support blend modes in their compositing attribute.
     
    313313    Node::InsertionNotificationRequest insertNotificationRequest = HTMLElement::insertedInto(insertionPoint);
    314314
    315     if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull())
    316         document().addImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
     315    if (insertionPoint.inDocument() && !m_caseFoldedUsemap.isNull())
     316        document().addImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this);
    317317
    318318    if (is<HTMLPictureElement>(parentNode())) {
     
    334334        m_form->removeImgElement(this);
    335335
    336     if (insertionPoint.inDocument() && !m_lowercasedUsemap.isNull())
    337         document().removeImageElementByLowercasedUsemap(*m_lowercasedUsemap.impl(), *this);
     336    if (insertionPoint.inDocument() && !m_caseFoldedUsemap.isNull())
     337        document().removeImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this);
    338338   
    339339    if (is<HTMLPictureElement>(parentNode()))
     
    475475}
    476476
    477 bool HTMLImageElement::matchesLowercasedUsemap(const AtomicStringImpl& name) const
    478 {
    479     ASSERT(String(&const_cast<AtomicStringImpl&>(name)).lower().impl() == &name);
    480     return m_lowercasedUsemap.impl() == &name;
     477bool HTMLImageElement::matchesCaseFoldedUsemap(const AtomicStringImpl& name) const
     478{
     479    ASSERT(String(&const_cast<AtomicStringImpl&>(name)).foldCase().impl() == &name);
     480    return m_caseFoldedUsemap.impl() == &name;
    481481}
    482482
  • trunk/Source/WebCore/html/HTMLImageElement.h

    r195132 r196223  
    6161    void setLoadManually(bool loadManually) { m_imageLoader.setLoadManually(loadManually); }
    6262
    63     bool matchesLowercasedUsemap(const AtomicStringImpl&) const;
     63    bool matchesCaseFoldedUsemap(const AtomicStringImpl&) const;
    6464
    6565    const AtomicString& alt() const;
     
    135135    AtomicString m_bestFitImageURL;
    136136    AtomicString m_currentSrc;
    137     AtomicString m_lowercasedUsemap;
     137    AtomicString m_caseFoldedUsemap;
    138138    float m_imageDevicePixelRatio;
    139139    bool m_experimentalImageMenuEnabled;
  • trunk/Source/WebCore/html/HTMLMapElement.cpp

    r188520 r196223  
    7979{
    8080    if (m_name.isEmpty())
    81         return 0;
    82     AtomicString lowercasedName = m_name.lower();
    83     ASSERT(lowercasedName.impl());
    84     return document().imageElementByLowercasedUsemap(*lowercasedName.impl());
     81        return nullptr;
     82    return document().imageElementByCaseFoldedUsemap(*AtomicString(m_name.string().foldCase()).impl());
    8583}
    8684
     
    102100        if (mapName[0] == '#')
    103101            mapName = mapName.substring(1);
    104         m_name = document().isHTMLDocument() ? mapName.lower() : mapName;
     102        m_name = document().isHTMLDocument() ? mapName.foldCase() : mapName;
    105103        if (inDocument())
    106104            treeScope().addImageMap(*this);
  • trunk/Source/WebCore/platform/Language.cpp

    r194819 r196223  
    100100static String canonicalLanguageIdentifier(const String& languageCode)
    101101{
    102     String lowercaseLanguageCode = languageCode.lower();
     102    String lowercaseLanguageCode = languageCode.convertToASCIILowercase();
    103103   
    104104    if (lowercaseLanguageCode.length() >= 3 && lowercaseLanguageCode[2] == '_')
     
    110110size_t indexOfBestMatchingLanguageInList(const String& language, const Vector<String>& languageList, bool& exactMatch)
    111111{
    112     String lowercaseLanguage = language.lower();
     112    String lowercaseLanguage = language.convertToASCIILowercase();
    113113    String languageWithoutLocaleMatch;
    114114    String languageMatchButNotLocale;
  • trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp

    r191014 r196223  
    483483
    484484        if (m_font->isSmallCaps() && u_islower(m_normalizedBuffer[currentRun->startIndex()])) {
    485             String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters()).upper();
     485            String upperText = String(m_normalizedBuffer.get() + currentRun->startIndex(), currentRun->numCharacters()).convertToUppercaseWithoutLocale();
    486486            currentFontData = m_font->glyphDataForCharacter(upperText[0], false, SmallCapsVariant).font;
    487487            const UChar* characters = StringView(upperText).upconvertedCharacters();
  • trunk/Source/WebCore/platform/network/HTTPParsers.cpp

    r195523 r196223  
    457457ContentTypeOptionsDisposition parseContentTypeOptionsHeader(const String& header)
    458458{
    459     if (header.stripWhiteSpace().lower() == "nosniff")
     459    if (equalLettersIgnoringASCIICase(header.stripWhiteSpace(), "nosniff"))
    460460        return ContentTypeOptionsNosniff;
    461461    return ContentTypeOptionsNone;
  • trunk/Source/WebCore/platform/network/MIMEHeader.cpp

    r166047 r196223  
    7171            continue;
    7272        }
    73         key = line.substring(0, semiColonIndex).lower().stripWhiteSpace();
     73        key = line.substring(0, semiColonIndex).convertToASCIILowercase().stripWhiteSpace();
    7474        value.append(line.substring(semiColonIndex + 1));
    7575    }
     
    115115MIMEHeader::Encoding MIMEHeader::parseContentTransferEncoding(const String& text)
    116116{
    117     String encoding = text.stripWhiteSpace().lower();
    118     if (encoding == "base64")
     117    String encoding = text.stripWhiteSpace();
     118    if (equalLettersIgnoringASCIICase(encoding, "base64"))
    119119        return Base64;
    120     if (encoding == "quoted-printable")
     120    if (equalLettersIgnoringASCIICase(encoding, "quoted-printable"))
    121121        return QuotedPrintable;
    122     if (encoding == "7bit")
     122    if (equalLettersIgnoringASCIICase(encoding, "7bit"))
    123123        return SevenBit;
    124     if (encoding == "binary")
     124    if (equalLettersIgnoringASCIICase(encoding, "binary"))
    125125        return Binary;
    126126    LOG_ERROR("Unknown encoding '%s' found in MIME header.", text.ascii().data());
  • trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp

    r194819 r196223  
    8383#if USE(CFNETWORK)
    8484
    85 static HashSet<String>& allowsAnyHTTPSCertificateHosts()
    86 {
    87     static NeverDestroyed<HashSet<String>> hosts;
     85static HashSet<String, ASCIICaseInsensitiveHash>& allowsAnyHTTPSCertificateHosts()
     86{
     87    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> hosts;
    8888    return hosts;
    8989}
    9090
    91 static HashMap<String, RetainPtr<CFDataRef>>& clientCerts()
    92 {
    93     typedef HashMap<String, RetainPtr<CFDataRef>> CertsMap;
    94     static NeverDestroyed<CertsMap> certs;
     91static HashMap<String, RetainPtr<CFDataRef>, ASCIICaseInsensitiveHash>& clientCertificates()
     92{
     93    static NeverDestroyed<HashMap<String, RetainPtr<CFDataRef>, ASCIICaseInsensitiveHash>> certs;
    9594    return certs;
    9695}
     
    170169    sslProps = adoptCF(ResourceHandle::createSSLPropertiesFromNSURLRequest(firstRequest()));
    171170#else
    172     if (allowsAnyHTTPSCertificateHosts().contains(firstRequest().url().host().lower())) {
     171    if (allowsAnyHTTPSCertificateHosts().contains(firstRequest().url().host())) {
    173172        sslProps = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    174173        CFDictionaryAddValue(sslProps.get(), kCFStreamSSLAllowsAnyRoot, kCFBooleanTrue);
     
    178177    }
    179178
    180     HashMap<String, RetainPtr<CFDataRef>>::iterator clientCert = clientCerts().find(firstRequest().url().host().lower());
    181     if (clientCert != clientCerts().end()) {
     179    auto clientCert = clientCertificates().find(firstRequest().url().host());
     180    if (clientCert != clientCertificates().end()) {
    182181        if (!sslProps)
    183182            sslProps = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
     
    604603void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
    605604{
    606     allowsAnyHTTPSCertificateHosts().add(host.lower());
    607 }
    608 
    609 void ResourceHandle::setClientCertificate(const String& host, CFDataRef cert)
    610 {
    611     clientCerts().set(host.lower(), cert);
     605    allowsAnyHTTPSCertificateHosts().add(host);
     606}
     607
     608void ResourceHandle::setClientCertificate(const String& host, CFDataRef certificate)
     609{
     610    clientCertificates().set(host, certificate);
    612611}
    613612
  • trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp

    r176963 r196223  
    196196            Vector<String> keyValuePair;
    197197            attribute->split('=', true, keyValuePair);
    198             String key = keyValuePair[0].stripWhiteSpace().lower();
     198            String key = keyValuePair[0].stripWhiteSpace();
    199199            String val = keyValuePair[1].stripWhiteSpace();
    200             if (key == "expires") {
     200            if (equalLettersIgnoringASCIICase(key, "expires")) {
    201201                CString dateStr(reinterpret_cast<const char*>(val.characters8()), val.length());
    202202                expires = WTF::parseDateFromNullTerminatedCharacters(dateStr.data()) / WTF::msPerSecond;
    203             } else if (key == "max-age")
     203            } else if (equalLettersIgnoringASCIICase(key, "max-age"))
    204204                expires = time(0) + val.toInt();
    205             else if (key == "domain")
     205            else if (equalLettersIgnoringASCIICase(key, "domain"))
    206206                domain = val;
    207             else if (key == "path")
     207            else if (equalLettersIgnoringASCIICase(key, "path"))
    208208                path = val;
    209209        } else {
    210             String key = attribute->stripWhiteSpace().lower();
    211             if (key == "secure")
     210            String key = attribute->stripWhiteSpace();
     211            if (equalLettersIgnoringASCIICase(key, "secure"))
    212212                secure = "TRUE";
    213213        }
  • trunk/Source/WebCore/platform/network/curl/MultipartHandle.cpp

    r183265 r196223  
    347347        String mimeType = extractMIMETypeFromMediaType(contentType);
    348348
    349         response->setMimeType(mimeType.lower());
     349        response->setMimeType(mimeType.convertToASCIILowercase());
    350350        response->setTextEncodingName(extractCharsetFromMediaType(contentType));
    351351
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp

    r186476 r196223  
    123123void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
    124124{
    125     allowsAnyHTTPSCertificateHosts(host.lower());
     125    allowsAnyHTTPSCertificateHosts(host);
    126126}
    127127
     
    135135
    136136#if PLATFORM(WIN) && USE(CF)
    137 // FIXME:  The CFDataRef will need to be something else when
    138 // building without
    139 static HashMap<String, RetainPtr<CFDataRef> >& clientCerts()
    140 {
    141     static HashMap<String, RetainPtr<CFDataRef> > certs;
    142     return certs;
    143 }
    144 
    145 void ResourceHandle::setClientCertificate(const String& host, CFDataRef cert)
    146 {
    147     clientCerts().set(host.lower(), cert);
    148 }
     137
     138void ResourceHandle::setClientCertificate(const String&, CFDataRef)
     139{
     140}
     141
    149142#endif
    150143
  • trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp

    r195743 r196223  
    498498
    499499        d->m_response.setHTTPStatusCode(httpCode);
    500         d->m_response.setMimeType(extractMIMETypeFromMediaType(d->m_response.httpHeaderField(HTTPHeaderName::ContentType)).lower());
     500        d->m_response.setMimeType(extractMIMETypeFromMediaType(d->m_response.httpHeaderField(HTTPHeaderName::ContentType)).convertToASCIILowercase());
    501501        d->m_response.setTextEncodingName(extractCharsetFromMediaType(d->m_response.httpHeaderField(HTTPHeaderName::ContentType)));
    502502
  • trunk/Source/WebCore/platform/network/curl/SSLHandle.cpp

    r165996 r196223  
    4040namespace WebCore {
    4141
    42 typedef std::tuple<WTF::String, WTF::String> clientCertificate;
    43 static HashMap<String, ListHashSet<String>> allowedHosts;
    44 static HashMap<String, clientCertificate> allowedClientHosts;
     42typedef std::tuple<String, String> clientCertificate;
     43static HashMap<String, ListHashSet<String>, ASCIICaseInsensitiveHash> allowedHosts;
     44static HashMap<String, clientCertificate, ASCIICaseInsensitiveHash> allowedClientHosts;
    4545
    4646void allowsAnyHTTPSCertificateHosts(const String& host)
     
    5353{
    5454    clientCertificate clientInfo(certificate, key);
    55     allowedClientHosts.set(host.lower(), clientInfo);
     55    allowedClientHosts.set(host, clientInfo);
    5656}
    5757
     
    5959{
    6060    String host = handle->firstRequest().url().host();
    61     HashMap<String, clientCertificate>::iterator it = allowedClientHosts.find(host.lower());
     61    auto it = allowedClientHosts.find(host);
    6262    if (it == allowedClientHosts.end())
    6363        return;
     
    7272bool sslIgnoreHTTPSCertificate(const String& host, const ListHashSet<String>& certificates)
    7373{
    74     HashMap<String, ListHashSet<String>>::iterator it = allowedHosts.find(host);
     74    auto it = allowedHosts.find(host);
    7575    if (it != allowedHosts.end()) {
    7676        if ((it->value).isEmpty()) {
     
    8080        if (certificates.size() != it->value.size())
    8181            return false;
    82         ListHashSet<String>::const_iterator certsIter = certificates.begin();
    83         ListHashSet<String>::iterator valueIter = (it->value).begin();
     82        auto certsIter = certificates.begin();
     83        auto valueIter = (it->value).begin();
    8484        for (; valueIter != (it->value).end(); ++valueIter, ++certsIter) {
    8585            if (*certsIter != *valueIter)
     
    199199
    200200#if PLATFORM(WIN)
    201     HashMap<String, ListHashSet<String>>::iterator it = allowedHosts.find(host);
     201    auto it = allowedHosts.find(host);
    202202    ok = (it != allowedHosts.end());
    203203#else
     
    205205    if (!pemData(ctx, certificates))
    206206        return 0;
    207     ok = sslIgnoreHTTPSCertificate(host.lower(), certificates);
     207    ok = sslIgnoreHTTPSCertificate(host, certificates);
    208208#endif
    209209
  • trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp

    r196061 r196223  
    245245static bool gIgnoreSSLErrors = false;
    246246
    247 static HashSet<String>& allowsAnyHTTPSCertificateHosts()
    248 {
    249     DEPRECATED_DEFINE_STATIC_LOCAL(HashSet<String>, hosts, ());
     247typedef HashSet<String, ASCIICaseInsensitiveHash> HostsSet;
     248static HostsSet& allowsAnyHTTPSCertificateHosts()
     249{
     250    DEPRECATED_DEFINE_STATIC_LOCAL(HostsSet, hosts, ());
    250251    return hosts;
    251252}
    252253
    253 typedef HashMap<String, HostTLSCertificateSet> CertificatesMap;
     254typedef HashMap<String, HostTLSCertificateSet, ASCIICaseInsensitiveHash> CertificatesMap;
    254255static CertificatesMap& clientCertificates()
    255256{
     
    323324        return false;
    324325
    325     String lowercaseHostURL = handle->firstRequest().url().host().lower();
    326     if (allowsAnyHTTPSCertificateHosts().contains(lowercaseHostURL))
     326    String host = handle->firstRequest().url().host();
     327    if (allowsAnyHTTPSCertificateHosts().contains(host))
    327328        return false;
    328329
    329330    // We aren't ignoring errors globally, but the user may have already decided to accept this certificate.
    330     auto it = clientCertificates().find(lowercaseHostURL);
     331    auto it = clientCertificates().find(host);
    331332    if (it != clientCertificates().end() && it->value.contains(certificate))
    332333        return false;
     
    10881089void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
    10891090{
    1090     allowsAnyHTTPSCertificateHosts().add(host.lower());
     1091    allowsAnyHTTPSCertificateHosts().add(host);
    10911092}
    10921093
    10931094void ResourceHandle::setClientCertificate(const String& host, GTlsCertificate* certificate)
    10941095{
    1095     clientCertificates().add(host.lower(), HostTLSCertificateSet()).iterator->value.add(certificate);
     1096    clientCertificates().add(host, HostTLSCertificateSet()).iterator->value.add(certificate);
    10961097}
    10971098
  • trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp

    r189038 r196223  
    158158
    159159struct ScriptNameCodeMapHashTraits : public HashTraits<String> {
    160     static const int minimumTableSize = WTF::HashTableCapacityForSize<sizeof(scriptNameCodeList) / sizeof(ScriptNameCode)>::value;
    161 };
    162 
    163 typedef HashMap<String, UScriptCode, DefaultHash<String>::Hash, ScriptNameCodeMapHashTraits> ScriptNameCodeMap;
     160    static const int minimumTableSize = WTF::HashTableCapacityForSize<WTF_ARRAY_LENGTH(scriptNameCodeList)>::value;
     161};
     162
     163typedef HashMap<String, UScriptCode, ASCIICaseInsensitiveHash, ScriptNameCodeMapHashTraits> ScriptNameCodeMap;
    164164
    165165UScriptCode scriptNameToCode(const String& scriptName)
    166166{
    167     static NeverDestroyed<ScriptNameCodeMap> scriptNameCodeMap;
    168     if (scriptNameCodeMap.get().isEmpty()) {
    169         for (size_t i = 0; i < sizeof(scriptNameCodeList) / sizeof(ScriptNameCode); ++i)
    170             scriptNameCodeMap.get().set(ASCIILiteral(scriptNameCodeList[i].name), scriptNameCodeList[i].code);
    171     }
    172 
    173     ScriptNameCodeMap::iterator it = scriptNameCodeMap.get().find(scriptName.lower());
     167    static NeverDestroyed<ScriptNameCodeMap> scriptNameCodeMap = []() {
     168        ScriptNameCodeMap map;
     169        for (auto& nameAndCode : scriptNameCodeList)
     170            map.add(ASCIILiteral(nameAndCode.name), nameAndCode.code);
     171        return map;
     172    }();
     173
     174    auto it = scriptNameCodeMap.get().find(scriptName);
    174175    if (it != scriptNameCodeMap.get().end())
    175176        return it->value;
     
    384385
    385386struct LocaleScriptMapHashTraits : public HashTraits<String> {
    386     static const int minimumTableSize = WTF::HashTableCapacityForSize<sizeof(localeScriptList) / sizeof(LocaleScript)>::value;
    387 };
    388 
    389 typedef HashMap<String, UScriptCode, DefaultHash<String>::Hash, LocaleScriptMapHashTraits> LocaleScriptMap;
     387    static const int minimumTableSize = WTF::HashTableCapacityForSize<WTF_ARRAY_LENGTH(localeScriptList)>::value;
     388};
     389
     390typedef HashMap<String, UScriptCode, ASCIICaseInsensitiveHash, LocaleScriptMapHashTraits> LocaleScriptMap;
    390391
    391392UScriptCode localeToScriptCodeForFontSelection(const String& locale)
    392393{
    393     static NeverDestroyed<LocaleScriptMap> localeScriptMap;
    394     if (localeScriptMap.get().isEmpty()) {
    395         for (size_t i = 0; i < sizeof(localeScriptList) / sizeof(LocaleScript); ++i)
    396             localeScriptMap.get().set(ASCIILiteral(localeScriptList[i].locale), localeScriptList[i].script);
    397     }
    398 
    399     String canonicalLocale = locale.lower().replace('-', '_');
     394    static NeverDestroyed<LocaleScriptMap> localeScriptMap = []() {
     395        LocaleScriptMap map;
     396        for (auto& localeAndScript : localeScriptList)
     397            map.add(ASCIILiteral(localeAndScript.locale), localeAndScript.script);
     398        return map;
     399    }();
     400
     401    String canonicalLocale = locale;
     402    canonicalLocale.replace('-', '_');
    400403    while (!canonicalLocale.isEmpty()) {
    401         LocaleScriptMap::iterator it = localeScriptMap.get().find(canonicalLocale);
     404        auto it = localeScriptMap.get().find(canonicalLocale);
    402405        if (it != localeScriptMap.get().end())
    403406            return it->value;
    404         size_t pos = canonicalLocale.reverseFind('_');
    405         if (pos == notFound)
     407        auto underscorePosition = canonicalLocale.reverseFind('_');
     408        if (underscorePosition == notFound)
    406409            break;
    407         UScriptCode code = scriptNameToCode(canonicalLocale.substring(pos + 1));
     410        UScriptCode code = scriptNameToCode(canonicalLocale.substring(underscorePosition + 1));
    408411        if (code != USCRIPT_INVALID_CODE && code != USCRIPT_UNKNOWN)
    409412            return code;
    410         canonicalLocale = canonicalLocale.substring(0, pos);
     413        canonicalLocale = canonicalLocale.substring(0, underscorePosition);
    411414    }
    412415    return USCRIPT_COMMON;
  • trunk/Source/WebCore/platform/text/win/LocaleWin.cpp

    r195879 r196223  
    4949
    5050typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD);
    51 typedef HashMap<String, LCID> NameToLCIDMap;
     51typedef HashMap<String, LCID, ASCIICaseInsensitiveHash> NameToLCIDMap;
    5252
    5353static String extractLanguageCode(const String& locale)
     
    108108    DEPRECATED_DEFINE_STATIC_LOCAL(NameToLCIDMap, map, ());
    109109    ensureNameToLCIDMap(map);
    110     String localeName = String(name).replace('_', '-').lower();
     110    String localeName = String(name).replace('_', '-');
    111111    do {
    112112        NameToLCIDMap::const_iterator iterator = map.find(localeName);
  • trunk/Source/WebCore/platform/win/PasteboardWin.cpp

    r189182 r196223  
    183183static ClipboardDataType clipboardTypeFromMIMEType(const String& type)
    184184{
    185     String qType = type.stripWhiteSpace().lower();
     185    String strippedType = type.stripWhiteSpace();
    186186
    187187    // two special cases for IE compatibility
    188     if (qType == "text" || qType == "text/plain" || qType.startsWith("text/plain;"))
     188    if (equalLettersIgnoringASCIICase(strippedType, "text") || equalLettersIgnoringASCIICase(strippedType, "text/plain") || strippedType.startsWith("text/plain;", false))
    189189        return ClipboardDataTypeText;
    190     if (qType == "url" || qType == "text/uri-list")
     190    if (equalLettersIgnoringASCIICase(strippedType, "url") || equalLettersIgnoringASCIICase(strippedType, "text/uri-list"))
    191191        return ClipboardDataTypeURL;
    192     if (qType == "text/html")
     192    if (equalLettersIgnoringASCIICase(strippedType, "text/html"))
    193193        return ClipboardDataTypeTextHTML;
    194194
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r195766 r196223  
    10361036        break;
    10371037    case UPPERCASE:
    1038         text = text.upper(style.locale());
     1038        text = text.convertToUppercaseWithLocale(style.locale());
    10391039        break;
    10401040    case LOWERCASE:
    1041         text = text.lower(style.locale());
     1041        text = text.convertToLowercaseWithLocale(style.locale());
    10421042        break;
    10431043    }
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r195743 r196223  
    10311031bool XMLHttpRequest::responseIsXML() const
    10321032{
    1033     // FIXME: Remove the lower() call when DOMImplementation.isXMLMIMEType() is modified
    1034     //        to do case insensitive MIME type matching.
    1035     return DOMImplementation::isXMLMIMEType(responseMIMEType().lower());
     1033    return DOMImplementation::isXMLMIMEType(responseMIMEType());
    10361034}
    10371035
  • trunk/Source/WebKit/mac/ChangeLog

    r196070 r196223  
     12016-02-06  Darin Adler  <darin@apple.com>
     2
     3        Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
     4        https://bugs.webkit.org/show_bug.cgi?id=153905
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Plugins/WebBasePluginPackage.mm:
     9        (-[WebBasePluginPackage getPluginInfoFromPLists]): Use modern for loops.
     10        (-[WebBasePluginPackage supportsExtension:]): Use convertToASCIILowercase for extension assert.
     11        Also use modern for loop.
     12        (-[WebBasePluginPackage supportsMIMEType:]): Ditto.
     13        (-[WebBasePluginPackage MIMETypeForExtension:]): Ditto.
     14
    1152016-02-03  Jessie Berlin  <jberlin@webkit.org>
    216
  • trunk/Source/WebKit/mac/Plugins/WebBasePluginPackage.mm

    r193378 r196223  
    217217       
    218218        NSArray *extensions = [[MIMEDictionary objectForKey:WebPluginExtensionsKey] _web_lowercaseStrings];
    219         for (NSUInteger i = 0; i < [extensions count]; ++i) {
     219        for (NSString *extension in extensions) {
    220220            // The DivX plug-in lists multiple extensions in a comma separated string instead of using
    221221            // multiple array elements in the property list. Work around this here by splitting the
    222222            // extension string into components.
    223             NSArray *extensionComponents = [[extensions objectAtIndex:i] componentsSeparatedByString:@","];
    224 
    225             for (NSString *extension in extensionComponents)
    226                 mimeClassInfo.extensions.append(extension);
     223            for (NSString *component in [extension componentsSeparatedByString:@","])
     224                mimeClassInfo.extensions.append(component);
    227225        }
    228226
    229         mimeClassInfo.type = String(MIME).lower();
    230 
     227        mimeClassInfo.type = String(MIME).convertToASCIILowercase();
    231228        mimeClassInfo.desc = [MIMEDictionary objectForKey:WebPluginTypeDescriptionKey];
    232229
     
    285282- (BOOL)supportsExtension:(const String&)extension
    286283{
    287     ASSERT(extension.lower() == extension);
    288    
    289     for (size_t i = 0; i < pluginInfo.mimes.size(); ++i) {
    290         const Vector<String>& extensions = pluginInfo.mimes[i].extensions;
    291 
    292         if (std::find(extensions.begin(), extensions.end(), extension) != extensions.end())
     284    ASSERT(extension.convertToASCIILowercase() == extension);
     285   
     286    for (auto& entry : pluginInfo.mimes) {
     287        if (entry.extensions.contains(extension))
    293288            return YES;
    294289    }
     
    299294- (BOOL)supportsMIMEType:(const WTF::String&)mimeType
    300295{
    301     ASSERT(mimeType.lower() == mimeType);
    302    
    303     for (size_t i = 0; i < pluginInfo.mimes.size(); ++i) {
    304         if (pluginInfo.mimes[i].type == mimeType)
     296    ASSERT(mimeType.convertToASCIILowercase() == mimeType);
     297   
     298    for (auto& entry : pluginInfo.mimes) {
     299        if (entry.type == mimeType)
    305300            return YES;
    306301    }
    307    
     302
    308303    return NO;
    309304}
     
    311306- (NSString *)MIMETypeForExtension:(const String&)extension
    312307{
    313     ASSERT(extension.lower() == extension);
    314    
    315     for (size_t i = 0; i < pluginInfo.mimes.size(); ++i) {
    316         const MimeClassInfo& mimeClassInfo = pluginInfo.mimes[i];
    317         const Vector<String>& extensions = mimeClassInfo.extensions;
    318 
    319         if (std::find(extensions.begin(), extensions.end(), extension) != extensions.end())
    320             return mimeClassInfo.type;
     308    ASSERT(extension.convertToASCIILowercase() == extension);
     309   
     310    for (auto& entry : pluginInfo.mimes) {
     311        if (entry.extensions.contains(extension))
     312            return entry.type;
    321313    }
    322314
  • trunk/Source/WebKit/win/ChangeLog

    r196165 r196223  
     12016-02-06  Darin Adler  <darin@apple.com>
     2
     3        Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
     4        https://bugs.webkit.org/show_bug.cgi?id=153905
     5
     6        Reviewed by Sam Weinig.
     7
     8        * Plugins/PluginDatabase.cpp:
     9        (WebCore::PluginDatabase::pluginForMIMEType): Use ASCII case-insensitive map rather
     10        than lowercasing the MIME type.
     11        (WebCore::PluginDatabase::setPreferredPluginForMIMEType): Ditto.
     12
     13        * Plugins/PluginDatabase.h: Make m_preferredPlugins use an ASCII case-insensitive hash.
     14
     15        * Plugins/PluginPackage.h: Use ASCII case-insensitive hash for maps keyed by MIME type.
     16
     17        * Plugins/PluginPackageWin.cpp:
     18        (WebCore::PluginPackage::fetchInfo): Use convertToASCIILowercase to lowercase a MIME type.
     19
    1202016-02-04  Joseph Pecoraro  <pecoraro@apple.com>
    221
  • trunk/Source/WebKit/win/Plugins/PluginDatabase.cpp

    r195743 r196223  
    105105
    106106        // Unload plugins
    107         PluginSet::const_iterator end = pluginsToUnload.end();
    108         for (PluginSet::const_iterator it = pluginsToUnload.begin(); it != end; ++it)
     107        auto end = pluginsToUnload.end();
     108        for (auto it = pluginsToUnload.begin(); it != end; ++it)
    109109            remove(it->get());
    110110
     
    122122    bool shouldSkipUnchangedFiles = !pluginSetChanged;
    123123
    124     HashSet<String>::const_iterator pathsEnd = paths.end();
    125     for (HashSet<String>::const_iterator it = paths.begin(); it != pathsEnd; ++it) {
     124    auto pathsEnd = paths.end();
     125    for (auto it = paths.begin(); it != pathsEnd; ++it) {
    126126        time_t lastModified;
    127127        if (!getFileModificationTime(*it, lastModified))
     
    157157
    158158    // Register plug-in MIME types
    159     PluginSet::const_iterator end = m_plugins.end();
    160     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
     159    auto end = m_plugins.end();
     160    for (auto it = m_plugins.begin(); it != end; ++it) {
    161161        // Get MIME types
    162         MIMEToDescriptionsMap::const_iterator map_it = (*it)->mimeToDescriptions().begin();
    163         MIMEToDescriptionsMap::const_iterator map_end = (*it)->mimeToDescriptions().end();
     162        auto map_it = (*it)->mimeToDescriptions().begin();
     163        auto map_end = (*it)->mimeToDescriptions().end();
    164164        for (; map_it != map_end; ++map_it)
    165165            m_registeredMIMETypes.add(map_it->key);
     
    173173    Vector<PluginPackage*> result;
    174174
    175     PluginSet::const_iterator end = m_plugins.end();
    176     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it)
     175    auto end = m_plugins.end();
     176    for (auto it = m_plugins.begin(); it != end; ++it)
    177177        result.append((*it).get());
    178178
     
    191191{
    192192    if (mimeType.isEmpty())
    193         return 0;
    194 
    195     String key = mimeType.lower();
    196     PluginSet::const_iterator end = m_plugins.end();
    197     PluginPackage* preferredPlugin = m_preferredPlugins.get(key);
     193        return nullptr;
     194
     195    PluginPackage* preferredPlugin = m_preferredPlugins.get(mimeType);
    198196    if (preferredPlugin
    199197        && preferredPlugin->isEnabled()
    200         && preferredPlugin->mimeToDescriptions().contains(key)) {
     198        && preferredPlugin->mimeToDescriptions().contains(mimeType)) {
    201199        return preferredPlugin;
    202200    }
     
    204202    Vector<PluginPackage*, 2> pluginChoices;
    205203
    206     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
     204    auto end = m_plugins.end();
     205    for (auto it = m_plugins.begin(); it != end; ++it) {
    207206        PluginPackage* plugin = (*it).get();
    208207
     
    210209            continue;
    211210
    212         if (plugin->mimeToDescriptions().contains(key)) {
     211        if (plugin->mimeToDescriptions().contains(mimeType)) {
    213212#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
    214213            if (!plugin->ensurePluginLoaded())
     
    232231        return String();
    233232
    234     PluginSet::const_iterator end = m_plugins.end();
     233    auto end = m_plugins.end();
    235234    String mimeType;
    236235    Vector<PluginPackage*, 2> pluginChoices;
    237236    HashMap<PluginPackage*, String> mimeTypeForPlugin;
    238237
    239     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
     238    for (auto it = m_plugins.begin(); it != end; ++it) {
    240239        if (!(*it)->isEnabled())
    241240            continue;
    242241
    243         MIMEToExtensionsMap::const_iterator mime_end = (*it)->mimeToExtensions().end();
    244 
    245         for (MIMEToExtensionsMap::const_iterator mime_it = (*it)->mimeToExtensions().begin(); mime_it != mime_end; ++mime_it) {
     242        auto mime_end = (*it)->mimeToExtensions().end();
     243
     244        for (auto mime_it = (*it)->mimeToExtensions().begin(); mime_it != mime_end; ++mime_it) {
    246245            mimeType = mime_it->key;
    247246            PluginPackage* preferredPlugin = m_preferredPlugins.get(mimeType);
     
    306305{
    307306    if (!plugin || plugin->mimeToExtensions().contains(mimeType))
    308         m_preferredPlugins.set(mimeType.lower(), plugin);
     307        m_preferredPlugins.set(mimeType, plugin);
    309308}
    310309
     
    320319void PluginDatabase::getDeletedPlugins(PluginSet& plugins) const
    321320{
    322     PluginSet::const_iterator end = m_plugins.end();
    323     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
     321    auto end = m_plugins.end();
     322    for (auto it = m_plugins.begin(); it != end; ++it) {
    324323        if (!fileExistsAndIsNotDisabled((*it)->path()))
    325324            plugins.add(*it);
     
    342341void PluginDatabase::remove(PluginPackage* package)
    343342{
    344     MIMEToExtensionsMap::const_iterator it = package->mimeToExtensions().begin();
    345     MIMEToExtensionsMap::const_iterator end = package->mimeToExtensions().end();
     343    auto it = package->mimeToExtensions().begin();
     344    auto end = package->mimeToExtensions().end();
    346345    for ( ; it != end; ++it) {
    347         PluginPackageByNameMap::iterator packageInMap = m_preferredPlugins.find(it->key);
     346        auto packageInMap = m_preferredPlugins.find(it->key);
    348347        if (packageInMap != m_preferredPlugins.end() && packageInMap->value == package)
    349348            m_preferredPlugins.remove(packageInMap);
     
    409408    String fileNameFilter("");
    410409
    411     Vector<String>::const_iterator dirsEnd = m_pluginDirectories.end();
    412     for (Vector<String>::const_iterator dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
     410    auto dirsEnd = m_pluginDirectories.end();
     411    for (auto dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
    413412        Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter);
    414         Vector<String>::const_iterator pluginsEnd = pluginPaths.end();
    415         for (Vector<String>::const_iterator pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
     413        auto pluginsEnd = pluginPaths.end();
     414        for (auto pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
    416415            if (!fileExistsAndIsNotDisabled(*pIt))
    417416                continue;
     
    584583    }
    585584
    586     PluginSet::const_iterator end = m_plugins.end();
    587     for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
     585    auto end = m_plugins.end();
     586    for (auto it = m_plugins.begin(); it != end; ++it) {
    588587        if (!(writeUTF8String(file, (*it)->path())
    589588              && writeTime(file, (*it)->lastModified())
  • trunk/Source/WebKit/win/Plugins/PluginDatabase.h

    r178219 r196223  
    108108        HashMap<String, RefPtr<PluginPackage> > m_pluginsByPath;
    109109        HashMap<String, time_t> m_pluginPathsWithTimes;
    110         HashMap<String, RefPtr<PluginPackage> > m_preferredPlugins;
     110        HashMap<String, RefPtr<PluginPackage>, ASCIICaseInsensitiveHash> m_preferredPlugins;
    111111#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE)
    112112        bool m_persistentMetadataCacheIsLoaded;
  • trunk/Source/WebKit/win/Plugins/PluginPackage.h

    r178219 r196223  
    4040
    4141namespace WebCore {
    42     typedef HashMap<String, String> MIMEToDescriptionsMap;
    43     typedef HashMap<String, Vector<String> > MIMEToExtensionsMap;
     42
     43    typedef HashMap<String, String, ASCIICaseInsensitiveHash> MIMEToDescriptionsMap;
     44    typedef HashMap<String, Vector<String>, ASCIICaseInsensitiveHash> MIMEToExtensionsMap;
    4445
    4546    class PluginPackage : public RefCounted<PluginPackage> {
  • trunk/Source/WebKit/win/Plugins/PluginPackageWin.cpp

    r195743 r196223  
    201201
    202202    for (unsigned i = 0; i < types.size(); i++) {
    203         String type = types[i].lower();
     203        String type = types[i].convertToASCIILowercase();
    204204        String description = i < descriptions.size() ? descriptions[i] : "";
    205205        String extensionList = i < extensionLists.size() ? extensionLists[i] : "";
     
    320320        return false;
    321321
    322     MIMEToExtensionsMap::const_iterator::Keys end = a.m_mimeToExtensions.end().keys();
    323     for (MIMEToExtensionsMap::const_iterator::Keys it = a.m_mimeToExtensions.begin().keys(); it != end; ++it) {
     322    auto end = a.m_mimeToExtensions.end().keys();
     323    for (auto it = a.m_mimeToExtensions.begin().keys(); it != end; ++it) {
    324324        if (!b.m_mimeToExtensions.contains(*it))
    325325            return false;
  • trunk/Source/WebKit2/ChangeLog

    r196214 r196223  
     12016-02-06  Darin Adler  <darin@apple.com>
     2
     3        Finish auditing call sites of upper() and lower(), eliminate many, and rename the functions
     4        https://bugs.webkit.org/show_bug.cgi?id=153905
     5
     6        Reviewed by Sam Weinig.
     7
     8        * NetworkProcess/CustomProtocols/CustomProtocolManager.h: Use ASCII case-insensitive hash
     9        for set of registered schemes.
     10
     11        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
     12        (WebKit::getPluginInfoFromPropertyLists): Use convertToASCIILowercase for MIME type and
     13        for file extensions.
     14
     15        * Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:
     16        (WebKit::NetscapePluginModule::parseMIMEDescription): Use convertToASCIILowercase for
     17        MIME description.
     18
     19        * UIProcess/API/efl/ewk_context.cpp:
     20        (ewk_context_preferred_languages_set): Use convertToASCIILowercase for language.
     21
     22        * UIProcess/API/gtk/WebKitWebContext.cpp:
     23        (webkit_web_context_set_preferred_languages): Use convertToASCIILowercase for language.
     24
     25        * UIProcess/Plugins/PluginInfoStore.cpp:
     26        (WebKit::PluginInfoStore::findPluginForExtension): Use Vector::contains instead of
     27        writing it out using std::find.
     28        (WebKit::pathExtension): Lowercase the result with convertToASCIILowercase instead of
     29        leaving that to the caller.
     30        (WebKit::PluginInfoStore::findPlugin): Removed call to lower since pathExtension
     31        handles that now.
     32
     33        * UIProcess/WebPageProxy.cpp:
     34        (WebKit::WebPageProxy::findPlugin): Use convertToASCIILowercase for MIME type.
     35
     36        * UIProcess/WebProcessPool.cpp:
     37        (WebKit::WebProcessPool::globalURLSchemesWithCustomProtocolHandlers): Use
     38        an ASCII case-insensitive hash.
     39        (WebKit::WebProcessPool::registerGlobalURLSchemeAsHavingCustomProtocolHandlers):
     40        Remove lowercasing, since the hash is now ASCII case-insensitive.
     41        (WebKit::WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers):
     42        Ditto.
     43
     44        * UIProcess/WebProcessPool.h: Use an ASCII case-insensitive hash.
     45
     46        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     47        (WebKit::NetscapePlugin::initialize): Use convertToASCIILowercase on parameter names
     48        and values.
     49
     50        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     51        (WebKit::pluginSupportsExtension): Use convertToASCIILowercase for extension assertion.
     52        Also use a modern for loop.
     53        (WebKit::WebFrameLoaderClient::objectContentType): Make the checks for empty MIME types
     54        a little less redundant. Reordered logic to avoid checking the list of supported MIME
     55        types extra times, and to eliminate the need for a boolean. Use convertToASCIILowercase
     56        on the extension.
     57
    1582016-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
    259
  • trunk/Source/WebKit2/NetworkProcess/CustomProtocols/CustomProtocolManager.h

    r195005 r196223  
    3737#include <wtf/RetainPtr.h>
    3838#include <wtf/Threading.h>
     39#include <wtf/text/StringHash.h>
    3940OBJC_CLASS NSURLSessionConfiguration;
    4041OBJC_CLASS WKCustomProtocol;
     
    100101
    101102#if PLATFORM(COCOA)
    102     HashSet<String> m_registeredSchemes;
     103    HashSet<String, ASCIICaseInsensitiveHash> m_registeredSchemes;
    103104    Lock m_registeredSchemesMutex;
    104105
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm

    r185294 r196223  
    187187            mimeTypeDescription = 0;
    188188
    189         mimeClassInfo.type = String(mimeType).lower();
     189        mimeClassInfo.type = String(mimeType).convertToASCIILowercase();
    190190        mimeClassInfo.desc = mimeTypeDescription;
    191191
     
    205205            // extension string into components.
    206206            Vector<String> extensionComponents;
    207             String(extension).lower().split(',', extensionComponents);
    208 
    209             for (size_t i = 0; i < extensionComponents.size(); ++i)
    210                 mimeClassInfo.extensions.append(extensionComponents[i]);
     207            String(extension).convertToASCIILowercase().split(',', extensionComponents);
     208
     209            for (auto& component : extensionComponents)
     210                mimeClassInfo.extensions.append(component);
    211211        }
    212212
  • trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp

    r174507 r196223  
    7777
    7878    Vector<String> types;
    79     mimeDescription.lower().split(UChar(';'), false, types);
     79    mimeDescription.convertToASCIILowercase().split(UChar(';'), false, types);
    8080    result.reserveInitialCapacity(types.size());
    8181
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp

    r194359 r196223  
    564564        void* data;
    565565        EINA_LIST_FOREACH(languages, l, data)
    566             preferredLanguages.append(String::fromUTF8(static_cast<char*>(data)).lower().replace("_", "-"));
     566            preferredLanguages.append(String::fromUTF8(static_cast<char*>(data)).convertToASCIILowercase().replace("_", "-"));
    567567    }
    568568
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

    r194532 r196223  
    969969    Vector<String> languages;
    970970    for (size_t i = 0; languageList[i]; ++i)
    971         languages.append(String::fromUTF8(languageList[i]).lower().replace("_", "-"));
     971        languages.append(String::fromUTF8(languageList[i]).convertToASCIILowercase().replace("_", "-"));
    972972
    973973    WebCore::overrideUserPreferredLanguages(languages);
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp

    r176290 r196223  
    139139
    140140        for (const auto& mimeClassInfo : plugin.info.mimes) {
    141             const Vector<String>& extensions = mimeClassInfo.extensions;
    142            
    143             if (std::find(extensions.begin(), extensions.end(), extension) != extensions.end()) {
     141            if (mimeClassInfo.extensions.contains(extension)) {
    144142                // We found a supported extension, set the correct MIME type.
    145143                mimeType = mimeClassInfo.type;
     
    161159            extension = filename.substring(extensionPos + 1);
    162160    }
    163    
    164     return extension;
     161    return extension.convertToASCIILowercase();
    165162}
    166163
    167164#if !PLATFORM(COCOA)
     165
    168166PluginModuleLoadPolicy PluginInfoStore::defaultLoadPolicyForPlugin(const PluginModuleInfo&)
    169167{
     
    191189
    192190    // Next, check if any plug-ins claim to support the URL extension.
    193     String extension = pathExtension(url).lower();
     191    String extension = pathExtension(url);
    194192    if (!extension.isNull() && mimeType.isEmpty()) {
    195193        PluginModuleInfo plugin = findPluginForExtension(extension, mimeType, allowedPluginTypes);
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r196024 r196223  
    18641864    MESSAGE_CHECK_URL(urlString);
    18651865
    1866     newMimeType = mimeType.lower();
     1866    newMimeType = mimeType.convertToASCIILowercase();
    18671867    pluginLoadPolicy = PluginModuleLoadNormally;
    18681868
  • trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp

    r195589 r196223  
    914914}
    915915
    916 HashSet<String>& WebProcessPool::globalURLSchemesWithCustomProtocolHandlers()
    917 {
    918     static NeverDestroyed<HashSet<String>> set;
     916HashSet<String, ASCIICaseInsensitiveHash>& WebProcessPool::globalURLSchemesWithCustomProtocolHandlers()
     917{
     918    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> set;
    919919    return set;
    920920}
     
    925925        return;
    926926
    927     String schemeLower = urlScheme.lower();
    928     globalURLSchemesWithCustomProtocolHandlers().add(schemeLower);
     927    globalURLSchemesWithCustomProtocolHandlers().add(urlScheme);
    929928    for (auto* processPool : allProcessPools())
    930         processPool->registerSchemeForCustomProtocol(schemeLower);
     929        processPool->registerSchemeForCustomProtocol(urlScheme);
    931930}
    932931
     
    936935        return;
    937936
    938     String schemeLower = urlScheme.lower();
    939     globalURLSchemesWithCustomProtocolHandlers().remove(schemeLower);
     937    globalURLSchemesWithCustomProtocolHandlers().remove(urlScheme);
    940938    for (auto* processPool : allProcessPools())
    941         processPool->unregisterSchemeForCustomProtocol(schemeLower);
     939        processPool->unregisterSchemeForCustomProtocol(urlScheme);
    942940}
    943941
  • trunk/Source/WebKit2/UIProcess/WebProcessPool.h

    r195589 r196223  
    318318    void unregisterSchemeForCustomProtocol(const String&);
    319319
    320     static HashSet<String>& globalURLSchemesWithCustomProtocolHandlers();
     320    static HashSet<String, ASCIICaseInsensitiveHash>& globalURLSchemesWithCustomProtocolHandlers();
    321321    static void registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
    322322    static void unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&);
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r196053 r196223  
    639639#if PLUGIN_ARCHITECTURE(MAC)
    640640        if (m_pluginModule->pluginQuirks().contains(PluginQuirks::WantsLowercaseParameterNames))
    641             parameterName = parameterName.lower();
     641            parameterName = parameterName.convertToASCIILowercase();
    642642#endif
    643643
     
    676676        for (size_t i = 0; i < parameters.names.size(); ++i) {
    677677            if (equalLettersIgnoringASCIICase(parameters.names[i], "background")) {
    678                 setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i].lower()));
     678                setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i].convertToASCIILowercase()));
    679679                break;
    680680            }
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r195722 r196223  
    15091509static bool pluginSupportsExtension(const PluginData& pluginData, const String& extension)
    15101510{
    1511     ASSERT(extension.lower() == extension);
    1512 
     1511    ASSERT(extension.convertToASCIILowercase() == extension);
    15131512    Vector<MimeClassInfo> mimes;
    15141513    Vector<size_t> mimePluginIndices;
    15151514    pluginData.getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
    1516     for (size_t i = 0; i < mimes.size(); ++i) {
    1517         const MimeClassInfo& mimeClassInfo = mimes[i];
    1518 
     1515    for (auto& mimeClassInfo : mimes) {
    15191516        if (mimeClassInfo.extensions.contains(extension))
    15201517            return true;
     
    15251522ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const String& mimeTypeIn)
    15261523{
    1527     // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code
    1528     // is consolidated.
     1524    // FIXME: This should eventually be merged with WebCore::FrameLoader::defaultObjectContentType.
    15291525
    15301526    String mimeType = mimeTypeIn;
    15311527    if (mimeType.isEmpty()) {
    1532         String extension = url.path().substring(url.path().reverseFind('.') + 1).lower();
     1528        String path = url.path();
     1529        auto dotPosition = path.reverseFind('.');
     1530        if (dotPosition == notFound)
     1531            return ObjectContentFrame;
     1532        String extension = path.substring(dotPosition + 1).convertToASCIILowercase();
    15331533
    15341534        // Try to guess the MIME type from the extension.
    15351535        mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
    1536 
    15371536        if (mimeType.isEmpty()) {
    15381537            // Check if there's a plug-in around that can handle the extension.
     
    15411540                    return ObjectContentNetscapePlugin;
    15421541            }
     1542            return ObjectContentFrame;
    15431543        }
    15441544    }
    15451545
    1546     if (mimeType.isEmpty())
    1547         return ObjectContentFrame;
    1548 
    1549     bool plugInSupportsMIMEType = false;
    1550     if (WebPage* webPage = m_frame->page()) {
    1551         const PluginData& pluginData = webPage->corePage()->pluginData();
    1552         if (pluginData.supportsMimeType(mimeType, PluginData::AllPlugins) && webFrame()->coreFrame()->loader().subframeLoader().allowPlugins())
    1553             plugInSupportsMIMEType = true;
    1554         else if (pluginData.supportsMimeType(mimeType, PluginData::OnlyApplicationPlugins))
    1555             plugInSupportsMIMEType = true;
    1556     }
    1557    
    15581546    if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
    15591547        return ObjectContentImage;
    15601548
    1561     if (plugInSupportsMIMEType)
    1562         return ObjectContentNetscapePlugin;
     1549    if (WebPage* webPage = m_frame->page()) {
     1550        auto allowedPluginTypes = webFrame()->coreFrame()->loader().subframeLoader().allowPlugins()
     1551            ? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins;
     1552        if (webPage->corePage()->pluginData().supportsMimeType(mimeType, allowedPluginTypes))
     1553            return ObjectContentNetscapePlugin;
     1554    }
    15631555
    15641556    if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
Note: See TracChangeset for help on using the changeset viewer.