Changeset 196223 in webkit
- Timestamp:
- Feb 6, 2016 3:18:47 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 57 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r196220 r196223 1 2016-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 1 15 2016-02-06 Chris Dumez <cdumez@apple.com> 2 16 -
trunk/Source/JavaScriptCore/runtime/IntlObject.cpp
r194387 r196223 323 323 ++currentIndex; 324 324 canonical.append('-'); 325 canonical.append(region. upper());325 canonical.append(region.convertToASCIIUppercase()); 326 326 } 327 327 } -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r195528 r196223 1407 1407 JSString* sVal = thisValue.toString(exec); 1408 1408 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()) 1412 1411 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)); 1420 1413 } 1421 1414 … … 1427 1420 JSString* sVal = thisValue.toString(exec); 1428 1421 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()) 1432 1424 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)); 1439 1426 } 1440 1427 -
trunk/Source/WTF/ChangeLog
r196080 r196223 1 2016-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 1 28 2016-02-03 Darin Adler <darin@apple.com> 2 29 -
trunk/Source/WTF/wtf/text/AtomicString.cpp
r195501 r196223 32 32 33 33 namespace WTF { 34 35 AtomicString AtomicString::lower() const36 {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 }50 34 51 35 template<AtomicString::CaseConvertType type> -
trunk/Source/WTF/wtf/text/AtomicString.h
r195946 r196223 156 156 WTF_EXPORT_STRING_API AtomicString convertToASCIILowercase() const; 157 157 WTF_EXPORT_STRING_API AtomicString convertToASCIIUppercase() const; 158 WTF_EXPORT_STRING_API AtomicString lower() const;159 158 160 159 int toInt(bool* ok = 0) const { return m_string.toInt(ok); } -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r195928 r196223 362 362 } 363 363 364 Ref<StringImpl> StringImpl:: lower()365 { 366 // Note: This is a hot function in the Dromaeo benchmark, specifically the364 Ref<StringImpl> StringImpl::convertToLowercaseWithoutLocale() 365 { 366 // Note: At one time this was a hot function in the Dromaeo benchmark, specifically the 367 367 // no-op code path up through the first 'return' statement. 368 368 … … 443 443 } 444 444 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. 445 Ref<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. 450 451 451 452 if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max())) … … 478 479 479 480 // 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. 481 482 // 2. Lower case sharp-S converts to "SS" (two characters) 482 483 for (int32_t i = 0; i < length; ++i) { … … 486 487 ASSERT(u_toupper(c) <= 0xFFFF); 487 488 UChar upper = u_toupper(c); 488 if (UNLIKELY(upper > 0x ff)) {489 if (UNLIKELY(upper > 0xFF)) { 489 490 // Since this upper-cased character does not fit in an 8-bit string, we need to take the 16-bit path. 490 491 goto upconvert; … … 555 556 } 556 557 557 Ref<StringImpl> StringImpl:: lower(const AtomicString& localeIdentifier)558 Ref<StringImpl> StringImpl::convertToLowercaseWithLocale(const AtomicString& localeIdentifier) 558 559 { 559 560 // Use the more-optimized code path most of the time. … … 562 563 // that have locale-specific lowercasing. There are only three of them. 563 564 if (!needsTurkishCasingRules(localeIdentifier)) 564 return lower();565 return convertToLowercaseWithoutLocale(); 565 566 566 567 // FIXME: Could share more code with the main StringImpl::lower by factoring out … … 591 592 } 592 593 593 Ref<StringImpl> StringImpl:: upper(const AtomicString& localeIdentifier)594 Ref<StringImpl> StringImpl::convertToUppercaseWithLocale(const AtomicString& localeIdentifier) 594 595 { 595 596 // Use the more-optimized code path most of the time. … … 597 598 // and that the only affected character is lowercase "i". 598 599 if (!needsTurkishCasingRules(localeIdentifier) || find('i') == notFound) 599 return upper();600 return convertToUppercaseWithoutLocale(); 600 601 601 602 if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max())) … … 624 625 Ref<StringImpl> StringImpl::foldCase() 625 626 { 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 639 SlowPath: 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 } 627 687 628 688 if (m_length > static_cast<unsigned>(std::numeric_limits<int32_t>::max())) 629 689 CRASH(); 690 691 auto upconvertedCharacters = StringView(*this).upconvertedCharacters(); 692 693 UChar* data; 694 auto folded = createUninitializedInternalNonEmpty(m_length, data); 630 695 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.670 696 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); 672 698 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); 675 702 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); 677 704 if (U_FAILURE(status)) 678 705 return *this; 679 return newImpl.releaseNonNull();706 return folded; 680 707 } 681 708 -
trunk/Source/WTF/wtf/text/StringImpl.h
r195928 r196223 682 682 WTF_EXPORT_STRING_API Ref<StringImpl> convertToASCIILowercase(); 683 683 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); 688 688 689 689 Ref<StringImpl> foldCase(); -
trunk/Source/WTF/wtf/text/WTFString.cpp
r195501 r196223 352 352 } 353 353 354 String String:: lower() const355 { 356 if (!m_impl) 357 return String(); 358 return m_impl-> lower();359 } 360 361 String String:: upper() const362 { 363 if (!m_impl) 364 return String(); 365 return m_impl-> upper();366 } 367 368 String String:: lower(const AtomicString& localeIdentifier) const369 { 370 if (!m_impl) 371 return String(); 372 return m_impl-> lower(localeIdentifier);373 } 374 375 String String:: upper(const AtomicString& localeIdentifier) const376 { 377 if (!m_impl) 378 return String(); 379 return m_impl-> upper(localeIdentifier);354 String String::convertToLowercaseWithoutLocale() const 355 { 356 if (!m_impl) 357 return String(); 358 return m_impl->convertToLowercaseWithoutLocale(); 359 } 360 361 String String::convertToUppercaseWithoutLocale() const 362 { 363 if (!m_impl) 364 return String(); 365 return m_impl->convertToUppercaseWithoutLocale(); 366 } 367 368 String String::convertToLowercaseWithLocale(const AtomicString& localeIdentifier) const 369 { 370 if (!m_impl) 371 return String(); 372 return m_impl->convertToLowercaseWithLocale(localeIdentifier); 373 } 374 375 String String::convertToUppercaseWithLocale(const AtomicString& localeIdentifier) const 376 { 377 if (!m_impl) 378 return String(); 379 return m_impl->convertToUppercaseWithLocale(localeIdentifier); 380 380 } 381 381 -
trunk/Source/WTF/wtf/text/WTFString.h
r195743 r196223 332 332 String right(unsigned len) const { return substring(length() - len, len); } 333 333 334 // Returns a lowercase/uppercase version of the string.335 // The convertToASCIILowercase is useful in many contexts such as HTML where we don't336 // want to do any conversion for non-ASCII letters.337 334 WTF_EXPORT_STRING_API String convertToASCIILowercase() const; 338 WTF_EXPORT_STRING_API String lower() const;339 335 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; 344 340 345 341 WTF_EXPORT_STRING_API String stripWhiteSpace() const; -
trunk/Source/WebCore/ChangeLog
r196222 r196223 1 2016-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 1 128 2016-02-06 Zalan Bujtas <zalan@apple.com> 2 129 -
trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp
r195951 r196223 734 734 735 735 // FIXME: Why do we convert to lowercase here, but not in MediaSource::addSourceBuffer? 736 ContentType contentType(type. lower());736 ContentType contentType(type.convertToASCIILowercase()); 737 737 String codecs = contentType.parameter("codecs"); 738 738 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r195928 r196223 762 762 if (frame->selection().setSelectedRange(closestStringRange.get(), DOWNSTREAM, true)) { 763 763 switch (activity) { 764 case FindAndCapitalize: {764 case FindAndCapitalize: 765 765 replacementString = closestString; 766 766 makeCapitalized(&replacementString, 0); 767 767 replaceSelection = true; 768 768 break; 769 }770 769 case FindAndUppercase: 771 replacementString = closestString. upper();770 replacementString = closestString.convertToUppercaseWithoutLocale(); // FIXME: Needs locale to work correctly. 772 771 replaceSelection = true; 773 772 break; 774 773 case FindAndLowercase: 775 replacementString = closestString. lower();774 replacementString = closestString.convertToLowercaseWithoutLocale(); // FIXME: Needs locale to work correctly. 776 775 replaceSelection = true; 777 776 break; 778 777 case FindAndReplaceActivity: { 779 778 replaceSelection = true; 780 781 779 // When applying find and replace activities, we want to match the capitalization of the replaced text, 782 780 // (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])) 786 783 makeCapitalized(&replacementString, 0); 787 784 else 788 replacementString = replacementString. lower();785 replacementString = replacementString.convertToLowercaseWithoutLocale(); // FIXME: Needs locale to work correctly. 789 786 } 790 787 break; -
trunk/Source/WebCore/dom/Document.cpp
r196135 r196223 767 767 } 768 768 769 void Document::addImageElementBy LowercasedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)769 void Document::addImageElementByCaseFoldedUsemap(const AtomicStringImpl& name, HTMLImageElement& element) 770 770 { 771 771 return m_imagesByUsemap.add(name, element, *this); 772 772 } 773 773 774 void Document::removeImageElementBy LowercasedUsemap(const AtomicStringImpl& name, HTMLImageElement& element)774 void Document::removeImageElementByCaseFoldedUsemap(const AtomicStringImpl& name, HTMLImageElement& element) 775 775 { 776 776 return m_imagesByUsemap.remove(name, element); 777 777 } 778 778 779 HTMLImageElement* Document::imageElementBy LowercasedUsemap(const AtomicStringImpl& name) const780 { 781 return m_imagesByUsemap.getElementBy LowercasedUsemap(name, *this);779 HTMLImageElement* Document::imageElementByCaseFoldedUsemap(const AtomicStringImpl& name) const 780 { 781 return m_imagesByUsemap.getElementByCaseFoldedUsemap(name, *this); 782 782 } 783 783 -
trunk/Source/WebCore/dom/Document.h
r195951 r196223 351 351 void invalidateAccessKeyMap(); 352 352 353 void addImageElementBy LowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);354 void removeImageElementBy LowercasedUsemap(const AtomicStringImpl&, HTMLImageElement&);355 HTMLImageElement* imageElementBy LowercasedUsemap(const AtomicStringImpl&) const;353 void addImageElementByCaseFoldedUsemap(const AtomicStringImpl&, HTMLImageElement&); 354 void removeImageElementByCaseFoldedUsemap(const AtomicStringImpl&, HTMLImageElement&); 355 HTMLImageElement* imageElementByCaseFoldedUsemap(const AtomicStringImpl&) const; 356 356 357 357 SelectorQuery* selectorQueryForString(const String&, ExceptionCode&); -
trunk/Source/WebCore/dom/DocumentOrderedMap.cpp
r190097 r196223 148 148 } 149 149 150 HTMLMapElement* DocumentOrderedMap::getElementBy LowercasedMapName(const AtomicStringImpl& key, const TreeScope& scope) const150 HTMLMapElement* DocumentOrderedMap::getElementByCaseFoldedMapName(const AtomicStringImpl& key, const TreeScope& scope) const 151 151 { 152 152 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::getElementBy LowercasedUsemap(const AtomicStringImpl& key, const TreeScope& scope) const153 return is<HTMLMapElement>(element) && equal(downcast<HTMLMapElement>(element).getName().string().foldCase().impl(), &key); 154 })); 155 } 156 157 HTMLImageElement* DocumentOrderedMap::getElementByCaseFoldedUsemap(const AtomicStringImpl& key, const TreeScope& scope) const 158 158 { 159 159 return downcast<HTMLImageElement>(get(key, scope, [] (const AtomicStringImpl& key, const Element& element) { 160 160 // FIXME: HTML5 specification says we should match both image and object elements. 161 return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element).matches LowercasedUsemap(key);161 return is<HTMLImageElement>(element) && downcast<HTMLImageElement>(element).matchesCaseFoldedUsemap(key); 162 162 })); 163 163 } -
trunk/Source/WebCore/dom/DocumentOrderedMap.h
r191955 r196223 61 61 Element* getElementByName(const AtomicStringImpl&, const TreeScope&) const; 62 62 HTMLMapElement* getElementByMapName(const AtomicStringImpl&, const TreeScope&) const; 63 HTMLMapElement* getElementBy LowercasedMapName(const AtomicStringImpl&, const TreeScope&) const;64 HTMLImageElement* getElementBy LowercasedUsemap(const AtomicStringImpl&, const TreeScope&) const;63 HTMLMapElement* getElementByCaseFoldedMapName(const AtomicStringImpl&, const TreeScope&) const; 64 HTMLImageElement* getElementByCaseFoldedUsemap(const AtomicStringImpl&, const TreeScope&) const; 65 65 HTMLLabelElement* getElementByLabelForAttribute(const AtomicStringImpl&, const TreeScope&) const; 66 66 Element* getElementByWindowNamedItem(const AtomicStringImpl&, const TreeScope&) const; -
trunk/Source/WebCore/dom/TreeScope.cpp
r195743 r196223 202 202 HTMLMapElement* TreeScope::getImageMap(const String& url) const 203 203 { 204 if (url.isNull())205 return nullptr;206 204 if (!m_imageMapsByName) 207 205 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); 210 210 if (name.isEmpty()) 211 211 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); 216 214 return m_imageMapsByName->getElementByMapName(*AtomicString(name).impl(), *this); 217 215 } -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r195946 r196223 57 57 #import "RGBColor.h" 58 58 #import "RenderImage.h" 59 #import "RenderText.h" 59 60 #import "SoftLinking.h" 60 61 #import "StyleProperties.h" … … 2279 2280 if (outputString.length()) { 2280 2281 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. 2290 2288 2291 2289 [_attrStr replaceCharactersInRange:rangeToReplace withString:outputString]; -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r196080 r196223 202 202 selectImageSource(); 203 203 else if (name == usemapAttr) { 204 if (inDocument() && !m_ lowercasedUsemap.isNull())205 document().removeImageElementBy LowercasedUsemap(*m_lowercasedUsemap.impl(), *this);204 if (inDocument() && !m_caseFoldedUsemap.isNull()) 205 document().removeImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this); 206 206 207 207 // The HTMLImageElement's useMap() value includes the '#' symbol at the beginning, which has to be stripped off. 208 208 // FIXME: We should check that the first character is '#'. 209 // FIXME: HTML 5specification says we should strip any leading string before '#'.210 // FIXME: HTML 5 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 '#'. 211 211 if (value.length() > 1) 212 m_ lowercasedUsemap = value.string().substring(1).lower();212 m_caseFoldedUsemap = value.string().substring(1).foldCase(); 213 213 else 214 m_ lowercasedUsemap = nullAtom;215 216 if (inDocument() && !m_ lowercasedUsemap.isNull())217 document().addImageElementBy LowercasedUsemap(*m_lowercasedUsemap.impl(), *this);214 m_caseFoldedUsemap = nullAtom; 215 216 if (inDocument() && !m_caseFoldedUsemap.isNull()) 217 document().addImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this); 218 218 } else if (name == compositeAttr) { 219 219 // FIXME: images don't support blend modes in their compositing attribute. … … 313 313 Node::InsertionNotificationRequest insertNotificationRequest = HTMLElement::insertedInto(insertionPoint); 314 314 315 if (insertionPoint.inDocument() && !m_ lowercasedUsemap.isNull())316 document().addImageElementBy LowercasedUsemap(*m_lowercasedUsemap.impl(), *this);315 if (insertionPoint.inDocument() && !m_caseFoldedUsemap.isNull()) 316 document().addImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this); 317 317 318 318 if (is<HTMLPictureElement>(parentNode())) { … … 334 334 m_form->removeImgElement(this); 335 335 336 if (insertionPoint.inDocument() && !m_ lowercasedUsemap.isNull())337 document().removeImageElementBy LowercasedUsemap(*m_lowercasedUsemap.impl(), *this);336 if (insertionPoint.inDocument() && !m_caseFoldedUsemap.isNull()) 337 document().removeImageElementByCaseFoldedUsemap(*m_caseFoldedUsemap.impl(), *this); 338 338 339 339 if (is<HTMLPictureElement>(parentNode())) … … 475 475 } 476 476 477 bool HTMLImageElement::matches LowercasedUsemap(const AtomicStringImpl& name) const478 { 479 ASSERT(String(&const_cast<AtomicStringImpl&>(name)). lower().impl() == &name);480 return m_ lowercasedUsemap.impl() == &name;477 bool HTMLImageElement::matchesCaseFoldedUsemap(const AtomicStringImpl& name) const 478 { 479 ASSERT(String(&const_cast<AtomicStringImpl&>(name)).foldCase().impl() == &name); 480 return m_caseFoldedUsemap.impl() == &name; 481 481 } 482 482 -
trunk/Source/WebCore/html/HTMLImageElement.h
r195132 r196223 61 61 void setLoadManually(bool loadManually) { m_imageLoader.setLoadManually(loadManually); } 62 62 63 bool matches LowercasedUsemap(const AtomicStringImpl&) const;63 bool matchesCaseFoldedUsemap(const AtomicStringImpl&) const; 64 64 65 65 const AtomicString& alt() const; … … 135 135 AtomicString m_bestFitImageURL; 136 136 AtomicString m_currentSrc; 137 AtomicString m_ lowercasedUsemap;137 AtomicString m_caseFoldedUsemap; 138 138 float m_imageDevicePixelRatio; 139 139 bool m_experimentalImageMenuEnabled; -
trunk/Source/WebCore/html/HTMLMapElement.cpp
r188520 r196223 79 79 { 80 80 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()); 85 83 } 86 84 … … 102 100 if (mapName[0] == '#') 103 101 mapName = mapName.substring(1); 104 m_name = document().isHTMLDocument() ? mapName. lower() : mapName;102 m_name = document().isHTMLDocument() ? mapName.foldCase() : mapName; 105 103 if (inDocument()) 106 104 treeScope().addImageMap(*this); -
trunk/Source/WebCore/platform/Language.cpp
r194819 r196223 100 100 static String canonicalLanguageIdentifier(const String& languageCode) 101 101 { 102 String lowercaseLanguageCode = languageCode. lower();102 String lowercaseLanguageCode = languageCode.convertToASCIILowercase(); 103 103 104 104 if (lowercaseLanguageCode.length() >= 3 && lowercaseLanguageCode[2] == '_') … … 110 110 size_t indexOfBestMatchingLanguageInList(const String& language, const Vector<String>& languageList, bool& exactMatch) 111 111 { 112 String lowercaseLanguage = language. lower();112 String lowercaseLanguage = language.convertToASCIILowercase(); 113 113 String languageWithoutLocaleMatch; 114 114 String languageMatchButNotLocale; -
trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
r191014 r196223 483 483 484 484 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(); 486 486 currentFontData = m_font->glyphDataForCharacter(upperText[0], false, SmallCapsVariant).font; 487 487 const UChar* characters = StringView(upperText).upconvertedCharacters(); -
trunk/Source/WebCore/platform/network/HTTPParsers.cpp
r195523 r196223 457 457 ContentTypeOptionsDisposition parseContentTypeOptionsHeader(const String& header) 458 458 { 459 if ( header.stripWhiteSpace().lower() == "nosniff")459 if (equalLettersIgnoringASCIICase(header.stripWhiteSpace(), "nosniff")) 460 460 return ContentTypeOptionsNosniff; 461 461 return ContentTypeOptionsNone; -
trunk/Source/WebCore/platform/network/MIMEHeader.cpp
r166047 r196223 71 71 continue; 72 72 } 73 key = line.substring(0, semiColonIndex). lower().stripWhiteSpace();73 key = line.substring(0, semiColonIndex).convertToASCIILowercase().stripWhiteSpace(); 74 74 value.append(line.substring(semiColonIndex + 1)); 75 75 } … … 115 115 MIMEHeader::Encoding MIMEHeader::parseContentTransferEncoding(const String& text) 116 116 { 117 String encoding = text.stripWhiteSpace() .lower();118 if (e ncoding == "base64")117 String encoding = text.stripWhiteSpace(); 118 if (equalLettersIgnoringASCIICase(encoding, "base64")) 119 119 return Base64; 120 if (e ncoding == "quoted-printable")120 if (equalLettersIgnoringASCIICase(encoding, "quoted-printable")) 121 121 return QuotedPrintable; 122 if (e ncoding == "7bit")122 if (equalLettersIgnoringASCIICase(encoding, "7bit")) 123 123 return SevenBit; 124 if (e ncoding == "binary")124 if (equalLettersIgnoringASCIICase(encoding, "binary")) 125 125 return Binary; 126 126 LOG_ERROR("Unknown encoding '%s' found in MIME header.", text.ascii().data()); -
trunk/Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
r194819 r196223 83 83 #if USE(CFNETWORK) 84 84 85 static HashSet<String >& allowsAnyHTTPSCertificateHosts()86 { 87 static NeverDestroyed<HashSet<String >> hosts;85 static HashSet<String, ASCIICaseInsensitiveHash>& allowsAnyHTTPSCertificateHosts() 86 { 87 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> hosts; 88 88 return hosts; 89 89 } 90 90 91 static HashMap<String, RetainPtr<CFDataRef>>& clientCerts() 92 { 93 typedef HashMap<String, RetainPtr<CFDataRef>> CertsMap; 94 static NeverDestroyed<CertsMap> certs; 91 static HashMap<String, RetainPtr<CFDataRef>, ASCIICaseInsensitiveHash>& clientCertificates() 92 { 93 static NeverDestroyed<HashMap<String, RetainPtr<CFDataRef>, ASCIICaseInsensitiveHash>> certs; 95 94 return certs; 96 95 } … … 170 169 sslProps = adoptCF(ResourceHandle::createSSLPropertiesFromNSURLRequest(firstRequest())); 171 170 #else 172 if (allowsAnyHTTPSCertificateHosts().contains(firstRequest().url().host() .lower())) {171 if (allowsAnyHTTPSCertificateHosts().contains(firstRequest().url().host())) { 173 172 sslProps = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); 174 173 CFDictionaryAddValue(sslProps.get(), kCFStreamSSLAllowsAnyRoot, kCFBooleanTrue); … … 178 177 } 179 178 180 HashMap<String, RetainPtr<CFDataRef>>::iterator clientCert = clientCerts().find(firstRequest().url().host().lower());181 if (clientCert != clientCert s().end()) {179 auto clientCert = clientCertificates().find(firstRequest().url().host()); 180 if (clientCert != clientCertificates().end()) { 182 181 if (!sslProps) 183 182 sslProps = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); … … 604 603 void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host) 605 604 { 606 allowsAnyHTTPSCertificateHosts().add(host .lower());607 } 608 609 void ResourceHandle::setClientCertificate(const String& host, CFDataRef cert )610 { 611 clientCert s().set(host.lower(), cert);605 allowsAnyHTTPSCertificateHosts().add(host); 606 } 607 608 void ResourceHandle::setClientCertificate(const String& host, CFDataRef certificate) 609 { 610 clientCertificates().set(host, certificate); 612 611 } 613 612 -
trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp
r176963 r196223 196 196 Vector<String> keyValuePair; 197 197 attribute->split('=', true, keyValuePair); 198 String key = keyValuePair[0].stripWhiteSpace() .lower();198 String key = keyValuePair[0].stripWhiteSpace(); 199 199 String val = keyValuePair[1].stripWhiteSpace(); 200 if ( key == "expires") {200 if (equalLettersIgnoringASCIICase(key, "expires")) { 201 201 CString dateStr(reinterpret_cast<const char*>(val.characters8()), val.length()); 202 202 expires = WTF::parseDateFromNullTerminatedCharacters(dateStr.data()) / WTF::msPerSecond; 203 } else if ( key == "max-age")203 } else if (equalLettersIgnoringASCIICase(key, "max-age")) 204 204 expires = time(0) + val.toInt(); 205 else if ( key == "domain")205 else if (equalLettersIgnoringASCIICase(key, "domain")) 206 206 domain = val; 207 else if ( key == "path")207 else if (equalLettersIgnoringASCIICase(key, "path")) 208 208 path = val; 209 209 } else { 210 String key = attribute->stripWhiteSpace() .lower();211 if ( key == "secure")210 String key = attribute->stripWhiteSpace(); 211 if (equalLettersIgnoringASCIICase(key, "secure")) 212 212 secure = "TRUE"; 213 213 } -
trunk/Source/WebCore/platform/network/curl/MultipartHandle.cpp
r183265 r196223 347 347 String mimeType = extractMIMETypeFromMediaType(contentType); 348 348 349 response->setMimeType(mimeType. lower());349 response->setMimeType(mimeType.convertToASCIILowercase()); 350 350 response->setTextEncodingName(extractCharsetFromMediaType(contentType)); 351 351 -
trunk/Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp
r186476 r196223 123 123 void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host) 124 124 { 125 allowsAnyHTTPSCertificateHosts(host .lower());125 allowsAnyHTTPSCertificateHosts(host); 126 126 } 127 127 … … 135 135 136 136 #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 138 void ResourceHandle::setClientCertificate(const String&, CFDataRef) 139 { 140 } 141 149 142 #endif 150 143 -
trunk/Source/WebCore/platform/network/curl/ResourceHandleManager.cpp
r195743 r196223 498 498 499 499 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()); 501 501 d->m_response.setTextEncodingName(extractCharsetFromMediaType(d->m_response.httpHeaderField(HTTPHeaderName::ContentType))); 502 502 -
trunk/Source/WebCore/platform/network/curl/SSLHandle.cpp
r165996 r196223 40 40 namespace WebCore { 41 41 42 typedef std::tuple< WTF::String, WTF::String> clientCertificate;43 static HashMap<String, ListHashSet<String> > allowedHosts;44 static HashMap<String, clientCertificate > allowedClientHosts;42 typedef std::tuple<String, String> clientCertificate; 43 static HashMap<String, ListHashSet<String>, ASCIICaseInsensitiveHash> allowedHosts; 44 static HashMap<String, clientCertificate, ASCIICaseInsensitiveHash> allowedClientHosts; 45 45 46 46 void allowsAnyHTTPSCertificateHosts(const String& host) … … 53 53 { 54 54 clientCertificate clientInfo(certificate, key); 55 allowedClientHosts.set(host .lower(), clientInfo);55 allowedClientHosts.set(host, clientInfo); 56 56 } 57 57 … … 59 59 { 60 60 String host = handle->firstRequest().url().host(); 61 HashMap<String, clientCertificate>::iterator it = allowedClientHosts.find(host.lower());61 auto it = allowedClientHosts.find(host); 62 62 if (it == allowedClientHosts.end()) 63 63 return; … … 72 72 bool sslIgnoreHTTPSCertificate(const String& host, const ListHashSet<String>& certificates) 73 73 { 74 HashMap<String, ListHashSet<String>>::iteratorit = allowedHosts.find(host);74 auto it = allowedHosts.find(host); 75 75 if (it != allowedHosts.end()) { 76 76 if ((it->value).isEmpty()) { … … 80 80 if (certificates.size() != it->value.size()) 81 81 return false; 82 ListHashSet<String>::const_iteratorcertsIter = certificates.begin();83 ListHashSet<String>::iteratorvalueIter = (it->value).begin();82 auto certsIter = certificates.begin(); 83 auto valueIter = (it->value).begin(); 84 84 for (; valueIter != (it->value).end(); ++valueIter, ++certsIter) { 85 85 if (*certsIter != *valueIter) … … 199 199 200 200 #if PLATFORM(WIN) 201 HashMap<String, ListHashSet<String>>::iteratorit = allowedHosts.find(host);201 auto it = allowedHosts.find(host); 202 202 ok = (it != allowedHosts.end()); 203 203 #else … … 205 205 if (!pemData(ctx, certificates)) 206 206 return 0; 207 ok = sslIgnoreHTTPSCertificate(host .lower(), certificates);207 ok = sslIgnoreHTTPSCertificate(host, certificates); 208 208 #endif 209 209 -
trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r196061 r196223 245 245 static bool gIgnoreSSLErrors = false; 246 246 247 static HashSet<String>& allowsAnyHTTPSCertificateHosts() 248 { 249 DEPRECATED_DEFINE_STATIC_LOCAL(HashSet<String>, hosts, ()); 247 typedef HashSet<String, ASCIICaseInsensitiveHash> HostsSet; 248 static HostsSet& allowsAnyHTTPSCertificateHosts() 249 { 250 DEPRECATED_DEFINE_STATIC_LOCAL(HostsSet, hosts, ()); 250 251 return hosts; 251 252 } 252 253 253 typedef HashMap<String, HostTLSCertificateSet > CertificatesMap;254 typedef HashMap<String, HostTLSCertificateSet, ASCIICaseInsensitiveHash> CertificatesMap; 254 255 static CertificatesMap& clientCertificates() 255 256 { … … 323 324 return false; 324 325 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)) 327 328 return false; 328 329 329 330 // 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); 331 332 if (it != clientCertificates().end() && it->value.contains(certificate)) 332 333 return false; … … 1088 1089 void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host) 1089 1090 { 1090 allowsAnyHTTPSCertificateHosts().add(host .lower());1091 allowsAnyHTTPSCertificateHosts().add(host); 1091 1092 } 1092 1093 1093 1094 void ResourceHandle::setClientCertificate(const String& host, GTlsCertificate* certificate) 1094 1095 { 1095 clientCertificates().add(host .lower(), HostTLSCertificateSet()).iterator->value.add(certificate);1096 clientCertificates().add(host, HostTLSCertificateSet()).iterator->value.add(certificate); 1096 1097 } 1097 1098 -
trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp
r189038 r196223 158 158 159 159 struct 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 163 typedef HashMap<String, UScriptCode, ASCIICaseInsensitiveHash, ScriptNameCodeMapHashTraits> ScriptNameCodeMap; 164 164 165 165 UScriptCode scriptNameToCode(const String& scriptName) 166 166 { 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); 174 175 if (it != scriptNameCodeMap.get().end()) 175 176 return it->value; … … 384 385 385 386 struct 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 390 typedef HashMap<String, UScriptCode, ASCIICaseInsensitiveHash, LocaleScriptMapHashTraits> LocaleScriptMap; 390 391 391 392 UScriptCode localeToScriptCodeForFontSelection(const String& locale) 392 393 { 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('-', '_'); 400 403 while (!canonicalLocale.isEmpty()) { 401 LocaleScriptMap::iteratorit = localeScriptMap.get().find(canonicalLocale);404 auto it = localeScriptMap.get().find(canonicalLocale); 402 405 if (it != localeScriptMap.get().end()) 403 406 return it->value; 404 size_t pos= canonicalLocale.reverseFind('_');405 if ( pos== notFound)407 auto underscorePosition = canonicalLocale.reverseFind('_'); 408 if (underscorePosition == notFound) 406 409 break; 407 UScriptCode code = scriptNameToCode(canonicalLocale.substring( pos+ 1));410 UScriptCode code = scriptNameToCode(canonicalLocale.substring(underscorePosition + 1)); 408 411 if (code != USCRIPT_INVALID_CODE && code != USCRIPT_UNKNOWN) 409 412 return code; 410 canonicalLocale = canonicalLocale.substring(0, pos);413 canonicalLocale = canonicalLocale.substring(0, underscorePosition); 411 414 } 412 415 return USCRIPT_COMMON; -
trunk/Source/WebCore/platform/text/win/LocaleWin.cpp
r195879 r196223 49 49 50 50 typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD); 51 typedef HashMap<String, LCID > NameToLCIDMap;51 typedef HashMap<String, LCID, ASCIICaseInsensitiveHash> NameToLCIDMap; 52 52 53 53 static String extractLanguageCode(const String& locale) … … 108 108 DEPRECATED_DEFINE_STATIC_LOCAL(NameToLCIDMap, map, ()); 109 109 ensureNameToLCIDMap(map); 110 String localeName = String(name).replace('_', '-') .lower();110 String localeName = String(name).replace('_', '-'); 111 111 do { 112 112 NameToLCIDMap::const_iterator iterator = map.find(localeName); -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r189182 r196223 183 183 static ClipboardDataType clipboardTypeFromMIMEType(const String& type) 184 184 { 185 String qType = type.stripWhiteSpace().lower();185 String strippedType = type.stripWhiteSpace(); 186 186 187 187 // 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)) 189 189 return ClipboardDataTypeText; 190 if ( qType == "url" || qType == "text/uri-list")190 if (equalLettersIgnoringASCIICase(strippedType, "url") || equalLettersIgnoringASCIICase(strippedType, "text/uri-list")) 191 191 return ClipboardDataTypeURL; 192 if ( qType == "text/html")192 if (equalLettersIgnoringASCIICase(strippedType, "text/html")) 193 193 return ClipboardDataTypeTextHTML; 194 194 -
trunk/Source/WebCore/rendering/RenderText.cpp
r195766 r196223 1036 1036 break; 1037 1037 case UPPERCASE: 1038 text = text. upper(style.locale());1038 text = text.convertToUppercaseWithLocale(style.locale()); 1039 1039 break; 1040 1040 case LOWERCASE: 1041 text = text. lower(style.locale());1041 text = text.convertToLowercaseWithLocale(style.locale()); 1042 1042 break; 1043 1043 } -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r195743 r196223 1031 1031 bool XMLHttpRequest::responseIsXML() const 1032 1032 { 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()); 1036 1034 } 1037 1035 -
trunk/Source/WebKit/mac/ChangeLog
r196070 r196223 1 2016-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 1 15 2016-02-03 Jessie Berlin <jberlin@webkit.org> 2 16 -
trunk/Source/WebKit/mac/Plugins/WebBasePluginPackage.mm
r193378 r196223 217 217 218 218 NSArray *extensions = [[MIMEDictionary objectForKey:WebPluginExtensionsKey] _web_lowercaseStrings]; 219 for (NS UInteger i = 0; i < [extensions count]; ++i) {219 for (NSString *extension in extensions) { 220 220 // The DivX plug-in lists multiple extensions in a comma separated string instead of using 221 221 // multiple array elements in the property list. Work around this here by splitting the 222 222 // 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); 227 225 } 228 226 229 mimeClassInfo.type = String(MIME).lower(); 230 227 mimeClassInfo.type = String(MIME).convertToASCIILowercase(); 231 228 mimeClassInfo.desc = [MIMEDictionary objectForKey:WebPluginTypeDescriptionKey]; 232 229 … … 285 282 - (BOOL)supportsExtension:(const String&)extension 286 283 { 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)) 293 288 return YES; 294 289 } … … 299 294 - (BOOL)supportsMIMEType:(const WTF::String&)mimeType 300 295 { 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) 305 300 return YES; 306 301 } 307 302 308 303 return NO; 309 304 } … … 311 306 - (NSString *)MIMETypeForExtension:(const String&)extension 312 307 { 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; 321 313 } 322 314 -
trunk/Source/WebKit/win/ChangeLog
r196165 r196223 1 2016-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 1 20 2016-02-04 Joseph Pecoraro <pecoraro@apple.com> 2 21 -
trunk/Source/WebKit/win/Plugins/PluginDatabase.cpp
r195743 r196223 105 105 106 106 // Unload plugins 107 PluginSet::const_iteratorend = pluginsToUnload.end();108 for ( PluginSet::const_iteratorit = pluginsToUnload.begin(); it != end; ++it)107 auto end = pluginsToUnload.end(); 108 for (auto it = pluginsToUnload.begin(); it != end; ++it) 109 109 remove(it->get()); 110 110 … … 122 122 bool shouldSkipUnchangedFiles = !pluginSetChanged; 123 123 124 HashSet<String>::const_iteratorpathsEnd = paths.end();125 for ( HashSet<String>::const_iteratorit = paths.begin(); it != pathsEnd; ++it) {124 auto pathsEnd = paths.end(); 125 for (auto it = paths.begin(); it != pathsEnd; ++it) { 126 126 time_t lastModified; 127 127 if (!getFileModificationTime(*it, lastModified)) … … 157 157 158 158 // Register plug-in MIME types 159 PluginSet::const_iteratorend = m_plugins.end();160 for ( PluginSet::const_iteratorit = m_plugins.begin(); it != end; ++it) {159 auto end = m_plugins.end(); 160 for (auto it = m_plugins.begin(); it != end; ++it) { 161 161 // Get MIME types 162 MIMEToDescriptionsMap::const_iteratormap_it = (*it)->mimeToDescriptions().begin();163 MIMEToDescriptionsMap::const_iteratormap_end = (*it)->mimeToDescriptions().end();162 auto map_it = (*it)->mimeToDescriptions().begin(); 163 auto map_end = (*it)->mimeToDescriptions().end(); 164 164 for (; map_it != map_end; ++map_it) 165 165 m_registeredMIMETypes.add(map_it->key); … … 173 173 Vector<PluginPackage*> result; 174 174 175 PluginSet::const_iteratorend = m_plugins.end();176 for ( PluginSet::const_iteratorit = m_plugins.begin(); it != end; ++it)175 auto end = m_plugins.end(); 176 for (auto it = m_plugins.begin(); it != end; ++it) 177 177 result.append((*it).get()); 178 178 … … 191 191 { 192 192 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); 198 196 if (preferredPlugin 199 197 && preferredPlugin->isEnabled() 200 && preferredPlugin->mimeToDescriptions().contains( key)) {198 && preferredPlugin->mimeToDescriptions().contains(mimeType)) { 201 199 return preferredPlugin; 202 200 } … … 204 202 Vector<PluginPackage*, 2> pluginChoices; 205 203 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) { 207 206 PluginPackage* plugin = (*it).get(); 208 207 … … 210 209 continue; 211 210 212 if (plugin->mimeToDescriptions().contains( key)) {211 if (plugin->mimeToDescriptions().contains(mimeType)) { 213 212 #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) 214 213 if (!plugin->ensurePluginLoaded()) … … 232 231 return String(); 233 232 234 PluginSet::const_iteratorend = m_plugins.end();233 auto end = m_plugins.end(); 235 234 String mimeType; 236 235 Vector<PluginPackage*, 2> pluginChoices; 237 236 HashMap<PluginPackage*, String> mimeTypeForPlugin; 238 237 239 for ( PluginSet::const_iteratorit = m_plugins.begin(); it != end; ++it) {238 for (auto it = m_plugins.begin(); it != end; ++it) { 240 239 if (!(*it)->isEnabled()) 241 240 continue; 242 241 243 MIMEToExtensionsMap::const_iteratormime_end = (*it)->mimeToExtensions().end();244 245 for ( MIMEToExtensionsMap::const_iteratormime_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) { 246 245 mimeType = mime_it->key; 247 246 PluginPackage* preferredPlugin = m_preferredPlugins.get(mimeType); … … 306 305 { 307 306 if (!plugin || plugin->mimeToExtensions().contains(mimeType)) 308 m_preferredPlugins.set(mimeType .lower(), plugin);307 m_preferredPlugins.set(mimeType, plugin); 309 308 } 310 309 … … 320 319 void PluginDatabase::getDeletedPlugins(PluginSet& plugins) const 321 320 { 322 PluginSet::const_iteratorend = m_plugins.end();323 for ( PluginSet::const_iteratorit = m_plugins.begin(); it != end; ++it) {321 auto end = m_plugins.end(); 322 for (auto it = m_plugins.begin(); it != end; ++it) { 324 323 if (!fileExistsAndIsNotDisabled((*it)->path())) 325 324 plugins.add(*it); … … 342 341 void PluginDatabase::remove(PluginPackage* package) 343 342 { 344 MIMEToExtensionsMap::const_iteratorit = package->mimeToExtensions().begin();345 MIMEToExtensionsMap::const_iteratorend = package->mimeToExtensions().end();343 auto it = package->mimeToExtensions().begin(); 344 auto end = package->mimeToExtensions().end(); 346 345 for ( ; it != end; ++it) { 347 PluginPackageByNameMap::iteratorpackageInMap = m_preferredPlugins.find(it->key);346 auto packageInMap = m_preferredPlugins.find(it->key); 348 347 if (packageInMap != m_preferredPlugins.end() && packageInMap->value == package) 349 348 m_preferredPlugins.remove(packageInMap); … … 409 408 String fileNameFilter(""); 410 409 411 Vector<String>::const_iteratordirsEnd = m_pluginDirectories.end();412 for ( Vector<String>::const_iteratordIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {410 auto dirsEnd = m_pluginDirectories.end(); 411 for (auto dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) { 413 412 Vector<String> pluginPaths = listDirectory(*dIt, fileNameFilter); 414 Vector<String>::const_iteratorpluginsEnd = pluginPaths.end();415 for ( Vector<String>::const_iteratorpIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {413 auto pluginsEnd = pluginPaths.end(); 414 for (auto pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) { 416 415 if (!fileExistsAndIsNotDisabled(*pIt)) 417 416 continue; … … 584 583 } 585 584 586 PluginSet::const_iteratorend = m_plugins.end();587 for ( PluginSet::const_iteratorit = m_plugins.begin(); it != end; ++it) {585 auto end = m_plugins.end(); 586 for (auto it = m_plugins.begin(); it != end; ++it) { 588 587 if (!(writeUTF8String(file, (*it)->path()) 589 588 && writeTime(file, (*it)->lastModified()) -
trunk/Source/WebKit/win/Plugins/PluginDatabase.h
r178219 r196223 108 108 HashMap<String, RefPtr<PluginPackage> > m_pluginsByPath; 109 109 HashMap<String, time_t> m_pluginPathsWithTimes; 110 HashMap<String, RefPtr<PluginPackage> 110 HashMap<String, RefPtr<PluginPackage>, ASCIICaseInsensitiveHash> m_preferredPlugins; 111 111 #if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) 112 112 bool m_persistentMetadataCacheIsLoaded; -
trunk/Source/WebKit/win/Plugins/PluginPackage.h
r178219 r196223 40 40 41 41 namespace 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; 44 45 45 46 class PluginPackage : public RefCounted<PluginPackage> { -
trunk/Source/WebKit/win/Plugins/PluginPackageWin.cpp
r195743 r196223 201 201 202 202 for (unsigned i = 0; i < types.size(); i++) { 203 String type = types[i]. lower();203 String type = types[i].convertToASCIILowercase(); 204 204 String description = i < descriptions.size() ? descriptions[i] : ""; 205 205 String extensionList = i < extensionLists.size() ? extensionLists[i] : ""; … … 320 320 return false; 321 321 322 MIMEToExtensionsMap::const_iterator::Keysend = a.m_mimeToExtensions.end().keys();323 for ( MIMEToExtensionsMap::const_iterator::Keysit = 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) { 324 324 if (!b.m_mimeToExtensions.contains(*it)) 325 325 return false; -
trunk/Source/WebKit2/ChangeLog
r196214 r196223 1 2016-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 1 58 2016-02-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 59 -
trunk/Source/WebKit2/NetworkProcess/CustomProtocols/CustomProtocolManager.h
r195005 r196223 37 37 #include <wtf/RetainPtr.h> 38 38 #include <wtf/Threading.h> 39 #include <wtf/text/StringHash.h> 39 40 OBJC_CLASS NSURLSessionConfiguration; 40 41 OBJC_CLASS WKCustomProtocol; … … 100 101 101 102 #if PLATFORM(COCOA) 102 HashSet<String > m_registeredSchemes;103 HashSet<String, ASCIICaseInsensitiveHash> m_registeredSchemes; 103 104 Lock m_registeredSchemesMutex; 104 105 -
trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm
r185294 r196223 187 187 mimeTypeDescription = 0; 188 188 189 mimeClassInfo.type = String(mimeType). lower();189 mimeClassInfo.type = String(mimeType).convertToASCIILowercase(); 190 190 mimeClassInfo.desc = mimeTypeDescription; 191 191 … … 205 205 // extension string into components. 206 206 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); 211 211 } 212 212 -
trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp
r174507 r196223 77 77 78 78 Vector<String> types; 79 mimeDescription. lower().split(UChar(';'), false, types);79 mimeDescription.convertToASCIILowercase().split(UChar(';'), false, types); 80 80 result.reserveInitialCapacity(types.size()); 81 81 -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
r194359 r196223 564 564 void* data; 565 565 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("_", "-")); 567 567 } 568 568 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r194532 r196223 969 969 Vector<String> languages; 970 970 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("_", "-")); 972 972 973 973 WebCore::overrideUserPreferredLanguages(languages); -
trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
r176290 r196223 139 139 140 140 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)) { 144 142 // We found a supported extension, set the correct MIME type. 145 143 mimeType = mimeClassInfo.type; … … 161 159 extension = filename.substring(extensionPos + 1); 162 160 } 163 164 return extension; 161 return extension.convertToASCIILowercase(); 165 162 } 166 163 167 164 #if !PLATFORM(COCOA) 165 168 166 PluginModuleLoadPolicy PluginInfoStore::defaultLoadPolicyForPlugin(const PluginModuleInfo&) 169 167 { … … 191 189 192 190 // Next, check if any plug-ins claim to support the URL extension. 193 String extension = pathExtension(url) .lower();191 String extension = pathExtension(url); 194 192 if (!extension.isNull() && mimeType.isEmpty()) { 195 193 PluginModuleInfo plugin = findPluginForExtension(extension, mimeType, allowedPluginTypes); -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r196024 r196223 1864 1864 MESSAGE_CHECK_URL(urlString); 1865 1865 1866 newMimeType = mimeType. lower();1866 newMimeType = mimeType.convertToASCIILowercase(); 1867 1867 pluginLoadPolicy = PluginModuleLoadNormally; 1868 1868 -
trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp
r195589 r196223 914 914 } 915 915 916 HashSet<String >& WebProcessPool::globalURLSchemesWithCustomProtocolHandlers()917 { 918 static NeverDestroyed<HashSet<String >> set;916 HashSet<String, ASCIICaseInsensitiveHash>& WebProcessPool::globalURLSchemesWithCustomProtocolHandlers() 917 { 918 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> set; 919 919 return set; 920 920 } … … 925 925 return; 926 926 927 String schemeLower = urlScheme.lower(); 928 globalURLSchemesWithCustomProtocolHandlers().add(schemeLower); 927 globalURLSchemesWithCustomProtocolHandlers().add(urlScheme); 929 928 for (auto* processPool : allProcessPools()) 930 processPool->registerSchemeForCustomProtocol( schemeLower);929 processPool->registerSchemeForCustomProtocol(urlScheme); 931 930 } 932 931 … … 936 935 return; 937 936 938 String schemeLower = urlScheme.lower(); 939 globalURLSchemesWithCustomProtocolHandlers().remove(schemeLower); 937 globalURLSchemesWithCustomProtocolHandlers().remove(urlScheme); 940 938 for (auto* processPool : allProcessPools()) 941 processPool->unregisterSchemeForCustomProtocol( schemeLower);939 processPool->unregisterSchemeForCustomProtocol(urlScheme); 942 940 } 943 941 -
trunk/Source/WebKit2/UIProcess/WebProcessPool.h
r195589 r196223 318 318 void unregisterSchemeForCustomProtocol(const String&); 319 319 320 static HashSet<String >& globalURLSchemesWithCustomProtocolHandlers();320 static HashSet<String, ASCIICaseInsensitiveHash>& globalURLSchemesWithCustomProtocolHandlers(); 321 321 static void registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&); 322 322 static void unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String&); -
trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
r196053 r196223 639 639 #if PLUGIN_ARCHITECTURE(MAC) 640 640 if (m_pluginModule->pluginQuirks().contains(PluginQuirks::WantsLowercaseParameterNames)) 641 parameterName = parameterName. lower();641 parameterName = parameterName.convertToASCIILowercase(); 642 642 #endif 643 643 … … 676 676 for (size_t i = 0; i < parameters.names.size(); ++i) { 677 677 if (equalLettersIgnoringASCIICase(parameters.names[i], "background")) { 678 setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i]. lower()));678 setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i].convertToASCIILowercase())); 679 679 break; 680 680 } -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
r195722 r196223 1509 1509 static bool pluginSupportsExtension(const PluginData& pluginData, const String& extension) 1510 1510 { 1511 ASSERT(extension.lower() == extension); 1512 1511 ASSERT(extension.convertToASCIILowercase() == extension); 1513 1512 Vector<MimeClassInfo> mimes; 1514 1513 Vector<size_t> mimePluginIndices; 1515 1514 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) { 1519 1516 if (mimeClassInfo.extensions.contains(extension)) 1520 1517 return true; … … 1525 1522 ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const String& mimeTypeIn) 1526 1523 { 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. 1529 1525 1530 1526 String mimeType = mimeTypeIn; 1531 1527 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(); 1533 1533 1534 1534 // Try to guess the MIME type from the extension. 1535 1535 mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); 1536 1537 1536 if (mimeType.isEmpty()) { 1538 1537 // Check if there's a plug-in around that can handle the extension. … … 1541 1540 return ObjectContentNetscapePlugin; 1542 1541 } 1542 return ObjectContentFrame; 1543 1543 } 1544 1544 } 1545 1545 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 1558 1546 if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) 1559 1547 return ObjectContentImage; 1560 1548 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 } 1563 1555 1564 1556 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
Note: See TracChangeset
for help on using the changeset viewer.