Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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:


Canonical link: https://commits.webkit.org/143741@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160572 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
weinig committed Dec 13, 2013
1 parent dd37b34 commit b5fc3c6
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 48 deletions.
28 changes: 28 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,31 @@
2013-12-13 Sam Weinig <sam@webkit.org>

[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:

2013-12-13 Enrica Casucci <enrica@apple.com>

WK2: Add support for inline candidates on iOS.
Expand Down
7 changes: 1 addition & 6 deletions Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
Expand Up @@ -164,11 +164,6 @@
return true;
}

static NSString* nsString(const String& string)
{
return string.impl() ? [NSString stringWithCharacters:reinterpret_cast<const UniChar*>(string.characters()) length:string.length()] : @"";
}

void ArgumentCoder<ResourceError>::encodePlatformData(ArgumentEncoder& encoder, const ResourceError& resourceError)
{
bool errorIsNull = resourceError.isNull();
Expand Down Expand Up @@ -241,7 +236,7 @@
CFDictionarySetValue((CFMutableDictionaryRef)userInfo.get(), CFSTR("NSErrorPeerCertificateChainKey"), (CFArrayRef)certificate.certificateChain());
}

RetainPtr<NSError> nsError = adoptNS([[NSError alloc] initWithDomain:nsString(domain) code:code userInfo:(NSDictionary *)userInfo.get()]);
RetainPtr<NSError> nsError = adoptNS([[NSError alloc] initWithDomain:domain code:code userInfo:(NSDictionary *)userInfo.get()]);

resourceError = ResourceError(nsError.get());
return true;
Expand Down
7 changes: 1 addition & 6 deletions Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
Expand Up @@ -176,11 +176,6 @@ PluginModuleLoadPolicy PluginInfoStore::defaultLoadPolicyForPlugin(const PluginM
{
return PluginModuleLoadNormally;
}

String PluginInfoStore::getMIMETypeForExtension(const String& extension)
{
return MIMETypeRegistry::getMIMETypeForExtension(extension);
}

PluginModuleInfo PluginInfoStore::findPluginWithBundleIdentifier(const String&)
{
Expand Down Expand Up @@ -209,7 +204,7 @@ PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const URL& url, P
return plugin;

// Finally, try to get the MIME type from the extension in a platform specific manner and use that.
String extensionMimeType = getMIMETypeForExtension(extension);
String extensionMimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
if (!extensionMimeType.isNull()) {
PluginModuleInfo plugin = findPluginForMIMEType(extensionMimeType, allowedPluginTypes);
if (!plugin.path.isNull()) {
Expand Down
3 changes: 0 additions & 3 deletions Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
Expand Up @@ -100,9 +100,6 @@ class PluginInfoStore {
// Return whether this plug-in should be used (added to the list of plug-ins) or not.
static bool shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo&);

// Get the MIME type for the given extension.
static String getMIMETypeForExtension(const String& extension);

Vector<String> m_additionalPluginsDirectories;
Vector<PluginModuleInfo> m_plugins;
bool m_pluginListIsUpToDate;
Expand Down
20 changes: 1 addition & 19 deletions Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
Expand Up @@ -47,20 +47,12 @@

return pluginsDirectories;
}

// FIXME: Once the UI process knows the difference between the main thread and the web thread we can drop this and just use
// String::createCFString.
static CFStringRef safeCreateCFString(const String& string)
{
return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length());
}

Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
{
Vector<String> pluginPaths;

RetainPtr<CFStringRef> directoryCFString = adoptCF(safeCreateCFString(directory));

RetainPtr<CFStringRef> directoryCFString = directory.createCFString();
NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:(NSString *)directoryCFString.get() error:nil];
for (NSString *filename in filenames)
pluginPaths.append([(NSString *)directoryCFString.get() stringByAppendingPathComponent:filename]);
Expand Down Expand Up @@ -113,16 +105,6 @@ static bool shouldBlockPlugin(const PluginModuleInfo& plugin)
return PluginModuleLoadNormally;
}

String PluginInfoStore::getMIMETypeForExtension(const String& extension)
{
// FIXME: This should just call MIMETypeRegistry::getMIMETypeForExtension and be
// strength reduced into the callsite once we can safely convert String
// to CFStringRef off the main thread.

RetainPtr<CFStringRef> extensionCFString = adoptCF(safeCreateCFString(extension));
return WKGetMIMETypeForExtension((NSString *)extensionCFString.get());
}

PluginModuleInfo PluginInfoStore::findPluginWithBundleIdentifier(const String& bundleIdentifier)
{
loadPluginsIfNecessary();
Expand Down
7 changes: 1 addition & 6 deletions Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
Expand Up @@ -33,14 +33,9 @@

namespace WebKit {

static RetainPtr<CFStringRef> cfStringFromWebCoreString(const String& string)
{
return RetainPtr<CFStringRef> = adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length()));
}

static inline RetainPtr<CFStringRef> makeKey(const String& identifier, const String& baseKey)
{
return cfStringFromWebCoreString(makeString(identifier, ".WebKit2", baseKey));
return makeString(identifier, ".WebKit2", baseKey).createCFString();
}

static void setStringValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store)
Expand Down
Expand Up @@ -55,7 +55,7 @@ - (CFBundleRef)_cfBundle;
m_sandboxExtension = 0;
}

