Bug 1382563 - Remove ns*String::AssignWithConversion. r=erahm.
authorJulian Seward <jseward@acm.org>
Mon, 24 Jul 2017 19:23:52 +0200
changeset 420278 b134b2048e02272a6cac1b93f5e4cc06f9050fbf
parent 420277 8f72d0cb7441ab21c73e9c8fb41162bac17715e0
child 420279 0792186da2507c233aeacbc33f069395b1292991
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1382563
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382563 - Remove ns*String::AssignWithConversion. r=erahm. This patch replaces four functions of the name AssignWithConversion which are essentially wrappers around CopyASCIItoUTF16 and LossyCopyUTF16toASCII with direct calls to the latter two functions. The replaced functions are: void nsCString::AssignWithConversion( const nsAString& aData ) void nsString::AssignWithConversion( const nsACString& aData ) void nsTString_CharT::AssignWithConversion( const incompatible_char_type* aData, int32_t aLength = -1); The last of the three exists inside the double-included nsTString* world and so describes two functions, giving four in total. This has two advantages: * it removes code * at the call points, it makes clear (from the replacement name) which conversion is being carried out. The generic name "AssignWithConversion" doesn't make that obvious -- one had to infer it from the types. The patch also removes two commented out lines from editor/composer/nsComposerCommands.cpp, that appear to be related. They are at top level, where they would never have compiled. They look like leftovers from some previous change.
dom/console/Console.cpp
dom/indexedDB/ActorsParent.cpp
dom/indexedDB/IDBIndex.cpp
dom/webbrowserpersist/nsWebBrowserPersist.cpp
dom/xbl/nsXBLPrototypeBinding.cpp
dom/xbl/nsXBLPrototypeHandler.cpp
dom/xhr/XMLHttpRequestWorker.cpp
dom/xul/XULDocument.cpp
dom/xul/nsXULCommandDispatcher.cpp
dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
editor/composer/nsComposerCommands.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditorDataTransfer.cpp
js/xpconnect/src/nsXPConnect.cpp
layout/style/nsCSSParser.cpp
security/manager/ssl/PKCS11.cpp
toolkit/components/printingui/win/nsPrintDialogUtil.cpp
toolkit/xre/nsEmbedFunctions.cpp
widget/cocoa/nsCocoaUtils.mm
xpcom/string/nsStringObsolete.cpp
xpcom/string/nsTString.h
xpcom/string/nsTStringObsolete.cpp
xpcom/tests/gtest/TestCRT.cpp
xpcom/tests/gtest/TestStrings.cpp
xpfe/appshell/nsXULWindow.cpp
xpfe/components/directory/nsDirectoryViewer.cpp
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -578,17 +578,17 @@ private:
       nsString id = frame.mFilename;
       nsString innerID;
       if (mWorkerPrivate->IsSharedWorker()) {
         innerID = NS_LITERAL_STRING("SharedWorker");
       } else if (mWorkerPrivate->IsServiceWorker()) {
         innerID = NS_LITERAL_STRING("ServiceWorker");
         // Use scope as ID so the webconsole can decide if the message should
         // show up per tab
-        id.AssignWithConversion(mWorkerPrivate->ServiceWorkerScope());
+        CopyASCIItoUTF16(mWorkerPrivate->ServiceWorkerScope(), id);
       } else {
         innerID = NS_LITERAL_STRING("Worker");
       }
 
       mCallData->SetIDs(id, innerID);
     }
 
     // Now we could have the correct window (if we are not window-less).
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -4415,17 +4415,17 @@ struct StorageOpenTraits<nsIFile*>
 
 #ifdef DEBUG
   static void
   GetPath(nsIFile* aFile, nsCString& aPath)
   {
     nsString path;
     MOZ_ALWAYS_SUCCEEDS(aFile->GetPath(path));
 
-    aPath.AssignWithConversion(path);
+    LossyCopyUTF16toASCII(path, aPath);
   }
 #endif
 };
 
 template <template <class> class SmartPtr, class FileOrURLType>
 struct StorageOpenTraits<SmartPtr<FileOrURLType>>
   : public StorageOpenTraits<FileOrURLType*>
 { };
@@ -22196,17 +22196,17 @@ OpenDatabaseOp::UpdateLocaleAwareIndex(m
                                            "locale = :locale WHERE id = :id");
   nsCOMPtr<mozIStorageStatement> metaStmt;
   rv = aConnection->CreateStatement(metaQuery, getter_AddRefs(metaStmt));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsString locale;
