Changeset 195951 in webkit


Ignore:
Timestamp:
Jan 31, 2016 9:46:20 PM (8 years ago)
Author:
Darin Adler
Message:

Cut down on calls to String::lower; mostly replace with convertToASCIILowercase
https://bugs.webkit.org/show_bug.cgi?id=153732

Reviewed by Dean Jackson.

Source/WebCore:

  • Modules/mediasource/MediaSource.cpp:

(WebCore::MediaSource::isTypeSupported): Added comment about mysterious call
to lower(); should probably return here and remove it.

  • Modules/navigatorcontentutils/NavigatorContentUtils.cpp:

(WebCore::initProtocolHandlerWhitelist): Deleted. Moved into isProtocolWhitelisted.
(WebCore::isProtocolWhitelisted): Changed set to be ASCIICaseInsensitiveHash and
initialized it using a lambda instead of a separate function.
(WebCore::verifyProtocolHandlerScheme): Added a FIXME about some case sensitive
checking of the protocol prefix here.

  • Modules/plugins/QuickTimePluginReplacement.mm:

(WebCore::QuickTimePluginReplacement::supportsMimeType): Changed set to be
ASCIICaseInsensitiveHash and initialized it using a lambda instead of using
an explict check for empty.
(WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto.

  • Modules/plugins/YouTubePluginReplacement.cpp:

(WebCore::queryKeysAndValues): Use convertToASCIILowercase. The keys here are
going to be all ASCII.
(WebCore::isYouTubeURL): Use equalLettersIgnoringASCIICase instead of lowercasing
the string.
(WebCore::processAndCreateYouTubeURL): Use url.protocolIsInHTTPFamily instead of
listing "http" and then "https" explicitly. Use equalLettersIgnoringASCIICase
instead of lowercasing a string.
(WebCore::YouTubePluginReplacement::youTubeURL): Ditto.

  • Modules/websockets/WebSocketHandshake.cpp:

(WebCore::hostName): Use convertToASCIILowercase on host name.
(WebCore::WebSocketHandshake::host): Ditto.

  • accessibility/atk/WebKitAccessibleWrapperAtk.cpp:

(webkitAccessibleGetAttributes): Call convertToASCIILowercase instead of lower
to lowercase an element's tag name. This is a strange way to do things; typically
would be better to use some other function on Element, since tagName goes out of
its way to be capitalized, but some ATK expert can improve this later.

  • css/CSSGrammar.y.in: Use the new convertToASCIILowercaseInPlace function rather

than the old lower function. We only need to lowercase the ASCII letters, and it's
also better to have the function have a clearer name.

  • css/CSSParser.cpp:

(WebCore::convertToASCIILowercaseInPlace): Renamed from makeLower and made it deal
with only ASCII lowercasing.
(WebCore::CSSParserString::convertToASCIILowercaseInPlace): Renamed from lower.
(WebCore::isUniversalKeyword): Added. Helper for the function below that uses
equalLettersIgnoringASCIICase rather than lowercasing the string.
(WebCore::parseKeywordValue): Use isUniversalKeyword. Also clarified a comment.
(WebCore::CSSParser::parseAttr): Use convertToASCIILowercaseInPlace and delay
String creation until later in the function, using CSSParserString operations more.

  • css/CSSParserValues.cpp:

(WebCore::CSSParserSelector::parsePseudoElementSelector): Use
convertToASCIILowercaseInPlace by its new name, with its new behavior.

  • css/CSSParserValues.h: Tweaked comment and formatting a bit. Replaced the lower

function with the convertToASCIILowercaseInPlace function.

  • css/CSSSelector.cpp:

(WebCore::CSSSelector::RareData::parseNth): Rewrote this to avoid the need to
make a lowercased copy of m_argument. Use equalLettersIgnoringASCIICase, and two
calls to find. Also use String::toIntStrict so we don't have to create String
objects for substrings.

  • css/MediaQuery.cpp:

(WebCore::MediaQuery::MediaQuery): Use convertToASCIILowercase for media type name.

  • css/MediaQueryExp.cpp:

(WebCore::MediaQueryExp::serialize): Use convertToASCIILowercase for media feature name.

  • dom/Document.cpp:

(WebCore::isSeparator): Tweaked formatting and removed non-helpful comment.
(WebCore::processArguments): Changed this from a static member function to a non-member
file internal function. Use a std::function instead of a function pointer with a void*
pointer. Rewrote algorithm to simplify it and use StringView instead of String for the
keys and values.
(WebCore::Document::processViewport): Use a lambda instead of a function pointer to
call setViewportFeature, so that function's interface is no longer dictated by
the exact type of the function pointer argument to processArguments.
(WebCore::Document::processFormatDetection): Use a lambda instead of the
setParserFeature function above; use equalLettersIgnoringASCIICase for both the
key and the value, since processArguments no longer lowercases the string.
(WebCore::Document::processArguments): Deleted.

  • dom/Document.h: Removed unnecessary declaration of processArguments and

ArgumentsCallback. Both are now private to the cpp file.

  • dom/Element.cpp:

(WebCore::makeIdForStyleResolution): Use convertToASCIILowercase. When in quirks mode,
we want to match IDs in an ASCII case-insensitive way not match compatibility caseless.

  • dom/ScriptElement.cpp:

(WebCore::ScriptElement::isScriptTypeSupported): Remove the use of lower here since
the MIME type registry is now itself ASCII case-insensitive.

  • dom/ViewportArguments.cpp:

(WebCore::numericPrefix): Changed to use StringView and take a Document&, rearranged
argument order so Document& comes first.
(WebCore::findSizeValue): Ditto.
(WebCore::findScaleValue): Ditto.
(WebCore::findBooleanValue): Ditto. Also use std::abs instead of fabs, possibly
avoiding a conversion from float to double (not sure it was happening before but it's
definitely not happening now).
(WebCore::setViewportFeature): Changed to put arguments in a more logical order, to take
the ViewportArguments as a reference, not a void*, and to use StringView to avoid forcing
the caller to allocate strings. Also changed to use equalLettersIgnoringASCIICase so we
don't rely on the caller to make the key lowercase for us.
(WebCore::reportViewportWarning): Changed argument types. Added a couple comments about
mistakes in the function.

  • dom/ViewportArguments.h: Removed unnecessary declaration of reportViewportWarning,

which is now private to the cpp file. Updated for new arguments to setViewportFeature.

  • editing/EditorCommand.cpp:

(WebCore::executeFormatBlock): Use convertToASCIILowercase on the argument, which is
specifying a tag name.

  • fileapi/Blob.cpp:

(WebCore::Blob::isValidContentType): Removed unnecessary separate loops for
8-bit and 16-bit strings. Content types are short strings and this small optimization is
not worth the additional code complexity.
(WebCore::Blob::normalizedContentType): Use convertToASCIILowercase since valid
content types are guaranteed to be all ASCII.
(WebCore::Blob::isNormalizedContentType): Removed unnecessary separate loops for
8-bit and 16-bit strings. Content types are short strings and this small optimization is
not worth the additional code complexity.

  • html/parser/HTMLParserIdioms.cpp: Added now-needed include of QualifiedName.h.
  • html/parser/HTMLParserIdioms.h: Removed unneeded include of QualifiedName.h and

WTFString.h. Made sure every function is declared first, even if it's also defined
later in the header in the section for functions templates and inline functions.

  • loader/archive/ArchiveFactory.cpp:

(WebCore::ArchiveFactory::registerKnownArchiveMIMETypes): Use auto& for the type of
the set of MIME types here, since it's now using ASCIICaseInsensitiveHash.

  • platform/MIMETypeRegistry.cpp: Changed the MIME type sets to use

ASCIICaseInsensitiveHash since MIME type are not case sensitive.
(WebCore::initializeSupportedImageMIMETypes): Use a modern for loop.
(WebCore::initializeSupportedImageMIMETypesForEncoding): Updated for HashSet type change.
(WebCore::initializePDFMIMETypes): Use a modern for loop.
(WebCore::initializeSupportedNonImageMimeTypes): Use a modern for loop.
(WebCore::initializeSupportedMediaMIMETypes): Updated for HashSet type change.
(WebCore::initializeUnsupportedTextMIMETypes): Use a modern for loop.
(WebCore::initializeMIMETypeRegistry): Updated for HashSet type change.
(WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): Ditto.
(WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Ditto.
(WebCore::MIMETypeRegistry::getSupportedImageMIMETypesForEncoding): Ditto.
(WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): Ditto.
(WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes): Ditto.
(WebCore::MIMETypeRegistry::getPDFMIMETypes): Ditto.
(WebCore::MIMETypeRegistry::getPDFAndPostScriptMIMETypes): Ditto.
(WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes): Ditto.
(WebCore::mimeTypeAssociationMap): Use ASCIICaseInsensitiveHash.
(WebCore::MIMETypeRegistry::getNormalizedMIMEType): Use auto to make code tighter.

  • platform/MIMETypeRegistry.h: Changed return types of the getMIMETypes functions

to use ASCIICaseInsensitiveHash.

  • platform/SchemeRegistry.cpp:

(WebCore::schemesForbiddenFromDomainRelaxation): Changed type to
use ASCIICaseInsensitiveHash.

  • platform/URL.cpp:

(WebCore::mimeTypeFromDataURL): Use convertToASCIILowercase instead of lower.
Also removed some dead code that tried to handle the case where the data URL
has a comma as one of the first 5 characters: That can't happen since it's a
precondition of this function that the first five characters are "data:".

  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::getSupportedTypes): Change type of argument to
a HashSet with ASCIICaseInsensitiveHash.

  • platform/graphics/MediaPlayer.h: Ditto.
  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList):
Changed type of HashSet to use ASCIICaseInsensitiveHash.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: Ditto.
  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:

(WebCore::avfMIMETypes):
Changed type of HashSet to use ASCIICaseInsensitiveHash.
(WebCore::MediaPlayerPrivateAVFoundationCF::getSupportedTypes): Ditto.

  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h: Ditto.
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:

Changed type of HashSet to use ASCIICaseInsensitiveHash.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator): Removed
an unnecessary line of code to set a local variable to 0 just before it falls
out of scope.
(WebCore::avfMIMETypes): Ditto. Also tightened up the code a bit.
(WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): Ditto.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:

Changed type of HashSet to use ASCIICaseInsensitiveHash.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::mimeTypeCache): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes): Ditto.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: Ditto.
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Ditto.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::mimeTypeCache): Ditto.
(WebCore::MediaPlayerPrivateGStreamer::getSupportedTypes): Ditto.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Ditto.
  • platform/graphics/mac/MediaPlayerPrivateQTKit.h: Ditto.
  • platform/graphics/mac/MediaPlayerPrivateQTKit.mm:

(WebCore::shouldRejectMIMEType): Made this non-case-sensitive by using startsWith
and the "false" argument. Later change this to startsWithIgnoringASCIICase or
startsWithLettersIgnoringASCIICase.
(WebCore::addFileTypesToCache): Use ASCIICaseInsensitiveHash. ALso rewrote to
tighten up the code a bit and use modern Objective-C for loops.
(WebCore::mimeCommonTypesCache): Use ASCIICaseInsensitiveHash.
(WebCore::mimeModernTypesCache): Ditto.
(WebCore::concatenateHashSets): Ditto.
(WebCore::MediaPlayerPrivateQTKit::getSupportedTypes): Ditto.
(WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Initialied
track type set using lambda, but left it case sensitive.

  • platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:

(WebCore::mimeTypeCache): Changed type of HashSet to use ASCIICaseInsensitiveHash.
(WebCore::MediaPlayerPrivateMediaFoundation::getSupportedTypes): Ditto.

  • platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
  • platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:

(WebCore::mimeTypeCache): Ditto.
(WebCore::MockMediaPlayerMediaSource::getSupportedTypes): Ditto.

  • platform/mock/mediasource/MockMediaPlayerMediaSource.h: Ditto.

Source/WebKit/mac:

  • WebView/WebHTMLRepresentation.mm:

(newArrayWithStrings): Updated to use HashSet<String, ASCIICaseInsensitiveHash>
and also to use a modern for loop.

Source/WTF:

  • wtf/text/StringView.h: Added toIntStrict. Not thrilled about the name of this

function, but generally it seems likely to be useful more often than toInt.
And it's needed for one call site in WebCore that was using String::lower.

Location:
trunk/Source
Files:
53 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r195946 r195951  
     12016-01-31  Darin Adler  <darin@apple.com>
     2
     3        Cut down on calls to String::lower; mostly replace with convertToASCIILowercase
     4        https://bugs.webkit.org/show_bug.cgi?id=153732
     5
     6        Reviewed by Dean Jackson.
     7
     8        * wtf/text/StringView.h: Added toIntStrict. Not thrilled about the name of this
     9        function, but generally it seems likely to be useful more often than toInt.
     10        And it's needed for one call site in WebCore that was using String::lower.
     11
    1122016-01-31  Darin Adler  <darin@apple.com>
    213
  • trunk/Source/WTF/wtf/text/StringView.h

    r195743 r195951  
    127127
    128128    int toInt(bool& isValid) const;
     129    int toIntStrict(bool& isValid) const;
    129130    float toFloat(bool& isValid) const;
    130131
     
    462463}
    463464
     465inline int StringView::toIntStrict(bool& isValid) const
     466{
     467    if (is8Bit())
     468        return charactersToIntStrict(characters8(), m_length, &isValid);
     469    return charactersToIntStrict(characters16(), length(), &isValid);
     470}
     471
    464472inline String StringView::toStringWithoutCopying() const
    465473{
  • trunk/Source/WebCore/ChangeLog

    r195950 r195951  
     12016-01-31  Darin Adler  <darin@apple.com>
     2
     3        Cut down on calls to String::lower; mostly replace with convertToASCIILowercase
     4        https://bugs.webkit.org/show_bug.cgi?id=153732
     5
     6        Reviewed by Dean Jackson.
     7
     8        * Modules/mediasource/MediaSource.cpp:
     9        (WebCore::MediaSource::isTypeSupported): Added comment about mysterious call
     10        to lower(); should probably return here and remove it.
     11
     12        * Modules/navigatorcontentutils/NavigatorContentUtils.cpp:
     13        (WebCore::initProtocolHandlerWhitelist): Deleted. Moved into isProtocolWhitelisted.
     14        (WebCore::isProtocolWhitelisted): Changed set to be ASCIICaseInsensitiveHash and
     15        initialized it using a lambda instead of a separate function.
     16        (WebCore::verifyProtocolHandlerScheme): Added a FIXME about some case sensitive
     17        checking of the protocol prefix here.
     18
     19        * Modules/plugins/QuickTimePluginReplacement.mm:
     20        (WebCore::QuickTimePluginReplacement::supportsMimeType): Changed set to be
     21        ASCIICaseInsensitiveHash and initialized it using a lambda instead of using
     22        an explict check for empty.
     23        (WebCore::QuickTimePluginReplacement::supportsFileExtension): Ditto.
     24
     25        * Modules/plugins/YouTubePluginReplacement.cpp:
     26        (WebCore::queryKeysAndValues): Use convertToASCIILowercase. The keys here are
     27        going to be all ASCII.
     28        (WebCore::isYouTubeURL): Use equalLettersIgnoringASCIICase instead of lowercasing
     29        the string.
     30        (WebCore::processAndCreateYouTubeURL): Use url.protocolIsInHTTPFamily instead of
     31        listing "http" and then "https" explicitly. Use equalLettersIgnoringASCIICase
     32        instead of lowercasing a string.
     33        (WebCore::YouTubePluginReplacement::youTubeURL): Ditto.
     34
     35        * Modules/websockets/WebSocketHandshake.cpp:
     36        (WebCore::hostName): Use convertToASCIILowercase on host name.
     37        (WebCore::WebSocketHandshake::host): Ditto.
     38
     39        * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
     40        (webkitAccessibleGetAttributes): Call convertToASCIILowercase instead of lower
     41        to lowercase an element's tag name. This is a strange way to do things; typically
     42        would be better to use some other function on Element, since tagName goes out of
     43        its way to be capitalized, but some ATK expert can improve this later.
     44
     45        * css/CSSGrammar.y.in: Use the new convertToASCIILowercaseInPlace function rather
     46        than the old lower function. We only need to lowercase the ASCII letters, and it's
     47        also better to have the function have a clearer name.
     48
     49        * css/CSSParser.cpp:
     50        (WebCore::convertToASCIILowercaseInPlace): Renamed from makeLower and made it deal
     51        with only ASCII lowercasing.
     52        (WebCore::CSSParserString::convertToASCIILowercaseInPlace): Renamed from lower.
     53        (WebCore::isUniversalKeyword): Added. Helper for the function below that uses
     54        equalLettersIgnoringASCIICase rather than lowercasing the string.
     55        (WebCore::parseKeywordValue): Use isUniversalKeyword. Also clarified a comment.
     56        (WebCore::CSSParser::parseAttr): Use convertToASCIILowercaseInPlace and delay
     57        String creation until later in the function, using CSSParserString operations more.
     58
     59        * css/CSSParserValues.cpp:
     60        (WebCore::CSSParserSelector::parsePseudoElementSelector): Use
     61        convertToASCIILowercaseInPlace by its new name, with its new behavior.
     62
     63        * css/CSSParserValues.h: Tweaked comment and formatting a bit. Replaced the lower
     64        function with the convertToASCIILowercaseInPlace function.
     65
     66        * css/CSSSelector.cpp:
     67        (WebCore::CSSSelector::RareData::parseNth): Rewrote this to avoid the need to
     68        make a lowercased copy of m_argument. Use equalLettersIgnoringASCIICase, and two
     69        calls to find. Also use String::toIntStrict so we don't have to create String
     70        objects for substrings.
     71
     72        * css/MediaQuery.cpp:
     73        (WebCore::MediaQuery::MediaQuery): Use convertToASCIILowercase for media type name.
     74        * css/MediaQueryExp.cpp:
     75        (WebCore::MediaQueryExp::serialize): Use convertToASCIILowercase for media feature name.
     76
     77        * dom/Document.cpp:
     78        (WebCore::isSeparator): Tweaked formatting and removed non-helpful comment.
     79        (WebCore::processArguments): Changed this from a static member function to a non-member
     80        file internal function. Use a std::function instead of a function pointer with a void*
     81        pointer. Rewrote algorithm to simplify it and use StringView instead of String for the
     82        keys and values.
     83        (WebCore::Document::processViewport): Use a lambda instead of a function pointer to
     84        call setViewportFeature, so that function's interface is no longer dictated by
     85        the exact type of the function pointer argument to processArguments.
     86        (WebCore::Document::processFormatDetection): Use a lambda instead of the
     87        setParserFeature function above; use equalLettersIgnoringASCIICase for both the
     88        key and the value, since processArguments no longer lowercases the string.
     89        (WebCore::Document::processArguments): Deleted.
     90
     91        * dom/Document.h: Removed unnecessary declaration of processArguments and
     92        ArgumentsCallback. Both are now private to the cpp file.
     93
     94        * dom/Element.cpp:
     95        (WebCore::makeIdForStyleResolution): Use convertToASCIILowercase. When in quirks mode,
     96        we want to match IDs in an ASCII case-insensitive way not match compatibility caseless.
     97
     98        * dom/ScriptElement.cpp:
     99        (WebCore::ScriptElement::isScriptTypeSupported): Remove the use of lower here since
     100        the MIME type registry is now itself ASCII case-insensitive.
     101
     102        * dom/ViewportArguments.cpp:
     103        (WebCore::numericPrefix): Changed to use StringView and take a Document&, rearranged
     104        argument order so Document& comes first.
     105        (WebCore::findSizeValue): Ditto.
     106        (WebCore::findScaleValue): Ditto.
     107        (WebCore::findBooleanValue): Ditto. Also use std::abs instead of fabs, possibly
     108        avoiding a conversion from float to double (not sure it was happening before but it's
     109        definitely not happening now).
     110        (WebCore::setViewportFeature): Changed to put arguments in a more logical order, to take
     111        the ViewportArguments as a reference, not a void*, and to use StringView to avoid forcing
     112        the caller to allocate strings. Also changed to use equalLettersIgnoringASCIICase so we
     113        don't rely on the caller to make the key lowercase for us.
     114        (WebCore::reportViewportWarning): Changed argument types. Added a couple comments about
     115        mistakes in the function.
     116
     117        * dom/ViewportArguments.h: Removed unnecessary declaration of reportViewportWarning,
     118        which is now private to the cpp file. Updated for new arguments to setViewportFeature.
     119
     120        * editing/EditorCommand.cpp:
     121        (WebCore::executeFormatBlock): Use convertToASCIILowercase on the argument, which is
     122        specifying a tag name.
     123
     124        * fileapi/Blob.cpp:
     125        (WebCore::Blob::isValidContentType): Removed unnecessary separate loops for
     126        8-bit and 16-bit strings. Content types are short strings and this small optimization is
     127        not worth the additional code complexity.
     128        (WebCore::Blob::normalizedContentType): Use convertToASCIILowercase since valid
     129        content types are guaranteed to be all ASCII.
     130        (WebCore::Blob::isNormalizedContentType): Removed unnecessary separate loops for
     131        8-bit and 16-bit strings. Content types are short strings and this small optimization is
     132        not worth the additional code complexity.
     133
     134        * html/parser/HTMLParserIdioms.cpp: Added now-needed include of QualifiedName.h.
     135
     136        * html/parser/HTMLParserIdioms.h: Removed unneeded include of QualifiedName.h and
     137        WTFString.h. Made sure every function is declared first, even if it's also defined
     138        later in the header in the section for functions templates and inline functions.
     139
     140        * loader/archive/ArchiveFactory.cpp:
     141        (WebCore::ArchiveFactory::registerKnownArchiveMIMETypes): Use auto& for the type of
     142        the set of MIME types here, since it's now using ASCIICaseInsensitiveHash.
     143
     144        * platform/MIMETypeRegistry.cpp: Changed the MIME type sets to use
     145        ASCIICaseInsensitiveHash since MIME type are not case sensitive.
     146        (WebCore::initializeSupportedImageMIMETypes): Use a modern for loop.
     147        (WebCore::initializeSupportedImageMIMETypesForEncoding): Updated for HashSet type change.
     148        (WebCore::initializePDFMIMETypes): Use a modern for loop.
     149        (WebCore::initializeSupportedNonImageMimeTypes): Use a modern for loop.
     150        (WebCore::initializeSupportedMediaMIMETypes): Updated for HashSet type change.
     151        (WebCore::initializeUnsupportedTextMIMETypes): Use a modern for loop.
     152        (WebCore::initializeMIMETypeRegistry): Updated for HashSet type change.
     153        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypes): Ditto.
     154        (WebCore::MIMETypeRegistry::getSupportedImageResourceMIMETypes): Ditto.
     155        (WebCore::MIMETypeRegistry::getSupportedImageMIMETypesForEncoding): Ditto.
     156        (WebCore::MIMETypeRegistry::getSupportedNonImageMIMETypes): Ditto.
     157        (WebCore::MIMETypeRegistry::getSupportedMediaMIMETypes): Ditto.
     158        (WebCore::MIMETypeRegistry::getPDFMIMETypes): Ditto.
     159        (WebCore::MIMETypeRegistry::getPDFAndPostScriptMIMETypes): Ditto.
     160        (WebCore::MIMETypeRegistry::getUnsupportedTextMIMETypes): Ditto.
     161        (WebCore::mimeTypeAssociationMap): Use ASCIICaseInsensitiveHash.
     162        (WebCore::MIMETypeRegistry::getNormalizedMIMEType): Use auto to make code tighter.
     163
     164        * platform/MIMETypeRegistry.h: Changed return types of the getMIMETypes functions
     165        to use ASCIICaseInsensitiveHash.
     166
     167        * platform/SchemeRegistry.cpp:
     168        (WebCore::schemesForbiddenFromDomainRelaxation): Changed type to
     169        use ASCIICaseInsensitiveHash.
     170
     171        * platform/URL.cpp:
     172        (WebCore::mimeTypeFromDataURL): Use convertToASCIILowercase instead of lower.
     173        Also removed some dead code that tried to handle the case where the data URL
     174        has a comma as one of the first 5 characters: That can't happen since it's a
     175        precondition of this function that the first five characters are "data:".
     176
     177        * platform/graphics/MediaPlayer.cpp:
     178        (WebCore::MediaPlayer::getSupportedTypes): Change type of argument to
     179        a HashSet with ASCIICaseInsensitiveHash.
     180        * platform/graphics/MediaPlayer.h: Ditto.
     181
     182        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     183        (WebCore::MediaPlayerPrivateAVFoundation::staticMIMETypeList):
     184        Changed type of HashSet to use ASCIICaseInsensitiveHash.
     185        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: Ditto.
     186
     187        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
     188        (WebCore::avfMIMETypes):
     189        Changed type of HashSet to use ASCIICaseInsensitiveHash.
     190        (WebCore::MediaPlayerPrivateAVFoundationCF::getSupportedTypes): Ditto.
     191        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h: Ditto.
     192
     193        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     194        Changed type of HashSet to use ASCIICaseInsensitiveHash.
     195        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     196        (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithImageGenerator): Removed
     197        an unnecessary line of code to set a local variable to 0 just before it falls
     198        out of scope.
     199        (WebCore::avfMIMETypes): Ditto. Also tightened up the code a bit.
     200        (WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): Ditto.
     201
     202        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
     203        Changed type of HashSet to use ASCIICaseInsensitiveHash.
     204        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
     205        (WebCore::mimeTypeCache): Ditto.
     206        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes): Ditto.
     207
     208        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: Ditto.
     209        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
     210        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes): Ditto.
     211
     212        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     213        (WebCore::mimeTypeCache): Ditto.
     214        (WebCore::MediaPlayerPrivateGStreamer::getSupportedTypes): Ditto.
     215        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: Ditto.
     216
     217        * platform/graphics/mac/MediaPlayerPrivateQTKit.h: Ditto.
     218        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
     219        (WebCore::shouldRejectMIMEType): Made this non-case-sensitive by using startsWith
     220        and the "false" argument. Later change this to startsWithIgnoringASCIICase or
     221        startsWithLettersIgnoringASCIICase.
     222        (WebCore::addFileTypesToCache): Use ASCIICaseInsensitiveHash. ALso rewrote to
     223        tighten up the code a bit and use modern Objective-C for loops.
     224        (WebCore::mimeCommonTypesCache): Use ASCIICaseInsensitiveHash.
     225        (WebCore::mimeModernTypesCache): Ditto.
     226        (WebCore::concatenateHashSets): Ditto.
     227        (WebCore::MediaPlayerPrivateQTKit::getSupportedTypes): Ditto.
     228        (WebCore::MediaPlayerPrivateQTKit::disableUnsupportedTracks): Initialied
     229        track type set using lambda, but left it case sensitive.
     230
     231        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
     232        (WebCore::mimeTypeCache): Changed type of HashSet to use ASCIICaseInsensitiveHash.
     233        (WebCore::MediaPlayerPrivateMediaFoundation::getSupportedTypes): Ditto.
     234        * platform/graphics/win/MediaPlayerPrivateMediaFoundation.h:
     235
     236        * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
     237        (WebCore::mimeTypeCache): Ditto.
     238        (WebCore::MockMediaPlayerMediaSource::getSupportedTypes): Ditto.
     239        * platform/mock/mediasource/MockMediaPlayerMediaSource.h: Ditto.
     240
    12412016-01-31  Brent Fulgham  <bfulgham@apple.com>
    2242
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp

    r194819 r195951  
    733733        return false;
    734734
     735    // FIXME: Why do we convert to lowercase here, but not in MediaSource::addSourceBuffer?
    735736    ContentType contentType(type.lower());
    736737    String codecs = contentType.parameter("codecs");
  • trunk/Source/WebCore/Modules/navigatorcontentutils/NavigatorContentUtils.cpp

    r194496 r195951  
    4040namespace WebCore {
    4141
    42 static HashSet<String>* protocolWhitelist;
    43 
    44 static void initProtocolHandlerWhitelist()
    45 {
    46     protocolWhitelist = new HashSet<String>;
    47     for (auto* protocol : { "bitcoin", "geo", "im", "irc", "ircs", "magnet", "mailto", "mms", "news", "nntp", "sip", "sms", "smsto", "ssh", "tel", "urn", "webcal", "wtai", "xmpp" })
    48         protocolWhitelist->add(protocol);
    49 }
    50 
    5142static bool verifyCustomHandlerURL(const URL& baseURL, const String& url, ExceptionCode& ec)
    5243{
     
    7566}
    7667
    77 static bool isProtocolWhitelisted(const String& scheme)
     68static inline bool isProtocolWhitelisted(const String& scheme)
    7869{
    79     if (!protocolWhitelist)
    80         initProtocolHandlerWhitelist();
    81     return protocolWhitelist->contains(scheme.convertToASCIILowercase());
     70    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> protocolWhitelist = []() {
     71        HashSet<String, ASCIICaseInsensitiveHash> set;
     72        for (auto* protocol : { "bitcoin", "geo", "im", "irc", "ircs", "magnet", "mailto", "mms", "news", "nntp", "sip", "sms", "smsto", "ssh", "tel", "urn", "webcal", "wtai", "xmpp" })
     73            set.add(protocol);
     74        return set;
     75    }();
     76    return protocolWhitelist.get().contains(scheme);
    8277}
    8378
     
    8782        return true;
    8883
     84    // FIXME: Should this be case sensitive, or should it be ASCII case-insensitive?
    8985    if (scheme.startsWith("web+")) {
    9086        // The specification requires that the length of scheme is at least five characters (including 'web+' prefix).
  • trunk/Source/WebCore/Modules/plugins/QuickTimePluginReplacement.mm

    r194819 r195951  
    8383bool QuickTimePluginReplacement::supportsMimeType(const String& mimeType)
    8484{
    85     static const char* types[] = {
    86         "application/vnd.apple.mpegurl", "application/x-mpegurl", "audio/3gpp", "audio/3gpp2", "audio/aac", "audio/aiff",
    87         "audio/amr", "audio/basic", "audio/mp3", "audio/mp4", "audio/mpeg", "audio/mpeg3", "audio/mpegurl", "audio/scpls",
    88         "audio/wav", "audio/x-aac", "audio/x-aiff", "audio/x-caf", "audio/x-m4a", "audio/x-m4b", "audio/x-m4p",
    89         "audio/x-m4r", "audio/x-mp3", "audio/x-mpeg", "audio/x-mpeg3", "audio/x-mpegurl", "audio/x-scpls", "audio/x-wav",
    90         "video/3gpp", "video/3gpp2", "video/mp4", "video/quicktime", "video/x-m4v"
    91     };
    92     static NeverDestroyed<HashSet<String>> typeHash;
    93     if (!typeHash.get().size()) {
    94         for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i)
    95             typeHash.get().add(types[i]);
    96     }
    97 
     85    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> typeHash = []() {
     86        static const char* const types[] = {
     87            "application/vnd.apple.mpegurl", "application/x-mpegurl", "audio/3gpp", "audio/3gpp2", "audio/aac", "audio/aiff",
     88            "audio/amr", "audio/basic", "audio/mp3", "audio/mp4", "audio/mpeg", "audio/mpeg3", "audio/mpegurl", "audio/scpls",
     89            "audio/wav", "audio/x-aac", "audio/x-aiff", "audio/x-caf", "audio/x-m4a", "audio/x-m4b", "audio/x-m4p",
     90            "audio/x-m4r", "audio/x-mp3", "audio/x-mpeg", "audio/x-mpeg3", "audio/x-mpegurl", "audio/x-scpls", "audio/x-wav",
     91            "video/3gpp", "video/3gpp2", "video/mp4", "video/quicktime", "video/x-m4v"
     92        };
     93        HashSet<String, ASCIICaseInsensitiveHash> set;
     94        for (auto& type : types)
     95            set.add(type);
     96        return set;
     97    }();
    9898    return typeHash.get().contains(mimeType);
    9999}
     
    101101bool QuickTimePluginReplacement::supportsFileExtension(const String& extension)
    102102{
    103     static const char* extensions[] = {
    104         "3g2", "3gp", "3gp2", "3gpp", "aac", "adts", "aif", "aifc", "aiff", "AMR", "au", "bwf", "caf", "cdda", "m3u",
    105         "m3u8", "m4a", "m4b", "m4p", "m4r", "m4v", "mov", "mp3", "mp3", "mp4", "mpeg", "mpg", "mqv", "pls", "qt",
    106         "snd", "swa", "ts", "ulw", "wav"
    107     };
    108     static NeverDestroyed<HashSet<String>> extensionHash;
    109     if (!extensionHash.get().size()) {
    110         for (size_t i = 0; i < WTF_ARRAY_LENGTH(extensions); ++i)
    111             extensionHash.get().add(extensions[i]);
    112     }
    113 
    114     return extensionHash.get().contains(extension);
     103    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> extensionSet = []() {
     104        static const char* const extensions[] = {
     105            "3g2", "3gp", "3gp2", "3gpp", "aac", "adts", "aif", "aifc", "aiff", "AMR", "au", "bwf", "caf", "cdda", "m3u",
     106            "m3u8", "m4a", "m4b", "m4p", "m4r", "m4v", "mov", "mp3", "mp3", "mp4", "mpeg", "mpg", "mqv", "pls", "qt",
     107            "snd", "swa", "ts", "ulw", "wav"
     108        };
     109        HashSet<String, ASCIICaseInsensitiveHash> set;
     110        for (auto& extension : extensions)
     111            set.add(extension);
     112        return set;
     113    }();
     114    return extensionSet.get().contains(extension);
    115115}
    116116
  • trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp

    r195452 r195951  
    155155        // Save the key and the value.
    156156        if (keyLength && valueLength) {
    157             const String& key = queryString.substring(keyLocation, keyLength).lower();
     157            String key = queryString.substring(keyLocation, keyLength).convertToASCIILowercase();
    158158            String value = queryString.substring(valueLocation, valueLength);
    159159            value.replace('+', ' ');
     
    182182static bool isYouTubeURL(const URL& url)
    183183{
    184     const String& hostName = url.host().lower();
    185    
    186     return hostName == "m.youtube.com"
    187         || hostName == "youtu.be"
    188         || hostName == "www.youtube.com"
    189         || hostName == "youtube.com"
    190         || hostName == "www.youtube-nocookie.com"
    191         || hostName == "youtube-nocookie.com";
     184    String hostName = url.host();
     185    return equalLettersIgnoringASCIICase(hostName, "m.youtube.com")
     186        || equalLettersIgnoringASCIICase(hostName, "youtu.be")
     187        || equalLettersIgnoringASCIICase(hostName, "www.youtube.com")
     188        || equalLettersIgnoringASCIICase(hostName, "youtube.com")
     189        || equalLettersIgnoringASCIICase(hostName, "www.youtube-nocookie.com")
     190        || equalLettersIgnoringASCIICase(hostName, "youtube-nocookie.com");
    192191}
    193192
     
    203202static URL processAndCreateYouTubeURL(const URL& url, bool& isYouTubeShortenedURL)
    204203{
    205     if (!url.protocolIs("http") && !url.protocolIs("https"))
     204    if (!url.protocolIsInHTTPFamily())
    206205        return URL();
    207    
     206
    208207    // Bail out early if we aren't even on www.youtube.com or youtube.com.
    209208    if (!isYouTubeURL(url))
    210209        return URL();
    211    
    212     const String& hostName = url.host().lower();
    213    
    214     bool isYouTubeMobileWebAppURL = hostName == "m.youtube.com";
    215     isYouTubeShortenedURL = hostName == "youtu.be";
    216    
     210
     211    String hostName = url.host();
     212    bool isYouTubeMobileWebAppURL = equalLettersIgnoringASCIICase(hostName, "m.youtube.com");
     213    isYouTubeShortenedURL = equalLettersIgnoringASCIICase(hostName, "youtu.be");
     214
    217215    // Short URL of the form: http://youtu.be/v1d301D
    218216    if (isYouTubeShortenedURL) {
    219         const String& videoID = url.lastPathComponent();
     217        String videoID = url.lastPathComponent();
    220218        if (videoID.isEmpty() || videoID == "/")
    221219            return URL();
    222        
    223220        return createYouTubeURL(videoID, emptyString());
    224221    }
     
    242239    }
    243240   
    244     if (path.lower() == "/watch") {
     241    if (equalLettersIgnoringASCIICase(path, "/watch")) {
    245242        if (!query.isEmpty()) {
    246243            const auto& queryDictionary = queryKeysAndValues(query);
     
    304301        // From the original URL, we need to get the part before /path/VideoId.
    305302        locationOfPathBeforeVideoID = srcString.find(srcPath.substring(0, locationOfVideoIDInPath));
    306     } else if (srcPath.lower() == "/watch") {
     303    } else if (equalLettersIgnoringASCIICase(srcPath, "/watch")) {
    307304        // From the original URL, we need to get the part before /watch/#!v=VideoID
     305        // FIXME: Shouldn't this be ASCII case-insensitive?
    308306        locationOfPathBeforeVideoID = srcString.find("/watch");
    309307    } else
  • trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp

    r195452 r195951  
    8282    ASSERT(url.protocolIs("wss") == secure);
    8383    StringBuilder builder;
    84     builder.append(url.host().lower());
     84    builder.append(url.host().convertToASCIILowercase());
    8585    if (url.port() && ((!secure && url.port() != 80) || (secure && url.port() != 443))) {
    8686        builder.append(':');
     
    144144}
    145145
     146// FIXME: Return type should just be String, not const String.
    146147const String WebSocketHandshake::host() const
    147148{
    148     return m_url.host().lower();
     149    return m_url.host().convertToASCIILowercase();
    149150}
    150151
  • trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp

    r193750 r195951  
    411411        String tagName = element->tagName();
    412412        if (!tagName.isEmpty())
    413             attributeSet = addToAtkAttributeSet(attributeSet, "tag", tagName.lower().utf8().data());
     413            attributeSet = addToAtkAttributeSet(attributeSet, "tag", tagName.convertToASCIILowercase().utf8().data());
    414414        String id = element->getIdAttribute().string();
    415415        if (!id.isEmpty())
  • trunk/Source/WebCore/css/CSSGrammar.y.in

    r195612 r195951  
    590590base_media_query_exp: '(' maybe_space IDENT maybe_space maybe_media_value ')' {
    591591        std::unique_ptr<CSSParserValueList> mediaValue($5);
    592         $3.lower();
     592        $3.convertToASCIILowercaseInPlace();
    593593        $$ = new MediaQueryExp($3, mediaValue.get());
    594594    }
     
    645645    |
    646646    maybe_media_restrictor maybe_space IDENT maybe_space maybe_and_media_query_exp_list {
    647         $3.lower();
     647        $3.convertToASCIILowercaseInPlace();
    648648        $$ = new MediaQuery($1, $3, std::unique_ptr<Vector<std::unique_ptr<MediaQueryExp>>>($5));
    649649    }
     
    12351235        $$->setMatch(CSSSelector::Id);
    12361236        if (parser->m_context.mode == CSSQuirksMode)
    1237             $1.lower();
     1237            $1.convertToASCIILowercaseInPlace();
    12381238        $$->setValue($1);
    12391239    }
     
    12451245            $$->setMatch(CSSSelector::Id);
    12461246            if (parser->m_context.mode == CSSQuirksMode)
    1247                 $1.lower();
     1247                $1.convertToASCIILowercaseInPlace();
    12481248            $$->setValue($1);
    12491249        }
     
    12591259        $$->setMatch(CSSSelector::Class);
    12601260        if (parser->m_context.mode == CSSQuirksMode)
    1261             $2.lower();
     1261            $2.convertToASCIILowercaseInPlace();
    12621262        $$->setValue($2);
    12631263    }
  • trunk/Source/WebCore/css/CSSParser.cpp

    r195892 r195951  
    341341}
    342342
    343 template <typename CharacterType>
    344 ALWAYS_INLINE static void makeLower(const CharacterType* input, CharacterType* output, unsigned length)
    345 {
    346     // FIXME: If we need Unicode lowercasing here, then we probably want the real kind
    347     // that can potentially change the length of the string rather than the character
    348     // by character kind. If we don't need Unicode lowercasing, it would be good to
    349     // simplify this function.
    350 
    351     if (charactersAreAllASCII(input, length)) {
    352         // Fast case for all-ASCII.
    353         for (unsigned i = 0; i < length; ++i)
    354             output[i] = toASCIILower(input[i]);
    355     } else {
    356         for (unsigned i = 0; i < length; ++i) {
    357             ASSERT(u_tolower(input[i]) <= 0xFFFF);
    358             output[i] = u_tolower(input[i]);
    359         }
    360     }
    361 }
    362 
    363 void CSSParserString::lower()
    364 {
    365     if (is8Bit()) {
    366         makeLower(characters8(), characters8(), length());
    367         return;
    368     }
    369 
    370     makeLower(characters16(), characters16(), length());
     343template<typename CharacterType> ALWAYS_INLINE static void convertToASCIILowercaseInPlace(CharacterType* characters, unsigned length)
     344{
     345    for (unsigned i = 0; i < length; ++i)
     346        characters[i] = toASCIILower(characters[i]);
     347}
     348
     349void CSSParserString::convertToASCIILowercaseInPlace()
     350{
     351    if (is8Bit())
     352        WebCore::convertToASCIILowercaseInPlace(characters8(), length());
     353    else
     354        WebCore::convertToASCIILowercaseInPlace(characters16(), length());
    371355}
    372356
     
    11991183}
    12001184
     1185static bool isUniversalKeyword(const String& string)
     1186{
     1187    // These keywords can be used for all properties.
     1188    return equalLettersIgnoringASCIICase(string, "initial")
     1189        || equalLettersIgnoringASCIICase(string, "inherit")
     1190        || equalLettersIgnoringASCIICase(string, "unset")
     1191        || equalLettersIgnoringASCIICase(string, "revert");
     1192}
     1193
    12011194static CSSParser::ParseResult parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents)
    12021195{
     
    12041197
    12051198    if (!isKeywordPropertyID(propertyId)) {
    1206         // All properties accept the values of "initial" and "inherit".
    1207         String lowerCaseString = string.lower();
    1208         if (lowerCaseString != "initial" && lowerCaseString != "inherit" && lowerCaseString != "unset" && lowerCaseString != "revert")
     1199        if (!isUniversalKeyword(string))
    12091200            return CSSParser::ParseResult::Error;
    12101201
    1211         // Parse initial/inherit/unset/revert shorthands using the CSSParser.
     1202        // Don't try to parse initial/inherit/unset/revert shorthands; return an error so the caller will use the full CSS parser.
    12121203        if (shorthandForProperty(propertyId).length())
    12131204            return CSSParser::ParseResult::Error;
     
    43434334        return nullptr;
    43444335
    4345     String attrName = argument.string;
     4336    ASSERT(argument.string.length());
     4337
    43464338    // CSS allows identifiers with "-" at the start, like "-webkit-mask-image".
    43474339    // But HTML attribute names can't have those characters, and we should not
    43484340    // even parse them inside attr().
    4349     if (attrName[0] == '-')
     4341    if (argument.string[0] == '-')
    43504342        return nullptr;
    43514343
    43524344    if (m_context.isHTMLDocument)
    4353         attrName = attrName.lower();
    4354 
    4355     return CSSValuePool::singleton().createValue(attrName, CSSPrimitiveValue::CSS_ATTR);
     4345        argument.string.convertToASCIILowercaseInPlace();
     4346
     4347    // FIXME: Is there some small benefit to creating an AtomicString here instead of a String?
     4348    return CSSValuePool::singleton().createValue(String(argument.string), CSSPrimitiveValue::CSS_ATTR);
    43564349}
    43574350
  • trunk/Source/WebCore/css/CSSParserValues.cpp

    r195452 r195951  
    200200CSSParserSelector* CSSParserSelector::parsePseudoElementSelector(CSSParserString& pseudoTypeString)
    201201{
    202     pseudoTypeString.lower();
     202    pseudoTypeString.convertToASCIILowercaseInPlace();
    203203    AtomicString name = pseudoTypeString;
    204204
  • trunk/Source/WebCore/css/CSSParserValues.h

    r195743 r195951  
    3434class QualifiedName;
    3535
    36 // This can't be a StringView for 2 reasons:
    37 // 1. lower() clobbers the data we point to.
    38 // 2. We are an element of a union (in CSSParserValue) so we need to have a trivial destructor.
     36// This should be a StringView but currently it can't because it's used as an element of a union in CSSParserValue.
    3937struct CSSParserString {
    4038    void init(LChar* characters, unsigned length)
     
    7472    LChar* characters8() const { ASSERT(is8Bit()); return m_data.characters8; }
    7573    UChar* characters16() const { ASSERT(!is8Bit()); return m_data.characters16; }
    76     template <typename CharacterType>
    77     CharacterType* characters() const;
     74    template<typename CharacterType> CharacterType* characters() const;
    7875
    7976    unsigned length() const { return m_length; }
    8077    void setLength(unsigned length) { m_length = length; }
    8178
    82     void lower();
     79    void convertToASCIILowercaseInPlace();
    8380
    8481    UChar operator[](unsigned i) const
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r194496 r195951  
    806806bool CSSSelector::RareData::parseNth()
    807807{
    808     String argument = m_argument.lower();
    809 
    810     if (argument.isEmpty())
     808    if (m_argument.isEmpty())
    811809        return false;
    812810
    813     m_a = 0;
    814     m_b = 0;
    815     if (argument == "odd") {
     811    if (equalLettersIgnoringASCIICase(m_argument, "odd")) {
    816812        m_a = 2;
    817813        m_b = 1;
    818     } else if (argument == "even") {
     814    } else if (equalLettersIgnoringASCIICase(m_argument, "even")) {
    819815        m_a = 2;
    820816        m_b = 0;
    821817    } else {
    822         size_t n = argument.find('n');
     818        m_a = 0;
     819        m_b = 0;
     820
     821        size_t n = std::min(m_argument.find('n'), m_argument.find('N'));
    823822        if (n != notFound) {
    824             if (argument[0] == '-') {
     823            if (m_argument[0] == '-') {
    825824                if (n == 1)
    826825                    m_a = -1; // -n == -1n
    827826                else {
    828827                    bool ok;
    829                     m_a = argument.substringSharingImpl(0, n).toIntStrict(&ok);
     828                    m_a = StringView(m_argument).substring(0, n).toIntStrict(ok);
    830829                    if (!ok)
    831830                        return false;
     
    835834            else {
    836835                bool ok;
    837                 m_a = argument.substringSharingImpl(0, n).toIntStrict(&ok);
     836                m_a = StringView(m_argument).substring(0, n).toIntStrict(ok);
    838837                if (!ok)
    839838                    return false;
    840839            }
    841840
    842             size_t p = argument.find('+', n);
     841            size_t p = m_argument.find('+', n);
    843842            if (p != notFound) {
    844843                bool ok;
    845                 m_b = argument.substringSharingImpl(p + 1, argument.length() - p - 1).toIntStrict(&ok);
     844                m_b = StringView(m_argument).substring(p + 1).toIntStrict(ok);
    846845                if (!ok)
    847846                    return false;
    848847            } else {
    849                 p = argument.find('-', n);
     848                p = m_argument.find('-', n);
    850849                if (p != notFound) {
    851850                    bool ok;
    852                     m_b = -argument.substringSharingImpl(p + 1, argument.length() - p - 1).toIntStrict(&ok);
     851                    m_b = -StringView(m_argument).substring(p + 1).toIntStrict(ok);
    853852                    if (!ok)
    854853                        return false;
     
    857856        } else {
    858857            bool ok;
    859             m_b = argument.toIntStrict(&ok);
     858            m_b = m_argument.string().toIntStrict(&ok);
    860859            if (!ok)
    861860                return false;
  • trunk/Source/WebCore/css/MediaQuery.cpp

    r194496 r195951  
    7575MediaQuery::MediaQuery(Restrictor r, const String& mediaType, std::unique_ptr<ExpressionVector> exprs)
    7676    : m_restrictor(r)
    77     , m_mediaType(mediaType.lower())
     77    , m_mediaType(mediaType.convertToASCIILowercase())
    7878    , m_expressions(WTFMove(exprs))
    7979    , m_ignored(false)
  • trunk/Source/WebCore/css/MediaQueryExp.cpp

    r195148 r195951  
    233233    StringBuilder result;
    234234    result.append('(');
    235     result.append(m_mediaFeature.lower());
     235    result.append(m_mediaFeature.convertToASCIILowercase());
    236236    if (m_value) {
    237237        result.appendLiteral(": ");
  • trunk/Source/WebCore/dom/Document.cpp

    r195948 r195951  
    32793279}
    32803280
    3281 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't.
    3282 static bool isSeparator(UChar c)
    3283 {
    3284     return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0';
    3285 }
    3286 
    3287 void Document::processArguments(const String& features, void* data, ArgumentsCallback callback)
    3288 {
    3289     // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
    3290     unsigned keyBegin, keyEnd;
    3291     unsigned valueBegin, valueEnd;
    3292 
    3293     String buffer = features.lower();
    3294     unsigned length = buffer.length();
     3281static bool isSeparator(UChar character)
     3282{
     3283    return character == ' ' || character == '\t' || character == '\n' || character == '\r' || character == '=' || character == ',';
     3284}
     3285
     3286static void processArguments(StringView features, std::function<void(StringView type, StringView value)> callback)
     3287{
     3288    unsigned length = features.length();
    32953289    for (unsigned i = 0; i < length; ) {
    3296         // skip to first non-separator, but don't skip past the end of the string
    3297         while (isSeparator(buffer[i])) {
    3298             if (i >= length)
    3299                 break;
     3290        // skip to first non-separator
     3291        while (i < length && isSeparator(features[i]))
     3292            ++i;
     3293        unsigned keyBegin = i;
     3294
     3295        // skip to first separator
     3296        while (i < length && !isSeparator(features[i]))
    33003297            i++;
    3301         }
    3302         keyBegin = i;
     3298        unsigned keyEnd = i;
     3299
     3300        // skip to first '=', but don't skip past a ','
     3301        while (i < length && features[i] != '=' && features[i] != ',')
     3302            ++i;
     3303
     3304        // skip to first non-separator, but don't skip past a ','
     3305        while (i < length && isSeparator(features[i]) && features[i] != ',')
     3306            ++i;
     3307        unsigned valueBegin = i;
    33033308
    33043309        // skip to first separator
    3305         while (!isSeparator(buffer[i]))
    3306             i++;
    3307         keyEnd = i;
    3308 
    3309         // skip to first '=', but don't skip past a ',' or the end of the string
    3310         while (buffer[i] != '=') {
    3311             if (buffer[i] == ',' || i >= length)
    3312                 break;
    3313             i++;
    3314         }
    3315 
    3316         // skip to first non-separator, but don't skip past a ',' or the end of the string
    3317         while (isSeparator(buffer[i])) {
    3318             if (buffer[i] == ',' || i >= length)
    3319                 break;
    3320             i++;
    3321         }
    3322         valueBegin = i;
    3323 
    3324         // skip to first separator
    3325         while (!isSeparator(buffer[i]))
    3326             i++;
    3327         valueEnd = i;
    3328 
    3329         ASSERT_WITH_SECURITY_IMPLICATION(i <= length);
    3330 
    3331         String keyString = buffer.substring(keyBegin, keyEnd - keyBegin);
    3332         String valueString = buffer.substring(valueBegin, valueEnd - valueBegin);
    3333         callback(keyString, valueString, this, data);
     3310        while (i < length && !isSeparator(features[i]))
     3311            ++i;
     3312        unsigned valueEnd = i;
     3313
     3314        callback(features.substring(keyBegin, keyEnd - keyBegin), features.substring(valueBegin, valueEnd - valueBegin));
    33343315    }
    33353316}
     
    33433324
    33443325    m_viewportArguments = ViewportArguments(origin);
    3345     processArguments(features, (void*)&m_viewportArguments, setViewportFeature);
     3326
     3327    processArguments(features, [this](StringView key, StringView value) {
     3328        setViewportFeature(m_viewportArguments, *this, key, value);
     3329    });
    33463330
    33473331    updateViewportArguments();
     
    33633347#if PLATFORM(IOS)
    33643348
    3365 // FIXME: Find a better place for this functionality.
    3366 void setParserFeature(const String& key, const String& value, Document* document, void*)
    3367 {
    3368     if (key == "telephone" && equalLettersIgnoringASCIICase(value, "no"))
    3369         document->setIsTelephoneNumberParsingAllowed(false);
    3370 }
    3371 
    33723349void Document::processFormatDetection(const String& features)
    33733350{
    3374     ASSERT(!features.isNull());
    3375     processArguments(features, nullptr, setParserFeature);
     3351    // FIXME: Find a better place for this function.
     3352    processArguments(features, [this](StringView key, StringView value) {
     3353        if (equalLettersIgnoringASCIICase(key, "telephone") && equalLettersIgnoringASCIICase(value, "no"))
     3354            setIsTelephoneNumberParsingAllowed(false);
     3355    });
    33763356}
    33773357
  • trunk/Source/WebCore/dom/Document.h

    r195928 r195951  
    13451345    void detachParser();
    13461346
    1347     typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);
    1348     void processArguments(const String& features, void* data, ArgumentsCallback);
    1349 
    13501347    // FontSelectorClient
    13511348    virtual void fontsNeedUpdate(FontSelector&) override final;
  • trunk/Source/WebCore/dom/Element.cpp

    r195743 r195951  
    12021202{
    12031203    if (inQuirksMode)
    1204         return value.lower();
     1204        return value.convertToASCIILowercase();
    12051205    return value;
    12061206}
  • trunk/Source/WebCore/dom/ScriptElement.cpp

    r195928 r195951  
    150150    // - Allowing type=javascript. type= should only support MIME types, such as text/javascript.
    151151    // - Allowing a different set of languages for language= and type=. language= supports Javascript 1.1 and 1.4-1.6, but type= does not.
    152 
    153152    String type = typeAttributeValue();
    154153    String language = languageAttributeValue();
    155     if (type.isEmpty() && language.isEmpty())
    156         return true; // Assume text/javascript.
    157154    if (type.isEmpty()) {
    158         type = "text/" + language.lower();
    159         if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySupportedJavaScriptLanguage(language))
     155        if (language.isEmpty())
     156            return true; // Assume text/javascript.
     157        if (MIMETypeRegistry::isSupportedJavaScriptMIMEType("text/" + language))
    160158            return true;
    161     } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace().lower()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type)))
     159        if (isLegacySupportedJavaScriptLanguage(language))
     160            return true;
     161        return false;
     162    }
     163    if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSpace()))
     164        return true;
     165    if (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySupportedJavaScriptLanguage(type))
    162166        return true;
    163167    return false;
  • trunk/Source/WebCore/dom/ViewportArguments.cpp

    r195607 r195951  
    287287}
    288288
    289 static float numericPrefix(const String& keyString, const String& valueString, Document* document, bool* ok = nullptr)
     289static void reportViewportWarning(Document&, ViewportErrorCode, StringView replacement1 = { }, StringView replacement2 = { });
     290
     291static float numericPrefix(Document& document, StringView key, StringView value, bool* ok = nullptr)
    290292{
    291293    size_t parsedLength;
    292     float value;
    293     if (valueString.is8Bit())
    294         value = charactersToFloat(valueString.characters8(), valueString.length(), parsedLength);
     294    float numericValue;
     295    if (value.is8Bit())
     296        numericValue = charactersToFloat(value.characters8(), value.length(), parsedLength);
    295297    else
    296         value = charactersToFloat(valueString.characters16(), valueString.length(), parsedLength);
     298        numericValue = charactersToFloat(value.characters16(), value.length(), parsedLength);
    297299    if (!parsedLength) {
    298         reportViewportWarning(document, UnrecognizedViewportArgumentValueError, valueString, keyString);
     300        reportViewportWarning(document, UnrecognizedViewportArgumentValueError, value, key);
    299301        if (ok)
    300302            *ok = false;
    301303        return 0;
    302304    }
    303     if (parsedLength < valueString.length())
    304         reportViewportWarning(document, TruncatedViewportArgumentValueError, valueString, keyString);
     305    if (parsedLength < value.length())
     306        reportViewportWarning(document, TruncatedViewportArgumentValueError, value, key);
    305307    if (ok)
    306308        *ok = true;
    307     return value;
    308 }
    309 
    310 static float findSizeValue(const String& keyString, const String& valueString, Document* document, bool* valueWasExplicit = nullptr)
     309    return numericValue;
     310}
     311
     312static float findSizeValue(Document& document, StringView key, StringView value, bool* valueWasExplicit = nullptr)
    311313{
    312314    // 1) Non-negative number values are translated to px lengths.
     
    318320        *valueWasExplicit = true;
    319321
    320     if (equalLettersIgnoringASCIICase(valueString, "device-width"))
     322    if (equalLettersIgnoringASCIICase(value, "device-width"))
    321323        return ViewportArguments::ValueDeviceWidth;
    322324
    323     if (equalLettersIgnoringASCIICase(valueString, "device-height"))
     325    if (equalLettersIgnoringASCIICase(value, "device-height"))
    324326        return ViewportArguments::ValueDeviceHeight;
    325327
    326     float sizeValue = numericPrefix(keyString, valueString, document);
     328    float sizeValue = numericPrefix(document, key, value);
    327329
    328330    if (sizeValue < 0) {
     
    335337}
    336338
    337 static float findScaleValue(const String& keyString, const String& valueString, Document* document)
     339static float findScaleValue(Document& document, StringView key, StringView value)
    338340{
    339341    // 1) Non-negative number values are translated to <number> values.
     
    343345    // 5) no and unknown values are translated to 0.0
    344346
    345     if (equalLettersIgnoringASCIICase(valueString, "yes"))
     347    if (equalLettersIgnoringASCIICase(value, "yes"))
    346348        return 1;
    347     if (equalLettersIgnoringASCIICase(valueString, "no"))
     349    if (equalLettersIgnoringASCIICase(value, "no"))
    348350        return 0;
    349     if (equalLettersIgnoringASCIICase(valueString, "device-width"))
     351    if (equalLettersIgnoringASCIICase(value, "device-width"))
    350352        return 10;
    351     if (equalLettersIgnoringASCIICase(valueString, "device-height"))
     353    if (equalLettersIgnoringASCIICase(value, "device-height"))
    352354        return 10;
    353355
    354     float value = numericPrefix(keyString, valueString, document);
    355 
    356     if (value < 0)
     356    float numericValue = numericPrefix(document, key, value);
     357
     358    if (numericValue < 0)
    357359        return ViewportArguments::ValueAuto;
    358360
    359     if (value > 10.0)
    360         reportViewportWarning(document, MaximumScaleTooLargeError, String(), String());
    361 
    362     return value;
    363 }
    364 
    365 static float findBooleanValue(const String& keyString, const String& valueString, Document* document)
     361    if (numericValue > 10.0)
     362        reportViewportWarning(document, MaximumScaleTooLargeError);
     363
     364    return numericValue;
     365}
     366
     367// FIXME: It's kind of bizarre to use floating point values of 1 and 0 to represent true and false.
     368static float findBooleanValue(Document& document, StringView key, StringView value)
    366369{
    367370    // yes and no are used as keywords.
     
    369372    // Numbers in the range <-1, 1>, and unknown values, are mapped to no.
    370373
    371     if (equalLettersIgnoringASCIICase(valueString, "yes"))
     374    if (equalLettersIgnoringASCIICase(value, "yes"))
    372375        return 1;
    373     if (equalLettersIgnoringASCIICase(valueString, "no"))
     376    if (equalLettersIgnoringASCIICase(value, "no"))
    374377        return 0;
    375     if (equalLettersIgnoringASCIICase(valueString, "device-width"))
     378    if (equalLettersIgnoringASCIICase(value, "device-width"))
    376379        return 1;
    377     if (equalLettersIgnoringASCIICase(valueString, "device-height"))
     380    if (equalLettersIgnoringASCIICase(value, "device-height"))
    378381        return 1;
    379 
    380     float value = numericPrefix(keyString, valueString, document);
    381 
    382     if (fabs(value) < 1)
    383         return 0;
    384 
    385     return 1;
    386 }
    387 
    388 void setViewportFeature(const String& keyString, const String& valueString, Document* document, void* data)
    389 {
    390     ViewportArguments* arguments = static_cast<ViewportArguments*>(data);
    391 
    392     if (keyString == "width")
    393         arguments->width = findSizeValue(keyString, valueString, document, &arguments->widthWasExplicit);
    394     else if (keyString == "height")
    395         arguments->height = findSizeValue(keyString, valueString, document);
    396     else if (keyString == "initial-scale")
    397         arguments->zoom = findScaleValue(keyString, valueString, document);
    398     else if (keyString == "minimum-scale")
    399         arguments->minZoom = findScaleValue(keyString, valueString, document);
    400     else if (keyString == "maximum-scale")
    401         arguments->maxZoom = findScaleValue(keyString, valueString, document);
    402     else if (keyString == "user-scalable")
    403         arguments->userZoom = findBooleanValue(keyString, valueString, document);
     382    return std::abs(numericPrefix(document, key, value)) >= 1 ? 1 : 0;
     383}
     384
     385void setViewportFeature(ViewportArguments& arguments, Document& document, StringView key, StringView value)
     386{
     387    if (equalLettersIgnoringASCIICase(key, "width"))
     388        arguments.width = findSizeValue(document, key, value, &arguments.widthWasExplicit);
     389    else if (equalLettersIgnoringASCIICase(key, "height"))
     390        arguments.height = findSizeValue(document, key, value);
     391    else if (equalLettersIgnoringASCIICase(key, "initial-scale"))
     392        arguments.zoom = findScaleValue(document, key, value);
     393    else if (equalLettersIgnoringASCIICase(key, "minimum-scale"))
     394        arguments.minZoom = findScaleValue(document, key, value);
     395    else if (equalLettersIgnoringASCIICase(key, "maximum-scale"))
     396        arguments.maxZoom = findScaleValue(document, key, value);
     397    else if (equalLettersIgnoringASCIICase(key, "user-scalable"))
     398        arguments.userZoom = findBooleanValue(document, key, value);
    404399#if PLATFORM(IOS)
    405     else if (keyString == "minimal-ui")
    406         // FIXME: Ignore silently for now. This should eventually fall back to the warning.
    407         { }
     400    else if (equalLettersIgnoringASCIICase(key, "minimal-ui")) {
     401        // FIXME: Ignore silently for now. This code should eventually be removed
     402        // so we start giving the warning in the web inspector as for other unimplemented keys.
     403    }
    408404#endif
    409     else if (keyString == "shrink-to-fit")
    410         arguments->shrinkToFit = findBooleanValue(keyString, valueString, document);
     405    else if (equalLettersIgnoringASCIICase(key, "shrink-to-fit"))
     406        arguments.shrinkToFit = findBooleanValue(document, key, value);
    411407    else
    412         reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, keyString, String());
     408        reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, key);
    413409}
    414410
     
    440436}
    441437
    442 void reportViewportWarning(Document* document, ViewportErrorCode errorCode, const String& replacement1, const String& replacement2)
    443 {
    444     Frame* frame = document->frame();
    445     if (!frame)
     438void reportViewportWarning(Document& document, ViewportErrorCode errorCode, StringView replacement1, StringView replacement2)
     439{
     440    // FIXME: Why is this null check needed? Can't addConsoleMessage deal with this?
     441    if (!document.frame())
    446442        return;
    447443
    448444    String message = viewportErrorMessageTemplate(errorCode);
    449445    if (!replacement1.isNull())
    450         message.replace("%replacement1", replacement1);
     446        message.replace("%replacement1", replacement1.toStringWithoutCopying());
     447    // FIXME: This will do the wrong thing if replacement1 contains the substring "%replacement2".
    451448    if (!replacement2.isNull())
    452         message.replace("%replacement2", replacement2);
    453 
    454     if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == TruncatedViewportArgumentValueError) && replacement1.find(';') != WTF::notFound)
     449        message.replace("%replacement2", replacement2.toStringWithoutCopying());
     450
     451    if ((errorCode == UnrecognizedViewportArgumentValueError || errorCode == TruncatedViewportArgumentValueError) && replacement1.contains(';'))
    455452        message.append(" Note that ';' is not a separator in viewport values. The list should be comma-separated.");
    456453
    457454    // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
    458     document->addConsoleMessage(MessageSource::Rendering, viewportErrorMessageLevel(errorCode), message);
     455    document.addConsoleMessage(MessageSource::Rendering, viewportErrorMessageLevel(errorCode), message);
    459456}
    460457
  • trunk/Source/WebCore/dom/ViewportArguments.h

    r195607 r195951  
    135135float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& viewportSize, const IntSize& contentSize);
    136136
    137 void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data);
    138 void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2);
     137void setViewportFeature(ViewportArguments&, Document&, StringView key, StringView value);
    139138
    140139TextStream& operator<<(TextStream&, const ViewportArguments&);
  • trunk/Source/WebCore/editing/EditorCommand.cpp

    r195928 r195951  
    412412static bool executeFormatBlock(Frame& frame, Event*, EditorCommandSource, const String& value)
    413413{
    414     String tagName = value.lower();
     414    String tagName = value.convertToASCIILowercase();
    415415    if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>')
    416416        tagName = tagName.substring(1, tagName.length() - 2);
  • trunk/Source/WebCore/fileapi/Blob.cpp

    r195452 r195951  
    9797
    9898Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size)
    99     : m_type(Blob::normalizedContentType(type))
     99    : m_type(normalizedContentType(type))
    100100    , m_size(size)
    101101{
     
    105105
    106106Blob::Blob(const URL& srcURL, long long start, long long end, const String& type)
    107     : m_type(Blob::normalizedContentType(type))
     107    : m_type(normalizedContentType(type))
    108108    , m_size(-1) // size is not necessarily equal to end - start.
    109109{
     
    123123        // come up with an exception to throw if file size is not representable.
    124124        unsigned long long actualSize = ThreadableBlobRegistry::blobSize(m_internalURL);
    125         m_size = (WTF::isInBounds<long long>(actualSize)) ? static_cast<long long>(actualSize) : 0;
     125        m_size = WTF::isInBounds<long long>(actualSize) ? static_cast<long long>(actualSize) : 0;
    126126    }
    127127
     
    131131bool Blob::isValidContentType(const String& contentType)
    132132{
    133     if (contentType.isNull())
    134         return true;
    135 
    136     size_t length = contentType.length();
    137     if (contentType.is8Bit()) {
    138         const LChar* characters = contentType.characters8();
    139         for (size_t i = 0; i < length; ++i) {
    140             if (characters[i] < 0x20 || characters[i] > 0x7e)
    141                 return false;
    142         }
    143     } else {
    144         const UChar* characters = contentType.characters16();
    145         for (size_t i = 0; i < length; ++i) {
    146             if (characters[i] < 0x20 || characters[i] > 0x7e)
    147                 return false;
    148         }
     133    // FIXME: Do we really want to treat the empty string and null string as valid content types?
     134    unsigned length = contentType.length();
     135    for (unsigned i = 0; i < length; ++i) {
     136        if (contentType[i] < 0x20 || contentType[i] > 0x7e)
     137            return false;
    149138    }
    150139    return true;
     
    153142String Blob::normalizedContentType(const String& contentType)
    154143{
    155     if (Blob::isValidContentType(contentType))
    156         return contentType.lower();
    157     return emptyString();
     144    if (!isValidContentType(contentType))
     145        return emptyString();
     146    return contentType.convertToASCIILowercase();
    158147}
    159148
    160149bool Blob::isNormalizedContentType(const String& contentType)
    161150{
    162     if (contentType.isNull())
    163         return true;
    164 
    165     size_t length = contentType.length();
    166     if (contentType.is8Bit()) {
    167         const LChar* characters = contentType.characters8();
    168         for (size_t i = 0; i < length; ++i) {
    169             if (characters[i] < 0x20 || characters[i] > 0x7e)
    170                 return false;
    171             if (isASCIIUpper(characters[i]))
    172                 return false;
    173         }
    174     } else {
    175         const UChar* characters = contentType.characters16();
    176         for (size_t i = 0; i < length; ++i) {
    177             if (characters[i] < 0x20 || characters[i] > 0x7e)
    178                 return false;
    179             if (isASCIIUpper(characters[i]))
    180                 return false;
    181         }
     151    // FIXME: Do we really want to treat the empty string and null string as valid content types?
     152    unsigned length = contentType.length();
     153    for (size_t i = 0; i < length; ++i) {
     154        if (contentType[i] < 0x20 || contentType[i] > 0x7e)
     155            return false;
     156        if (isASCIIUpper(contentType[i]))
     157            return false;
    182158    }
    183159    return true;
     
    186162bool Blob::isNormalizedContentType(const CString& contentType)
    187163{
     164    // FIXME: Do we really want to treat the empty string and null string as valid content types?
    188165    size_t length = contentType.length();
    189166    const char* characters = contentType.data();
  • trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp

    r169573 r195951  
    2727
    2828#include "Decimal.h"
     29#include "QualifiedName.h"
    2930#include "URL.h"
    3031#include <limits>
    3132#include <wtf/MathExtras.h>
    32 #include <wtf/text/AtomicString.h>
    3333#include <wtf/text/StringBuilder.h>
    3434
  • trunk/Source/WebCore/html/parser/HTMLParserIdioms.h

    r177952 r195951  
    2626#define HTMLParserIdioms_h
    2727
    28 #include "QualifiedName.h"
     28#include <unicode/uchar.h>
    2929#include <wtf/Forward.h>
    30 #include <wtf/text/WTFString.h>
    3130
    3231namespace WebCore {
    3332
    3433class Decimal;
     34class QualifiedName;
    3535
    3636// Space characters as defined by the HTML specification.
     37template<typename CharacterType> bool isHTMLSpace(CharacterType);
     38template<typename CharacterType> bool isComma(CharacterType);
     39template<typename CharacterType> bool isHTMLSpaceOrComma(CharacterType);
    3740bool isHTMLLineBreak(UChar);
    3841bool isNotHTMLSpace(UChar);
    39 bool isHTMLSpaceButNotLineBreak(UChar character);
     42bool isHTMLSpaceButNotLineBreak(UChar);
    4043
    4144// Strip leading and trailing whitespace as defined by the HTML specification.
     
    6063bool parseHTMLNonNegativeInteger(const String&, unsigned int&);
    6164
     65bool threadSafeMatch(const QualifiedName&, const QualifiedName&);
     66
    6267// Inline implementations of some of the functions declared above.
    63 template<typename CharType>
    64 inline bool isHTMLSpace(CharType character)
     68
     69template<typename CharacterType> inline bool isHTMLSpace(CharacterType character)
    6570{
    6671    // Histogram from Apple's page load test combined with some ad hoc browsing some other test suites.
     
    8287}
    8388
    84 template<typename CharType>
    85 inline bool isComma(CharType character)
     89template<typename CharacterType> inline bool isComma(CharacterType character)
    8690{
    8791    return character == ',';
    8892}
    8993
    90 template<typename CharType>
    91 inline bool isHTMLSpaceOrComma(CharType character)
     94template<typename CharacterType> inline bool isHTMLSpaceOrComma(CharacterType character)
    9295{
    93     return isComma(character) || isHTMLSpace<CharType>(character);
     96    return isComma(character) || isHTMLSpace(character);
    9497}
    9598
     
    104107}
    105108
    106 bool threadSafeMatch(const QualifiedName&, const QualifiedName&);
    107 
    108109}
    109110
  • trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp

    r195928 r195951  
    9292void ArchiveFactory::registerKnownArchiveMIMETypes()
    9393{
    94     HashSet<String>& mimeTypes = MIMETypeRegistry::getSupportedNonImageMIMETypes();
    95    
    96     for (const auto& mimeType : archiveMIMETypes().keys())
     94    auto& mimeTypes = MIMETypeRegistry::getSupportedNonImageMIMETypes();
     95    for (auto& mimeType : archiveMIMETypes().keys())
    9796        mimeTypes.add(mimeType);
    9897}
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r195928 r195951  
    141141};
    142142
    143 static HashSet<String>* supportedImageResourceMIMETypes;
    144 static HashSet<String>* supportedImageMIMETypes;
    145 static HashSet<String>* supportedImageMIMETypesForEncoding;
    146 static HashSet<String>* supportedJavaScriptMIMETypes;
    147 static HashSet<String>* supportedNonImageMIMETypes;
    148 static HashSet<String>* supportedMediaMIMETypes;
    149 static HashSet<String>* pdfMIMETypes;
    150 static HashSet<String>* pdfAndPostScriptMIMETypes;
    151 static HashSet<String>* unsupportedTextMIMETypes;
     143static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageResourceMIMETypes;
     144static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypes;
     145static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypesForEncoding;
     146static HashSet<String, ASCIICaseInsensitiveHash>* supportedJavaScriptMIMETypes;
     147static HashSet<String, ASCIICaseInsensitiveHash>* supportedNonImageMIMETypes;
     148static HashSet<String, ASCIICaseInsensitiveHash>* supportedMediaMIMETypes;
     149static HashSet<String, ASCIICaseInsensitiveHash>* pdfMIMETypes;
     150static HashSet<String, ASCIICaseInsensitiveHash>* pdfAndPostScriptMIMETypes;
     151static HashSet<String, ASCIICaseInsensitiveHash>* unsupportedTextMIMETypes;
    152152
    153153typedef HashMap<String, Vector<String>*, ASCIICaseInsensitiveHash> MediaMIMETypeMap;
     
    211211        "application/bmp", "application/x-bmp", "application/x-win-bitmap",
    212212    };
    213     for (size_t i = 0; i < WTF_ARRAY_LENGTH(malformedMIMETypes); ++i) {
    214         supportedImageMIMETypes->add(malformedMIMETypes[i]);
    215         supportedImageResourceMIMETypes->add(malformedMIMETypes[i]);
     213    for (auto& type : malformedMIMETypes) {
     214        supportedImageMIMETypes->add(type);
     215        supportedImageResourceMIMETypes->add(type);
    216216    }
    217217#endif
     
    229229        "image/x-xbitmap"  // xbm
    230230    };
    231     for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
    232         supportedImageMIMETypes->add(types[i]);
    233         supportedImageResourceMIMETypes->add(types[i]);
     231    for (auto& type : types) {
     232        supportedImageMIMETypes->add(type);
     233        supportedImageResourceMIMETypes->add(type);
    234234    }
    235235
     
    244244static void initializeSupportedImageMIMETypesForEncoding()
    245245{
    246     supportedImageMIMETypesForEncoding = new HashSet<String>;
     246    supportedImageMIMETypesForEncoding = new HashSet<String, ASCIICaseInsensitiveHash>;
    247247
    248248#if USE(CG)
     
    308308        "text/pdf"
    309309    };
    310     for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i)
    311         pdfMIMETypes->add(types[i]);
     310    for (auto& type : types)
     311        pdfMIMETypes->add(type);
    312312}
    313313
     
    338338#endif
    339339        "multipart/x-mixed-replace"
    340         // Note: ADDING a new type here will probably render it as HTML. This can
    341         // result in cross-site scripting.
     340        // Note: Adding a new type here will probably render it as HTML.
     341        // This can result in cross-site scripting vulnerabilities.
    342342    };
    343     COMPILE_ASSERT(sizeof(types) / sizeof(types[0]) <= 16,
    344                    nonimage_mime_types_must_be_less_than_or_equal_to_16);
    345 
    346     for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i)
    347         supportedNonImageMIMETypes->add(types[i]);
     343
     344    for (auto& type : types)
     345        supportedNonImageMIMETypes->add(type);
    348346
    349347#if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)
     
    415413static void initializeSupportedMediaMIMETypes()
    416414{
    417     supportedMediaMIMETypes = new HashSet<String>;
     415    supportedMediaMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
    418416#if ENABLE(VIDEO)
    419417    MediaPlayer::getSupportedTypes(*supportedMediaMIMETypes);
     
    442440#endif
    443441    };
    444     for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i)
    445       unsupportedTextMIMETypes->add(types[i]);
     442    for (auto& type : types)
     443        unsupportedTextMIMETypes->add(type);
    446444}
    447445
    448446static void initializeMIMETypeRegistry()
    449447{
    450     supportedJavaScriptMIMETypes = new HashSet<String>;
     448    supportedJavaScriptMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
    451449    initializeSupportedJavaScriptMIMETypes();
    452450
    453     supportedNonImageMIMETypes = new HashSet<String>(*supportedJavaScriptMIMETypes);
     451    supportedNonImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>(*supportedJavaScriptMIMETypes);
    454452    initializeSupportedNonImageMimeTypes();
    455453
    456     supportedImageResourceMIMETypes = new HashSet<String>;
    457     supportedImageMIMETypes = new HashSet<String>;
     454    supportedImageResourceMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
     455    supportedImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
    458456    initializeSupportedImageMIMETypes();
    459457
    460     pdfMIMETypes = new HashSet<String>;
     458    pdfMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
    461459    initializePDFMIMETypes();
    462460
    463     pdfAndPostScriptMIMETypes = new HashSet<String>(*pdfMIMETypes);
     461    pdfAndPostScriptMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>(*pdfMIMETypes);
    464462    initializePostScriptMIMETypes();
    465463
    466     unsupportedTextMIMETypes = new HashSet<String>;
     464    unsupportedTextMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>;
    467465    initializeUnsupportedTextMIMETypes();
    468466}
     
    585583}
    586584
    587 HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypes()
     585HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypes()
    588586{
    589587    if (!supportedImageMIMETypes)
     
    592590}
    593591
    594 HashSet<String>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
     592HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
    595593{
    596594    if (!supportedImageResourceMIMETypes)
     
    599597}
    600598
    601 HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding()
     599HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding()
    602600{
    603601    if (!supportedImageMIMETypesForEncoding)
     
    606604}
    607605
    608 HashSet<String>& MIMETypeRegistry::getSupportedNonImageMIMETypes()
     606HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedNonImageMIMETypes()
    609607{
    610608    if (!supportedNonImageMIMETypes)
     
    613611}
    614612
    615 HashSet<String>& MIMETypeRegistry::getSupportedMediaMIMETypes()
     613HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedMediaMIMETypes()
    616614{
    617615    if (!supportedMediaMIMETypes)
     
    621619
    622620
    623 HashSet<String>& MIMETypeRegistry::getPDFMIMETypes()
     621HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFMIMETypes()
    624622{
    625623    if (!pdfMIMETypes)
     
    628626}
    629627
    630 HashSet<String>& MIMETypeRegistry::getPDFAndPostScriptMIMETypes()
     628HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFAndPostScriptMIMETypes()
    631629{
    632630    if (!pdfAndPostScriptMIMETypes)
     
    635633}
    636634
    637 HashSet<String>& MIMETypeRegistry::getUnsupportedTextMIMETypes()
     635HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getUnsupportedTextMIMETypes()
    638636{
    639637    if (!unsupportedTextMIMETypes)
     
    649647
    650648#if !USE(CURL)
     649
     650// FIXME: Not sure why it makes sense to have a cross-platform function when only CURL has the concept
     651// of a "normalized" MIME type.
    651652String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeType)
    652653{
    653654    return mimeType;
    654655}
    655 #endif
    656 
    657 #if USE(CURL)
    658 typedef HashMap<String, String> MIMETypeAssociationMap;
     656
     657#else
     658
     659typedef HashMap<String, String, ASCIICaseInsensitiveHash> MIMETypeAssociationMap;
    659660
    660661static const MIMETypeAssociationMap& mimeTypeAssociationMap()
     
    664665        return *mimeTypeMap;
    665666
     667    // FIXME: Should not allocate this on the heap; use NeverDestroyed instead.
    666668    mimeTypeMap = new MIMETypeAssociationMap;
    667669
     670    // FIXME: Writing the function out like this will create a giant function.
     671    // Should use a loop instead.
    668672    mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp"));
    669673    mimeTypeMap->add(ASCIILiteral("image/x-windows-bmp"), ASCIILiteral("image/bmp"));
     
    717721String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeType)
    718722{
    719     MIMETypeAssociationMap::const_iterator it = mimeTypeAssociationMap().find(mimeType);
    720 
     723    auto it = mimeTypeAssociationMap().find(mimeType);
    721724    if (it != mimeTypeAssociationMap().end())
    722725        return it->value;
    723 
    724726    return mimeType;
    725727}
     728
    726729#endif
    727730
  • trunk/Source/WebCore/platform/MIMETypeRegistry.h

    r184843 r195951  
    3838    WEBCORE_EXPORT static String getMIMETypeForExtension(const String& extension);
    3939
     40    // FIXME: WebKit coding style says we should not have the word "get" in the names of these functions.
    4041    static Vector<String> getExtensionsForMIMEType(const String& type);
    4142    WEBCORE_EXPORT static String getPreferredExtensionForMIMEType(const String& type);
     
    4546    static String getMIMETypeForPath(const String& path);
    4647
    47     // Check to see if a mime type is suitable for being loaded inline as an
     48    // Check to see if a MIME type is suitable for being loaded inline as an
    4849    // image (e.g., <img> tags).
    4950    WEBCORE_EXPORT static bool isSupportedImageMIMEType(const String& mimeType);
    5051
    51     // Check to see if a mime type is suitable for being loaded as an image
     52    // Check to see if a MIME type is suitable for being loaded as an image
    5253    // document in a frame.
    5354    WEBCORE_EXPORT static bool isSupportedImageResourceMIMEType(const String& mimeType);
    5455
    55     // Check to see if a mime type is suitable for being encoded.
     56    // Check to see if a MIME type is suitable for being encoded.
    5657    static bool isSupportedImageMIMETypeForEncoding(const String& mimeType);
    5758
    58     // Check to see if a mime type is suitable for being loaded as a JavaScript
    59     // resource.
     59    // Check to see if a MIME type is suitable for being loaded as a JavaScript resource.
    6060    static bool isSupportedJavaScriptMIMEType(const String& mimeType);   
    6161
    62     // Check to see if a non-image mime type is suitable for being loaded as a
     62    // Check to see if a non-image MIME type is suitable for being loaded as a
    6363    // document in a frame.  Includes supported JavaScript MIME types.
    6464    WEBCORE_EXPORT static bool isSupportedNonImageMIMEType(const String& mimeType);
    6565
    66     // Check to see if a mime type is suitable for being loaded using <video> and <audio>
     66    // Check to see if a MIME type is suitable for being loaded using <video> and <audio>.
    6767    WEBCORE_EXPORT static bool isSupportedMediaMIMEType(const String& mimeType);
    6868
    69     // Check to see if the mime type is not suitable for being loaded as a text
    70     // document in a frame. Only valid for mime types begining with "text/".
     69    // Check to see if the MIME type is not suitable for being loaded as a text
     70    // document in a frame. Only valid for MIME types begining with "text/".
    7171    static bool isUnsupportedTextMIMEType(const String& mimeType);
    7272
    73     // Check to see if a mime type is a valid Java applet mime type
     73    // Check to see if a MIME type is a valid Java applet mime type.
    7474    WEBCORE_EXPORT static bool isJavaAppletMIMEType(const String& mimeType);
    7575
    76     // Check to see if a mime type is a plugin implemented by the
    77     // browser (e.g. a Qt Plugin).
     76    // Check to see if a MIME type is a plugin implemented by the browser.
    7877    static bool isApplicationPluginMIMEType(const String& mimeType);
    7978
    80     // Check to see if a mime type is one of the common PDF/PS types.
     79    // Check to see if a MIME type is one of the common PDF/PS types.
    8180    WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType);
    8281    static bool isPDFMIMEType(const String& mimeType);
    8382
    84     // Check to see if a mime type is suitable for being shown inside a page.
    85     // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), isSupportedMediaMIMEType() returns true
    86     // or if given mime type begins with "text/" and isUnsupportedTextMIMEType() returns false.
     83    // Check to see if a MIME type is suitable for being shown inside a page.
     84    // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), or
     85    // isSupportedMediaMIMEType() returns true or if the given MIME type begins with
     86    // "text/" and isUnsupportedTextMIMEType() returns false.
    8787    WEBCORE_EXPORT static bool canShowMIMEType(const String& mimeType);
    8888
    89     WEBCORE_EXPORT static HashSet<String>& getSupportedImageMIMETypes();
    90     static HashSet<String>& getSupportedImageResourceMIMETypes();
    91     static HashSet<String>& getSupportedImageMIMETypesForEncoding();
    92     WEBCORE_EXPORT static HashSet<String>& getSupportedNonImageMIMETypes();
    93     WEBCORE_EXPORT static HashSet<String>& getSupportedMediaMIMETypes();
    94     WEBCORE_EXPORT static HashSet<String>& getPDFMIMETypes();
    95     static HashSet<String>& getPDFAndPostScriptMIMETypes();
    96     WEBCORE_EXPORT static HashSet<String>& getUnsupportedTextMIMETypes();
     89    // FIXME: WebKit coding style says we should not have the word "get" in the names of these functions.
     90    // FIXME: Would be nice to find a way to avoid exposing these sets, even worse exposing non-const references.
     91    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypes();
     92    static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageResourceMIMETypes();
     93    static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedImageMIMETypesForEncoding();
     94    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedNonImageMIMETypes();
     95    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getSupportedMediaMIMETypes();
     96    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getPDFMIMETypes();
     97    static HashSet<String, ASCIICaseInsensitiveHash>& getPDFAndPostScriptMIMETypes();
     98    WEBCORE_EXPORT static HashSet<String, ASCIICaseInsensitiveHash>& getUnsupportedTextMIMETypes();
    9799
     100    // FIXME: WebKit coding style says we should not have the word "get" in the name of this function.
     101    // FIXME: Unclear what the concept of a normalized MIME type is; currently it's a platform-specific notion.
    98102    static String getNormalizedMIMEType(const String&);
    99103};
  • trunk/Source/WebCore/platform/SchemeRegistry.cpp

    r194880 r195951  
    9797}
    9898
    99 static HashSet<String>& schemesForbiddenFromDomainRelaxation()
    100 {
    101     static NeverDestroyed<HashSet<String>> schemes;
     99static HashSet<String, ASCIICaseInsensitiveHash>& schemesForbiddenFromDomainRelaxation()
     100{
     101    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> schemes;
    102102    return schemes;
    103103}
  • trunk/Source/WebCore/platform/URL.cpp

    r195928 r195951  
    21222122{
    21232123    ASSERT(protocolIs(url, "data"));
    2124     size_t index = url.find(';');
     2124
     2125    // FIXME: What's the right behavior when the URL has a comma first, but a semicolon later?
     2126    // Currently this code will break at the semicolon in that case. Not sure that's correct.
     2127    auto index = url.find(';', 5);
    21252128    if (index == notFound)
    2126         index = url.find(',');
    2127     if (index != notFound) {
    2128         if (index > 5)
    2129             return url.substring(5, index - 5).lower();
    2130         return "text/plain"; // Data URLs with no MIME type are considered text/plain.
    2131     }
    2132     return "";
     2129        index = url.find(',', 5);
     2130    if (index == notFound) {
     2131        // FIXME: There was an old comment here that made it sound like this should be returning text/plain.
     2132        // But we have been returning empty string here for some time, so not changing its behavior at this time.
     2133        return emptyString();
     2134    }
     2135    ASSERT(index >= 5);
     2136    return url.substring(5, index - 5).convertToASCIILowercase();
    21332137}
    21342138
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r195743 r195951  
    866866}
    867867
    868 void MediaPlayer::getSupportedTypes(HashSet<String>& types)
     868void MediaPlayer::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
    869869{
    870870    for (auto& engine : installedMediaEngines()) {
    871         HashSet<String> engineTypes;
     871        HashSet<String, ASCIICaseInsensitiveHash> engineTypes;
    872872        engine.getSupportedTypes(engineTypes);
    873873        types.add(engineTypes.begin(), engineTypes.end());
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r195412 r195951  
    295295    enum SupportsType { IsNotSupported, IsSupported, MayBeSupported };
    296296    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&, const MediaPlayerSupportsTypeClient*);
    297     static void getSupportedTypes(HashSet<String>&);
     297    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
    298298    static bool isAvailable();
    299299    static void getSitesInMediaCache(Vector<String>&);
     
    632632
    633633typedef std::function<std::unique_ptr<MediaPlayerPrivateInterface> (MediaPlayer*)> CreateMediaEnginePlayer;
    634 typedef void (*MediaEngineSupportedTypes)(HashSet<String>& types);
     634typedef void (*MediaEngineSupportedTypes)(HashSet<String, ASCIICaseInsensitiveHash>& types);
    635635typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const MediaEngineSupportParameters& parameters);
    636636typedef void (*MediaEngineGetSitesInMediaCache)(Vector<String>&);
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r188702 r195951  
    11121112}
    11131113
    1114 const HashSet<String>& MediaPlayerPrivateAVFoundation::staticMIMETypeList()
    1115 {
    1116     static NeverDestroyed<HashSet<String>> cache = []() {
    1117         HashSet<String> types;
    1118 
    1119         static const char* typeNames[] = {
     1114const HashSet<String, ASCIICaseInsensitiveHash>& MediaPlayerPrivateAVFoundation::staticMIMETypeList()
     1115{
     1116    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() {
     1117        HashSet<String, ASCIICaseInsensitiveHash> types;
     1118
     1119        static const char* const typeNames[] = {
    11201120            "application/vnd.apple.mpegurl",
    11211121            "application/x-mpegurl",
     
    11491149            "video/x-mpg",
    11501150        };
    1151         for (size_t i = 0; i < WTF_ARRAY_LENGTH(typeNames); ++i)
    1152             types.add(typeNames[i]);
     1151        for (auto& type : typeNames)
     1152            types.add(type);
    11531153
    11541154        return types;
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r189144 r195951  
    260260
    261261    static bool isUnsupportedMIMEType(const String&);
    262     static const HashSet<String>& staticMIMETypeList();
     262    static const HashSet<String, ASCIICaseInsensitiveHash>& staticMIMETypeList();
    263263
    264264protected:
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r195743 r195951  
    883883#endif
    884884
    885 static const HashSet<String>& avfMIMETypes()
    886 {
    887     static NeverDestroyed<HashSet<String>> cache = []() {
    888         HashSet<String> types;
     885static const HashSet<String, ASCIICaseInsensitiveHash>& avfMIMETypes()
     886{
     887    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() {
     888        HashSet<String, ASCIICaseInsensitiveHash> types;
    889889        RetainPtr<CFArrayRef> avTypes = adoptCF(AVCFURLAssetCopyAudiovisualMIMETypes());
    890 
    891890        CFIndex typeCount = CFArrayGetCount(avTypes.get());
    892         for (CFIndex i = 0; i < typeCount; ++i) {
    893             String mimeType = (CFStringRef)(CFArrayGetValueAtIndex(avTypes.get(), i));
    894             types.add(mimeType.lower());
    895         }
    896 
     891        for (CFIndex i = 0; i < typeCount; ++i)
     892            types.add((CFStringRef)CFArrayGetValueAtIndex(avTypes.get(), i));
    897893        return types;
    898894    }();
     
    901897}
    902898
    903 void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String>& supportedTypes)
     899void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes)
    904900{
    905901    supportedTypes = avfMIMETypes();
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h

    r193482 r195951  
    6161
    6262private:
    63     static void getSupportedTypes(HashSet<String>& types);
     63    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    6464    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    6565    static bool supportsKeySystem(const String& keySystem, const String& mimeType);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r195595 r195951  
    146146private:
    147147    // engine support
    148     static void getSupportedTypes(HashSet<String>& types);
     148    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    149149    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    150150    static bool supportsKeySystem(const String& keySystem, const String& mimeType);
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r195595 r195951  
    15061506        IntRect paintRect(IntPoint(0, 0), IntSize(rect.width(), rect.height()));
    15071507        CGContextDrawImage(context.platformContext(), CGRectMake(0, 0, paintRect.width(), paintRect.height()), image.get());
    1508         image = 0;
    1509     }
    1510 }
    1511 
    1512 static const HashSet<String>& avfMIMETypes()
    1513 {
    1514     static NeverDestroyed<HashSet<String>> cache = [] () {
    1515         HashSet<String> types;
    1516 
    1517         NSArray *nsTypes = [AVURLAsset audiovisualMIMETypes];
    1518         for (NSString *mimeType in nsTypes)
    1519             types.add([mimeType lowercaseString]);
    1520 
     1508    }
     1509}
     1510
     1511static const HashSet<String, ASCIICaseInsensitiveHash>& avfMIMETypes()
     1512{
     1513    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() {
     1514        HashSet<String, ASCIICaseInsensitiveHash> types;
     1515        for (NSString *type in [AVURLAsset audiovisualMIMETypes])
     1516            types.add(type);
    15211517        return types;
    15221518    }();
    1523 
    15241519   
    15251520    return cache;
     
    15481543}
    15491544
    1550 void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String>& supportedTypes)
     1545void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes)
    15511546{
    15521547    supportedTypes = avfMIMETypes();
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r195692 r195951  
    6262    // MediaPlayer Factory Methods
    6363    static bool isAvailable();
    64     static void getSupportedTypes(HashSet<String>& types);
     64    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    6565    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    6666
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r195692 r195951  
    219219}
    220220
    221 static const HashSet<String>& mimeTypeCache()
    222 {
    223     static NeverDestroyed<HashSet<String>> cache;
     221static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
     222{
     223    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
    224224    static bool typeListInitialized = false;
    225225
     
    235235}
    236236
    237 void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String>& types)
     237void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
    238238{
    239239    types = mimeTypeCache();
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h

    r192503 r195951  
    5656    // MediaPlayer Factory Methods
    5757    static bool isAvailable();
    58     static void getSupportedTypes(HashSet<String>& types);
     58    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    5959    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    6060
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm

    r192503 r195951  
    8484}
    8585
    86 void MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes(HashSet<String>& types)
    87 {
    88     static NeverDestroyed<HashSet<String>> cache;
     86void MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
     87{
     88    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
    8989    types = cache;
    9090}
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r195234 r195951  
    4242#include <wtf/HexNumber.h>
    4343#include <wtf/MediaTime.h>
     44#include <wtf/NeverDestroyed.h>
    4445#include <wtf/glib/GUniquePtr.h>
    4546#include <wtf/text/CString.h>
     
    16601661}
    16611662
    1662 static HashSet<String> mimeTypeCache()
    1663 {
    1664     initializeGStreamerAndRegisterWebKitElements();
    1665 
    1666     DEPRECATED_DEFINE_STATIC_LOCAL(HashSet<String>, cache, ());
    1667     static bool typeListInitialized = false;
    1668 
    1669     if (typeListInitialized)
    1670         return cache;
    1671 
    1672     const char* mimeTypes[] = {
    1673         "application/ogg",
    1674         "application/vnd.apple.mpegurl",
    1675         "application/vnd.rn-realmedia",
    1676         "application/x-3gp",
    1677         "application/x-pn-realaudio",
    1678         "application/x-mpegurl",
    1679         "audio/3gpp",
    1680         "audio/aac",
    1681         "audio/flac",
    1682         "audio/iLBC-sh",
    1683         "audio/midi",
    1684         "audio/mobile-xmf",
    1685         "audio/mp1",
    1686         "audio/mp2",
    1687         "audio/mp3",
    1688         "audio/mp4",
    1689         "audio/mpeg",
    1690         "audio/ogg",
    1691         "audio/opus",
    1692         "audio/qcelp",
    1693         "audio/riff-midi",
    1694         "audio/speex",
    1695         "audio/wav",
    1696         "audio/webm",
    1697         "audio/x-ac3",
    1698         "audio/x-aiff",
    1699         "audio/x-amr-nb-sh",
    1700         "audio/x-amr-wb-sh",
    1701         "audio/x-au",
    1702         "audio/x-ay",
    1703         "audio/x-celt",
    1704         "audio/x-dts",
    1705         "audio/x-flac",
    1706         "audio/x-gbs",
    1707         "audio/x-gsm",
    1708         "audio/x-gym",
    1709         "audio/x-imelody",
    1710         "audio/x-ircam",
    1711         "audio/x-kss",
    1712         "audio/x-m4a",
    1713         "audio/x-mod",
    1714         "audio/x-mp3",
    1715         "audio/x-mpeg",
    1716         "audio/x-musepack",
    1717         "audio/x-nist",
    1718         "audio/x-nsf",
    1719         "audio/x-paris",
    1720         "audio/x-sap",
    1721         "audio/x-sbc",
    1722         "audio/x-sds",
    1723         "audio/x-shorten",
    1724         "audio/x-sid",
    1725         "audio/x-spc",
    1726         "audio/x-speex",
    1727         "audio/x-svx",
    1728         "audio/x-ttafile",
    1729         "audio/x-vgm",
    1730         "audio/x-voc",
    1731         "audio/x-vorbis+ogg",
    1732         "audio/x-w64",
    1733         "audio/x-wav",
    1734         "audio/x-wavpack",
    1735         "audio/x-wavpack-correction",
    1736         "video/3gpp",
    1737         "video/flv",
    1738         "video/mj2",
    1739         "video/mp2t",
    1740         "video/mp4",
    1741         "video/mpeg",
    1742         "video/mpegts",
    1743         "video/ogg",
    1744         "video/quicktime",
    1745         "video/vivo",
    1746         "video/webm",
    1747         "video/x-cdxa",
    1748         "video/x-dirac",
    1749         "video/x-dv",
    1750         "video/x-fli",
    1751         "video/x-flv",
    1752         "video/x-h263",
    1753         "video/x-ivf",
    1754         "video/x-m4v",
    1755         "video/x-matroska",
    1756         "video/x-mng",
    1757         "video/x-ms-asf",
    1758         "video/x-msvideo",
    1759         "video/x-mve",
    1760         "video/x-nuv",
    1761         "video/x-vcd"
    1762     };
    1763 
    1764     for (unsigned i = 0; i < (sizeof(mimeTypes) / sizeof(*mimeTypes)); ++i)
    1765         cache.add(String(mimeTypes[i]));
    1766 
    1767     typeListInitialized = true;
     1663// FIXME: In what sense is this a "cache"?
     1664static HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
     1665{
     1666    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() {
     1667        initializeGStreamerAndRegisterWebKitElements();
     1668        HashSet<String, ASCIICaseInsensitiveHash> set;
     1669        const char* mimeTypes[] = {
     1670            "application/ogg",
     1671            "application/vnd.apple.mpegurl",
     1672            "application/vnd.rn-realmedia",
     1673            "application/x-3gp",
     1674            "application/x-pn-realaudio",
     1675            "application/x-mpegurl",
     1676            "audio/3gpp",
     1677            "audio/aac",
     1678            "audio/flac",
     1679            "audio/iLBC-sh",
     1680            "audio/midi",
     1681            "audio/mobile-xmf",
     1682            "audio/mp1",
     1683            "audio/mp2",
     1684            "audio/mp3",
     1685            "audio/mp4",
     1686            "audio/mpeg",
     1687            "audio/ogg",
     1688            "audio/opus",
     1689            "audio/qcelp",
     1690            "audio/riff-midi",
     1691            "audio/speex",
     1692            "audio/wav",
     1693            "audio/webm",
     1694            "audio/x-ac3",
     1695            "audio/x-aiff",
     1696            "audio/x-amr-nb-sh",
     1697            "audio/x-amr-wb-sh",
     1698            "audio/x-au",
     1699            "audio/x-ay",
     1700            "audio/x-celt",
     1701            "audio/x-dts",
     1702            "audio/x-flac",
     1703            "audio/x-gbs",
     1704            "audio/x-gsm",
     1705            "audio/x-gym",
     1706            "audio/x-imelody",
     1707            "audio/x-ircam",
     1708            "audio/x-kss",
     1709            "audio/x-m4a",
     1710            "audio/x-mod",
     1711            "audio/x-mp3",
     1712            "audio/x-mpeg",
     1713            "audio/x-musepack",
     1714            "audio/x-nist",
     1715            "audio/x-nsf",
     1716            "audio/x-paris",
     1717            "audio/x-sap",
     1718            "audio/x-sbc",
     1719            "audio/x-sds",
     1720            "audio/x-shorten",
     1721            "audio/x-sid",
     1722            "audio/x-spc",
     1723            "audio/x-speex",
     1724            "audio/x-svx",
     1725            "audio/x-ttafile",
     1726            "audio/x-vgm",
     1727            "audio/x-voc",
     1728            "audio/x-vorbis+ogg",
     1729            "audio/x-w64",
     1730            "audio/x-wav",
     1731            "audio/x-wavpack",
     1732            "audio/x-wavpack-correction",
     1733            "video/3gpp",
     1734            "video/flv",
     1735            "video/mj2",
     1736            "video/mp2t",
     1737            "video/mp4",
     1738            "video/mpeg",
     1739            "video/mpegts",
     1740            "video/ogg",
     1741            "video/quicktime",
     1742            "video/vivo",
     1743            "video/webm",
     1744            "video/x-cdxa",
     1745            "video/x-dirac",
     1746            "video/x-dv",
     1747            "video/x-fli",
     1748            "video/x-flv",
     1749            "video/x-h263",
     1750            "video/x-ivf",
     1751            "video/x-m4v",
     1752            "video/x-matroska",
     1753            "video/x-mng",
     1754            "video/x-ms-asf",
     1755            "video/x-msvideo",
     1756            "video/x-mve",
     1757            "video/x-nuv",
     1758            "video/x-vcd"
     1759        };
     1760        for (auto& type : mimeTypes)
     1761            set.add(type);
     1762        return set;
     1763    }();
    17681764    return cache;
    17691765}
    17701766
    1771 void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet<String>& types)
     1767void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
    17721768{
    17731769    types = mimeTypeCache();
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r195234 r195951  
    127127
    128128private:
    129     static void getSupportedTypes(HashSet<String>&);
     129    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
    130130    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    131131
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h

    r189144 r195951  
    6666private:
    6767    // engine support
    68     static void getSupportedTypes(HashSet<String>& types);
     68    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    6969    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    7070
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

    r194819 r195951  
    12331233    // QTKit will return non-video MIME types which it claims to support, but which we
    12341234    // do not support in the <video> element. Disclaim all non video/ or audio/ types.
    1235     return !type.startsWith("video/") && !type.startsWith("audio/");
    1236 }
    1237 
    1238 static void addFileTypesToCache(NSArray * fileTypes, HashSet<String> &cache)
    1239 {
    1240     int count = [fileTypes count];
    1241     for (int n = 0; n < count; n++) {
    1242         CFStringRef ext = reinterpret_cast<CFStringRef>([fileTypes objectAtIndex:n]);
     1235    return !type.startsWith("video/", false) && !type.startsWith("audio/", false);
     1236}
     1237
     1238static void addFileTypesToCache(NSArray *fileTypes, HashSet<String, ASCIICaseInsensitiveHash> &cache)
     1239{
     1240    for (NSString *fileType : fileTypes) {
     1241        CFStringRef ext = reinterpret_cast<CFStringRef>(fileType);
    12431242        RetainPtr<CFStringRef> uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext, NULL));
    12441243        if (!uti)
     
    12551254            // UTI is missing many media related MIME types supported by QTKit (see rdar://6434168), and not all
    12561255            // web servers use the MIME type UTI returns for an extension (see rdar://7875393), so even if UTI
    1257             // has a type for this extension add any types in hard coded table in the MIME type regsitry.
    1258             Vector<String> typesForExtension = MIMETypeRegistry::getMediaMIMETypesForExtension(ext);
    1259             unsigned count = typesForExtension.size();
    1260             for (unsigned ndx = 0; ndx < count; ++ndx) {
    1261                 String type = typesForExtension[ndx].lower();
    1262 
    1263                 if (shouldRejectMIMEType(type))
    1264                     continue;
    1265 
    1266                 if (!cache.contains(type))
     1256            // has a type for this extension add any types in hard coded table in the MIME type registry.
     1257            for (auto& type : MIMETypeRegistry::getMediaMIMETypesForExtension(ext)) {
     1258                if (!shouldRejectMIMEType(type))
    12671259                    cache.add(type);
    12681260            }
     
    12711263}
    12721264
    1273 static HashSet<String> mimeCommonTypesCache()
    1274 {
    1275     static NeverDestroyed<HashSet<String>> cache;
     1265static HashSet<String, ASCIICaseInsensitiveHash> mimeCommonTypesCache()
     1266{
     1267    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
    12761268    static bool typeListInitialized = false;
    12771269
     
    12851277}
    12861278
    1287 static HashSet<String> mimeModernTypesCache()
    1288 {
    1289     static NeverDestroyed<HashSet<String>> cache;
     1279static HashSet<String, ASCIICaseInsensitiveHash> mimeModernTypesCache()
     1280{
     1281    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
    12901282    static bool typeListInitialized = false;
    12911283   
     
    12991291}
    13001292
    1301 static void concatenateHashSets(HashSet<String>& destination, const HashSet<String>& source)
    1302 {
    1303     HashSet<String>::const_iterator it = source.begin();
    1304     HashSet<String>::const_iterator end = source.end();
    1305     for (; it != end; ++it)
    1306         destination.add(*it);
    1307 }
    1308 
    1309 void MediaPlayerPrivateQTKit::getSupportedTypes(HashSet<String>& supportedTypes)
     1293static void concatenateHashSets(HashSet<String, ASCIICaseInsensitiveHash>& destination, const HashSet<String, ASCIICaseInsensitiveHash>& source)
     1294{
     1295    for (auto& type : source)
     1296        destination.add(type);
     1297}
     1298
     1299void MediaPlayerPrivateQTKit::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes)
    13101300{
    13111301    concatenateHashSets(supportedTypes, mimeModernTypesCache());
     
    13791369    }
    13801370   
    1381     static HashSet<String>* allowedTrackTypes = 0;
    1382     if (!allowedTrackTypes) {
    1383         allowedTrackTypes = new HashSet<String>;
    1384         allowedTrackTypes->add(QTMediaTypeVideo);
    1385         allowedTrackTypes->add(QTMediaTypeSound);
    1386         allowedTrackTypes->add(QTMediaTypeText);
    1387         allowedTrackTypes->add(QTMediaTypeBase);
    1388         allowedTrackTypes->add(QTMediaTypeMPEG);
    1389         allowedTrackTypes->add("clcp"); // Closed caption
    1390         allowedTrackTypes->add("sbtl"); // Subtitle
    1391         allowedTrackTypes->add("odsm"); // MPEG-4 object descriptor stream
    1392         allowedTrackTypes->add("sdsm"); // MPEG-4 scene description stream
    1393         allowedTrackTypes->add("tmcd"); // timecode
    1394         allowedTrackTypes->add("tc64"); // timcode-64
    1395         allowedTrackTypes->add("tmet"); // timed metadata
    1396     }
     1371    static NeverDestroyed<HashSet<String>> allowedTrackTypes = []() {
     1372        NSString *types[] = {
     1373            QTMediaTypeVideo,
     1374            QTMediaTypeSound,
     1375            QTMediaTypeText,
     1376            QTMediaTypeBase,
     1377            QTMediaTypeMPEG,
     1378            @"clcp", // Closed caption
     1379            @"sbtl", // Subtitle
     1380            @"odsm", // MPEG-4 object descriptor stream
     1381            @"sdsm", // MPEG-4 scene description stream
     1382            @"tmcd", // timecode
     1383            @"tc64", // timcode-64
     1384            @"tmet", // timed metadata
     1385        };
     1386        HashSet<String> set;
     1387        for (auto& type : types)
     1388            set.add(type);
     1389        return set;
     1390    }();
    13971391   
    13981392    NSArray *tracks = [m_qtMovie.get() tracks];
     
    14201414
    14211415        // Test whether the media type is in our white list.
    1422         if (!allowedTrackTypes->contains(mediaType)) {
     1416        if (!allowedTrackTypes.get().contains(mediaType)) {
    14231417            // If this track type is not allowed, then we need to disable it.
    14241418            [track setEnabled:NO];
  • trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp

    r194787 r195951  
    121121}
    122122
    123 static const HashSet<String>& mimeTypeCache()
    124 {
    125     static NeverDestroyed<HashSet<String>> cachedTypes;
     123static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
     124{
     125    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cachedTypes;
    126126
    127127    if (cachedTypes.get().size() > 0)
     
    149149}
    150150
    151 void MediaPlayerPrivateMediaFoundation::getSupportedTypes(HashSet<String>& types)
     151void MediaPlayerPrivateMediaFoundation::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
    152152{
    153153    types = mimeTypeCache();
  • trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h

    r194535 r195951  
    5454    static void registerMediaEngine(MediaEngineRegistrar);
    5555
    56     static void getSupportedTypes(HashSet<String>& types);
     56    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    5757    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    5858    static bool isAvailable();
  • trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp

    r190020 r195951  
    4646}
    4747
    48 static const HashSet<String>& mimeTypeCache()
    49 {
    50     static NeverDestroyed<HashSet<String>> cache;
     48static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
     49{
     50    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
    5151    static bool isInitialized = false;
    5252
     
    6060}
    6161
    62 void MockMediaPlayerMediaSource::getSupportedTypes(HashSet<String>& supportedTypes)
     62void MockMediaPlayerMediaSource::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes)
    6363{
    6464    supportedTypes = mimeTypeCache();
  • trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h

    r189144 r195951  
    4343    // MediaPlayer Engine Support
    4444    WEBCORE_EXPORT static void registerMediaEngine(MediaEngineRegistrar);
    45     static void getSupportedTypes(HashSet<String>& types);
     45    static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types);
    4646    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
    4747
  • trunk/Source/WebKit/mac/ChangeLog

    r195937 r195951  
     12016-01-31  Darin Adler  <darin@apple.com>
     2
     3        Cut down on calls to String::lower; mostly replace with convertToASCIILowercase
     4        https://bugs.webkit.org/show_bug.cgi?id=153732
     5
     6        Reviewed by Dean Jackson.
     7
     8        * WebView/WebHTMLRepresentation.mm:
     9        (newArrayWithStrings): Updated to use HashSet<String, ASCIICaseInsensitiveHash>
     10        and also to use a modern for loop.
     11
    1122016-01-31  Dan Bernstein  <mitz@apple.com>
    213
  • trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm

    r194987 r195951  
    8888@implementation WebHTMLRepresentation
    8989
    90 static NSMutableArray *newArrayWithStrings(const HashSet<String>& set) NS_RETURNS_RETAINED;
    91 static NSMutableArray *newArrayWithStrings(const HashSet<String>& set)
     90static NSMutableArray *newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>&) NS_RETURNS_RETAINED;
     91static NSMutableArray *newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>& set)
    9292{
    9393    NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:set.size()];
    94     HashSet<String>::const_iterator end = set.end();
    95     for (HashSet<String>::const_iterator it = set.begin(); it != end; ++it)
    96         [array addObject:(NSString *)(*it)];
     94    for (auto& string : set)
     95        [array addObject:(NSString *)string];
    9796    return array;
    9897}
Note: See TracChangeset for help on using the changeset viewer.