RetainPtr<CFStringRef> injectedBundlePathStr = adoptCF(CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(m_path.characters()), m_path.length()));
RetainPtr<CFStringRef> injectedBundlePathStr = m_path.createCFString();
if (!injectedBundlePathStr) {
WTFLogAlways("InjectedBundle::load failed - Could not create the path string.\n");
return false;
Expand Down
22 changes: 15 additions & 7 deletions Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Expand Up @@ -917,6 +917,17 @@ void WebPage::loadDataImpl(PassRefPtr<SharedBuffer> sharedBuffer, const String&
m_mainFrame->coreFrame()->loader().load(FrameLoadRequest(m_mainFrame->coreFrame(), request, substituteData));
}

void WebPage::loadString(const String& htmlString, const String& MIMEType, const URL& baseURL, const URL& unreachableURL, CoreIPC::MessageDecoder& decoder)
{
if (htmlString.is8Bit()) {
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters8()), htmlString.length() * sizeof(LChar));
loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-8"), baseURL, unreachableURL, decoder);
} else {
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters16()), htmlString.length() * sizeof(UChar));
loadDataImpl(sharedBuffer, MIMEType, ASCIILiteral("utf-16"), baseURL, unreachableURL, decoder);
}
}

void WebPage::loadData(const CoreIPC::DataReference& data, const String& MIMEType, const String& encodingName, const String& baseURLString, CoreIPC::MessageDecoder& decoder)
{
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(data.data()), data.size());
Expand All @@ -926,29 +937,26 @@ void WebPage::loadData(const CoreIPC::DataReference& data, const String& MIMETyp

void WebPage::loadHTMLString(const String& htmlString, const String& baseURLString, CoreIPC::MessageDecoder& decoder)
{
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar));
URL baseURL = baseURLString.isEmpty() ? blankURL() : URL(URL(), baseURLString);
loadDataImpl(sharedBuffer, "text/html", "utf-16", baseURL, URL(), decoder);
loadString(htmlString, ASCIILiteral("text/html"), baseURL, URL(), decoder);
}

void WebPage::loadAlternateHTMLString(const String& htmlString, const String& baseURLString, const String& unreachableURLString, CoreIPC::MessageDecoder& decoder)
{
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(htmlString.characters()), htmlString.length() * sizeof(UChar));
URL baseURL = baseURLString.isEmpty() ? blankURL() : URL(URL(), baseURLString);
URL unreachableURL = unreachableURLString.isEmpty() ? URL() : URL(URL(), unreachableURLString);
loadDataImpl(sharedBuffer, "text/html", "utf-16", baseURL, unreachableURL, decoder);
loadString(htmlString, ASCIILiteral("text/html"), baseURL, unreachableURL, decoder);
}

void WebPage::loadPlainTextString(const String& string, CoreIPC::MessageDecoder& decoder)
{
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(string.characters()), string.length() * sizeof(UChar));
loadDataImpl(sharedBuffer, "text/plain", "utf-16", blankURL(), URL(), decoder);
loadString(string, ASCIILiteral("text/plain"), blankURL(), URL(), decoder);
}

void WebPage::loadWebArchiveData(const CoreIPC::DataReference& webArchiveData, CoreIPC::MessageDecoder& decoder)
{
RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(webArchiveData.data()), webArchiveData.size() * sizeof(uint8_t));
loadDataImpl(sharedBuffer, "application/x-webarchive", "utf-16", blankURL(), URL(), decoder);
loadDataImpl(sharedBuffer, ASCIILiteral("application/x-webarchive"), ASCIILiteral("utf-16"), blankURL(), URL(), decoder);
}

void WebPage::linkClicked(const String& url, const WebMouseEvent& event)
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit2/WebProcess/WebPage/WebPage.h
Expand Up @@ -700,6 +700,7 @@ class WebPage : public API::ObjectImpl<API::Object::Type::BundlePage>, public Co
String sourceForFrame(WebFrame*);

void loadDataImpl(PassRefPtr<WebCore::SharedBuffer>, const String& MIMEType, const String& encodingName, const WebCore::URL& baseURL, const WebCore::URL& failingURL, CoreIPC::MessageDecoder&);
void loadString(const String&, const String& MIMEType, const WebCore::URL& baseURL, const WebCore::URL& failingURL, CoreIPC::MessageDecoder&);

bool platformHasLocalDataForURL(const WebCore::URL&);

Expand Down

0 comments on commit b5fc3c6

Please sign in to comment.