From e3b2da9c83158db5eb273f812da13241afbf3572 Mon Sep 17 00:00:00 2001 From: "alecf%netscape.com" Date: Mon, 26 Aug 2002 21:20:34 +0000 Subject: [PATCH] bug 157624 - freeze nsISupportsPrimitives, which includes changing nsISupport[C]String over to using A[C]String and fixing consumers r=dougt, sr=darin git-svn-id: svn://10.0.0.236/trunk@128163 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/src/nsContentAreaDragDrop.cpp | 14 +- mozilla/content/base/src/nsContentPolicy.cpp | 8 +- mozilla/content/base/src/nsCopySupport.cpp | 9 +- mozilla/dom/src/base/nsDOMClassInfo.cpp | 9 +- .../dom/src/base/nsScriptNameSpaceManager.cpp | 13 +- .../src/build/nsScriptNameSpaceManager.cpp | 13 +- .../composer/src/nsComposerController.cpp | 1 - .../libeditor/html/nsHTMLDataTransfer.cpp | 75 +++---- .../text/nsPlaintextDataTransfer.cpp | 13 +- .../appstartup/src/nsAppStartupNotifier.cpp | 6 +- .../commandhandler/src/nsCommandGroup.cpp | 4 +- .../windowwatcher/src/nsWindowWatcher.cpp | 17 +- .../xmlextras/base/src/nsXMLHttpRequest.cpp | 2 +- mozilla/gfx/src/nsFontList.cpp | 2 +- mozilla/gfx/src/nsPrintOptionsImpl.cpp | 2 +- mozilla/intl/strres/src/nsStringBundle.cpp | 6 +- .../uconv/src/nsCharsetConverterManager.cpp | 4 +- .../js/src/xpconnect/src/xpccomponents.cpp | 7 +- mozilla/layout/base/nsPresState.cpp | 6 +- mozilla/layout/base/src/nsCopySupport.cpp | 9 +- mozilla/layout/base/src/nsPresState.cpp | 6 +- .../src/nsAbLDAPAutoCompFormatter.cpp | 2 +- mozilla/mailnews/addrbook/src/nsAbView.cpp | 8 +- .../base/resources/content/mailCommands.js | 2 +- .../base/src/nsMessengerBootstrap.cpp | 2 +- .../base/src/nsMsgAccountManagerDS.cpp | 4 +- .../compose/src/nsMsgComposeProgress.cpp | 2 +- .../import/comm4x/src/nsComm4xMailImport.cpp | 2 +- .../import/eudora/src/nsEudoraImport.cpp | 2 +- .../mailnews/import/oexpress/nsOEImport.cpp | 2 +- .../import/outlook/src/nsOutlookImport.cpp | 2 +- .../import/src/nsImportAddressBooks.cpp | 32 +-- mozilla/mailnews/import/src/nsImportMail.cpp | 64 ++---- mozilla/modules/libpref/src/nsPref.cpp | 24 +- mozilla/modules/libpref/src/nsPrefBranch.cpp | 35 ++- mozilla/modules/libpref/src/nsPrefBranch.h | 4 + mozilla/netwerk/base/src/nsIOService.cpp | 8 +- .../base/src/nsSocketTransportService.cpp | 1 - .../protocol/http/src/nsHttpChannel.cpp | 10 +- .../protocol/http/src/nsHttpHandler.cpp | 1 - .../src/nsStreamConverterService.cpp | 6 +- mozilla/netwerk/test/TestCacheService.cpp | 2 +- .../pref-migrator/src/nsPrefMigration.cpp | 1 - mozilla/profile/src/nsProfile.cpp | 7 +- mozilla/widget/src/os2/nsDragService.cpp | 14 +- mozilla/widget/src/windows/nsDataObj.cpp | 20 +- .../src/xpwidgets/nsClipboardHelper.cpp | 2 +- .../src/xpwidgets/nsHTMLFormatConverter.cpp | 10 +- .../src/xpwidgets/nsPrimitiveHelpers.cpp | 23 +- .../widget/src/xpwidgets/nsTransferable.cpp | 10 +- .../xpcom/components/nsCategoryManager.cpp | 9 +- .../xpcom/components/nsComponentManager.cpp | 22 +- mozilla/xpcom/ds/nsISupportsPrimitives.idl | 42 +--- mozilla/xpcom/ds/nsSupportsPrimitives.cpp | 210 +++--------------- mozilla/xpcom/ds/nsSupportsPrimitives.h | 17 +- .../appshell/src/nsCommandLineServiceMac.cpp | 2 +- mozilla/xpfe/bootstrap/nsAppRunner.cpp | 12 +- .../xpfe/bootstrap/nsNativeAppSupportOS2.cpp | 2 +- .../xpfe/bootstrap/nsNativeAppSupportWin.cpp | 6 +- .../components/alerts/src/nsAlertsService.cpp | 9 +- .../bookmarks/src/nsBookmarksService.cpp | 2 +- .../startup/src/nsCommandLineServiceMac.cpp | 2 +- .../components/xremote/src/XRemoteService.cpp | 4 +- 63 files changed, 335 insertions(+), 532 deletions(-) diff --git a/mozilla/content/base/src/nsContentAreaDragDrop.cpp b/mozilla/content/base/src/nsContentAreaDragDrop.cpp index e0621e4be14..f80dfd95738 100644 --- a/mozilla/content/base/src/nsContentAreaDragDrop.cpp +++ b/mozilla/content/base/src/nsContentAreaDragDrop.cpp @@ -293,9 +293,7 @@ nsContentAreaDragDrop::ExtractURLFromData(const nsACString & inFlavor, nsISuppor // may not be. *shrug* nsCOMPtr stringData(do_QueryInterface(inDataWrapper)); if ( stringData ) { - nsXPIDLString data; - stringData->GetData(getter_Copies(data)); - outURL = data; + stringData->GetData(outURL); } } else if ( inFlavor.Equals(kURLMime) ) { @@ -303,8 +301,8 @@ nsContentAreaDragDrop::ExtractURLFromData(const nsACString & inFlavor, nsISuppor // out the url piece and return that. nsCOMPtr stringData(do_QueryInterface(inDataWrapper)); if ( stringData ) { - nsXPIDLString data; - stringData->GetData(getter_Copies(data)); + nsAutoString data; + stringData->GetData(data); PRInt32 separator = data.FindChar('\n'); if ( separator >= 0 ) outURL = Substring(data, 0, separator); @@ -914,7 +912,7 @@ nsContentAreaDragDrop::CreateTransferable(const nsAString & inURLString, const n nsCOMPtr urlPrimitive(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if ( !urlPrimitive ) return NS_ERROR_FAILURE; - urlPrimitive->SetData(dragData.get()); + urlPrimitive->SetData(dragData); trans->SetTransferData(kURLMime, urlPrimitive, dragData.Length() * 2); } @@ -922,7 +920,7 @@ nsContentAreaDragDrop::CreateTransferable(const nsAString & inURLString, const n nsCOMPtr htmlPrimitive(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if ( !htmlPrimitive ) return NS_ERROR_FAILURE; - htmlPrimitive->SetData(PromiseFlatString(inHTMLString).get()); + htmlPrimitive->SetData(inHTMLString); trans->SetTransferData(kHTMLMime, htmlPrimitive, inHTMLString.Length() * 2); // add the plain (unicode) text. we use the url for text/unicode data if an anchor @@ -931,7 +929,7 @@ nsContentAreaDragDrop::CreateTransferable(const nsAString & inURLString, const n nsCOMPtr textPrimitive(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); if ( !textPrimitive ) return NS_ERROR_FAILURE; - textPrimitive->SetData(PromiseFlatString(inIsAnchor ? inURLString : inTitleString).get()); + textPrimitive->SetData(inIsAnchor ? inURLString : inTitleString); trans->SetTransferData(kUnicodeMime, textPrimitive, (inIsAnchor ? inURLString.Length() : inTitleString.Length()) * 2); // add image data, if present. For now, all we're going to do with this is turn it diff --git a/mozilla/content/base/src/nsContentPolicy.cpp b/mozilla/content/base/src/nsContentPolicy.cpp index 0ed0ad51190..ea906cb371f 100644 --- a/mozilla/content/base/src/nsContentPolicy.cpp +++ b/mozilla/content/base/src/nsContentPolicy.cpp @@ -82,12 +82,12 @@ nsContentPolicy::nsContentPolicy() if (NS_FAILED(rv)) continue; - nsXPIDLCString contractid; - if (NS_FAILED(string->GetData(getter_Copies(contractid)))) + nsCAutoString contractid; + if (NS_FAILED(string->GetData(contractid))) continue; #ifdef DEBUG_shaver - fprintf(stderr, "POLICY: loading %s\n", (const char *)contractid); + fprintf(stderr, "POLICY: loading %s\n", contractid.get()); #endif /* * Create this policy service and add to mPolicies. @@ -95,7 +95,7 @@ nsContentPolicy::nsContentPolicy() * Should we try to parse as a CID, in case the component prefers to be * registered that way? */ - nsCOMPtr policy = do_GetService(contractid, &rv); + nsCOMPtr policy = do_GetService(contractid.get(), &rv); if (NS_SUCCEEDED(rv)) mPolicies->AppendElement(policy); } diff --git a/mozilla/content/base/src/nsCopySupport.cpp b/mozilla/content/base/src/nsCopySupport.cpp index a0fa4545d9b..3b65972e125 100644 --- a/mozilla/content/base/src/nsCopySupport.cpp +++ b/mozilla/content/base/src/nsCopySupport.cpp @@ -209,16 +209,13 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16 // populate the strings nsresult data_rv = NS_OK, context_rv = NS_OK, info_rv = NS_OK; data_rv = - dataWrapper->SetDataWithLength(buffer.Length(), - NS_CONST_CAST(PRUnichar*, buffer.get())); + dataWrapper->SetData(buffer); if (bIsHTMLCopy) { context_rv = - contextWrapper->SetDataWithLength(parents.Length(), - NS_CONST_CAST(PRUnichar*, parents.get())); + contextWrapper->SetData(parents); info_rv = - infoWrapper->SetDataWithLength(info.Length(), - NS_CONST_CAST(PRUnichar*, info.get())); + infoWrapper->SetData(info); } // QI the data object an |nsISupports| so that when the transferable holds diff --git a/mozilla/dom/src/base/nsDOMClassInfo.cpp b/mozilla/dom/src/base/nsDOMClassInfo.cpp index 4c84e665e7f..6ec67691057 100644 --- a/mozilla/dom/src/base/nsDOMClassInfo.cpp +++ b/mozilla/dom/src/base/nsDOMClassInfo.cpp @@ -1146,7 +1146,8 @@ nsDOMClassInfo::RegisterExternalClasses() rv = cm->EnumerateCategory(JAVASCRIPT_DOM_CLASS, getter_AddRefs(e)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLCString categoryEntry, contractId; + nsXPIDLCString contractId; + nsCAutoString categoryEntry; nsCOMPtr entry; while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) { @@ -1157,9 +1158,9 @@ nsDOMClassInfo::RegisterExternalClasses() continue; } - rv = category->GetData(getter_Copies(categoryEntry)); + rv = category->GetData(categoryEntry); - cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry, + cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(), getter_Copies(contractId)); NS_ENSURE_SUCCESS(rv, rv); @@ -1171,7 +1172,7 @@ nsDOMClassInfo::RegisterExternalClasses() continue; } - rv = gNameSpaceManager->RegisterExternalClassName(categoryEntry, cid); + rv = gNameSpaceManager->RegisterExternalClassName(categoryEntry.get(), cid); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/mozilla/dom/src/base/nsScriptNameSpaceManager.cpp b/mozilla/dom/src/base/nsScriptNameSpaceManager.cpp index 315927a3799..ae74db8d971 100644 --- a/mozilla/dom/src/base/nsScriptNameSpaceManager.cpp +++ b/mozilla/dom/src/base/nsScriptNameSpaceManager.cpp @@ -171,7 +171,7 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager, getter_AddRefs(e)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLCString categoryEntry; + nsCAutoString categoryEntry; nsXPIDLCString contractId; nsCOMPtr entry; @@ -184,9 +184,9 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager, continue; } - rv = category->GetData(getter_Copies(categoryEntry)); + rv = category->GetData(categoryEntry); - aCategoryManager->GetCategoryEntry(aCategory, categoryEntry, + aCategoryManager->GetCategoryEntry(aCategory, categoryEntry.get(), getter_Copies(contractId)); NS_ENSURE_SUCCESS(rv, rv); @@ -295,7 +295,8 @@ nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto) getter_AddRefs(enumerator)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLCString IID_string, category_entry; + nsXPIDLCString IID_string; + nsCAutoString category_entry; const char* if_name; nsCOMPtr entry; nsCOMPtr if_info; @@ -310,10 +311,10 @@ nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto) continue; } - rv = category->GetData(getter_Copies(category_entry)); + rv = category->GetData(category_entry); NS_ENSURE_SUCCESS(rv, rv); - rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry, + rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry.get(), getter_Copies(IID_string)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/dom/src/build/nsScriptNameSpaceManager.cpp b/mozilla/dom/src/build/nsScriptNameSpaceManager.cpp index 315927a3799..ae74db8d971 100644 --- a/mozilla/dom/src/build/nsScriptNameSpaceManager.cpp +++ b/mozilla/dom/src/build/nsScriptNameSpaceManager.cpp @@ -171,7 +171,7 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager, getter_AddRefs(e)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLCString categoryEntry; + nsCAutoString categoryEntry; nsXPIDLCString contractId; nsCOMPtr entry; @@ -184,9 +184,9 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager, continue; } - rv = category->GetData(getter_Copies(categoryEntry)); + rv = category->GetData(categoryEntry); - aCategoryManager->GetCategoryEntry(aCategory, categoryEntry, + aCategoryManager->GetCategoryEntry(aCategory, categoryEntry.get(), getter_Copies(contractId)); NS_ENSURE_SUCCESS(rv, rv); @@ -295,7 +295,8 @@ nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto) getter_AddRefs(enumerator)); NS_ENSURE_SUCCESS(rv, rv); - nsXPIDLCString IID_string, category_entry; + nsXPIDLCString IID_string; + nsCAutoString category_entry; const char* if_name; nsCOMPtr entry; nsCOMPtr if_info; @@ -310,10 +311,10 @@ nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto) continue; } - rv = category->GetData(getter_Copies(category_entry)); + rv = category->GetData(category_entry); NS_ENSURE_SUCCESS(rv, rv); - rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry, + rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry.get(), getter_Copies(IID_string)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/editor/composer/src/nsComposerController.cpp b/mozilla/editor/composer/src/nsComposerController.cpp index 9ac738fd42d..6e6be6ea3ee 100644 --- a/mozilla/editor/composer/src/nsComposerController.cpp +++ b/mozilla/editor/composer/src/nsComposerController.cpp @@ -49,7 +49,6 @@ #include "nsIFormControlFrame.h" #include "nsISelection.h" #include "nsIHTMLEditor.h" -#include "nsISupportsPrimitives.h" #include "nsXPIDLString.h" #include "nsISelectionController.h" diff --git a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp index 58ba47a6a10..d8e94b27c1f 100644 --- a/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -808,15 +808,14 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable nsCOMPtr textDataObj ( do_QueryInterface(genericDataObj) ); if (textDataObj && len > 0) { - PRUnichar* text = nsnull; + nsAutoString text; - textDataObj->ToString ( &text ); - nsAutoString debugDump (text); - stuffToPaste.Assign ( text, len / 2 ); + textDataObj->GetData ( text ); + + NS_ASSERTION(text.Length() <= (len/2), "Invalid length!"); + stuffToPaste.Assign ( text.get(), len / 2 ); nsAutoEditBatch beginBatching(this); rv = InsertHTMLWithContext(stuffToPaste, aContextStr, aInfoStr); - if (text) - nsMemory::Free(text); } } else if (flavor.Equals(NS_LITERAL_STRING(kUnicodeMime))) @@ -824,15 +823,14 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable nsCOMPtr textDataObj ( do_QueryInterface(genericDataObj) ); if (textDataObj && len > 0) { - PRUnichar* text = nsnull; - textDataObj->ToString ( &text ); - stuffToPaste.Assign ( text, len / 2 ); + nsAutoString text; + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (len/2), "Invalid length!"); + stuffToPaste.Assign ( text.get(), len / 2 ); nsAutoEditBatch beginBatching(this); // pasting does not inherit local inline styles RemoveAllInlineProperties(); rv = InsertText(stuffToPaste); - if (text) - nsMemory::Free(text); } } else if (flavor.Equals(NS_LITERAL_STRING(kFileMime))) @@ -959,22 +957,20 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) if (contextDataObj) { - PRUnichar* text = nsnull; + nsAutoString text; textDataObj = do_QueryInterface(contextDataObj); - textDataObj->ToString ( &text ); - contextStr.Assign ( text, contextLen / 2 ); - if (text) - nsMemory::Free(text); + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (contextLen/2), "Invalid length!"); + contextStr.Assign ( text.get(), contextLen / 2 ); } if (infoDataObj) { - PRUnichar* text = nsnull; + nsAutoString text; textDataObj = do_QueryInterface(infoDataObj); - textDataObj->ToString ( &text ); - infoStr.Assign ( text, infoLen / 2 ); - if (text) - nsMemory::Free(text); + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (infoLen/2), "Invalid length!"); + infoStr.Assign ( text.get(), infoLen / 2 ); } if ( doPlaceCaret ) @@ -1268,7 +1264,7 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent) dataWrapper = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID); NS_ENSURE_TRUE(dataWrapper, NS_ERROR_FAILURE); - rv = dataWrapper->SetData( NS_CONST_CAST(PRUnichar*, buffer.get()) ); + rv = dataWrapper->SetData(buffer); if (NS_FAILED(rv)) return rv; if (bIsPlainTextControl) @@ -1290,8 +1286,8 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent) infoWrapper = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID); NS_ENSURE_TRUE(infoWrapper, NS_ERROR_FAILURE); - contextWrapper->SetData ( NS_CONST_CAST(PRUnichar*,parents.get()) ); - infoWrapper->SetData ( NS_CONST_CAST(PRUnichar*,info.get()) ); + contextWrapper->SetData ( parents ); + infoWrapper->SetData ( info ); rv = trans->AddDataFlavor(kHTMLMime); if (NS_FAILED(rv)) return rv; @@ -1383,22 +1379,20 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType) if (contextDataObj) { - PRUnichar* text = nsnull; + nsAutoString text; textDataObj = do_QueryInterface(contextDataObj); - textDataObj->ToString ( &text ); - contextStr.Assign ( text, contextLen / 2 ); - if (text) - nsMemory::Free(text); + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (contextLen/2), "Invalid length!"); + contextStr.Assign ( text.get(), contextLen / 2 ); } if (infoDataObj) { - PRUnichar* text = nsnull; + nsAutoString text; textDataObj = do_QueryInterface(infoDataObj); - textDataObj->ToString ( &text ); - infoStr.Assign ( text, infoLen / 2 ); - if (text) - nsMemory::Free(text); + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (infoLen/2), "Invalid length!"); + infoStr.Assign ( text.get(), infoLen / 2 ); } rv = InsertFromTransferable(trans, contextStr, infoStr); } @@ -1442,7 +1436,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) NS_GET_IID(nsISupportsCString), getter_AddRefs(flavorString)); if (flavorString) { - flavorString->SetData(*flavor); + flavorString->SetData(nsDependentCString(*flavor)); flavorsList->AppendElement(flavorString); } } @@ -1459,7 +1453,7 @@ NS_IMETHODIMP nsHTMLEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPaste) NS_GET_IID(nsISupportsCString), getter_AddRefs(flavorString)); if (flavorString) { - flavorString->SetData(*htmlFlavor); + flavorString->SetData(nsDependentCString(*htmlFlavor)); flavorsList->AppendElement(flavorString); } } @@ -1581,13 +1575,12 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType) nsCOMPtr textDataObj ( do_QueryInterface(genericDataObj) ); if (textDataObj && len > 0) { - PRUnichar* text = nsnull; - textDataObj->ToString ( &text ); - stuffToPaste.Assign ( text, len / 2 ); + nsAutoString text; + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (len/2), "Invalid length!"); + stuffToPaste.Assign ( text.get(), len / 2 ); nsAutoEditBatch beginBatching(this); rv = InsertAsPlaintextQuotation(stuffToPaste, 0); - if (text) - nsMemory::Free(text); } } nsCRT::free(flav); diff --git a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp index fed12548912..f2a5a51b1bf 100644 --- a/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/mozilla/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -168,13 +168,12 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *tra nsCOMPtr textDataObj ( do_QueryInterface(genericDataObj) ); if (textDataObj && len > 0) { - PRUnichar* text = nsnull; - textDataObj->ToString ( &text ); - stuffToPaste.Assign ( text, len / 2 ); + nsAutoString text; + textDataObj->GetData ( text ); + NS_ASSERTION(text.Length() <= (len/2), "Invalid length!"); + stuffToPaste.Assign ( text.get(), len / 2 ); nsAutoEditBatch beginBatching(this); rv = InsertText(stuffToPaste); - if (text) - nsMemory::Free(text); } } } @@ -496,7 +495,7 @@ NS_IMETHODIMP nsPlaintextEditor::DoDrag(nsIDOMEvent *aDragEvent) nsCOMPtr dataWrapper = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID); NS_ENSURE_TRUE(dataWrapper, NS_ERROR_FAILURE); - rv = dataWrapper->SetData( NS_CONST_CAST(PRUnichar*, buffer.get()) ); + rv = dataWrapper->SetData( buffer ); if (NS_FAILED(rv)) return rv; if (bIsPlainTextControl) @@ -606,7 +605,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanPaste(PRInt32 aSelectionType, PRBool *aCanPa NS_GET_IID(nsISupportsCString), getter_AddRefs(flavorString)); if (flavorString) { - flavorString->SetData(*flavor); + flavorString->SetData(nsDependentCString(*flavor)); flavorsList->AppendElement(flavorString); } } diff --git a/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp b/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp index 64c2091db05..5195011787e 100644 --- a/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp +++ b/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp @@ -75,12 +75,12 @@ NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const char *a nsCOMPtr category = do_QueryInterface(entry, &rv); if (NS_SUCCEEDED(rv)) { - nsXPIDLCString categoryEntry; - rv = category->GetData(getter_Copies(categoryEntry)); + nsCAutoString categoryEntry; + rv = category->GetData(categoryEntry); nsXPIDLCString contractId; categoryManager->GetCategoryEntry(aTopic, - categoryEntry, + categoryEntry.get(), getter_Copies(contractId)); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/embedding/components/commandhandler/src/nsCommandGroup.cpp b/mozilla/embedding/components/commandhandler/src/nsCommandGroup.cpp index 312bb7a0262..0d097f5b290 100644 --- a/mozilla/embedding/components/commandhandler/src/nsCommandGroup.cpp +++ b/mozilla/embedding/components/commandhandler/src/nsCommandGroup.cpp @@ -129,7 +129,7 @@ nsGroupsEnumerator::GetNext(nsISupports **_retval) nsCOMPtr supportsString = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; - supportsString->SetData(thisGroupName); + supportsString->SetData(nsDependentCString(thisGroupName)); return CallQueryInterface(supportsString, _retval); } @@ -225,7 +225,7 @@ nsNamedGroupEnumerator::GetNext(nsISupports **_retval) nsCOMPtr supportsString = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; - supportsString->SetData(thisGroupName); + supportsString->SetData(nsDependentString(thisGroupName)); return CallQueryInterface(supportsString, _retval); } diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 311ec271ee0..6f6277ecfb8 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -1740,11 +1740,12 @@ nsWindowWatcher::AddSupportsTojsvals(nsISupports *aArg, nsCOMPtr p(do_QueryInterface(argPrimitive)); NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED); - char *data; + nsCAutoString data; - p->GetData(&data); + p->GetData(data); - JSString *str = ::JS_NewString(cx, data, strlen(data)); + + JSString *str = ::JS_NewStringCopyN(cx, data.get(), data.Length()); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); *aArgv = STRING_TO_JSVAL(str); @@ -1755,14 +1756,16 @@ nsWindowWatcher::AddSupportsTojsvals(nsISupports *aArg, nsCOMPtr p(do_QueryInterface(argPrimitive)); NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED); - PRUnichar *data; + nsAutoString data; - p->GetData(&data); + p->GetData(data); // cast is probably safe since wchar_t and jschar are expected // to be equivalent; both unsigned 16-bit entities - JSString *str = ::JS_NewUCString(cx, NS_REINTERPRET_CAST(jschar *, data), - nsCRT::strlen(data)); + JSString *str = + ::JS_NewUCStringCopyN(cx, + NS_REINTERPRET_CAST(const jschar *,data.get()), + data.Length()); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); *aArgv = STRING_TO_JSVAL(str); diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 28c8f990b4a..29bb3e9ef87 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -1061,7 +1061,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) // nsISupportsString? nsCOMPtr wstr(do_QueryInterface(supports)); if (wstr) { - wstr->GetData(getter_Copies(serial)); + wstr->GetData(serial); } else { // stream? nsCOMPtr stream(do_QueryInterface(supports)); diff --git a/mozilla/gfx/src/nsFontList.cpp b/mozilla/gfx/src/nsFontList.cpp index a482366bc55..feb26f80673 100644 --- a/mozilla/gfx/src/nsFontList.cpp +++ b/mozilla/gfx/src/nsFontList.cpp @@ -134,7 +134,7 @@ nsFontListEnumerator::GetNext(nsISupports **aFont) NS_GET_IID(nsISupportsString), getter_AddRefs(fontNameWrapper)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(fontNameWrapper, NS_ERROR_OUT_OF_MEMORY); - fontNameWrapper->SetData(NS_CONST_CAST(PRUnichar*, fontName)); + fontNameWrapper->SetData(nsDependentString(fontName)); *aFont = NS_STATIC_CAST(nsISupports*, fontNameWrapper); NS_ADDREF(*aFont); return NS_OK; diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index 31b05034b6c..fbc85e2b2c4 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -213,7 +213,7 @@ NS_IMETHODIMP nsPrinterListEnumerator::GetNext(nsISupports **aPrinter) NS_GET_IID(nsISupportsString), getter_AddRefs(printerNameWrapper)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(printerNameWrapper, NS_ERROR_OUT_OF_MEMORY); - printerNameWrapper->SetData(NS_CONST_CAST(PRUnichar*, printerName)); + printerNameWrapper->SetData(nsDependentString(printerName)); *aPrinter = NS_STATIC_CAST(nsISupports*, printerNameWrapper); NS_ADDREF(*aPrinter); return NS_OK; diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index 8a82b030f1a..9420dc9553b 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -507,13 +507,13 @@ nsExtensibleStringBundle::Init(const char * aCategory, if (NS_FAILED(rv)) continue; - nsXPIDLCString name; - rv = supStr->GetData(getter_Copies(name)); + nsCAutoString name; + rv = supStr->GetData(name); if (NS_FAILED(rv)) continue; nsCOMPtr bundle; - rv = aBundleService->CreateBundle(name, getter_AddRefs(bundle)); + rv = aBundleService->CreateBundle(name.get(), getter_AddRefs(bundle)); if (NS_FAILED(rv)) continue; diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp index 51a7770c6e0..e8aa496f20b 100644 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp @@ -303,8 +303,8 @@ nsCharsetConverterManager::GetList(const nsACString& aCategory, nsCAutoString fullName(aPrefix); - nsXPIDLCString name; - if (NS_FAILED(supStr->GetData(getter_Copies(name)))) + nsCAutoString name; + if (NS_FAILED(supStr->GetData(name))) continue; fullName += name; diff --git a/mozilla/js/src/xpconnect/src/xpccomponents.cpp b/mozilla/js/src/xpconnect/src/xpccomponents.cpp index 7beb81c2dbe..d69f21700a2 100644 --- a/mozilla/js/src/xpconnect/src/xpccomponents.cpp +++ b/mozilla/js/src/xpconnect/src/xpccomponents.cpp @@ -392,11 +392,10 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper, nsCOMPtr holder(do_QueryInterface(isup)); if(holder) { - char* name; - if(NS_SUCCEEDED(holder->GetData(&name)) && name) + nsCAutoString name; + if(NS_SUCCEEDED(holder->GetData(name))) { - JSString* idstr = JS_NewStringCopyZ(cx, name); - nsMemory::Free(name); + JSString* idstr = JS_NewStringCopyN(cx, name.get(), name.Length()); if(idstr && JS_ValueToId(cx, STRING_TO_JSVAL(idstr), idp)) { diff --git a/mozilla/layout/base/nsPresState.cpp b/mozilla/layout/base/nsPresState.cpp index 92fcd9e1fff..0f6c9bd595f 100644 --- a/mozilla/layout/base/nsPresState.cpp +++ b/mozilla/layout/base/nsPresState.cpp @@ -74,8 +74,8 @@ nsPresState::GetStateProperty(const nsAString& aName, mPropertyTable->Get(&key))); if (supportsStr) { - nsXPIDLCString data; - supportsStr->GetData(getter_Copies(data)); + nsCAutoString data; + supportsStr->GetData(data); aResult.Append(NS_ConvertUTF8toUCS2(data)); } @@ -99,7 +99,7 @@ nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue) nsCOMPtr supportsStr(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY); - supportsStr->SetData(NS_ConvertUCS2toUTF8(aValue).get()); + supportsStr->SetData(NS_ConvertUCS2toUTF8(aValue)); mPropertyTable->Put(&key, supportsStr); return NS_OK; diff --git a/mozilla/layout/base/src/nsCopySupport.cpp b/mozilla/layout/base/src/nsCopySupport.cpp index a0fa4545d9b..3b65972e125 100644 --- a/mozilla/layout/base/src/nsCopySupport.cpp +++ b/mozilla/layout/base/src/nsCopySupport.cpp @@ -209,16 +209,13 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16 // populate the strings nsresult data_rv = NS_OK, context_rv = NS_OK, info_rv = NS_OK; data_rv = - dataWrapper->SetDataWithLength(buffer.Length(), - NS_CONST_CAST(PRUnichar*, buffer.get())); + dataWrapper->SetData(buffer); if (bIsHTMLCopy) { context_rv = - contextWrapper->SetDataWithLength(parents.Length(), - NS_CONST_CAST(PRUnichar*, parents.get())); + contextWrapper->SetData(parents); info_rv = - infoWrapper->SetDataWithLength(info.Length(), - NS_CONST_CAST(PRUnichar*, info.get())); + infoWrapper->SetData(info); } // QI the data object an |nsISupports| so that when the transferable holds diff --git a/mozilla/layout/base/src/nsPresState.cpp b/mozilla/layout/base/src/nsPresState.cpp index 92fcd9e1fff..0f6c9bd595f 100644 --- a/mozilla/layout/base/src/nsPresState.cpp +++ b/mozilla/layout/base/src/nsPresState.cpp @@ -74,8 +74,8 @@ nsPresState::GetStateProperty(const nsAString& aName, mPropertyTable->Get(&key))); if (supportsStr) { - nsXPIDLCString data; - supportsStr->GetData(getter_Copies(data)); + nsCAutoString data; + supportsStr->GetData(data); aResult.Append(NS_ConvertUTF8toUCS2(data)); } @@ -99,7 +99,7 @@ nsPresState::SetStateProperty(const nsAString& aName, const nsAString& aValue) nsCOMPtr supportsStr(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); NS_ENSURE_TRUE(supportsStr, NS_ERROR_OUT_OF_MEMORY); - supportsStr->SetData(NS_ConvertUCS2toUTF8(aValue).get()); + supportsStr->SetData(NS_ConvertUCS2toUTF8(aValue)); mPropertyTable->Put(&key, supportsStr); return NS_OK; diff --git a/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp b/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp index ab3ea3ec347..b3b83b242e9 100644 --- a/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp @@ -327,7 +327,7 @@ nsAbLDAPAutoCompFormatter::FormatException(PRInt32 aState, NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): " "could not create nsISupportsString"); } else { - rv = alert->SetData(alertMsg.get()); + rv = alert->SetData(alertMsg); if (NS_FAILED(rv)) { NS_WARNING("nsAbLDAPAutoCompFormatter::FormatException(): " "alert.Set() failed"); diff --git a/mozilla/mailnews/addrbook/src/nsAbView.cpp b/mozilla/mailnews/addrbook/src/nsAbView.cpp index ee35b246802..f7cd574b25a 100644 --- a/mozilla/mailnews/addrbook/src/nsAbView.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbView.cpp @@ -1206,8 +1206,8 @@ NS_IMETHODIMP nsAbView::GetSelectedAddresses(nsISupportsArray **_retval) NS_ENSURE_SUCCESS(rv,rv); if (!primaryEmail.IsEmpty()) { - nsCOMPtr supportsEmail(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); - supportsEmail->SetDataWithLength(primaryEmail.Length(), ToNewCString(primaryEmail)); + nsCOMPtr supportsEmail(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); + supportsEmail->SetData(primaryEmail); addresses->AppendElement(supportsEmail); } } @@ -1217,8 +1217,8 @@ NS_IMETHODIMP nsAbView::GetSelectedAddresses(nsISupportsArray **_retval) NS_ENSURE_SUCCESS(rv,rv); if (!primaryEmail.IsEmpty()) { - nsCOMPtr supportsEmail(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); - supportsEmail->SetDataWithLength(primaryEmail.Length(), ToNewCString(primaryEmail)); + nsCOMPtr supportsEmail(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); + supportsEmail->SetData(primaryEmail); addresses->AppendElement(supportsEmail); } } diff --git a/mozilla/mailnews/base/resources/content/mailCommands.js b/mozilla/mailnews/base/resources/content/mailCommands.js index 0b6d5b73203..44a75eac348 100644 --- a/mozilla/mailnews/base/resources/content/mailCommands.js +++ b/mozilla/mailnews/base/resources/content/mailCommands.js @@ -221,7 +221,7 @@ function NewMessageToSelectedAddresses(type, format, identity) { if (composeFields) { var addressList = ""; for (var i = 0; i < addresses.Count(); i++) { - addressList = addressList + (i > 0 ? ",":"") + addresses.GetElementAt(i).QueryInterface(Components.interfaces.nsISupportsCString).data; + addressList = addressList + (i > 0 ? ",":"") + addresses.QueryElementAt(i,Components.interfaces.nsISupportsString).data; } composeFields.to = addressList; params.composeFields = composeFields; diff --git a/mozilla/mailnews/base/src/nsMessengerBootstrap.cpp b/mozilla/mailnews/base/src/nsMessengerBootstrap.cpp index 66fa72bd186..6b085193f75 100644 --- a/mozilla/mailnews/base/src/nsMessengerBootstrap.cpp +++ b/mozilla/mailnews/base/src/nsMessengerBootstrap.cpp @@ -115,7 +115,7 @@ NS_IMETHODIMP nsMessengerBootstrap::OpenMessengerWindowWithUri(const char *windo nsCOMPtr scriptableFolderURI (do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); NS_ENSURE_TRUE(scriptableFolderURI, NS_ERROR_FAILURE); - scriptableFolderURI->SetData(aFolderURI); + scriptableFolderURI->SetData(nsDependentCString(aFolderURI)); argsArray->AppendElement(scriptableFolderURI); nsCOMPtr scriptableMessageKey (do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID)); diff --git a/mozilla/mailnews/base/src/nsMsgAccountManagerDS.cpp b/mozilla/mailnews/base/src/nsMsgAccountManagerDS.cpp index 8ca57b2d657..c387d246c93 100644 --- a/mozilla/mailnews/base/src/nsMsgAccountManagerDS.cpp +++ b/mozilla/mailnews/base/src/nsMsgAccountManagerDS.cpp @@ -660,8 +660,8 @@ nsMsgAccountManagerDataSource::appendGenericSettingsResources(nsIMsgIncomingServ if (NS_FAILED(rv) || !catEntry) break; - nsXPIDLCString entryString; - rv = catEntry->GetData(getter_Copies(entryString)); + nsCAutoString entryString; + rv = catEntry->GetData(entryString); if (NS_FAILED(rv)) break; diff --git a/mozilla/mailnews/compose/src/nsMsgComposeProgress.cpp b/mozilla/mailnews/compose/src/nsMsgComposeProgress.cpp index 51abe3a5549..6a100d9c139 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeProgress.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeProgress.cpp @@ -85,7 +85,7 @@ nsMsgComposeProgress::OpenProgress(nsIDOMWindowInternal *parent, do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); - strptr->SetData(subject); + strptr->SetData(nsDependentString(subject)); array->AppendElement(strptr); diff --git a/mozilla/mailnews/import/comm4x/src/nsComm4xMailImport.cpp b/mozilla/mailnews/import/comm4x/src/nsComm4xMailImport.cpp index 256cfd34e76..0fde4e229db 100644 --- a/mozilla/mailnews/import/comm4x/src/nsComm4xMailImport.cpp +++ b/mozilla/mailnews/import/comm4x/src/nsComm4xMailImport.cpp @@ -162,7 +162,7 @@ NS_IMETHODIMP nsComm4xMailImport::GetImportInterface(const char *pImportType, ns nsCOMPtr nameString (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv)); NS_ENSURE_SUCCESS(rv,rv); - nameString->SetData(name.get()); + nameString->SetData(name); pGeneric->SetData("name", nameString); rv = pGeneric->QueryInterface(kISupportsIID, (void **)ppInterface); } diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp index 7fccf60bde1..87f0f12ecce 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp @@ -289,7 +289,7 @@ NS_IMETHODIMP nsEudoraImport::GetImportInterface( const char *pImportType, nsISu nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME, name); nsCOMPtr nameString (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { - nameString->SetData(name.get()); + nameString->SetData(name); pGeneric->SetData( "name", nameString); rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface); } diff --git a/mozilla/mailnews/import/oexpress/nsOEImport.cpp b/mozilla/mailnews/import/oexpress/nsOEImport.cpp index b9efafdf868..746e6eddf09 100644 --- a/mozilla/mailnews/import/oexpress/nsOEImport.cpp +++ b/mozilla/mailnews/import/oexpress/nsOEImport.cpp @@ -269,7 +269,7 @@ NS_IMETHODIMP nsOEImport::GetImportInterface( const char *pImportType, nsISuppor nsOEStringBundle::GetStringByID( OEIMPORT_NAME, name); nsCOMPtr nameString (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { - nameString->SetData(name.get()); + nameString->SetData(name); pGeneric->SetData( "name", nameString); rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface); } diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp index 01f5d3e0bc2..4489ab247c2 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp @@ -269,7 +269,7 @@ NS_IMETHODIMP nsOutlookImport::GetImportInterface( const char *pImportType, nsIS nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_NAME, name); nsCOMPtr nameString (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { - nameString->SetData(name.get()); + nameString->SetData(name); pGeneric->SetData( "name", nameString); rv = pGeneric->QueryInterface( kISupportsIID, (void **)ppInterface); } diff --git a/mozilla/mailnews/import/src/nsImportAddressBooks.cpp b/mozilla/mailnews/import/src/nsImportAddressBooks.cpp index 80bef6749b3..a245b7b6bb5 100644 --- a/mozilla/mailnews/import/src/nsImportAddressBooks.cpp +++ b/mozilla/mailnews/import/src/nsImportAddressBooks.cpp @@ -313,7 +313,7 @@ NS_IMETHODIMP nsImportGenericAddressBooks::GetData(const char *dataId, nsISuppor if (NS_FAILED( rv)) return( rv); if (found) { - data->SetData( pData); + data->SetData(nsDependentString(pData)); *_retval = data; NS_ADDREF( *_retval); } @@ -543,32 +543,16 @@ NS_IMETHODIMP nsImportGenericAddressBooks::WantsProgress(PRBool *_retval) void nsImportGenericAddressBooks::SetLogs( nsString& success, nsString& error, nsISupportsString *pSuccess, nsISupportsString *pError) { - nsString str; - PRUnichar * pStr = nsnull; + nsAutoString str; if (pSuccess) { - pSuccess->GetData( &pStr); - if (pStr) { - str = pStr; - nsCRT::free( pStr); - pStr = nsnull; - str.Append( success); - pSuccess->SetData( str.get()); - } - else { - pSuccess->SetData( success.get()); - } + pSuccess->GetData(str); + str.Append(success); + pSuccess->SetData(success); } if (pError) { - pError->GetData( &pStr); - if (pStr) { - str = pStr; - nsCRT::free( pStr); - str.Append( error); - pError->SetData( str.get()); - } - else { - pError->SetData( error.get()); - } + pError->GetData(str); + str.Append(error); + pError->SetData(error); } } diff --git a/mozilla/mailnews/import/src/nsImportMail.cpp b/mozilla/mailnews/import/src/nsImportMail.cpp index e314ae55617..b5667bf8f8b 100644 --- a/mozilla/mailnews/import/src/nsImportMail.cpp +++ b/mozilla/mailnews/import/src/nsImportMail.cpp @@ -130,7 +130,7 @@ public: static void ReportError( PRInt32 id, const PRUnichar *pName, nsString *pStream); private: - PRUnichar * m_pName; // module name that created this interface + nsString m_pName; // module name that created this interface nsIMsgFolder * m_pDestFolder; PRBool m_deleteDestFolder; PRBool m_createdFolder; @@ -207,7 +207,6 @@ nsImportGenericMail::nsImportGenericMail() m_pDestFolder = nsnull; m_deleteDestFolder = PR_FALSE; m_createdFolder = PR_FALSE; - m_pName = nsnull; } @@ -219,9 +218,6 @@ nsImportGenericMail::~nsImportGenericMail() m_pThreadData = nsnull; } - if (m_pName) - nsCRT::free( m_pName); - NS_IF_RELEASE( m_pDestFolder); NS_IF_RELEASE( m_pSrcLocation); NS_IF_RELEASE( m_pInterface); @@ -320,13 +316,10 @@ NS_IMETHODIMP nsImportGenericMail::SetData( const char *dataId, nsISupports *ite } if (!nsCRT::strcasecmp( dataId, "name")) { - if (m_pName) - nsCRT::free( m_pName); - m_pName = nsnull; nsCOMPtr nameString; if (item) { item->QueryInterface( NS_GET_IID(nsISupportsString), getter_AddRefs(nameString)); - rv = nameString->GetData(&m_pName); + rv = nameString->GetData(m_pName); } } @@ -471,12 +464,11 @@ void nsImportGenericMail::GetMailboxName( PRUint32 index, nsISupportsString *pSt nsCOMPtr iFace( dont_AddRef( pSupports)); nsCOMPtr box( do_QueryInterface( pSupports)); if (box) { - PRUnichar *pName = nsnull; - box->GetDisplayName( &pName); - if (pName) { - pStr->SetData( pName); - nsCRT::free( pName); - } + nsXPIDLString name; + box->GetDisplayName(getter_Copies(name)); + if (!name.IsEmpty()) { + pStr->SetData(name); + } } } } @@ -641,33 +633,17 @@ void nsImportGenericMail::ReportError( PRInt32 id, const PRUnichar *pName, nsStr void nsImportGenericMail::SetLogs( nsString& success, nsString& error, nsISupportsString *pSuccess, nsISupportsString *pError) { - nsString str; - PRUnichar * pStr = nsnull; - if (pSuccess) { - pSuccess->GetData( &pStr); - if (pStr) { - str = pStr; - nsCRT::free( pStr); - pStr = nsnull; - str.Append( success); - pSuccess->SetData( str.get()); - } - else { - pSuccess->SetData( success.get()); - } - } - if (pError) { - pError->GetData( &pStr); - if (pStr) { - str = pStr; - nsCRT::free( pStr); - str.Append( error); - pError->SetData( str.get()); - } - else { - pError->SetData( error.get()); - } - } + nsAutoString str; + if (pSuccess) { + pSuccess->GetData(str); + str.Append(success); + pSuccess->SetData(str); + } + if (pError) { + pError->GetData(str); + str.Append(error); + pError->SetData(str); + } } NS_IMETHODIMP nsImportGenericMail::CancelImport(void) @@ -976,8 +952,8 @@ PRBool nsImportGenericMail::CreateFolder( nsIMsgFolder **ppFolder) if (NS_FAILED(rv)) return PR_FALSE; nsXPIDLString folderName; - if (m_pName) { - const PRUnichar *moduleName[] = { m_pName }; + if (!m_pName.IsEmpty()) { + const PRUnichar *moduleName[] = { m_pName.get() }; rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ModuleFolderName").get(), moduleName, 1, getter_Copies(folderName)); diff --git a/mozilla/modules/libpref/src/nsPref.cpp b/mozilla/modules/libpref/src/nsPref.cpp index 8a88d502230..b5a4d1b459e 100644 --- a/mozilla/modules/libpref/src/nsPref.cpp +++ b/mozilla/modules/libpref/src/nsPref.cpp @@ -393,9 +393,10 @@ NS_IMETHODIMP nsPref::CopyUnicharPref(const char *pref, PRUnichar **_retval) nsCOMPtr theString; rv = prefBranch->GetComplexValue(pref, NS_GET_IID(nsISupportsString), getter_AddRefs(theString)); - if (NS_SUCCEEDED(rv)) { - rv = theString->GetData(_retval); - } + if (NS_FAILED(rv)) + return rv; + + return theString->ToString(_retval); } return rv; } @@ -407,10 +408,10 @@ NS_IMETHODIMP nsPref::CopyDefaultUnicharPref(const char *pref, PRUnichar **_retv rv = mDefaultBranch->GetComplexValue(pref, NS_GET_IID(nsISupportsString), getter_AddRefs(theString)); - if (NS_SUCCEEDED(rv)) { - rv = theString->GetData(_retval); - } - return rv; + if (NS_FAILED(rv)) + return rv; + + return theString->ToString(_retval); } NS_IMETHODIMP nsPref::SetUnicharPref(const char *pref, const PRUnichar *value) @@ -421,7 +422,7 @@ NS_IMETHODIMP nsPref::SetUnicharPref(const char *pref, const PRUnichar *value) if (NS_SUCCEEDED(rv)) { nsCOMPtr theString = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - theString->SetData(value); + theString->SetData(nsDependentString(value)); rv = prefBranch->SetComplexValue(pref, NS_GET_IID(nsISupportsString), theString); } } @@ -434,7 +435,7 @@ NS_IMETHODIMP nsPref::SetDefaultUnicharPref(const char *pref, const PRUnichar *v nsCOMPtr theString = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { - theString->SetData(value); + theString->SetData(nsDependentString(value)); rv = mDefaultBranch->SetComplexValue(pref, NS_GET_IID(nsISupportsString), theString); } return rv; @@ -450,7 +451,7 @@ NS_IMETHODIMP nsPref::GetLocalizedUnicharPref(const char *pref, PRUnichar **_ret rv = prefBranch->GetComplexValue(pref, NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(theString)); if (NS_SUCCEEDED(rv)) { - rv = theString->GetData(_retval); + rv = theString->ToString(_retval); } } return rv; @@ -464,8 +465,9 @@ NS_IMETHODIMP nsPref::GetDefaultLocalizedUnicharPref(const char *pref, PRUnichar rv = mDefaultBranch->GetComplexValue(pref, NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(theString)); if (NS_SUCCEEDED(rv)) { - rv = theString->GetData(_retval); + rv = theString->ToString(_retval); } + return rv; } diff --git a/mozilla/modules/libpref/src/nsPrefBranch.cpp b/mozilla/modules/libpref/src/nsPrefBranch.cpp index 64e34db662f..01f98736d63 100644 --- a/mozilla/modules/libpref/src/nsPrefBranch.cpp +++ b/mozilla/modules/libpref/src/nsPrefBranch.cpp @@ -377,7 +377,7 @@ NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID & nsCOMPtr theString(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv)); if (NS_SUCCEEDED(rv)) { - rv = theString->SetData(NS_ConvertUTF8toUCS2(utf8String).get()); + rv = theString->SetData(NS_ConvertUTF8toUCS2(utf8String)); if (NS_SUCCEEDED(rv)) { nsISupportsString *temp = theString; @@ -466,9 +466,9 @@ NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID & nsCOMPtr theString = do_QueryInterface(aValue); if (theString) { - nsXPIDLString wideString; + nsAutoString wideString; - rv = theString->GetData(getter_Copies(wideString)); + rv = theString->GetData(wideString); if (NS_SUCCEEDED(rv)) { rv = SetCharPref(aPrefName, NS_ConvertUCS2toUTF8(wideString).get()); } @@ -998,6 +998,35 @@ nsresult nsPrefLocalizedString::Init() return rv; } +NS_IMETHODIMP +nsPrefLocalizedString::GetData(PRUnichar** _retval) +{ + nsAutoString data; + + nsresult rv = GetData(data); + if (NS_FAILED(rv)) + return rv; + + *_retval = ToNewUnicode(data); + if (!*_retval) + return NS_ERROR_OUT_OF_MEMORY; + + return NS_OK; +} + +NS_IMETHODIMP +nsPrefLocalizedString::SetData(const PRUnichar *aData) +{ + return SetData(nsDependentString(aData)); +} + +NS_IMETHODIMP +nsPrefLocalizedString::SetDataWithLength(PRUint32 aLength, + const PRUnichar* aData) +{ + return SetData(Substring(aData, aData + aLength)); +} + //---------------------------------------------------------------------------- // nsRelativeFilePref //---------------------------------------------------------------------------- diff --git a/mozilla/modules/libpref/src/nsPrefBranch.h b/mozilla/modules/libpref/src/nsPrefBranch.h index 5a997e4ba61..3d60e0356e2 100644 --- a/mozilla/modules/libpref/src/nsPrefBranch.h +++ b/mozilla/modules/libpref/src/nsPrefBranch.h @@ -102,6 +102,10 @@ public: nsresult Init(); private: + NS_IMETHOD GetData(PRUnichar**); + NS_IMETHOD SetData(const PRUnichar* aData); + NS_IMETHOD SetDataWithLength(PRUint32 aLength, const PRUnichar *aData); + nsCOMPtr mUnicodeString; }; diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 3d4944950ab..d1c819dcf80 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -516,13 +516,13 @@ nsIOService::GetParserForScheme(const char *scheme, nsIURLParser **_retval) if (NS_FAILED(rv)) break; // get the entry string - nsXPIDLCString entryString; - rv = entry->GetData(getter_Copies(entryString)); + nsCAutoString entryString; + rv = entry->GetData(entryString); if (NS_FAILED(rv)) break; - if (strcmp(entryString, scheme) == 0) { + if (entryString.Equals(scheme)) { nsXPIDLCString contractID; - rv = catmgr->GetCategoryEntry(NS_IURLPARSER_KEY,(const char *)entryString, getter_Copies(contractID)); + rv = catmgr->GetCategoryEntry(NS_IURLPARSER_KEY, entryString.get(), getter_Copies(contractID)); if (NS_FAILED(rv)) break; rv = nsServiceManager::GetService(contractID, NS_GET_IID(nsIURLParser), (nsISupports **)_retval); diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.cpp b/mozilla/netwerk/base/src/nsSocketTransportService.cpp index 7da9e1d5658..26b8ef03908 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransportService.cpp @@ -43,7 +43,6 @@ #include "nsIIOService.h" #include "nsIServiceManager.h" #include "nsICategoryManager.h" -#include "nsISupportsPrimitives.h" #include "nsProxiedService.h" #include "nsString.h" #include "nsPrintfCString.h" diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index 0054b8a5c0b..6f6a627ce82 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -3321,8 +3321,7 @@ nsHttpChannel::nsContentEncodings::GetNext(nsISupports** aNextEncoding) if (CaseInsensitiveFindInReadable(NS_LITERAL_CSTRING("gzip"), start, end)) { - str->SetDataWithLength(sizeof(APPLICATION_GZIP) - 1, - APPLICATION_GZIP); + str->SetData(NS_LITERAL_CSTRING(APPLICATION_GZIP)); haveType = PR_TRUE; } @@ -3331,8 +3330,8 @@ nsHttpChannel::nsContentEncodings::GetNext(nsISupports** aNextEncoding) if (CaseInsensitiveFindInReadable(NS_LITERAL_CSTRING("compress"), start, end)) { - str->SetDataWithLength(sizeof(APPLICATION_COMPRESS) - 1, - APPLICATION_COMPRESS); + str->SetData(NS_LITERAL_CSTRING(APPLICATION_COMPRESS)); + haveType = PR_TRUE; } } @@ -3342,8 +3341,7 @@ nsHttpChannel::nsContentEncodings::GetNext(nsISupports** aNextEncoding) if (CaseInsensitiveFindInReadable(NS_LITERAL_CSTRING("deflate"), start, end)) { - str->SetDataWithLength(sizeof(APPLICATION_ZIP) - 1, - APPLICATION_ZIP); + str->SetData(NS_LITERAL_CSTRING(APPLICATION_ZIP)); haveType = PR_TRUE; } } diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp index aa7aefa37fb..79b814c98d0 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -43,7 +43,6 @@ #include "nsICategoryManager.h" #include "nsCategoryManagerUtils.h" #include "nsIObserverService.h" -#include "nsISupportsPrimitives.h" #include "nsINetModRegEntry.h" #include "nsICacheService.h" #include "nsIPrefService.h" diff --git a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp index 9f9ef7d9a05..9d4bd33d8de 100644 --- a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -116,13 +116,13 @@ nsStreamConverterService::BuildGraph() { while (NS_SUCCEEDED(rv)) { // get the entry string - nsXPIDLCString entryString; - rv = entry->GetData(getter_Copies(entryString)); + nsCAutoString entryString; + rv = entry->GetData(entryString); if (NS_FAILED(rv)) return rv; // cobble the entry string w/ the converter key to produce a full contractID. nsCAutoString contractID(NS_ISTREAMCONVERTER_KEY); - contractID.Append((const char *)entryString); + contractID.Append(entryString); // now we've got the CONTRACTID, let's parse it up. rv = AddAdjacency(contractID.get()); diff --git a/mozilla/netwerk/test/TestCacheService.cpp b/mozilla/netwerk/test/TestCacheService.cpp index 99691ea96a8..c99c2f689d7 100644 --- a/mozilla/netwerk/test/TestCacheService.cpp +++ b/mozilla/netwerk/test/TestCacheService.cpp @@ -116,7 +116,7 @@ TestMemoryObjectCache() nsCOMPtr foo = do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv); - foo->SetData("hello world"); + foo->SetData(NS_LITERAL_CSTRING("hello world")); rv = descriptor->SetCacheElement(foo); rv = descriptor->SetDataSize(11); diff --git a/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp b/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp index 8c7d16cac07..f79fb756596 100644 --- a/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp @@ -61,7 +61,6 @@ #include "nsXPIDLString.h" #include "nsReadableUtils.h" #include "nsIStringBundle.h" -#include "nsISupportsPrimitives.h" #include "nsProxiedService.h" #include "nsNetUtil.h" diff --git a/mozilla/profile/src/nsProfile.cpp b/mozilla/profile/src/nsProfile.cpp index f7fa0bee5e6..a14e37cd4b8 100644 --- a/mozilla/profile/src/nsProfile.cpp +++ b/mozilla/profile/src/nsProfile.cpp @@ -77,7 +77,6 @@ #include "nsIChromeRegistry.h" // chromeReg #include "nsIStringBundle.h" #include "nsIObserverService.h" -#include "nsISupportsPrimitives.h" #include "nsHashtable.h" #include "nsIAtom.h" @@ -611,10 +610,10 @@ nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr, PRBool canInteract) rv = enumItem->GetNext(getter_AddRefs(contractid)); if (NS_FAILED(rv) || !contractid) break; - nsXPIDLCString contractidString; - contractid->ToString (getter_Copies(contractidString)); + nsCAutoString contractidString; + contractid->GetData(contractidString); - nsCOMPtr listener = do_CreateInstance(contractidString, &rv); + nsCOMPtr listener = do_CreateInstance(contractidString.get(), &rv); if (listener) listener->OnProfileStartup(currentProfileStr); diff --git a/mozilla/widget/src/os2/nsDragService.cpp b/mozilla/widget/src/os2/nsDragService.cpp index 1df63b94588..5d9c539f78f 100644 --- a/mozilla/widget/src/os2/nsDragService.cpp +++ b/mozilla/widget/src/os2/nsDragService.cpp @@ -124,9 +124,9 @@ NS_IMETHODIMP nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode, nsISupports nsCOMPtr urlObject ( do_QueryInterface(genericURL) ); if( urlObject ) { - nsXPIDLString urlInfo; + nsAutoString urlInfo; nsAutoString linkName, url, holder; - urlObject->GetData ( getter_Copies(urlInfo) ); + urlObject->GetData ( urlInfo ); holder = urlInfo; PRInt32 lineIndex = holder.FindChar ('\n'); if ( lineIndex != -1 ) @@ -204,8 +204,8 @@ NS_IMETHODIMP nsDragService::GetData(nsITransferable *aTransferable, PRUint32 aI nsCOMPtr currentFlavor; currentFlavor = do_QueryInterface(genericWrapper); if (currentFlavor) { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); + nsCAutoString flavorStr; + currentFlavor->GetData(flavorStr); nsCOMPtr genericItem; @@ -255,9 +255,9 @@ NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBo nsCOMPtr currentFlavor; currentFlavor = do_QueryInterface(genericWrapper); if (currentFlavor) { - nsXPIDLCString flavorStr; - currentFlavor->ToString ( getter_Copies(flavorStr) ); - if (strcmp(flavorStr, aDataFlavor) == 0) { + nsCAutoString flavorStr; + currentFlavor->GetData ( flavorStr ); + if (flavorStr.Equals(aDataFlavor)) { *_retval = PR_TRUE; } } diff --git a/mozilla/widget/src/windows/nsDataObj.cpp b/mozilla/widget/src/windows/nsDataObj.cpp index 875a42fa39a..f805706cda3 100644 --- a/mozilla/widget/src/windows/nsDataObj.cpp +++ b/mozilla/widget/src/windows/nsDataObj.cpp @@ -602,9 +602,9 @@ nsDataObj :: IsInternetShortcut ( ) flavorList->GetElementAt (i, getter_AddRefs(genericFlavor)); nsCOMPtr currentFlavor (do_QueryInterface(genericFlavor)); if (currentFlavor) { - nsXPIDLCString flavorStr; - currentFlavor->ToString(getter_Copies(flavorStr)); - if ( strcmp(flavorStr, kURLMime) == 0 ) { + nsCAutoString flavorStr; + currentFlavor->GetData(flavorStr); + if ( flavorStr.Equals(kURLMime) ) { retval = PR_TRUE; // found it! break; } @@ -816,8 +816,8 @@ nsDataObj :: ExtractShortcutURL ( nsString & outURL ) if ( NS_SUCCEEDED(mTransferable->GetTransferData(kURLMime, getter_AddRefs(genericURL), &len)) ) { nsCOMPtr urlObject ( do_QueryInterface(genericURL) ); if ( urlObject ) { - nsXPIDLString url; - urlObject->GetData ( getter_Copies(url) ); + nsAutoString url; + urlObject->GetData ( url ); outURL = url; // find the first linefeed in the data, that's where the url ends. trunc the @@ -856,17 +856,15 @@ nsDataObj :: ExtractShortcutTitle ( nsString & outTitle ) if ( NS_SUCCEEDED(mTransferable->GetTransferData(kURLMime, getter_AddRefs(genericURL), &len)) ) { nsCOMPtr urlObject ( do_QueryInterface(genericURL) ); if ( urlObject ) { - nsXPIDLString url; - nsAutoString holder; - urlObject->GetData ( getter_Copies(url) ); - holder = url; + nsAutoString url; + urlObject->GetData ( url ); // find the first linefeed in the data, that's where the url ends. we want // everything after that linefeed. FindChar() returns -1 if we can't find - PRInt32 lineIndex = holder.FindChar ( '\n' ); + PRInt32 lineIndex = url.FindChar ( '\n' ); NS_ASSERTION ( lineIndex != -1, "Format for url flavor is " ); if ( lineIndex != -1 ) { - holder.Mid ( outTitle, lineIndex + 1, (len/2) - (lineIndex + 1) ); + url.Mid ( outTitle, lineIndex + 1, (len/2) - (lineIndex + 1) ); rv = NS_OK; } } diff --git a/mozilla/widget/src/xpwidgets/nsClipboardHelper.cpp b/mozilla/widget/src/xpwidgets/nsClipboardHelper.cpp index c19ced81b73..3b556b57cfa 100644 --- a/mozilla/widget/src/xpwidgets/nsClipboardHelper.cpp +++ b/mozilla/widget/src/xpwidgets/nsClipboardHelper.cpp @@ -94,7 +94,7 @@ nsClipboardHelper::CopyStringToClipboard(const nsAString& aString, NS_ENSURE_TRUE(data, NS_ERROR_FAILURE); // populate the string - rv = data->AdoptData(ToNewUnicode(aString)); + rv = data->SetData(aString); NS_ENSURE_SUCCESS(rv, rv); // qi the data object an |nsISupports| so that when the transferable holds diff --git a/mozilla/widget/src/xpwidgets/nsHTMLFormatConverter.cpp b/mozilla/widget/src/xpwidgets/nsHTMLFormatConverter.cpp index f5a726bd77a..df66c0b4026 100644 --- a/mozilla/widget/src/xpwidgets/nsHTMLFormatConverter.cpp +++ b/mozilla/widget/src/xpwidgets/nsHTMLFormatConverter.cpp @@ -160,7 +160,7 @@ nsHTMLFormatConverter :: AddFlavorToList ( nsISupportsArray* inList, const char* nsresult rv = nsComponentManager::CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, nsnull, NS_GET_IID(nsISupportsCString), getter_AddRefs(dataFlavor)); if ( dataFlavor ) { - dataFlavor->SetData ( NS_CONST_CAST(char*, inFlavor) ); + dataFlavor->SetData ( nsDependentCString(inFlavor) ); // add to list as an nsISupports so the correct interface gets the addref // in AppendElement() nsCOMPtr genericFlavor ( do_QueryInterface(dataFlavor) ); @@ -234,11 +234,9 @@ nsHTMLFormatConverter::Convert(const char *aFromDataFlavor, nsISupports *aFromDa // length represents the length in 1-byte chars, so we need to divide by two. nsCOMPtr dataWrapper0 ( do_QueryInterface(aFromData) ); if ( dataWrapper0 ) { - nsXPIDLString data; - dataWrapper0->ToString ( getter_Copies(data) ); //еее COPY #1 - if ( data ) { - PRUnichar* castedData = NS_CONST_CAST(PRUnichar*, NS_STATIC_CAST(const PRUnichar*, data)); - nsAutoString dataStr ( CBufDescriptor(castedData, PR_TRUE, aDataLen) ); //еее try not to copy the data + nsAutoString dataStr; + dataWrapper0->GetData ( dataStr ); //еее COPY #1 + if ( !dataStr.IsEmpty() ) { // note: conversion to text/plain is done inside the clipboard. we do not need to worry // about it here. diff --git a/mozilla/widget/src/xpwidgets/nsPrimitiveHelpers.cpp b/mozilla/widget/src/xpwidgets/nsPrimitiveHelpers.cpp index aa6b2ee2e93..5f120297802 100644 --- a/mozilla/widget/src/xpwidgets/nsPrimitiveHelpers.cpp +++ b/mozilla/widget/src/xpwidgets/nsPrimitiveHelpers.cpp @@ -42,6 +42,7 @@ #include "nsITransferable.h" #include "nsIComponentManager.h" #include "nsLinebreakConverter.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsICharsetConverterManager.h" @@ -70,7 +71,8 @@ nsPrimitiveHelpers :: CreatePrimitiveForData ( const char* aFlavor, void* aDataB nsComponentManager::CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, nsnull, NS_GET_IID(nsISupportsCString), getter_AddRefs(primitive)); if ( primitive ) { - primitive->SetDataWithLength ( aDataLen, NS_STATIC_CAST(char*, aDataBuff) ); + const char * start = NS_STATIC_CAST(const char*, aDataBuff); + primitive->SetData(Substring(start, start + aDataLen)); nsCOMPtr genericPrimitive ( do_QueryInterface(primitive) ); *aPrimitive = genericPrimitive; NS_ADDREF(*aPrimitive); @@ -81,8 +83,9 @@ nsPrimitiveHelpers :: CreatePrimitiveForData ( const char* aFlavor, void* aDataB nsresult rv = nsComponentManager::CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, nsnull, NS_GET_IID(nsISupportsString), getter_AddRefs(primitive)); if (NS_SUCCEEDED(rv) && primitive ) { - // recall that SetDataWithLength() takes length as characters, not bytes - primitive->SetDataWithLength ( aDataLen / 2, NS_STATIC_CAST(PRUnichar*, aDataBuff) ); + // recall that length takes length as characters, not bytes + const PRUnichar* start = NS_STATIC_CAST(const PRUnichar*, aDataBuff); + primitive->SetData(Substring(start, start + (aDataLen / 2))); nsCOMPtr genericPrimitive ( do_QueryInterface(primitive) ); *aPrimitive = genericPrimitive; NS_ADDREF(*aPrimitive); @@ -108,13 +111,19 @@ nsPrimitiveHelpers :: CreateDataFromPrimitive ( const char* aFlavor, nsISupports if ( strcmp(aFlavor,kTextMime) == 0 ) { nsCOMPtr plainText ( do_QueryInterface(aPrimitive) ); - if ( plainText ) - plainText->GetData ( NS_REINTERPRET_CAST(char**, aDataBuff) ); + if ( plainText ) { + nsCAutoString data; + plainText->GetData ( data ); + *aDataBuff = ToNewCString(data); + } } else { nsCOMPtr doubleByteText ( do_QueryInterface(aPrimitive) ); - if ( doubleByteText ) - doubleByteText->GetData ( NS_REINTERPRET_CAST(PRUnichar**, aDataBuff) ); + if ( doubleByteText ) { + nsAutoString data; + doubleByteText->GetData ( data ); + *aDataBuff = ToNewCString(data); + } } } diff --git a/mozilla/widget/src/xpwidgets/nsTransferable.cpp b/mozilla/widget/src/xpwidgets/nsTransferable.cpp index e0b93c492cb..d879a8ad43f 100644 --- a/mozilla/widget/src/xpwidgets/nsTransferable.cpp +++ b/mozilla/widget/src/xpwidgets/nsTransferable.cpp @@ -330,7 +330,7 @@ nsTransferable :: GetTransferDataFlavors(nsISupportsArray ** aDataFlavorList) rv = nsComponentManager::CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, nsnull, NS_GET_IID(nsISupportsCString), getter_AddRefs(flavorWrapper)); if ( flavorWrapper ) { - flavorWrapper->SetData ( NS_CONST_CAST(char*, data->GetFlavor().get()) ); + flavorWrapper->SetData ( data->GetFlavor() ); nsCOMPtr genericWrapper ( do_QueryInterface(flavorWrapper) ); (*aDataFlavorList)->AppendElement( genericWrapper ); } @@ -578,8 +578,8 @@ nsTransferable :: FlavorsTransferableCanImport(nsISupportsArray **_retval) convertedList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); nsCOMPtr flavorWrapper ( do_QueryInterface (genericFlavor) ); - nsXPIDLCString flavorStr; - flavorWrapper->ToString( getter_Copies(flavorStr) ); + nsCAutoString flavorStr; + flavorWrapper->GetData( flavorStr ); if (!GetDataForFlavor (mDataArray, flavorStr.get())) // Don't append if already in intrinsic list (*_retval)->AppendElement (genericFlavor); @@ -622,8 +622,8 @@ nsTransferable :: FlavorsTransferableCanExport(nsISupportsArray **_retval) convertedList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); nsCOMPtr flavorWrapper ( do_QueryInterface (genericFlavor) ); - nsXPIDLCString flavorStr; - flavorWrapper->ToString( getter_Copies(flavorStr) ); + nsCAutoString flavorStr; + flavorWrapper->GetData( flavorStr ); if (!GetDataForFlavor (mDataArray, flavorStr.get())) // Don't append if already in intrinsic list (*_retval)->AppendElement (genericFlavor); diff --git a/mozilla/xpcom/components/nsCategoryManager.cpp b/mozilla/xpcom/components/nsCategoryManager.cpp index c57ce4d9c61..1d72151131e 100644 --- a/mozilla/xpcom/components/nsCategoryManager.cpp +++ b/mozilla/xpcom/components/nsCategoryManager.cpp @@ -75,7 +75,8 @@ ExtractKeyString( nsHashKey* key, void*, void*, nsISupports** _retval ) nsCOMPtr obj = new nsSupportsCStringImpl(); if ( obj ) { nsCStringKey* strkey = NS_STATIC_CAST(nsCStringKey*, key); - status = obj->SetDataWithLength(strkey->GetStringLength(), strkey->GetString()); + status = obj->SetData(nsDependentCString(strkey->GetString(), + strkey->GetStringLength())); } *_retval = obj; @@ -476,14 +477,14 @@ NS_CreateServicesFromCategory(const char *category, nFailed++; continue; } - nsXPIDLCString entryString; - rv = catEntry->GetData(getter_Copies(entryString)); + nsCAutoString entryString; + rv = catEntry->GetData(entryString); if (NS_FAILED(rv)) { nFailed++; continue; } nsXPIDLCString contractID; - rv = categoryManager->GetCategoryEntry(category,(const char *)entryString, getter_Copies(contractID)); + rv = categoryManager->GetCategoryEntry(category,entryString.get(), getter_Copies(contractID)); if (NS_FAILED(rv)) { nFailed++; continue; diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 79ff1e430ce..615217b66a8 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -665,7 +665,7 @@ ConvertContractIDKeyToString(PLDHashTable *table, const nsContractIDTableEntry *entry = NS_REINTERPRET_CAST(const nsContractIDTableEntry *, hdr); - wrapper->SetData(entry->mContractID); + wrapper->SetData(nsDependentCString(entry->mContractID)); *retval = wrapper; NS_ADDREF(*retval); return NS_OK; @@ -1321,11 +1321,11 @@ nsComponentManagerImpl::WriteCategoryManagerToRegistry(PRFileDesc* fd) if (!supStr) continue; - nsXPIDLCString categoryType; - if (NS_FAILED(supStr->GetData(getter_Copies(categoryType)))) + nsCAutoString categoryType; + if (NS_FAILED(supStr->GetData(categoryType))) continue; - rv = mCategoryManager->EnumerateCategory(categoryType, getter_AddRefs(innerEnum)); + rv = mCategoryManager->EnumerateCategory(categoryType.get(), getter_AddRefs(innerEnum)); if (NS_FAILED(rv)) continue; @@ -1338,13 +1338,13 @@ nsComponentManagerImpl::WriteCategoryManagerToRegistry(PRFileDesc* fd) if (!supStr) continue; - nsXPIDLCString category; - if (NS_FAILED(supStr->GetData(getter_Copies(category)))) + nsCAutoString category; + if (NS_FAILED(supStr->GetData(category))) continue; nsXPIDLCString value; - rv = mCategoryManager->GetCategoryEntry(categoryType, - category, + rv = mCategoryManager->GetCategoryEntry(categoryType.get(), + category.get(), getter_Copies(value)); if (NS_FAILED(rv)) continue; @@ -3067,14 +3067,14 @@ nsComponentManagerImpl::AutoRegisterImpl(PRInt32 when, if (!supStr) continue; - nsXPIDLCString loaderType; - if (NS_FAILED(supStr->GetData(getter_Copies(loaderType)))) + nsCAutoString loaderType; + if (NS_FAILED(supStr->GetData(loaderType))) continue; // We depend on the loader being created. Add the loader type and // create the loader object too. nsCOMPtr loader; - GetLoaderForType(AddLoaderType(loaderType), getter_AddRefs(loader)); + GetLoaderForType(AddLoaderType(loaderType.get()), getter_AddRefs(loader)); } /* iterate over all known loaders and ask them to autoregister. */ diff --git a/mozilla/xpcom/ds/nsISupportsPrimitives.idl b/mozilla/xpcom/ds/nsISupportsPrimitives.idl index e4757d977b5..f84ea117f27 100644 --- a/mozilla/xpcom/ds/nsISupportsPrimitives.idl +++ b/mozilla/xpcom/ds/nsISupportsPrimitives.idl @@ -79,53 +79,15 @@ interface nsISupportsID : nsISupportsPrimitive [scriptable, uuid(d65ff270-4a1c-11d3-9890-006008962422)] interface nsISupportsCString : nsISupportsPrimitive { - attribute string data; + attribute ACString data; string toString(); - - /** - * Note: setting |data| and using |setDataWithLength| make a copy of - * the data string argument. Using |adoptData| and |adoptDataWithLength|, - * which are not scriptable, subsumes the data string as the internal - * buffer. - * - * Also note that the |length| param should not include space for a null - * terminator, nor should it account for the size of a char. It should - * only be the number of characters for which there is space in the string. - */ - - void setDataWithLength(in unsigned long length, - [size_is(length)] in string data); - - [noscript] void adoptData(in charPtr data); - - [noscript] void adoptDataWithLength(in unsigned long length, - [size_is(length)] in charPtr data); }; [scriptable, uuid(d79dc970-4a1c-11d3-9890-006008962422)] interface nsISupportsString : nsISupportsPrimitive { - attribute wstring data; + attribute AString data; wstring toString(); - - /** - * Note: setting |data| and using |setDataWithLength| make a copy of - * the data string argument. Using |adoptData| and |adoptDataWithLength|, - * which are not scriptable, subsumes the data string as the internal - * buffer. - * - * Also note that the |length| param should not include space for a null - * terminator, nor should it account for the size of a char. It should - * only be the number of characters for which there is space in the string. - */ - - void setDataWithLength(in unsigned long length, - [size_is(length)] in wstring data); - - [noscript] void adoptData(in unicharPtr data); - - [noscript] void adoptDataWithLength(in unsigned long length, - [size_is(length)] in unicharPtr data); }; /** diff --git a/mozilla/xpcom/ds/nsSupportsPrimitives.cpp b/mozilla/xpcom/ds/nsSupportsPrimitives.cpp index 2ff4313e361..21657b11b82 100644 --- a/mozilla/xpcom/ds/nsSupportsPrimitives.cpp +++ b/mozilla/xpcom/ds/nsSupportsPrimitives.cpp @@ -41,6 +41,9 @@ #include "nsMemory.h" #include "prprf.h" #include "nsIInterfaceInfoManager.h" +#include "nsDependentString.h" +#include "nsReadableUtils.h" +#include "nsPromiseFlatString.h" /***************************************************************************/ @@ -49,13 +52,10 @@ NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive) nsSupportsIDImpl::nsSupportsIDImpl() : mData(nsnull) { - NS_INIT_ISUPPORTS(); } nsSupportsIDImpl::~nsSupportsIDImpl() { - if(mData) - nsMemory::Free(mData); } NS_IMETHODIMP nsSupportsIDImpl::GetType(PRUint16 *aType) @@ -114,18 +114,6 @@ NS_IMETHODIMP nsSupportsIDImpl::ToString(char **_retval) NS_IMPL_ISUPPORTS2(nsSupportsCStringImpl, nsISupportsCString, nsISupportsPrimitive) -nsSupportsCStringImpl::nsSupportsCStringImpl() - : mData(0), mLength(0) -{ - NS_INIT_ISUPPORTS(); -} - -nsSupportsCStringImpl::~nsSupportsCStringImpl() -{ - if (mData) - nsMemory::Free(mData); -} - NS_IMETHODIMP nsSupportsCStringImpl::GetType(PRUint16 *aType) { NS_ASSERTION(aType, "Bad pointer"); @@ -134,90 +122,29 @@ NS_IMETHODIMP nsSupportsCStringImpl::GetType(PRUint16 *aType) return NS_OK; } -NS_IMETHODIMP nsSupportsCStringImpl::GetData(char **aData) +NS_IMETHODIMP nsSupportsCStringImpl::GetData(nsACString& aData) { - nsresult rv = NS_OK; - // copy the buffer - if (mData) { - size_t size((mLength + 1) * sizeof(char)); - *aData = NS_STATIC_CAST(char*, nsMemory::Clone(mData, size)); - if (!(*aData)) - rv = NS_ERROR_OUT_OF_MEMORY; - } - else - *aData = nsnull; - - return rv; -} - -NS_IMETHODIMP nsSupportsCStringImpl::SetData(const char *aData) -{ - return SetDataWithLength(aData ? strlen(aData) : 0, aData); + aData = mData; + return NS_OK; } NS_IMETHODIMP nsSupportsCStringImpl::ToString(char **_retval) { - return GetData(_retval); -} - -NS_IMETHODIMP nsSupportsCStringImpl::SetDataWithLength(PRUint32 aLength, - const char *aData) -{ - // if the new string length is the same as the old, - // just copy into the old buffer to avoid reallocating. we - // can further avoid reallocating by reusing the same - // buffer if aLength <= mLength, but there's high potential - // for bloat there. see bug 80097 for discussion. - if ((aLength == mLength) && aData && mData) { - memcpy(mData, aData, aLength * sizeof(char)); - return NS_OK; - } - - // otherwise, we'll have to allocate a new buffer, copy - // into that new buffer, and adopt it - char* newData = nsnull; - if (aData) { - // allocate a new buffer - size_t size((aLength + 1) * sizeof(char)); - newData = NS_STATIC_CAST(char*, nsMemory::Alloc(size)); - if (!newData) - return NS_ERROR_OUT_OF_MEMORY; - // copy into that buffer if it was successfully allocated - memcpy(newData, aData, aLength * sizeof(char)); - } - - // if we've succeeded so far, adopt the new buffer. the adopt - // function handles the null buffer case - return AdoptDataWithLength(aLength, newData); -} - -NS_IMETHODIMP nsSupportsCStringImpl::AdoptData(char *aData) -{ - return AdoptDataWithLength(aData ? strlen(aData) : 0, aData); -} - -NS_IMETHODIMP nsSupportsCStringImpl::AdoptDataWithLength(PRUint32 aLength, - char *aData) -{ - // free current buffer - if (mData) - nsMemory::Free(mData); - - // subsume new buffer, null or not - mData = aData; - - if (mData) { - // set length of new buffer - mLength = aLength; - // always make sure we're null-terminated - mData[mLength] = '\0'; - } - else - mLength = 0; + *_retval = ToNewCString(mData); + if (!*_retval) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; } +NS_IMETHODIMP nsSupportsCStringImpl::SetData(const nsACString& aData) +{ + mData = aData; + return NS_OK; +} + + /***************************************************************************** * nsSupportsStringImpl *****************************************************************************/ @@ -225,18 +152,6 @@ NS_IMETHODIMP nsSupportsCStringImpl::AdoptDataWithLength(PRUint32 aLength, NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString, nsISupportsPrimitive) -nsSupportsStringImpl::nsSupportsStringImpl() - : mData(0), mLength(0) -{ - NS_INIT_ISUPPORTS(); -} - -nsSupportsStringImpl::~nsSupportsStringImpl() -{ - if (mData) - nsMemory::Free(mData); -} - NS_IMETHODIMP nsSupportsStringImpl::GetType(PRUint16 *aType) { NS_ASSERTION(aType, "Bad pointer"); @@ -245,90 +160,29 @@ NS_IMETHODIMP nsSupportsStringImpl::GetType(PRUint16 *aType) return NS_OK; } -NS_IMETHODIMP nsSupportsStringImpl::GetData(PRUnichar **aData) +NS_IMETHODIMP nsSupportsStringImpl::GetData(nsAString& aData) { - nsresult rv = NS_OK; - // copy the buffer - if (mData) { - size_t size((mLength + 1) * sizeof(PRUnichar)); - *aData = NS_STATIC_CAST(PRUnichar*, nsMemory::Clone(mData, size)); - if (!(*aData)) - rv = NS_ERROR_OUT_OF_MEMORY; - } - else - *aData = nsnull; - - return rv; -} - -NS_IMETHODIMP nsSupportsStringImpl::SetData(const PRUnichar *aData) -{ - return SetDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData); + aData = mData; + return NS_OK; } NS_IMETHODIMP nsSupportsStringImpl::ToString(PRUnichar **_retval) { - return GetData(_retval); -} - -NS_IMETHODIMP nsSupportsStringImpl::SetDataWithLength(PRUint32 aLength, - const PRUnichar *aData) -{ - // if the new string length is the same as the old, - // just copy into the old buffer to avoid reallocating. we - // can further avoid reallocating by reusing the same - // buffer if aLength <= mLength, but there's high potential - // for bloat there. see bug 80097 for discussion. - if ((aLength == mLength) && aData && mData) { - memcpy(mData, aData, aLength * sizeof(PRUnichar)); - return NS_OK; - } - - // otherwise, we'll have to allocate a new buffer, copy - // into that new buffer, and adopt it - PRUnichar* newData = nsnull; - if (aData) { - // allocate a new buffer - size_t size((aLength + 1) * sizeof(PRUnichar)); - newData = NS_STATIC_CAST(PRUnichar*, nsMemory::Alloc(size)); - if (!newData) - return NS_ERROR_OUT_OF_MEMORY; - // copy into that buffer if it was successfully allocated - memcpy(newData, aData, aLength * sizeof(PRUnichar)); - } - - // if we've succeeded so far, adopt the new buffer. the adopt - // function handles the null buffer case - return AdoptDataWithLength(aLength, newData); -} - -NS_IMETHODIMP nsSupportsStringImpl::AdoptData(PRUnichar *aData) -{ - return AdoptDataWithLength(aData ? nsCRT::strlen(aData) : 0, aData); -} - -NS_IMETHODIMP nsSupportsStringImpl::AdoptDataWithLength(PRUint32 aLength, - PRUnichar *aData) -{ - // free current buffer - if (mData) - nsMemory::Free(mData); - - // subsume new buffer, null or not - mData = aData; - - if (mData) { - // set length of new buffer - mLength = aLength; - // always make sure we're null-terminated - mData[mLength] = NS_STATIC_CAST(PRUnichar, 0); - } - else - mLength = 0; - + *_retval = ToNewUnicode(mData); + + if (!*_retval) + return NS_ERROR_OUT_OF_MEMORY; + return NS_OK; } +NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData) +{ + mData = aData; + return NS_OK; +} + + /***************************************************************************/ NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool, diff --git a/mozilla/xpcom/ds/nsSupportsPrimitives.h b/mozilla/xpcom/ds/nsSupportsPrimitives.h index 5f7370995fa..a29a01f5972 100644 --- a/mozilla/xpcom/ds/nsSupportsPrimitives.h +++ b/mozilla/xpcom/ds/nsSupportsPrimitives.h @@ -41,6 +41,7 @@ #include "nsISupportsPrimitives.h" #include "nsCOMPtr.h" +#include "nsString.h" class nsSupportsIDImpl : public nsISupportsID { @@ -65,12 +66,12 @@ public: NS_DECL_NSISUPPORTSPRIMITIVE NS_DECL_NSISUPPORTSCSTRING - nsSupportsCStringImpl(); - virtual ~nsSupportsCStringImpl(); + nsSupportsCStringImpl() { NS_INIT_ISUPPORTS(); } + virtual ~nsSupportsCStringImpl() {} private: - char *mData; - PRUint32 mLength; + + nsCString mData; }; /***************************************************************************/ @@ -82,12 +83,12 @@ public: NS_DECL_NSISUPPORTSPRIMITIVE NS_DECL_NSISUPPORTSSTRING - nsSupportsStringImpl(); - virtual ~nsSupportsStringImpl(); + nsSupportsStringImpl() { NS_INIT_ISUPPORTS(); } + virtual ~nsSupportsStringImpl() {} private: - PRUnichar *mData; - PRUint32 mLength; + + nsString mData; }; /***************************************************************************/ diff --git a/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp index 7dee157b30e..97e18eba0ef 100644 --- a/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -326,7 +326,7 @@ nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url) if (!wwatch || !urlWrapper) return NS_ERROR_FAILURE; - urlWrapper->SetData(url); + urlWrapper->SetData(nsDependentString(url)); nsCOMPtr newWindow; nsresult rv; diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index 8ca8df9e04f..83781087e88 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -484,7 +484,7 @@ static nsresult OpenWindow(const nsAFlatCString& aChromeURL, } } - sarg->SetData(aAppArgs.get()); + sarg->SetData(aAppArgs); nsCAutoString features("chrome,dialog=no,all"); if (aHeight != nsIAppShellService::SIZE_TO_CONTENT) { @@ -519,12 +519,14 @@ static void DumpArbitraryHelp() rv = e->GetNext(getter_AddRefs(catEntry)); if (NS_FAILED(rv) || !catEntry) break; - nsXPIDLCString entryString; - rv = catEntry->GetData(getter_Copies(entryString)); - if (NS_FAILED(rv) || !((const char *)entryString)) break; + nsCAutoString entryString; + rv = catEntry->GetData(entryString); + if (NS_FAILED(rv) || !entryString.IsEmpty()) break; nsXPIDLCString contractidString; - rv = catman->GetCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS,(const char *)entryString, getter_Copies(contractidString)); + rv = catman->GetCategoryEntry(COMMAND_LINE_ARGUMENT_HANDLERS, + entryString.get(), + getter_Copies(contractidString)); if (NS_FAILED(rv) || !((const char *)contractidString)) break; #ifdef DEBUG_CMD_LINE diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index 374d4f0e62e..20dd9648713 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -2108,7 +2108,7 @@ nsNativeAppSupportOS2::OpenWindow( const char*urlstr, const char *args ) { nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); if (sarg) - sarg->SetData(args); + sarg->SetData(nsDependentCString(args)); if (wwatch && sarg) { nsCOMPtr newWindow; diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index eddb848ed89..21d30b074b5 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -2124,7 +2124,7 @@ nsNativeAppSupportWin::OpenWindow( const char*urlstr, const char *args ) { nsCOMPtr wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); if (sarg) - sarg->SetData(args); + sarg->SetData(nsDependentCString(args)); if (wwatch && sarg) { nsCOMPtr newWindow; @@ -2498,8 +2498,8 @@ nsNativeAppSupportWin::StartServerMode() { // arg1 is the url to load. // arg2 is the string that tells navigator.js to auto-close. - arg1->SetData( NS_LITERAL_STRING( "about:blank" ).get() ); - arg2->SetData( NS_LITERAL_STRING( "turbo=yes" ).get() ); + arg1->SetData( NS_LITERAL_STRING( "about:blank" ) ); + arg2->SetData( NS_LITERAL_STRING( "turbo=yes" ) ); // Put args into array. if ( NS_FAILED( argArray->AppendElement( arg1 ) ) || diff --git a/mozilla/xpfe/components/alerts/src/nsAlertsService.cpp b/mozilla/xpfe/components/alerts/src/nsAlertsService.cpp index 88c08077d9d..6138f669051 100644 --- a/mozilla/xpfe/components/alerts/src/nsAlertsService.cpp +++ b/mozilla/xpfe/components/alerts/src/nsAlertsService.cpp @@ -42,6 +42,7 @@ #include "nsIServiceManager.h" #include "nsIDOMWindowInternal.h" #include "nsIWindowWatcher.h" +#include "nsDependentString.h" #define ALERT_CHROME_URL "chrome://communicator/content/alerts/alert.xul" @@ -78,19 +79,19 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, con nsCOMPtr scriptableImageUrl (do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID)); NS_ENSURE_TRUE(scriptableImageUrl, NS_ERROR_FAILURE); - scriptableImageUrl->SetData(aImageUrl); + scriptableImageUrl->SetData(nsDependentCString(aImageUrl)); argsArray->AppendElement(scriptableImageUrl); nsCOMPtr scriptableAlertTitle (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); NS_ENSURE_TRUE(scriptableAlertTitle, NS_ERROR_FAILURE); - scriptableAlertTitle->SetData(aAlertTitle); + scriptableAlertTitle->SetData(nsDependentString(aAlertTitle)); argsArray->AppendElement(scriptableAlertTitle); nsCOMPtr scriptableAlertText (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); NS_ENSURE_TRUE(scriptableAlertText, NS_ERROR_FAILURE); - scriptableAlertText->SetData(aAlertText); + scriptableAlertText->SetData(nsDependentString(aAlertText)); argsArray->AppendElement(scriptableAlertText); nsCOMPtr scriptableIsClickable (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID)); @@ -102,7 +103,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const char * aImageUrl, con nsCOMPtr scriptableAlertCookie (do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); NS_ENSURE_TRUE(scriptableAlertCookie, NS_ERROR_FAILURE); - scriptableAlertCookie->SetData(aAlertCookie); + scriptableAlertCookie->SetData(nsDependentString(aAlertCookie)); argsArray->AppendElement(scriptableAlertCookie); if (aAlertListener) diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp index 7899f85f393..6642628c246 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -2520,7 +2520,7 @@ nsBookmarksService::OnStopRequest(nsIRequest* request, nsISupports *ctxt, if (NS_FAILED(rv)) return rv; nsCOMPtr suppString(do_CreateInstance("@mozilla.org/supports-cstring;1", &rv)); if (!suppString) return rv; - rv = suppString->SetData(uri); + rv = suppString->SetData(nsDependentCString(uri)); if (NS_FAILED(rv)) return rv; suppArray->AppendElement(suppString); wwatch->OpenWindow(0, NAVIGATOR_CHROME_URL, "_blank", "chrome,dialog=no,all", diff --git a/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index 7dee157b30e..97e18eba0ef 100644 --- a/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -326,7 +326,7 @@ nsresult nsMacCommandLine::OpenWindow(const char *chrome, const PRUnichar *url) if (!wwatch || !urlWrapper) return NS_ERROR_FAILURE; - urlWrapper->SetData(url); + urlWrapper->SetData(nsDependentString(url)); nsCOMPtr newWindow; nsresult rv; diff --git a/mozilla/xpfe/components/xremote/src/XRemoteService.cpp b/mozilla/xpfe/components/xremote/src/XRemoteService.cpp index d9868284557..269184bc201 100644 --- a/mozilla/xpfe/components/xremote/src/XRemoteService.cpp +++ b/mozilla/xpfe/components/xremote/src/XRemoteService.cpp @@ -651,8 +651,8 @@ XRemoteService::OpenURL(nsCString &aArgument, if (!arg) return NS_ERROR_FAILURE; - // save the url into the wstring - arg->SetData(url.get()); + // save the url into the string object + arg->SetData(url); nsCOMPtr window; rv = OpenChromeWindow(finalWindow, urlString, "chrome,all,dialog=no",