Bug 1374580 (part 2) - Remove nsAFlat{,C}String typedefs. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 20 Jun 2017 19:19:05 +1000
changeset 414464 2915d4b7849612e583048650beabe33bad2cfeca
parent 414463 87b31f17dd993477d662161290335e01844530ed
child 414465 6352096eb0de303cba9440092279e4254a1ec586
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)
reviewersfroydnj
bugs1374580
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 1374580 (part 2) - Remove nsAFlat{,C}String typedefs. r=froydnj. All the instances are converted as follows. - nsAFlatString --> nsString - nsAFlatCString --> nsCString
accessible/base/Logging.cpp
accessible/base/Logging.h
dom/base/DOMImplementation.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsFrameLoader.cpp
dom/base/nsImageLoadingContent.cpp
dom/cache/TypeUtils.cpp
dom/events/ContentEventHandler.cpp
dom/events/ContentEventHandler.h
dom/events/Event.cpp
dom/jsurl/nsJSProtocolHandler.cpp
dom/jsurl/nsJSProtocolHandler.h
dom/plugins/base/nsPluginTags.cpp
dom/security/test/gtest/TestCSPParser.cpp
dom/svg/nsSVGElement.cpp
dom/xbl/nsXBLBinding.cpp
dom/xbl/nsXBLBinding.h
dom/xslt/base/txExpandedName.cpp
dom/xslt/xml/txXMLUtils.cpp
dom/xslt/xml/txXMLUtils.h
dom/xslt/xslt/txBufferingHandler.cpp
dom/xslt/xslt/txInstructions.cpp
dom/xslt/xslt/txPatternParser.cpp
dom/xslt/xslt/txPatternParser.h
dom/xslt/xslt/txXPathResultComparator.cpp
dom/xslt/xslt/txXPathResultComparator.h
dom/xslt/xslt/txXSLTNumber.h
dom/xslt/xslt/txXSLTNumberCounters.cpp
editor/composer/nsComposerCommands.cpp
editor/composer/nsEditingSession.cpp
editor/libeditor/EditorBase.cpp
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/TextEditorTest.cpp
extensions/cookie/nsPermissionManager.cpp
extensions/cookie/nsPermissionManager.h
intl/uconv/nsTextToSubURI.cpp
intl/uconv/nsTextToSubURI.h
layout/inspector/inCSSValueSearch.cpp
layout/inspector/inCSSValueSearch.h
layout/style/CounterStyleManager.cpp
layout/style/FontFaceSet.cpp
layout/style/Loader.cpp
layout/style/ServoBindings.cpp
layout/style/nsCSSKeywords.cpp
layout/style/nsCSSKeywords.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSProps.h
layout/style/nsCSSValue.cpp
modules/libpref/prefapi.cpp
netwerk/base/nsStandardURL.cpp
netwerk/base/nsStandardURL.h
netwerk/base/nsURLHelper.h
netwerk/cookie/nsCookie.h
netwerk/cookie/nsCookieService.cpp
netwerk/cookie/nsCookieService.h
netwerk/dns/nsIDNService.cpp
netwerk/mime/nsMIMEHeaderParamImpl.cpp
netwerk/protocol/http/Http2Stream.h
netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
netwerk/protocol/http/nsHttpChannelAuthProvider.h
netwerk/protocol/http/nsHttpConnectionInfo.h
netwerk/protocol/http/nsHttpDigestAuth.cpp
netwerk/protocol/http/nsHttpDigestAuth.h
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
netwerk/streamconv/converters/nsBinHexDecoder.cpp
netwerk/streamconv/converters/nsBinHexDecoder.h
rdf/base/nsRDFService.cpp
security/manager/ssl/nsKeygenHandler.cpp
security/manager/ssl/nsKeygenHandler.h
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/exthandler/nsExternalHelperAppService.h
uriloader/exthandler/win/nsOSHelperAppService.cpp
uriloader/exthandler/win/nsOSHelperAppService.h
widget/cocoa/TextInputHandler.h
widget/cocoa/TextInputHandler.mm
widget/tests/TestChromeMargin.cpp
widget/windows/IMMHandler.cpp
widget/windows/IMMHandler.h
xpcom/ds/nsPersistentProperties.cpp
xpcom/ds/nsStaticNameTable.cpp
xpcom/ds/nsStaticNameTable.h
xpcom/io/nsEscape.cpp
xpcom/io/nsEscape.h
xpcom/io/nsLocalFileWin.cpp
xpcom/io/nsLocalFileWin.h
xpcom/string/nsReadableUtils.cpp
xpcom/string/nsReadableUtils.h
xpcom/string/nsStringFwd.h
xpcom/string/nsStringObsolete.cpp
xpcom/string/nsTString.h
--- a/accessible/base/Logging.cpp
+++ b/accessible/base/Logging.cpp
@@ -1021,17 +1021,17 @@ logging::IsEnabled(const nsAString& aMod
     if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr))
       return sModules & sModuleMap[idx].mModule;
   }
 
   return false;
 }
 
 void
