Changeset 160572 in webkit


Ignore:
Timestamp:
Dec 13, 2013 3:59:14 PM (10 years ago)
Author:
weinig@apple.com
Message:

[WK2] Start removing calls to String::characters()
https://bugs.webkit.org/show_bug.cgi?id=125699

Reviewed by Anders Carlsson.

  • Shared/mac/WebCoreArgumentCodersMac.mm:

(CoreIPC::::decodePlatformData):

  • UIProcess/Plugins/PluginInfoStore.cpp:

(WebKit::PluginInfoStore::defaultLoadPolicyForPlugin):
(WebKit::PluginInfoStore::findPlugin):

  • UIProcess/Plugins/PluginInfoStore.h:
  • UIProcess/Plugins/mac/PluginInfoStoreMac.mm:

(WebKit::PluginInfoStore::pluginsDirectories):
(WebKit::PluginInfoStore::pluginPathsInDirectory):

  • UIProcess/cf/WebPreferencesCF.cpp:

(WebKit::makeKey):

  • WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:

(WebKit::InjectedBundle::load):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::loadStringImpl):
(WebKit::WebPage::loadHTMLString):
(WebKit::WebPage::loadAlternateHTMLString):
(WebKit::WebPage::loadPlainTextString):
(WebKit::WebPage::loadWebArchiveData):

  • WebProcess/WebPage/WebPage.h:
