Bug 1390428 (part 2, attempt 2) - Remove more nsXPIDLCString local variables. r=erahm.

--HG--
extra : rebase_source : 69d58b0cfb56efc6b03d8e2d7be2ce3c3e6cd843
This commit is contained in:
Nicholas Nethercote 2017-08-21 20:01:27 +10:00
parent 6a1689dfaf
commit 8a72cf2251
36 changed files with 208 additions and 197 deletions

View File

@ -7132,12 +7132,12 @@ nsContentUtils::FindInternalContentViewer(const nsACString& aType,
nsCOMPtr<nsIDocumentLoaderFactory> docFactory;
nsXPIDLCString contractID;
nsCString contractID;
nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers",
PromiseFlatCString(aType).get(),
getter_Copies(contractID));
if (NS_SUCCEEDED(rv)) {
docFactory = do_GetService(contractID);
docFactory = do_GetService(contractID.get());
if (docFactory && aLoaderType) {
if (contractID.EqualsLiteral(CONTENT_DLF_CONTRACTID))
*aLoaderType = TYPE_CONTENT;

View File

@ -806,9 +806,9 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * aProto)
getter_AddRefs(if_info));
if (if_info) {
nsXPIDLCString name;
nsCString name;
if_info->GetName(getter_Copies(name));
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name), mData->mClass.name) == 0,
NS_ASSERTION(nsCRT::strcmp(CutPrefix(name.get()), mData->mClass.name) == 0,
"Class name and proto chain interface name mismatch!");
}
}
@ -959,11 +959,11 @@ DefineInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *
JS::Rooted<JS::Value> v(cx);
for (i = parent_constant_count; i < constant_count; i++) {
nsXPIDLCString name;
nsCString name;
rv = if_info->GetConstant(i, &v, getter_Copies(name));
NS_ENSURE_TRUE(NS_SUCCEEDED(rv), rv);
if (!::JS_DefineProperty(cx, obj, name, v,
if (!::JS_DefineProperty(cx, obj, name.get(), v,
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT,
JS_STUBGETTER, JS_STUBSETTER)) {
return NS_ERROR_UNEXPECTED;

View File

@ -1007,12 +1007,12 @@ nsExternalResourceMap::PendingLoad::SetupViewer(nsIRequest* aRequest,
nsCOMPtr<nsICategoryManager> catMan =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
NS_ENSURE_TRUE(catMan, NS_ERROR_NOT_AVAILABLE);
nsXPIDLCString contractId;
nsCString contractId;
nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", type.get(),
getter_Copies(contractId));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
do_GetService(contractId);
do_GetService(contractId.get());
NS_ENSURE_TRUE(docLoaderFactory, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIContentViewer> viewer;

View File

@ -315,7 +315,7 @@ nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategory
return NS_OK;
}
nsXPIDLCString contractId;
nsCString contractId;
rv = aCategoryManager->GetCategoryEntry(aCategory, categoryEntry.get(),
getter_Copies(contractId));
NS_ENSURE_SUCCESS(rv, rv);
@ -325,7 +325,7 @@ nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategory
NS_ENSURE_SUCCESS(rv, rv);
nsCID *cidPtr;
rv = registrar->ContractIDToCID(contractId, &cidPtr);
rv = registrar->ContractIDToCID(contractId.get(), &cidPtr);
if (NS_FAILED(rv)) {
NS_WARNING("Bad contract id registed with the script namespace manager");

View File

@ -2708,11 +2708,11 @@ nsPluginHost::RegisterWithCategoryManager(const nsCString& aMimeType,
}
// Only delete the entry if a plugin registered for it
nsXPIDLCString value;
nsCString value;
nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers",
aMimeType.get(),
getter_Copies(value));
if (NS_SUCCEEDED(rv) && strcmp(value, contractId) == 0) {
if (NS_SUCCEEDED(rv) && strcmp(value.get(), contractId) == 0) {
catMan->DeleteCategoryEntry("Gecko-Content-Viewers",
aMimeType.get(),
true);

View File

@ -313,14 +313,14 @@ PushDispatcher::DoNotifyObservers(nsISupports *aSubject, const char *aTopic,
nsCOMPtr<nsICategoryManager> catMan =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
if (catMan) {
nsXPIDLCString contractId;
nsCString contractId;
nsresult rv = catMan->GetCategoryEntry("push",
mScope.BeginReading(),
getter_Copies(contractId));
if (NS_SUCCEEDED(rv)) {
// Ensure the service is created - we don't need to do anything with
// it though - we assume the service constructor attaches a listener.
nsCOMPtr<nsISupports> service = do_GetService(contractId);
nsCOMPtr<nsISupports> service = do_GetService(contractId.get());
}
}
return obsService->NotifyObservers(aSubject, aTopic,

View File

@ -116,8 +116,8 @@ NS_IMETHODIMP nsReadConfig::Observe(nsISupports *aSubject, const char *aTopic, c
nsresult nsReadConfig::readConfigFile()
{
nsresult rv = NS_OK;
nsXPIDLCString lockFileName;
nsXPIDLCString lockVendor;
nsCString lockFileName;
nsCString lockVendor;
uint32_t fileNameLen = 0;
nsCOMPtr<nsIPrefBranch> defaultPrefBranch;
@ -193,18 +193,18 @@ nsresult nsReadConfig::readConfigFile()
// If vendor is not nullptr, do this check
if (NS_SUCCEEDED(rv)) {
fileNameLen = strlen(lockFileName);
fileNameLen = strlen(lockFileName.get());
// lockVendor and lockFileName should be the same with the addtion of
// .cfg to the filename by checking this post reading of the cfg file
// this value can be set within the cfg file adding a level of security.
if (PL_strncmp(lockFileName, lockVendor, fileNameLen - 4) != 0)
if (PL_strncmp(lockFileName.get(), lockVendor.get(), fileNameLen - 4) != 0)
return NS_ERROR_FAILURE;
}
// get the value of the autoconfig url
nsXPIDLCString urlName;
nsCString urlName;
rv = prefBranch->GetCharPref("autoadmin.global_config_url",
getter_Copies(urlName));
if (NS_SUCCEEDED(rv) && !urlName.IsEmpty()) {
@ -214,7 +214,7 @@ nsresult nsReadConfig::readConfigFile()
if (NS_FAILED(rv))
return NS_ERROR_OUT_OF_MEMORY;
rv = mAutoConfig->SetConfigURL(urlName);
rv = mAutoConfig->SetConfigURL(urlName.get());
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;

View File

@ -136,11 +136,12 @@ nsresult
gfxSVGGlyphsDocument::SetupPresentation()
{
nsCOMPtr<nsICategoryManager> catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
nsXPIDLCString contractId;
nsCString contractId;
nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "image/svg+xml", getter_Copies(contractId));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory = do_GetService(contractId);
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
do_GetService(contractId.get());
NS_ASSERTION(docLoaderFactory, "Couldn't get DocumentLoaderFactory");
nsCOMPtr<nsIContentViewer> viewer;

View File

@ -331,12 +331,12 @@ SVGDocumentWrapper::SetupViewer(nsIRequest* aRequest,
nsCOMPtr<nsICategoryManager> catMan =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
NS_ENSURE_TRUE(catMan, NS_ERROR_NOT_AVAILABLE);
nsXPIDLCString contractId;
nsCString contractId;
nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", IMAGE_SVG_XML,
getter_Copies(contractId));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
do_GetService(contractId);
do_GetService(contractId.get());
NS_ENSURE_TRUE(docLoaderFactory, NS_ERROR_NOT_AVAILABLE);
nsCOMPtr<nsIContentViewer> viewer;

View File

@ -670,7 +670,7 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
nsresult rv;
uint32_t i, argCount = 0;
nsCOMPtr<nsIStringBundle> bundle;
nsXPIDLCString stringBundleURL;
nsCString stringBundleURL;
// XXX hack for mailnews who has already formatted their messages:
if (aStatus == NS_OK && aStatusArg) {
@ -713,7 +713,7 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
rv = mErrorService->GetErrorStringBundle(NS_ERROR_GET_MODULE(aStatus),
getter_Copies(stringBundleURL));
if (NS_SUCCEEDED(rv)) {
getStringBundle(stringBundleURL, getter_AddRefs(bundle));
getStringBundle(stringBundleURL.get(), getter_AddRefs(bundle));
rv = FormatWithBundle(bundle, aStatus, argCount, argArray, result);
}
if (NS_FAILED(rv)) {

View File

@ -333,13 +333,13 @@ XPCNativeInterface::NewInstance(nsIInterfaceInfo* aInfo)
if (!failed) {
for (i = 0; i < constCount; i++) {
RootedValue constant(cx);
nsXPIDLCString namestr;
nsCString namestr;
if (NS_FAILED(aInfo->GetConstant(i, &constant, getter_Copies(namestr)))) {
failed = true;
break;
}
str = JS_AtomizeAndPinString(cx, namestr);
str = JS_AtomizeAndPinString(cx, namestr.get());
if (!str) {
NS_ERROR("bad constant name");
failed = true;

View File

@ -841,7 +841,7 @@ nsPrefBranch::GetDefaultFromPropertiesFile(const char *aPrefName,
// the default value contains a URL to a .properties file
nsXPIDLCString propertyFileURL;
nsCString propertyFileURL;
rv = PREF_CopyCharPref(aPrefName, getter_Copies(propertyFileURL), true);
if (NS_FAILED(rv))
return rv;
@ -852,7 +852,7 @@ nsPrefBranch::GetDefaultFromPropertiesFile(const char *aPrefName,
return NS_ERROR_FAILURE;
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(propertyFileURL,
rv = bundleService->CreateBundle(propertyFileURL.get(),
getter_AddRefs(bundle));
if (NS_FAILED(rv))
return rv;

View File

@ -784,7 +784,7 @@ nsFtpState::S_pass() {
// XXX Is UTF-8 the best choice?
AppendUTF16toUTF8(mPassword, passwordStr);
} else {
nsXPIDLCString anonPassword;
nsCString anonPassword;
bool useRealEmail = false;
nsCOMPtr<nsIPrefBranch> prefs =
do_GetService(NS_PREFSERVICE_CONTRACTID);
@ -796,7 +796,7 @@ nsFtpState::S_pass() {
}
}
if (!anonPassword.IsEmpty()) {
passwordStr.AppendASCII(anonPassword);
passwordStr.AppendASCII(anonPassword.get());
} else {
// We need to default to a valid email address - bug 101027
// example.com is reserved (rfc2606), so use that

View File

@ -1351,37 +1351,37 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("accept.default"))) {
nsXPIDLCString accept;
nsCString accept;
rv = prefs->GetCharPref(HTTP_PREF("accept.default"),
getter_Copies(accept));
if (NS_SUCCEEDED(rv)) {
rv = SetAccept(accept);
rv = SetAccept(accept.get());
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
if (PREF_CHANGED(HTTP_PREF("accept-encoding"))) {
nsXPIDLCString acceptEncodings;
nsCString acceptEncodings;
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"),
getter_Copies(acceptEncodings));
if (NS_SUCCEEDED(rv)) {
rv = SetAcceptEncodings(acceptEncodings, false);
rv = SetAcceptEncodings(acceptEncodings.get(), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure"))) {
nsXPIDLCString acceptEncodings;
nsCString acceptEncodings;
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding.secure"),
getter_Copies(acceptEncodings));
if (NS_SUCCEEDED(rv)) {
rv = SetAcceptEncodings(acceptEncodings, true);
rv = SetAcceptEncodings(acceptEncodings.get(), true);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
if (PREF_CHANGED(HTTP_PREF("default-socket-type"))) {
nsXPIDLCString sval;
nsCString sval;
rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"),
getter_Copies(sval));
if (NS_SUCCEEDED(rv)) {
@ -1393,7 +1393,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
do_GetService(NS_SOCKETPROVIDERSERVICE_CONTRACTID));
if (sps) {
nsCOMPtr<nsISocketProvider> sp;
rv = sps->GetSocketProvider(sval, getter_AddRefs(sp));
rv = sps->GetSocketProvider(sval.get(), getter_AddRefs(sp));
if (NS_SUCCEEDED(rv)) {
// OK, this looks like a valid socket provider.
mDefaultSocketType.Assign(sval);

View File

@ -680,7 +680,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest,
// We don't know the file's character set yet, so retrieve the raw bytes
// which will be decoded by the HTML parser.
nsXPIDLCString loc;
nsCString loc;
aIndex->GetLocation(getter_Copies(loc));
// Adjust the length in case unescaping shortened the string.

View File

@ -790,19 +790,19 @@ InMemoryDataSource::LogOperation(const char* aOperation,
if (! MOZ_LOG_TEST(gLog, LogLevel::Debug))
return;
nsXPIDLCString uri;
nsCString uri;
aSource->GetValue(getter_Copies(uri));
MOZ_LOG(gLog, LogLevel::Debug,
("InMemoryDataSource(%p): %s", this, aOperation));
MOZ_LOG(gLog, LogLevel::Debug,
(" [(%p)%s]--", aSource, (const char*) uri));
(" [(%p)%s]--", aSource, uri.get()));
aProperty->GetValue(getter_Copies(uri));
char tv = (aTruthValue ? '-' : '!');
MOZ_LOG(gLog, LogLevel::Debug,
(" --%c[(%p)%s]--", tv, aProperty, (const char*) uri));
(" --%c[(%p)%s]--", tv, aProperty, uri.get()));
nsCOMPtr<nsIRDFResource> resource;
nsCOMPtr<nsIRDFLiteral> literal;
@ -810,7 +810,7 @@ InMemoryDataSource::LogOperation(const char* aOperation,
if ((resource = do_QueryInterface(aTarget)) != nullptr) {
resource->GetValue(getter_Copies(uri));
MOZ_LOG(gLog, LogLevel::Debug,
(" -->[(%p)%s]", aTarget, (const char*) uri));
(" -->[(%p)%s]", aTarget, uri.get()));
}
else if ((literal = do_QueryInterface(aTarget)) != nullptr) {
nsString value;

View File

@ -315,10 +315,10 @@ RDFContentSinkImpl::~RDFContentSinkImpl()
// XXX we should save line numbers on the context stack: this'd
// be about 1000x more helpful.
if (resource && MOZ_LOG_TEST(gLog, LogLevel::Debug)) {
nsXPIDLCString uri;
nsCString uri;
resource->GetValue(getter_Copies(uri));
MOZ_LOG(gLog, LogLevel::Debug,
("rdfxml: uri=%s", (const char*) uri));
("rdfxml: uri=%s", uri.get()));
}
NS_IF_RELEASE(resource);

View File

@ -1177,12 +1177,14 @@ RDFServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource, bool aReplace)
nsresult rv;
nsXPIDLCString uri;
nsCString uri;
rv = aDataSource->GetURI(getter_Copies(uri));
if (NS_FAILED(rv)) return rv;
PLHashEntry** hep =
PL_HashTableRawLookup(mNamedDataSources, (*mNamedDataSources->keyHash)(uri), uri);
PL_HashTableRawLookup(mNamedDataSources,
(*mNamedDataSources->keyHash)(uri.get()),
uri.get());
if (*hep) {
if (! aReplace)
@ -1193,12 +1195,12 @@ RDFServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource, bool aReplace)
// refcounts.
MOZ_LOG(gLog, LogLevel::Debug,
("rdfserv replace-datasource [%p] <-- [%p] %s",
(*hep)->value, aDataSource, (const char*) uri));
(*hep)->value, aDataSource, uri.get()));
(*hep)->value = aDataSource;
}
else {
const char* key = PL_strdup(uri);
const char* key = PL_strdup(uri.get());
if (! key)
return NS_ERROR_OUT_OF_MEMORY;
@ -1206,7 +1208,7 @@ RDFServiceImpl::RegisterDataSource(nsIRDFDataSource* aDataSource, bool aReplace)
MOZ_LOG(gLog, LogLevel::Debug,
("rdfserv register-datasource [%p] %s",
aDataSource, (const char*) uri));
aDataSource, uri.get()));
// N.B., we only hold a weak reference to the datasource, so don't
// addref.

View File

@ -142,8 +142,8 @@ nsUserInfo::GetEmailAddress(char * *aEmailAddress)
nsresult rv;
nsAutoCString emailAddress;
nsXPIDLCString username;
nsXPIDLCString domain;
nsCString username;
nsCString domain;
rv = GetUsername(getter_Copies(username));
if (NS_FAILED(rv)) return rv;
@ -152,9 +152,9 @@ nsUserInfo::GetEmailAddress(char * *aEmailAddress)
if (NS_FAILED(rv)) return rv;
if (!username.IsEmpty() && !domain.IsEmpty()) {
emailAddress = (const char *)username;
emailAddress = username.get();
emailAddress += "@";
emailAddress += (const char *)domain;
emailAddress += domain.get();
}
else {
return NS_ERROR_FAILURE;

View File

@ -331,10 +331,10 @@ nsUrlClassifierUtils::GetProtocolVersion(const nsACString& aProvider,
if (prefBranch) {
nsPrintfCString prefName("browser.safebrowsing.provider.%s.pver",
nsCString(aProvider).get());
nsXPIDLCString version;
nsCString version;
nsresult rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(version));
aVersion = NS_SUCCEEDED(rv) ? version : DEFAULT_PROTOCOL_VERSION;
aVersion = NS_SUCCEEDED(rv) ? version.get() : DEFAULT_PROTOCOL_VERSION;
} else {
aVersion = DEFAULT_PROTOCOL_VERSION;
}

View File

@ -44,7 +44,7 @@ NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const char *a
nsAutoCString categoryEntry;
rv = category->GetData(categoryEntry);
nsXPIDLCString contractId;
nsCString contractId;
categoryManager->GetCategoryEntry(aTopic,
categoryEntry.get(),
getter_Copies(contractId));
@ -59,7 +59,7 @@ NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const char *a
if (Substring(contractId, 0, 8).EqualsLiteral("service,"))
startupInstance = do_GetService(contractId.get() + 8, &rv);
else
startupInstance = do_CreateInstance(contractId, &rv);
startupInstance = do_CreateInstance(contractId.get(), &rv);
if (NS_SUCCEEDED(rv)) {
// Try to QI to nsIObserver

View File

@ -456,7 +456,7 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
nsCOMPtr<nsICategoryManager> catman =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
if (catman) {
nsXPIDLCString contractidString;
nsCString contractidString;
rv = catman->GetCategoryEntry(NS_CONTENT_LISTENER_CATEGORYMANAGER_ENTRY,
mContentType.get(),
getter_Copies(contractidString));
@ -464,9 +464,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
LOG((" Listener contractid for '%s' is '%s'",
mContentType.get(), contractidString.get()));
listener = do_CreateInstance(contractidString);
listener = do_CreateInstance(contractidString.get());
LOG((" Listener from category manager: 0x%p", listener.get()));
if (listener && TryContentListener(listener, aChannel)) {
LOG((" Listener from category manager likes this type"));
return NS_OK;

View File

@ -205,7 +205,7 @@ nsClipboard::TransferableFromPasteboard(nsITransferable *aTransferable, NSPasteb
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr)); // i has a flavr
// printf("looking for clipboard data of type %s\n", flavorStr.get());
@ -248,7 +248,7 @@ nsClipboard::TransferableFromPasteboard(nsITransferable *aTransferable, NSPasteb
nsCOMPtr<nsISupports> genericDataWrapper;
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, clipboardDataPtrNoBOM, dataLength,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(flavorStr, genericDataWrapper, dataLength);
aTransferable->SetTransferData(flavorStr.get(), genericDataWrapper, dataLength);
free(clipboardDataPtr);
break;
}
@ -278,7 +278,7 @@ nsClipboard::TransferableFromPasteboard(nsITransferable *aTransferable, NSPasteb
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, clipboardDataPtr, dataLength,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(flavorStr, genericDataWrapper, dataLength);
aTransferable->SetTransferData(flavorStr.get(), genericDataWrapper, dataLength);
free(clipboardDataPtr);
}
else if (flavorStr.EqualsLiteral(kJPEGImageMime) ||
@ -339,7 +339,7 @@ nsClipboard::TransferableFromPasteboard(nsITransferable *aTransferable, NSPasteb
NS_NewByteInputStream(getter_AddRefs(byteStream), (const char*)[encodedData bytes],
[encodedData length], NS_ASSIGNMENT_COPY);
aTransferable->SetTransferData(flavorStr, byteStream, sizeof(nsIInputStream*));
aTransferable->SetTransferData(flavorStr.get(), byteStream, sizeof(nsIInputStream*));
}
if (dest)
@ -396,14 +396,14 @@ nsClipboard::GetNativeClipboardData(nsITransferable* aTransferable, int32_t aWhi
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
nsCOMPtr<nsISupports> dataSupports;
uint32_t dataSize = 0;
rv = mTransferable->GetTransferData(flavorStr, getter_AddRefs(dataSupports), &dataSize);
rv = mTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(dataSupports), &dataSize);
if (NS_SUCCEEDED(rv)) {
aTransferable->SetTransferData(flavorStr, dataSupports, dataSize);
aTransferable->SetTransferData(flavorStr.get(), dataSupports, dataSize);
return NS_OK; // maybe try to fill in more types? Is there a point?
}
}
@ -534,7 +534,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
MOZ_LOG(sCocoaLog, LogLevel::Info, ("writing out clipboard data of type %s (%d)\n", flavorStr.get(), i));
@ -545,7 +545,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
void* data = nullptr;
uint32_t dataSize = 0;
nsCOMPtr<nsISupports> genericDataWrapper;
rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper), &dataSize);
rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(genericDataWrapper), &dataSize);
nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr, genericDataWrapper, &data, dataSize);
NSString* nativeString;
@ -565,7 +565,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
void* data = nullptr;
uint32_t dataSize = 0;
nsCOMPtr<nsISupports> genericDataWrapper;
rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper), &dataSize);
rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(genericDataWrapper), &dataSize);
nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr, genericDataWrapper, &data, dataSize);
if (data) {
@ -581,7 +581,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
flavorStr.EqualsLiteral(kNativeImageMime)) {
uint32_t dataSize = 0;
nsCOMPtr<nsISupports> transferSupports;
aTransferable->GetTransferData(flavorStr, getter_AddRefs(transferSupports), &dataSize);
aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(transferSupports), &dataSize);
nsCOMPtr<nsISupportsInterfacePointer> ptrPrimitive(do_QueryInterface(transferSupports));
if (!ptrPrimitive)
continue;
@ -636,7 +636,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
else if (flavorStr.EqualsLiteral(kFileMime)) {
uint32_t len = 0;
nsCOMPtr<nsISupports> genericFile;
rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(genericFile), &len);
rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(genericFile), &len);
if (NS_FAILED(rv)) {
continue;
}
@ -683,7 +683,7 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable)
else if (flavorStr.EqualsLiteral(kURLMime)) {
uint32_t len = 0;
nsCOMPtr<nsISupports> genericURL;
rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(genericURL), &len);
rv = aTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(genericURL), &len);
nsCOMPtr<nsISupportsString> urlObject(do_QueryInterface(genericURL));
nsAutoString url;

View File

@ -396,14 +396,14 @@ nsDragService::GetData(nsITransferable* aTransferable, uint32_t aItemIndex)
nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryElementAt(flavorList, i);
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
nsCOMPtr<nsISupports> dataSupports;
uint32_t dataSize = 0;
rv = currentTransferable->GetTransferData(flavorStr, getter_AddRefs(dataSupports), &dataSize);
rv = currentTransferable->GetTransferData(flavorStr.get(), getter_AddRefs(dataSupports), &dataSize);
if (NS_SUCCEEDED(rv)) {
aTransferable->SetTransferData(flavorStr, dataSupports, dataSize);
aTransferable->SetTransferData(flavorStr.get(), dataSupports, dataSize);
return NS_OK; // maybe try to fill in more types? Is there a point?
}
}
@ -416,7 +416,7 @@ nsDragService::GetData(nsITransferable* aTransferable, uint32_t aItemIndex)
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
MOZ_LOG(sCocoaLog, LogLevel::Info, ("nsDragService::GetData: looking for clipboard data of type %s\n", flavorStr.get()));
@ -455,7 +455,7 @@ nsDragService::GetData(nsITransferable* aTransferable, uint32_t aItemIndex)
if (NS_FAILED(rv))
continue;
aTransferable->SetTransferData(flavorStr, file, dataLength);
aTransferable->SetTransferData(flavorStr.get(), file, dataLength);
break;
}
@ -482,7 +482,7 @@ nsDragService::GetData(nsITransferable* aTransferable, uint32_t aItemIndex)
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, clipboardDataPtr, dataLength,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(flavorStr, genericDataWrapper, sizeof(nsIInputStream*));
aTransferable->SetTransferData(flavorStr.get(), genericDataWrapper, sizeof(nsIInputStream*));
free(clipboardDataPtr);
break;
}
@ -548,7 +548,7 @@ nsDragService::GetData(nsITransferable* aTransferable, uint32_t aItemIndex)
nsCOMPtr<nsISupports> genericDataWrapper;
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, clipboardDataPtrNoBOM, dataLength,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(flavorStr, genericDataWrapper, dataLength);
aTransferable->SetTransferData(flavorStr.get(), genericDataWrapper, dataLength);
free(clipboardDataPtr);
break;
}

View File

@ -173,12 +173,12 @@ nsClipboard::SetData(nsITransferable *aTransferable,
nsCOMPtr<nsISupportsCString> flavor = do_QueryElementAt(flavors, i);
if (flavor) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
flavor->ToString(getter_Copies(flavorStr));
// special case text/unicode since we can handle all of
// the string types
if (!strcmp(flavorStr, kUnicodeMime)) {
if (flavorStr.EqualsLiteral(kUnicodeMime)) {
gtk_target_list_add(list, gdk_atom_intern("UTF8_STRING", FALSE), 0, 0);
gtk_target_list_add(list, gdk_atom_intern("COMPOUND_TEXT", FALSE), 0, 0);
gtk_target_list_add(list, gdk_atom_intern("TEXT", FALSE), 0, 0);
@ -201,7 +201,7 @@ nsClipboard::SetData(nsITransferable *aTransferable,
}
// Add this to our list of valid targets
GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
GdkAtom atom = gdk_atom_intern(flavorStr.get(), FALSE);
gtk_target_list_add(list, atom, 0, 0);
}
}
@ -270,12 +270,12 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
currentFlavor = do_QueryElementAt(flavors, i);
if (currentFlavor) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
// Special case text/unicode since we can convert any
// string into text/unicode
if (!strcmp(flavorStr, kUnicodeMime)) {
if (flavorStr.EqualsLiteral(kUnicodeMime)) {
gchar* new_text = wait_for_text(clipboard);
if (new_text) {
// Convert utf-8 into our unicode format.
@ -295,16 +295,16 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
// For images, we must wrap the data in an nsIInputStream then return instead of break,
// because that code below won't help us.
if (!strcmp(flavorStr, kJPEGImageMime) ||
!strcmp(flavorStr, kJPGImageMime) ||
!strcmp(flavorStr, kPNGImageMime) ||
!strcmp(flavorStr, kGIFImageMime)) {
if (flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) ||
flavorStr.EqualsLiteral(kPNGImageMime) ||
flavorStr.EqualsLiteral(kGIFImageMime)) {
// Emulate support for image/jpg
if (!strcmp(flavorStr, kJPGImageMime)) {
if (flavorStr.EqualsLiteral(kJPGImageMime)) {
flavorStr.Assign(kJPEGImageMime);
}
GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
GdkAtom atom = gdk_atom_intern(flavorStr.get(), FALSE);
GtkSelectionData *selectionData = wait_for_contents(clipboard, atom);
if (!selectionData)
@ -315,21 +315,21 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
(const char*)gtk_selection_data_get_data(selectionData),
gtk_selection_data_get_length(selectionData),
NS_ASSIGNMENT_COPY);
aTransferable->SetTransferData(flavorStr, byteStream, sizeof(nsIInputStream*));
aTransferable->SetTransferData(flavorStr.get(), byteStream, sizeof(nsIInputStream*));
gtk_selection_data_free(selectionData);
return NS_OK;
}
// Get the atom for this type and try to request it off
// the clipboard.
GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);
GdkAtom atom = gdk_atom_intern(flavorStr.get(), FALSE);
GtkSelectionData *selectionData;
selectionData = wait_for_contents(clipboard, atom);
if (selectionData) {
const guchar *clipboardData = gtk_selection_data_get_data(selectionData);
length = gtk_selection_data_get_length(selectionData);
// Special case text/html since we can convert into UCS2
if (!strcmp(flavorStr, kHTMLMime)) {
if (flavorStr.EqualsLiteral(kHTMLMime)) {
char16_t* htmlBody= nullptr;
int32_t htmlBodyLen = 0;
// Convert text/html into our unicode format
@ -356,7 +356,7 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
if (foundData) {
nsCOMPtr<nsISupports> wrapper;
nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor.get(),
nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor,
data, length,
getter_AddRefs(wrapper));
aTransferable->SetTransferData(foundFlavor.get(),
@ -603,8 +603,8 @@ nsClipboard::SelectionGetEvent(GtkClipboard *aClipboard,
}
void *primitive_data = nullptr;
nsPrimitiveHelpers::CreateDataFromPrimitive(target_name, item,
&primitive_data, len);
nsPrimitiveHelpers::CreateDataFromPrimitive(nsDependentCString(target_name),
item, &primitive_data, len);
if (primitive_data) {
// Check to see if the selection data is text/html

View File

@ -92,7 +92,7 @@ NS_IMETHODIMP nsColorPicker::Open(nsIColorPickerShownCallback *aColorPickerShown
}
mCallback = aColorPickerShownCallback;
nsXPIDLCString title;
nsCString title;
title.Adopt(ToNewUTF8String(mTitle));
GtkWindow *parent_window = GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
@ -111,7 +111,7 @@ NS_IMETHODIMP nsColorPicker::Open(nsIColorPickerShownCallback *aColorPickerShown
g_signal_connect(GTK_COLOR_CHOOSER(color_chooser), "color-activated",
G_CALLBACK(OnColorChanged), this);
#else
GtkWidget *color_chooser = gtk_color_selection_dialog_new(title);
GtkWidget *color_chooser = gtk_color_selection_dialog_new(title.get());
if (parent_window) {
GtkWindow *window = GTK_WINDOW(color_chooser);

View File

@ -735,11 +735,11 @@ nsDragService::GetData(nsITransferable * aTransferable,
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
MOZ_LOG(sDragLm,
LogLevel::Debug,
("flavor is %s\n", (const char *)flavorStr));
("flavor is %s\n", flavorStr.get()));
// get the item with the right index
nsCOMPtr<nsITransferable> item =
do_QueryElementAt(mSourceDataItems, aItemIndex);
@ -750,8 +750,8 @@ nsDragService::GetData(nsITransferable * aTransferable,
uint32_t tmpDataLen = 0;
MOZ_LOG(sDragLm, LogLevel::Debug,
("trying to get transfer data for %s\n",
(const char *)flavorStr));
rv = item->GetTransferData(flavorStr,
flavorStr.get()));
rv = item->GetTransferData(flavorStr.get(),
getter_AddRefs(data),
&tmpDataLen);
if (NS_FAILED(rv)) {
@ -759,7 +759,8 @@ nsDragService::GetData(nsITransferable * aTransferable,
continue;
}
MOZ_LOG(sDragLm, LogLevel::Debug, ("succeeded.\n"));
rv = aTransferable->SetTransferData(flavorStr,data,tmpDataLen);
rv = aTransferable->SetTransferData(flavorStr.get(), data,
tmpDataLen);
if (NS_FAILED(rv)) {
MOZ_LOG(sDragLm,
LogLevel::Debug,
@ -781,12 +782,12 @@ nsDragService::GetData(nsITransferable * aTransferable,
currentFlavor = do_QueryElementAt(flavorList, i);
if (currentFlavor) {
// find our gtk flavor
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
GdkAtom gdkFlavor = gdk_atom_intern(flavorStr, FALSE);
GdkAtom gdkFlavor = gdk_atom_intern(flavorStr.get(), FALSE);
MOZ_LOG(sDragLm, LogLevel::Debug,
("looking for data in type %s, gdk flavor %p\n",
static_cast<const char*>(flavorStr), gdkFlavor));
flavorStr.get(), gdkFlavor));
bool dataFound = false;
if (gdkFlavor) {
GetTargetDragData(gdkFlavor);
@ -800,7 +801,7 @@ nsDragService::GetData(nsITransferable * aTransferable,
// Dragging and dropping from the file manager would cause us
// to parse the source text as a nsIFile URL.
if ( strcmp(flavorStr, kFileMime) == 0 ) {
if (flavorStr.EqualsLiteral(kFileMime)) {
gdkFlavor = gdk_atom_intern(kTextMime, FALSE);
GetTargetDragData(gdkFlavor);
if (!mTargetDragData) {
@ -831,7 +832,7 @@ nsDragService::GetData(nsITransferable * aTransferable,
// and calls text-specific operations.
// Make a secret hideout here for nsIFile
// objects and return early.
aTransferable->SetTransferData(flavorStr, file,
aTransferable->SetTransferData(flavorStr.get(), file,
convertedTextLen);
g_free(convertedText);
return NS_OK;
@ -847,7 +848,7 @@ nsDragService::GetData(nsITransferable * aTransferable,
// if we are looking for text/unicode and we fail to find it
// on the clipboard first, try again with text/plain. If that
// is present, convert it to unicode.
if ( strcmp(flavorStr, kUnicodeMime) == 0 ) {
if (flavorStr.EqualsLiteral(kUnicodeMime)) {
MOZ_LOG(sDragLm, LogLevel::Debug,
("we were looking for text/unicode... \
trying with text/plain;charset=utf-8\n"));
@ -902,7 +903,7 @@ nsDragService::GetData(nsITransferable * aTransferable,
// if we are looking for text/x-moz-url and we failed to find
// it on the clipboard, try again with text/uri-list, and then
// _NETSCAPE_URL
if (strcmp(flavorStr, kURLMime) == 0) {
if (flavorStr.EqualsLiteral(kURLMime)) {
MOZ_LOG(sDragLm, LogLevel::Debug,
("we were looking for text/x-moz-url...\
trying again with text/uri-list\n"));
@ -970,7 +971,7 @@ nsDragService::GetData(nsITransferable * aTransferable,
} // else we try one last ditch effort to find our data
if (dataFound) {
if (strcmp(flavorStr, kCustomTypesMime) != 0) {
if (!flavorStr.EqualsLiteral(kCustomTypesMime)) {
// the DOM only wants LF, so convert from MacOS line endings
// to DOM line endings.
nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks(
@ -984,7 +985,7 @@ nsDragService::GetData(nsITransferable * aTransferable,
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr,
mTargetDragData, mTargetDragDataLen,
getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(flavorStr,
aTransferable->SetTransferData(flavorStr.get(),
genericDataWrapper,
mTargetDragDataLen);
// we found one, get out of this loop!
@ -1046,12 +1047,12 @@ nsDragService::IsDataFlavorSupported(const char *aDataFlavor,
nsCOMPtr<nsISupportsCString> currentFlavor;
currentFlavor = do_QueryElementAt(flavorList, flavorIndex);
if (currentFlavor) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
MOZ_LOG(sDragLm, LogLevel::Debug,
("checking %s against %s\n",
(const char *)flavorStr, aDataFlavor));
if (strcmp(flavorStr, aDataFlavor) == 0) {
flavorStr.get(), aDataFlavor));
if (flavorStr.Equals(aDataFlavor)) {
MOZ_LOG(sDragLm, LogLevel::Debug,
("boioioioiooioioioing!\n"));
*_retval = true;
@ -1282,13 +1283,13 @@ nsDragService::GetSourceList(void)
nsCOMPtr<nsISupportsCString> currentFlavor;
currentFlavor = do_QueryElementAt(flavorList, flavorIndex);
if (currentFlavor) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
// check if text/x-moz-url is supported.
// If so, advertise
// text/uri-list.
if (strcmp(flavorStr, kURLMime) == 0) {
if (flavorStr.EqualsLiteral(kURLMime)) {
listTarget =
(GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
listTarget->target = g_strdup(gTextUriListType);
@ -1317,18 +1318,18 @@ nsDragService::GetSourceList(void)
nsCOMPtr<nsISupportsCString> currentFlavor;
currentFlavor = do_QueryElementAt(flavorList, flavorIndex);
if (currentFlavor) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
GtkTargetEntry *target =
(GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
target->target = g_strdup(flavorStr);
target->target = g_strdup(flavorStr.get());
target->flags = 0;
MOZ_LOG(sDragLm, LogLevel::Debug,
("adding target %s\n", target->target));
targetArray.AppendElement(target);
// If there is a file, add the text/uri-list type.
if (strcmp(flavorStr, kFileMime) == 0) {
if (flavorStr.EqualsLiteral(kFileMime)) {
GtkTargetEntry *urilistTarget =
(GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
urilistTarget->target = g_strdup(gTextUriListType);
@ -1342,7 +1343,7 @@ nsDragService::GetSourceList(void)
// If it is, add text/plain
// since we automatically support text/plain
// if we support text/unicode.
else if (strcmp(flavorStr, kUnicodeMime) == 0) {
else if (flavorStr.EqualsLiteral(kUnicodeMime)) {
GtkTargetEntry *plainUTF8Target =
(GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
plainUTF8Target->target = g_strdup(gTextPlainUTF8Type);
@ -1364,7 +1365,7 @@ nsDragService::GetSourceList(void)
// Check to see if this is the x-moz-url type.
// If it is, add _NETSCAPE_URL
// this is a type used by everybody.
else if (strcmp(flavorStr, kURLMime) == 0) {
else if (flavorStr.EqualsLiteral(kURLMime)) {
GtkTargetEntry *urlTarget =
(GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));
urlTarget->target = g_strdup(gMozUrlType);
@ -1497,10 +1498,8 @@ CreateUriList(nsIArray *items, gchar **text, gint *length)
&tmpDataLen);
if (NS_SUCCEEDED(rv)) {
nsPrimitiveHelpers::CreateDataFromPrimitive(kURLMime,
data,
&tmpData,
tmpDataLen);
nsPrimitiveHelpers::CreateDataFromPrimitive(
nsDependentCString(kURLMime), data, &tmpData, tmpDataLen);
char* plainTextData = nullptr;
char16_t* castedUnicode = reinterpret_cast<char16_t*>
(tmpData);
@ -1578,7 +1577,7 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
{
MOZ_LOG(sDragLm, LogLevel::Debug, ("nsDragService::SourceDataGet"));
GdkAtom target = gtk_selection_data_get_target(aSelectionData);
nsXPIDLCString mimeFlavor;
nsCString mimeFlavor;
gchar *typeName = 0;
typeName = gdk_atom_name(target);
if (!typeName) {
@ -1587,7 +1586,7 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
}
MOZ_LOG(sDragLm, LogLevel::Debug, ("Type is %s\n", typeName));
// make a copy since |nsXPIDLCString| won't use |g_free|...
// make a copy since |nsCString| won't use |g_free|...
mimeFlavor.Adopt(strdup(typeName));
g_free(typeName);
// check to make sure that we have data items to return.
@ -1602,26 +1601,26 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
// if someone was asking for text/plain, lookup unicode instead so
// we can convert it.
bool needToDoConversionToPlainText = false;
const char* actualFlavor = mimeFlavor;
if (strcmp(mimeFlavor, kTextMime) == 0 ||
strcmp(mimeFlavor, gTextPlainUTF8Type) == 0) {
const char* actualFlavor;
if (mimeFlavor.EqualsLiteral(kTextMime) ||
mimeFlavor.EqualsLiteral(gTextPlainUTF8Type)) {
actualFlavor = kUnicodeMime;
needToDoConversionToPlainText = true;
}
// if someone was asking for _NETSCAPE_URL we need to convert to
// plain text but we also need to look for x-moz-url
else if (strcmp(mimeFlavor, gMozUrlType) == 0) {
else if (mimeFlavor.EqualsLiteral(gMozUrlType)) {
actualFlavor = kURLMime;
needToDoConversionToPlainText = true;
}
// if someone was asking for text/uri-list we need to convert to
// plain text.
else if (strcmp(mimeFlavor, gTextUriListType) == 0) {
else if (mimeFlavor.EqualsLiteral(gTextUriListType)) {
actualFlavor = gTextUriListType;
needToDoConversionToPlainText = true;
}
else
actualFlavor = mimeFlavor;
actualFlavor = mimeFlavor.get();
uint32_t tmpDataLen = 0;
void *tmpData = nullptr;
@ -1631,8 +1630,8 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
getter_AddRefs(data),
&tmpDataLen);
if (NS_SUCCEEDED(rv)) {
nsPrimitiveHelpers::CreateDataFromPrimitive (actualFlavor, data,
&tmpData, tmpDataLen);
nsPrimitiveHelpers::CreateDataFromPrimitive(
nsDependentCString(actualFlavor), data, &tmpData, tmpDataLen);
// if required, do the extra work to convert unicode to plain
// text and replace the output values with the plain text.
if (needToDoConversionToPlainText) {
@ -1660,7 +1659,7 @@ nsDragService::SourceDataGet(GtkWidget *aWidget,
free(tmpData);
}
} else {
if (strcmp(mimeFlavor, gTextUriListType) == 0) {
if (mimeFlavor.EqualsLiteral(gTextUriListType)) {
// fall back for text/uri-list
gchar *uriList;
gint length;

View File

@ -376,7 +376,7 @@ nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
if (mRunning)
return NS_ERROR_NOT_AVAILABLE;
nsXPIDLCString title;
nsCString title;
title.Adopt(ToNewUTF8String(mTitle));
GtkWindow *parent_widget =
@ -394,7 +394,7 @@ nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
}
GtkWidget *file_chooser =
gtk_file_chooser_dialog_new(title, parent_widget, action,
gtk_file_chooser_dialog_new(title.get(), parent_widget, action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
accept_button, GTK_RESPONSE_ACCEPT,
nullptr);

View File

@ -181,7 +181,7 @@ nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromDa
nsresult res;
if (toFlavor.Equals(kHTMLMime)) {
int32_t dataLen = dataStr.Length() * 2;
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor.get(), dataStr.get(), dataLen, aToData );
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor, dataStr.get(), dataLen, aToData );
if ( *aToData )
*aDataToLen = dataLen;
} else {
@ -189,7 +189,7 @@ nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromDa
res = ConvertFromHTMLToUnicode(dataStr, outStr);
if (NS_SUCCEEDED(res)) {
int32_t dataLen = outStr.Length() * 2;
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor.get(), outStr.get(), dataLen, aToData );
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor, outStr.get(), dataLen, aToData );
if ( *aToData )
*aDataToLen = dataLen;
}
@ -199,7 +199,7 @@ nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromDa
nsAutoString outStr;
if ( NS_SUCCEEDED(ConvertFromHTMLToAOLMail(dataStr, outStr)) ) {
int32_t dataLen = outStr.Length() * 2;
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor.get(), outStr.get(), dataLen, aToData );
nsPrimitiveHelpers::CreatePrimitiveForData ( toFlavor, outStr.get(), dataLen, aToData );
if ( *aToData )
*aDataToLen = dataLen;
}

View File

@ -41,14 +41,16 @@
// platform HTML (CF_HTML on win32)
//
void
nsPrimitiveHelpers :: CreatePrimitiveForData ( const char* aFlavor, const void* aDataBuff,
nsPrimitiveHelpers :: CreatePrimitiveForData ( const nsACString& aFlavor, const void* aDataBuff,
uint32_t aDataLen, nsISupports** aPrimitive )
{
if ( !aPrimitive )
return;
if ( strcmp(aFlavor,kTextMime) == 0 || strcmp(aFlavor,kNativeHTMLMime) == 0 ||
strcmp(aFlavor,kRTFMime) == 0 || strcmp(aFlavor,kCustomTypesMime) == 0) {
if ( aFlavor.EqualsLiteral(kTextMime) ||
aFlavor.EqualsLiteral(kNativeHTMLMime) ||
aFlavor.EqualsLiteral(kRTFMime) ||
aFlavor.EqualsLiteral(kCustomTypesMime)) {
nsCOMPtr<nsISupportsCString> primitive =
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID);
if ( primitive ) {
@ -106,7 +108,7 @@ nsPrimitiveHelpers :: CreatePrimitiveForCFHTML ( const void* aDataBuff,
return;
memcpy(utf8, aDataBuff, *aDataLen);
int32_t signedLen = static_cast<int32_t>(*aDataLen);
nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks(kTextMime, &utf8, &signedLen);
nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks(nsDependentCString(kTextMime), &utf8, &signedLen);
*aDataLen = signedLen;
nsAutoString str(NS_ConvertUTF8toUTF16(reinterpret_cast<const char*>(utf8), *aDataLen));
@ -125,7 +127,7 @@ nsPrimitiveHelpers :: CreatePrimitiveForCFHTML ( const void* aDataBuff,
// parameter does not reflect that.
//
void
nsPrimitiveHelpers :: CreateDataFromPrimitive ( const char* aFlavor, nsISupports* aPrimitive,
nsPrimitiveHelpers :: CreateDataFromPrimitive ( const nsACString& aFlavor, nsISupports* aPrimitive,
void** aDataBuff, uint32_t aDataLen )
{
if ( !aDataBuff )
@ -133,7 +135,8 @@ nsPrimitiveHelpers :: CreateDataFromPrimitive ( const char* aFlavor, nsISupports
*aDataBuff = nullptr;
if ( strcmp(aFlavor,kTextMime) == 0 || strcmp(aFlavor,kCustomTypesMime) == 0) {
if (aFlavor.EqualsLiteral(kTextMime) ||
aFlavor.EqualsLiteral(kCustomTypesMime)) {
nsCOMPtr<nsISupportsCString> plainText ( do_QueryInterface(aPrimitive) );
if ( plainText ) {
nsAutoCString data;
@ -164,7 +167,7 @@ nsPrimitiveHelpers :: CreateDataFromPrimitive ( const char* aFlavor, nsISupports
// NOTE: this assumes that it can use 'free' to dispose of the old buffer.
//
nsresult
nsLinebreakHelpers :: ConvertPlatformToDOMLinebreaks ( const char* inFlavor, void** ioData,
nsLinebreakHelpers :: ConvertPlatformToDOMLinebreaks ( const nsACString& inFlavor, void** ioData,
int32_t* ioLengthInBytes )
{
NS_ASSERTION ( ioData && *ioData && ioLengthInBytes, "Bad Params");
@ -173,7 +176,8 @@ nsLinebreakHelpers :: ConvertPlatformToDOMLinebreaks ( const char* inFlavor, voi
nsresult retVal = NS_OK;
if ( strcmp(inFlavor, kTextMime) == 0 || strcmp(inFlavor, kRTFMime) == 0) {
if (inFlavor.EqualsLiteral(kTextMime) ||
inFlavor.EqualsLiteral(kRTFMime)) {
char* buffAsChars = reinterpret_cast<char*>(*ioData);
char* oldBuffer = buffAsChars;
retVal = nsLinebreakConverter::ConvertLineBreaksInSitu ( &buffAsChars, nsLinebreakConverter::eLinebreakAny,
@ -185,7 +189,7 @@ nsLinebreakHelpers :: ConvertPlatformToDOMLinebreaks ( const char* inFlavor, voi
*ioData = buffAsChars;
}
}
else if ( strcmp(inFlavor, "image/jpeg") == 0 ) {
else if (inFlavor.EqualsLiteral("image/jpeg")) {
// I'd assume we don't want to do anything for binary data....
}
else {

View File

@ -20,7 +20,7 @@ public:
// Given some data and the flavor it corresponds to, creates the appropriate
// nsISupports* wrapper for passing across IDL boundaries. The length parameter
// should not include the null if the data is null terminated.
static void CreatePrimitiveForData ( const char* aFlavor, const void* aDataBuff,
static void CreatePrimitiveForData ( const nsACString& aFlavor, const void* aDataBuff,
uint32_t aDataLen, nsISupports** aPrimitive ) ;
// A specific case of CreatePrimitive for windows CF_HTML handling in DataTransfer
@ -30,7 +30,7 @@ public:
// Given a nsISupports* primitive and the flavor it represents, creates a new data
// buffer with the data in it. This data will be null terminated, but the length
// parameter does not reflect that.
static void CreateDataFromPrimitive ( const char* aFlavor, nsISupports* aPrimitive,
static void CreateDataFromPrimitive ( const nsACString& aFlavor, nsISupports* aPrimitive,
void** aDataBuff, uint32_t aDataLen ) ;
}; // class nsPrimitiveHelpers
@ -47,7 +47,7 @@ public:
// the note below).
//
// NOTE: this assumes that it can use 'free' to dispose of the old buffer.
static nsresult ConvertPlatformToDOMLinebreaks ( const char* inFlavor, void** ioData, int32_t* ioLengthInBytes ) ;
static nsresult ConvertPlatformToDOMLinebreaks ( const nsACString& inFlavor, void** ioData, int32_t* ioLengthInBytes ) ;
}; // class nsLinebreakHelpers

View File

@ -139,9 +139,9 @@ DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen)
if (cacheFile) {
// remember the file name
if (!mCacheFileName) {
nsXPIDLCString fName;
nsCString fName;
cacheFile->GetNativeLeafName(fName);
mCacheFileName = strdup(fName);
mCacheFileName = strdup(fName.get());
}
// write out the contents of the clipboard
@ -155,7 +155,7 @@ DataStruct::WriteCache(nsISupports* aData, uint32_t aDataLen)
if (!outStr) return NS_ERROR_FAILURE;
void* buff = nullptr;
nsPrimitiveHelpers::CreateDataFromPrimitive ( mFlavor.get(), aData, &buff, aDataLen );
nsPrimitiveHelpers::CreateDataFromPrimitive ( mFlavor, aData, &buff, aDataLen );
if ( buff ) {
uint32_t ignored;
outStr->Write(reinterpret_cast<char*>(buff), aDataLen, &ignored);
@ -203,7 +203,7 @@ DataStruct::ReadCache(nsISupports** aData, uint32_t* aDataLen)
// make sure we got all the data ok
if (NS_SUCCEEDED(rv) && *aDataLen == size) {
nsPrimitiveHelpers::CreatePrimitiveForData(mFlavor.get(), data.get(),
nsPrimitiveHelpers::CreatePrimitiveForData(mFlavor, data.get(),
fileSize, aData);
return *aData ? NS_OK : NS_ERROR_FAILURE;
}

View File

@ -175,36 +175,36 @@ nsresult nsClipboard::SetupNativeDataObject(nsITransferable * aTransferable, IDa
for (i=0;i<cnt;i++) {
nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryElementAt(dfList, i);
if ( currentFlavor ) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
// When putting data onto the clipboard, we want to maintain kHTMLMime
// ("text/html") and not map it to CF_HTML here since this will be done below.
UINT format = GetFormat(flavorStr, false);
UINT format = GetFormat(flavorStr.get(), false);
// Now tell the native IDataObject about both our mime type and
// the native data format
FORMATETC fe;
SET_FORMATETC(fe, format, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
dObj->AddDataFlavor(flavorStr, &fe);
dObj->AddDataFlavor(flavorStr.get(), &fe);
// Do various things internal to the implementation, like map one
// flavor to another or add additional flavors based on what's required
// for the win32 impl.
if ( strcmp(flavorStr, kUnicodeMime) == 0 ) {
if (flavorStr.EqualsLiteral(kUnicodeMime)) {
// if we find text/unicode, also advertise text/plain (which we will convert
// on our own in nsDataObj::GetText().
FORMATETC textFE;
SET_FORMATETC(textFE, CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
dObj->AddDataFlavor(kTextMime, &textFE);
}
else if ( strcmp(flavorStr, kHTMLMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kHTMLMime)) {
// if we find text/html, also advertise win32's html flavor (which we will convert
// on our own in nsDataObj::GetText().
FORMATETC htmlFE;
SET_FORMATETC(htmlFE, CF_HTML, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL);
dObj->AddDataFlavor(kHTMLMime, &htmlFE);
}
else if ( strcmp(flavorStr, kURLMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kURLMime)) {
// if we're a url, in addition to also being text, we need to register
// the "file" flavors so that the win32 shell knows to create an internet
// shortcut when it sees one of these beasts.
@ -220,19 +220,21 @@ nsresult nsClipboard::SetupNativeDataObject(nsITransferable * aTransferable, IDa
SET_FORMATETC(shortcutFE, ::RegisterClipboardFormat(CFSTR_INETURLW), 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
dObj->AddDataFlavor(kURLMime, &shortcutFE);
}
else if ( strcmp(flavorStr, kPNGImageMime) == 0 || strcmp(flavorStr, kJPEGImageMime) == 0 ||
strcmp(flavorStr, kJPGImageMime) == 0 || strcmp(flavorStr, kGIFImageMime) == 0 ||
strcmp(flavorStr, kNativeImageMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kPNGImageMime) ||
flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) ||
flavorStr.EqualsLiteral(kGIFImageMime) ||
flavorStr.EqualsLiteral(kNativeImageMime)) {
// if we're an image, register the native bitmap flavor
FORMATETC imageFE;
// Add DIBv5
SET_FORMATETC(imageFE, CF_DIBV5, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
dObj->AddDataFlavor(flavorStr, &imageFE);
dObj->AddDataFlavor(flavorStr.get(), &imageFE);
// Add DIBv3
SET_FORMATETC(imageFE, CF_DIB, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL)
dObj->AddDataFlavor(flavorStr, &imageFE);
dObj->AddDataFlavor(flavorStr.get(), &imageFE);
}
else if ( strcmp(flavorStr, kFilePromiseMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kFilePromiseMime)) {
// if we're a file promise flavor, also register the
// CFSTR_PREFERREDDROPEFFECT format. The data object
// returns a value of DROPEFFECTS_MOVE to the drop target
@ -613,9 +615,9 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
for (i=0;i<cnt;i++) {
nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryElementAt(flavorList, i);
if ( currentFlavor ) {
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
UINT format = GetFormat(flavorStr);
UINT format = GetFormat(flavorStr.get());
// Try to get the data using the desired flavor. This might fail, but all is
// not lost.
@ -623,7 +625,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
uint32_t dataLen = 0;
bool dataFound = false;
if (nullptr != aDataObject) {
if (NS_SUCCEEDED(GetNativeDataOffClipboard(aDataObject, anIndex, format, flavorStr, &data, &dataLen))) {
if (NS_SUCCEEDED(GetNativeDataOffClipboard(aDataObject, anIndex, format, flavorStr.get(), &data, &dataLen))) {
dataFound = true;
}
}
@ -637,10 +639,10 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
// when directly asking for the flavor. Let's try digging around in other
// flavors to help satisfy our craving for data.
if ( !dataFound ) {
if (strcmp(flavorStr, kUnicodeMime) == 0) {
if (flavorStr.EqualsLiteral(kUnicodeMime)) {
dataFound = FindUnicodeFromPlainText(aDataObject, anIndex, &data, &dataLen);
}
else if ( strcmp(flavorStr, kURLMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kURLMime)) {
// drags from other windows apps expose the native
// CFSTR_INETURL{A,W} flavor
dataFound = FindURLFromNativeURL ( aDataObject, anIndex, &data, &dataLen );
@ -653,7 +655,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
// Hopefully by this point we've found it and can go about our business
if ( dataFound ) {
nsCOMPtr<nsISupports> genericDataWrapper;
if ( strcmp(flavorStr, kFileMime) == 0 ) {
if (flavorStr.EqualsLiteral(kFileMime)) {
// we have a file path in |data|. Create an nsLocalFile object.
nsDependentString filepath(reinterpret_cast<char16_t*>(data));
nsCOMPtr<nsIFile> file;
@ -662,7 +664,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
}
free(data);
}
else if ( strcmp(flavorStr, kNativeHTMLMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kNativeHTMLMime)) {
uint32_t dummy;
// the editor folks want CF_HTML exactly as it's on the clipboard, no conversions,
// no fancy stuff. Pull it off the clipboard, stuff it into a wrapper and hand
@ -677,7 +679,7 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
}
free(data);
}
else if ( strcmp(flavorStr, kHTMLMime) == 0 ) {
else if (flavorStr.EqualsLiteral(kHTMLMime)) {
uint32_t startOfData = 0;
// The JS folks want CF_HTML exactly as it is on the clipboard, but
// minus the CF_HTML header index information.
@ -694,23 +696,23 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
}
free(data);
}
else if ( strcmp(flavorStr, kJPEGImageMime) == 0 ||
strcmp(flavorStr, kJPGImageMime) == 0 ||
strcmp(flavorStr, kPNGImageMime) == 0) {
else if (flavorStr.EqualsLiteral(kJPEGImageMime) ||
flavorStr.EqualsLiteral(kJPGImageMime) ||
flavorStr.EqualsLiteral(kPNGImageMime)) {
nsIInputStream * imageStream = reinterpret_cast<nsIInputStream*>(data);
genericDataWrapper = do_QueryInterface(imageStream);
NS_IF_RELEASE(imageStream);
}
else {
// Treat custom types as a string of bytes.
if (strcmp(flavorStr, kCustomTypesMime) != 0) {
if (!flavorStr.EqualsLiteral(kCustomTypesMime)) {
// we probably have some form of text. The DOM only wants LF, so convert from Win32 line
// endings to DOM line endings.
int32_t signedLen = static_cast<int32_t>(dataLen);
nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks ( flavorStr, &data, &signedLen );
nsLinebreakHelpers::ConvertPlatformToDOMLinebreaks(flavorStr, &data, &signedLen);
dataLen = signedLen;
if (strcmp(flavorStr, kRTFMime) == 0) {
if (flavorStr.EqualsLiteral(kRTFMime)) {
// RTF on Windows is known to sometimes deliver an extra null byte.
if (dataLen > 0 && static_cast<char*>(data)[dataLen - 1] == '\0') {
dataLen--;
@ -718,12 +720,12 @@ nsresult nsClipboard::GetDataFromDataObject(IDataObject * aDataObject,
}
}
nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, data, dataLen, getter_AddRefs(genericDataWrapper) );
nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, data, dataLen, getter_AddRefs(genericDataWrapper));
free(data);
}
NS_ASSERTION ( genericDataWrapper, "About to put null data into the transferable" );
aTransferable->SetTransferData(flavorStr, genericDataWrapper, dataLen);
aTransferable->SetTransferData(flavorStr.get(), genericDataWrapper, dataLen);
res = NS_OK;
// we found one, get out of the loop

View File

@ -1341,7 +1341,8 @@ HRESULT nsDataObj::GetText(const nsACString & aDataFlavor, FORMATETC& aFE, STGME
mTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper), &len);
if ( !len )
return E_FAIL;
nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, len );
nsPrimitiveHelpers::CreateDataFromPrimitive(
nsDependentCString(flavorStr), genericDataWrapper, &data, len);
if ( !data )
return E_FAIL;

View File

@ -789,14 +789,14 @@ NS_CreateServicesFromCategory(const char* aCategory,
continue;
}
nsXPIDLCString contractID;
nsCString contractID;
rv = categoryManager->GetCategoryEntry(aCategory, entryString.get(),
getter_Copies(contractID));
if (NS_FAILED(rv)) {
continue;
}
nsCOMPtr<nsISupports> instance = do_GetService(contractID);
nsCOMPtr<nsISupports> instance = do_GetService(contractID.get());
if (!instance) {
LogMessage("While creating services from category '%s', could not create service for entry '%s', contract ID '%s'",
aCategory, entryString.get(), contractID.get());

View File

@ -1282,13 +1282,14 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand,
nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
nsXPIDLCString contractID;
nsCString contractID;
rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "application/vnd.mozilla.xul+xml",
getter_Copies(contractID));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDocumentLoaderFactory> factory(do_GetService(contractID, &rv));
nsCOMPtr<nsIDocumentLoaderFactory>
factory(do_GetService(contractID.get(), &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIURI> uri;
@ -1342,13 +1343,14 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand,
nsCOMPtr<nsICategoryManager> catMan(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
nsXPIDLCString contractID;
nsCString contractID;
rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "text/html",
getter_Copies(contractID));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDocumentLoaderFactory> factory(do_GetService(contractID, &rv));
nsCOMPtr<nsIDocumentLoaderFactory>
factory(do_GetService(contractID.get(), &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStreamListener> listener;