-logging::Enable(const nsAFlatCString& aModules)
+logging::Enable(const nsCString& aModules)
 {
   EnableLogging(aModules.get());
 }
 
 
 void
 logging::CheckEnv()
 {
--- a/accessible/base/Logging.h
+++ b/accessible/base/Logging.h
@@ -204,17 +204,17 @@ void DOMEvent(const char* aDescr, nsINod
 /**
  * Log the call stack, two spaces offset is used.
  */
 void Stack();
 
 /**
  * Enable logging of the specified modules, all other modules aren't logged.
  */
-void Enable(const nsAFlatCString& aModules);
+void Enable(const nsCString& aModules);
 
 /**
  * Enable logging of modules specified by A11YLOG environment variable,
  * all other modules aren't logged.
  */
 void CheckEnv();
 
 } // namespace logging
--- a/dom/base/DOMImplementation.cpp
+++ b/dom/base/DOMImplementation.cpp
@@ -93,17 +93,17 @@ DOMImplementation::CreateDocument(const 
                                   nsIDocument** aDocument,
                                   nsIDOMDocument** aDOMDocument)
 {
   *aDocument = nullptr;
   *aDOMDocument = nullptr;
 
   nsresult rv;
   if (!aQualifiedName.IsEmpty()) {
-    const nsAFlatString& qName = PromiseFlatString(aQualifiedName);
+    const nsString& qName = PromiseFlatString(aQualifiedName);
     const char16_t *colon;
     rv = nsContentUtils::CheckQName(qName, true, &colon);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (colon &&
         (DOMStringIsNull(aNamespaceURI) ||
          (Substring(qName.get(), colon).EqualsLiteral("xml") &&
           !aNamespaceURI.EqualsLiteral("http://www.w3.org/XML/1998/namespace")))) {
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3258,17 +3258,17 @@ nsContentUtils::CheckQName(const nsAStri
   }
 
   return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
 }
 
 //static
 nsresult
 nsContentUtils::SplitQName(const nsIContent* aNamespaceResolver,
-                           const nsAFlatString& aQName,
+                           const nsString& aQName,
                            int32_t *aNamespace, nsIAtom **aLocalName)
 {
   const char16_t* colon;
   nsresult rv = nsContentUtils::CheckQName(aQName, true, &colon);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (colon) {
     const char16_t* end;
@@ -3297,17 +3297,17 @@ nsContentUtils::SplitQName(const nsICont
 // static
 nsresult
 nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI,
                                      const nsAString& aQualifiedName,
                                      nsNodeInfoManager* aNodeInfoManager,
                                      uint16_t aNodeType,
                                      mozilla::dom::NodeInfo** aNodeInfo)
 {
-  const nsAFlatString& qName = PromiseFlatString(aQualifiedName);
+  const nsString& qName = PromiseFlatString(aQualifiedName);
   const char16_t* colon;
   nsresult rv = nsContentUtils::CheckQName(qName, true, &colon);
   NS_ENSURE_SUCCESS(rv, rv);
 
   int32_t nsID;
   sNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsID);
   if (colon) {
     const char16_t* end;
@@ -3950,17 +3950,17 @@ nsContentUtils::LogSimpleConsoleError(co
 nsContentUtils::ReportToConsole(uint32_t aErrorFlags,
                                 const nsACString& aCategory,
                                 const nsIDocument* aDocument,
                                 PropertiesFile aFile,
                                 const char *aMessageName,
                                 const char16_t **aParams,
                                 uint32_t aParamsLength,
                                 nsIURI* aURI,
-                                const nsAFlatString& aSourceLine,
+                                const nsString& aSourceLine,
                                 uint32_t aLineNumber,
                                 uint32_t aColumnNumber)
 {
   NS_ASSERTION((aParams && aParamsLength) || (!aParams && !aParamsLength),
                "Supply either both parameters and their number or no"
                "parameters and 0.");
 
   nsresult rv;
@@ -3981,17 +3981,17 @@ nsContentUtils::ReportToConsole(uint32_t
 
 
 /* static */ nsresult
 nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
                                             uint32_t aErrorFlags,
                                             const nsACString& aCategory,
                                             const nsIDocument* aDocument,
                                             nsIURI* aURI,
-                                            const nsAFlatString& aSourceLine,
+                                            const nsString& aSourceLine,
                                             uint32_t aLineNumber,
                                             uint32_t aColumnNumber,
                                             MissingErrorLocationMode aLocationMode)
 {
   uint64_t innerWindowID = 0;
   if (aDocument) {
     if (!aURI) {
       aURI = aDocument->GetDocumentURI();
@@ -4005,17 +4005,17 @@ nsContentUtils::ReportToConsoleNonLocali
 }
 
 /* static */ nsresult
 nsContentUtils::ReportToConsoleByWindowID(const nsAString& aErrorText,
                                           uint32_t aErrorFlags,
                                           const nsACString& aCategory,
                                           uint64_t aInnerWindowID,
                                           nsIURI* aURI,
-                                          const nsAFlatString& aSourceLine,
+                                          const nsString& aSourceLine,
                                           uint32_t aLineNumber,
                                           uint32_t aColumnNumber,
                                           MissingErrorLocationMode aLocationMode)
 {
   nsresult rv;
   if (!sConsoleService) { // only need to bother null-checking here
     rv = CallGetService(NS_CONSOLESERVICE_CONTRACTID, &sConsoleService);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -158,18 +158,18 @@ class LayerManager;
 } // namespace mozilla
 
 class nsIBidiKeyboard;
 
 extern const char kLoadAsData[];
 
 // Stolen from nsReadableUtils, but that's OK, since we can declare the same
 // name multiple times.
-const nsAFlatString& EmptyString();
-const nsAFlatCString& EmptyCString();
+const nsString& EmptyString();
+const nsCString& EmptyCString();
 
 enum EventNameType {
   EventNameType_None = 0x0000,
   EventNameType_HTML = 0x0001,
   EventNameType_XUL = 0x0002,
   EventNameType_SVGGraphic = 0x0004, // svg graphic elements
   EventNameType_SVGSVG = 0x0008, // the svg element
   EventNameType_SMIL = 0x0010, // smil elements
@@ -625,17 +625,17 @@ public:
    */
   static bool IsCustomElementName(nsIAtom* aName);
 
   static nsresult CheckQName(const nsAString& aQualifiedName,
                              bool aNamespaceAware = true,
                              const char16_t** aColon = nullptr);
 
   static nsresult SplitQName(const nsIContent* aNamespaceResolver,
-                             const nsAFlatString& aQName,
+                             const nsString& aQName,
                              int32_t *aNamespace, nsIAtom **aLocalName);
 
   static nsresult GetNodeInfoFromQName(const nsAString& aNamespaceURI,
                                        const nsAString& aQualifiedName,
                                        nsNodeInfoManager* aNodeInfoManager,
                                        uint16_t aNodeType,
                                        mozilla::dom::NodeInfo** aNodeInfo);
 
@@ -917,17 +917,17 @@ public:
     // Get location information from the currently executing script.
     eUSE_CALLING_LOCATION
   };
   static nsresult ReportToConsoleNonLocalized(const nsAString& aErrorText,
                                               uint32_t aErrorFlags,
                                               const nsACString& aCategory,
                                               const nsIDocument* aDocument,
                                               nsIURI* aURI = nullptr,
-                                              const nsAFlatString& aSourceLine
+                                              const nsString& aSourceLine
                                                 = EmptyString(),
                                               uint32_t aLineNumber = 0,
                                               uint32_t aColumnNumber = 0,
                                               MissingErrorLocationMode aLocationMode
                                                 = eUSE_CALLING_LOCATION);
 
   /**
    * Report a non-localized error message to the error console base on the
@@ -948,17 +948,17 @@ public:
    *   @param [aLocationMode] (Optional) Specifies the behavior if
               error location information is omitted.
    */
   static nsresult ReportToConsoleByWindowID(const nsAString& aErrorText,
                                             uint32_t aErrorFlags,
                                             const nsACString& aCategory,
                                             uint64_t aInnerWindowID,
                                             nsIURI* aURI = nullptr,
-                                            const nsAFlatString& aSourceLine
+                                            const nsString& aSourceLine
                                               = EmptyString(),
                                             uint32_t aLineNumber = 0,
                                             uint32_t aColumnNumber = 0,
                                             MissingErrorLocationMode aLocationMode
                                               = eUSE_CALLING_LOCATION);
 
   /**
    * Report a localized error message to the error console.
@@ -999,17 +999,17 @@ public:
   static nsresult ReportToConsole(uint32_t aErrorFlags,
                                   const nsACString& aCategory,
                                   const nsIDocument* aDocument,
                                   PropertiesFile aFile,
                                   const char *aMessageName,
                                   const char16_t **aParams = nullptr,
                                   uint32_t aParamsLength = 0,
                                   nsIURI* aURI = nullptr,
-                                  const nsAFlatString& aSourceLine
+                                  const nsString& aSourceLine
                                     = EmptyString(),
                                   uint32_t aLineNumber = 0,
                                   uint32_t aColumnNumber = 0);
 
   static void LogMessageToConsole(const char* aMsg);
 
   /**
    * Get the localized string named |aKey| in properties file |aFile|.
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -267,17 +267,17 @@ nsFrameLoader::LoadFrame()
   }
 
   if (doc->IsLoadedAsInteractiveData()) {
     // XBL bindings doc shouldn't load sub-documents.
     return NS_OK;
   }
 
   nsCOMPtr<nsIURI> base_uri = mOwnerContent->GetBaseURI();
-  const nsAFlatCString &doc_charset = doc->GetDocumentCharacterSet();
+  const nsCString& doc_charset = doc->GetDocumentCharacterSet();
   const char *charset = doc_charset.IsEmpty() ? nullptr : doc_charset.get();
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), src, charset, base_uri);
 
   // If the URI was malformed, try to recover by loading about:blank.
   if (rv == NS_ERROR_MALFORMED_URI) {
     rv = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_STRING("about:blank"),
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -1123,17 +1123,17 @@ nsImageLoadingContent::StringToURI(const
   NS_PRECONDITION(aDocument, "Must have a document");
   NS_PRECONDITION(aURI, "Null out param");
 
   // (1) Get the base URI
   nsIContent* thisContent = AsContent();
   nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();
 
   // (2) Get the charset
-  const nsAFlatCString &charset = aDocument->GetDocumentCharacterSet();
+  const nsCString& charset = aDocument->GetDocumentCharacterSet();
 
   // (3) Construct the silly thing
   return NS_NewURI(aURI,
                    aSpec,
                    charset.IsEmpty() ? nullptr : charset.get(),
                    baseURL,
                    nsContentUtils::GetIOService());
 }
--- a/dom/cache/TypeUtils.cpp
+++ b/dom/cache/TypeUtils.cpp
@@ -368,17 +368,17 @@ TypeUtils::ToInternalHeaders(const nsTAr
 // provide a URL without the query.  We're not using nsIURL or URL to do this because
 // they require going to the main thread.
 // static
 void
 TypeUtils::ProcessURL(nsACString& aUrl, bool* aSchemeValidOut,
                       nsACString* aUrlWithoutQueryOut,nsACString* aUrlQueryOut,
                       ErrorResult& aRv)
 {
-  const nsAFlatCString& flatURL = PromiseFlatCString(aUrl);
+  const nsCString& flatURL = PromiseFlatCString(aUrl);
   const char* url = flatURL.get();
 
   // off the main thread URL parsing using nsStdURLParser.
   nsCOMPtr<nsIURLParser> urlParser = new nsStdURLParser();
 
   uint32_t pathPos;
   int32_t pathLen;
   uint32_t schemePos;
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -419,17 +419,17 @@ static bool IsContentBR(nsIContent* aCon
                                 eIgnoreCase);
 }
 
 static bool IsMozBR(nsIContent* aContent)
 {
   return aContent->IsHTMLElement(nsGkAtoms::br) && !IsContentBR(aContent);
 }
 
-static void ConvertToNativeNewlines(nsAFlatString& aString)
+static void ConvertToNativeNewlines(nsString& aString)
 {
 #if defined(XP_WIN)
   aString.ReplaceSubstring(NS_LITERAL_STRING("\n"), NS_LITERAL_STRING("\r\n"));
 #endif
 }
 
 static void AppendString(nsAString& aString, nsIContent* aContent)
 {
@@ -659,33 +659,33 @@ ContentEventHandler::ShouldBreakLineBefo
   // If the element is unknown element, we shouldn't insert line breaks before
   // it since unknown elements should be ignored.
   RefPtr<HTMLUnknownElement> unknownHTMLElement = do_QueryObject(aContent);
   return !unknownHTMLElement;
 }
 
 nsresult
 ContentEventHandler::GenerateFlatTextContent(nsIContent* aContent,
-                                             nsAFlatString& aString,
+                                             nsString& aString,
                                              LineBreakType aLineBreakType)
 {
   MOZ_ASSERT(aString.IsEmpty());
 
   RefPtr<nsRange> range = new nsRange(mRootContent);
   ErrorResult rv;
   range->SelectNodeContents(*aContent, rv);
   if (NS_WARN_IF(rv.Failed())) {
     return rv.StealNSResult();
   }
   return GenerateFlatTextContent(range, aString, aLineBreakType);
 }
 
 nsresult
 ContentEventHandler::GenerateFlatTextContent(nsRange* aRange,
-                                             nsAFlatString& aString,
+                                             nsString& aString,
                                              LineBreakType aLineBreakType)
 {
   MOZ_ASSERT(aString.IsEmpty());
 
   if (aRange->Collapsed()) {
     return NS_OK;
   }
 
--- a/dom/events/ContentEventHandler.h
+++ b/dom/events/ContentEventHandler.h
@@ -241,21 +241,21 @@ protected:
                                        uint32_t aXPEndOffset,
                                        LineBreakType aLineBreakType);
   // Get the contents in aContent (meaning all children of aContent) as plain
   // text.  E.g., specifying mRootContent gets whole text in it.
   // Note that the result is not same as .textContent.  The result is
   // optimized for native IMEs.  For example, <br> element and some block
   // elements causes "\n" (or "\r\n"), see also ShouldBreakLineBefore().
   nsresult GenerateFlatTextContent(nsIContent* aContent,
-                                   nsAFlatString& aString,
+                                   nsString& aString,
                                    LineBreakType aLineBreakType);
   // Get the contents of aRange as plain text.
   nsresult GenerateFlatTextContent(nsRange* aRange,
-                                   nsAFlatString& aString,
+                                   nsString& aString,
                                    LineBreakType aLineBreakType);
   // Get offset of start of aRange.  Note that the result includes the length
   // of line breaker caused by the start of aContent because aRange never
   // includes the line breaker caused by its start node.
   nsresult GetStartOffset(nsRange* aRange,
                           uint32_t* aOffset,
                           LineBreakType aLineBreakType);
   // Check if we should insert a line break before aContent.
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -661,22 +661,22 @@ PopupAllowedForEvent(const char *eventNa
 
     if (!sPopupAllowedEvents) {
       return false;
     }
   }
 
   nsDependentCString events(sPopupAllowedEvents);
 
-  nsAFlatCString::const_iterator start, end;
-  nsAFlatCString::const_iterator startiter(events.BeginReading(start));
+  nsCString::const_iterator start, end;
+  nsCString::const_iterator startiter(events.BeginReading(start));
   events.EndReading(end);
 
   while (startiter != end) {
-    nsAFlatCString::const_iterator enditer(end);
+    nsCString::const_iterator enditer(end);
 
     if (!FindInReadable(nsDependentCString(eventName), startiter, enditer))
       return false;
 
     // the match is surrounded by spaces, or at a string boundary
     if ((startiter == start || *--startiter == ' ') &&
         (enditer == end || *enditer == ' ')) {
       return true;
--- a/dom/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/jsurl/nsJSProtocolHandler.cpp
@@ -1137,17 +1137,17 @@ nsJSProtocolHandler::Create(nsISupports 
     if (NS_SUCCEEDED(rv)) {
         rv = ph->QueryInterface(aIID, aResult);
     }
     NS_RELEASE(ph);
     return rv;
 }
 
 nsresult 
-nsJSProtocolHandler::EnsureUTF8Spec(const nsAFlatCString &aSpec, const char *aCharset, 
+nsJSProtocolHandler::EnsureUTF8Spec(const nsCString& aSpec, const char *aCharset, 
                                     nsACString &aUTF8Spec)
 {
   aUTF8Spec.Truncate();
 
   nsresult rv;
   
   if (!mTextToSubURI) {
     mTextToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
--- a/dom/jsurl/nsJSProtocolHandler.h
+++ b/dom/jsurl/nsJSProtocolHandler.h
@@ -49,17 +49,17 @@ public:
     static nsresult
     Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
     nsresult Init();
 
 protected:
     virtual ~nsJSProtocolHandler();
 
-    nsresult EnsureUTF8Spec(const nsAFlatCString &aSpec, const char *aCharset, 
+    nsresult EnsureUTF8Spec(const nsCString& aSpec, const char *aCharset, 
                             nsACString &aUTF8Spec);
 
     nsCOMPtr<nsITextToSubURI>  mTextToSubURI;
 };
 
 
 class nsJSURI : public mozilla::net::nsSimpleURI
 {
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -439,17 +439,17 @@ nsPluginTag::InitSandboxLevel()
     mSandboxLevel = 2;
   }
 #endif
 #endif
 }
 
 #if !defined(XP_WIN) && !defined(XP_MACOSX)
 static void
-ConvertToUTF8(nsAFlatCString& aString)
+ConvertToUTF8(nsCString& aString)
 {
   Unused << UTF_8_ENCODING->DecodeWithoutBOMHandling(aString, aString);
 }
 #endif
 
 nsresult nsPluginTag::EnsureMembersAreUTF8()
 {
 #if defined(XP_WIN) || defined(XP_MACOSX)
--- a/dom/security/test/gtest/TestCSPParser.cpp
+++ b/dom/security/test/gtest/TestCSPParser.cpp
@@ -12,18 +12,18 @@
 #ifndef MOZILLA_INTERNAL_API
 // some of the includes make use of internal string types
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
 class nsACString;
 class nsAString;
-class nsAFlatString;
-class nsAFlatCString;
+class nsString;
+class nsCString;
 class nsAdoptingString;
 class nsAdoptingCString;
 class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nsIContentSecurityPolicy.h"
 #include "nsNetUtil.h"
--- a/dom/svg/nsSVGElement.cpp
+++ b/dom/svg/nsSVGElement.cpp
@@ -2489,17 +2489,17 @@ nsSVGElement::StringListAttributesInfo::
   // caller notifies
 }
 
 nsresult
 nsSVGElement::ReportAttributeParseFailure(nsIDocument* aDocument,
                                           nsIAtom* aAttribute,
                                           const nsAString& aValue)
 {
-  const nsAFlatString& attributeValue = PromiseFlatString(aValue);
+  const nsString& attributeValue = PromiseFlatString(aValue);
   const char16_t *strings[] = { aAttribute->GetUTF16String(),
                                  attributeValue.get() };
   return SVGContentUtils::ReportToConsole(aDocument,
                                           "AttributeParseWarning",
                                           strings, ArrayLength(strings));
 }
 
 void
--- a/dom/xbl/nsXBLBinding.cpp
+++ b/dom/xbl/nsXBLBinding.cpp
@@ -984,17 +984,17 @@ GetProtoBindingFromClassObject(JSObject*
   return static_cast<nsXBLPrototypeBinding*>(::JS_GetReservedSlot(obj, 0).toPrivate());
 }
 
 
 // static
 nsresult
 nsXBLBinding::DoInitJSClass(JSContext *cx,
                             JS::Handle<JSObject*> obj,
-                            const nsAFlatString& aClassName,
+                            const nsString& aClassName,
                             nsXBLPrototypeBinding* aProtoBinding,
                             JS::MutableHandle<JSObject*> aClassObject,
                             bool* aNew)
 {
   MOZ_ASSERT(obj);
 
   // Note that, now that NAC reflectors are created in the XBL scope, the
   // reflector is not necessarily same-compartment with the document. So we'll
--- a/dom/xbl/nsXBLBinding.h
+++ b/dom/xbl/nsXBLBinding.h
@@ -128,17 +128,17 @@ public:
 
   void ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocument);
 
   void WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, void* aData);
 
   const mozilla::ServoStyleSet* GetServoStyleSet() const;
 
   static nsresult DoInitJSClass(JSContext *cx, JS::Handle<JSObject*> obj,
-                                const nsAFlatString& aClassName,
+                                const nsString& aClassName,
                                 nsXBLPrototypeBinding* aProtoBinding,
                                 JS::MutableHandle<JSObject*> aClassObject,
                                 bool* aNew);
 
   bool AllowScripts();
 
   mozilla::dom::XBLChildrenElement* FindInsertionPointFor(nsIContent* aChild);
 
--- a/dom/xslt/base/txExpandedName.cpp
+++ b/dom/xslt/base/txExpandedName.cpp
@@ -9,17 +9,17 @@
 #include "txStringUtils.h"
 #include "txNamespaceMap.h"
 #include "txXMLUtils.h"
 
 nsresult
 txExpandedName::init(const nsAString& aQName, txNamespaceMap* aResolver,
                      bool aUseDefault)
 {
-    const nsAFlatString& qName = PromiseFlatString(aQName);
+    const nsString& qName = PromiseFlatString(aQName);
     const char16_t* colon;
     bool valid = XMLUtils::isValidQName(qName, &colon);
     if (!valid) {
         return NS_ERROR_FAILURE;
     }
 
     if (colon) {
         nsCOMPtr<nsIAtom> prefix = NS_Atomize(Substring(qName.get(), colon));
--- a/dom/xslt/xml/txXMLUtils.cpp
+++ b/dom/xslt/xml/txXMLUtils.cpp
@@ -79,17 +79,17 @@ XMLUtils::splitExpatName(const char16_t 
 
     return *aLocalName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 nsresult
 XMLUtils::splitQName(const nsAString& aName, nsIAtom** aPrefix,
                      nsIAtom** aLocalName)
 {
-    const nsAFlatString& qName = PromiseFlatString(aName);
+    const nsString& qName = PromiseFlatString(aName);
     const char16_t* colon;
     bool valid = XMLUtils::isValidQName(qName, &colon);
     if (!valid) {
         return NS_ERROR_FAILURE;
     }
 
     if (colon) {
         const char16_t *end;
@@ -104,19 +104,19 @@ XMLUtils::splitQName(const nsAString& aN
     }
 
     return NS_OK;
 }
 
 /**
  * Returns true if the given string has only whitespace characters
  */
-bool XMLUtils::isWhitespace(const nsAFlatString& aText)
+bool XMLUtils::isWhitespace(const nsString& aText)
 {
-    nsAFlatString::const_char_iterator start, end;
+    nsString::const_char_iterator start, end;
     aText.BeginReading(start);
     aText.EndReading(end);
     for ( ; start != end; ++start) {
         if (!isWhitespace(*start)) {
             return false;
         }
     }
     return true;
@@ -150,18 +150,17 @@ void XMLUtils::normalizePIValue(nsAStrin
         }
         piValue.Append(ch);
         prevCh = ch;
         ++conversionLoop;
     }
 }
 
 //static
-bool XMLUtils::isValidQName(const nsAFlatString& aQName,
-                            const char16_t** aColon)
+bool XMLUtils::isValidQName(const nsString& aQName, const char16_t** aColon)
 {
   return NS_SUCCEEDED(nsContentUtils::CheckQName(aQName, true, aColon));
 }
 
 //static
 bool XMLUtils::getXMLSpacePreserve(const txXPathNode& aNode)
 {
     nsAutoString value;
--- a/dom/xslt/xml/txXMLUtils.h
+++ b/dom/xslt/xml/txXMLUtils.h
@@ -38,28 +38,27 @@ public:
         return (aChar <= ' ' &&
                 (aChar == ' ' || aChar == '\r' ||
                  aChar == '\n'|| aChar == '\t'));
     }
 
     /**
      * Returns true if the given string has only whitespace characters
      */
-    static bool isWhitespace(const nsAFlatString& aText);
+    static bool isWhitespace(const nsString& aText);
 
     /**
      * Normalizes the value of a XML processingInstruction
     **/
     static void normalizePIValue(nsAString& attValue);
 
     /**
      * Returns true if the given string is a valid XML QName
      */
-    static bool isValidQName(const nsAFlatString& aQName,
-                             const char16_t** aColon);
+    static bool isValidQName(const nsString& aQName, const char16_t** aColon);
 
     /**
      * Returns true if the given character represents an Alpha letter
      */
     static bool isLetter(char16_t aChar)
     {
         return !!MOZ_XMLIsLetter(reinterpret_cast<const char*>(&aChar));
     }   
--- a/dom/xslt/xslt/txBufferingHandler.cpp
+++ b/dom/xslt/xslt/txBufferingHandler.cpp
@@ -352,17 +352,17 @@ txResultBuffer::addTransaction(txOutputT
         return NS_ERROR_OUT_OF_MEMORY;
     }
     return NS_OK;
 }
 
 static nsresult
 flushTransaction(txOutputTransaction* aTransaction,
                  txAXMLEventHandler* aHandler,
-                 nsAFlatString::const_char_iterator& aIter)
+                 nsString::const_char_iterator& aIter)
 {
     switch (aTransaction->mType) {
         case txOutputTransaction::eAttributeAtomTransaction:
         {
             txAttributeAtomTransaction* transaction =
                 static_cast<txAttributeAtomTransaction*>(aTransaction);
             return aHandler->attribute(transaction->mPrefix,
                                        transaction->mLocalName,
@@ -379,18 +379,18 @@ flushTransaction(txOutputTransaction* aT
                                        attrTransaction->mNsID,
                                        attrTransaction->mValue);
         }
         case txOutputTransaction::eCharacterTransaction:
         case txOutputTransaction::eCharacterNoOETransaction:
         {
             txCharacterTransaction* charTransaction =
                 static_cast<txCharacterTransaction*>(aTransaction);
-            nsAFlatString::const_char_iterator start = aIter;
-            nsAFlatString::const_char_iterator end =
+            nsString::const_char_iterator start = aIter;
+            nsString::const_char_iterator end =
                 start + charTransaction->mLength;
             aIter = end;
             return aHandler->characters(Substring(start, end),
                                         aTransaction->mType ==
                                         txOutputTransaction::eCharacterNoOETransaction);
         }
         case txOutputTransaction::eCommentTransaction:
         {
@@ -437,17 +437,17 @@ flushTransaction(txOutputTransaction* aT
     }
 
     return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 txResultBuffer::flushToHandler(txAXMLEventHandler* aHandler)
 {
-    nsAFlatString::const_char_iterator iter;
+    nsString::const_char_iterator iter;
     mStringValue.BeginReading(iter);
 
     for (uint32_t i = 0, len = mTransactions.Length(); i < len; ++i) {
         nsresult rv = flushTransaction(mTransactions[i], aHandler, iter);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     return NS_OK;
--- a/dom/xslt/xslt/txInstructions.cpp
+++ b/dom/xslt/xslt/txInstructions.cpp
@@ -322,17 +322,17 @@ txCopy::execute(txExecutionState& aEs)
 {
     nsresult rv = NS_OK;
     const txXPathNode& node = aEs.getEvalContext()->getContextNode();
 
     switch (txXPathNodeUtils::getNodeType(node)) {
         case txXPathNodeType::DOCUMENT_NODE:
         case txXPathNodeType::DOCUMENT_FRAGMENT_NODE:
         {
-            const nsAFlatString& empty = EmptyString();
+            const nsString& empty = EmptyString();
 
             // "close" current element to ensure that no attributes are added
             rv = aEs.mResultHandler->characters(empty, false);
             NS_ENSURE_SUCCESS(rv, rv);
 
             rv = aEs.pushBool(false);
             NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/xslt/xslt/txPatternParser.cpp
+++ b/dom/xslt/xslt/txPatternParser.cpp
@@ -8,17 +8,17 @@
 #include "nsGkAtoms.h"
 #include "nsError.h"
 #include "txStringUtils.h"
 #include "txXSLTPatterns.h"
 #include "txStylesheetCompiler.h"
 #include "txPatternOptimizer.h"
 
 
-nsresult txPatternParser::createPattern(const nsAFlatString& aPattern,
+nsresult txPatternParser::createPattern(const nsString& aPattern,
                                         txIParseContext* aContext,
                                         txPattern** aResult)
 {
     txExprLexer lexer;
     nsresult rv = lexer.parse(aPattern);
     if (NS_FAILED(rv)) {
         // XXX error report parsing error
         return rv;
--- a/dom/xslt/xslt/txPatternParser.h
+++ b/dom/xslt/xslt/txPatternParser.h
@@ -9,17 +9,17 @@
 #include "txXSLTPatterns.h"
 #include "txExprParser.h"
 
 class txStylesheetCompilerState;
 
 class txPatternParser : public txExprParser
 {
 public:
-    static nsresult createPattern(const nsAFlatString& aPattern,
+    static nsresult createPattern(const nsString& aPattern,
                                   txIParseContext* aContext,
                                   txPattern** aResult);
 protected:
     static nsresult createUnionPattern(txExprLexer& aLexer,
                                        txIParseContext* aContext,
                                        txPattern*& aPattern);
     static nsresult createLocPathPattern(txExprLexer& aLexer,
                                          txIParseContext* aContext,
--- a/dom/xslt/xslt/txXPathResultComparator.cpp
+++ b/dom/xslt/xslt/txXPathResultComparator.cpp
@@ -12,29 +12,29 @@
 #include "nsIServiceManager.h"
 #include "prmem.h"
 
 #define kAscending (1<<0)
 #define kUpperFirst (1<<1)
 
 txResultStringComparator::txResultStringComparator(bool aAscending,
                                                    bool aUpperFirst,
-                                                   const nsAFlatString& aLanguage)
+                                                   const nsString& aLanguage)
 {
     mSorting = 0;
     if (aAscending)
         mSorting |= kAscending;
     if (aUpperFirst)
         mSorting |= kUpperFirst;
     nsresult rv = init(aLanguage);
     if (NS_FAILED(rv))
         NS_ERROR("Failed to initialize txResultStringComparator");
 }
 
-nsresult txResultStringComparator::init(const nsAFlatString& aLanguage)
+nsresult txResultStringComparator::init(const nsString& aLanguage)
 {
     nsresult rv;
 
     nsCOMPtr<nsICollationFactory> colFactory =
                     do_CreateInstance(NS_COLLATIONFACTORY_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (aLanguage.IsEmpty()) {
--- a/dom/xslt/xslt/txXPathResultComparator.h
+++ b/dom/xslt/xslt/txXPathResultComparator.h
@@ -40,24 +40,24 @@ public:
 
 /*
  * Compare results as stings (data-type="text")
  */
 class txResultStringComparator : public txXPathResultComparator
 {
 public:
     txResultStringComparator(bool aAscending, bool aUpperFirst,
-                             const nsAFlatString& aLanguage);
+                             const nsString& aLanguage);
 
     int compareValues(txObject* aVal1, txObject* aVal2) override;
     nsresult createSortableValue(Expr *aExpr, txIEvalContext *aContext,
                                  txObject *&aResult) override;
 private:
     nsCOMPtr<nsICollation> mCollation;
-    nsresult init(const nsAFlatString& aLanguage);
+    nsresult init(const nsString& aLanguage);
     nsresult createRawSortKey(const int32_t aStrength,
                               const nsString& aString,
                               uint8_t** aKey,
                               uint32_t* aLength);
     int mSorting;
 
     class StringValue : public txObject
     {
--- a/dom/xslt/xslt/txXSLTNumber.h
+++ b/dom/xslt/xslt/txXSLTNumber.h
@@ -59,16 +59,16 @@ private:
 class txFormattedCounter {
 public:
     virtual ~txFormattedCounter()
     {
     }
     
     virtual void appendNumber(int32_t aNumber, nsAString& aDest) = 0;
 
-    static nsresult getCounterFor(const nsAFlatString& aToken, int aGroupSize,
+    static nsresult getCounterFor(const nsString& aToken, int aGroupSize,
                                   const nsAString& aGroupSeparator,
                                   txFormattedCounter*& aCounter);
     
     nsString mSeparator;
 };
 
 #endif //TRANSFRMX_TXXSLTNUMBER_H
--- a/dom/xslt/xslt/txXSLTNumberCounters.cpp
+++ b/dom/xslt/xslt/txXSLTNumberCounters.cpp
@@ -45,17 +45,17 @@ public:
     void appendNumber(int32_t aNumber, nsAString& aDest);
 
 private:
     int32_t mTableOffset;
 };
 
 
 nsresult
-txFormattedCounter::getCounterFor(const nsAFlatString& aToken,
+txFormattedCounter::getCounterFor(const nsString& aToken,
                                   int32_t aGroupSize,
                                   const nsAString& aGroupSeparator,
                                   txFormattedCounter*& aCounter)
 {
     int32_t length = aToken.Length();
     NS_ASSERTION(length, "getting counter for empty token");
     aCounter = 0;
     
--- a/editor/composer/nsComposerCommands.cpp
+++ b/editor/composer/nsComposerCommands.cpp
@@ -20,17 +20,17 @@
 #include "nsID.h"
 #include "nsIDOMElement.h"              // for nsIDOMElement
 #include "nsIEditor.h"                  // for nsIEditor
 #include "nsIHTMLAbsPosEditor.h"        // for nsIHTMLAbsPosEditor
 #include "nsIHTMLEditor.h"              // for nsIHTMLEditor, etc
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 #include "nsReadableUtils.h"            // for EmptyString
 #include "nsString.h"                   // for nsAutoString, nsString, etc
-#include "nsStringFwd.h"                // for nsAFlatString
+#include "nsStringFwd.h"                // for nsString
 
 class nsISupports;
 
 //prototype
 nsresult GetListState(nsIHTMLEditor* aEditor, bool* aMixed,
                       nsAString& aLocalName);
 nsresult RemoveOneProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
 nsresult RemoveTextProperty(nsIHTMLEditor* aEditor, const nsAString& aProp);
--- a/editor/composer/nsEditingSession.cpp
+++ b/editor/composer/nsEditingSession.cpp
@@ -43,17 +43,17 @@
 #include "nsIWeakReference.h"           // for nsISupportsWeakReference, etc
 #include "nsIWebNavigation.h"           // for nsIWebNavigation
 #include "nsIWebProgress.h"             // for nsIWebProgress, etc
 #include "nsLiteralString.h"            // for NS_LITERAL_STRING
 #include "nsPICommandUpdater.h"         // for nsPICommandUpdater
 #include "nsPIDOMWindow.h"              // for nsPIDOMWindow
 #include "nsPresContext.h"              // for nsPresContext
 #include "nsReadableUtils.h"            // for AppendUTF16toUTF8
-#include "nsStringFwd.h"                // for nsAFlatString
+#include "nsStringFwd.h"                // for nsString
 #include "mozilla/dom/Selection.h"      // for AutoHideSelectionChanges
 #include "nsFrameSelection.h"           // for nsFrameSelection
 
 class nsISupports;
 class nsIURI;
 
 /*---------------------------------------------------------------------------
 
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -90,17 +90,17 @@
 #include "nsITransactionManager.h"
 #include "nsIWeakReference.h"           // for nsISupportsWeakReference
 #include "nsIWidget.h"                  // for nsIWidget, IMEState, etc.
 #include "nsPIDOMWindow.h"              // for nsPIDOMWindow
 #include "nsPresContext.h"              // for nsPresContext
 #include "nsRange.h"                    // for nsRange
 #include "nsReadableUtils.h"            // for EmptyString, ToNewCString
 #include "nsString.h"                   // for nsAutoString, nsString, etc.
-#include "nsStringFwd.h"                // for nsAFlatString
+#include "nsStringFwd.h"                // for nsString
 #include "nsStyleConsts.h"              // for NS_STYLE_DIRECTION_RTL, etc.
 #include "nsStyleContext.h"             // for nsStyleContext
 #include "nsStyleStruct.h"              // for nsStyleDisplay, nsStyleText, etc.
 #include "nsStyleStructFwd.h"           // for nsIFrame::StyleUIReset, etc.
 #include "nsTextNode.h"                 // for nsTextNode
 #include "nsThreadUtils.h"              // for nsRunnable
 #include "nsTransactionManager.h"       // for nsTransactionManager
 #include "prtime.h"                     // for PR_Now
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -155,17 +155,17 @@ HTMLEditor::LoadHTML(const nsAString& aI
   }
 
   return rules->DidDoAction(selection, &ruleInfo, rv);
 }
 
 NS_IMETHODIMP
 HTMLEditor::InsertHTML(const nsAString& aInString)
 {
-  const nsAFlatString& empty = EmptyString();
+  const nsString& empty = EmptyString();
 
   return InsertHTMLWithContext(aInString, empty, empty, empty,
                                nullptr,  nullptr, 0, true);
 }
 
 nsresult
 HTMLEditor::InsertHTMLWithContext(const nsAString& aInputString,
                                   const nsAString& aContextStr,
@@ -946,18 +946,18 @@ HTMLEditor::ParseCFHTML(nsCString& aCfht
 
   // remove the StartFragment/EndFragment comments from the fragment, if present
   RemoveFragComments(fragmentUTF8);
 
   // remove the StartFragment/EndFragment comments from the context, if present
   RemoveFragComments(contextUTF8);
 
   // convert both strings to usc2
-  const nsAFlatString& fragUcs2Str = NS_ConvertUTF8toUTF16(fragmentUTF8);
-  const nsAFlatString& cntxtUcs2Str = NS_ConvertUTF8toUTF16(contextUTF8);
+  const nsString& fragUcs2Str = NS_ConvertUTF8toUTF16(fragmentUTF8);
+  const nsString& cntxtUcs2Str = NS_ConvertUTF8toUTF16(contextUTF8);
 
   // translate platform linebreaks for fragment
   int32_t oldLengthInChars = fragUcs2Str.Length() + 1;  // +1 to include null terminator
   int32_t newLengthInChars = 0;
   *aStuffToPaste = nsLinebreakConverter::ConvertUnicharLineBreaks(fragUcs2Str.get(),
                                                            nsLinebreakConverter::eLinebreakAny,
                                                            nsLinebreakConverter::eLinebreakContent,
                                                            oldLengthInChars, &newLengthInChars);
@@ -1506,17 +1506,17 @@ HTMLEditor::PasteNoFormatting(int32_t aS
   // Get the nsITransferable interface for getting the data from the clipboard.
   // use TextEditor::PrepareTransferable() to force unicode plaintext data.
   nsCOMPtr<nsITransferable> trans;
   rv = TextEditor::PrepareTransferable(getter_AddRefs(trans));
   if (NS_SUCCEEDED(rv) && trans) {
     // Get the Data from the clipboard
     if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) &&
         IsModifiable()) {
-      const nsAFlatString& empty = EmptyString();
+      const nsString& empty = EmptyString();
       rv = InsertFromTransferable(trans, nullptr, empty, empty, false, nullptr, 0,
                                   true);
     }
   }
 
   return rv;
 }
 
--- a/editor/libeditor/TextEditorTest.cpp
+++ b/editor/libeditor/TextEditorTest.cpp
@@ -164,17 +164,17 @@ nsresult TextEditorTest::TestTextPropert
 
   nsCOMPtr<nsIHTMLEditor> htmlEditor (do_QueryInterface(mTextEditor));
   NS_ENSURE_TRUE(htmlEditor, NS_ERROR_FAILURE);
 
   bool any = false;
   bool all = false;
   bool first=false;
 
-  const nsAFlatString& empty = EmptyString();
+  const nsString& empty = EmptyString();
 
   rv = htmlEditor->GetInlineProperty(nsGkAtoms::b, empty, empty, &first,
                                      &any, &all);
   TEST_RESULT(rv);
   NS_ASSERTION(false==first, "first should be false");
   NS_ASSERTION(false==any, "any should be false");
   NS_ASSERTION(false==all, "all should be false");
   rv = htmlEditor->SetInlineProperty(nsGkAtoms::b, empty, empty);
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -319,34 +319,34 @@ public:
     return permManager->RemovePermissionsWithAttributes(nsDependentString(aData));
   }
 };
 
 NS_IMPL_ISUPPORTS(ClearOriginDataObserver, nsIObserver)
 
 class MOZ_STACK_CLASS UpgradeHostToOriginHelper {
 public:
-  virtual nsresult Insert(const nsACString& aOrigin, const nsAFlatCString& aType,
+  virtual nsresult Insert(const nsACString& aOrigin, const nsCString& aType,
                           uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
                           int64_t aModificationTime) = 0;
 };
 
 class MOZ_STACK_CLASS UpgradeHostToOriginDBMigration final : public UpgradeHostToOriginHelper {
 public:
   UpgradeHostToOriginDBMigration(mozIStorageConnection* aDBConn, int64_t* aID) : mDBConn(aDBConn)
                                                                                , mID(aID)
   {
     mDBConn->CreateStatement(NS_LITERAL_CSTRING(
       "INSERT INTO moz_hosts_new "
       "(id, origin, type, permission, expireType, expireTime, modificationTime) "
       "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)"), getter_AddRefs(mStmt));
   }
 
   nsresult
-  Insert(const nsACString& aOrigin, const nsAFlatCString& aType,
+  Insert(const nsACString& aOrigin, const nsCString& aType,
          uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
          int64_t aModificationTime) final
   {
     nsresult rv = mStmt->BindInt64ByIndex(0, *mID);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = mStmt->BindUTF8StringByIndex(1, aOrigin);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -386,17 +386,17 @@ public:
   UpgradeHostToOriginHostfileImport(nsPermissionManager* aPm,
                                     nsPermissionManager::DBOperationType aOperation,
                                     int64_t aID) : mPm(aPm)
                                                  , mOperation(aOperation)
                                                  , mID(aID)
   {}
 
   nsresult
-  Insert(const nsACString& aOrigin, const nsAFlatCString& aType,
+  Insert(const nsACString& aOrigin, const nsCString& aType,
          uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
          int64_t aModificationTime) final
   {
     nsCOMPtr<nsIPrincipal> principal;
     nsresult rv = GetPrincipalFromOrigin(aOrigin, getter_AddRefs(principal));
     NS_ENSURE_SUCCESS(rv, rv);
 
     return mPm->AddInternal(principal, aType, aPermission, mID,
@@ -421,17 +421,17 @@ public:
       "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)"), getter_AddRefs(mStmt));
 
     mDBConn->CreateStatement(NS_LITERAL_CSTRING(
       "SELECT id FROM moz_perms WHERE origin = ?1 AND type = ?2"),
       getter_AddRefs(mLookupStmt));
   }
 
   nsresult
-  Insert(const nsACString& aOrigin, const nsAFlatCString& aType,
+  Insert(const nsACString& aOrigin, const nsCString& aType,
          uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
          int64_t aModificationTime) final
   {
     // Every time the migration code wants to insert an origin into
     // the database we need to check to see if someone has already
     // created a permissions entry for that permission. If they have,
     // we don't want to insert a duplicate row.
     //
@@ -493,17 +493,17 @@ private:
   nsCOMPtr<mozIStorageStatement> mStmt;
   nsCOMPtr<mozIStorageStatement> mLookupStmt;
   nsCOMPtr<mozIStorageConnection> mDBConn;
   int64_t* mID;
 };
 
 
 nsresult
-UpgradeHostToOriginAndInsert(const nsACString& aHost, const nsAFlatCString& aType,
+UpgradeHostToOriginAndInsert(const nsACString& aHost, const nsCString& aType,
                              uint32_t aPermission, uint32_t aExpireType, int64_t aExpireTime,
                              int64_t aModificationTime, uint32_t aAppId, bool aIsInIsolatedMozBrowserElement,
                              UpgradeHostToOriginHelper* aHelper)
 {
   if (aHost.EqualsLiteral("<file>")) {
     // We no longer support the magic host <file>
     NS_WARNING("The magic host <file> is no longer supported. "
                "It is being removed from the permissions database.");
@@ -1675,17 +1675,17 @@ nsPermissionManager::AddFromPrincipal(ns
   int64_t modificationTime = 0;
 
   return AddInternal(aPrincipal, nsDependentCString(aType), aPermission, 0,
                      aExpireType, aExpireTime, modificationTime, eNotify, eWriteToDB);
 }
 
 nsresult
 nsPermissionManager::AddInternal(nsIPrincipal* aPrincipal,
-                                 const nsAFlatCString &aType,
+                                 const nsCString& aType,
                                  uint32_t              aPermission,
                                  int64_t               aID,
                                  uint32_t              aExpireType,
                                  int64_t               aExpireTime,
                                  int64_t               aModificationTime,
                                  NotifyOperationType   aNotifyOperation,
                                  DBOperationType       aDBOperation,
                                  const bool            aIgnoreSessionPermissions)
--- a/extensions/cookie/nsPermissionManager.h
+++ b/extensions/cookie/nsPermissionManager.h
@@ -189,17 +189,17 @@ public:
   };
 
   // A special value for a permission ID that indicates the ID was loaded as
   // a default value.  These will never be written to the database, but may
   // be overridden with an explicit permission (including UNKNOWN_ACTION)
   static const int64_t cIDPermissionIsDefault = -1;
 
   nsresult AddInternal(nsIPrincipal* aPrincipal,
-                       const nsAFlatCString &aType,
+                       const nsCString& aType,
                        uint32_t aPermission,
                        int64_t aID,
                        uint32_t aExpireType,
                        int64_t  aExpireTime,
                        int64_t aModificationTime,
                        NotifyOperationType aNotifyOperation,
                        DBOperationType aDBOperation,
                        const bool aIgnoreSessionPermissions = false);
--- a/intl/uconv/nsTextToSubURI.cpp
+++ b/intl/uconv/nsTextToSubURI.cpp
@@ -97,18 +97,18 @@ static bool statefulCharset(const char *
       !nsCRT::strcasecmp(charset, "UTF-7") ||
       !nsCRT::strcasecmp(charset, "HZ-GB-2312"))
     return true;
 
   return false;
 }
 
 nsresult
-nsTextToSubURI::convertURItoUnicode(const nsAFlatCString& aCharset,
-                                    const nsAFlatCString& aURI,
+nsTextToSubURI::convertURItoUnicode(const nsCString& aCharset,
+                                    const nsCString& aURI,
                                     nsAString& aOut)
 {
   // check for 7bit encoding the data may not be ASCII after we decode
   bool isStatefulCharset = statefulCharset(aCharset.get());
 
   if (!isStatefulCharset) {
     if (IsASCII(aURI)) {
       CopyASCIItoUTF16(aURI, aOut);
--- a/intl/uconv/nsTextToSubURI.h
+++ b/intl/uconv/nsTextToSubURI.h
@@ -14,18 +14,18 @@ class nsTextToSubURI: public nsITextToSu
 {
   NS_DECL_ISUPPORTS
   NS_DECL_NSITEXTTOSUBURI
 
 private:
   virtual ~nsTextToSubURI();
 
   // We assume that the URI is encoded as UTF-8.
-  nsresult convertURItoUnicode(const nsAFlatCString &aCharset,
-                               const nsAFlatCString &aURI, 
+  nsresult convertURItoUnicode(const nsCString& aCharset,
+                               const nsCString& aURI,
                                nsAString &_retval);
 
   // Characters from the pref "network.IDN.blacklist_chars", or a built-in
   // fallback if reading the pref fails.
   nsTArray<char16_t> mUnsafeChars;
 };
 
 #endif // nsTextToSubURI_h__
--- a/layout/inspector/inCSSValueSearch.cpp
+++ b/layout/inspector/inCSSValueSearch.cpp
@@ -346,17 +346,17 @@ inCSSValueSearch::SearchStyleRule(nsIDOM
     // implemented.
     decl->GetPropertyValue(property, value);
     SearchStyleValue(value, aBaseURL);
   }
   return NS_OK;
 }
 
 nsresult
-inCSSValueSearch::SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURL)
+inCSSValueSearch::SearchStyleValue(const nsString& aValue, nsIURI* aBaseURL)
 {
   if (StringBeginsWith(aValue, NS_LITERAL_STRING("url(")) &&
       StringEndsWith(aValue, NS_LITERAL_STRING(")"))) {
     const nsAString& url = Substring(aValue, 4, aValue.Length() - 5);
     // XXXldb Need to do more with |mReturnRelativeURLs|, perhaps?
     nsCOMPtr<nsIURI> uri;
     nsresult rv = NS_NewURI(getter_AddRefs(uri), url, nullptr, aBaseURL);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/layout/inspector/inCSSValueSearch.h
+++ b/layout/inspector/inCSSValueSearch.h
@@ -44,17 +44,17 @@ protected:
   bool mReturnRelativeURLs;
   bool mNormalizeChromeURLs;
 
   nsresult InitSearch();
   nsresult KillSearch(int16_t aResult);
   nsresult SearchStyleSheet(nsIDOMCSSStyleSheet* aStyleSheet, nsIURI* aBaseURI);
   nsresult SearchRuleList(nsIDOMCSSRuleList* aRuleList, nsIURI* aBaseURI);
   nsresult SearchStyleRule(nsIDOMCSSStyleRule* aStyleRule, nsIURI* aBaseURI);
-  nsresult SearchStyleValue(const nsAFlatString& aValue, nsIURI* aBaseURI);
+  nsresult SearchStyleValue(const nsString& aValue, nsIURI* aBaseURI);
   nsresult EqualizeURL(nsAutoString* aURL);
 };
 
 // {4D977F60-FBE7-4583-8CB7-F5ED882293EF}
 #define IN_CSSVALUESEARCH_CID \
 { 0x4d977f60, 0xfbe7, 0x4583, { 0x8c, 0xb7, 0xf5, 0xed, 0x88, 0x22, 0x93, 0xef } }
 
 #endif // __inCSSValueSearch_h__
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -612,17 +612,17 @@ public:
                                      nsSubstring& aResult,
                                      bool& aIsRTL) override;
 };
 
 /* virtual */ void
 BuiltinCounterStyle::GetStyleName(nsSubstring& aResult)
 {
   MOZ_ASSERT(mStyle != NS_STYLE_LIST_STYLE_CUSTOM);
-  const nsAFlatCString& str =
+  const nsCString& str =
     nsCSSProps::ValueToKeyword(mStyle, nsCSSProps::kListStyleKTable);
   MOZ_ASSERT(!str.IsEmpty());
   aResult.Assign(NS_ConvertUTF8toUTF16(str));
 }
 
 /* virtual */ void
 BuiltinCounterStyle::GetPrefix(nsSubstring& aResult)
 {
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -1210,17 +1210,17 @@ FontFaceSet::LogMessage(gfxUserFontEntry
   }
 
   nsAutoCString familyName;
   nsAutoCString fontURI;
   aUserFontEntry->GetFamilyNameAndURIForLogging(familyName, fontURI);
 
   char weightKeywordBuf[8]; // plenty to sprintf() a uint16_t
   const char* weightKeyword;
-  const nsAFlatCString& weightKeywordString =
+  const nsCString& weightKeywordString =
     nsCSSProps::ValueToKeyword(aUserFontEntry->Weight(),
                                nsCSSProps::kFontWeightKTable);
   if (weightKeywordString.Length() > 0) {
     weightKeyword = weightKeywordString.get();
   } else {
     SprintfLiteral(weightKeywordBuf, "%u", aUserFontEntry->Weight());
     weightKeyword = weightKeywordBuf;
   }
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -923,19 +923,19 @@ SheetLoadData::OnStreamComplete(nsIUnich
     if (sameOrigin && mLoader->mCompatMode == eCompatibility_NavQuirks) {
       errorMessage = "MimeNotCssWarn";
       errorFlag = nsIScriptError::warningFlag;
     } else {
       errorMessage = "MimeNotCss";
       errorFlag = nsIScriptError::errorFlag;
     }
 
-    const nsAFlatString& specUTF16 =
+    const nsString& specUTF16 =
       NS_ConvertUTF8toUTF16(channelURI->GetSpecOrDefault());
-    const nsAFlatString& ctypeUTF16 = NS_ConvertASCIItoUTF16(contentType);
+    const nsString& ctypeUTF16 = NS_ConvertASCIItoUTF16(contentType);
     const char16_t *strings[] = { specUTF16.get(), ctypeUTF16.get() };
 
     nsCOMPtr<nsIURI> referrer = GetReferrerURI();
     nsContentUtils::ReportToConsole(errorFlag,
                                     NS_LITERAL_CSTRING("CSS Loader"),
                                     mLoader->mDocument,
                                     nsContentUtils::eCSS_PROPERTIES,
                                     errorMessage,
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2354,17 +2354,17 @@ Gecko_LookupCSSKeyword(const uint8_t* aS
   return nsCSSKeywords::LookupKeyword(keyword);
 }
 
 const char*
 Gecko_CSSKeywordString(nsCSSKeyword aKeyword, uint32_t* aLength)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aLength);
-  const nsAFlatCString& value = nsCSSKeywords::GetStringValue(aKeyword);
+  const nsCString& value = nsCSSKeywords::GetStringValue(aKeyword);
   *aLength = value.Length();
   return value.get();
 }
 
 nsCSSFontFaceRule*
 Gecko_CSSFontFaceRule_Create(uint32_t aLine, uint32_t aColumn)
 {
   RefPtr<nsCSSFontFaceRule> rule = new nsCSSFontFaceRule(aLine, aColumn);
--- a/layout/style/nsCSSKeywords.cpp
+++ b/layout/style/nsCSSKeywords.cpp
@@ -67,17 +67,17 @@ nsCSSKeywords::LookupKeyword(const nsASt
 {
   NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
   if (gKeywordTable) {
     return nsCSSKeyword(gKeywordTable->Lookup(aKeyword));
   }  
   return eCSSKeyword_UNKNOWN;
 }
 
-const nsAFlatCString& 
+const nsCString&
 nsCSSKeywords::GetStringValue(nsCSSKeyword aKeyword)
 {
   NS_ASSERTION(gKeywordTable, "no lookup table, needs addref");
   NS_ASSERTION(0 <= aKeyword && aKeyword < eCSSKeyword_COUNT, "out of range");
   if (gKeywordTable) {
     return gKeywordTable->GetStringValue(int32_t(aKeyword));
   } else {
     static nsDependentCString kNullStr("");
--- a/layout/style/nsCSSKeywords.h
+++ b/layout/style/nsCSSKeywords.h
@@ -31,12 +31,12 @@ public:
   static void AddRefTable(void);
   static void ReleaseTable(void);
 
   // Given a keyword string, return the enum value
   static nsCSSKeyword LookupKeyword(const nsACString& aKeyword);
   static nsCSSKeyword LookupKeyword(const nsAString& aKeyword);
 
   // Given a keyword enum, get the string value
-  static const nsAFlatCString& GetStringValue(nsCSSKeyword aKeyword);
+  static const nsCString& GetStringValue(nsCSSKeyword aKeyword);
 };
 
 #endif /* nsCSSKeywords_h___ */
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -671,41 +671,41 @@ bool
 nsCSSProps::IsPredefinedCounterStyle(const nsACString& aStyle)
 {
   MOZ_ASSERT(gPredefinedCounterStyleTable,
              "no lookup table, needs addref");
   return gPredefinedCounterStyleTable->Lookup(aStyle) !=
     nsStaticCaseInsensitiveNameTable::NOT_FOUND;
 }
 
-const nsAFlatCString&
+const nsCString&
 nsCSSProps::GetStringValue(nsCSSPropertyID aProperty)
 {
   MOZ_ASSERT(gPropertyTable, "no lookup table, needs addref");
   if (gPropertyTable) {
     return gPropertyTable->GetStringValue(int32_t(aProperty));
   } else {
     static nsDependentCString sNullStr("");
     return sNullStr;
   }
 }
 
-const nsAFlatCString&
+const nsCString&
 nsCSSProps::GetStringValue(nsCSSFontDesc aFontDescID)
 {
   MOZ_ASSERT(gFontDescTable, "no lookup table, needs addref");
   if (gFontDescTable) {
     return gFontDescTable->GetStringValue(int32_t(aFontDescID));
   } else {
     static nsDependentCString sNullStr("");
     return sNullStr;
   }
 }
 
-const nsAFlatCString&
+const nsCString&
 nsCSSProps::GetStringValue(nsCSSCounterDesc aCounterDesc)
 {
   MOZ_ASSERT(gCounterDescTable, "no lookup table, needs addref");
   if (gCounterDescTable) {
     return gCounterDescTable->GetStringValue(int32_t(aCounterDesc));
   } else {
     static nsDependentCString sNullStr("");
     return sNullStr;
@@ -2494,17 +2494,17 @@ nsCSSProps::ValueToKeywordEnum(int32_t a
     }
     if (aValue == entry.mValue) {
       return entry.mKeyword;
     }
   }
   return eCSSKeyword_UNKNOWN;
 }
 
-const nsAFlatCString&
+const nsCString& 
 nsCSSProps::ValueToKeyword(int32_t aValue, const KTableEntry aTable[])
 {
   nsCSSKeyword keyword = ValueToKeywordEnum(aValue, aTable);
   if (keyword == eCSSKeyword_UNKNOWN) {
     static nsDependentCString sNullStr("");
     return sNullStr;
   } else {
     return nsCSSKeywords::GetStringValue(keyword);
@@ -2517,17 +2517,17 @@ nsCSSProps::kKeywordTableTable[eCSSPrope
                    kwtable_, stylestruct_, stylestructoffset_, animtype_) \
     kwtable_,
   #define CSS_PROP_LIST_INCLUDE_LOGICAL
   #include "nsCSSPropList.h"
   #undef CSS_PROP_LIST_INCLUDE_LOGICAL
   #undef CSS_PROP
 };
 
-const nsAFlatCString&
+const nsCString&
 nsCSSProps::LookupPropertyValue(nsCSSPropertyID aProp, int32_t aValue)
 {
   MOZ_ASSERT(aProp >= 0 && aProp < eCSSProperty_COUNT,
              "property out of range");
 #ifdef DEBUG
   typedef decltype(KTableEntry::mValue) table_value_type;
   NS_ASSERTION(table_value_type(aValue) == aValue, "Value out of range");
 #endif
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -403,24 +403,24 @@ public:
   static nsCSSCounterDesc LookupCounterDesc(const nsAString& aProperty);
   static nsCSSCounterDesc LookupCounterDesc(const nsACString& aProperty);
 
   // For predefined counter styles which need to be lower-cased during parse
   static bool IsPredefinedCounterStyle(const nsAString& aStyle);
   static bool IsPredefinedCounterStyle(const nsACString& aStyle);
 
   // Given a property enum, get the string value
-  static const nsAFlatCString& GetStringValue(nsCSSPropertyID aProperty);
-  static const nsAFlatCString& GetStringValue(nsCSSFontDesc aFontDesc);
-  static const nsAFlatCString& GetStringValue(nsCSSCounterDesc aCounterDesc);
+  static const nsCString& GetStringValue(nsCSSPropertyID aProperty);
+  static const nsCString& GetStringValue(nsCSSFontDesc aFontDesc);
+  static const nsCString& GetStringValue(nsCSSCounterDesc aCounterDesc);
 
   // Given a CSS Property and a Property Enum Value
   // Return back a const nsString& representation of the
   // value. Return back nullstr if no value is found
-  static const nsAFlatCString& LookupPropertyValue(nsCSSPropertyID aProperty, int32_t aValue);
+  static const nsCString& LookupPropertyValue(nsCSSPropertyID aProperty, int32_t aValue);
 
   // Get a color name for a predefined color value like buttonhighlight or activeborder
   // Sets the aStr param to the name of the propertyID
   static bool GetColorName(int32_t aPropID, nsCString &aStr);
 
   // Returns the index of |aKeyword| in |aTable|, if it exists there;
   // otherwise, returns -1.
   // NOTE: Generally, clients should call FindKeyword() instead of this method.
@@ -440,22 +440,21 @@ public:
   static nsCSSKeyword ValueToKeywordEnum(T aValue,
                                          const KTableEntry aTable[])
   {
     static_assert(mozilla::EnumTypeFitsWithin<T, int16_t>::value,
                   "aValue must be an enum that fits within KTableEntry::mValue");
     return ValueToKeywordEnum(static_cast<int16_t>(aValue), aTable);
   }
   // Ditto but as a string, return "" when not found.
-  static const nsAFlatCString& ValueToKeyword(int32_t aValue,
-                                              const KTableEntry aTable[]);
+  static const nsCString& ValueToKeyword(int32_t aValue,
+                                         const KTableEntry aTable[]);
   template<typename T,
            typename = typename std::enable_if<std::is_enum<T>::value>::type>
-  static const nsAFlatCString& ValueToKeyword(T aValue,
-                                              const KTableEntry aTable[])
+  static const nsCString& ValueToKeyword(T aValue, const KTableEntry aTable[])
   {
     static_assert(mozilla::EnumTypeFitsWithin<T, int16_t>::value,
                   "aValue must be an enum that fits within KTableEntry::mValue");
     return ValueToKeyword(static_cast<int16_t>(aValue), aTable);
   }
 
   static const nsStyleStructID kSIDTable[eCSSProperty_COUNT_no_shorthands];
   static const KTableEntry* const kKeywordTableTable[eCSSProperty_COUNT_no_shorthands];
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -1655,17 +1655,17 @@ nsCSSValue::AppendToString(nsCSSProperty
       aResult.Append(' ');
       auto shape = intValue & NS_STYLE_TEXT_EMPHASIS_STYLE_SHAPE_MASK;
       AppendASCIItoUTF16(nsCSSProps::ValueToKeyword(
         shape, nsCSSProps::kTextEmphasisStyleShapeKTable), aResult);
       break;
     }
 
     default:
-      const nsAFlatCString& name = nsCSSProps::LookupPropertyValue(aProperty, intValue);
+      const nsCString& name = nsCSSProps::LookupPropertyValue(aProperty, intValue);
       AppendASCIItoUTF16(name, aResult);
       break;
     }
   }
   else if (eCSSUnit_EnumColor == unit) {
     // we can lookup the property in the ColorTable and then
     // get a string mapping the name
     nsAutoCString str;
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -179,17 +179,17 @@ void PREF_CleanupPrefs()
     if (gHashTable) {
         delete gHashTable;
         gHashTable = nullptr;
         gPrefNameArena.Clear();
     }
 }
 
 // note that this appends to aResult, and does not assign!
-static void str_escape(const char * original, nsAFlatCString& aResult)
+static void str_escape(const char * original, nsCString& aResult)
 {
     /* JavaScript does not allow quotes, slashes, or line terminators inside
      * strings so we must escape them. ECMAScript defines four line
      * terminators, but we're only worrying about \r and \n here.  We currently
      * feed our pref script to the JS interpreter as Latin-1 so  we won't
      * encounter \u2028 (line separator) or \u2029 (paragraph separator).
      *
      * WARNING: There are hints that we may be moving to storing prefs
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -204,17 +204,17 @@ nsStandardURL::nsSegmentEncoder::nsSegme
     mEncoding = nullptr;
   }
 }
 
 int32_t nsStandardURL::
 nsSegmentEncoder::EncodeSegmentCount(const char *str,
                                      const URLSegment &seg,
                                      int16_t mask,
-                                     nsAFlatCString &result,
+                                     nsCString& result,
                                      bool &appended,
                                      uint32_t extraLen)
 {
     // extraLen is characters outside the segment that will be 
     // added when the segment is not empty (like the @ following
     // a username).
     appended = false;
     if (!str)
@@ -257,17 +257,17 @@ nsSegmentEncoder::EncodeSegmentCount(con
         len += extraLen;
     }
     return len;
 }
 
 const nsACString &nsStandardURL::
 nsSegmentEncoder::EncodeSegment(const nsACString& str,
                                 int16_t mask,
-                                nsAFlatCString &result)
+                                nsCString& result)
 {
     const char *text;
     bool encoded;
     EncodeSegmentCount(str.BeginReading(text), URLSegment(0, str.Length()), mask, result, encoded);
     if (encoded)
         return result;
     return str;
 }
--- a/netwerk/base/nsStandardURL.h
+++ b/netwerk/base/nsStandardURL.h
@@ -125,26 +125,26 @@ public: /* internal -- HPUX compiler can
         explicit nsSegmentEncoder(const char *charset);
 
         // Encode the given segment if necessary, and return the length of
         // the encoded segment.  The encoded segment is appended to |buf|
         // if and only if encoding is required.
         int32_t EncodeSegmentCount(const char *str,
                                    const URLSegment &segment,
                                    int16_t mask,
-                                   nsAFlatCString &buf,
+                                   nsCString& buf,
                                    bool& appended,
                                    uint32_t extraLen = 0);
          
         // Encode the given string if necessary, and return a reference to
         // the encoded string.  Returns a reference to |buf| if encoding
         // is required.  Otherwise, a reference to |str| is returned.
         const nsACString& EncodeSegment(const nsACString& str,
                                         int16_t mask,
-                                        nsAFlatCString &buf);
+                                        nsCString& buf);
     private:
       const Encoding* mEncoding;
     };
     friend class nsSegmentEncoder;
 
     static nsresult NormalizeIPv4(const nsCSubstring &host, nsCString &result);
 
 protected:
--- a/netwerk/base/nsURLHelper.h
+++ b/netwerk/base/nsURLHelper.h
@@ -94,17 +94,17 @@ bool net_IsAbsoluteURL(const nsACString&
  * @param scheme    scheme copied to this buffer on return (may be null)
  */
 nsresult net_ExtractURLScheme(const nsACString &inURI,
                               nsACString &scheme);
 
 /* check that the given scheme conforms to RFC 2396 */
 bool net_IsValidScheme(const char *scheme, uint32_t schemeLen);
 
-inline bool net_IsValidScheme(const nsAFlatCString &scheme)
+inline bool net_IsValidScheme(const nsCString& scheme)
 {
     return net_IsValidScheme(scheme.get(), scheme.Length());
 }
 
 /**
  * This function strips out all C0 controls and space at the beginning and end
  * of the URL and filters out \r, \n, \t from the middle of the URL.  This makes
  * it safe to call on things like javascript: urls or data: urls, where we may
--- a/netwerk/cookie/nsCookie.h
+++ b/netwerk/cookie/nsCookie.h
@@ -124,17 +124,17 @@ class nsCookie : public nsICookie2
   protected:
     virtual ~nsCookie() {}
 
   private:
     // member variables
     // we use char* ptrs to store the strings in a contiguous block,
     // so we save on the overhead of using nsCStrings. However, we
     // store a terminating null for each string, so we can hand them
-    // out as nsAFlatCStrings.
+    // out as nsCStrings.
     //
     // Please update SizeOfIncludingThis if this strategy changes.
     const char  *mName;
     const char  *mValue;
     const char  *mHost;
     const char  *mPath;
     const char  *mEnd;
     int64_t      mExpiry;
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -311,25 +311,25 @@ LogEvicted(nsCookie *aCookie, const char
   MOZ_LOG(gCookieLog, LogLevel::Debug,("===== COOKIE EVICTED =====\n"));
   MOZ_LOG(gCookieLog, LogLevel::Debug,("%s\n", details));
 
   LogCookie(aCookie);
 
   MOZ_LOG(gCookieLog, LogLevel::Debug,("\n"));
 }
 
-// inline wrappers to make passing in nsAFlatCStrings easier
+// inline wrappers to make passing in nsCStrings easier
 static inline void
-LogFailure(bool aSetCookie, nsIURI *aHostURI, const nsAFlatCString &aCookieString, const char *aReason)
+LogFailure(bool aSetCookie, nsIURI *aHostURI, const nsCString& aCookieString, const char *aReason)
 {
   LogFailure(aSetCookie, aHostURI, aCookieString.get(), aReason);
 }
 
 static inline void
-LogSuccess(bool aSetCookie, nsIURI *aHostURI, const nsAFlatCString &aCookieString, nsCookie *aCookie, bool aReplacing)
+LogSuccess(bool aSetCookie, nsIURI *aHostURI, const nsCString& aCookieString, nsCookie *aCookie, bool aReplacing)
 {
   LogSuccess(aSetCookie, aHostURI, aCookieString.get(), aCookie, aReplacing);
 }
 
 #ifdef DEBUG
 #define NS_ASSERT_SUCCESS(res)                                               \
   PR_BEGIN_MACRO                                                             \
   nsresult __rv = res; /* Do not evaluate |res| more than once! */           \
@@ -5005,19 +5005,19 @@ nsCookieService::FindSecureCookie(const 
   }
 
   return false;
 }
 
 // find an exact cookie specified by host, name, and path that hasn't expired.
 bool
 nsCookieService::FindCookie(const nsCookieKey    &aKey,
-                            const nsAFlatCString &aHost,
-                            const nsAFlatCString &aName,
-                            const nsAFlatCString &aPath,
+                            const nsCString& aHost,
+                            const nsCString& aName,
+                            const nsCString& aPath,
                             nsListIter           &aIter)
 {
   EnsureReadDomain(aKey);
 
   nsCookieEntry *entry = mDBState->hostTable.GetEntry(aKey);
   if (!entry)
     return false;
 
--- a/netwerk/cookie/nsCookieService.h
+++ b/netwerk/cookie/nsCookieService.h
@@ -307,17 +307,17 @@ class nsCookieService final : public nsI
     bool                          RequireThirdPartyCheck();
     CookieStatus                  CheckPrefs(nsIURI *aHostURI, bool aIsForeign, const char *aCookieHeader);
     bool                          CheckDomain(nsCookieAttributes &aCookie, nsIURI *aHostURI, const nsCString &aBaseDomain, bool aRequireHostMatch);
     static bool                   CheckPath(nsCookieAttributes &aCookie, nsIURI *aHostURI);
     static bool                   CheckPrefixes(nsCookieAttributes &aCookie, bool aSecureRequest);
     static bool                   GetExpiry(nsCookieAttributes &aCookie, int64_t aServerTime, int64_t aCurrentTime);
     void                          RemoveAllFromMemory();
     already_AddRefed<nsIArray>    PurgeCookies(int64_t aCurrentTimeInUsec);
-    bool                          FindCookie(const nsCookieKey& aKey, const nsAFlatCString &aHost, const nsAFlatCString &aName, const nsAFlatCString &aPath, nsListIter &aIter);
+    bool                          FindCookie(const nsCookieKey& aKey, const nsCString& aHost, const nsCString& aName, const nsCString& aPath, nsListIter &aIter);
     bool                          FindSecureCookie(const nsCookieKey& aKey, nsCookie* aCookie);
     int64_t                       FindStaleCookie(nsCookieEntry *aEntry, int64_t aCurrentTime, nsIURI* aSource, const mozilla::Maybe<bool> &aIsSecure, nsListIter &aIter);
     void                          TelemetryForEvictingStaleCookie(nsCookie* aEvicted, int64_t oldestCookieTime);
     void                          NotifyRejected(nsIURI *aHostURI);
     void                          NotifyThirdParty(nsIURI *aHostURI, bool aAccepted, nsIChannel *aChannel);
     void                          NotifyChanged(nsISupports *aSubject, const char16_t *aData);
     void                          NotifyPurged(nsICookie2* aCookie);
     already_AddRefed<nsIArray>    CreatePurgeList(nsICookie2* aCookie);
--- a/netwerk/dns/nsIDNService.cpp
+++ b/netwerk/dns/nsIDNService.cpp
@@ -40,18 +40,17 @@ static const char kACEPrefix[] = "xn--";
 //-----------------------------------------------------------------------------
 
 #define NS_NET_PREF_IDNBLACKLIST    "network.IDN.blacklist_chars"
 #define NS_NET_PREF_SHOWPUNYCODE    "network.IDN_show_punycode"
 #define NS_NET_PREF_IDNWHITELIST    "network.IDN.whitelist."
 #define NS_NET_PREF_IDNUSEWHITELIST "network.IDN.use_whitelist"
 #define NS_NET_PREF_IDNRESTRICTION  "network.IDN.restriction_profile"
 
-inline bool isOnlySafeChars(const nsAFlatString& in,
-                              const nsAFlatString& blacklist)
+inline bool isOnlySafeChars(const nsString& in, const nsString& blacklist)
 {
   return (blacklist.IsEmpty() ||
           in.FindCharInSet(blacklist) == kNotFound);
 }
 
 //-----------------------------------------------------------------------------
 // nsIDNService
 //-----------------------------------------------------------------------------
--- a/netwerk/mime/nsMIMEHeaderParamImpl.cpp
+++ b/netwerk/mime/nsMIMEHeaderParamImpl.cpp
@@ -908,17 +908,17 @@ internalDecodeParameter(const nsACString
   if (aCharset && *aCharset)
   {
     nsCOMPtr<nsIUTF8ConverterService> cvtUTF8(do_GetService(NS_UTF8CONVERTERSERVICE_CONTRACTID));
     if (cvtUTF8)
       return cvtUTF8->ConvertStringToUTF8(aParamValue, aCharset,
           true, true, 1, aResult);
   }
 
-  const nsAFlatCString& param = PromiseFlatCString(aParamValue);
+  const nsCString& param = PromiseFlatCString(aParamValue);
   nsAutoCString unQuoted;
   nsACString::const_iterator s, e;
   param.BeginReading(s);
   param.EndReading(e);
 
   // strip '\' when used to quote CR, LF, '"' and '\'
   for ( ; s != e; ++s) {
     if ((*s == '\\')) {
--- a/netwerk/protocol/http/Http2Stream.h
+++ b/netwerk/protocol/http/Http2Stream.h
@@ -65,19 +65,19 @@ public:
   virtual MOZ_MUST_USE nsresult WriteSegments(nsAHttpSegmentWriter *,
                                               uint32_t, uint32_t *);
   virtual bool DeferCleanup(nsresult status);
 
   // The consumer stream is the synthetic pull stream hooked up to this stream
   // http2PushedStream overrides it
   virtual Http2Stream *GetConsumerStream() { return nullptr; };
 
-  const nsAFlatCString &Origin() const { return mOrigin; }
-  const nsAFlatCString &Host() const { return mHeaderHost; }
-  const nsAFlatCString &Path() const { return mHeaderPath; }
+  const nsCString& Origin() const { return mOrigin; }
+  const nsCString& Host() const { return mHeaderHost; }
+  const nsCString& Path() const { return mHeaderPath; }
 
   bool RequestBlockedOnRead()
   {
     return static_cast<bool>(mRequestBlockedOnRead);
   }
 
   bool HasRegisteredID() { return mStreamID != 0; }
 
--- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
+++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
@@ -558,17 +558,17 @@ nsHttpChannelAuthProvider::PrepareForAut
     }
 
     return NS_OK;
 }
 
 nsresult
 nsHttpChannelAuthProvider::GetCredentials(const char     *challenges,
                                           bool            proxyAuth,
-                                          nsAFlatCString &creds)
+                                          nsCString& creds)
 {
     nsCOMPtr<nsIHttpAuthenticator> auth;
     nsAutoCString challenge;
 
     nsCString authType; // force heap allocation to enable string sharing since
                         // we'll be assigning this value into mAuthType.
 
     // set informations that depend on whether we're authenticating against a
@@ -696,17 +696,17 @@ nsHttpChannelAuthProvider::GetAuthorizat
     return NS_OK;
 }
 
 nsresult
 nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
                                                       const char *authType,
                                                       bool        proxyAuth,
                                                       nsIHttpAuthenticator *auth,
-                                                      nsAFlatCString     &creds)
+                                                      nsCString& creds)
 {
     LOG(("nsHttpChannelAuthProvider::GetCredentialsForChallenge "
          "[this=%p channel=%p proxyAuth=%d challenges=%s]\n",
         this, mAuthChannel, proxyAuth, challenge));
 
     // this getter never fails
     nsHttpAuthCache *authCache = gHttpHandler->AuthCache(mIsPrivate);
 
--- a/netwerk/protocol/http/nsHttpChannelAuthProvider.h
+++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.h
@@ -69,21 +69,21 @@ private:
 
     /**
      * Following three methods return NS_ERROR_IN_PROGRESS when
      * nsIAuthPrompt2.asyncPromptAuth method is called. This result indicates
      * the user's decision will be gathered in a callback and is not an actual
      * error.
      */
     MOZ_MUST_USE nsresult GetCredentials(const char *challenges, bool proxyAuth,
-                                         nsAFlatCString &creds);
+                                         nsCString& creds);
     MOZ_MUST_USE nsresult
     GetCredentialsForChallenge(const char *challenge, const char *scheme,
                                bool proxyAuth, nsIHttpAuthenticator *auth,
-                               nsAFlatCString &creds);
+                               nsCString& creds);
     MOZ_MUST_USE nsresult PromptForIdentity(uint32_t level, bool proxyAuth,
                                             const char *realm,
                                             const char *authType,
                                             uint32_t authFlags,
                                             nsHttpAuthIdentity &);
 
     bool     ConfirmAuth(const nsString &bundleKey, bool doYesNoPrompt);
     void     SetAuthorizationHeader(nsHttpAuthCache *, nsHttpAtom header,
--- a/netwerk/protocol/http/nsHttpConnectionInfo.h
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.h
@@ -59,17 +59,17 @@ private:
     virtual ~nsHttpConnectionInfo()
     {
         MOZ_LOG(gHttpLog, LogLevel::Debug, ("Destroying nsHttpConnectionInfo @%p\n", this));
     }
 
     void BuildHashKey();
 
 public:
-    const nsAFlatCString &HashKey() const { return mHashKey; }
+    const nsCString& HashKey() const { return mHashKey; }
 
     const nsCString &GetOrigin() const { return mOrigin; }
     const char   *Origin()       const { return mOrigin.get(); }
     int32_t       OriginPort()   const { return mOriginPort; }
 
     const nsCString &GetRoutedHost() const { return mRoutedHost; }
     const char      *RoutedHost() const { return mRoutedHost.get(); }
     int32_t          RoutedPort() const { return mRoutedPort; }
--- a/netwerk/protocol/http/nsHttpDigestAuth.cpp
+++ b/netwerk/protocol/http/nsHttpDigestAuth.cpp
@@ -401,20 +401,20 @@ nsHttpDigestAuth::GetAuthFlags(uint32_t 
   //       so we do not set the REUSABLE_CREDENTIALS flag.
   //
   return NS_OK;
 }
 
 nsresult
 nsHttpDigestAuth::CalculateResponse(const char * ha1_digest,
                                     const char * ha2_digest,
-                                    const nsAFlatCString & nonce,
+                                    const nsCString& nonce,
                                     uint16_t qop,
                                     const char * nonce_count,
-                                    const nsAFlatCString & cnonce,
+                                    const nsCString& cnonce,
                                     char * result)
 {
   uint32_t len = 2*EXPANDED_DIGEST_LENGTH + nonce.Length() + 2;
 
   if (qop & QOP_AUTH || qop & QOP_AUTH_INT) {
     len += cnonce.Length() + NONCE_COUNT_LENGTH + 3;
     if (qop & QOP_AUTH_INT)
       len += 8; // length of "auth-int"
@@ -468,22 +468,22 @@ nsHttpDigestAuth::ExpandToHex(const char
       result[(index*2)+1] = value - 10 + 'a';
   }
 
   result[EXPANDED_DIGEST_LENGTH] = 0;
   return NS_OK;
 }
 
 nsresult
-nsHttpDigestAuth::CalculateHA1(const nsAFlatCString & username,
-                               const nsAFlatCString & password,
-                               const nsAFlatCString & realm,
+nsHttpDigestAuth::CalculateHA1(const nsCString& username,
+                               const nsCString& password,
+                               const nsCString& realm,
                                uint16_t algorithm,
-                               const nsAFlatCString & nonce,
-                               const nsAFlatCString & cnonce,
+                               const nsCString& nonce,
+                               const nsCString& cnonce,
                                char * result)
 {
   int16_t len = username.Length() + password.Length() + realm.Length() + 2;
   if (algorithm & ALGO_MD5_SESS) {
     int16_t exlen = EXPANDED_DIGEST_LENGTH + nonce.Length() + cnonce.Length() + 2;
     if (exlen > len)
         len = exlen;
   }
@@ -517,18 +517,18 @@ nsHttpDigestAuth::CalculateHA1(const nsA
     if (NS_FAILED(rv))
       return rv;
   }
 
   return ExpandToHex(mHashBuf, result);
 }
 
 nsresult
-nsHttpDigestAuth::CalculateHA2(const nsAFlatCString & method,
-                               const nsAFlatCString & path,
+nsHttpDigestAuth::CalculateHA2(const nsCString& method,
+                               const nsCString& path,
                                uint16_t qop,
                                const char * bodyDigest,
                                char * result)
 {
   uint16_t methodLen = method.Length();
   uint32_t pathLen = path.Length();
   uint32_t len = methodLen + pathLen + 1;
 
--- a/netwerk/protocol/http/nsHttpDigestAuth.h
+++ b/netwerk/protocol/http/nsHttpDigestAuth.h
@@ -40,32 +40,32 @@ class nsHttpDigestAuth final : public ns
 
   protected:
     ~nsHttpDigestAuth();
 
     MOZ_MUST_USE nsresult ExpandToHex(const char * digest, char * result);
 
     MOZ_MUST_USE nsresult CalculateResponse(const char * ha1_digest,
                                             const char * ha2_digest,
-                                            const nsAFlatCString & nonce,
+                                            const nsCString&  nonce,
                                             uint16_t qop,
                                             const char * nonce_count,
-                                            const nsAFlatCString & cnonce,
+                                            const nsCString&  cnonce,
                                             char * result);
 
-    MOZ_MUST_USE nsresult CalculateHA1(const nsAFlatCString & username,
-                                       const nsAFlatCString & password,
-                                       const nsAFlatCString & realm,
+    MOZ_MUST_USE nsresult CalculateHA1(const nsCString& username,
+                                       const nsCString& password,
+                                       const nsCString& realm,
                                        uint16_t algorithm,
-                                       const nsAFlatCString & nonce,
-                                       const nsAFlatCString & cnonce,
+                                       const nsCString& nonce,
+                                       const nsCString& cnonce,
                                        char * result);
 
-    MOZ_MUST_USE nsresult CalculateHA2(const nsAFlatCString & http_method,
-                                       const nsAFlatCString & http_uri_path,
+    MOZ_MUST_USE nsresult CalculateHA2(const nsCString& http_method,
+                                       const nsCString& http_uri_path,
                                        uint16_t qop,
                                        const char * body_digest,
                                        char * result);
 
     MOZ_MUST_USE nsresult ParseChallenge(const char * challenge,
                                          nsACString & realm,
                                          nsACString & domain,
                                          nsACString & nonce,
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -786,17 +786,17 @@ nsHttpHandler::GenerateHostPort(const ns
 {
     return NS_GenerateHostPort(host, port, hostLine);
 }
 
 //-----------------------------------------------------------------------------
 // nsHttpHandler <private>
 //-----------------------------------------------------------------------------
 
-const nsAFlatCString &
+const nsCString&
 nsHttpHandler::UserAgent()
 {
     if (nsContentUtils::ShouldResistFingerprinting() &&
         !mSpoofedUserAgent.IsEmpty()) {
         LOG(("using spoofed userAgent : %s\n", mSpoofedUserAgent.get()));
         return mSpoofedUserAgent;
     }
 
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -69,17 +69,17 @@ public:
 
     MOZ_MUST_USE nsresult Init();
     MOZ_MUST_USE nsresult AddStandardRequestHeaders(nsHttpRequestHead *,
                                                     bool isSecure);
     MOZ_MUST_USE nsresult AddConnectionHeader(nsHttpRequestHead *,
                                               uint32_t capabilities);
     bool     IsAcceptableEncoding(const char *encoding, bool isSecure);
 
-    const nsAFlatCString &UserAgent();
+    const nsCString& UserAgent();
 
     nsHttpVersion  HttpVersion()             { return mHttpVersion; }
     nsHttpVersion  ProxyHttpVersion()        { return mProxyHttpVersion; }
     uint8_t        ReferrerLevel()           { return mReferrerLevel; }
     bool           SpoofReferrerSource()     { return mSpoofReferrerSource; }
     bool           HideOnionReferrerSource() { return mHideOnionReferrerSource; }
     uint8_t        ReferrerTrimmingPolicy()  { return mReferrerTrimmingPolicy; }
     uint8_t        ReferrerXOriginTrimmingPolicy() {
--- a/netwerk/streamconv/converters/nsBinHexDecoder.cpp
+++ b/netwerk/streamconv/converters/nsBinHexDecoder.cpp
@@ -463,17 +463,17 @@ nsBinHexDecoder::OnStartRequest(nsIReque
   return rv;
 }
 
 // Given the fileName we discovered inside the bin hex decoding, figure out the
 // content type and set it on the channel associated with the request.  If the
 // filename tells us nothing useful, just report an unknown type and let the
 // unknown decoder handle things.
 nsresult nsBinHexDecoder::DetectContentType(nsIRequest* aRequest,
-                                            const nsAFlatCString &aFilename)
+                                            const nsCString& aFilename)
 {
   if (aFilename.IsEmpty()) {
     // Nothing to do here.
     return NS_OK;
   }
 
   nsresult rv;
   nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest, &rv));
--- a/netwerk/streamconv/converters/nsBinHexDecoder.h
+++ b/netwerk/streamconv/converters/nsBinHexDecoder.h
@@ -79,17 +79,17 @@ public:
   nsBinHexDecoder();
 
 protected:
   virtual ~nsBinHexDecoder();
 
   int16_t  GetNextChar(uint32_t numBytesInBuffer);
   nsresult ProcessNextChunk(nsIRequest * aRequest, nsISupports * aContext, uint32_t numBytesInBuffer);
   nsresult ProcessNextState(nsIRequest * aRequest, nsISupports * aContext);
-  nsresult DetectContentType(nsIRequest * aRequest, const nsAFlatCString &aFilename);
+  nsresult DetectContentType(nsIRequest * aRequest, const nsCString& aFilename);
 
 protected:
   nsCOMPtr<nsIStreamListener> mNextListener;
 
   // the input and output streams form a pipe...they need to be passed around together..
   nsCOMPtr<nsIOutputStream>     mOutputStream;     // output stream
   nsCOMPtr<nsIInputStream>      mInputStream;
 
--- a/rdf/base/nsRDFService.cpp
+++ b/rdf/base/nsRDFService.cpp
@@ -822,17 +822,17 @@ RDFServiceImpl::GetResource(const nsACSt
     // Sanity checks
     NS_PRECONDITION(aResource != nullptr, "null ptr");
     NS_PRECONDITION(!aURI.IsEmpty(), "URI is empty");
     if (! aResource)
         return NS_ERROR_NULL_POINTER;
     if (aURI.IsEmpty())
         return NS_ERROR_INVALID_ARG;
 
-    const nsAFlatCString& flatURI = PromiseFlatCString(aURI);
+    const nsCString& flatURI = PromiseFlatCString(aURI);
     MOZ_LOG(gLog, LogLevel::Debug, ("rdfserv get-resource %s", flatURI.get()));
 
     // First, check the cache to see if we've already created and
     // registered this thing.
     PLDHashEntryHdr *hdr = mResources.Search(flatURI.get());
     if (hdr) {
         ResourceHashEntry *entry = static_cast<ResourceHashEntry *>(hdr);
         NS_ADDREF(*aResource = entry->mResource);
--- a/security/manager/ssl/nsKeygenHandler.cpp
+++ b/security/manager/ssl/nsKeygenHandler.cpp
@@ -394,17 +394,17 @@ loser:
           NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(numSlots, tokenNameList);
       }
       return rv;
 }
 
 nsresult
 nsKeygenFormProcessor::GetPublicKey(const nsAString& aValue,
                                     const nsAString& aChallenge,
-                                    const nsAFlatString& aKeyType,
+                                    const nsString& aKeyType,
                                     nsAString& aOutPublicKey,
                                     const nsAString& aKeyParams)
 {
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown()) {
       return NS_ERROR_NOT_AVAILABLE;
     }
 
--- a/security/manager/ssl/nsKeygenHandler.h
+++ b/security/manager/ssl/nsKeygenHandler.h
@@ -59,17 +59,17 @@ public:
 
   // Nothing to release.
   virtual void virtualDestroyNSSReference() override {}
 
 protected:
   virtual ~nsKeygenFormProcessor();
 
   nsresult GetPublicKey(const nsAString& aValue, const nsAString& aChallenge,
-                        const nsAFlatString& akeyType, nsAString& aOutPublicKey,
+                        const nsString& akeyType, nsAString& aOutPublicKey,
                         const nsAString& aPqg);
   nsresult GetSlot(uint32_t aMechanism, PK11SlotInfo** aSlot);
 private:
   nsCOMPtr<nsIInterfaceRequestor> m_ctx;
 
   typedef struct SECKeySizeChoiceInfoStr {
       nsString name;
       int size;
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1798,17 +1798,17 @@ NS_IMETHODIMP nsExternalAppHandler::OnSt
     }
   }
 
   return NS_OK;
 }
 
 // Convert error info into proper message text and send OnStatusChange
 // notification to the dialog progress listener or nsITransfer implementation.
-void nsExternalAppHandler::SendStatusChange(ErrorType type, nsresult rv, nsIRequest *aRequest, const nsAFlatString &path)
+void nsExternalAppHandler::SendStatusChange(ErrorType type, nsresult rv, nsIRequest *aRequest, const nsString& path)
 {
     nsAutoString msgId;
     switch (rv) {
     case NS_ERROR_OUT_OF_MEMORY:
         // No memory
         msgId.AssignLiteral("noMemory");
         break;
 
@@ -2256,17 +2256,17 @@ nsresult nsExternalAppHandler::SaveDesti
   if (aFile)
     ContinueSave(aFile);
   else
     Cancel(NS_BINDING_ABORTED);
 
   return NS_OK;
 }
 
-void nsExternalAppHandler::RequestSaveDestination(const nsAFlatString &aDefaultFile, const nsAFlatString &aFileExtension)
+void nsExternalAppHandler::RequestSaveDestination(const nsString& aDefaultFile, const nsString& aFileExtension)
 {
   // Display the dialog
   // XXX Convert to use file picker? No, then embeddors could not do any sort of
   // "AutoDownload" w/o showing a prompt
   nsresult rv = NS_OK;
   if (!mDialog) {
     // Get helper app launcher dialog.
     mDialog = do_CreateInstance(NS_HELPERAPPLAUNCHERDLG_CONTRACTID, &rv);
--- a/uriloader/exthandler/nsExternalHelperAppService.h
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
@@ -412,18 +412,18 @@ protected:
    *                                     v
    *    ContinueSave  <-------   SaveDestinationAvailable
    */
 
   /**
    * This is called by SaveToDisk to decide what's the final
    * file destination chosen by the user or by auto-download settings.
    */
-  void RequestSaveDestination(const nsAFlatString &aDefaultFile,
-                              const nsAFlatString &aDefaultFileExt);
+  void RequestSaveDestination(const nsString& aDefaultFile,
+                              const nsString& aDefaultFileExt);
 
   /**
    * When SaveToDisk is called, it possibly delegates to RequestSaveDestination
    * to decide the file destination. ContinueSave must then be called when
    * the final destination is finally known.
    * @param  aFile  The file that was chosen as the final destination.
    *                Must not be null.
    */
@@ -459,17 +459,17 @@ protected:
    * is different from mSuggestedFileName's extension.
    */
   void EnsureSuggestedFileName();
 
   typedef enum { kReadError, kWriteError, kLaunchError } ErrorType;
   /**
    * Utility function to send proper error notification to web progress listener
    */
-  void SendStatusChange(ErrorType type, nsresult aStatus, nsIRequest *aRequest, const nsAFlatString &path);
+  void SendStatusChange(ErrorType type, nsresult aStatus, nsIRequest *aRequest, const nsString& path);
 
   /**
    * Closes the window context if it does not have a refresh header
    * and it never displayed content before the external helper app
    * service was invoked.
    */
   nsresult MaybeCloseWindow();
 
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -220,17 +220,17 @@ NS_IMETHODIMP nsOSHelperAppService::GetA
 // attributes for the mimeType/extension associated with the input registry key.  The default
 // entry for that key is the name of a registry key under HKEY_CLASSES_ROOT.  The default
 // value for *that* key is the descriptive name of the type.  The EditFlags value is a binary
 // value; the low order bit of the third byte of which indicates that the user does not need
 // to be prompted.
 //
 // This function sets only the Description attribute of the input nsIMIMEInfo.
 /* static */
-nsresult nsOSHelperAppService::GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo)
+nsresult nsOSHelperAppService::GetMIMEInfoFromRegistry(const nsString& fileType, nsIMIMEInfo *pInfo)
 {
   nsresult rv = NS_OK;
 
   NS_ENSURE_ARG(pInfo);
   nsCOMPtr<nsIWindowsRegKey> regKey = 
     do_CreateInstance("@mozilla.org/windows-registry-key;1");
   if (!regKey) 
     return NS_ERROR_NOT_AVAILABLE;
@@ -385,17 +385,17 @@ nsOSHelperAppService::GetDefaultAppInfo(
 
   // The "FileDescription" field contains the actual name of the application.
   lf->GetVersionInfoField("FileDescription", aDefaultDescription);
   lf.forget(aDefaultApplication);
 
   return NS_OK;
 }
 
-already_AddRefed<nsMIMEInfoWin> nsOSHelperAppService::GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint)
+already_AddRefed<nsMIMEInfoWin> nsOSHelperAppService::GetByExtension(const nsString& aFileExt, const char *aTypeHint)
 {
   if (aFileExt.IsEmpty())
     return nullptr;
 
   // Determine the mime type.
   nsAutoCString typeToUse;
   if (aTypeHint && *aTypeHint) {
     typeToUse.Assign(aTypeHint);
--- a/uriloader/exthandler/win/nsOSHelperAppService.h
+++ b/uriloader/exthandler/win/nsOSHelperAppService.h
@@ -46,20 +46,20 @@ public:
   /** Get the string value of a registry value and store it in result.
    * @return true on success, false on failure
    */
   static bool GetValueString(HKEY hKey, const char16_t* pValueName, nsAString& result);
 
 protected:
   nsresult GetDefaultAppInfo(const nsAString& aTypeName, nsAString& aDefaultDescription, nsIFile** aDefaultApplication);
   // Lookup a mime info by extension, using an optional type hint
-  already_AddRefed<nsMIMEInfoWin> GetByExtension(const nsAFlatString& aFileExt, const char *aTypeHint = nullptr);
+  already_AddRefed<nsMIMEInfoWin> GetByExtension(const nsString& aFileExt, const char *aTypeHint = nullptr);
   nsresult FindOSMimeInfoForType(const char * aMimeContentType, nsIURI * aURI, char ** aFileExtension, nsIMIMEInfo ** aMIMEInfo);
 
-  static nsresult GetMIMEInfoFromRegistry(const nsAFlatString& fileType, nsIMIMEInfo *pInfo);
+  static nsresult GetMIMEInfoFromRegistry(const nsString& fileType, nsIMIMEInfo *pInfo);
   /// Looks up the type for the extension aExt and compares it to aType
   static bool typeFromExtEquals(const char16_t* aExt, const char *aType);
 
 private:
   IApplicationAssociationRegistration* mAppAssoc;
 };
 
 #endif // nsOSHelperAppService_h__
--- a/widget/cocoa/TextInputHandler.h
+++ b/widget/cocoa/TextInputHandler.h
@@ -85,17 +85,17 @@ public:
   {
     mInputSourceList = nullptr;
     InitByTISInputSourceRef(aInputSource);
   }
 
   ~TISInputSourceWrapper() { Clear(); }
 
   void InitByInputSourceID(const char* aID);
-  void InitByInputSourceID(const nsAFlatString &aID);
+  void InitByInputSourceID(const nsString& aID);
   void InitByInputSourceID(const CFStringRef aID);
   /**
    * InitByLayoutID() initializes the keyboard layout by the layout ID.
    *
    * @param aLayoutID             An ID of keyboard layout.
    *                                0: US
    *                                1: Greek
    *                                2: German
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -451,17 +451,17 @@ TISInputSourceWrapper::InitByInputSource
 
   CFStringRef idstr = ::CFStringCreateWithCString(kCFAllocatorDefault, aID,
                                                   kCFStringEncodingASCII);
   InitByInputSourceID(idstr);
   ::CFRelease(idstr);
 }
 
 void
-TISInputSourceWrapper::InitByInputSourceID(const nsAFlatString &aID)
+TISInputSourceWrapper::InitByInputSourceID(const nsString& aID)
 {
   Clear();
   if (aID.IsEmpty())
     return;
   CFStringRef idstr = ::CFStringCreateWithCharacters(kCFAllocatorDefault,
                                                      reinterpret_cast<const UniChar*>(aID.get()),
                                                      aID.Length());
   InitByInputSourceID(idstr);
--- a/widget/tests/TestChromeMargin.cpp
+++ b/widget/tests/TestChromeMargin.cpp
@@ -19,18 +19,18 @@
 #ifndef MOZILLA_INTERNAL_API
 // some of the includes make use of internal string types
 #define nsAString_h___
 #define nsString_h___
 #define nsStringFwd_h___
 #define nsReadableUtils_h___
 class nsACString;
 class nsAString;
-class nsAFlatString;
-class nsAFlatCString;
+class nsString;
+class nsCString;
 class nsAdoptingString;
 class nsAdoptingCString;
 class nsXPIDLString;
 template<class T> class nsReadingIterator;
 #endif
 
 #include "nscore.h"
 #include "nsContentUtils.h"
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -2138,17 +2138,17 @@ IMMHandler::GetTargetClauseRange(uint32_
       *aLength = i - offsetInComposition;
       break;
     }
   }
   return true;
 }
 
 bool
-IMMHandler::ConvertToANSIString(const nsAFlatString& aStr,
+IMMHandler::ConvertToANSIString(const nsString& aStr,
                                 UINT aCodePage,
                                 nsACString& aANSIStr)
 {
   int len = ::WideCharToMultiByte(aCodePage, 0,
                                   (LPCWSTR)aStr.get(), aStr.Length(),
                                   nullptr, 0, nullptr, nullptr);
   NS_ENSURE_TRUE(len >= 0, false);
 
--- a/widget/windows/IMMHandler.h
+++ b/widget/windows/IMMHandler.h
@@ -273,17 +273,17 @@ protected:
    *                          coordinates.
    *  @param aOutRect         The converted cursor rect.
    */
   void ResolveIMECaretPos(nsIWidget* aReferenceWidget,
                           mozilla::LayoutDeviceIntRect& aCursorRect,
                           nsIWidget* aNewOriginWidget,
                           mozilla::LayoutDeviceIntRect& aOutRect);
 
-  bool ConvertToANSIString(const nsAFlatString& aStr,
+  bool ConvertToANSIString(const nsString& aStr,
                              UINT aCodePage,
                              nsACString& aANSIStr);
 
   bool SetIMERelatedWindowsPos(nsWindow* aWindow,
                                const IMEContext& aContext);
   void SetIMERelatedWindowsPosOnPlugin(nsWindow* aWindow,
                                        const IMEContext& aContext);
   /**
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -490,17 +490,17 @@ nsPersistentProperties::Load(nsIInputStr
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPersistentProperties::SetStringProperty(const nsACString& aKey,
                                           const nsAString& aNewValue,
                                           nsAString& aOldValue)
 {
-  const nsAFlatCString&  flatKey = PromiseFlatCString(aKey);
+  const nsCString& flatKey = PromiseFlatCString(aKey);
   auto entry = static_cast<PropertyTableEntry*>
                           (mTable.Add(flatKey.get()));
 
   if (entry->mKey) {
     aOldValue = entry->mValue;
     NS_WARNING(nsPrintfCString("the property %s already exists",
                                flatKey.get()).get());
   } else {
@@ -518,17 +518,17 @@ nsPersistentProperties::Save(nsIOutputSt
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsPersistentProperties::GetStringProperty(const nsACString& aKey,
                                           nsAString& aValue)
 {
-  const nsAFlatCString&  flatKey = PromiseFlatCString(aKey);
+  const nsCString& flatKey = PromiseFlatCString(aKey);
 
   auto entry = static_cast<PropertyTableEntry*>(mTable.Search(flatKey.get()));
   if (!entry) {
     return NS_ERROR_FAILURE;
   }
 
   aValue = entry->mValue;
   return NS_OK;
--- a/xpcom/ds/nsStaticNameTable.cpp
+++ b/xpcom/ds/nsStaticNameTable.cpp
@@ -14,36 +14,36 @@
 
 #include "nsStaticNameTable.h"
 
 using namespace mozilla;
 
 struct NameTableKey
 {
   NameTableKey(const nsDependentCString aNameArray[],
-               const nsAFlatCString* aKeyStr)
+               const nsCString* aKeyStr)
     : mNameArray(aNameArray)
     , mIsUnichar(false)
   {
     mKeyStr.m1b = aKeyStr;
   }
 
   NameTableKey(const nsDependentCString aNameArray[],
-               const nsAFlatString* aKeyStr)
+               const nsString* aKeyStr)
     : mNameArray(aNameArray)
     , mIsUnichar(true)
   {
     mKeyStr.m2b = aKeyStr;
   }
 
   const nsDependentCString* mNameArray;
   union
   {
-    const nsAFlatCString* m1b;
-    const nsAFlatString* m2b;
+    const nsCString* m1b;
+    const nsString* m2b;
   } mKeyStr;
   bool mIsUnichar;
 };
 
 struct NameTableEntry : public PLDHashEntryHdr
 {
   int32_t mIndex;
 };
@@ -162,38 +162,38 @@ nsStaticCaseInsensitiveNameTable::~nsSta
   MOZ_COUNT_DTOR(nsStaticCaseInsensitiveNameTable);
 }
 
 int32_t
 nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName)
 {
   NS_ASSERTION(mNameArray, "not inited");
 
-  const nsAFlatCString& str = PromiseFlatCString(aName);
+  const nsCString& str = PromiseFlatCString(aName);
 
   NameTableKey key(mNameArray, &str);
   auto entry = static_cast<NameTableEntry*>(mNameTable.Search(&key));
 
   return entry ? entry->mIndex : nsStaticCaseInsensitiveNameTable::NOT_FOUND;
 }
 
 int32_t
 nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName)
 {
   NS_ASSERTION(mNameArray, "not inited");
 
-  const nsAFlatString& str = PromiseFlatString(aName);
+  const nsString& str = PromiseFlatString(aName);
 
   NameTableKey key(mNameArray, &str);
   auto entry = static_cast<NameTableEntry*>(mNameTable.Search(&key));
 
   return entry ? entry->mIndex : nsStaticCaseInsensitiveNameTable::NOT_FOUND;
 }
 
-const nsAFlatCString&
+const nsCString&
 nsStaticCaseInsensitiveNameTable::GetStringValue(int32_t aIndex)
 {
   NS_ASSERTION(mNameArray, "not inited");
 
   if ((NOT_FOUND < aIndex) && ((uint32_t)aIndex < mNameTable.EntryCount())) {
     return mNameArray[aIndex];
   }
   return mNullStr;
--- a/xpcom/ds/nsStaticNameTable.h
+++ b/xpcom/ds/nsStaticNameTable.h
@@ -30,17 +30,17 @@
 
 class nsStaticCaseInsensitiveNameTable
 {
 public:
   enum { NOT_FOUND = -1 };
 
   int32_t          Lookup(const nsACString& aName);
   int32_t          Lookup(const nsAString& aName);
-  const nsAFlatCString& GetStringValue(int32_t aIndex);
+  const nsCString& GetStringValue(int32_t aIndex);
 
   nsStaticCaseInsensitiveNameTable(const char* const aNames[], int32_t aLength);
   ~nsStaticCaseInsensitiveNameTable();
 
 private:
   nsDependentCString*   mNameArray;
   PLDHashTable          mNameTable;
   nsDependentCString    mNullStr;
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -514,32 +514,32 @@ NS_EscapeURL(const nsSubstring& aStr, ui
     return aResult;
   }
   return aStr;
 }
 
 // Starting at aStr[aStart] find the first index in aStr that matches any
 // character in aForbidden. Return false if not found.
 static bool
-FindFirstMatchFrom(const nsAFlatString& aStr, size_t aStart,
+FindFirstMatchFrom(const nsString& aStr, size_t aStart,
                    const nsTArray<char16_t>& aForbidden, size_t* aIndex)
 {
   const size_t len = aForbidden.Length();
   for (size_t j = aStart, l = aStr.Length(); j < l; ++j) {
     size_t unused;
     if (mozilla::BinarySearch(aForbidden, 0, len, aStr[j], &unused)) {
       *aIndex = j;
       return true;
     }
   }
   return false;
 }
 
 const nsSubstring&
-NS_EscapeURL(const nsAFlatString& aStr, const nsTArray<char16_t>& aForbidden,
+NS_EscapeURL(const nsString& aStr, const nsTArray<char16_t>& aForbidden,
              nsSubstring& aResult)
 {
   bool didEscape = false;
   for (size_t i = 0, strLen = aStr.Length(); i < strLen; ) {
     size_t j;
     if (MOZ_UNLIKELY(FindFirstMatchFrom(aStr, i, aForbidden, &j))) {
       if (i == 0) {
         didEscape = true;
--- a/xpcom/io/nsEscape.h
+++ b/xpcom/io/nsEscape.h
@@ -185,17 +185,17 @@ NS_EscapeURL(const nsSubstring& aStr, ui
  * @param aStr the input URL string
  * @param aForbidden the characters that should be escaped if found in aStr
  * @note that aForbidden MUST be sorted (low to high)
  * @param aResult the result if some characters were escaped
  * @return aResult if some characters were escaped, or aStr otherwise (aResult
  *         is unmodified in that case)
  */
 const nsSubstring&
-NS_EscapeURL(const nsAFlatString& aStr, const nsTArray<char16_t>& aForbidden,
+NS_EscapeURL(const nsString& aStr, const nsTArray<char16_t>& aForbidden,
              nsSubstring& aResult);
 
 /**
  * CString version of nsEscape. Returns true on success, false
  * on out of memory. To reverse this function, use NS_UnescapeURL.
  */
 inline bool
 NS_Escape(const nsACString& aOriginal, nsACString& aEscaped,
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -542,17 +542,17 @@ struct PRFilePrivate
 // UTF-16 APIs are implemented on all the supported platforms (or at least
 // Windows 9x/ME) in NSPR. Currently, they're only implemented on
 // Windows NT4 or later. (bug 330665)
 //-----------------------------------------------------------------------------
 
 // copied from nsprpub/pr/src/{io/prfile.c | md/windows/w95io.c} :
 // PR_Open and _PR_MD_OPEN
 nsresult
-OpenFile(const nsAFlatString& aName,
+OpenFile(const nsString& aName,
          int aOsflags,
          int aMode,
          bool aShareDelete,
          PRFileDesc** aFd)
 {
   int32_t access = 0;
 
   int32_t shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
@@ -646,17 +646,17 @@ FileTimeToPRTime(const FILETIME* aFileti
 #else
   *aPrtm = (*aPrtm - _pr_filetime_offset) / 10i64;
 #endif
 }
 
 // copied from nsprpub/pr/src/{io/prfile.c | md/windows/w95io.c} with some
 // changes : PR_GetFileInfo64, _PR_MD_GETFILEINFO64
 static nsresult
-GetFileInfo(const nsAFlatString& aName, PRFileInfo64* aInfo)
+GetFileInfo(const nsString& aName, PRFileInfo64* aInfo)
 {
   WIN32_FILE_ATTRIBUTE_DATA fileData;
 
   if (aName.IsEmpty() || aName.FindCharInSet(u"?*") != kNotFound) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (!::GetFileAttributesExW(aName.get(), GetFileExInfoStandard, &fileData)) {
@@ -687,17 +687,17 @@ GetFileInfo(const nsAFlatString& aName, 
 struct nsDir
 {
   HANDLE handle;
   WIN32_FIND_DATAW data;
   bool firstEntry;
 };
 
 static nsresult
-OpenDir(const nsAFlatString& aName, nsDir** aDir)
+OpenDir(const nsString& aName, nsDir** aDir)
 {
   if (NS_WARN_IF(!aDir)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   *aDir = nullptr;
   if (aName.Length() + 3 >= MAX_PATH) {
     return NS_ERROR_FILE_NAME_TOO_LONG;
@@ -1462,17 +1462,17 @@ NS_IMETHODIMP
 nsLocalFile::AppendRelativePath(const nsAString& aNode)
 {
   // append this path, multiple components are permitted
   return AppendInternal(PromiseFlatString(aNode), true);
 }
 
 
 nsresult
-nsLocalFile::AppendInternal(const nsAFlatString& aNode,
+nsLocalFile::AppendInternal(const nsString& aNode,
                             bool aMultipleComponents)
 {
   if (aNode.IsEmpty()) {
     return NS_OK;
   }
 
   // check the relative path for validity
   if (aNode.First() == L'\\' ||               // can't start with an '\'
--- a/xpcom/io/nsLocalFileWin.h
+++ b/xpcom/io/nsLocalFileWin.h
@@ -106,18 +106,17 @@ private:
 
   nsresult CopyMove(nsIFile* aNewParentDir, const nsAString& aNewName,
                     uint32_t aOptions);
   nsresult CopySingleFile(nsIFile* aSource, nsIFile* aDest,
                           const nsAString& aNewName, uint32_t aOptions);
 
   nsresult SetModDate(int64_t aLastModifiedTime, const wchar_t* aFilePath);
   nsresult HasFileAttribute(DWORD aFileAttrib, bool* aResult);
-  nsresult AppendInternal(const nsAFlatString& aNode,
-                          bool aMultipleComponents);
+  nsresult AppendInternal(const nsString& aNode, bool aMultipleComponents);
 
   nsresult OpenNSPRFileDescMaybeShareDelete(int32_t aFlags,
                                             int32_t aMode,
                                             bool aShareDelete,
                                             PRFileDesc** aResult);
 };
 
 #endif
--- a/xpcom/string/nsReadableUtils.cpp
+++ b/xpcom/string/nsReadableUtils.cpp
@@ -1254,41 +1254,41 @@ StringEndsWith(const nsACString& aSource
   return Substring(aSource, src_len - sub_len, sub_len).Equals(aSubstring,
                                                                aComparator);
 }
 
 
 
 static const char16_t empty_buffer[1] = { '\0' };
 
-const nsAFlatString&
+const nsString&
 EmptyString()
 {
   static const nsDependentString sEmpty(empty_buffer);
 
   return sEmpty;
 }
 
-const nsAFlatCString&
+const nsCString&
 EmptyCString()
 {
   static const nsDependentCString sEmpty((const char*)empty_buffer);
 
   return sEmpty;
 }
 
-const nsAFlatString&
+const nsString&
 NullString()
 {
   static const nsXPIDLString sNull;
 
   return sNull;
 }
 
-const nsAFlatCString&
+const nsCString&
 NullCString()
 {
   static const nsXPIDLCString sNull;
 
   return sNull;
 }
 
 int32_t
--- a/xpcom/string/nsReadableUtils.h
+++ b/xpcom/string/nsReadableUtils.h
@@ -395,21 +395,21 @@ bool StringBeginsWith(const nsACString& 
                       const nsCStringComparator& aComparator);
 bool StringEndsWith(const nsAString& aSource, const nsAString& aSubstring);
 bool StringEndsWith(const nsAString& aSource, const nsAString& aSubstring,
                     const nsStringComparator& aComparator);
 bool StringEndsWith(const nsACString& aSource, const nsACString& aSubstring);
 bool StringEndsWith(const nsACString& aSource, const nsACString& aSubstring,
                     const nsCStringComparator& aComparator);
 
-const nsAFlatString& EmptyString();
-const nsAFlatCString& EmptyCString();
+const nsString& EmptyString();
+const nsCString& EmptyCString();
 
-const nsAFlatString& NullString();
-const nsAFlatCString& NullCString();
+const nsString& NullString();
+const nsCString& NullCString();
 
 /**
 * Compare a UTF-8 string to an UTF-16 string.
 *
 * Returns 0 if the strings are equal, -1 if aUTF8String is less
 * than aUTF16Count, and 1 in the reverse case.  In case of fatal
 * error (eg the strings are not valid UTF8 and UTF16 respectively),
 * this method will return INT32_MIN.
--- a/xpcom/string/nsStringFwd.h
+++ b/xpcom/string/nsStringFwd.h
@@ -58,14 +58,9 @@ class nsXPIDLCString;
 
 /**
  * typedefs for backwards compatibility
  */
 
 typedef nsAString             nsSubstring;
 typedef nsACString            nsCSubstring;
 
-typedef nsString              nsAFlatString;
-
-typedef nsCString             nsAFlatCString;
-
-
 #endif /* !defined(nsStringFwd_h___) */
--- a/xpcom/string/nsStringObsolete.cpp
+++ b/xpcom/string/nsStringObsolete.cpp
@@ -859,17 +859,17 @@ RFind_ComputeSearchRange( uint32_t bigLe
 #include "nsTStringObsolete.cpp"
 #include "string-template-undef.h"
 
 //-----------------------------------------------------------------------------
 
 // specialized methods:
 
 int32_t
-nsString::Find( const nsAFlatString& aString, int32_t aOffset, int32_t aCount ) const
+nsString::Find( const nsString& aString, int32_t aOffset, int32_t aCount ) const
 {
   // this method changes the meaning of aOffset and aCount:
   Find_ComputeSearchRange(mLength, aString.Length(), aOffset, aCount);
 
   int32_t result = FindSubstring(mData + aOffset, aCount, static_cast<const char16_t*>(aString.get()), aString.Length(), false);
   if (result != kNotFound)
     result += aOffset;
   return result;
@@ -877,17 +877,17 @@ nsString::Find( const nsAFlatString& aSt
 
 int32_t
 nsString::Find( const char16_t* aString, int32_t aOffset, int32_t aCount ) const
 {
   return Find(nsDependentString(aString), aOffset, aCount);
 }
 
 int32_t
-nsString::RFind( const nsAFlatString& aString, int32_t aOffset, int32_t aCount ) const
+nsString::RFind( const nsString& aString, int32_t aOffset, int32_t aCount ) const
 {
   // this method changes the meaning of aOffset and aCount:
   RFind_ComputeSearchRange(mLength, aString.Length(), aOffset, aCount);
 
   int32_t result = RFindSubstring(mData + aOffset, aCount, static_cast<const char16_t*>(aString.get()), aString.Length(), false);
   if (result != kNotFound)
     result += aOffset;
   return result;
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -152,17 +152,17 @@ public:
    */
 
   int32_t Find(const nsCString& aString, bool aIgnoreCase = false,
                int32_t aOffset = 0, int32_t aCount = -1) const;
   int32_t Find(const char* aString, bool aIgnoreCase = false,
                int32_t aOffset = 0, int32_t aCount = -1) const;
 
 #ifdef CharT_is_PRUnichar
-  int32_t Find(const nsAFlatString& aString, int32_t aOffset = 0,
+  int32_t Find(const nsString& aString, int32_t aOffset = 0,
                int32_t aCount = -1) const;
   int32_t Find(const char16_t* aString, int32_t aOffset = 0,
                int32_t aCount = -1) const;
 #ifdef MOZ_USE_CHAR16_WRAPPER
   int32_t Find(char16ptr_t aString, int32_t aOffset = 0,
                int32_t aCount = -1) const
   {
     return Find(static_cast<const char16_t*>(aString), aOffset, aCount);
@@ -184,17 +184,17 @@ public:
    */
 
   int32_t RFind(const nsCString& aString, bool aIgnoreCase = false,
                 int32_t aOffset = -1, int32_t aCount = -1) const;
   int32_t RFind(const char* aCString, bool aIgnoreCase = false,
                 int32_t aOffset = -1, int32_t aCount = -1) const;
 
 #ifdef CharT_is_PRUnichar
-  int32_t RFind(const nsAFlatString& aString, int32_t aOffset = -1,
+  int32_t RFind(const nsString& aString, int32_t aOffset = -1,
                 int32_t aCount = -1) const;
   int32_t RFind(const char16_t* aString, int32_t aOffset = -1,
                 int32_t aCount = -1) const;
 #endif
 
 
   /**
    *  Search for given char within this string