Location:
trunk/Source/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160566 r160572  
     12013-12-13  Sam Weinig  <sam@webkit.org>
     2
     3        [WK2] Start removing calls to String::characters()
     4        https://bugs.webkit.org/show_bug.cgi?id=125699
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/mac/WebCoreArgumentCodersMac.mm:
     9        (CoreIPC::::decodePlatformData):
     10        * UIProcess/Plugins/PluginInfoStore.cpp:
     11        (WebKit::PluginInfoStore::defaultLoadPolicyForPlugin):
     12        (WebKit::PluginInfoStore::findPlugin):
     13        * UIProcess/Plugins/PluginInfoStore.h:
     14        * UIProcess/Plugins/mac/PluginInfoStoreMac.mm:
     15        (WebKit::PluginInfoStore::pluginsDirectories):
     16        (WebKit::PluginInfoStore::pluginPathsInDirectory):
     17        * UIProcess/cf/WebPreferencesCF.cpp:
     18        (WebKit::makeKey):
     19        * WebProcess/InjectedBundle/mac/InjectedBundleMac.mm:
     20        (WebKit::InjectedBundle::load):
     21        * WebProcess/WebPage/WebPage.cpp:
     22        (WebKit::WebPage::loadStringImpl):
     23        (WebKit::WebPage::loadHTMLString):
     24        (WebKit::WebPage::loadAlternateHTMLString):
     25        (WebKit::WebPage::loadPlainTextString):
     26        (WebKit::WebPage::loadWebArchiveData):
     27        * WebProcess/WebPage/WebPage.h:
     28
    1292013-12-13  Enrica Casucci  <enrica@apple.com>
    230
  • trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm

    r160487 r160572  
    165165}
    166166
    167 static NSString* nsString(const String& string)
    168 {
    169     return string.impl() ? [NSString stringWithCharacters:reinterpret_cast<const UniChar*>(string.characters()) length:string.length()] : @"";
    170 }
    171 
    172167void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError)
    173168{
     
    242237    }
    243238
    244     RetainPtr<NSError> nsError = adoptNS([[NSError alloc] initWithDomain:nsString(domain) code:code userInfo:(NSDictionary *)userInfo.get()]);
     239    RetainPtr<NSError> nsError = adoptNS([[NSError alloc] initWithDomain:domain code:code userInfo:(NSDictionary *)userInfo.get()]);
    245240
    246241    resourceError = ResourceError(nsError.get());
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp

    r156550 r160572  
    177177    return PluginModuleLoadNormally;
    178178}
    179 
    180 String PluginInfoStore::getMIMETypeForExtension(const String& extension)
    181 {
    182     return MIMETypeRegistry::getMIMETypeForExtension(extension);
    183 }
    184179   
    185180PluginModuleInfo PluginInfoStore::findPluginWithBundleIdentifier(const String&)
     
    210205       
    211206        // Finally, try to get the MIME type from the extension in a platform specific manner and use that.
    212         String extensionMimeType = getMIMETypeForExtension(extension);
     207        String extensionMimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
    213208        if (!extensionMimeType.isNull()) {
    214209            PluginModuleInfo plugin = findPluginForMIMEType(extensionMimeType, allowedPluginTypes);
  • trunk/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h

    r156550 r160572  
    101101    static bool shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo&);
    102102
    103     // Get the MIME type for the given extension.
    104     static String getMIMETypeForExtension(const String& extension);
    105 
    106103    Vector<String> m_additionalPluginsDirectories;
    107104    Vector<PluginModuleInfo> m_plugins;
  • trunk/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm

    r156598 r160572  
    4848    return pluginsDirectories;
    4949}
    50 
    51 // FIXME: Once the UI process knows the difference between the main thread and the web thread we can drop this and just use
    52 // String::createCFString.
    53 static CFStringRef safeCreateCFString(const String& string)
    54 {
    55     return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length());
    56 }
    5750   
    5851Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
     
    6053    Vector<String> pluginPaths;
    6154
    62     RetainPtr<CFStringRef> directoryCFString = adoptCF(safeCreateCFString(directory));
    63    
     55    RetainPtr<CFStringRef> directoryCFString = directory.createCFString();
    6456    NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:(NSString *)directoryCFString.get() error:nil];
    6557    for (NSString *filename in filenames)
     
    114106}
    115107
    116 String PluginInfoStore::getMIMETypeForExtension(const String& extension)
    117 {
    118     // FIXME: This should just call MIMETypeRegistry::getMIMETypeForExtension and be
    119     // strength reduced into the callsite once we can safely convert String
    120     // to CFStringRef off the main thread.
    121 
    122     RetainPtr<CFStringRef> extensionCFString = adoptCF(safeCreateCFString(extension));
    123     return WKGetMIMETypeForExtension((NSString *)extensionCFString.get());
    124 }
    125 
    126108PluginModuleInfo PluginInfoStore::findPluginWithBundleIdentifier(const String& bundleIdentifier)
    127109{
  • trunk/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp

    r149255 r160572  
    3434namespace WebKit {
    3535
    36 static RetainPtr<CFStringRef> cfStringFromWebCoreString(const String& string)
    37 {
    38     return RetainPtr<CFStringRef> = adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length()));
    39 }
    40 
    4136static inline RetainPtr<CFStringRef> makeKey(const String& identifier, const String& baseKey)
    4237{
    43     return cfStringFromWebCoreString(makeString(identifier, ".WebKit2", baseKey));
     38    return makeString(identifier, ".WebKit2", baseKey).createCFString();
    4439}
    4540
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/mac/InjectedBundleMac.mm

    r160291 r160572  
    5656    }
    5757   
    58     RetainPtr<CFStringRef> injectedBundlePathStr = adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(m_path.characters()), m_path.length()));
     58    RetainPtr<CFStringRef> injectedBundlePathStr = m_path.createCFString();
    5959    if (!injectedBundlePathStr) {
    6060        WTFLogAlways("InjectedBundle::load failed - Could not create the path string.\n");
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r160566 r160572  
    918918}
    919919
     920void WebPage::loadString(const String& htmlString, const String& MIMEType, const URL& baseURL, const URL& unreachableURL, CoreIPC::MessageDecoder& decoder)
     921{
     922    if (htmlString.is8Bit()) {
     923        RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters8()), htmlString.length() * sizeof(LChar));
     924        loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-8"), baseURL, unreachableURL, decoder);
     925    } else {
     926        RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters16()), htmlString.length() * sizeof(UChar));
     927        loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-16"), baseURL, unreachableURL, decoder);
     928    }
     929}
     930
    920931void WebPage::loadData(const CoreIPC::DataReference& data, const String& MIMEType, const String& encodingName, const String& baseURLString, CoreIPC::MessageDecoder& decoder)
    921932{
     
    927938void WebPage::loadHTMLString(const String& htmlString, const String& baseURLString, CoreIPC::MessageDecoder& decoder)
    928939{
    929     RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar));
    930940    URL baseURL = baseURLString.isEmpty() ? blankURL() : URL(URL(), baseURLString);
    931     loadDataImpl(sharedBuffer, "text/html", "utf-16", baseURL, URL(), decoder);
     941    loadString(htmlString, ASCIILiteral("text/html"), baseURL, URL(), decoder);
    932942}
    933943
    934944void WebPage::loadAlternateHTMLString(const String& htmlString, const String& baseURLString, const String& unreachableURLString, CoreIPC::MessageDecoder& decoder)
    935945{
    936     RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar));
    937946    URL baseURL = baseURLString.isEmpty() ? blankURL() : URL(URL(), baseURLString);
    938947    URL unreachableURL = unreachableURLString.isEmpty() ? URL() : URL(URL(), unreachableURLString);
    939     loadDataImpl(sharedBuffer, "text/html", "utf-16", baseURL, unreachableURL, decoder);
     948    loadString(htmlString, ASCIILiteral("text/html"), baseURL, unreachableURL, decoder);
    940949}
    941950
    942951void WebPage::loadPlainTextString(const String& string, CoreIPC::MessageDecoder& decoder)
    943952{
    944     RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar));
    945     loadDataImpl(sharedBuffer, "text/plain", "utf-16", blankURL(), URL(), decoder);
     953    loadString(string, ASCIILiteral("text/plain"), blankURL(), URL(), decoder);
    946954}
    947955
     
    949957{
    950958    RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(webArchiveData.data()), webArchiveData.size() * sizeof(uint8_t));
    951     loadDataImpl(sharedBuffer, "application/x-webarchive", "utf-16", blankURL(), URL(), decoder);
     959    loadDataImpl(sharedBuffer, ASCIILiteral("application/x-webarchive"), ASCIILiteral("utf-16"), blankURL(), URL(), decoder);
    952960}
    953961
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r160566 r160572  
    701701
    702702    void loadDataImpl(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::URL& baseURL, const WebCore::URL& failingURL, CoreIPC::MessageDecoder&);
     703    void loadString(const String&, const String& MIMEType, const WebCore::URL& baseURL, const WebCore::URL& failingURL, CoreIPC::MessageDecoder&);
    703704
    704705    bool platformHasLocalDataForURL(const WebCore::URL&);
Note: See TracChangeset for help on using the changeset viewer.