-  locale.AssignWithConversion(aLocale);
+  CopyASCIItoUTF16(aLocale, locale);
   rv = metaStmt->BindStringByName(NS_LITERAL_CSTRING("locale"), locale);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = metaStmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), aIndexMetadata.id());
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
--- a/dom/indexedDB/IDBIndex.cpp
+++ b/dom/indexedDB/IDBIndex.cpp
@@ -248,17 +248,17 @@ void
 IDBIndex::GetLocale(nsString& aLocale) const
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mMetadata);
 
   if (mMetadata->locale().IsEmpty()) {
     SetDOMStringToNull(aLocale);
   } else {
-    aLocale.AssignWithConversion(mMetadata->locale());
+    CopyASCIItoUTF16(mMetadata->locale(), aLocale);
   }
 }
 
 const nsCString&
 IDBIndex::Locale() const
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mMetadata);
--- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp
+++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp
@@ -1536,17 +1536,17 @@ nsWebBrowserPersist::GetExtensionForCont
     nsresult rv;
     if (!mMIMEService)
     {
         mMIMEService = do_GetService(NS_MIMESERVICE_CONTRACTID, &rv);
         NS_ENSURE_TRUE(mMIMEService, NS_ERROR_FAILURE);
     }
 
     nsAutoCString contentType;
-    contentType.AssignWithConversion(aContentType);
+    LossyCopyUTF16toASCII(aContentType, contentType);
     nsAutoCString ext;
     rv = mMIMEService->GetPrimaryExtension(contentType, EmptyCString(), ext);
     if (NS_SUCCEEDED(rv))
     {
         *aExt = UTF8ToNewUnicode(ext);
         NS_ENSURE_TRUE(*aExt, NS_ERROR_OUT_OF_MEMORY);
         return NS_OK;
     }
@@ -2086,17 +2086,17 @@ nsWebBrowserPersist::CalculateUniqueFile
         }
 
         nsCOMPtr<nsIFile> localFile;
         GetLocalFileFromURI(aURI, getter_AddRefs(localFile));
 
         if (localFile)
         {
             nsAutoString filenameAsUnichar;
-            filenameAsUnichar.AssignWithConversion(filename.get());
+            CopyASCIItoUTF16(filename, filenameAsUnichar);
             localFile->SetLeafName(filenameAsUnichar);
 
             // Resync the URI with the file after the extension has been appended
             nsresult rv;
             nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aURI, &rv);
             NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
             fileURL->SetFile(localFile);  // this should recalculate uri
         }
