Changeset 195951 in webkit
- Timestamp:
- Jan 31, 2016 9:46:20 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r195946 r195951 1 2016-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 1 12 2016-01-31 Darin Adler <darin@apple.com> 2 13 -
trunk/Source/WTF/wtf/text/StringView.h
r195743 r195951 127 127 128 128 int toInt(bool& isValid) const; 129 int toIntStrict(bool& isValid) const; 129 130 float toFloat(bool& isValid) const; 130 131 … … 462 463 } 463 464 465 inline 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 464 472 inline String StringView::toStringWithoutCopying() const 465 473 { -
trunk/Source/WebCore/ChangeLog
r195950 r195951 1 2016-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 1 241 2016-01-31 Brent Fulgham <bfulgham@apple.com> 2 242 -
trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp
r194819 r195951 733 733 return false; 734 734 735 // FIXME: Why do we convert to lowercase here, but not in MediaSource::addSourceBuffer? 735 736 ContentType contentType(type.lower()); 736 737 String codecs = contentType.parameter("codecs"); -
trunk/Source/WebCore/Modules/navigatorcontentutils/NavigatorContentUtils.cpp
r194496 r195951 40 40 namespace WebCore { 41 41 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 51 42 static bool verifyCustomHandlerURL(const URL& baseURL, const String& url, ExceptionCode& ec) 52 43 { … … 75 66 } 76 67 77 static bool isProtocolWhitelisted(const String& scheme)68 static inline bool isProtocolWhitelisted(const String& scheme) 78 69 { 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); 82 77 } 83 78 … … 87 82 return true; 88 83 84 // FIXME: Should this be case sensitive, or should it be ASCII case-insensitive? 89 85 if (scheme.startsWith("web+")) { 90 86 // 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 83 83 bool QuickTimePluginReplacement::supportsMimeType(const String& mimeType) 84 84 { 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 }(); 98 98 return typeHash.get().contains(mimeType); 99 99 } … … 101 101 bool QuickTimePluginReplacement::supportsFileExtension(const String& extension) 102 102 { 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 extension Hash.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); 115 115 } 116 116 -
trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp
r195452 r195951 155 155 // Save the key and the value. 156 156 if (keyLength && valueLength) { 157 const String& key = queryString.substring(keyLocation, keyLength).lower();157 String key = queryString.substring(keyLocation, keyLength).convertToASCIILowercase(); 158 158 String value = queryString.substring(valueLocation, valueLength); 159 159 value.replace('+', ' '); … … 182 182 static bool isYouTubeURL(const URL& url) 183 183 { 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"); 192 191 } 193 192 … … 203 202 static URL processAndCreateYouTubeURL(const URL& url, bool& isYouTubeShortenedURL) 204 203 { 205 if (!url.protocolIs ("http") && !url.protocolIs("https"))204 if (!url.protocolIsInHTTPFamily()) 206 205 return URL(); 207 206 208 207 // Bail out early if we aren't even on www.youtube.com or youtube.com. 209 208 if (!isYouTubeURL(url)) 210 209 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 217 215 // Short URL of the form: http://youtu.be/v1d301D 218 216 if (isYouTubeShortenedURL) { 219 const String&videoID = url.lastPathComponent();217 String videoID = url.lastPathComponent(); 220 218 if (videoID.isEmpty() || videoID == "/") 221 219 return URL(); 222 223 220 return createYouTubeURL(videoID, emptyString()); 224 221 } … … 242 239 } 243 240 244 if ( path.lower() == "/watch") {241 if (equalLettersIgnoringASCIICase(path, "/watch")) { 245 242 if (!query.isEmpty()) { 246 243 const auto& queryDictionary = queryKeysAndValues(query); … … 304 301 // From the original URL, we need to get the part before /path/VideoId. 305 302 locationOfPathBeforeVideoID = srcString.find(srcPath.substring(0, locationOfVideoIDInPath)); 306 } else if ( srcPath.lower() == "/watch") {303 } else if (equalLettersIgnoringASCIICase(srcPath, "/watch")) { 307 304 // From the original URL, we need to get the part before /watch/#!v=VideoID 305 // FIXME: Shouldn't this be ASCII case-insensitive? 308 306 locationOfPathBeforeVideoID = srcString.find("/watch"); 309 307 } else -
trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp
r195452 r195951 82 82 ASSERT(url.protocolIs("wss") == secure); 83 83 StringBuilder builder; 84 builder.append(url.host(). lower());84 builder.append(url.host().convertToASCIILowercase()); 85 85 if (url.port() && ((!secure && url.port() != 80) || (secure && url.port() != 443))) { 86 86 builder.append(':'); … … 144 144 } 145 145 146 // FIXME: Return type should just be String, not const String. 146 147 const String WebSocketHandshake::host() const 147 148 { 148 return m_url.host(). lower();149 return m_url.host().convertToASCIILowercase(); 149 150 } 150 151 -
trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
r193750 r195951 411 411 String tagName = element->tagName(); 412 412 if (!tagName.isEmpty()) 413 attributeSet = addToAtkAttributeSet(attributeSet, "tag", tagName. lower().utf8().data());413 attributeSet = addToAtkAttributeSet(attributeSet, "tag", tagName.convertToASCIILowercase().utf8().data()); 414 414 String id = element->getIdAttribute().string(); 415 415 if (!id.isEmpty()) -
trunk/Source/WebCore/css/CSSGrammar.y.in
r195612 r195951 590 590 base_media_query_exp: '(' maybe_space IDENT maybe_space maybe_media_value ')' { 591 591 std::unique_ptr<CSSParserValueList> mediaValue($5); 592 $3. lower();592 $3.convertToASCIILowercaseInPlace(); 593 593 $$ = new MediaQueryExp($3, mediaValue.get()); 594 594 } … … 645 645 | 646 646 maybe_media_restrictor maybe_space IDENT maybe_space maybe_and_media_query_exp_list { 647 $3. lower();647 $3.convertToASCIILowercaseInPlace(); 648 648 $$ = new MediaQuery($1, $3, std::unique_ptr<Vector<std::unique_ptr<MediaQueryExp>>>($5)); 649 649 } … … 1235 1235 $$->setMatch(CSSSelector::Id); 1236 1236 if (parser->m_context.mode == CSSQuirksMode) 1237 $1. lower();1237 $1.convertToASCIILowercaseInPlace(); 1238 1238 $$->setValue($1); 1239 1239 } … … 1245 1245 $$->setMatch(CSSSelector::Id); 1246 1246 if (parser->m_context.mode == CSSQuirksMode) 1247 $1. lower();1247 $1.convertToASCIILowercaseInPlace(); 1248 1248 $$->setValue($1); 1249 1249 } … … 1259 1259 $$->setMatch(CSSSelector::Class); 1260 1260 if (parser->m_context.mode == CSSQuirksMode) 1261 $2. lower();1261 $2.convertToASCIILowercaseInPlace(); 1262 1262 $$->setValue($2); 1263 1263 } -
trunk/Source/WebCore/css/CSSParser.cpp
r195892 r195951 341 341 } 342 342 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()); 343 template<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 349 void CSSParserString::convertToASCIILowercaseInPlace() 350 { 351 if (is8Bit()) 352 WebCore::convertToASCIILowercaseInPlace(characters8(), length()); 353 else 354 WebCore::convertToASCIILowercaseInPlace(characters16(), length()); 371 355 } 372 356 … … 1199 1183 } 1200 1184 1185 static 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 1201 1194 static CSSParser::ParseResult parseKeywordValue(MutableStyleProperties* declaration, CSSPropertyID propertyId, const String& string, bool important, const CSSParserContext& parserContext, StyleSheetContents* styleSheetContents) 1202 1195 { … … 1204 1197 1205 1198 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)) 1209 1200 return CSSParser::ParseResult::Error; 1210 1201 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. 1212 1203 if (shorthandForProperty(propertyId).length()) 1213 1204 return CSSParser::ParseResult::Error; … … 4343 4334 return nullptr; 4344 4335 4345 String attrName = argument.string; 4336 ASSERT(argument.string.length()); 4337 4346 4338 // CSS allows identifiers with "-" at the start, like "-webkit-mask-image". 4347 4339 // But HTML attribute names can't have those characters, and we should not 4348 4340 // even parse them inside attr(). 4349 if (a ttrName[0] == '-')4341 if (argument.string[0] == '-') 4350 4342 return nullptr; 4351 4343 4352 4344 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); 4356 4349 } 4357 4350 -
trunk/Source/WebCore/css/CSSParserValues.cpp
r195452 r195951 200 200 CSSParserSelector* CSSParserSelector::parsePseudoElementSelector(CSSParserString& pseudoTypeString) 201 201 { 202 pseudoTypeString. lower();202 pseudoTypeString.convertToASCIILowercaseInPlace(); 203 203 AtomicString name = pseudoTypeString; 204 204 -
trunk/Source/WebCore/css/CSSParserValues.h
r195743 r195951 34 34 class QualifiedName; 35 35 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. 39 37 struct CSSParserString { 40 38 void init(LChar* characters, unsigned length) … … 74 72 LChar* characters8() const { ASSERT(is8Bit()); return m_data.characters8; } 75 73 UChar* characters16() const { ASSERT(!is8Bit()); return m_data.characters16; } 76 template <typename CharacterType> 77 CharacterType* characters() const; 74 template<typename CharacterType> CharacterType* characters() const; 78 75 79 76 unsigned length() const { return m_length; } 80 77 void setLength(unsigned length) { m_length = length; } 81 78 82 void lower();79 void convertToASCIILowercaseInPlace(); 83 80 84 81 UChar operator[](unsigned i) const -
trunk/Source/WebCore/css/CSSSelector.cpp
r194496 r195951 806 806 bool CSSSelector::RareData::parseNth() 807 807 { 808 String argument = m_argument.lower(); 809 810 if (argument.isEmpty()) 808 if (m_argument.isEmpty()) 811 809 return false; 812 810 813 m_a = 0; 814 m_b = 0; 815 if (argument == "odd") { 811 if (equalLettersIgnoringASCIICase(m_argument, "odd")) { 816 812 m_a = 2; 817 813 m_b = 1; 818 } else if ( argument == "even") {814 } else if (equalLettersIgnoringASCIICase(m_argument, "even")) { 819 815 m_a = 2; 820 816 m_b = 0; 821 817 } 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')); 823 822 if (n != notFound) { 824 if ( argument[0] == '-') {823 if (m_argument[0] == '-') { 825 824 if (n == 1) 826 825 m_a = -1; // -n == -1n 827 826 else { 828 827 bool ok; 829 m_a = argument.substringSharingImpl(0, n).toIntStrict(&ok);828 m_a = StringView(m_argument).substring(0, n).toIntStrict(ok); 830 829 if (!ok) 831 830 return false; … … 835 834 else { 836 835 bool ok; 837 m_a = argument.substringSharingImpl(0, n).toIntStrict(&ok);836 m_a = StringView(m_argument).substring(0, n).toIntStrict(ok); 838 837 if (!ok) 839 838 return false; 840 839 } 841 840 842 size_t p = argument.find('+', n);841 size_t p = m_argument.find('+', n); 843 842 if (p != notFound) { 844 843 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); 846 845 if (!ok) 847 846 return false; 848 847 } else { 849 p = argument.find('-', n);848 p = m_argument.find('-', n); 850 849 if (p != notFound) { 851 850 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); 853 852 if (!ok) 854 853 return false; … … 857 856 } else { 858 857 bool ok; 859 m_b = argument.toIntStrict(&ok);858 m_b = m_argument.string().toIntStrict(&ok); 860 859 if (!ok) 861 860 return false; -
trunk/Source/WebCore/css/MediaQuery.cpp
r194496 r195951 75 75 MediaQuery::MediaQuery(Restrictor r, const String& mediaType, std::unique_ptr<ExpressionVector> exprs) 76 76 : m_restrictor(r) 77 , m_mediaType(mediaType. lower())77 , m_mediaType(mediaType.convertToASCIILowercase()) 78 78 , m_expressions(WTFMove(exprs)) 79 79 , m_ignored(false) -
trunk/Source/WebCore/css/MediaQueryExp.cpp
r195148 r195951 233 233 StringBuilder result; 234 234 result.append('('); 235 result.append(m_mediaFeature. lower());235 result.append(m_mediaFeature.convertToASCIILowercase()); 236 236 if (m_value) { 237 237 result.appendLiteral(": "); -
trunk/Source/WebCore/dom/Document.cpp
r195948 r195951 3279 3279 } 3280 3280 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(); 3281 static bool isSeparator(UChar character) 3282 { 3283 return character == ' ' || character == '\t' || character == '\n' || character == '\r' || character == '=' || character == ','; 3284 } 3285 3286 static void processArguments(StringView features, std::function<void(StringView type, StringView value)> callback) 3287 { 3288 unsigned length = features.length(); 3295 3289 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])) 3300 3297 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; 3303 3308 3304 3309 // 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)); 3334 3315 } 3335 3316 } … … 3343 3324 3344 3325 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 }); 3346 3330 3347 3331 updateViewportArguments(); … … 3363 3347 #if PLATFORM(IOS) 3364 3348 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 3372 3349 void Document::processFormatDetection(const String& features) 3373 3350 { 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 }); 3376 3356 } 3377 3357 -
trunk/Source/WebCore/dom/Document.h
r195928 r195951 1345 1345 void detachParser(); 1346 1346 1347 typedef void (*ArgumentsCallback)(const String& keyString, const String& valueString, Document*, void* data);1348 void processArguments(const String& features, void* data, ArgumentsCallback);1349 1350 1347 // FontSelectorClient 1351 1348 virtual void fontsNeedUpdate(FontSelector&) override final; -
trunk/Source/WebCore/dom/Element.cpp
r195743 r195951 1202 1202 { 1203 1203 if (inQuirksMode) 1204 return value. lower();1204 return value.convertToASCIILowercase(); 1205 1205 return value; 1206 1206 } -
trunk/Source/WebCore/dom/ScriptElement.cpp
r195928 r195951 150 150 // - Allowing type=javascript. type= should only support MIME types, such as text/javascript. 151 151 // - 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 153 152 String type = typeAttributeValue(); 154 153 String language = languageAttributeValue(); 155 if (type.isEmpty() && language.isEmpty())156 return true; // Assume text/javascript.157 154 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)) 160 158 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)) 162 166 return true; 163 167 return false; -
trunk/Source/WebCore/dom/ViewportArguments.cpp
r195607 r195951 287 287 } 288 288 289 static float numericPrefix(const String& keyString, const String& valueString, Document* document, bool* ok = nullptr) 289 static void reportViewportWarning(Document&, ViewportErrorCode, StringView replacement1 = { }, StringView replacement2 = { }); 290 291 static float numericPrefix(Document& document, StringView key, StringView value, bool* ok = nullptr) 290 292 { 291 293 size_t parsedLength; 292 float value;293 if (value String.is8Bit())294 value = charactersToFloat(valueString.characters8(), valueString.length(), parsedLength);294 float numericValue; 295 if (value.is8Bit()) 296 numericValue = charactersToFloat(value.characters8(), value.length(), parsedLength); 295 297 else 296 value = charactersToFloat(valueString.characters16(), valueString.length(), parsedLength);298 numericValue = charactersToFloat(value.characters16(), value.length(), parsedLength); 297 299 if (!parsedLength) { 298 reportViewportWarning(document, UnrecognizedViewportArgumentValueError, value String, keyString);300 reportViewportWarning(document, UnrecognizedViewportArgumentValueError, value, key); 299 301 if (ok) 300 302 *ok = false; 301 303 return 0; 302 304 } 303 if (parsedLength < value String.length())304 reportViewportWarning(document, TruncatedViewportArgumentValueError, value String, keyString);305 if (parsedLength < value.length()) 306 reportViewportWarning(document, TruncatedViewportArgumentValueError, value, key); 305 307 if (ok) 306 308 *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 312 static float findSizeValue(Document& document, StringView key, StringView value, bool* valueWasExplicit = nullptr) 311 313 { 312 314 // 1) Non-negative number values are translated to px lengths. … … 318 320 *valueWasExplicit = true; 319 321 320 if (equalLettersIgnoringASCIICase(value String, "device-width"))322 if (equalLettersIgnoringASCIICase(value, "device-width")) 321 323 return ViewportArguments::ValueDeviceWidth; 322 324 323 if (equalLettersIgnoringASCIICase(value String, "device-height"))325 if (equalLettersIgnoringASCIICase(value, "device-height")) 324 326 return ViewportArguments::ValueDeviceHeight; 325 327 326 float sizeValue = numericPrefix( keyString, valueString, document);328 float sizeValue = numericPrefix(document, key, value); 327 329 328 330 if (sizeValue < 0) { … … 335 337 } 336 338 337 static float findScaleValue( const String& keyString, const String& valueString, Document* document)339 static float findScaleValue(Document& document, StringView key, StringView value) 338 340 { 339 341 // 1) Non-negative number values are translated to <number> values. … … 343 345 // 5) no and unknown values are translated to 0.0 344 346 345 if (equalLettersIgnoringASCIICase(value String, "yes"))347 if (equalLettersIgnoringASCIICase(value, "yes")) 346 348 return 1; 347 if (equalLettersIgnoringASCIICase(value String, "no"))349 if (equalLettersIgnoringASCIICase(value, "no")) 348 350 return 0; 349 if (equalLettersIgnoringASCIICase(value String, "device-width"))351 if (equalLettersIgnoringASCIICase(value, "device-width")) 350 352 return 10; 351 if (equalLettersIgnoringASCIICase(value String, "device-height"))353 if (equalLettersIgnoringASCIICase(value, "device-height")) 352 354 return 10; 353 355 354 float value = numericPrefix(keyString, valueString, document);355 356 if ( value < 0)356 float numericValue = numericPrefix(document, key, value); 357 358 if (numericValue < 0) 357 359 return ViewportArguments::ValueAuto; 358 360 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. 368 static float findBooleanValue(Document& document, StringView key, StringView value) 366 369 { 367 370 // yes and no are used as keywords. … … 369 372 // Numbers in the range <-1, 1>, and unknown values, are mapped to no. 370 373 371 if (equalLettersIgnoringASCIICase(value String, "yes"))374 if (equalLettersIgnoringASCIICase(value, "yes")) 372 375 return 1; 373 if (equalLettersIgnoringASCIICase(value String, "no"))376 if (equalLettersIgnoringASCIICase(value, "no")) 374 377 return 0; 375 if (equalLettersIgnoringASCIICase(value String, "device-width"))378 if (equalLettersIgnoringASCIICase(value, "device-width")) 376 379 return 1; 377 if (equalLettersIgnoringASCIICase(value String, "device-height"))380 if (equalLettersIgnoringASCIICase(value, "device-height")) 378 381 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 385 void 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); 404 399 #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 } 408 404 #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); 411 407 else 412 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, key String, String());408 reportViewportWarning(document, UnrecognizedViewportArgumentKeyError, key); 413 409 } 414 410 … … 440 436 } 441 437 442 void reportViewportWarning(Document * document, ViewportErrorCode errorCode, const String& replacement1, const String&replacement2)443 { 444 Frame* frame = document->frame();445 if (! frame)438 void 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()) 446 442 return; 447 443 448 444 String message = viewportErrorMessageTemplate(errorCode); 449 445 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". 451 448 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(';')) 455 452 message.append(" Note that ';' is not a separator in viewport values. The list should be comma-separated."); 456 453 457 454 // 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); 459 456 } 460 457 -
trunk/Source/WebCore/dom/ViewportArguments.h
r195607 r195951 135 135 float computeMinimumScaleFactorForContentContained(const ViewportAttributes& result, const IntSize& viewportSize, const IntSize& contentSize); 136 136 137 void setViewportFeature(const String& keyString, const String& valueString, Document*, void* data); 138 void reportViewportWarning(Document*, ViewportErrorCode, const String& replacement1, const String& replacement2); 137 void setViewportFeature(ViewportArguments&, Document&, StringView key, StringView value); 139 138 140 139 TextStream& operator<<(TextStream&, const ViewportArguments&); -
trunk/Source/WebCore/editing/EditorCommand.cpp
r195928 r195951 412 412 static bool executeFormatBlock(Frame& frame, Event*, EditorCommandSource, const String& value) 413 413 { 414 String tagName = value. lower();414 String tagName = value.convertToASCIILowercase(); 415 415 if (tagName[0] == '<' && tagName[tagName.length() - 1] == '>') 416 416 tagName = tagName.substring(1, tagName.length() - 2); -
trunk/Source/WebCore/fileapi/Blob.cpp
r195452 r195951 97 97 98 98 Blob::Blob(DeserializationContructor, const URL& srcURL, const String& type, long long size) 99 : m_type( Blob::normalizedContentType(type))99 : m_type(normalizedContentType(type)) 100 100 , m_size(size) 101 101 { … … 105 105 106 106 Blob::Blob(const URL& srcURL, long long start, long long end, const String& type) 107 : m_type( Blob::normalizedContentType(type))107 : m_type(normalizedContentType(type)) 108 108 , m_size(-1) // size is not necessarily equal to end - start. 109 109 { … … 123 123 // come up with an exception to throw if file size is not representable. 124 124 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; 126 126 } 127 127 … … 131 131 bool Blob::isValidContentType(const String& contentType) 132 132 { 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; 149 138 } 150 139 return true; … … 153 142 String Blob::normalizedContentType(const String& contentType) 154 143 { 155 if ( Blob::isValidContentType(contentType))156 return contentType.lower();157 return emptyString();144 if (!isValidContentType(contentType)) 145 return emptyString(); 146 return contentType.convertToASCIILowercase(); 158 147 } 159 148 160 149 bool Blob::isNormalizedContentType(const String& contentType) 161 150 { 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; 182 158 } 183 159 return true; … … 186 162 bool Blob::isNormalizedContentType(const CString& contentType) 187 163 { 164 // FIXME: Do we really want to treat the empty string and null string as valid content types? 188 165 size_t length = contentType.length(); 189 166 const char* characters = contentType.data(); -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp
r169573 r195951 27 27 28 28 #include "Decimal.h" 29 #include "QualifiedName.h" 29 30 #include "URL.h" 30 31 #include <limits> 31 32 #include <wtf/MathExtras.h> 32 #include <wtf/text/AtomicString.h>33 33 #include <wtf/text/StringBuilder.h> 34 34 -
trunk/Source/WebCore/html/parser/HTMLParserIdioms.h
r177952 r195951 26 26 #define HTMLParserIdioms_h 27 27 28 #include "QualifiedName.h"28 #include <unicode/uchar.h> 29 29 #include <wtf/Forward.h> 30 #include <wtf/text/WTFString.h>31 30 32 31 namespace WebCore { 33 32 34 33 class Decimal; 34 class QualifiedName; 35 35 36 36 // Space characters as defined by the HTML specification. 37 template<typename CharacterType> bool isHTMLSpace(CharacterType); 38 template<typename CharacterType> bool isComma(CharacterType); 39 template<typename CharacterType> bool isHTMLSpaceOrComma(CharacterType); 37 40 bool isHTMLLineBreak(UChar); 38 41 bool isNotHTMLSpace(UChar); 39 bool isHTMLSpaceButNotLineBreak(UChar character);42 bool isHTMLSpaceButNotLineBreak(UChar); 40 43 41 44 // Strip leading and trailing whitespace as defined by the HTML specification. … … 60 63 bool parseHTMLNonNegativeInteger(const String&, unsigned int&); 61 64 65 bool threadSafeMatch(const QualifiedName&, const QualifiedName&); 66 62 67 // Inline implementations of some of the functions declared above. 63 template<typename CharType> 64 inline bool isHTMLSpace(CharType character)68 69 template<typename CharacterType> inline bool isHTMLSpace(CharacterType character) 65 70 { 66 71 // Histogram from Apple's page load test combined with some ad hoc browsing some other test suites. … … 82 87 } 83 88 84 template<typename CharType> 85 inline bool isComma(CharType character) 89 template<typename CharacterType> inline bool isComma(CharacterType character) 86 90 { 87 91 return character == ','; 88 92 } 89 93 90 template<typename CharType> 91 inline bool isHTMLSpaceOrComma(CharType character) 94 template<typename CharacterType> inline bool isHTMLSpaceOrComma(CharacterType character) 92 95 { 93 return isComma(character) || isHTMLSpace <CharType>(character);96 return isComma(character) || isHTMLSpace(character); 94 97 } 95 98 … … 104 107 } 105 108 106 bool threadSafeMatch(const QualifiedName&, const QualifiedName&);107 108 109 } 109 110 -
trunk/Source/WebCore/loader/archive/ArchiveFactory.cpp
r195928 r195951 92 92 void ArchiveFactory::registerKnownArchiveMIMETypes() 93 93 { 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()) 97 96 mimeTypes.add(mimeType); 98 97 } -
trunk/Source/WebCore/platform/MIMETypeRegistry.cpp
r195928 r195951 141 141 }; 142 142 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;143 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageResourceMIMETypes; 144 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypes; 145 static HashSet<String, ASCIICaseInsensitiveHash>* supportedImageMIMETypesForEncoding; 146 static HashSet<String, ASCIICaseInsensitiveHash>* supportedJavaScriptMIMETypes; 147 static HashSet<String, ASCIICaseInsensitiveHash>* supportedNonImageMIMETypes; 148 static HashSet<String, ASCIICaseInsensitiveHash>* supportedMediaMIMETypes; 149 static HashSet<String, ASCIICaseInsensitiveHash>* pdfMIMETypes; 150 static HashSet<String, ASCIICaseInsensitiveHash>* pdfAndPostScriptMIMETypes; 151 static HashSet<String, ASCIICaseInsensitiveHash>* unsupportedTextMIMETypes; 152 152 153 153 typedef HashMap<String, Vector<String>*, ASCIICaseInsensitiveHash> MediaMIMETypeMap; … … 211 211 "application/bmp", "application/x-bmp", "application/x-win-bitmap", 212 212 }; 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); 216 216 } 217 217 #endif … … 229 229 "image/x-xbitmap" // xbm 230 230 }; 231 for ( size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {232 supportedImageMIMETypes->add(type s[i]);233 supportedImageResourceMIMETypes->add(type s[i]);231 for (auto& type : types) { 232 supportedImageMIMETypes->add(type); 233 supportedImageResourceMIMETypes->add(type); 234 234 } 235 235 … … 244 244 static void initializeSupportedImageMIMETypesForEncoding() 245 245 { 246 supportedImageMIMETypesForEncoding = new HashSet<String >;246 supportedImageMIMETypesForEncoding = new HashSet<String, ASCIICaseInsensitiveHash>; 247 247 248 248 #if USE(CG) … … 308 308 "text/pdf" 309 309 }; 310 for ( size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i)311 pdfMIMETypes->add(type s[i]);310 for (auto& type : types) 311 pdfMIMETypes->add(type); 312 312 } 313 313 … … 338 338 #endif 339 339 "multipart/x-mixed-replace" 340 // Note: A DDING a new type here will probably render it as HTML. This can341 // 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. 342 342 }; 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); 348 346 349 347 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) … … 415 413 static void initializeSupportedMediaMIMETypes() 416 414 { 417 supportedMediaMIMETypes = new HashSet<String >;415 supportedMediaMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 418 416 #if ENABLE(VIDEO) 419 417 MediaPlayer::getSupportedTypes(*supportedMediaMIMETypes); … … 442 440 #endif 443 441 }; 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); 446 444 } 447 445 448 446 static void initializeMIMETypeRegistry() 449 447 { 450 supportedJavaScriptMIMETypes = new HashSet<String >;448 supportedJavaScriptMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 451 449 initializeSupportedJavaScriptMIMETypes(); 452 450 453 supportedNonImageMIMETypes = new HashSet<String >(*supportedJavaScriptMIMETypes);451 supportedNonImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>(*supportedJavaScriptMIMETypes); 454 452 initializeSupportedNonImageMimeTypes(); 455 453 456 supportedImageResourceMIMETypes = new HashSet<String >;457 supportedImageMIMETypes = new HashSet<String >;454 supportedImageResourceMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 455 supportedImageMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 458 456 initializeSupportedImageMIMETypes(); 459 457 460 pdfMIMETypes = new HashSet<String >;458 pdfMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 461 459 initializePDFMIMETypes(); 462 460 463 pdfAndPostScriptMIMETypes = new HashSet<String >(*pdfMIMETypes);461 pdfAndPostScriptMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>(*pdfMIMETypes); 464 462 initializePostScriptMIMETypes(); 465 463 466 unsupportedTextMIMETypes = new HashSet<String >;464 unsupportedTextMIMETypes = new HashSet<String, ASCIICaseInsensitiveHash>; 467 465 initializeUnsupportedTextMIMETypes(); 468 466 } … … 585 583 } 586 584 587 HashSet<String >& MIMETypeRegistry::getSupportedImageMIMETypes()585 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypes() 588 586 { 589 587 if (!supportedImageMIMETypes) … … 592 590 } 593 591 594 HashSet<String >& MIMETypeRegistry::getSupportedImageResourceMIMETypes()592 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageResourceMIMETypes() 595 593 { 596 594 if (!supportedImageResourceMIMETypes) … … 599 597 } 600 598 601 HashSet<String >& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding()599 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding() 602 600 { 603 601 if (!supportedImageMIMETypesForEncoding) … … 606 604 } 607 605 608 HashSet<String >& MIMETypeRegistry::getSupportedNonImageMIMETypes()606 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedNonImageMIMETypes() 609 607 { 610 608 if (!supportedNonImageMIMETypes) … … 613 611 } 614 612 615 HashSet<String >& MIMETypeRegistry::getSupportedMediaMIMETypes()613 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getSupportedMediaMIMETypes() 616 614 { 617 615 if (!supportedMediaMIMETypes) … … 621 619 622 620 623 HashSet<String >& MIMETypeRegistry::getPDFMIMETypes()621 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFMIMETypes() 624 622 { 625 623 if (!pdfMIMETypes) … … 628 626 } 629 627 630 HashSet<String >& MIMETypeRegistry::getPDFAndPostScriptMIMETypes()628 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getPDFAndPostScriptMIMETypes() 631 629 { 632 630 if (!pdfAndPostScriptMIMETypes) … … 635 633 } 636 634 637 HashSet<String >& MIMETypeRegistry::getUnsupportedTextMIMETypes()635 HashSet<String, ASCIICaseInsensitiveHash>& MIMETypeRegistry::getUnsupportedTextMIMETypes() 638 636 { 639 637 if (!unsupportedTextMIMETypes) … … 649 647 650 648 #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. 651 652 String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeType) 652 653 { 653 654 return mimeType; 654 655 } 655 #endif 656 657 #if USE(CURL) 658 typedef HashMap<String, String > MIMETypeAssociationMap;656 657 #else 658 659 typedef HashMap<String, String, ASCIICaseInsensitiveHash> MIMETypeAssociationMap; 659 660 660 661 static const MIMETypeAssociationMap& mimeTypeAssociationMap() … … 664 665 return *mimeTypeMap; 665 666 667 // FIXME: Should not allocate this on the heap; use NeverDestroyed instead. 666 668 mimeTypeMap = new MIMETypeAssociationMap; 667 669 670 // FIXME: Writing the function out like this will create a giant function. 671 // Should use a loop instead. 668 672 mimeTypeMap->add(ASCIILiteral("image/x-ms-bmp"), ASCIILiteral("image/bmp")); 669 673 mimeTypeMap->add(ASCIILiteral("image/x-windows-bmp"), ASCIILiteral("image/bmp")); … … 717 721 String MIMETypeRegistry::getNormalizedMIMEType(const String& mimeType) 718 722 { 719 MIMETypeAssociationMap::const_iterator it = mimeTypeAssociationMap().find(mimeType); 720 723 auto it = mimeTypeAssociationMap().find(mimeType); 721 724 if (it != mimeTypeAssociationMap().end()) 722 725 return it->value; 723 724 726 return mimeType; 725 727 } 728 726 729 #endif 727 730 -
trunk/Source/WebCore/platform/MIMETypeRegistry.h
r184843 r195951 38 38 WEBCORE_EXPORT static String getMIMETypeForExtension(const String& extension); 39 39 40 // FIXME: WebKit coding style says we should not have the word "get" in the names of these functions. 40 41 static Vector<String> getExtensionsForMIMEType(const String& type); 41 42 WEBCORE_EXPORT static String getPreferredExtensionForMIMEType(const String& type); … … 45 46 static String getMIMETypeForPath(const String& path); 46 47 47 // Check to see if a mimetype is suitable for being loaded inline as an48 // Check to see if a MIME type is suitable for being loaded inline as an 48 49 // image (e.g., <img> tags). 49 50 WEBCORE_EXPORT static bool isSupportedImageMIMEType(const String& mimeType); 50 51 51 // Check to see if a mimetype is suitable for being loaded as an image52 // Check to see if a MIME type is suitable for being loaded as an image 52 53 // document in a frame. 53 54 WEBCORE_EXPORT static bool isSupportedImageResourceMIMEType(const String& mimeType); 54 55 55 // Check to see if a mimetype is suitable for being encoded.56 // Check to see if a MIME type is suitable for being encoded. 56 57 static bool isSupportedImageMIMETypeForEncoding(const String& mimeType); 57 58 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. 60 60 static bool isSupportedJavaScriptMIMEType(const String& mimeType); 61 61 62 // Check to see if a non-image mimetype is suitable for being loaded as a62 // Check to see if a non-image MIME type is suitable for being loaded as a 63 63 // document in a frame. Includes supported JavaScript MIME types. 64 64 WEBCORE_EXPORT static bool isSupportedNonImageMIMEType(const String& mimeType); 65 65 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>. 67 67 WEBCORE_EXPORT static bool isSupportedMediaMIMEType(const String& mimeType); 68 68 69 // Check to see if the mimetype is not suitable for being loaded as a text70 // document in a frame. Only valid for mimetypes 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/". 71 71 static bool isUnsupportedTextMIMEType(const String& mimeType); 72 72 73 // Check to see if a mime type is a valid Java applet mime type73 // Check to see if a MIME type is a valid Java applet mime type. 74 74 WEBCORE_EXPORT static bool isJavaAppletMIMEType(const String& mimeType); 75 75 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. 78 77 static bool isApplicationPluginMIMEType(const String& mimeType); 79 78 80 // Check to see if a mimetype is one of the common PDF/PS types.79 // Check to see if a MIME type is one of the common PDF/PS types. 81 80 WEBCORE_EXPORT static bool isPDFOrPostScriptMIMEType(const String& mimeType); 82 81 static bool isPDFMIMEType(const String& mimeType); 83 82 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. 87 87 WEBCORE_EXPORT static bool canShowMIMEType(const String& mimeType); 88 88 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(); 97 99 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. 98 102 static String getNormalizedMIMEType(const String&); 99 103 }; -
trunk/Source/WebCore/platform/SchemeRegistry.cpp
r194880 r195951 97 97 } 98 98 99 static HashSet<String >& schemesForbiddenFromDomainRelaxation()100 { 101 static NeverDestroyed<HashSet<String >> schemes;99 static HashSet<String, ASCIICaseInsensitiveHash>& schemesForbiddenFromDomainRelaxation() 100 { 101 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> schemes; 102 102 return schemes; 103 103 } -
trunk/Source/WebCore/platform/URL.cpp
r195928 r195951 2122 2122 { 2123 2123 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); 2125 2128 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(); 2133 2137 } 2134 2138 -
trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp
r195743 r195951 866 866 } 867 867 868 void MediaPlayer::getSupportedTypes(HashSet<String >& types)868 void MediaPlayer::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) 869 869 { 870 870 for (auto& engine : installedMediaEngines()) { 871 HashSet<String > engineTypes;871 HashSet<String, ASCIICaseInsensitiveHash> engineTypes; 872 872 engine.getSupportedTypes(engineTypes); 873 873 types.add(engineTypes.begin(), engineTypes.end()); -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r195412 r195951 295 295 enum SupportsType { IsNotSupported, IsSupported, MayBeSupported }; 296 296 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&, const MediaPlayerSupportsTypeClient*); 297 static void getSupportedTypes(HashSet<String >&);297 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&); 298 298 static bool isAvailable(); 299 299 static void getSitesInMediaCache(Vector<String>&); … … 632 632 633 633 typedef std::function<std::unique_ptr<MediaPlayerPrivateInterface> (MediaPlayer*)> CreateMediaEnginePlayer; 634 typedef void (*MediaEngineSupportedTypes)(HashSet<String >& types);634 typedef void (*MediaEngineSupportedTypes)(HashSet<String, ASCIICaseInsensitiveHash>& types); 635 635 typedef MediaPlayer::SupportsType (*MediaEngineSupportsType)(const MediaEngineSupportParameters& parameters); 636 636 typedef void (*MediaEngineGetSitesInMediaCache)(Vector<String>&); -
trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
r188702 r195951 1112 1112 } 1113 1113 1114 const HashSet<String >& MediaPlayerPrivateAVFoundation::staticMIMETypeList()1115 { 1116 static NeverDestroyed<HashSet<String >> cache = []() {1117 HashSet<String > types;1118 1119 static const char* typeNames[] = {1114 const 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[] = { 1120 1120 "application/vnd.apple.mpegurl", 1121 1121 "application/x-mpegurl", … … 1149 1149 "video/x-mpg", 1150 1150 }; 1151 for ( size_t i = 0; i < WTF_ARRAY_LENGTH(typeNames); ++i)1152 types.add(type Names[i]);1151 for (auto& type : typeNames) 1152 types.add(type); 1153 1153 1154 1154 return types; -
trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
r189144 r195951 260 260 261 261 static bool isUnsupportedMIMEType(const String&); 262 static const HashSet<String >& staticMIMETypeList();262 static const HashSet<String, ASCIICaseInsensitiveHash>& staticMIMETypeList(); 263 263 264 264 protected: -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
r195743 r195951 883 883 #endif 884 884 885 static const HashSet<String >& avfMIMETypes()886 { 887 static NeverDestroyed<HashSet<String >> cache = []() {888 HashSet<String > types;885 static const HashSet<String, ASCIICaseInsensitiveHash>& avfMIMETypes() 886 { 887 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() { 888 HashSet<String, ASCIICaseInsensitiveHash> types; 889 889 RetainPtr<CFArrayRef> avTypes = adoptCF(AVCFURLAssetCopyAudiovisualMIMETypes()); 890 891 890 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)); 897 893 return types; 898 894 }(); … … 901 897 } 902 898 903 void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String >& supportedTypes)899 void MediaPlayerPrivateAVFoundationCF::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes) 904 900 { 905 901 supportedTypes = avfMIMETypes(); -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h
r193482 r195951 61 61 62 62 private: 63 static void getSupportedTypes(HashSet<String >& types);63 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 64 64 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 65 65 static bool supportsKeySystem(const String& keySystem, const String& mimeType); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r195595 r195951 146 146 private: 147 147 // engine support 148 static void getSupportedTypes(HashSet<String >& types);148 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 149 149 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 150 150 static bool supportsKeySystem(const String& keySystem, const String& mimeType); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r195595 r195951 1506 1506 IntRect paintRect(IntPoint(0, 0), IntSize(rect.width(), rect.height())); 1507 1507 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 1511 static 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); 1521 1517 return types; 1522 1518 }(); 1523 1524 1519 1525 1520 return cache; … … 1548 1543 } 1549 1544 1550 void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String >& supportedTypes)1545 void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes) 1551 1546 { 1552 1547 supportedTypes = avfMIMETypes(); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r195692 r195951 62 62 // MediaPlayer Factory Methods 63 63 static bool isAvailable(); 64 static void getSupportedTypes(HashSet<String >& types);64 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 65 65 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 66 66 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r195692 r195951 219 219 } 220 220 221 static const HashSet<String >& mimeTypeCache()222 { 223 static NeverDestroyed<HashSet<String >> cache;221 static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache() 222 { 223 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache; 224 224 static bool typeListInitialized = false; 225 225 … … 235 235 } 236 236 237 void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String >& types)237 void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) 238 238 { 239 239 types = mimeTypeCache(); -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h
r192503 r195951 56 56 // MediaPlayer Factory Methods 57 57 static bool isAvailable(); 58 static void getSupportedTypes(HashSet<String >& types);58 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 59 59 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 60 60 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm
r192503 r195951 84 84 } 85 85 86 void MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes(HashSet<String >& types)87 { 88 static NeverDestroyed<HashSet<String >> cache;86 void MediaPlayerPrivateMediaStreamAVFObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) 87 { 88 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache; 89 89 types = cache; 90 90 } -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r195234 r195951 42 42 #include <wtf/HexNumber.h> 43 43 #include <wtf/MediaTime.h> 44 #include <wtf/NeverDestroyed.h> 44 45 #include <wtf/glib/GUniquePtr.h> 45 46 #include <wtf/text/CString.h> … … 1660 1661 } 1661 1662 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"? 1664 static 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 }(); 1768 1764 return cache; 1769 1765 } 1770 1766 1771 void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet<String >& types)1767 void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) 1772 1768 { 1773 1769 types = mimeTypeCache(); -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
r195234 r195951 127 127 128 128 private: 129 static void getSupportedTypes(HashSet<String >&);129 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&); 130 130 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 131 131 -
trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
r189144 r195951 66 66 private: 67 67 // engine support 68 static void getSupportedTypes(HashSet<String >& types);68 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 69 69 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 70 70 -
trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
r194819 r195951 1233 1233 // QTKit will return non-video MIME types which it claims to support, but which we 1234 1234 // 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 1238 static void addFileTypesToCache(NSArray *fileTypes, HashSet<String, ASCIICaseInsensitiveHash> &cache) 1239 { 1240 for (NSString *fileType : fileTypes) { 1241 CFStringRef ext = reinterpret_cast<CFStringRef>(fileType); 1243 1242 RetainPtr<CFStringRef> uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext, NULL)); 1244 1243 if (!uti) … … 1255 1254 // UTI is missing many media related MIME types supported by QTKit (see rdar://6434168), and not all 1256 1255 // 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)) 1267 1259 cache.add(type); 1268 1260 } … … 1271 1263 } 1272 1264 1273 static HashSet<String > mimeCommonTypesCache()1274 { 1275 static NeverDestroyed<HashSet<String >> cache;1265 static HashSet<String, ASCIICaseInsensitiveHash> mimeCommonTypesCache() 1266 { 1267 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache; 1276 1268 static bool typeListInitialized = false; 1277 1269 … … 1285 1277 } 1286 1278 1287 static HashSet<String > mimeModernTypesCache()1288 { 1289 static NeverDestroyed<HashSet<String >> cache;1279 static HashSet<String, ASCIICaseInsensitiveHash> mimeModernTypesCache() 1280 { 1281 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache; 1290 1282 static bool typeListInitialized = false; 1291 1283 … … 1299 1291 } 1300 1292 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) 1293 static void concatenateHashSets(HashSet<String, ASCIICaseInsensitiveHash>& destination, const HashSet<String, ASCIICaseInsensitiveHash>& source) 1294 { 1295 for (auto& type : source) 1296 destination.add(type); 1297 } 1298 1299 void MediaPlayerPrivateQTKit::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes) 1310 1300 { 1311 1301 concatenateHashSets(supportedTypes, mimeModernTypesCache()); … … 1379 1369 } 1380 1370 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 }(); 1397 1391 1398 1392 NSArray *tracks = [m_qtMovie.get() tracks]; … … 1420 1414 1421 1415 // Test whether the media type is in our white list. 1422 if (!allowedTrackTypes ->contains(mediaType)) {1416 if (!allowedTrackTypes.get().contains(mediaType)) { 1423 1417 // If this track type is not allowed, then we need to disable it. 1424 1418 [track setEnabled:NO]; -
trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp
r194787 r195951 121 121 } 122 122 123 static const HashSet<String >& mimeTypeCache()124 { 125 static NeverDestroyed<HashSet<String >> cachedTypes;123 static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache() 124 { 125 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cachedTypes; 126 126 127 127 if (cachedTypes.get().size() > 0) … … 149 149 } 150 150 151 void MediaPlayerPrivateMediaFoundation::getSupportedTypes(HashSet<String >& types)151 void MediaPlayerPrivateMediaFoundation::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) 152 152 { 153 153 types = mimeTypeCache(); -
trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.h
r194535 r195951 54 54 static void registerMediaEngine(MediaEngineRegistrar); 55 55 56 static void getSupportedTypes(HashSet<String >& types);56 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 57 57 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 58 58 static bool isAvailable(); -
trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp
r190020 r195951 46 46 } 47 47 48 static const HashSet<String >& mimeTypeCache()49 { 50 static NeverDestroyed<HashSet<String >> cache;48 static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache() 49 { 50 static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache; 51 51 static bool isInitialized = false; 52 52 … … 60 60 } 61 61 62 void MockMediaPlayerMediaSource::getSupportedTypes(HashSet<String >& supportedTypes)62 void MockMediaPlayerMediaSource::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes) 63 63 { 64 64 supportedTypes = mimeTypeCache(); -
trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h
r189144 r195951 43 43 // MediaPlayer Engine Support 44 44 WEBCORE_EXPORT static void registerMediaEngine(MediaEngineRegistrar); 45 static void getSupportedTypes(HashSet<String >& types);45 static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); 46 46 static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); 47 47 -
trunk/Source/WebKit/mac/ChangeLog
r195937 r195951 1 2016-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 1 12 2016-01-31 Dan Bernstein <mitz@apple.com> 2 13 -
trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm
r194987 r195951 88 88 @implementation WebHTMLRepresentation 89 89 90 static NSMutableArray *newArrayWithStrings(const HashSet<String >& set) NS_RETURNS_RETAINED;91 static NSMutableArray *newArrayWithStrings(const HashSet<String >& set)90 static NSMutableArray *newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>&) NS_RETURNS_RETAINED; 91 static NSMutableArray *newArrayWithStrings(const HashSet<String, ASCIICaseInsensitiveHash>& set) 92 92 { 93 93 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]; 97 96 return array; 98 97 }
Note: See TracChangeset
for help on using the changeset viewer.