Changeset 196080 in webkit


Ignore:
Timestamp:
Feb 3, 2016 2:08:57 PM (8 years ago)
Author:
Darin Adler
Message:

Convert another batch of String::lower callsites to something better, typically convertToASCIILowercase
https://bugs.webkit.org/show_bug.cgi?id=153789

Reviewed by Sam Weinig.

Source/WebCore:

  • dom/DOMImplementation.cpp:

(WebCore::DOMImplementation::isXMLMIMEType): Use equalLettersIgnoringASCIICase
and the boolean argument to endsWith to ignore ASCII case.
(WebCore::DOMImplementation::isTextMIMEType): Ditto. Also simplified the logic
by removing an if statement.

  • dom/Document.cpp:

(WebCore::isSeparator): Deleted. Moved to WindowFeatures.cpp.
(WebCore::processArguments): Ditto.
(WebCore::Document::processViewport): Call the processFeaturesString function
from WindowFeatures.h; the code here was originally just a pasted copy of that code!
(WebCore::Document::processFormatDetection): Ditto.

  • html/HTMLCanvasElement.cpp:

(WebCore::HTMLCanvasElement::toEncodingMimeType): Remove now-unneeded
lowercasing of MIME type before calling isSupportedImageMIMETypeForEncoding,
since the MIME type registry now ignores ASCII case. Use convertToASCIILowercase
on the return value, to preserve behavior.
(WebCore::HTMLCanvasElement::toDataURL): Minor coding style tweaks.

  • html/HTMLEmbedElement.cpp:

(WebCore::HTMLEmbedElement::parseAttribute): Use convertToASCIILowercase for
the service type here.

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::bestFitSourceFromPictureElement): Remove now-unneeded
lowercasing since MIME type registry now ignores ASCII case. And use
equalLettersIgnoringASCIICase for the case here.

  • html/HTMLInputElement.cpp:

(WebCore::parseAcceptAttribute): Use convertToASCIILowercase for the type here.

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::parseAttribute): Use convertToASCIILowercase for the
media value here.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::canPlayType): Use convertToASCIILowercase for the
content type here.
(WebCore::HTMLMediaElement::selectNextSourceChild): Ditto.

  • html/HTMLObjectElement.cpp:

(WebCore::HTMLObjectElement::parseAttribute): Use convertToASCIILowercase for
the service type here.

  • html/HTMLTrackElement.cpp:

(WebCore::HTMLTrackElement::parseAttribute): Use convertToASCIILowercase for
the kind here.
(WebCore::HTMLTrackElement::ensureTrack): Ditto. Also use fastGetAttribute
since this is neither the style attribute nor an animatable SVG attribute.

  • html/parser/HTMLTreeBuilder.cpp:

(WebCore::createCaseMap): Use convertToASCIILowercase for the local names here.

  • inspector/DOMPatchSupport.cpp:

(WebCore::DOMPatchSupport::patchNode): Use containsIgnoringASCIICase instead
of combining lower with find == notFound here.
(WebCore::nodeName): Use convertToASCIILowercase here.

  • inspector/InspectorOverlay.cpp:

(WebCore::buildObjectForElementData): Use convertToASCIILowercase for node
name here.

  • inspector/InspectorPageAgent.cpp:

(WebCore::createXHRTextDecoder): Remove a now-unneeded call to lower since
DOMImplementation::isXMLMIMEType now ignores ASCII case.

  • inspector/InspectorStyleSheet.cpp:

(WebCore::lowercasePropertyName): Use convertToASCIILowercase for property
names here. Also use startsWith rather than a hand-written alternative.
(WebCore::InspectorStyle::populateAllProperties): Use the return value of
the add function to avoid doing a double hash table lookp.
(WebCore::InspectorStyle::styleWithProperties): Use convertToASCIILowercase
to lowercase the property name.

  • inspector/NetworkResourcesData.cpp:

(WebCore::createOtherResourceTextDecoder): Remove unneeded call to lower since
DOMImplement::isXMLMIMEType now ignores ASCII case.

  • loader/CrossOriginAccessControl.cpp:

(WebCore::createAccessControlPreflightRequest): Use convertToASCIILowercase
to lowercase the access control request header field value.

  • loader/cache/CachedScript.cpp:

(WebCore::CachedScript::mimeType): Use convertToASCIILowercase on the content type.

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::languageIdentifier): Use convertToASCIILowercase on the language code.

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::open): Call parseWindowFeatures instead of using the
constructor for WindowFeatures.
(WebCore::DOMWindow::showModalDialog): Call parseDialogFeatures instead of
using the constructor for WindowFeatures.

  • page/EventHandler.cpp:

(WebCore::findDropZone): Remove unneeded lowercasing and empty string checking,
and use the option SpaceSplitString already has to convert to lowercase.
(WebCore::EventHandler::handleAccessKey): Remove unneeded call to lower since
getElementByAccessKey now ignores case. Also tweaked coding style a bit.

  • page/OriginAccessEntry.cpp:

(WebCore::OriginAccessEntry::OriginAccessEntry): Use convertToASCIILowercase
on the protocol and host.
(WebCore::OriginAccessEntry::matchesOrigin): Ditto.

  • page/SecurityOrigin.cpp:

(WebCore::shouldTreatAsUniqueOrigin): Remove unneeded call to lower since
SchemeRegistry now ignores ASCII case.
(WebCore::SecurityOrigin::SecurityOrigin): Use convertToASCIILowercase on
the protocol and host.
(WebCore::SecurityOrigin::setDomainFromDOM): Use convertToASCIILowercase on
the domain.
(WebCore::SecurityOrigin::canDisplay): Remove call to lower since SchemeRegistry
now ignores ASCII case and because this now uses equalIgnoringASCIICase in
one place that used to use exact matching.

  • page/WindowFeatures.cpp: Refactored so this is now some helper functions

plus a struct rather than a class.
(WebCore::isSeparator): Renamed this and removed special handling for NUL.
(WebCore::parseWindowFeatures): Moved the code that was formerly in the
WindowFeatures constructor in here. Refactored the parsing into the
processFeaturesString function, shared with the functions in Document that
do the same kind of parsing. Removed the code that converts the entire string
to lowercase before parsing.
(WebCore::processFeaturesString): Moved the improved version of this function
here from Document.cpp; more efficient because it doesn't allocate strings.
(WebCore::setWindowFeature): Changed to be a function private to this file
with internal linkage. Use equalLettersIgnoringASCIICase so we no longer
rely on converting the string to lowercase before parsing.
(WebCore::parseDialogFeatures): Similar refactoring, but also changed all
the default handling to use Optional<> instead of default values.
(WebCore::boolFeature): Changed to use option and to ignore ASCII case.
(WebCore::floatFeature): Ditto.
(WebCore::parseDialogFeaturesMap): Removed the calls to lower, which are
not needed any more.

  • page/WindowFeatures.h: Added default values for all the data members,

and removed all the functions from the WindowFeatures struct. Added the two
functions for parsing window and dialog features. Also added the
processFeaturesString function so we can share it with Document.cpp.

  • platform/SchemeRegistry.cpp:

(WebCore::SchemeRegistry::removeURLSchemeRegisteredAsLocal): Use
equalLettersIgnoringASCIICase to ignore ASCII case.

  • platform/efl/MIMETypeRegistryEfl.cpp:

(WebCore::MIMETypeRegistry::getMIMETypeForExtension): Use a modern for loop,
and equalIgnoringASCIICase rather than calling lower.

  • platform/graphics/MediaPlayer.cpp:

(WebCore::MediaPlayer::load): Use convertToASCIILowercase on MIME type and
key system.
(WebCore::MediaPlayer::generateKeyRequest): Ditto.
(WebCore::MediaPlayer::addKey): Ditto.
(WebCore::MediaPlayer::cancelKeyRequest): Ditto.

  • platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:

(WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon): Use
convertToASCIILowercase on vendor string.

  • platform/gtk/MIMETypeRegistryGtk.cpp:

(WebCore::MIMETypeRegistry::getMIMETypeForExtension): Use a modern for loop,
and equalIgnoringASCIICase rather than calling lower.

  • platform/mac/PasteboardMac.mm:

(WebCore::cocoaTypeFromHTMLClipboardType): Use convertToASCIILowercase
on the type. Also did a bit of renaming and tweaking the logic.

Source/WTF:

  • wtf/text/StringView.h:

(WTF::StringView::toInt): Added an overload without the out parameter.

Location:
trunk/Source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r196077 r196080  
     12016-02-03  Darin Adler  <darin@apple.com>
     2
     3        Convert another batch of String::lower callsites to something better, typically convertToASCIILowercase
     4        https://bugs.webkit.org/show_bug.cgi?id=153789
     5
     6        Reviewed by Sam Weinig.
     7
     8        * wtf/text/StringView.h:
     9        (WTF::StringView::toInt): Added an overload without the out parameter.
     10
    1112016-02-03  Michael Catanzaro  <mcatanzaro@igalia.com>
    212
  • trunk/Source/WTF/wtf/text/StringView.h

    r195951 r196080  
    126126    WTF_EXPORT_STRING_API bool endsWithIgnoringASCIICase(const StringView&) const;
    127127
     128    int toInt() const;
    128129    int toInt(bool& isValid) const;
    129130    int toIntStrict(bool& isValid) const;
     
    456457}
    457458
     459inline int StringView::toInt() const
     460{
     461    bool isValid;
     462    return toInt(isValid);
     463}
     464
    458465inline int StringView::toInt(bool& isValid) const
    459466{
  • trunk/Source/WebCore/ChangeLog

    r196075 r196080  
     12016-02-03  Darin Adler  <darin@apple.com>
     2
     3        Convert another batch of String::lower callsites to something better, typically convertToASCIILowercase
     4        https://bugs.webkit.org/show_bug.cgi?id=153789
     5
     6        Reviewed by Sam Weinig.
     7
     8        * dom/DOMImplementation.cpp:
     9        (WebCore::DOMImplementation::isXMLMIMEType): Use equalLettersIgnoringASCIICase
     10        and the boolean argument to endsWith to ignore ASCII case.
     11        (WebCore::DOMImplementation::isTextMIMEType): Ditto. Also simplified the logic
     12        by removing an if statement.
     13
     14        * dom/Document.cpp:
     15        (WebCore::isSeparator): Deleted. Moved to WindowFeatures.cpp.
     16        (WebCore::processArguments): Ditto.
     17        (WebCore::Document::processViewport): Call the processFeaturesString function
     18        from WindowFeatures.h; the code here was originally just a pasted copy of that code!
     19        (WebCore::Document::processFormatDetection): Ditto.
     20
     21        * html/HTMLCanvasElement.cpp:
     22        (WebCore::HTMLCanvasElement::toEncodingMimeType): Remove now-unneeded
     23        lowercasing of MIME type before calling isSupportedImageMIMETypeForEncoding,
     24        since the MIME type registry now ignores ASCII case. Use convertToASCIILowercase
     25        on the return value, to preserve behavior.
     26        (WebCore::HTMLCanvasElement::toDataURL): Minor coding style tweaks.
     27
     28        * html/HTMLEmbedElement.cpp:
     29        (WebCore::HTMLEmbedElement::parseAttribute): Use convertToASCIILowercase for
     30        the service type here.
     31
     32        * html/HTMLImageElement.cpp:
     33        (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): Remove now-unneeded
     34        lowercasing since MIME type registry now ignores ASCII case. And use
     35        equalLettersIgnoringASCIICase for the case here.
     36
     37        * html/HTMLInputElement.cpp:
     38        (WebCore::parseAcceptAttribute): Use convertToASCIILowercase for the type here.
     39
     40        * html/HTMLLinkElement.cpp:
     41        (WebCore::HTMLLinkElement::parseAttribute): Use convertToASCIILowercase for the
     42        media value here.
     43
     44        * html/HTMLMediaElement.cpp:
     45        (WebCore::HTMLMediaElement::canPlayType): Use convertToASCIILowercase for the
     46        content type here.
     47        (WebCore::HTMLMediaElement::selectNextSourceChild): Ditto.
     48
     49        * html/HTMLObjectElement.cpp:
     50        (WebCore::HTMLObjectElement::parseAttribute): Use convertToASCIILowercase for
     51        the service type here.
     52
     53        * html/HTMLTrackElement.cpp:
     54        (WebCore::HTMLTrackElement::parseAttribute): Use convertToASCIILowercase for
     55        the kind here.
     56        (WebCore::HTMLTrackElement::ensureTrack): Ditto. Also use fastGetAttribute
     57        since this is neither the style attribute nor an animatable SVG attribute.
     58
     59        * html/parser/HTMLTreeBuilder.cpp:
     60        (WebCore::createCaseMap): Use convertToASCIILowercase for the local names here.
     61
     62        * inspector/DOMPatchSupport.cpp:
     63        (WebCore::DOMPatchSupport::patchNode): Use containsIgnoringASCIICase instead
     64        of combining lower with find == notFound here.
     65        (WebCore::nodeName): Use convertToASCIILowercase here.
     66
     67        * inspector/InspectorOverlay.cpp:
     68        (WebCore::buildObjectForElementData): Use convertToASCIILowercase for node
     69        name here.
     70
     71        * inspector/InspectorPageAgent.cpp:
     72        (WebCore::createXHRTextDecoder): Remove a now-unneeded call to lower since
     73        DOMImplementation::isXMLMIMEType now ignores ASCII case.
     74
     75        * inspector/InspectorStyleSheet.cpp:
     76        (WebCore::lowercasePropertyName): Use convertToASCIILowercase for property
     77        names here. Also use startsWith rather than a hand-written alternative.
     78        (WebCore::InspectorStyle::populateAllProperties): Use the return value of
     79        the add function to avoid doing a double hash table lookp.
     80        (WebCore::InspectorStyle::styleWithProperties): Use convertToASCIILowercase
     81        to lowercase the property name.
     82
     83        * inspector/NetworkResourcesData.cpp:
     84        (WebCore::createOtherResourceTextDecoder): Remove unneeded call to lower since
     85        DOMImplement::isXMLMIMEType now ignores ASCII case.
     86
     87        * loader/CrossOriginAccessControl.cpp:
     88        (WebCore::createAccessControlPreflightRequest): Use convertToASCIILowercase
     89        to lowercase the access control request header field value.
     90
     91        * loader/cache/CachedScript.cpp:
     92        (WebCore::CachedScript::mimeType): Use convertToASCIILowercase on the content type.
     93
     94        * page/CaptionUserPreferencesMediaAF.cpp:
     95        (WebCore::languageIdentifier): Use convertToASCIILowercase on the language code.
     96
     97        * page/DOMWindow.cpp:
     98        (WebCore::DOMWindow::open): Call parseWindowFeatures instead of using the
     99        constructor for WindowFeatures.
     100        (WebCore::DOMWindow::showModalDialog): Call parseDialogFeatures instead of
     101        using the constructor for WindowFeatures.
     102
     103        * page/EventHandler.cpp:
     104        (WebCore::findDropZone): Remove unneeded lowercasing and empty string checking,
     105        and use the option SpaceSplitString already has to convert to lowercase.
     106        (WebCore::EventHandler::handleAccessKey): Remove unneeded call to lower since
     107        getElementByAccessKey now ignores case. Also tweaked coding style a bit.
     108
     109        * page/OriginAccessEntry.cpp:
     110        (WebCore::OriginAccessEntry::OriginAccessEntry): Use convertToASCIILowercase
     111        on the protocol and host.
     112        (WebCore::OriginAccessEntry::matchesOrigin): Ditto.
     113
     114        * page/SecurityOrigin.cpp:
     115        (WebCore::shouldTreatAsUniqueOrigin): Remove unneeded call to lower since
     116        SchemeRegistry now ignores ASCII case.
     117        (WebCore::SecurityOrigin::SecurityOrigin): Use convertToASCIILowercase on
     118        the protocol and host.
     119        (WebCore::SecurityOrigin::setDomainFromDOM): Use convertToASCIILowercase on
     120        the domain.
     121        (WebCore::SecurityOrigin::canDisplay): Remove call to lower since SchemeRegistry
     122        now ignores ASCII case and because this now uses equalIgnoringASCIICase in
     123        one place that used to use exact matching.
     124
     125        * page/WindowFeatures.cpp: Refactored so this is now some helper functions
     126        plus a struct rather than a class.
     127        (WebCore::isSeparator): Renamed this and removed special handling for NUL.
     128        (WebCore::parseWindowFeatures): Moved the code that was formerly in the
     129        WindowFeatures constructor in here. Refactored the parsing into the
     130        processFeaturesString function, shared with the functions in Document that
     131        do the same kind of parsing. Removed the code that converts the entire string
     132        to lowercase before parsing.
     133        (WebCore::processFeaturesString): Moved the improved version of this function
     134        here from Document.cpp; more efficient because it doesn't allocate strings.
     135        (WebCore::setWindowFeature): Changed to be a function private to this file
     136        with internal linkage. Use equalLettersIgnoringASCIICase so we no longer
     137        rely on converting the string to lowercase before parsing.
     138        (WebCore::parseDialogFeatures): Similar refactoring, but also changed all
     139        the default handling to use Optional<> instead of default values.
     140        (WebCore::boolFeature): Changed to use option and to ignore ASCII case.
     141        (WebCore::floatFeature): Ditto.
     142        (WebCore::parseDialogFeaturesMap): Removed the calls to lower, which are
     143        not needed any more.
     144
     145        * page/WindowFeatures.h: Added default values for all the data members,
     146        and removed all the functions from the WindowFeatures struct. Added the two
     147        functions for parsing window and dialog features. Also added the
     148        processFeaturesString function so we can share it with Document.cpp.
     149
     150        * platform/SchemeRegistry.cpp:
     151        (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsLocal): Use
     152        equalLettersIgnoringASCIICase to ignore ASCII case.
     153
     154        * platform/efl/MIMETypeRegistryEfl.cpp:
     155        (WebCore::MIMETypeRegistry::getMIMETypeForExtension): Use a modern for loop,
     156        and equalIgnoringASCIICase rather than calling lower.
     157
     158        * platform/graphics/MediaPlayer.cpp:
     159        (WebCore::MediaPlayer::load): Use convertToASCIILowercase on MIME type and
     160        key system.
     161        (WebCore::MediaPlayer::generateKeyRequest): Ditto.
     162        (WebCore::MediaPlayer::addKey): Ditto.
     163        (WebCore::MediaPlayer::cancelKeyRequest): Ditto.
     164
     165        * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
     166        (WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon): Use
     167        convertToASCIILowercase on vendor string.
     168
     169        * platform/gtk/MIMETypeRegistryGtk.cpp:
     170        (WebCore::MIMETypeRegistry::getMIMETypeForExtension): Use a modern for loop,
     171        and equalIgnoringASCIICase rather than calling lower.
     172
     173        * platform/mac/PasteboardMac.mm:
     174        (WebCore::cocoaTypeFromHTMLClipboardType): Use convertToASCIILowercase
     175        on the type. Also did a bit of renaming and tweaking the logic.
     176
    11772016-02-03  Dave Hyatt  <hyatt@apple.com>
    2178
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r195928 r196080  
    269269bool DOMImplementation::isXMLMIMEType(const String& mimeType)
    270270{
    271     if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "text/xsl")
     271    // FIXME: Can we move this logic to MIMETypeRegistry and have this just be a single function call?
     272
     273    if (equalLettersIgnoringASCIICase(mimeType, "text/xml") || equalLettersIgnoringASCIICase(mimeType, "application/xml") || equalLettersIgnoringASCIICase(mimeType, "text/xsl"))
    272274        return true;
    273275
    274     if (!mimeType.endsWith("+xml"))
     276    if (!mimeType.endsWith("+xml", false))
    275277        return false;
    276278
     
    292294bool DOMImplementation::isTextMIMEType(const String& mimeType)
    293295{
    294     if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType)
    295         || mimeType == "application/json" // Render JSON as text/plain.
    296         || (mimeType.startsWith("text/") && mimeType != "text/html"
    297             && mimeType != "text/xml" && mimeType != "text/xsl"))
    298         return true;
    299 
    300     return false;
     296    // FIXME: Can we move this logic to MIMETypeRegistry and have this just be a single function call?
     297
     298    return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType)
     299        || equalLettersIgnoringASCIICase(mimeType, "application/json") // Render JSON as text/plain.
     300        || (mimeType.startsWith("text/", false)
     301            && !equalLettersIgnoringASCIICase(mimeType, "text/html")
     302            && !equalLettersIgnoringASCIICase(mimeType, "text/xml")
     303            && !equalLettersIgnoringASCIICase(mimeType, "text/xsl"));
    301304}
    302305
  • trunk/Source/WebCore/dom/Document.cpp

    r196012 r196080  
    169169#include "VisitedLinkState.h"
    170170#include "WheelEvent.h"
     171#include "WindowFeatures.h"
    171172#include "XMLDocument.h"
    172173#include "XMLDocumentParser.h"
     
    32793280}
    32803281
    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();
    3289     for (unsigned i = 0; i < length; ) {
    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]))
    3297             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;
    3308 
    3309         // skip to first separator
    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));
    3315     }
    3316 }
    3317 
    33183282void Document::processViewport(const String& features, ViewportArguments::Type origin)
    33193283{
     
    33253289    m_viewportArguments = ViewportArguments(origin);
    33263290
    3327     processArguments(features, [this](StringView key, StringView value) {
     3291    processFeaturesString(features, [this](StringView key, StringView value) {
    33283292        setViewportFeature(m_viewportArguments, *this, key, value);
    33293293    });
     
    33503314{
    33513315    // FIXME: Find a better place for this function.
    3352     processArguments(features, [this](StringView key, StringView value) {
     3316    processFeaturesString(features, [this](StringView key, StringView value) {
    33533317        if (equalLettersIgnoringASCIICase(key, "telephone") && equalLettersIgnoringASCIICase(value, "no"))
    33543318            setIsTelephoneNumberParsingAllowed(false);
  • trunk/Source/WebCore/html/HTMLCanvasElement.cpp

    r195848 r196080  
    481481String HTMLCanvasElement::toEncodingMimeType(const String& mimeType)
    482482{
    483     String lowercaseMimeType = mimeType.lower();
    484 
    485     // FIXME: Make isSupportedImageMIMETypeForEncoding threadsafe (to allow this method to be used on a worker thread).
    486     if (mimeType.isNull() || !MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(lowercaseMimeType))
    487         lowercaseMimeType = "image/png";
    488 
    489     return lowercaseMimeType;
     483    if (!MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType))
     484        return ASCIILiteral("image/png");
     485    return mimeType.convertToASCIILowercase();
    490486}
    491487
     
    500496        return ASCIILiteral("data:,");
    501497
    502     String encodingMimeType = toEncodingMimeType(mimeType);
     498    String encodingMIMEType = toEncodingMimeType(mimeType);
    503499
    504500#if USE(CG)
    505501    // Try to get ImageData first, as that may avoid lossy conversions.
    506     RefPtr<ImageData> imageData = getImageData();
    507 
    508     if (imageData)
    509         return ImageDataToDataURL(*imageData, encodingMimeType, quality);
     502    if (auto imageData = getImageData())
     503        return ImageDataToDataURL(*imageData, encodingMIMEType, quality);
    510504#endif
    511505
    512506    makeRenderingResultsAvailable();
    513507
    514     return buffer()->toDataURL(encodingMimeType, quality);
     508    return buffer()->toDataURL(encodingMIMEType, quality);
    515509}
    516510
  • trunk/Source/WebCore/html/HTMLEmbedElement.cpp

    r195452 r196080  
    102102{
    103103    if (name == typeAttr) {
    104         m_serviceType = value.string().left(value.find(';')).lower();
     104        m_serviceType = value.string().left(value.find(';')).convertToASCIILowercase();
    105105        // FIXME: The only difference between this and HTMLObjectElement's corresponding
    106106        // code is that HTMLObjectElement does setNeedsWidgetUpdate(true). Consider moving
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r195452 r196080  
    163163                type.truncate(indexOfSemicolon);
    164164            type = stripLeadingAndTrailingHTMLSpaces(type);
    165             type = type.lower();
    166             if (!type.isEmpty() && !MIMETypeRegistry::isSupportedImageMIMEType(type) && type != "image/svg+xml")
     165            if (!type.isEmpty() && !MIMETypeRegistry::isSupportedImageMIMEType(type) && !equalLettersIgnoringASCIICase(type, "image/svg+xml"))
    167166                continue;
    168167        }
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r195685 r196080  
    12301230        if (!predicate(trimmedType))
    12311231            continue;
    1232         types.append(trimmedType.lower());
     1232        types.append(trimmedType.convertToASCIILowercase());
    12331233    }
    12341234
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r194819 r196080  
    165165    }
    166166    if (name == mediaAttr) {
    167         m_media = value.string().lower();
     167        m_media = value.string().convertToASCIILowercase();
    168168        process();
    169169        if (m_sheet && !isDisabled())
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r196010 r196080  
    921921    MediaEngineSupportParameters parameters;
    922922    ContentType contentType(mimeType);
    923     parameters.type = contentType.type().lower();
     923    parameters.type = contentType.type().convertToASCIILowercase();
    924924    parameters.codecs = contentType.parameter(ASCIILiteral("codecs"));
    925925    parameters.url = url;
     
    41774177            MediaEngineSupportParameters parameters;
    41784178            ContentType contentType(type);
    4179             parameters.type = contentType.type().lower();
     4179            parameters.type = contentType.type().convertToASCIILowercase();
    41804180            parameters.codecs = contentType.parameter(ASCIILiteral("codecs"));
    41814181            parameters.url = mediaURL;
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r195928 r196080  
    113113        formAttributeChanged();
    114114    else if (name == typeAttr) {
    115         m_serviceType = value.string().left(value.find(';')).lower();
     115        m_serviceType = value.string().left(value.find(';')).convertToASCIILowercase();
    116116        invalidateRenderer = !fastHasAttribute(classidAttr);
    117117        setNeedsWidgetUpdate(true);
  • trunk/Source/WebCore/html/HTMLTrackElement.cpp

    r192354 r196080  
    103103        // As the kind, label, and srclang attributes are set, changed, or removed, the text track must update accordingly...
    104104        } else if (name == kindAttr)
    105             track()->setKind(value.lower());
     105            track()->setKind(value.convertToASCIILowercase());
    106106        else if (name == labelAttr)
    107107            track()->setLabel(value);
     
    158158{
    159159    if (!m_track) {
    160         // The kind attribute is an enumerated attribute, limited only to know values. It defaults to 'subtitles' if missing or invalid.
    161         String kind = getAttribute(kindAttr).lower();
     160        // The kind attribute is an enumerated attribute, limited only to known values. It defaults to 'subtitles' if missing or invalid.
     161        String kind = fastGetAttribute(kindAttr).convertToASCIILowercase();
    162162        if (!TextTrack::isValidKindKeyword(kind))
    163163            kind = TextTrack::subtitlesKeyword();
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r195452 r196080  
    512512        const QualifiedName& name = *names[i];
    513513        const AtomicString& localName = name.localName();
    514         AtomicString loweredLocalName = localName.lower();
     514        AtomicString loweredLocalName = localName.convertToASCIILowercase();
    515515        if (loweredLocalName != localName)
    516516            map.add(loweredLocalName, name);
  • trunk/Source/WebCore/inspector/DOMPatchSupport.cpp

    r195520 r196080  
    137137
    138138    // Compose the new list.
    139     String markupCopy = markup.lower();
    140139    Vector<std::unique_ptr<Digest>> newList;
    141140    for (Node* child = parentNode->firstChild(); child != &node; child = child->nextSibling())
    142141        newList.append(createDigest(child, nullptr));
    143142    for (Node* child = fragment->firstChild(); child; child = child->nextSibling()) {
    144         if (child->hasTagName(headTag) && !child->firstChild() && markupCopy.find("</head>") == notFound)
     143        if (child->hasTagName(headTag) && !child->firstChild() && !markup.containsIgnoringASCIICase("</head>"))
    145144            continue; // HTML5 parser inserts empty <head> tag whenever it parses <body>
    146         if (child->hasTagName(bodyTag) && !child->firstChild() && markupCopy.find("</body>") == notFound)
     145        if (child->hasTagName(bodyTag) && !child->firstChild() && !markup.containsIgnoringASCIICase("</body>"))
    147146            continue; // HTML5 parser inserts empty <body> tag whenever it parses </head>
    148147        newList.append(createDigest(child, &m_unusedNodesMap));
     
    497496
    498497#ifdef DEBUG_DOM_PATCH_SUPPORT
     498
    499499static String nodeName(Node* node)
    500500{
    501501    if (node->document().isXHTMLDocument())
    502502         return node->nodeName();
    503     return node->nodeName().lower();
     503    return node->nodeName().convertToASCIILowercase();
    504504}
    505505
     
    510510        fprintf(stderr, "%s[%lu]: %s (%p) - [%lu]\n", name.utf8().data(), i, map[i].first ? nodeName(map[i].first->m_node).utf8().data() : "", map[i].first, map[i].second);
    511511}
     512
    512513#endif
    513514
  • trunk/Source/WebCore/inspector/InspectorOverlay.cpp

    r194496 r196080  
    710710    bool isXHTML = element.document().isXHTMLDocument();
    711711    auto elementData = Inspector::Protocol::OverlayTypes::ElementData::create()
    712         .setTagName(isXHTML ? element.nodeName() : element.nodeName().lower())
     712        .setTagName(isXHTML ? element.nodeName() : element.nodeName().convertToASCIILowercase())
    713713        .setIdValue(element.getIdAttribute())
    714714        .release();
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r195452 r196080  
    124124    if (!textEncodingName.isEmpty())
    125125        decoder = TextResourceDecoder::create("text/plain", textEncodingName);
    126     else if (DOMImplementation::isXMLMIMEType(mimeType.lower())) {
     126    else if (DOMImplementation::isXMLMIMEType(mimeType)) {
    127127        decoder = TextResourceDecoder::create("application/xml");
    128128        decoder->useLenientXMLDecoding();
  • trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp

    r195293 r196080  
    351351{
    352352    // Custom properties are case-sensitive.
    353     if (name.length() > 2 && name.characterAt(0) == '-' && name.characterAt(1) == '-')
     353    if (name.startsWith("--"))
    354354        return name;
    355     return name.lower();
     355    return name.convertToASCIILowercase();
    356356}
    357357
     
    376376    for (int i = 0, size = m_style->length(); i < size; ++i) {
    377377        String name = m_style->item(i);
    378         String lowerName = lowercasePropertyName(name);
    379         if (sourcePropertyNames.contains(lowerName))
    380             continue;
    381         sourcePropertyNames.add(lowerName);
    382         result->append(InspectorStyleProperty(CSSPropertySourceData(name, m_style->getPropertyValue(name), !m_style->getPropertyPriority(name).isEmpty(), true, SourceRange()), false, false));
     378        if (sourcePropertyNames.add(lowercasePropertyName(name)))
     379            result->append(InspectorStyleProperty(CSSPropertySourceData(name, m_style->getPropertyValue(name), !m_style->getPropertyPriority(name).isEmpty(), true, SourceRange()), false, false));
    383380    }
    384381
     
    414411
    415412        RefPtr<Inspector::Protocol::CSS::CSSProperty> property = Inspector::Protocol::CSS::CSSProperty::create()
    416             .setName(name.lower())
     413            .setName(name.convertToASCIILowercase())
    417414            .setValue(propertyEntry.value)
    418415            .release();
  • trunk/Source/WebCore/inspector/NetworkResourcesData.cpp

    r195452 r196080  
    142142    if (!textEncodingName.isEmpty())
    143143        decoder = TextResourceDecoder::create("text/plain", textEncodingName);
    144     else if (DOMImplementation::isXMLMIMEType(mimeType.lower())) {
     144    else if (DOMImplementation::isXMLMIMEType(mimeType)) {
    145145        decoder = TextResourceDecoder::create("application/xml");
    146146        decoder->useLenientXMLDecoding();
  • trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp

    r195452 r196080  
    128128        }
    129129
    130         preflightRequest.setHTTPHeaderField(HTTPHeaderName::AccessControlRequestHeaders, headerBuffer.toString().lower());
     130        preflightRequest.setHTTPHeaderField(HTTPHeaderName::AccessControlRequestHeaders, headerBuffer.toString().convertToASCIILowercase());
    131131    }
    132132
  • trunk/Source/WebCore/loader/cache/CachedScript.cpp

    r194529 r196080  
    6767String CachedScript::mimeType() const
    6868{
    69     return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)).lower();
     69    return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)).convertToASCIILowercase();
    7070}
    7171
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r196010 r196080  
    594594        return languageCode;
    595595
    596     String lowercaseLanguageCode = languageCode.lower();
     596    String lowercaseLanguageCode = languageCode.convertToASCIILowercase();
    597597
    598598    // Need 2U here to disambiguate String::operator[] from operator(NSString*, int)[] in a production build.
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r195694 r196080  
    22182218    }
    22192219
    2220     WindowFeatures windowFeatures(windowFeaturesString);
    2221     RefPtr<Frame> result = createWindow(urlString, frameName, windowFeatures, activeWindow, *firstFrame, *m_frame);
     2220    RefPtr<Frame> result = createWindow(urlString, frameName, parseWindowFeatures(windowFeaturesString), activeWindow, *firstFrame, *m_frame);
    22222221    return result ? result->document()->domWindow() : nullptr;
    22232222}
     
    22462245        return;
    22472246
    2248     WindowFeatures windowFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view()));
    2249     RefPtr<Frame> dialogFrame = createWindow(urlString, emptyAtom, windowFeatures, activeWindow, *firstFrame, *m_frame, WTFMove(prepareDialogFunction));
     2247    RefPtr<Frame> dialogFrame = createWindow(urlString, emptyAtom, parseDialogFeatures(dialogFeaturesString, screenAvailableRect(m_frame->view())), activeWindow, *firstFrame, *m_frame, WTFMove(prepareDialogFunction));
    22502248    if (!dialogFrame)
    22512249        return;
  • trunk/Source/WebCore/page/EventHandler.cpp

    r195659 r196080  
    21672167    Element* element = is<Element>(*target) ? downcast<Element>(target) : target->parentElement();
    21682168    for (; element; element = element->parentElement()) {
     2169        SpaceSplitString keywords(element->fastGetAttribute(webkitdropzoneAttr), true);
    21692170        bool matched = false;
    2170         String dropZoneStr = element->fastGetAttribute(webkitdropzoneAttr);
    2171 
    2172         if (dropZoneStr.isEmpty())
    2173             continue;
    2174        
    2175         dropZoneStr = dropZoneStr.lower();
    2176        
    2177         SpaceSplitString keywords(dropZoneStr, false);
    2178         if (keywords.isEmpty())
    2179             continue;
    2180        
    21812171        DragOperation dragOperation = DragOperationNone;
    2182         for (unsigned int i = 0; i < keywords.size(); i++) {
     2172        for (unsigned i = 0, size = keywords.size(); i < size; ++i) {
    21832173            DragOperation op = convertDropZoneOperationToDragOperation(keywords[i]);
    21842174            if (op != DragOperationNone) {
     
    21872177            } else
    21882178                matched = matched || hasDropZoneType(*dataTransfer, keywords[i].string());
    2189 
    21902179            if (matched && dragOperation != DragOperationNone)
    21912180                break;
     
    29142903}
    29152904
    2916 bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
     2905bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& event)
    29172906{
    29182907    // FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
     
    29212910    // Firefox only matches an access key if Shift is not pressed, and does that case-insensitively.
    29222911    ASSERT(!(accessKeyModifiers() & PlatformEvent::ShiftKey));
    2923     if ((evt.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers())
    2924         return false;
    2925     String key = evt.unmodifiedText();
    2926     Element* elem = m_frame.document()->getElementByAccessKey(key.lower());
    2927     if (!elem)
    2928         return false;
    2929     elem->accessKeyAction(false);
     2912    if ((event.modifiers() & ~PlatformEvent::ShiftKey) != accessKeyModifiers())
     2913        return false;
     2914    Element* element = m_frame.document()->getElementByAccessKey(event.unmodifiedText());
     2915    if (!element)
     2916        return false;
     2917    element->accessKeyAction(false);
    29302918    return true;
    29312919}
  • trunk/Source/WebCore/page/OriginAccessEntry.cpp

    r95901 r196080  
    3737   
    3838OriginAccessEntry::OriginAccessEntry(const String& protocol, const String& host, SubdomainSetting subdomainSetting)
    39     : m_protocol(protocol.lower())
    40     , m_host(host.lower())
     39    : m_protocol(protocol.convertToASCIILowercase())
     40    , m_host(host.convertToASCIILowercase())
    4141    , m_subdomainSettings(subdomainSetting)
    4242{
     
    4949bool OriginAccessEntry::matchesOrigin(const SecurityOrigin& origin) const
    5050{
    51     ASSERT(origin.host() == origin.host().lower());
    52     ASSERT(origin.protocol() == origin.protocol().lower());
     51    ASSERT(origin.host() == origin.host().convertToASCIILowercase());
     52    ASSERT(origin.protocol() == origin.protocol().convertToASCIILowercase());
    5353
    5454    if (m_protocol != origin.protocol())
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r195452 r196080  
    9898        return true;
    9999
    100     // SchemeRegistry needs a lower case protocol because it uses HashMaps
    101     // that assume the scheme has already been canonicalized.
    102     String protocol = innerURL.protocol().lower();
    103 
    104     if (SchemeRegistry::shouldTreatURLSchemeAsNoAccess(protocol))
     100    if (SchemeRegistry::shouldTreatURLSchemeAsNoAccess(innerURL.protocol()))
    105101        return true;
    106102
     
    110106
    111107SecurityOrigin::SecurityOrigin(const URL& url)
    112     : m_protocol(url.protocol().isNull() ? emptyString() : url.protocol().lower())
    113     , m_host(url.host().isNull() ? emptyString() : url.host().lower())
     108    : m_protocol(url.protocol().isNull() ? emptyString() : url.protocol().convertToASCIILowercase())
     109    , m_host(url.host().isNull() ? emptyString() : url.host().convertToASCIILowercase())
    114110    , m_port(url.port())
    115111    , m_isUnique(false)
     
    204200{
    205201    m_domainWasSetInDOM = true;
    206     m_domain = newDomain.lower();
     202    m_domain = newDomain.convertToASCIILowercase();
    207203}
    208204
     
    355351        return true;
    356352
    357     String protocol = url.protocol().lower();
    358 
    359353    if (isFeedWithNestedProtocolInHTTPFamily(url))
    360354        return true;
     355
     356    String protocol = url.protocol();
    361357
    362358    if (SchemeRegistry::canDisplayOnlyIfCanRequest(protocol))
     
    364360
    365361    if (SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(protocol))
    366         return m_protocol == protocol || SecurityPolicy::isAccessToURLWhiteListed(this, url);
     362        return equalIgnoringASCIICase(m_protocol, protocol) || SecurityPolicy::isAccessToURLWhiteListed(this, url);
    367363
    368364    if (SecurityPolicy::restrictAccessToLocal() && SchemeRegistry::shouldTreatURLSchemeAsLocal(protocol))
  • trunk/Source/WebCore/page/WindowFeatures.cpp

    r188386 r196080  
    2626#include "FloatRect.h"
    2727#include <wtf/Assertions.h>
     28#include <wtf/HashMap.h>
    2829#include <wtf/MathExtras.h>
    2930#include <wtf/text/StringHash.h>
     
    3132namespace WebCore {
    3233
    33 // Though isspace() considers \t and \v to be whitespace, Win IE doesn't when parsing window features.
    34 static bool isWindowFeaturesSeparator(UChar c)
    35 {
    36     return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == ',' || c == '\0';
    37 }
    38 
    39 WindowFeatures::WindowFeatures(const String& features)
    40     : resizable(true)
    41     , fullscreen(false)
    42     , dialog(false)
    43 {
    44     /*
    45      The IE rule is: all features except for channelmode and fullscreen default to YES, but
    46      if the user specifies a feature string, all features default to NO. (There is no public
    47      standard that applies to this method.)
    48 
    49      <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp>
    50      We always allow a window to be resized, which is consistent with Firefox.
    51      */
    52 
    53     if (features.isEmpty()) {
    54         menuBarVisible = true;
    55         statusBarVisible = true;
    56         toolBarVisible = true;
    57         locationBarVisible = true;
    58         scrollbarsVisible = true;
    59         return;
     34typedef HashMap<String, String, ASCIICaseInsensitiveHash> DialogFeaturesMap;
     35
     36static void setWindowFeature(WindowFeatures&, StringView key, StringView value);
     37
     38static DialogFeaturesMap parseDialogFeaturesMap(const String&);
     39static Optional<bool> boolFeature(const DialogFeaturesMap&, const char* key);
     40static Optional<float> floatFeature(const DialogFeaturesMap&, const char* key, float min, float max);
     41
     42static bool isSeparator(UChar character)
     43{
     44    return character == ' ' || character == '\t' || character == '\n' || character == '\r' || character == '=' || character == ',';
     45}
     46
     47WindowFeatures parseWindowFeatures(StringView featuresString)
     48{
     49    // The IE rule is: all features except for channelmode and fullscreen default to YES, but
     50    // if the user specifies a feature string, all features default to NO. (There is no public
     51    // standard that applies to this method.)
     52    //
     53    // <http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp>
     54    // We always allow a window to be resized, which is consistent with Firefox.
     55
     56    WindowFeatures features;
     57
     58    if (featuresString.isEmpty())
     59        return features;
     60
     61    features.menuBarVisible = false;
     62    features.statusBarVisible = false;
     63    features.toolBarVisible = false;
     64    features.locationBarVisible = false;
     65    features.scrollbarsVisible = false;
     66
     67    processFeaturesString(featuresString, [&features](StringView key, StringView value) {
     68        setWindowFeature(features, key, value);
     69    });
     70
     71    return features;
     72}
     73
     74void processFeaturesString(StringView features, std::function<void(StringView type, StringView value)> callback)
     75{
     76    unsigned length = features.length();
     77    for (unsigned i = 0; i < length; ) {
     78        // skip to first non-separator
     79        while (i < length && isSeparator(features[i]))
     80            ++i;
     81        unsigned keyBegin = i;
     82
     83        // skip to first separator
     84        while (i < length && !isSeparator(features[i]))
     85            i++;
     86        unsigned keyEnd = i;
     87
     88        // skip to first '=', but don't skip past a ','
     89        while (i < length && features[i] != '=' && features[i] != ',')
     90            ++i;
     91
     92        // skip to first non-separator, but don't skip past a ','
     93        while (i < length && isSeparator(features[i]) && features[i] != ',')
     94            ++i;
     95        unsigned valueBegin = i;
     96
     97        // skip to first separator
     98        while (i < length && !isSeparator(features[i]))
     99            ++i;
     100        unsigned valueEnd = i;
     101
     102        callback(features.substring(keyBegin, keyEnd - keyBegin), features.substring(valueBegin, valueEnd - valueBegin));
    60103    }
    61 
    62     menuBarVisible = false;
    63     statusBarVisible = false;
    64     toolBarVisible = false;
    65     locationBarVisible = false;
    66     scrollbarsVisible = false;
    67 
    68     // Tread lightly in this code -- it was specifically designed to mimic Win IE's parsing behavior.
    69     unsigned keyBegin, keyEnd;
    70     unsigned valueBegin, valueEnd;
    71 
    72     String buffer = features.lower();
    73     unsigned length = buffer.length();
    74     for (unsigned i = 0; i < length; ) {
    75         // skip to first non-separator, but don't skip past the end of the string
    76         while (isWindowFeaturesSeparator(buffer[i])) {
    77             if (i >= length)
    78                 break;
    79             i++;
    80         }
    81         keyBegin = i;
    82 
    83         // skip to first separator
    84         while (!isWindowFeaturesSeparator(buffer[i]))
    85             i++;
    86         keyEnd = i;
    87 
    88         // skip to first '=', but don't skip past a ',' or the end of the string
    89         while (buffer[i] != '=') {
    90             if (buffer[i] == ',' || i >= length)
    91                 break;
    92             i++;
    93         }
    94 
    95         // skip to first non-separator, but don't skip past a ',' or the end of the string
    96         while (isWindowFeaturesSeparator(buffer[i])) {
    97             if (buffer[i] == ',' || i >= length)
    98                 break;
    99             i++;
    100         }
    101         valueBegin = i;
    102 
    103         // skip to first separator
    104         while (!isWindowFeaturesSeparator(buffer[i]))
    105             i++;
    106         valueEnd = i;
    107 
    108         ASSERT_WITH_SECURITY_IMPLICATION(i <= length);
    109 
    110         String keyString(buffer.substring(keyBegin, keyEnd - keyBegin));
    111         String valueString(buffer.substring(valueBegin, valueEnd - valueBegin));
    112         setWindowFeature(keyString, valueString);
    113     }
    114 }
    115 
    116 void WindowFeatures::setWindowFeature(const String& keyString, const String& valueString)
    117 {
    118     int value;
    119 
     104}
     105
     106static void setWindowFeature(WindowFeatures& features, StringView key, StringView value)
     107{
    120108    // Listing a key with no value is shorthand for key=yes
    121     if (valueString.isEmpty() || valueString == "yes")
    122         value = 1;
     109    int numericValue;
     110    if (value.isEmpty() || equalLettersIgnoringASCIICase(value, "yes"))
     111        numericValue = 1;
    123112    else
    124         value = valueString.toInt();
    125 
    126     // We treat keyString of "resizable" here as an additional feature rather than setting resizeable to true.
     113        numericValue = value.toInt();
     114
     115    // We treat key of "resizable" here as an additional feature rather than setting resizeable to true.
    127116    // This is consistent with Firefox, but could also be handled at another level.
    128117
    129     if (keyString == "left" || keyString == "screenx")
    130         x = value;
    131     else if (keyString == "top" || keyString == "screeny")
    132         y = value;
    133     else if (keyString == "width" || keyString == "innerwidth")
    134         width = value;
    135     else if (keyString == "height" || keyString == "innerheight")
    136         height = value;
    137     else if (keyString == "menubar")
    138         menuBarVisible = value;
    139     else if (keyString == "toolbar")
    140         toolBarVisible = value;
    141     else if (keyString == "location")
    142         locationBarVisible = value;
    143     else if (keyString == "status")
    144         statusBarVisible = value;
    145     else if (keyString == "fullscreen")
    146         fullscreen = value;
    147     else if (keyString == "scrollbars")
    148         scrollbarsVisible = value;
    149     else if (value == 1)
    150         additionalFeatures.append(keyString);
    151 }
    152 
    153 WindowFeatures::WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect)
    154     : menuBarVisible(false)
    155     , toolBarVisible(false)
    156     , locationBarVisible(false)
    157     , fullscreen(false)
    158     , dialog(true)
    159 {
    160     auto features = parseDialogFeatures(dialogFeaturesString);
    161 
    162     const bool trusted = false;
     118    if (equalLettersIgnoringASCIICase(key, "left") || equalLettersIgnoringASCIICase(key, "screenx"))
     119        features.x = numericValue;
     120    else if (equalLettersIgnoringASCIICase(key, "top") || equalLettersIgnoringASCIICase(key, "screeny"))
     121        features.y = numericValue;
     122    else if (equalLettersIgnoringASCIICase(key, "width") || equalLettersIgnoringASCIICase(key, "innerwidth"))
     123        features.width = numericValue;
     124    else if (equalLettersIgnoringASCIICase(key, "height") || equalLettersIgnoringASCIICase(key, "innerheight"))
     125        features.height = numericValue;
     126    else if (equalLettersIgnoringASCIICase(key, "menubar"))
     127        features.menuBarVisible = numericValue;
     128    else if (equalLettersIgnoringASCIICase(key, "toolbar"))
     129        features.toolBarVisible = numericValue;
     130    else if (equalLettersIgnoringASCIICase(key, "location"))
     131        features.locationBarVisible = numericValue;
     132    else if (equalLettersIgnoringASCIICase(key, "status"))
     133        features.statusBarVisible = numericValue;
     134    else if (equalLettersIgnoringASCIICase(key, "fullscreen"))
     135        features.fullscreen = numericValue;
     136    else if (equalLettersIgnoringASCIICase(key, "scrollbars"))
     137        features.scrollbarsVisible = numericValue;
     138    else if (numericValue == 1)
     139        features.additionalFeatures.append(key.toString());
     140}
     141
     142WindowFeatures parseDialogFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect)
     143{
     144    auto featuresMap = parseDialogFeaturesMap(dialogFeaturesString);
    163145
    164146    // The following features from Microsoft's documentation are not implemented:
     
    170152    // - unadorned: trusted && boolFeature(features, "unadorned");
    171153
    172     width = floatFeature(features, "dialogwidth", 100, screenAvailableRect.width(), 620); // default here came from frame size of dialog in MacIE
    173     height = floatFeature(features, "dialogheight", 100, screenAvailableRect.height(), 450); // default here came from frame size of dialog in MacIE
    174 
    175     auto dialogLeft = floatFeature(features, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - *width, -1);
    176     if (dialogLeft > 0)
    177         x = dialogLeft;
    178 
    179     auto dialogTop = floatFeature(features, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - *height, -1);
    180     if (dialogTop > 0)
    181         y = dialogTop;
    182 
    183     if (boolFeature(features, "center", true)) {
    184         if (!x)
    185             x = screenAvailableRect.x() + (screenAvailableRect.width() - *width) / 2;
    186 
    187         if (!y)
    188             y = screenAvailableRect.y() + (screenAvailableRect.height() - *height) / 2;
     154    WindowFeatures features;
     155
     156    features.menuBarVisible = false;
     157    features.toolBarVisible = false;
     158    features.locationBarVisible = false;
     159    features.dialog = true;
     160
     161    float width = floatFeature(featuresMap, "dialogwidth", 100, screenAvailableRect.width()).valueOr(620); // default here came from frame size of dialog in MacIE
     162    float height = floatFeature(featuresMap, "dialogheight", 100, screenAvailableRect.height()).valueOr(450); // default here came from frame size of dialog in MacIE
     163
     164    features.width = width;
     165    features.height = height;
     166
     167    features.x = floatFeature(featuresMap, "dialogleft", screenAvailableRect.x(), screenAvailableRect.maxX() - width);
     168    features.y = floatFeature(featuresMap, "dialogtop", screenAvailableRect.y(), screenAvailableRect.maxY() - height);
     169
     170    if (boolFeature(featuresMap, "center").valueOr(true)) {
     171        if (!features.x)
     172            features.x = screenAvailableRect.x() + (screenAvailableRect.width() - width) / 2;
     173        if (!features.y)
     174            features.y = screenAvailableRect.y() + (screenAvailableRect.height() - height) / 2;
    189175    }
    190176
    191     resizable = boolFeature(features, "resizable");
    192     scrollbarsVisible = boolFeature(features, "scroll", true);
    193     statusBarVisible = boolFeature(features, "status", !trusted);
    194 }
    195 
    196 bool WindowFeatures::boolFeature(const HashMap<String, String>& features, const char* key, bool defaultValue)
     177    features.resizable = boolFeature(featuresMap, "resizable").valueOr(false);
     178    features.scrollbarsVisible = boolFeature(featuresMap, "scroll").valueOr(true);
     179    features.statusBarVisible = boolFeature(featuresMap, "status").valueOr(false);
     180
     181    return features;
     182}
     183
     184static Optional<bool> boolFeature(const DialogFeaturesMap& features, const char* key)
    197185{
    198186    auto it = features.find(key);
    199187    if (it == features.end())
    200         return defaultValue;
    201 
    202     const String& value = it->value;
    203     return value.isNull() || value == "1" || value == "yes" || value == "on";
    204 }
    205 
    206 float WindowFeatures::floatFeature(const HashMap<String, String>& features, const char* key, float min, float max, float defaultValue)
     188        return Nullopt;
     189
     190    auto& value = it->value;
     191    return value.isNull()
     192        || value == "1"
     193        || equalLettersIgnoringASCIICase(value, "yes")
     194        || equalLettersIgnoringASCIICase(value, "on");
     195}
     196
     197static Optional<float> floatFeature(const DialogFeaturesMap& features, const char* key, float min, float max)
    207198{
    208199    auto it = features.find(key);
    209200    if (it == features.end())
    210         return defaultValue;
     201        return Nullopt;
    211202
    212203    // FIXME: The toDouble function does not offer a way to tell "0q" from string with no digits in it: Both
     
    215206    double parsedNumber = it->value.toDouble(&ok);
    216207    if ((!parsedNumber && !ok) || std::isnan(parsedNumber))
    217         return defaultValue;
     208        return Nullopt;
    218209    if (parsedNumber < min || max <= min)
    219210        return min;
     
    225216}
    226217
    227 HashMap<String, String> WindowFeatures::parseDialogFeatures(const String& string)
    228 {
    229     HashMap<String, String> features;
     218static DialogFeaturesMap parseDialogFeaturesMap(const String& string)
     219{
     220    // FIXME: Not clear why we take such a different approach to parsing dialog features
     221    // as opposed to window features (using a map, different parsing quirks).
     222
     223    DialogFeaturesMap features;
    230224
    231225    Vector<String> vector;
     
    240234            separatorPosition = colonPosition;
    241235
    242         String key = featureString.left(separatorPosition).stripWhiteSpace().lower();
     236        String key = featureString.left(separatorPosition).stripWhiteSpace();
    243237
    244238        // Null string for value indicates key without value.
    245239        String value;
    246240        if (separatorPosition != notFound) {
    247             value = featureString.substring(separatorPosition + 1).stripWhiteSpace().lower();
     241            value = featureString.substring(separatorPosition + 1).stripWhiteSpace();
    248242            value = value.left(value.find(' '));
    249243        }
  • trunk/Source/WebCore/page/WindowFeatures.h

    r188386 r196080  
    11/*
    2  * Copyright (C) 2003, 2007, 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2003, 2007, 2010, 2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#define WindowFeatures_h
    3131
    32 #include <wtf/Forward.h>
    33 #include <wtf/HashMap.h>
     32#include <functional>
    3433#include <wtf/Optional.h>
    3534#include <wtf/Vector.h>
    36 #include <wtf/text/StringHash.h>
     35#include <wtf/text/WTFString.h>
    3736
    3837namespace WebCore {
     
    4140
    4241struct WindowFeatures {
    43     WindowFeatures()
    44         : menuBarVisible(true)
    45         , statusBarVisible(true)
    46         , toolBarVisible(true)
    47         , locationBarVisible(true)
    48         , scrollbarsVisible(true)
    49         , resizable(true)
    50         , fullscreen(false)
    51         , dialog(false)
    52     {
    53     }
    54     explicit WindowFeatures(const String& windowFeaturesString);
    55     WindowFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect);
    56 
    5742    Optional<float> x;
    5843    Optional<float> y;
     
    6045    Optional<float> height;
    6146
    62     bool menuBarVisible;
    63     bool statusBarVisible;
    64     bool toolBarVisible;
    65     bool locationBarVisible;
    66     bool scrollbarsVisible;
    67     bool resizable;
     47    bool menuBarVisible { true };
     48    bool statusBarVisible { true };
     49    bool toolBarVisible { true };
     50    bool locationBarVisible { true };
     51    bool scrollbarsVisible { true };
     52    bool resizable { true };
    6853
    69     bool fullscreen;
    70     bool dialog;
     54    bool fullscreen { false };
     55    bool dialog { false };
    7156
    7257    Vector<String> additionalFeatures;
     58};
    7359
    74 private:
    75     static HashMap<String, String> parseDialogFeatures(const String&);
    76     static bool boolFeature(const HashMap<String, String>&, const char* key, bool defaultValue = false);
    77     static float floatFeature(const HashMap<String, String>&, const char* key, float min, float max, float defaultValue);
    78     void setWindowFeature(const String& keyString, const String& valueString);
    79 };
     60WindowFeatures parseWindowFeatures(StringView windowFeaturesString);
     61WindowFeatures parseDialogFeatures(const String& dialogFeaturesString, const FloatRect& screenAvailableRect);
     62
     63void processFeaturesString(StringView features, std::function<void(StringView type, StringView value)> callback);
    8064
    8165} // namespace WebCore
  • trunk/Source/WebCore/platform/SchemeRegistry.cpp

    r195951 r196080  
    127127void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
    128128{
    129     if (scheme == "file")
     129    if (equalLettersIgnoringASCIICase(scheme, "file"))
    130130        return;
    131131#if PLATFORM(COCOA)
    132     if (scheme == "applewebdata")
     132    if (equalLettersIgnoringASCIICase(scheme, "applewebdata"))
    133133        return;
    134134#endif
  • trunk/Source/WebCore/platform/efl/MIMETypeRegistryEfl.cpp

    r187206 r196080  
    3131#include "config.h"
    3232#include "MIMETypeRegistry.h"
    33 
    34 #include "NotImplemented.h"
    35 #include <wtf/Assertions.h>
    36 #include <wtf/MainThread.h>
    3733
    3834namespace WebCore {
     
    7571    { "wml", "text/vnd.wap.wml" },
    7672    { "wmlc", "application/vnd.wap.wmlc" },
    77     { 0, 0 }
    7873};
    7974
    80 String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
     75String MIMETypeRegistry::getMIMETypeForExtension(const String& extension)
    8176{
    82     ASSERT(isMainThread());
    83 
    84     String s = ext.lower();
    85     const ExtensionMap *e = extensionMap;
    86     while (e->extension) {
    87         if (s == e->extension)
    88             return e->mimeType;
    89         ++e;
     77    for (auto& entry : extensionMap) {
     78        if (equalIgnoringASCIICase(extension, entry.extension))
     79            return entry.mimeType;
    9080    }
    91 
    9281    return String();
    9382}
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r195951 r196080  
    325325    ASSERT(!m_reloadTimer.isActive());
    326326
    327     m_contentMIMEType = contentType.type().lower();
     327    m_contentMIMEType = contentType.type().convertToASCIILowercase();
    328328    m_contentTypeCodecs = contentType.parameter(codecs());
    329329    m_url = url;
    330     m_keySystem = keySystem.lower();
     330    m_keySystem = keySystem.convertToASCIILowercase();
    331331    m_contentMIMETypeWasInferredFromExtension = false;
    332332
     
    367367
    368368    m_mediaSource = mediaSource;
    369     m_contentMIMEType = contentType.type().lower();
     369    m_contentMIMEType = contentType.type().convertToASCIILowercase();
    370370    m_contentTypeCodecs = contentType.parameter(codecs());
    371371    m_url = url;
     
    518518MediaPlayer::MediaKeyException MediaPlayer::generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength)
    519519{
    520     return m_private->generateKeyRequest(keySystem.lower(), initData, initDataLength);
     520    return m_private->generateKeyRequest(keySystem.convertToASCIILowercase(), initData, initDataLength);
    521521}
    522522
    523523MediaPlayer::MediaKeyException MediaPlayer::addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId)
    524524{
    525     return m_private->addKey(keySystem.lower(), key, keyLength, initData, initDataLength, sessionId);
     525    return m_private->addKey(keySystem.convertToASCIILowercase(), key, keyLength, initData, initDataLength, sessionId);
    526526}
    527527
    528528MediaPlayer::MediaKeyException MediaPlayer::cancelKeyRequest(const String& keySystem, const String& sessionId)
    529529{
    530     return m_private->cancelKeyRequest(keySystem.lower(), sessionId);
     530    return m_private->cancelKeyRequest(keySystem.convertToASCIILowercase(), sessionId);
    531531}
    532532#endif
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp

    r196039 r196080  
    6666
    6767    Vector<String> vendorComponents;
    68     m_vendor.lower().split(' ', vendorComponents);
     68    m_vendor.convertToASCIILowercase().split(' ', vendorComponents);
    6969    if (vendorComponents.contains("nvidia"))
    7070        m_isNVIDIA = true;
  • trunk/Source/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp

    r186581 r196080  
    2828#include "config.h"
    2929#include "MIMETypeRegistry.h"
    30 
    31 #include <wtf/Assertions.h>
    32 #include <wtf/MainThread.h>
    3330
    3431namespace WebCore {
     
    6259    { "wml", "text/vnd.wap.wml" },
    6360    { "wmlc", "application/vnd.wap.wmlc" },
    64     { 0, 0 }
    6561};
    6662
    67 String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
     63String MIMETypeRegistry::getMIMETypeForExtension(const String& extension)
    6864{
    69     ASSERT(isMainThread());
    70 
    71     String s = ext.lower();
    72     const ExtensionMap *e = extensionMap;
    73     while (e->extension) {
    74         if (s == e->extension)
    75             return e->mimeType;
    76         ++e;
     65    for (auto& entry : extensionMap) {
     66        if (equalIgnoringASCIICase(extension, entry.extension))
     67            return entry.mimeType;
    7768    }
    78 
    7969    return String();
    8070}
  • trunk/Source/WebCore/platform/mac/PasteboardMac.mm

    r195452 r196080  
    418418{
    419419    // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dom-datatransfer-setdata
    420     String qType = type.lower();
    421 
    422     if (qType == "text")
    423         qType = ASCIILiteral("text/plain");
    424     if (qType == "url")
    425         qType = ASCIILiteral("text/uri-list");
    426 
    427     // Ignore any trailing charset - JS strings are Unicode, which encapsulates the charset issue
    428     if (qType == "text/plain" || qType.startsWith("text/plain;"))
    429         return String(NSStringPboardType);
    430     if (qType == "text/uri-list")
    431         // special case because UTI doesn't work with Cocoa's URL type
    432         return String(NSURLPboardType); // note special case in getData to read NSFilenamesType
    433 
    434     // Blacklist types that might contain subframe information
    435     if (qType == "text/rtf" || qType == "public.rtf" || qType == "com.apple.traditional-mac-plain-text")
     420    String lowercasedType = type.convertToASCIILowercase();
     421
     422    if (lowercasedType == "text")
     423        lowercasedType = ASCIILiteral("text/plain");
     424    if (lowercasedType == "url")
     425        lowercasedType = ASCIILiteral("text/uri-list");
     426
     427    // Ignore any trailing charset - strings are already UTF-16, and the charset issue has already been dealt with.
     428    if (lowercasedType == "text/plain" || lowercasedType.startsWith("text/plain;"))
     429        return NSStringPboardType;
     430    if (lowercasedType == "text/uri-list") {
     431        // Special case because UTI doesn't work with Cocoa's URL type.
     432        return NSURLPboardType;
     433    }
     434
     435    // Blacklist types that might contain subframe information.
     436    if (lowercasedType == "text/rtf" || lowercasedType == "public.rtf" || lowercasedType == "com.apple.traditional-mac-plain-text")
    436437        return String();
    437438
    438     // Try UTI now
    439     String mimeType = qType;
    440     if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType.createCFString().get(), NULL))) {
    441         RetainPtr<CFStringRef> pbType = adoptCF(UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType));
    442         if (pbType)
     439    if (auto utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, lowercasedType.createCFString().get(), NULL))) {
     440        if (auto pbType = adoptCF(UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType)))
    443441            return pbType.get();
    444442    }
    445443
    446444    // No mapping, just pass the whole string though
    447     return qType;
     445    return lowercasedType;
    448446}
    449447
Note: See TracChangeset for help on using the changeset viewer.