@@ -2121,17 +2121,17 @@ nsWebBrowserPersist::MakeFilenameFromURI
 
     nsCOMPtr<nsIURL> url(do_QueryInterface(aURI));
     if (url)
     {
         nsAutoCString nameFromURL;
         url->GetFileName(nameFromURL);
         if (mPersistFlags & PERSIST_FLAGS_DONT_CHANGE_FILENAMES)
         {
-            fileName.AssignWithConversion(NS_UnescapeURL(nameFromURL).BeginReading());
+            CopyASCIItoUTF16(NS_UnescapeURL(nameFromURL), fileName);
             aFilename = fileName;
             return NS_OK;
         }
         if (!nameFromURL.IsEmpty())
         {
             // Unescape the file name (GetFileName escapes it)
             NS_UnescapeURL(nameFromURL);
             uint32_t nameLength = 0;
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -630,17 +630,17 @@ nsXBLPrototypeBinding::ConstructAttribut
       while( token != nullptr ) {
         // Build an atom out of this attribute.
         nsCOMPtr<nsIAtom> atom;
         int32_t atomNsID = kNameSpaceID_None;
         nsCOMPtr<nsIAtom> attribute;
         int32_t attributeNsID = kNameSpaceID_None;
 
         // Figure out if this token contains a :.
-        nsAutoString attrTok; attrTok.AssignWithConversion(token);
+        NS_ConvertASCIItoUTF16 attrTok(token);
         int32_t index = attrTok.Find("=", true);
         nsresult rv;
         if (index != -1) {
           // This attribute maps to something different.
           nsAutoString left, right;
           attrTok.Left(left, index);
           attrTok.Right(right, attrTok.Length()-index-1);
 
@@ -650,18 +650,17 @@ nsXBLPrototypeBinding::ConstructAttribut
             return;
 
           rv = nsContentUtils::SplitQName(aElement, right, &atomNsID,
                                           getter_AddRefs(atom));
           if (NS_FAILED(rv))
             return;
         }
         else {
-          nsAutoString tok;
-          tok.AssignWithConversion(token);
+          NS_ConvertASCIItoUTF16 tok(token);
           rv = nsContentUtils::SplitQName(aElement, tok, &atomNsID,
                                           getter_AddRefs(atom));
           if (NS_FAILED(rv))
             return;
           attribute = atom;
           attributeNsID = atomNsID;
         }
 
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -767,17 +767,17 @@ static const keyCodeData gKeyCodes[] = {
 #undef NS_DEFINE_VK
 
   { nullptr, 0, 0 }
 };
 
 int32_t nsXBLPrototypeHandler::GetMatchingKeyCode(const nsAString& aKeyName)
 {
   nsAutoCString keyName;
-  keyName.AssignWithConversion(aKeyName);
+  LossyCopyUTF16toASCII(aKeyName, keyName);
   ToUpperCase(keyName); // We want case-insensitive comparison with data
                         // stored as uppercase.
 
   uint32_t keyNameLength = keyName.Length();
   const char* keyNameStr = keyName.get();
   for (uint16_t i = 0; i < ArrayLength(gKeyCodes) - 1; ++i) {
     if (keyNameLength == gKeyCodes[i].strlength &&
         !nsCRT::strcmp(gKeyCodes[i].str, keyNameStr)) {
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -443,17 +443,17 @@ public:
     , mWorkerPrivate(aProxy->mWorkerPrivate)
     , mProxy(aProxy)
     , mXHR(aProxy->mXHR)
     , mXMLHttpRequestPrivate(aXHRPrivate)
     , mChannelId(mProxy->mInnerChannelId)
     , mReceivedLoadStart(false)
   {
     AssertIsOnMainThread();
-    mEventType.AssignWithConversion(sEventStrings[STRING_loadstart]);
+    CopyASCIItoUTF16(sEventStrings[STRING_loadstart], mEventType);
   }
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSIDOMEVENTLISTENER
 
   bool
   RegisterAndDispatch()
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -3809,17 +3809,17 @@ XULDocument::OverlayForwardReference::Re
         // XXX this is bogus, the content in 'target' might already be
         // in the document
         rv = mDocument->AddSubtreeToDocument(target);
         if (NS_FAILED(rv)) return eResolve_Error;
     }
 
     if (MOZ_LOG_TEST(gXULLog, LogLevel::Debug)) {
         nsAutoCString idC;
-        idC.AssignWithConversion(id);
+        LossyCopyUTF16toASCII(id, idC);
         MOZ_LOG(gXULLog, LogLevel::Debug,
                ("xul: overlay resolved '%s'",
                 idC.get()));
     }
 
     mResolved = true;
     return eResolve_Succeeded;
 }
@@ -3981,17 +3981,17 @@ XULDocument::OverlayForwardReference::Me
 
 XULDocument::OverlayForwardReference::~OverlayForwardReference()
 {
     if (MOZ_LOG_TEST(gXULLog, LogLevel::Warning) && !mResolved) {
         nsAutoString id;
         mOverlay->GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
 
         nsAutoCString idC;
-        idC.AssignWithConversion(id);
+        LossyCopyUTF16toASCII(id, idC);
 
         nsIURI *protoURI = mDocument->mCurrentPrototype->GetURI();
 
         nsCOMPtr<nsIURI> docURI;
         mDocument->mChannel->GetOriginalURI(getter_AddRefs(docURI));
 
         MOZ_LOG(gXULLog, LogLevel::Warning,
                ("xul: %s overlay failed to resolve '%s' in %s",
@@ -4032,18 +4032,18 @@ XULDocument::BroadcasterHookup::~Broadca
             mObservesElement->GetAttr(kNameSpaceID_None, nsGkAtoms::attribute, attribute);
         }
         else {
             mObservesElement->GetAttr(kNameSpaceID_None, nsGkAtoms::observes, broadcasterID);
             attribute.Assign('*');
         }
 
         nsAutoCString attributeC,broadcasteridC;
-        attributeC.AssignWithConversion(attribute);
-        broadcasteridC.AssignWithConversion(broadcasterID);
+        LossyCopyUTF16toASCII(attribute, attributeC);
+        LossyCopyUTF16toASCII(broadcasterID, broadcasteridC);
         MOZ_LOG(gXULLog, LogLevel::Warning,
                ("xul: broadcaster hookup failed <%s attribute='%s'> to %s",
                 nsAtomCString(mObservesElement->NodeInfo()->NameAtom()).get(),
                 attributeC.get(),
                 broadcasteridC.get()));
     }
 }
 
@@ -4244,18 +4244,18 @@ XULDocument::CheckBroadcasterHookup(Elem
         nsCOMPtr<nsIContent> content =
             do_QueryInterface(listener);
 
         NS_ASSERTION(content != nullptr, "not an nsIContent");
         if (! content)
             return rv;
 
         nsAutoCString attributeC,broadcasteridC;
-        attributeC.AssignWithConversion(attribute);
-        broadcasteridC.AssignWithConversion(broadcasterID);
+        LossyCopyUTF16toASCII(attribute, attributeC);
+        LossyCopyUTF16toASCII(broadcasterID, broadcasteridC);
         MOZ_LOG(gXULLog, LogLevel::Debug,
                ("xul: broadcaster hookup <%s attribute='%s'> to %s",
                 nsAtomCString(content->NodeInfo()->NameAtom()).get(),
                 attributeC.get(),
                 broadcasteridC.get()));
     }
 
     *aNeedsHookup = false;
--- a/dom/xul/nsXULCommandDispatcher.cpp
+++ b/dom/xul/nsXULCommandDispatcher.cpp
@@ -258,18 +258,18 @@ nsXULCommandDispatcher::AddCommandUpdate
   Updater** link = &mUpdaters;
 
   while (updater) {
     if (updater->mElement == aElement) {
 
 #ifdef DEBUG
       if (MOZ_LOG_TEST(gCommandLog, LogLevel::Debug)) {
         nsAutoCString eventsC, targetsC, aeventsC, atargetsC;
-        eventsC.AssignWithConversion(updater->mEvents);
-        targetsC.AssignWithConversion(updater->mTargets);
+        LossyCopyUTF16toASCII(updater->mEvents, eventsC);
+        LossyCopyUTF16toASCII(updater->mTargets, targetsC);
         CopyUTF16toUTF8(aEvents, aeventsC);
         CopyUTF16toUTF8(aTargets, atargetsC);
         MOZ_LOG(gCommandLog, LogLevel::Debug,
                ("xulcmd[%p] replace %p(events=%s targets=%s) with (events=%s targets=%s)",
                 this, aElement,
                 eventsC.get(),
                 targetsC.get(),
                 aeventsC.get(),
@@ -317,18 +317,18 @@ nsXULCommandDispatcher::RemoveCommandUpd
   Updater* updater = mUpdaters;
   Updater** link = &mUpdaters;
 
   while (updater) {
     if (updater->mElement == aElement) {
 #ifdef DEBUG
       if (MOZ_LOG_TEST(gCommandLog, LogLevel::Debug)) {
         nsAutoCString eventsC, targetsC;
-        eventsC.AssignWithConversion(updater->mEvents);
-        targetsC.AssignWithConversion(updater->mTargets);
+        LossyCopyUTF16toASCII(updater->mEvents, eventsC);
+        LossyCopyUTF16toASCII(updater->mTargets, targetsC);
         MOZ_LOG(gCommandLog, LogLevel::Debug,
                ("xulcmd[%p] remove  %p(events=%s targets=%s)",
                 this, aElement,
                 eventsC.get(),
                 targetsC.get()));
       }
 #endif
 
--- a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
@@ -1008,17 +1008,17 @@ nsXULTemplateQueryProcessorRDF::Log(cons
             return rv;
 
         nsAutoString targetStr;
         rv = nsXULContentUtils::GetTextForNode(aTarget, targetStr);
         if (NS_FAILED(rv))
             return rv;
 
         nsAutoCString targetstrC;
-        targetstrC.AssignWithConversion(targetStr);
+        LossyCopyUTF16toASCII(targetStr, targetstrC);
         MOZ_LOG(gXULTemplateLog, LogLevel::Debug,
                ("                        --[%s]-->[%s]",
                 propertyStr,
                 targetstrC.get()));
     }
     return NS_OK;
 }
 
@@ -1234,17 +1234,17 @@ nsXULTemplateQueryProcessorRDF::CompileQ
     else if (aTag == nsGkAtoms::member) {
         rv = CompileMemberCondition(aQuery, aCondition, aParentNode, aResult);
     }
     else if (MOZ_LOG_TEST(gXULTemplateLog, LogLevel::Info)) {
         nsAutoString tagstr;
         aTag->ToString(tagstr);
 
         nsAutoCString tagstrC;
-        tagstrC.AssignWithConversion(tagstr);
+        LossyCopyUTF16toASCII(tagstr, tagstrC);
         MOZ_LOG(gXULTemplateLog, LogLevel::Info,
                ("xultemplate[%p] unrecognized condition test <%s>",
                 this, tagstrC.get()));
     }
 
     return rv;
 }
 
--- a/editor/composer/nsComposerCommands.cpp
+++ b/editor/composer/nsComposerCommands.cpp
@@ -582,17 +582,17 @@ nsMultiStateCommand::DoCommandParams(con
   nsresult rv = NS_OK;
   if (editor) {
       nsAutoString tString;
 
       if (aParams) {
         nsXPIDLCString s;
         rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));
         if (NS_SUCCEEDED(rv))
-          tString.AssignWithConversion(s);
+          CopyASCIItoUTF16(s, tString);
         else
           rv = aParams->GetStringValue(STATE_ATTRIBUTE, tString);
       }
 
       rv = SetState(editor, tString);
   }
 
   return rv;
@@ -625,17 +625,17 @@ nsParagraphStateCommand::GetCurrentState
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = htmlEditor->GetParagraphState(&outMixed, outStateString);
   if (NS_SUCCEEDED(rv)) {
     nsAutoCString tOutStateString;
-    tOutStateString.AssignWithConversion(outStateString);
+    LossyCopyUTF16toASCII(outStateString, tOutStateString);
     aParams->SetBooleanValue(STATE_MIXED,outMixed);
     aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
   }
   return rv;
 }
 
 
 nsresult
@@ -702,18 +702,16 @@ nsFontFaceStateCommand::SetState(nsIEdit
                                        NS_LITERAL_STRING("face"), newState);
 }
 
 nsFontSizeStateCommand::nsFontSizeStateCommand()
   : nsMultiStateCommand()
 {
 }
 
-//  nsAutoCString tOutStateString;
-//  tOutStateString.AssignWithConversion(outStateString);
 nsresult
 nsFontSizeStateCommand::GetCurrentState(nsIEditor *aEditor,
                                         nsICommandParams *aParams)
 {
   NS_ASSERTION(aEditor, "Need an editor here");
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(aEditor);
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_INVALID_ARG);
 
@@ -723,17 +721,17 @@ nsFontSizeStateCommand::GetCurrentState(
   nsresult rv = htmlEditor->GetInlinePropertyWithAttrValue(fontAtom,
                                          NS_LITERAL_STRING("size"),
                                          EmptyString(),
                                          &firstHas, &anyHas, &allHas,
                                          outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
-  tOutStateString.AssignWithConversion(outStateString);
+  LossyCopyUTF16toASCII(outStateString, tOutStateString);
   aParams->SetBooleanValue(STATE_MIXED, anyHas && !allHas);
   aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
   aParams->SetBooleanValue(STATE_ENABLED, true);
 
   return rv;
 }
 
 
@@ -786,17 +784,17 @@ nsFontColorStateCommand::GetCurrentState
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = htmlEditor->GetFontColorState(&outMixed, outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
-  tOutStateString.AssignWithConversion(outStateString);
+  LossyCopyUTF16toASCII(outStateString, tOutStateString);
   aParams->SetBooleanValue(STATE_MIXED, outMixed);
   aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
   return NS_OK;
 }
 
 nsresult
 nsFontColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
 {
@@ -827,17 +825,17 @@ nsHighlightColorStateCommand::GetCurrent
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv = htmlEditor->GetHighlightColorState(&outMixed, outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
-  tOutStateString.AssignWithConversion(outStateString);
+  LossyCopyUTF16toASCII(outStateString, tOutStateString);
   aParams->SetBooleanValue(STATE_MIXED, outMixed);
   aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
   return NS_OK;
 }
 
 nsresult
 nsHighlightColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
 {
@@ -884,17 +882,17 @@ nsBackgroundColorStateCommand::GetCurren
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
   bool outMixed;
   nsAutoString outStateString;
   nsresult rv =  htmlEditor->GetBackgroundColorState(&outMixed, outStateString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoCString tOutStateString;
-  tOutStateString.AssignWithConversion(outStateString);
+  LossyCopyUTF16toASCII(outStateString, tOutStateString);
   aParams->SetBooleanValue(STATE_MIXED, outMixed);
   aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
   return NS_OK;
 }
 
 nsresult
 nsBackgroundColorStateCommand::SetState(nsIEditor *aEditor, nsString& newState)
 {
@@ -940,17 +938,17 @@ nsAlignCommand::GetCurrentState(nsIEdito
       outStateString.AssignLiteral("right");
       break;
 
     case nsIHTMLEditor::eJustify:
       outStateString.AssignLiteral("justify");
       break;
   }
   nsAutoCString tOutStateString;
-  tOutStateString.AssignWithConversion(outStateString);
+  LossyCopyUTF16toASCII(outStateString, tOutStateString);
   aParams->SetBooleanValue(STATE_MIXED,outMixed);
   aParams->SetCStringValue(STATE_ATTRIBUTE, tOutStateString.get());
   return NS_OK;
 }
 
 nsresult
 nsAlignCommand::SetState(nsIEditor *aEditor, nsString& newState)
 {
@@ -1403,17 +1401,18 @@ nsInsertTagCommand::DoCommandParams(cons
 
   nsCOMPtr<nsIHTMLEditor> editor = do_QueryInterface(refCon);
   NS_ENSURE_TRUE(editor, NS_ERROR_NOT_IMPLEMENTED);
 
   // do we have an href to use for creating link?
   nsXPIDLCString s;
   nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));
   NS_ENSURE_SUCCESS(rv, rv);
-  nsAutoString attrib; attrib.AssignWithConversion(s);
+  nsAutoString attrib;
+  CopyASCIItoUTF16(s, attrib);
 
   if (attrib.IsEmpty())
     return NS_ERROR_INVALID_ARG;
 
   // filter out tags we don't know how to insert
   nsAutoString attributeType;
   if (mTagName == nsGkAtoms::a) {
     attributeType.AssignLiteral("href");
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3483,17 +3483,17 @@ HTMLEditor::StyleSheetLoaded(StyleSheet*
   nsresult rv = DoTransaction(transaction);
   if (NS_SUCCEEDED(rv)) {
     // Get the URI, then url spec from the sheet
     nsAutoCString spec;
     rv = aSheet->GetSheetURI()->GetSpec(spec);
 
     if (NS_SUCCEEDED(rv)) {
       // Save it so we can remove before applying the next one
-      mLastStyleSheetURL.AssignWithConversion(spec.get());
+      CopyASCIItoUTF16(spec, mLastStyleSheetURL);
 
       // Also save in our arrays of urls and sheets
       AddNewStyleSheetToList(mLastStyleSheetURL, aSheet);
     }
   }
 
   return NS_OK;
 }
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1148,17 +1148,17 @@ HTMLEditor::InsertFromTransferable(nsITr
   nsCOMPtr<nsISupports> genericDataObj;
   uint32_t len = 0;
   if (NS_SUCCEEDED(
         transferable->GetAnyTransferData(bestFlavor,
                                          getter_AddRefs(genericDataObj),
                                          &len))) {
     AutoTransactionsConserveSelection dontSpazMySelection(this);
     nsAutoString flavor;
-    flavor.AssignWithConversion(bestFlavor);
+    CopyASCIItoUTF16(bestFlavor, flavor);
     nsAutoString stuffToPaste;
     bool isSafe = IsSafeToInsertData(aSourceDoc);
 
     if (bestFlavor.EqualsLiteral(kFileMime) ||
         bestFlavor.EqualsLiteral(kJPEGImageMime) ||
         bestFlavor.EqualsLiteral(kJPGImageMime) ||
         bestFlavor.EqualsLiteral(kPNGImageMime) ||
         bestFlavor.EqualsLiteral(kGIFImageMime)) {
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -179,17 +179,17 @@ nsXPConnect::IsISupportsDescendant(nsIIn
 }
 
 void
 xpc::ErrorBase::Init(JSErrorBase* aReport)
 {
     if (!aReport->filename)
         mFileName.SetIsVoid(true);
     else
-        mFileName.AssignWithConversion(aReport->filename);
+        CopyASCIItoUTF16(aReport->filename, mFileName);
 
     mLineNumber = aReport->lineno;
     mColumn = aReport->column;
 }
 
 void
 xpc::ErrorNote::Init(JSErrorNotes::Note* aNote)
 {
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -6736,27 +6736,27 @@ CSSParserImpl::ParseColor(nsCSSValue& aV
     switch (tk->mType) {
       case eCSSToken_Ident:
         str.Assign(tk->mIdent);
         break;
 
       case eCSSToken_Number:
         if (tk->mIntegerValid && tk->mInteger < 1000000 && tk->mInteger >= 0) {
           SprintfLiteral(buffer, "%06d", tk->mInteger);
-          str.AssignWithConversion(buffer);
+          CopyASCIItoUTF16(buffer, str);
         }
         break;
 
       case eCSSToken_Dimension:
         if (tk->mIntegerValid &&
             tk->mIdent.Length() + CountNumbersForHashlessColor(tk->mInteger) <= 6 &&
             tk->mInteger >= 0) {
           SprintfLiteral(buffer, "%06d", tk->mInteger);
           nsAutoString temp;
-          temp.AssignWithConversion(buffer);
+          CopyASCIItoUTF16(buffer, temp);
           temp.Right(str, 6 - tk->mIdent.Length());
           str.Append(tk->mIdent);
         }
         break;
       default:
         // There is a whole bunch of cases that are
         // not handled by this switch.  Ignore them.
         break;
--- a/security/manager/ssl/PKCS11.cpp
+++ b/security/manager/ssl/PKCS11.cpp
@@ -84,23 +84,23 @@ PKCS11::DeleteModule(const nsAString& aM
 // to programmatically query the scalar key length limit, so we have to
 // hard-code the value here.)
 void
 GetModuleNameForTelemetry(/*in*/ const SECMODModule* module,
                           /*out*/nsString& result)
 {
   result.Truncate();
   if (module->dllName) {
-    result.AssignWithConversion(module->dllName);
+    CopyASCIItoUTF16(module->dllName, result);
     int32_t separatorIndex = result.RFind(FILE_PATH_SEPARATOR);
     if (separatorIndex != kNotFound) {
       result = Substring(result, separatorIndex + 1);
     }
   } else {
-    result.AssignWithConversion(module->commonName);
+    CopyASCIItoUTF16(module->commonName, result);
   }
   if (result.Length() >= 70) {
     result.Truncate(69);
   }
 }
 
 // Add a new PKCS11 module to the user's profile.
 NS_IMETHODIMP
--- a/toolkit/components/printingui/win/nsPrintDialogUtil.cpp
+++ b/toolkit/components/printingui/win/nsPrintDialogUtil.cpp
@@ -250,19 +250,19 @@ static HWND CreateControl(LPCTSTR       
 //--------------------------------------------------------
 // Create a Radio Button
 static HWND CreateRadioBtn(HINSTANCE        aHInst,
                            HWND             aHdlg,
                            int              aId,
                            const char*      aStr,
                            const nsIntRect& aRect)
 {
-  nsString cStr;
-  cStr.AssignWithConversion(aStr);
-  return CreateControl("BUTTON", BS_RADIOBUTTON, aHInst, aHdlg, aId, cStr, aRect);
+  nsString str;
+  CopyASCIItoUTF16(aStr, str);
+  return CreateControl("BUTTON", BS_RADIOBUTTON, aHInst, aHdlg, aId, str, aRect);
 }
 
 //--------------------------------------------------------
 // Create a Group Box
 static HWND CreateGroupBox(HINSTANCE        aHInst,
                            HWND             aHdlg,
                            int              aId,
                            const nsAString& aStr,
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -580,17 +580,17 @@ XRE_InitChildProcess(int aArgc,
   // On Win7+, register the application user model id passed in by
   // parent. This insures windows created by the container properly
   // group with the parent app on the Win7 taskbar.
   const char* const appModelUserId = aArgv[--aArgc];
   if (appModelUserId) {
     // '-' implies no support
     if (*appModelUserId != '-') {
       nsString appId;
-      appId.AssignWithConversion(nsDependentCString(appModelUserId));
+      CopyASCIItoUTF16(nsDependentCString(appModelUserId), appId);
       // The version string is encased in quotes
       appId.Trim("\"");
       // Set the id
       SetTaskbarGroupId(appId);
     }
   }
 #endif
 
--- a/widget/cocoa/nsCocoaUtils.mm
+++ b/widget/cocoa/nsCocoaUtils.mm
@@ -943,17 +943,17 @@ static const KeyConversionData gKeyConve
 uint32_t
 nsCocoaUtils::ConvertGeckoNameToMacCharCode(const nsAString& aKeyCodeName)
 {
   if (aKeyCodeName.IsEmpty()) {
     return 0;
   }
 
   nsAutoCString keyCodeName;
-  keyCodeName.AssignWithConversion(aKeyCodeName);
+  LossyCopyUTF16toASCII(aKeyCodeName, keyCodeName);
   // We want case-insensitive comparison with data stored as uppercase.
   ToUpperCase(keyCodeName);
 
   uint32_t keyCodeNameLength = keyCodeName.Length();
   const char* keyCodeNameStr = keyCodeName.get();
   for (uint16_t i = 0; i < ArrayLength(gKeyConversions); ++i) {
     if (keyCodeNameLength == gKeyConversions[i].strLength &&
         nsCRT::strcmp(gKeyConversions[i].str, keyCodeNameStr) == 0) {
--- a/xpcom/string/nsStringObsolete.cpp
+++ b/xpcom/string/nsStringObsolete.cpp
@@ -1026,26 +1026,9 @@ nsCString::ToDouble(nsresult* aErrorCode
 }
 
 double
 nsString::ToDouble(nsresult* aErrorCode) const
 {
   return NS_LossyConvertUTF16toASCII(*this).ToDouble(aErrorCode);
 }
 
-
-/**
- * nsTString::AssignWithConversion
- */
-
-void
-nsCString::AssignWithConversion( const nsAString& aData )
-{
-  LossyCopyUTF16toASCII(aData, *this);
-}
-
-void
-nsString::AssignWithConversion( const nsACString& aData )
-{
-  CopyASCIItoUTF16(aData, *this);
-}
-
 #endif // !MOZ_STRING_WITH_OBSOLETE_API
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -425,25 +425,16 @@ public:
    *  string as well.
    *
    *  @param   aEliminateLeading controls stripping of leading ws
    *  @param   aEliminateTrailing controls stripping of trailing ws
    */
   void CompressWhitespace(bool aEliminateLeading = true,
                           bool aEliminateTrailing = true);
 
-
-  /**
-   * assign/append/insert with _LOSSY_ conversion
-   */
-
-  void AssignWithConversion(const nsTAString_IncompatibleCharT& aString);
-  void AssignWithConversion(const incompatible_char_type* aData,
-                            int32_t aLength = -1);
-
 #endif // !MOZ_STRING_WITH_OBSOLETE_API
 
   /**
    * Allow this string to be bound to a character buffer
    * until the string is rebound or mutated; the caller
    * must ensure that the buffer outlives the string.
    */
   void Rebind(const char_type* aData, size_type aLength);
--- a/xpcom/string/nsTStringObsolete.cpp
+++ b/xpcom/string/nsTStringObsolete.cpp
@@ -713,31 +713,8 @@ nsTString_CharT::CompressWhitespace( boo
   // If we need to trim the trailing whitespace, back up one character.
   if (aTrimTrailing && skipWS && to > mData) {
     to--;
   }
 
   *to = char_type(0); // add the null
   mLength = to - mData;
 }
-
-
-/**
- * nsTString::AssignWithConversion
- */
-
-void
-nsTString_CharT::AssignWithConversion( const incompatible_char_type* aData, int32_t aLength )
-{
-  // for compatibility with the old string implementation, we need to allow
-  // for a nullptr input buffer :-(
-  if (!aData)
-  {
-    Truncate();
-  }
-  else
-  {
-    if (aLength < 0)
-      aLength = nsCharTraits<incompatible_char_type>::length(aData);
-
-    AssignWithConversion(Substring(aData, aLength));
-  }
-}
--- a/xpcom/tests/gtest/TestCRT.cpp
+++ b/xpcom/tests/gtest/TestCRT.cpp
@@ -32,18 +32,18 @@ int sign(int val) {
 // iso-latin-1 strings, so the comparison must be valid.
 static void Check(const char* s1, const char* s2, int n)
 {
   int clib = PL_strcmp(s1, s2);
 
   int clib_n = PL_strncmp(s1, s2, n);
 
   nsAutoString t1,t2;
-  t1.AssignWithConversion(s1);
-  t2.AssignWithConversion(s2);
+  CopyASCIItoUTF16(s1, t1);
+  CopyASCIItoUTF16(s2, t2);
   const char16_t* us1 = t1.get();
   const char16_t* us2 = t2.get();
 
   int u2 = nsCRT::strcmp(us1, us2);
 
   int u2_n = nsCRT::strncmp(us1, us2, n);
 
   EXPECT_EQ(sign(clib), sign(u2));
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -318,18 +318,18 @@ TEST(Strings, replace_substr)
 }
 
 TEST(Strings, replace_substr_2)
 {
   const char *oldName = nullptr;
   const char *newName = "user";
   nsString acctName; acctName.AssignLiteral("forums.foo.com");
   nsAutoString newAcctName, oldVal, newVal;
-  oldVal.AssignWithConversion(oldName);
-  newVal.AssignWithConversion(newName);
+  CopyASCIItoUTF16(oldName, oldVal);
+  CopyASCIItoUTF16(newName, newVal);
   newAcctName.Assign(acctName);
 
   // here, oldVal is empty.  we are testing that this function
   // does not hang.  see bug 235355.
   newAcctName.ReplaceSubstring(oldVal, newVal);
 
   // we expect that newAcctName will be unchanged.
   EXPECT_TRUE(newAcctName.Equals(acctName));
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -1650,44 +1650,44 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
   }
 
   bool shouldPersist = !isFullscreen && ownerXULDoc;
   ErrorResult rv;
   // (only for size elements which are persisted)
   if ((mPersistentAttributesDirty & PAD_POSITION) && gotRestoredBounds) {
     if (persistString.Find("screenX") >= 0) {
       SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.x / posScale.scale));
-      sizeString.AssignWithConversion(sizeBuf);
+      CopyASCIItoUTF16(sizeBuf, sizeString);
       docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, SCREENX_ATTRIBUTE);
       }
     }
     if (persistString.Find("screenY") >= 0) {
       SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.y / posScale.scale));
-      sizeString.AssignWithConversion(sizeBuf);
+      CopyASCIItoUTF16(sizeBuf, sizeString);
       docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, SCREENY_ATTRIBUTE);
       }
     }
   }
 
   if ((mPersistentAttributesDirty & PAD_SIZE) && gotRestoredBounds) {
     if (persistString.Find("width") >= 0) {
       SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.width / sizeScale.scale));
-      sizeString.AssignWithConversion(sizeBuf);
+      CopyASCIItoUTF16(sizeBuf, sizeString);
       docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, WIDTH_ATTRIBUTE);
       }
     }
     if (persistString.Find("height") >= 0) {
       SprintfLiteral(sizeBuf, "%d", NSToIntRound(rect.height / sizeScale.scale));
-      sizeString.AssignWithConversion(sizeBuf);
+      CopyASCIItoUTF16(sizeBuf, sizeString);
       docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
       if (shouldPersist) {
         ownerXULDoc->Persist(windowElementId, HEIGHT_ATTRIBUTE);
       }
     }
   }
 
   if (mPersistentAttributesDirty & PAD_MISC) {
@@ -1706,17 +1706,17 @@ NS_IMETHODIMP nsXULWindow::SavePersisten
       }
     }
     if (persistString.Find("zlevel") >= 0) {
       uint32_t zLevel;
       nsCOMPtr<nsIWindowMediator> mediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
       if (mediator) {
         mediator->GetZLevel(this, &zLevel);
         SprintfLiteral(sizeBuf, "%" PRIu32, zLevel);
-        sizeString.AssignWithConversion(sizeBuf);
+        CopyASCIItoUTF16(sizeBuf, sizeString);
         docShellElement->SetAttribute(ZLEVEL_ATTRIBUTE, sizeString, rv);
         if (shouldPersist) {
           ownerXULDoc->Persist(windowElementId, ZLEVEL_ATTRIBUTE);
         }
       }
     }
   }
 
--- a/xpfe/components/directory/nsDirectoryViewer.cpp
+++ b/xpfe/components/directory/nsDirectoryViewer.cpp
@@ -159,17 +159,17 @@ nsHTTPIndex::OnFTPControlLog(bool server
     dom::AutoEntryScript aes(globalObject,
                              "nsHTTPIndex OnFTPControlLog");
     JSContext* cx = aes.cx();
 
     JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
     NS_ENSURE_TRUE(global, NS_OK);
 
     nsString unicodeMsg;
-    unicodeMsg.AssignWithConversion(msg);
+    CopyASCIItoUTF16(msg, unicodeMsg);
     JSString* jsMsgStr = JS_NewUCStringCopyZ(cx, unicodeMsg.get());
     NS_ENSURE_TRUE(jsMsgStr, NS_ERROR_OUT_OF_MEMORY);
 
     JS::AutoValueArray<2> params(cx);
     params[0].setBoolean(server);
     params[1].setString(jsMsgStr);
 
     JS::Rooted<JS::Value> val(cx);
@@ -402,17 +402,17 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest
   // constructed a resource for it, stored in entry. So now take a
   // second pass through the values and add as statements to the RDF
   // datasource.
 
   if (entry && NS_SUCCEEDED(rv)) {
     nsCOMPtr<nsIRDFLiteral> lit;
     nsString str;
 
-    str.AssignWithConversion(entryuriC.get());
+    CopyASCIItoUTF16(entryuriC, str);
 
     rv = mDirRDF->GetLiteral(str.get(), getter_AddRefs(lit));
 
     if (NS_SUCCEEDED(rv)) {
       rv = Assert(entry, kNC_URL, lit, true);
       if (NS_FAILED(rv)) return rv;
 
       nsXPIDLString xpstr;