Bug 1374580 (part 3) - Remove ns{,C}Substring typedefs. r=froydnj.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 20 Jun 2017 19:19:52 +1000
changeset 416867 6352096eb0de303cba9440092279e4254a1ec586
parent 416866 2915d4b7849612e583048650beabe33bad2cfeca
child 416868 1fd20434759f528282da8fe419b99b9eba40b170
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [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 3) - Remove ns{,C}Substring typedefs. r=froydnj. All the instances are converted as follows. - nsSubstring --> nsAString - nsCSubstring --> nsACString
accessible/base/nsCoreUtils.cpp
accessible/base/nsCoreUtils.h
docshell/base/nsDocShell.cpp
dom/base/Navigator.cpp
dom/base/nsContentSink.cpp
dom/base/nsContentSink.h
dom/ipc/ContentChild.cpp
dom/media/VideoUtils.cpp
dom/plugins/base/nsPluginTags.cpp
dom/security/FramingChecker.cpp
dom/security/nsCSPUtils.cpp
dom/security/nsContentSecurityManager.cpp
dom/storage/LocalStorage.cpp
dom/storage/LocalStorage.h
dom/storage/StorageUtils.cpp
dom/storage/StorageUtils.h
dom/svg/SVGTests.cpp
dom/svg/SVGTests.h
dom/xml/nsXMLContentSink.cpp
dom/xml/nsXMLContentSink.h
dom/xml/nsXMLFragmentContentSink.cpp
dom/xslt/xpath/txCoreFunctionCall.cpp
dom/xslt/xpath/txExprParser.cpp
dom/xslt/xpath/txExprParser.h
dom/xslt/xslt/txBufferingHandler.cpp
dom/xslt/xslt/txEXSLTFunctions.cpp
dom/xslt/xslt/txMozillaTextOutput.cpp
dom/xslt/xslt/txMozillaXMLOutput.cpp
dom/xslt/xslt/txMozillaXMLOutput.h
dom/xslt/xslt/txMozillaXSLTProcessor.cpp
dom/xslt/xslt/txTextHandler.cpp
dom/xslt/xslt/txUnknownHandler.cpp
dom/xslt/xslt/txUnknownHandler.h
dom/xslt/xslt/txXMLEventHandler.h
dom/xslt/xslt/txXSLTPatterns.cpp
dom/xslt/xslt/txXSLTPatterns.h
extensions/permissions/nsContentBlocker.cpp
extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
extensions/spellcheck/src/mozInlineSpellWordUtil.h
gfx/src/nsFont.h
intl/locale/LocaleService.cpp
layout/base/nsCounterManager.cpp
layout/base/nsCounterManager.h
layout/generic/nsGridContainerFrame.cpp
layout/style/CounterStyleManager.cpp
layout/style/CounterStyleManager.h
layout/style/Loader.cpp
layout/style/nsAnimationManager.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSParser.h
layout/style/nsCSSRules.h
layout/style/nsStyleStruct.h
layout/style/nsStyleUtil.cpp
layout/style/nsStyleUtil.h
media/mtransport/nr_socket_prsock.cpp
netwerk/base/nsBase64Encoder.cpp
netwerk/base/nsBase64Encoder.h
netwerk/base/nsChannelClassifier.cpp
netwerk/base/nsMediaFragmentURIParser.cpp
netwerk/base/nsSerializationHelper.cpp
netwerk/base/nsSerializationHelper.h
netwerk/base/nsStandardURL.cpp
netwerk/base/nsStandardURL.h
netwerk/base/nsURLHelper.cpp
netwerk/base/nsURLHelper.h
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/cache/nsDiskCacheDeviceSQL.h
netwerk/cache2/CacheEntry.cpp
netwerk/cache2/CacheEntry.h
netwerk/cache2/CacheFileUtils.cpp
netwerk/cache2/CacheFileUtils.h
netwerk/cache2/CacheStorageService.cpp
netwerk/cache2/CacheStorageService.h
netwerk/cache2/OldWrappers.cpp
netwerk/cache2/OldWrappers.h
netwerk/protocol/ftp/nsFTPChannel.h
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
netwerk/protocol/ftp/nsFtpConnectionThread.h
netwerk/protocol/ftp/nsFtpControlConnection.cpp
netwerk/protocol/ftp/nsFtpControlConnection.h
netwerk/protocol/http/Http2Stream.cpp
netwerk/protocol/http/Http2Stream.h
netwerk/protocol/http/HttpAuthUtils.cpp
netwerk/protocol/http/nsCORSListenerProxy.cpp
netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
netwerk/protocol/http/nsHttpChannelAuthProvider.h
netwerk/protocol/http/nsHttpRequestHead.cpp
netwerk/protocol/http/nsHttpRequestHead.h
netwerk/test/gtest/TestStandardURL.cpp
parser/htmlparser/nsScannerString.cpp
parser/htmlparser/nsScannerString.h
rdf/base/nsNameSpaceMap.cpp
rdf/base/nsNameSpaceMap.h
rdf/base/nsRDFXMLSerializer.cpp
rdf/base/rdfutil.cpp
rdf/base/rdfutil.h
security/manager/ssl/nsNSSIOLayer.cpp
security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
toolkit/components/places/nsNavHistoryQuery.cpp
toolkit/components/url-classifier/LookupCache.cpp
toolkit/components/url-classifier/ProtocolParser.cpp
toolkit/xre/nsUpdateDriver.cpp
uriloader/exthandler/nsExternalHelperAppService.cpp
uriloader/exthandler/nsExternalHelperAppService.h
uriloader/prefetch/nsOfflineCacheUpdate.cpp
uriloader/prefetch/nsOfflineCacheUpdate.h
xpcom/components/ManifestParser.cpp
xpcom/ds/nsCharSeparatedTokenizer.h
xpcom/ds/nsWhitespaceTokenizer.h
xpcom/io/nsEscape.cpp
xpcom/io/nsEscape.h
xpcom/string/nsReadableUtils.cpp
xpcom/string/nsReadableUtils.h
xpcom/string/nsStringFwd.h
xpcom/string/nsSubstring.cpp
xpcom/string/nsTSubstring.h
xpcom/tests/gtest/TestStrings.cpp
xpcom/threads/LazyIdleThread.cpp
xpcom/threads/LazyIdleThread.h
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -628,19 +628,19 @@ nsCoreUtils::ScrollTo(nsIPresShell* aPre
 {
   nsIPresShell::ScrollAxis vertical, horizontal;
   ConvertScrollTypeToPercents(aScrollType, &vertical, &horizontal);
   aPresShell->ScrollContentIntoView(aContent, vertical, horizontal,
                                     nsIPresShell::SCROLL_OVERFLOW_HIDDEN);
 }
 
 bool
-nsCoreUtils::IsWhitespaceString(const nsSubstring& aString)
+nsCoreUtils::IsWhitespaceString(const nsAString& aString)
 {
-  nsSubstring::const_char_iterator iterBegin, iterEnd;
+  nsAString::const_char_iterator iterBegin, iterEnd;
 
   aString.BeginReading(iterBegin);
   aString.EndReading(iterEnd);
 
   while (iterBegin != iterEnd && IsWhitespace(*iterBegin))
     ++iterBegin;
 
   return iterBegin == iterEnd;
--- a/accessible/base/nsCoreUtils.h
+++ b/accessible/base/nsCoreUtils.h
@@ -294,17 +294,17 @@ public:
       aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::scope);
   }
 
   /**
    * Returns true if the given string is empty or contains whitespace symbols
    * only. In contrast to nsWhitespaceTokenizer class it takes into account
    * non-breaking space (0xa0).
    */
-  static bool IsWhitespaceString(const nsSubstring& aString);
+  static bool IsWhitespaceString(const nsAString& aString);
 
   /**
    * Returns true if the given character is whitespace symbol.
    */
   static bool IsWhitespace(char16_t aChar)
   {
     return aChar == ' ' || aChar == '\n' ||
       aChar == '\r' || aChar == '\t' || aChar == 0xa0;
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -11422,17 +11422,17 @@ nsDocShell::AddHeadersToChannel(nsIInput
 
   static const char kWhitespace[] = "\b\t\r\n ";
   while (true) {
     crlf = headersString.Find("\r\n");
     if (crlf == kNotFound) {
       return NS_OK;
     }
 
-    const nsCSubstring& oneHeader = StringHead(headersString, crlf);
+    const nsACString& oneHeader = StringHead(headersString, crlf);
 
     colon = oneHeader.FindChar(':');
     if (colon == kNotFound) {
       return NS_ERROR_UNEXPECTED;
     }
 
     headerName = StringHead(oneHeader, colon);
     headerValue = Substring(oneHeader, colon + 1);
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -396,17 +396,17 @@ Navigator::GetAcceptLanguages(nsTArray<n
     // Use uppercase for country part, e.g. "en-US", not "en-us", see BCP47
     // only uppercase 2-letter country codes, not "zh-Hant", "de-DE-x-goethe".
     // NOTE: we should probably rely on the pref being set correctly.
     if (lang.Length() > 2) {
       nsCharSeparatedTokenizer localeTokenizer(lang, '-');
       int32_t pos = 0;
       bool first = true;
       while (localeTokenizer.hasMoreTokens()) {
-        const nsSubstring& code = localeTokenizer.nextToken();
+        const nsAString& code = localeTokenizer.nextToken();
 
         if (code.Length() == 2 && !first) {
           nsAutoString upper(code);
           ToUpperCase(upper);
           lang.Replace(pos, code.Length(), upper);
         }
 
         pos += code.Length() + 1; // 1 is the separator
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -351,17 +351,17 @@ nsContentSink::DoProcessLinkHeader()
   mDocument->GetHeaderData(nsGkAtoms::link, value);
   ProcessLinkHeader(value);
 }
 
 // check whether the Link header field applies to the context resource
 // see <http://tools.ietf.org/html/rfc5988#section-5.2>
 
 bool
-nsContentSink::LinkContextIsOurDocument(const nsSubstring& aAnchor)
+nsContentSink::LinkContextIsOurDocument(const nsAString& aAnchor)
 {
   if (aAnchor.IsEmpty()) {
     // anchor parameter not present or empty -> same document reference
     return true;
   }
 
   nsIURI* docUri = mDocument->GetDocumentURI();
 
@@ -675,20 +675,20 @@ nsContentSink::ProcessLinkHeader(const n
                      type, media, crossOrigin);
   }
 
   return rv;
 }
 
 
 nsresult
-nsContentSink::ProcessLink(const nsSubstring& aAnchor, const nsSubstring& aHref,
-                           const nsSubstring& aRel, const nsSubstring& aTitle,
-                           const nsSubstring& aType, const nsSubstring& aMedia,
-                           const nsSubstring& aCrossOrigin)
+nsContentSink::ProcessLink(const nsAString& aAnchor, const nsAString& aHref,
+                           const nsAString& aRel, const nsAString& aTitle,
+                           const nsAString& aType, const nsAString& aMedia,
+                           const nsAString& aCrossOrigin)
 {
   uint32_t linkTypes =
     nsStyleLinkElement::ParseLinkTypes(aRel);
 
   // The link relation may apply to a different resource, specified
   // in the anchor parameter. For the link relations supported so far,
   // we simply abort if the link applies to a resource different to the
   // one we've loaded
@@ -729,21 +729,21 @@ nsContentSink::ProcessLink(const nsSubst
 
   bool isAlternate = linkTypes & nsStyleLinkElement::eALTERNATE;
   return ProcessStyleLink(nullptr, aHref, isAlternate, aTitle, aType,
                           aMedia);
 }
 
 nsresult
 nsContentSink::ProcessStyleLink(nsIContent* aElement,
-                                const nsSubstring& aHref,
+                                const nsAString& aHref,
                                 bool aAlternate,
-                                const nsSubstring& aTitle,
-                                const nsSubstring& aType,
-                                const nsSubstring& aMedia)
+                                const nsAString& aTitle,
+                                const nsAString& aType,
+                                const nsAString& aMedia)
 {
   if (aAlternate && aTitle.IsEmpty()) {
     // alternates must have title return without error, for now
     return NS_OK;
   }
 
   nsAutoString  mimeType;
   nsAutoString  params;
--- a/dom/base/nsContentSink.h
+++ b/dom/base/nsContentSink.h
@@ -108,17 +108,17 @@ class nsContentSink : public nsICSSLoade
 
   // nsIDocumentObserver
   NS_DECL_NSIDOCUMENTOBSERVER_BEGINUPDATE
   NS_DECL_NSIDOCUMENTOBSERVER_ENDUPDATE
 
   virtual void UpdateChildCounts() = 0;
 
   bool IsTimeToNotify();
-  bool LinkContextIsOurDocument(const nsSubstring& aAnchor);
+  bool LinkContextIsOurDocument(const nsAString& aAnchor);
   bool Decode5987Format(nsAString& aEncoded);
 
   static void InitializeStatics();
 
 protected:
   nsContentSink();
   virtual ~nsContentSink();
 
@@ -146,27 +146,27 @@ protected:
 
   nsresult Init(nsIDocument* aDoc, nsIURI* aURI,
                 nsISupports* aContainer, nsIChannel* aChannel);
 
   nsresult ProcessHTTPHeaders(nsIChannel* aChannel);
   nsresult ProcessHeaderData(nsIAtom* aHeader, const nsAString& aValue,
                              nsIContent* aContent = nullptr);
   nsresult ProcessLinkHeader(const nsAString& aLinkData);
-  nsresult ProcessLink(const nsSubstring& aAnchor,
-                       const nsSubstring& aHref, const nsSubstring& aRel,
-                       const nsSubstring& aTitle, const nsSubstring& aType,
-                       const nsSubstring& aMedia, const nsSubstring& aCrossOrigin);
+  nsresult ProcessLink(const nsAString& aAnchor,
+                       const nsAString& aHref, const nsAString& aRel,
+                       const nsAString& aTitle, const nsAString& aType,
+                       const nsAString& aMedia, const nsAString& aCrossOrigin);
 
   virtual nsresult ProcessStyleLink(nsIContent* aElement,
-                                    const nsSubstring& aHref,
+                                    const nsAString& aHref,
                                     bool aAlternate,
-                                    const nsSubstring& aTitle,
-                                    const nsSubstring& aType,
-                                    const nsSubstring& aMedia);
+                                    const nsAString& aTitle,
+                                    const nsAString& aType,
+                                    const nsAString& aMedia);
 
   void PrefetchHref(const nsAString &aHref, nsINode *aSource,
                     bool aExplicit);
 
   // For PrefetchDNS() aHref can either be the usual
   // URI format or of the form "//www.hostname.com" without a scheme.
   void PrefetchDNS(const nsAString &aHref);
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1514,17 +1514,17 @@ ContentChild::RecvSetProcessSandbox(cons
       // didn't intend it.
       MOZ_RELEASE_ASSERT(brokerFd >= 0);
     }
     // Allow user overrides of seccomp-bpf syscall filtering
     std::vector<int> syscallWhitelist;
     nsAdoptingCString extraSyscalls =
       Preferences::GetCString("security.sandbox.content.syscall_whitelist");
     if (extraSyscalls) {
-      for (const nsCSubstring& callNrString : extraSyscalls.Split(',')) {
+      for (const nsACString& callNrString : extraSyscalls.Split(',')) {
         nsresult rv;
         int callNr = PromiseFlatCString(callNrString).ToInteger(&rv);
         if (NS_SUCCEEDED(rv)) {
           syscallWhitelist.push_back(callNr);
         }
       }
     }
     sandboxEnabled = SetContentProcessSandbox(brokerFd, syscallWhitelist);
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -412,17 +412,17 @@ LogToBrowserConsole(const nsAString& aMs
 
 bool
 ParseCodecsString(const nsAString& aCodecs, nsTArray<nsString>& aOutCodecs)
 {
   aOutCodecs.Clear();
   bool expectMoreTokens = false;
   nsCharSeparatedTokenizer tokenizer(aCodecs, ',');
   while (tokenizer.hasMoreTokens()) {
-    const nsSubstring& token = tokenizer.nextToken();
+    const nsAString& token = tokenizer.nextToken();
     expectMoreTokens = tokenizer.separatorAfterCurrentToken();
     aOutCodecs.AppendElement(token);
   }
   if (expectMoreTokens) {
     // Last codec name was empty
     return false;
   }
   return true;
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -38,17 +38,17 @@ static const char kPrefDefaultEnabledSta
 static const char kPrefDefaultEnabledStateXpi[] = "plugin.defaultXpi.state";
 
 // check comma delimited extensions
 static bool ExtensionInList(const nsCString& aExtensionList,
                             const nsACString& aExtension)
 {
   nsCCharSeparatedTokenizer extensions(aExtensionList, ',');
   while (extensions.hasMoreTokens()) {
-    const nsCSubstring& extension = extensions.nextToken();
+    const nsACString& extension = extensions.nextToken();
     if (extension.Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
       return true;
     }
   }
   return false;
 }
 
 // Search for an extension in an extensions array, and return its
--- a/dom/security/FramingChecker.cpp
+++ b/dom/security/FramingChecker.cpp
@@ -234,17 +234,17 @@ FramingChecker::CheckFrameOptions(nsICha
   if (xfoHeaderValue.IsEmpty()) {
     return true;
   }
 
   // iterate through all the header values (usually there's only one, but can
   // be many.  If any want to deny the load, deny the load.
   nsCharSeparatedTokenizer tokenizer(xfoHeaderValue, ',');
   while (tokenizer.hasMoreTokens()) {
-    const nsSubstring& tok = tokenizer.nextToken();
+    const nsAString& tok = tokenizer.nextToken();
     if (!CheckOneFrameOptionsPolicy(httpChannel, tok, aDocShell)) {
       // cancel the load and display about:blank
       httpChannel->Cancel(NS_BINDING_ABORTED);
       if (aDocShell) {
         nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(aDocShell));
         if (webNav) {
           nsCOMPtr<nsILoadInfo> loadInfo = httpChannel->GetLoadInfo();
           nsCOMPtr<nsIPrincipal> triggeringPrincipal = loadInfo
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -423,17 +423,17 @@ CSP_AppendCSPFromHeader(nsIContentSecuri
   NS_ENSURE_ARG(aCsp);
 
   // Need to tokenize the header value since multiple headers could be
   // concatenated into one comma-separated list of policies.
   // See RFC2616 section 4.2 (last paragraph)
   nsresult rv = NS_OK;
   nsCharSeparatedTokenizer tokenizer(aHeaderValue, ',');
   while (tokenizer.hasMoreTokens()) {
-    const nsSubstring& policy = tokenizer.nextToken();
+    const nsAString& policy = tokenizer.nextToken();
     rv = aCsp->AppendPolicy(policy, aReportOnly, false);
     NS_ENSURE_SUCCESS(rv, rv);
     {
       CSPUTILSLOG(("CSP refined with policy: \"%s\"",
                    NS_ConvertUTF16toUTF8(policy).get()));
     }
   }
   return NS_OK;
--- a/dom/security/nsContentSecurityManager.cpp
+++ b/dom/security/nsContentSecurityManager.cpp
@@ -721,17 +721,17 @@ nsContentSecurityManager::IsOriginPotent
   // check to see if it has been whitelisted by the user.  We only apply this
   // whitelist for network resources, i.e., those with scheme "http" or "ws".
   // The pref should contain a comma-separated list of hostnames.
   if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("ws")) {
     nsAdoptingCString whitelist = Preferences::GetCString("dom.securecontext.whitelist");
     if (whitelist) {
       nsCCharSeparatedTokenizer tokenizer(whitelist, ',');
       while (tokenizer.hasMoreTokens()) {
-        const nsCSubstring& allowedHost = tokenizer.nextToken();
+        const nsACString& allowedHost = tokenizer.nextToken();
         if (host.Equals(allowedHost)) {
           *aIsTrustWorthy = true;
           return NS_OK;
         }
       }
     }
   }
 
--- a/dom/storage/LocalStorage.cpp
+++ b/dom/storage/LocalStorage.cpp
@@ -170,19 +170,19 @@ LocalStorage::Clear(nsIPrincipal& aSubje
   }
 
   if (!aRv.ErrorCodeIs(NS_SUCCESS_DOM_NO_OPERATION)) {
     BroadcastChangeNotification(NullString(), NullString(), NullString());
   }
 }
 
 void
-LocalStorage::BroadcastChangeNotification(const nsSubstring& aKey,
-                                          const nsSubstring& aOldValue,
-                                          const nsSubstring& aNewValue)
+LocalStorage::BroadcastChangeNotification(const nsAString& aKey,
+                                          const nsAString& aOldValue,
+                                          const nsAString& aNewValue)
 {
   if (!XRE_IsParentProcess() && Principal()) {
     // If we are in a child process, we want to send a message to the parent in
     // order to broadcast the StorageEvent correctly to any child process.
     dom::ContentChild* cc = dom::ContentChild::GetSingleton();
     Unused << NS_WARN_IF(!cc->SendBroadcastLocalStorageChange(
       mDocumentURI, nsString(aKey), nsString(aOldValue), nsString(aNewValue),
       IPC::Principal(Principal()), mIsPrivate));
--- a/dom/storage/LocalStorage.h
+++ b/dom/storage/LocalStorage.h
@@ -110,17 +110,17 @@ private:
 
   // Principal this Storage (i.e. localStorage or sessionStorage) has
   // been created for
   nsCOMPtr<nsIPrincipal> mPrincipal;
 
   // Whether this storage is running in private-browsing window.
   bool mIsPrivate : 1;
 
-  void BroadcastChangeNotification(const nsSubstring& aKey,
-                                   const nsSubstring& aOldValue,
-                                   const nsSubstring& aNewValue);
+  void BroadcastChangeNotification(const nsAString& aKey,
+                                   const nsAString& aOldValue,
+                                   const nsAString& aNewValue);
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_LocalStorage_h
--- a/dom/storage/StorageUtils.cpp
+++ b/dom/storage/StorageUtils.cpp
@@ -79,17 +79,17 @@ PrincipalsEqual(nsIPrincipal* aObjectPri
   if (!aObjectPrincipal) {
     return false;
   }
 
   return aSubjectPrincipal->Equals(aObjectPrincipal);
 }
 
 void
-ReverseString(const nsCSubstring& aSource, nsCSubstring& aResult)
+ReverseString(const nsACString& aSource, nsACString& aResult)
 {
   nsACString::const_iterator sourceBegin, sourceEnd;
   aSource.BeginReading(sourceBegin);
   aSource.EndReading(sourceEnd);
 
   aResult.SetLength(aSource.Length());
   nsACString::iterator destEnd;
   aResult.EndWriting(destEnd);
--- a/dom/storage/StorageUtils.h
+++ b/dom/storage/StorageUtils.h
@@ -17,17 +17,17 @@ nsresult
 GenerateOriginKey(nsIPrincipal* aPrincipal, nsACString& aOriginAttrSuffix,
                   nsACString& aOriginKey);
 
 bool
 PrincipalsEqual(nsIPrincipal* aObjectPrincipal,
                 nsIPrincipal* aSubjectPrincipal);
 
 void
-ReverseString(const nsCSubstring& aSource, nsCSubstring& aResult);
+ReverseString(const nsACString& aSource, nsACString& aResult);
 
 nsresult
 CreateReversedDomain(const nsACString& aAsciiDomain,
                      nsACString& aKey);
 
 } // StorageUtils namespace
 } // dom namespace
 } // mozilla namespace
--- a/dom/svg/SVGTests.cpp
+++ b/dom/svg/SVGTests.cpp
@@ -67,31 +67,31 @@ SVGTests::IsConditionalProcessingAttribu
     if (aAttribute == *sStringListNames[i]) {
       return true;
     }
   }
   return false;
 }
 
 int32_t
-SVGTests::GetBestLanguagePreferenceRank(const nsSubstring& aAcceptLangs) const
+SVGTests::GetBestLanguagePreferenceRank(const nsAString& aAcceptLangs) const
 {
   const nsDefaultStringComparator defaultComparator;
 
   if (!mStringListAttributes[LANGUAGE].IsExplicitlySet()) {
     return -2;
   }
 
   int32_t lowestRank = -1;
 
   for (uint32_t i = 0; i < mStringListAttributes[LANGUAGE].Length(); i++) {
     nsCharSeparatedTokenizer languageTokenizer(aAcceptLangs, ',');
     int32_t index = 0;
     while (languageTokenizer.hasMoreTokens()) {
-      const nsSubstring &languageToken = languageTokenizer.nextToken();
+      const nsAString& languageToken = languageTokenizer.nextToken();
       bool exactMatch = (languageToken == mStringListAttributes[LANGUAGE][i]);
       bool prefixOnlyMatch =
         !exactMatch &&
         nsStyleUtil::DashMatchCompare(mStringListAttributes[LANGUAGE][i],
                                       languageTokenizer.nextToken(),
                                       defaultComparator);
       if (index == 0 && exactMatch) {
         // best possible match
--- a/dom/svg/SVGTests.h
+++ b/dom/svg/SVGTests.h
@@ -41,17 +41,17 @@ public:
    * We have a match if a language name in the users language preferences
    * exactly equals one of the language names or exactly equals a prefix of
    * one of the language names in the systemLanguage attribute.
    * @returns 2 * the lowest index in the aAcceptLangs that matches + 1
    * if only the prefix matches, -2 if there's no systemLanguage attribute,
    * or -1 if no indices match.
    * XXX This algorithm is O(M*N).
    */
-  int32_t GetBestLanguagePreferenceRank(const nsSubstring& aAcceptLangs) const;
+  int32_t GetBestLanguagePreferenceRank(const nsAString& aAcceptLangs) const;
 
   /**
    * Special value to pass to PassesConditionalProcessingTests to ignore systemLanguage
    * attributes
    */
   static const nsString * const kIgnoreSystemLanguage;
 
   /**
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -655,21 +655,21 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIU
   // XML document whether we're able to load the XSLT stylesheet or
   // not.
 
   return NS_OK;
 }
 
 nsresult
 nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
-                                   const nsSubstring& aHref,
+                                   const nsAString& aHref,
                                    bool aAlternate,
-                                   const nsSubstring& aTitle,
-                                   const nsSubstring& aType,
-                                   const nsSubstring& aMedia)
+                                   const nsAString& aTitle,
+                                   const nsAString& aType,
+                                   const nsAString& aMedia)
 {
   nsresult rv = NS_OK;
   mPrettyPrintXML = false;
 
   nsAutoCString cmd;
   if (mParser)
     GetParser()->GetCommand(cmd);
   if (cmd.EqualsASCII(kLoadAsData))
--- a/dom/xml/nsXMLContentSink.h
+++ b/dom/xml/nsXMLContentSink.h
@@ -141,21 +141,21 @@ protected:
   {
     if (IsTimeToNotify()) {
       FlushTags();	
     }
   }
   
   // nsContentSink override
   virtual nsresult ProcessStyleLink(nsIContent* aElement,
-                                    const nsSubstring& aHref,
+                                    const nsAString& aHref,
                                     bool aAlternate,
-                                    const nsSubstring& aTitle,
-                                    const nsSubstring& aType,
-                                    const nsSubstring& aMedia) override;
+                                    const nsAString& aTitle,
+                                    const nsAString& aType,
+                                    const nsAString& aMedia) override;
 
   nsresult LoadXSLStyleSheet(nsIURI* aUrl);
 
   bool CanStillPrettyPrint();
 
   nsresult MaybePrettyPrint();
   
   bool IsMonolithicContainer(mozilla::dom::NodeInfo* aNodeInfo);
--- a/dom/xml/nsXMLFragmentContentSink.cpp
+++ b/dom/xml/nsXMLFragmentContentSink.cpp
@@ -87,21 +87,21 @@ protected:
                                  nsIContent** aResult, bool* aAppendContent,
                                  mozilla::dom::FromParser aFromParser) override;
   virtual nsresult CloseElement(nsIContent* aContent) override;
 
   virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
 
   // nsContentSink overrides
   virtual nsresult ProcessStyleLink(nsIContent* aElement,
-                                    const nsSubstring& aHref,
+                                    const nsAString& aHref,
                                     bool aAlternate,
-                                    const nsSubstring& aTitle,
-                                    const nsSubstring& aType,
-                                    const nsSubstring& aMedia) override;
+                                    const nsAString& aTitle,
+                                    const nsAString& aType,
+                                    const nsAString& aMedia) override;
   nsresult LoadXSLStyleSheet(nsIURI* aUrl);
   void StartLayout();
 
   nsCOMPtr<nsIDocument> mTargetDocument;
   // the fragment
   nsCOMPtr<nsIContent>  mRoot;
   bool                  mParseError;
 };
@@ -323,21 +323,21 @@ nsXMLFragmentContentSink::ReportError(co
   // destructor, so don't mess with it.
   mTextLength = 0;
 
   return NS_OK; 
 }
 
 nsresult
 nsXMLFragmentContentSink::ProcessStyleLink(nsIContent* aElement,
-                                           const nsSubstring& aHref,
+                                           const nsAString& aHref,
                                            bool aAlternate,
-                                           const nsSubstring& aTitle,
-                                           const nsSubstring& aType,
-                                           const nsSubstring& aMedia)
+                                           const nsAString& aTitle,
+                                           const nsAString& aType,
+                                           const nsAString& aMedia)
 {
   // don't process until moved to document
   return NS_OK;
 }
 
 nsresult
 nsXMLFragmentContentSink::LoadXSLStyleSheet(nsIURI* aUrl)
 {
--- a/dom/xslt/xpath/txCoreFunctionCall.cpp
+++ b/dom/xslt/xpath/txCoreFunctionCall.cpp
@@ -425,17 +425,17 @@ txCoreFunctionCall::evaluate(txIEvalCont
 
             int32_t idx = arg1.Find(arg2);
             if (idx == kNotFound) {
                 aContext->recycler()->getEmptyStringResult(aResult);
                 
                 return NS_OK;
             }
 
-            const nsSubstring& result = Substring(arg1, idx + arg2.Length());
+            const nsAString& result = Substring(arg1, idx + arg2.Length());
             return aContext->recycler()->getStringResult(result, aResult);
         }
         case SUBSTRING_BEFORE:
         {
             nsAutoString arg2;
             rv = mParams[1]->evaluateToString(aContext, arg2);
             NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/xslt/xpath/txExprParser.cpp
+++ b/dom/xslt/xpath/txExprParser.cpp
@@ -23,28 +23,28 @@
 
 using mozilla::Move;
 
 /**
  * Creates an Attribute Value Template using the given value
  * This should move to XSLProcessor class
  */
 nsresult
-txExprParser::createAVT(const nsSubstring& aAttrValue,
+txExprParser::createAVT(const nsAString& aAttrValue,
                         txIParseContext* aContext,
                         Expr** aResult)
 {
     *aResult = nullptr;
     nsresult rv = NS_OK;
     nsAutoPtr<Expr> expr;
     FunctionCall* concat = nullptr;
 
     nsAutoString literalString;
     bool inExpr = false;
-    nsSubstring::const_char_iterator iter, start, end, avtStart;
+    nsAString::const_char_iterator iter, start, end, avtStart;
     aAttrValue.BeginReading(iter);
     aAttrValue.EndReading(end);
     avtStart = iter;
 
     while (iter != end) {
         // Every iteration through this loop parses either a literal section
         // or an expression
         start = iter;
@@ -141,17 +141,17 @@ txExprParser::createAVT(const nsSubstrin
     }
 
     *aResult = expr.forget();
 
     return NS_OK;
 }
 
 nsresult
-txExprParser::createExprInternal(const nsSubstring& aExpression,
+txExprParser::createExprInternal(const nsAString& aExpression,
                                  uint32_t aSubStringPos,
                                  txIParseContext* aContext, Expr** aExpr)
 {
     NS_ENSURE_ARG_POINTER(aExpr);
     *aExpr = nullptr;
     txExprLexer lexer;
     nsresult rv = lexer.parse(aExpression);
     if (NS_FAILED(rv)) {
--- a/dom/xslt/xpath/txExprParser.h
+++ b/dom/xslt/xpath/txExprParser.h
@@ -25,32 +25,32 @@ class PredicateList;
 class Token;
 class txIParseContext;
 class txNodeTest;
 
 class txExprParser
 {
 public:
 
-    static nsresult createExpr(const nsSubstring& aExpression,
+    static nsresult createExpr(const nsAString& aExpression,
                                txIParseContext* aContext, Expr** aExpr)
     {
         return createExprInternal(aExpression, 0, aContext, aExpr);
     }
 
     /**
      * Creates an Attribute Value Template using the given value
      */
-    static nsresult createAVT(const nsSubstring& aAttrValue,
+    static nsresult createAVT(const nsAString& aAttrValue,
                               txIParseContext* aContext,
                               Expr** aResult);
 
 
 protected:
-    static nsresult createExprInternal(const nsSubstring& aExpression,
+    static nsresult createExprInternal(const nsAString& aExpression,
                                        uint32_t aSubStringPos,
                                        txIParseContext* aContext,
                                        Expr** aExpr);
     /**
      * Using nsAutoPtr& to optimize passing the ownership to the
      * created binary expression objects.
      */
     static nsresult createBinaryExpr(nsAutoPtr<Expr>& left,
--- a/dom/xslt/xslt/txBufferingHandler.cpp
+++ b/dom/xslt/xslt/txBufferingHandler.cpp
@@ -105,17 +105,17 @@ public:
     nsCOMPtr<nsIAtom> mLowercaseLocalName;
     int32_t mNsID;
 };
 
 class txStartElementTransaction : public txOutputTransaction
 {
 public:
     txStartElementTransaction(nsIAtom* aPrefix,
-                              const nsSubstring& aLocalName, int32_t aNsID)
+                              const nsAString& aLocalName, int32_t aNsID)
         : txOutputTransaction(eStartElementTransaction),
           mPrefix(aPrefix),
           mLocalName(aLocalName),
           mNsID(aNsID)
     {
         MOZ_COUNT_CTOR_INHERITED(txStartElementTransaction, txOutputTransaction);
     }
     virtual ~txStartElementTransaction()
@@ -126,17 +126,17 @@ public:
     nsString mLocalName;
     int32_t mNsID;
 };
 
 class txAttributeTransaction : public txOutputTransaction
 {
 public:
     txAttributeTransaction(nsIAtom* aPrefix,
-                           const nsSubstring& aLocalName, int32_t aNsID,
+                           const nsAString& aLocalName, int32_t aNsID,
                            const nsString& aValue)
         : txOutputTransaction(eAttributeTransaction),
           mPrefix(aPrefix),
           mLocalName(aLocalName),
           mNsID(aNsID),
           mValue(aValue)
     {
         MOZ_COUNT_CTOR_INHERITED(txAttributeTransaction, txOutputTransaction);
@@ -203,33 +203,33 @@ txBufferingHandler::attribute(nsIAtom* a
     txOutputTransaction* transaction =
         new txAttributeAtomTransaction(aPrefix, aLocalName,
                                        aLowercaseLocalName, aNsID,
                                        aValue);
     return mBuffer->addTransaction(transaction);
 }
 
 nsresult
-txBufferingHandler::attribute(nsIAtom* aPrefix, const nsSubstring& aLocalName,
+txBufferingHandler::attribute(nsIAtom* aPrefix, const nsAString& aLocalName,
                               const int32_t aNsID, const nsString& aValue)
 {
     NS_ENSURE_TRUE(mBuffer, NS_ERROR_OUT_OF_MEMORY);
 
     if (!mCanAddAttribute) {
         // XXX ErrorReport: Can't add attributes without element
         return NS_OK;
     }
 
     txOutputTransaction* transaction =
         new txAttributeTransaction(aPrefix, aLocalName, aNsID, aValue);
     return mBuffer->addTransaction(transaction);
 }
 
 nsresult
-txBufferingHandler::characters(const nsSubstring& aData, bool aDOE)
+txBufferingHandler::characters(const nsAString& aData, bool aDOE)
 {
     NS_ENSURE_TRUE(mBuffer, NS_ERROR_OUT_OF_MEMORY);
 
     mCanAddAttribute = false;
 
     txOutputTransaction::txTransactionType type =
          aDOE ? txOutputTransaction::eCharacterNoOETransaction
               : txOutputTransaction::eCharacterTransaction;
@@ -315,17 +315,17 @@ txBufferingHandler::startElement(nsIAtom
     txOutputTransaction* transaction =
         new txStartElementAtomTransaction(aPrefix, aLocalName,
                                           aLowercaseLocalName, aNsID);
     return mBuffer->addTransaction(transaction);
 }
 
 nsresult
 txBufferingHandler::startElement(nsIAtom* aPrefix,
-                                 const nsSubstring& aLocalName,
+                                 const nsAString& aLocalName,
                                  const int32_t aNsID)
 {
     NS_ENSURE_TRUE(mBuffer, NS_ERROR_OUT_OF_MEMORY);
 
     mCanAddAttribute = true;
 
     txOutputTransaction* transaction =
         new txStartElementTransaction(aPrefix, aLocalName, aNsID);
--- a/dom/xslt/xslt/txEXSLTFunctions.cpp
+++ b/dom/xslt/xslt/txEXSLTFunctions.cpp
@@ -112,17 +112,17 @@ createDocFragment(txIEvalContext *aConte
     nsIDocument *doc = txXPathNativeNode::getDocument(document);
     RefPtr<DocumentFragment> fragment =
       new DocumentFragment(doc->NodeInfoManager());
 
     return fragment.forget();
 }
 
 static nsresult
-createAndAddToResult(nsIAtom* aName, const nsSubstring& aValue,
+createAndAddToResult(nsIAtom* aName, const nsAString& aValue,
                      txNodeSet* aResultSet, nsIContent* aResultHolder)
 {
     NS_ASSERTION(aResultHolder->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) &&
                  aResultHolder->OwnerDoc(),
                  "invalid result-holder");
 
     nsIDocument* doc = aResultHolder->OwnerDoc();
     nsCOMPtr<Element> elem = doc->CreateElem(nsDependentAtomString(aName),
--- a/dom/xslt/xslt/txMozillaTextOutput.cpp
+++ b/dom/xslt/xslt/txMozillaTextOutput.cpp
@@ -44,25 +44,25 @@ nsresult
 txMozillaTextOutput::attribute(nsIAtom* aPrefix, nsIAtom* aLocalName,
                                nsIAtom* aLowercaseLocalName,
                                int32_t aNsID, const nsString& aValue)
 {
     return NS_OK;
 }
 
 nsresult
-txMozillaTextOutput::attribute(nsIAtom* aPrefix, const nsSubstring& aName,
+txMozillaTextOutput::attribute(nsIAtom* aPrefix, const nsAString& aName,
                                const int32_t aNsID,
                                const nsString& aValue)
 {
     return NS_OK;
 }
 
 nsresult
-txMozillaTextOutput::characters(const nsSubstring& aData, bool aDOE)
+txMozillaTextOutput::characters(const nsAString& aData, bool aDOE)
 {
     mText.Append(aData);
 
     return NS_OK;
 }
 
 nsresult
 txMozillaTextOutput::comment(const nsString& aData)
@@ -232,17 +232,17 @@ txMozillaTextOutput::createResultDocumen
 nsresult
 txMozillaTextOutput::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
                                   nsIAtom* aLowercaseLocalName, int32_t aNsID)
 {
     return NS_OK;
 }
 
 nsresult
-txMozillaTextOutput::startElement(nsIAtom* aPrefix, const nsSubstring& aName,
+txMozillaTextOutput::startElement(nsIAtom* aPrefix, const nsAString& aName,
                                   const int32_t aNsID)
 {
     return NS_OK;
 }
 
 void txMozillaTextOutput::getOutputDocument(nsIDOMDocument** aDocument)
 {
     CallQueryInterface(mDocument, aDocument);
--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
+++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
@@ -118,17 +118,17 @@ txMozillaXMLOutput::attribute(nsIAtom* a
         }
     }
 
     return attributeInternal(aPrefix, aLocalName, aNsID, aValue);
 }
 
 nsresult
 txMozillaXMLOutput::attribute(nsIAtom* aPrefix,
-                              const nsSubstring& aLocalName,
+                              const nsAString& aLocalName,
                               const int32_t aNsID,
                               const nsString& aValue)
 {
     nsCOMPtr<nsIAtom> lname;
 
     if (mOpenedElementIsHTML && aNsID == kNameSpaceID_None) {
         nsAutoString lnameStr;
         nsContentUtils::ASCIIToLower(aLocalName, lnameStr);
@@ -166,17 +166,17 @@ txMozillaXMLOutput::attributeInternal(ns
 
     NS_ASSERTION(!mBadChildLevel, "mBadChildLevel set when element is opened");
 
     return mOpenedElement->SetAttr(aNsID, aLocalName, aPrefix, aValue,
                                    false);
 }
 
 nsresult
-txMozillaXMLOutput::characters(const nsSubstring& aData, bool aDOE)
+txMozillaXMLOutput::characters(const nsAString& aData, bool aDOE)
 {
     nsresult rv = closePrevious(false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!mBadChildLevel) {
         mText.Append(aData);
     }
 
@@ -449,17 +449,17 @@ txMozillaXMLOutput::startElement(nsIAtom
                                     kNameSpaceID_XHTML);
     }
 
     return startElementInternal(aPrefix, aLocalName, aNsID);
 }
 
 nsresult
 txMozillaXMLOutput::startElement(nsIAtom* aPrefix,
-                                 const nsSubstring& aLocalName,
+                                 const nsAString& aLocalName,
                                  const int32_t aNsID)
 {
     int32_t nsId = aNsID;
     nsCOMPtr<nsIAtom> lname;
 
     if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) {
         nsId = kNameSpaceID_XHTML;
 
@@ -772,17 +772,17 @@ void txMozillaXMLOutput::processHTTPEqui
 {
     // For now we only handle "refresh". There's a longer list in
     // HTMLContentSink::ProcessHeaderData
     if (aHeader == nsGkAtoms::refresh)
         LossyCopyUTF16toASCII(aValue, mRefreshString);
 }
 
 nsresult
-txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, int32_t aNsID,
+txMozillaXMLOutput::createResultDocument(const nsAString& aName, int32_t aNsID,
                                          nsIDOMDocument* aSourceDocument,
                                          bool aLoadedAsData)
 {
     nsresult rv;
 
     // Create the document
     if (mOutputFormat.mMethod == eHTMLOutput) {
         rv = NS_NewHTMLDocument(getter_AddRefs(mDocument),
--- a/dom/xslt/xslt/txMozillaXMLOutput.h
+++ b/dom/xslt/xslt/txMozillaXMLOutput.h
@@ -67,17 +67,17 @@ public:
                        bool aNoFixup);
     ~txMozillaXMLOutput();
 
     TX_DECL_TXAXMLEVENTHANDLER
     TX_DECL_TXAOUTPUTXMLEVENTHANDLER
 
     nsresult closePrevious(bool aFlushText);
 
-    nsresult createResultDocument(const nsSubstring& aName, int32_t aNsID,
+    nsresult createResultDocument(const nsAString& aName, int32_t aNsID,
                                   nsIDOMDocument* aSourceDocument,
                                   bool aLoadedAsData);
 
 private:
     nsresult createTxWrapper();
     nsresult startHTMLElement(nsIContent* aElement, bool aXHTML);
     nsresult endHTMLElement(nsIContent* aElement);
     void processHTTPEquiv(nsIAtom* aHeader, const nsString& aValue);
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -127,17 +127,17 @@ txToDocHandlerFactory::createHandlerWith
 
     MOZ_CRASH("Unknown output method");
 
     return NS_ERROR_FAILURE;
 }
 
 nsresult
 txToDocHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
-                                         const nsSubstring& aName,
+                                         const nsAString& aName,
                                          int32_t aNsID,
                                          txAXMLEventHandler** aHandler)
 {
     *aHandler = nullptr;
     switch (aFormat->mMethod) {
         case eMethodNotSet:
         {
             NS_ERROR("How can method not be known when root element is?");
@@ -219,17 +219,17 @@ txToFragmentHandlerFactory::createHandle
         }
     }
     NS_ENSURE_TRUE(*aHandler, NS_ERROR_OUT_OF_MEMORY);
     return NS_OK;
 }
 
 nsresult
 txToFragmentHandlerFactory::createHandlerWith(txOutputFormat* aFormat,
-                                              const nsSubstring& aName,
+                                              const nsAString& aName,
                                               int32_t aNsID,
                                               txAXMLEventHandler** aHandler)
 {
     *aHandler = nullptr;
     NS_ASSERTION(aFormat->mMethod != eMethodNotSet,
                  "How can method not be known when root element is?");
     NS_ENSURE_TRUE(aFormat->mMethod != eMethodNotSet, NS_ERROR_UNEXPECTED);
     return createHandlerWith(aFormat, aHandler);
--- a/dom/xslt/xslt/txTextHandler.cpp
+++ b/dom/xslt/xslt/txTextHandler.cpp
@@ -15,25 +15,25 @@ nsresult
 txTextHandler::attribute(nsIAtom* aPrefix, nsIAtom* aLocalName,
                          nsIAtom* aLowercaseLocalName, int32_t aNsID,
                          const nsString& aValue)
 {
     return NS_OK;
 }
 
 nsresult
-txTextHandler::attribute(nsIAtom* aPrefix, const nsSubstring& aLocalName,
+txTextHandler::attribute(nsIAtom* aPrefix, const nsAString& aLocalName,
                          const int32_t aNsID,
                          const nsString& aValue)
 {
     return NS_OK;
 }
 
 nsresult
-txTextHandler::characters(const nsSubstring& aData, bool aDOE)
+txTextHandler::characters(const nsAString& aData, bool aDOE)
 {
     if (mLevel == 0)
         mValue.Append(aData);
 
     return NS_OK;
 }
 
 nsresult
@@ -75,16 +75,16 @@ txTextHandler::startElement(nsIAtom* aPr
 {
     if (mOnlyText)
         ++mLevel;
 
     return NS_OK;
 }
 
 nsresult
-txTextHandler::startElement(nsIAtom* aPrefix, const nsSubstring& aLocalName,
+txTextHandler::startElement(nsIAtom* aPrefix, const nsAString& aLocalName,
                             const int32_t aNsID)
 {
     if (mOnlyText)
         ++mLevel;
 
     return NS_OK;
 }
--- a/dom/xslt/xslt/txUnknownHandler.cpp
+++ b/dom/xslt/xslt/txUnknownHandler.cpp
@@ -33,26 +33,26 @@ txUnknownHandler::attribute(nsIAtom* aPr
     return mFlushed ?
            mEs->mResultHandler->attribute(aPrefix, aLocalName,
                                           aLowercaseLocalName, aNsID, aValue) :
            txBufferingHandler::attribute(aPrefix, aLocalName,
                                          aLowercaseLocalName, aNsID, aValue);
 }
 
 nsresult
-txUnknownHandler::attribute(nsIAtom* aPrefix, const nsSubstring& aLocalName,
+txUnknownHandler::attribute(nsIAtom* aPrefix, const nsAString& aLocalName,
                             const int32_t aNsID, const nsString& aValue)
 {
     return mFlushed ?
            mEs->mResultHandler->attribute(aPrefix, aLocalName, aNsID, aValue) :
            txBufferingHandler::attribute(aPrefix, aLocalName, aNsID, aValue);
 }
 
 nsresult
-txUnknownHandler::characters(const nsSubstring& aData, bool aDOE)
+txUnknownHandler::characters(const nsAString& aData, bool aDOE)
 {
     return mFlushed ?
            mEs->mResultHandler->characters(aData, aDOE) :
            txBufferingHandler::characters(aData, aDOE);
 }
 
 nsresult
 txUnknownHandler::comment(const nsString& aData)
@@ -142,17 +142,17 @@ txUnknownHandler::startElement(nsIAtom* 
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     return mEs->mResultHandler->startElement(aPrefix, aLocalName,
                                              aLowercaseLocalName, aNsID);
 }
 
 nsresult
-txUnknownHandler::startElement(nsIAtom* aPrefix, const nsSubstring& aLocalName,
+txUnknownHandler::startElement(nsIAtom* aPrefix, const nsAString& aLocalName,
                                const int32_t aNsID)
 {
     if (!mFlushed) {
         // Make sure that mEs->mResultHandler == this is true, otherwise we'll
         // leak mEs->mResultHandler in createHandlerAndFlush.
         NS_ASSERTION(mEs->mResultHandler == this,
                      "We're leaking mEs->mResultHandler.");
 
@@ -162,17 +162,17 @@ txUnknownHandler::startElement(nsIAtom* 
         nsresult rv = createHandlerAndFlush(htmlRoot, aLocalName, aNsID);
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
     return mEs->mResultHandler->startElement(aPrefix, aLocalName, aNsID);
 }
 
 nsresult txUnknownHandler::createHandlerAndFlush(bool aHTMLRoot,
-                                                 const nsSubstring& aName,
+                                                 const nsAString& aName,
                                                  const int32_t aNsID)
 {
     NS_ENSURE_TRUE(mBuffer, NS_ERROR_NOT_INITIALIZED);
 
     txOutputFormat format;
     format.merge(*(mEs->mStylesheet->getOutputFormat()));
     if (format.mMethod == eMethodNotSet) {
         format.mMethod = aHTMLRoot ? eHTMLOutput : eXMLOutput;
--- a/dom/xslt/xslt/txUnknownHandler.h
+++ b/dom/xslt/xslt/txUnknownHandler.h
@@ -16,17 +16,17 @@ class txUnknownHandler : public txBuffer
 public:
     explicit txUnknownHandler(txExecutionState* aEs);
     virtual ~txUnknownHandler();
 
     TX_DECL_TXAXMLEVENTHANDLER
 
 private:
     nsresult createHandlerAndFlush(bool aHTMLRoot,
-                                   const nsSubstring& aName,
+                                   const nsAString& aName,
                                    const int32_t aNsID);
 
     /*
      * XXX we shouldn't hold to the txExecutionState, as we're supposed
      * to live without it. But as a standalone handler, we don't.
      * The right fix may need a txOutputFormat here.
      */
     txExecutionState* mEs;
--- a/dom/xslt/xslt/txXMLEventHandler.h
+++ b/dom/xslt/xslt/txXMLEventHandler.h
@@ -42,27 +42,27 @@ public:
      * Signals to receive the start of an attribute.
      *
      * @param aPrefix the prefix of the attribute
      * @param aLocalName the localname of the attribute
      * @param aNsID the namespace ID of the attribute
      * @param aValue the value of the attribute
      */
     virtual nsresult attribute(nsIAtom* aPrefix,
-                               const nsSubstring& aLocalName,
+                               const nsAString& aLocalName,
                                const int32_t aNsID,
                                const nsString& aValue) = 0;
 
     /**
      * Signals to receive characters.
      *
      * @param aData the characters to receive
      * @param aDOE disable output escaping for these characters
      */
-    virtual nsresult characters(const nsSubstring& aData, bool aDOE) = 0;
+    virtual nsresult characters(const nsAString& aData, bool aDOE) = 0;
 
     /**
      * Signals to receive data that should be treated as a comment.
      *
      * @param data the comment data to receive
      */
     virtual nsresult comment(const nsString& aData) = 0;
 
@@ -108,41 +108,41 @@ public:
      * Signals to receive the start of an element. Can throw
      * NS_ERROR_XSLT_BAD_NODE_NAME if the name is invalid
      *
      * @param aPrefix the prefix of the element
      * @param aLocalName the localname of the element
      * @param aNsID the namespace ID of the element
      */
     virtual nsresult startElement(nsIAtom* aPrefix,
-                                  const nsSubstring& aLocalName,
+                                  const nsAString& aLocalName,
                                   const int32_t aNsID) = 0;
 };
 
 #define TX_DECL_TXAXMLEVENTHANDLER                                           \
     virtual nsresult attribute(nsIAtom* aPrefix, nsIAtom* aLocalName,        \
                                nsIAtom* aLowercaseLocalName, int32_t aNsID,  \
                                const nsString& aValue);                      \
     virtual nsresult attribute(nsIAtom* aPrefix,                             \
-                               const nsSubstring& aLocalName,                \
+                               const nsAString& aLocalName,                  \
                                const int32_t aNsID,                          \
                                const nsString& aValue);                      \
-    virtual nsresult characters(const nsSubstring& aData, bool aDOE);      \
+    virtual nsresult characters(const nsAString& aData, bool aDOE);          \
     virtual nsresult comment(const nsString& aData);                         \
     virtual nsresult endDocument(nsresult aResult = NS_OK);                  \
     virtual nsresult endElement();                                           \
     virtual nsresult processingInstruction(const nsString& aTarget,          \
                                            const nsString& aData);           \
     virtual nsresult startDocument();                                        \
     virtual nsresult startElement(nsIAtom* aPrefix,                          \
                                   nsIAtom* aLocalName,                       \
                                   nsIAtom* aLowercaseLocalName,              \
                                   int32_t aNsID);                            \
     virtual nsresult startElement(nsIAtom* aPrefix,                          \
-                                  const nsSubstring& aName,                  \
+                                  const nsAString& aName,                    \
                                   const int32_t aNsID);
 
 
 class txAOutputXMLEventHandler : public txAXMLEventHandler
 {
 public:
     /**
      * Gets the Mozilla output document
@@ -177,22 +177,22 @@ public:
      * name and namespace for the root element.
      * @param aFromat  format to get handler for
      * @param aName    name of the root element
      * @param aNsID    namespace-id of the root element
      * @param aHandler outparam. The created handler
      */
     virtual nsresult
     createHandlerWith(txOutputFormat* aFormat,
-                      const nsSubstring& aName,
+                      const nsAString& aName,
                       int32_t aNsID,
                       txAXMLEventHandler** aHandler) = 0;
 };
 
 #define TX_DECL_TXAOUTPUTHANDLERFACTORY                        \
     nsresult createHandlerWith(txOutputFormat* aFormat,        \
                                txAXMLEventHandler** aHandler); \
     nsresult createHandlerWith(txOutputFormat* aFormat,        \
-                               const nsSubstring& aName,       \
+                               const nsAString& aName,         \
                                int32_t aNsID,                  \
                                txAXMLEventHandler** aHandler);
 
 #endif
--- a/dom/xslt/xslt/txXSLTPatterns.cpp
+++ b/dom/xslt/xslt/txXSLTPatterns.cpp
@@ -295,17 +295,17 @@ txRootPattern::toString(nsAString& aDest
 /*
  * txIdPattern
  *
  * txIdPattern matches if the given node has a ID attribute with one
  * of the space delimited values.
  * This looks like the id() function, but may only have LITERALs as
  * argument.
  */
-txIdPattern::txIdPattern(const nsSubstring& aString)
+txIdPattern::txIdPattern(const nsAString& aString)
 {
     nsWhitespaceTokenizer tokenizer(aString);
     while (tokenizer.hasMoreTokens()) {
         // this can fail, XXX move to a Init(aString) method
         nsCOMPtr<nsIAtom> atom = NS_Atomize(tokenizer.nextToken());
         mIds.AppendObject(atom);
     }
 }
--- a/dom/xslt/xslt/txXSLTPatterns.h
+++ b/dom/xslt/xslt/txXSLTPatterns.h
@@ -183,17 +183,17 @@ private:
     // Don't serialize txRootPattern if it's used in a txLocPathPattern
     bool mSerialize;
 #endif
 };
 
 class txIdPattern : public txPattern
 {
 public:
-    explicit txIdPattern(const nsSubstring& aString);
+    explicit txIdPattern(const nsAString& aString);
 
     TX_DECL_PATTERN;
 
 private:
     nsCOMArray<nsIAtom> mIds;
 };
 
 class txKeyPattern : public txPattern
--- a/extensions/permissions/nsContentBlocker.cpp
+++ b/extensions/permissions/nsContentBlocker.cpp
@@ -341,31 +341,31 @@ nsContentBlocker::TestPermission(nsIURI 
     // If there are no two dots found, ++dot will turn to zero,
     // that will return the entire string.
     int32_t dot = currentHost.RFindChar('.');
     dot = currentHost.RFindChar('.', dot-1);
     ++dot;
 
     // Get the domain, ie the last part of the host (www.domain.com -> domain.com)
     // This will break on co.uk
-    const nsCSubstring &tail =
+    const nsACString& tail =
       Substring(currentHost, dot, currentHost.Length() - dot);
 
     nsAutoCString firstHost;
     rv = aFirstURI->GetAsciiHost(firstHost);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // If the tail is longer then the whole firstHost, it will never match
     if (firstHost.Length() < tail.Length()) {
       *aPermission = false;
       return NS_OK;
     }
     
     // Get the last part of the firstUri with the same length as |tail|
-    const nsCSubstring &firstTail = 
+    const nsACString& firstTail =
       Substring(firstHost, firstHost.Length() - tail.Length(), tail.Length());
 
     // Check that both tails are the same, and that just before the tail in
     // |firstUri| there is a dot. That means both url are in the same domain
     if ((firstHost.Length() > tail.Length() && 
          firstHost.CharAt(firstHost.Length() - tail.Length() - 1) != '.') || 
         !tail.Equals(firstTail)) {
       *aPermission = false;
--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
@@ -264,17 +264,17 @@ mozInlineSpellWordUtil::GetRangeForWord(
   int32_t wordIndex = FindRealWordContaining(offset, HINT_BEGIN, false);
   if (wordIndex < 0)
     return MakeRange(pt, pt, aRange);
   return MakeRangeForWord(mRealWords[wordIndex], aRange);
 }
 
 // This is to fix characters that the spellchecker may not like
 static void
-NormalizeWord(const nsSubstring& aInput, int32_t aPos, int32_t aLen, nsAString& aOutput)
+NormalizeWord(const nsAString& aInput, int32_t aPos, int32_t aLen, nsAString& aOutput)
 {
   aOutput.Truncate();
   for (int32_t i = 0; i < aLen; i++) {
     char16_t ch = aInput.CharAt(i + aPos);
 
     // remove ignorable characters from the word
     if (IsIgnorableCharacter(ch))
       continue;
@@ -731,17 +731,17 @@ CheckLeavingBreakElement(nsINode* aNode,
   CheckLeavingBreakElementClosure* cl =
     static_cast<CheckLeavingBreakElementClosure*>(aClosure);
   if (!cl->mLeftBreakElement && IsBreakElement(aNode)) {
     cl->mLeftBreakElement = true;
   }
 }
 
 void
-mozInlineSpellWordUtil::NormalizeWord(nsSubstring& aWord)
+mozInlineSpellWordUtil::NormalizeWord(nsAString& aWord)
 {
   nsAutoString result;
   ::NormalizeWord(aWord, 0, aWord.Length(), result);
   aWord = result;
 }
 
 void
 mozInlineSpellWordUtil::BuildSoftText()
--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.h
+++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.h
@@ -85,17 +85,17 @@ public:
   // An empty word and a nullptr range are returned when we are done checking.
   // aSkipChecking will be set if the word is "special" and shouldn't be
   // checked (e.g., an email address).
   nsresult GetNextWord(nsAString& aText, nsRange** aRange,
                        bool* aSkipChecking);
 
   // Call to normalize some punctuation. This function takes an autostring
   // so we can access characters directly.
-  static void NormalizeWord(nsSubstring& aWord);
+  static void NormalizeWord(nsAString& aWord);
 
   nsIDOMDocument* GetDOMDocument() const { return mDOMDocument; }
   nsIDocument* GetDocument() const { return mDocument; }
   nsINode* GetRootNode() { return mRootNode; }
   
 private:
 
   // cached stuff for the editor, set by Init
--- a/gfx/src/nsFont.h
+++ b/gfx/src/nsFont.h
@@ -9,17 +9,17 @@
 #include <stdint.h>                     // for uint8_t, uint16_t
 #include <sys/types.h>                  // for int16_t
 #include "gfxFontFamilyList.h"
 #include "gfxFontConstants.h"           // for NS_FONT_KERNING_AUTO, etc
 #include "gfxFontFeatures.h"
 #include "gfxFontVariations.h"
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "nsCoord.h"                    // for nscoord
-#include "nsStringFwd.h"                // for nsSubstring
+#include "nsStringFwd.h"                // for nsAString
 #include "nsString.h"               // for nsString
 #include "nsTArray.h"                   // for nsTArray
 
 struct gfxFontStyle;
 
 // XXX we need a method to enumerate all of the possible fonts on the
 // system across family, weight, style, size, etc. But not here!
 
--- a/intl/locale/LocaleService.cpp
+++ b/intl/locale/LocaleService.cpp
@@ -696,17 +696,17 @@ LocaleService::NegotiateLanguages(const 
 LocaleService::Locale::Locale(const nsCString& aLocale, bool aRange)
   : mLocaleStr(aLocale)
 {
   int32_t partNum = 0;
 
   nsAutoCString normLocale(aLocale);
   normLocale.ReplaceChar('_', '-');
 
-  for (const nsCSubstring& part : normLocale.Split('-')) {
+  for (const nsACString& part : normLocale.Split('-')) {
     switch (partNum) {
       case 0:
         if (part.EqualsLiteral("*") ||
             part.Length() == 2 || part.Length() == 3) {
           mLanguage.Assign(part);
         }
         break;
       case 1:
--- a/layout/base/nsCounterManager.cpp
+++ b/layout/base/nsCounterManager.cpp
@@ -231,17 +231,17 @@ nsCounterManager::AddResetOrIncrement(ns
   // anyway, and trying to calculate with a dirty list doesn't work.
   if (MOZ_LIKELY(!counterList->IsDirty())) {
     node->Calc(counterList);
   }
   return false;
 }
 
 nsCounterList*
-nsCounterManager::CounterListFor(const nsSubstring& aCounterName)
+nsCounterManager::CounterListFor(const nsAString& aCounterName)
 {
   return mNames.LookupForAdd(aCounterName).OrInsert([]() {
     return new nsCounterList();
   });
 }
 
 void
 nsCounterManager::RecalcAll()
--- a/layout/base/nsCounterManager.h
+++ b/layout/base/nsCounterManager.h
@@ -207,17 +207,17 @@ private:
  */
 class nsCounterManager {
 public:
     // Returns true if dirty
     bool AddCounterResetsAndIncrements(nsIFrame *aFrame);
 
     // Gets the appropriate counter list, creating it if necessary.
     // Guaranteed to return non-null. (Uses an infallible hashtable API.)
-    nsCounterList* CounterListFor(const nsSubstring& aCounterName);
+    nsCounterList* CounterListFor(const nsAString& aCounterName);
 
     // Clean up data in any dirty counter lists.
     void RecalcAll();
 
     // Set all counter lists dirty
     void SetAllDirty();
 
     // Destroy nodes for the frame in any lists, and return whether any
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -2175,17 +2175,17 @@ struct MOZ_STACK_CLASS nsGridContainerFr
   }
 
   /**
    * A convenience method to lookup a name in 'grid-template-areas'.
    * @param aStyle the StylePosition() for the grid container
    * @return null if not found
    */
   static const css::GridNamedArea*
-  FindNamedArea(const nsSubstring& aName, const nsStylePosition* aStyle)
+  FindNamedArea(const nsAString& aName, const nsStylePosition* aStyle)
   {
     if (!aStyle->mGridTemplateAreas) {
       return nullptr;
     }
     const nsTArray<css::GridNamedArea>& areas =
       aStyle->mGridTemplateAreas->mNamedAreas;
     size_t len = areas.Length();
     for (size_t i = 0; i < len; ++i) {
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -47,45 +47,45 @@ struct PadType
 // The spec requires user agents to support at least 60 Unicode code-
 // points for counter text. However, this constant only limits the
 // length in 16-bit units. So it has to be at least 120, since code-
 // points outside the BMP will need 2 16-bit units.
 #define LENGTH_LIMIT 150
 
 static bool
 GetCyclicCounterText(CounterValue aOrdinal,
-                     nsSubstring& aResult,
+                     nsAString& aResult,
                      const nsTArray<nsString>& aSymbols)
 {
   MOZ_ASSERT(aSymbols.Length() >= 1,
              "No symbol available for cyclic counter.");
   auto n = aSymbols.Length();
   CounterValue index = (aOrdinal - 1) % n;
   aResult = aSymbols[index >= 0 ? index : index + n];
   return true;
 }
 
 static bool
 GetFixedCounterText(CounterValue aOrdinal,
-                    nsSubstring& aResult,
+                    nsAString& aResult,
                     CounterValue aStart,
                     const nsTArray<nsString>& aSymbols)
 {
   CounterValue index = aOrdinal - aStart;
   if (index >= 0 && index < CounterValue(aSymbols.Length())) {
     aResult = aSymbols[index];
     return true;
   } else {
     return false;
   }
 }
 
 static bool
 GetSymbolicCounterText(CounterValue aOrdinal,
-                       nsSubstring& aResult,
+                       nsAString& aResult,
                        const nsTArray<nsString>& aSymbols)
 {
   MOZ_ASSERT(aSymbols.Length() >= 1,
              "No symbol available for symbolic counter.");
   MOZ_ASSERT(aOrdinal >= 0, "Invalid ordinal.");
   if (aOrdinal == 0) {
     return false;
   }
@@ -104,17 +104,17 @@ GetSymbolicCounterText(CounterValue aOrd
       aResult.Append(symbol);
     }
   }
   return true;
 }
 
 static bool
 GetAlphabeticCounterText(CounterValue aOrdinal,
-                         nsSubstring& aResult,
+                         nsAString& aResult,
                          const nsTArray<nsString>& aSymbols)
 {
   MOZ_ASSERT(aSymbols.Length() >= 2,
              "Too few symbols for alphabetic counter.");
   MOZ_ASSERT(aOrdinal >= 0, "Invalid ordinal.");
   if (aOrdinal == 0) {
     return false;
   }
@@ -134,17 +134,17 @@ GetAlphabeticCounterText(CounterValue aO
   for (auto i = indexes.Length(); i > 0; --i) {
     aResult.Append(aSymbols[indexes[i - 1]]);
   }
   return true;
 }
 
 static bool
 GetNumericCounterText(CounterValue aOrdinal,
-                      nsSubstring& aResult,
+                      nsAString& aResult,
                       const nsTArray<nsString>& aSymbols)
 {
   MOZ_ASSERT(aSymbols.Length() >= 2,
              "Too few symbols for numeric counter.");
   MOZ_ASSERT(aOrdinal >= 0, "Invalid ordinal.");
 
   if (aOrdinal == 0) {
     aResult = aSymbols[0];
@@ -162,17 +162,17 @@ GetNumericCounterText(CounterValue aOrdi
   for (auto i = indexes.Length(); i > 0; --i) {
     aResult.Append(aSymbols[indexes[i - 1]]);
   }
   return true;
 }
 
 static bool
 GetAdditiveCounterText(CounterValue aOrdinal,
-                       nsSubstring& aResult,
+                       nsAString& aResult,
                        const nsTArray<AdditiveSymbol>& aSymbols)
 {
   MOZ_ASSERT(aOrdinal >= 0, "Invalid ordinal.");
 
   if (aOrdinal == 0) {
     const AdditiveSymbol& last = aSymbols.LastElement();
     if (last.weight == 0) {
       aResult = last.symbol;
@@ -204,17 +204,17 @@ GetAdditiveCounterText(CounterValue aOrd
       }
       aOrdinal -= times * symbol.weight;
     }
   }
   return aOrdinal == 0;
 }
 
 static bool
-DecimalToText(CounterValue aOrdinal, nsSubstring& aResult)
+DecimalToText(CounterValue aOrdinal, nsAString& aResult)
 {
   aResult.AppendInt(aOrdinal);
   return true;
 }
 
 // We know cjk-ideographic need 31 characters to display 99,999,999,999,999,999
 // georgian needs 6 at most
 // armenian needs 12 at most
@@ -319,17 +319,17 @@ static const CJKIdeographicData gDataTra
   },
   { 0x62fe, 0x4f70, 0x4edf }, // unit
   { 0x842c, 0x5104 },         // unit10K
   CHINESE,                    // lang
   false                       // informal
 };
 
 static bool
-CJKIdeographicToText(CounterValue aOrdinal, nsSubstring& aResult,
+CJKIdeographicToText(CounterValue aOrdinal, nsAString& aResult,
                      const CJKIdeographicData& data)
 {
   NS_ASSERTION(aOrdinal >= 0, "Only accept non-negative ordinal");
   char16_t buf[NUM_BUF_SIZE];
   int32_t idx = NUM_BUF_SIZE;
   int32_t pos = 0;
   bool needZero = (aOrdinal == 0);
   int32_t unitidx = 0, unit10Kidx = 0;
@@ -402,17 +402,17 @@ static const char16_t gHebrewDigit[22] =
   0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8,
   //  10      20      30      40      50      60      70      80      90
   0x05D9, 0x05DB, 0x05DC, 0x05DE, 0x05E0, 0x05E1, 0x05E2, 0x05E4, 0x05E6,
   // 100     200     300     400
   0x05E7, 0x05E8, 0x05E9, 0x05EA
 };
 
 static bool
-HebrewToText(CounterValue aOrdinal, nsSubstring& aResult)
+HebrewToText(CounterValue aOrdinal, nsAString& aResult)
 {
   if (aOrdinal < 1 || aOrdinal > 999999) {
     return false;
   }
 
   bool outputSep = false;
   nsAutoString allText, thousandsGroup;
   do {
@@ -471,17 +471,17 @@ HebrewToText(CounterValue aOrdinal, nsSu
 // Daniel Yacob <yacob@geez.org>.
 // Another reference is Unicode 3.0 standard section 11.1.
 #define ETHIOPIC_ONE             0x1369
 #define ETHIOPIC_TEN             0x1372
 #define ETHIOPIC_HUNDRED         0x137B
 #define ETHIOPIC_TEN_THOUSAND    0x137C
 
 static bool
-EthiopicToText(CounterValue aOrdinal, nsSubstring& aResult)
+EthiopicToText(CounterValue aOrdinal, nsAString& aResult)
 {
   if (aOrdinal < 1) {
     return false;
   }
 
   nsAutoString asciiNumberString;      // decimal string representation of ordinal
   DecimalToText(aOrdinal, asciiNumberString);
   uint8_t asciiStringLength = asciiNumberString.Length();
@@ -585,57 +585,57 @@ public:
 
 protected:
   constexpr explicit BuiltinCounterStyle(int32_t aStyle)
     : CounterStyle(aStyle)
   {
   }
 
 public:
-  virtual void GetStyleName(nsSubstring& aResult) override;
-  virtual void GetPrefix(nsSubstring& aResult) override;
-  virtual void GetSuffix(nsSubstring& aResult) override;
+  virtual void GetStyleName(nsAString& aResult) override;
+  virtual void GetPrefix(nsAString& aResult) override;
+  virtual void GetSuffix(nsAString& aResult) override;
   virtual void GetSpokenCounterText(CounterValue aOrdinal,
                                     WritingMode aWritingMode,
-                                    nsSubstring& aResult,
+                                    nsAString& aResult,
                                     bool& aIsBullet) override;
   virtual bool IsBullet() override;
 
   virtual void GetNegative(NegativeType& aResult) override;
   virtual bool IsOrdinalInRange(CounterValue aOrdinal) override;
   virtual bool IsOrdinalInAutoRange(CounterValue aOrdinal) override;
   virtual void GetPad(PadType& aResult) override;
   virtual CounterStyle* GetFallback() override;
   virtual uint8_t GetSpeakAs() override;
   virtual bool UseNegativeSign() override;
 
   virtual bool GetInitialCounterText(CounterValue aOrdinal,
                                      WritingMode aWritingMode,
-                                     nsSubstring& aResult,
+                                     nsAString& aResult,
                                      bool& aIsRTL) override;
 };
 
 /* virtual */ void
-BuiltinCounterStyle::GetStyleName(nsSubstring& aResult)
+BuiltinCounterStyle::GetStyleName(nsAString& aResult)
 {
   MOZ_ASSERT(mStyle != NS_STYLE_LIST_STYLE_CUSTOM);
   const nsCString& str =
     nsCSSProps::ValueToKeyword(mStyle, nsCSSProps::kListStyleKTable);
   MOZ_ASSERT(!str.IsEmpty());
   aResult.Assign(NS_ConvertUTF8toUTF16(str));
 }
 
 /* virtual */ void
-BuiltinCounterStyle::GetPrefix(nsSubstring& aResult)
+BuiltinCounterStyle::GetPrefix(nsAString& aResult)
 {
   aResult.Truncate();
 }
 
 /* virtual */ void
-BuiltinCounterStyle::GetSuffix(nsSubstring& aResult)
+BuiltinCounterStyle::GetSuffix(nsAString& aResult)
 {
   switch (mStyle) {
     case NS_STYLE_LIST_STYLE_NONE:
       aResult.Truncate();
       break;
 
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
@@ -672,17 +672,17 @@ static const char16_t kCircleCharacter =
 static const char16_t kSquareCharacter = 0x25fe;
 static const char16_t kRightPointingCharacter = 0x25b8;
 static const char16_t kLeftPointingCharacter = 0x25c2;
 static const char16_t kDownPointingCharacter = 0x25be;
 
 /* virtual */ void
 BuiltinCounterStyle::GetSpokenCounterText(CounterValue aOrdinal,
                                           WritingMode aWritingMode,
-                                          nsSubstring& aResult,
+                                          nsAString& aResult,
                                           bool& aIsBullet)
 {
   switch (mStyle) {
     case NS_STYLE_LIST_STYLE_NONE:
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
     case NS_STYLE_LIST_STYLE_SQUARE:
     case NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED:
@@ -878,17 +878,17 @@ BuiltinCounterStyle::UseNegativeSign()
     default:
       return true;
   }
 }
 
 /* virtual */ bool
 BuiltinCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
                                            WritingMode aWritingMode,
-                                           nsSubstring& aResult,
+                                           nsAString& aResult,
                                            bool& aIsRTL)
 {
   aIsRTL = false;
   switch (mStyle) {
     // used by counters & extends counter-style code only
     // XXX We really need to do this the same way we do list bullets.
     case NS_STYLE_LIST_STYLE_NONE:
       aResult.Truncate();
@@ -1042,40 +1042,40 @@ public:
   // For counter style extends other, in addition, all fields will be
   // reset to uninitialized state. This method should be called when any
   // other counter style is added, removed, or changed.
   void ResetDependentData();
 
   nsCSSCounterStyleRule* GetRule() const { return mRule; }
   uint32_t GetRuleGeneration() const { return mRuleGeneration; }
 
-  virtual void GetStyleName(nsSubstring& aResult) override;
-  virtual void GetPrefix(nsSubstring& aResult) override;
-  virtual void GetSuffix(nsSubstring& aResult) override;
+  virtual void GetStyleName(nsAString& aResult) override;
+  virtual void GetPrefix(nsAString& aResult) override;
+  virtual void GetSuffix(nsAString& aResult) override;
   virtual void GetSpokenCounterText(CounterValue aOrdinal,
                                     WritingMode aWritingMode,
-                                    nsSubstring& aResult,
+                                    nsAString& aResult,
                                     bool& aIsBullet) override;
   virtual bool IsBullet() override;
 
   virtual void GetNegative(NegativeType& aResult) override;
   virtual bool IsOrdinalInRange(CounterValue aOrdinal) override;
   virtual bool IsOrdinalInAutoRange(CounterValue aOrdinal) override;
   virtual void GetPad(PadType& aResult) override;
   virtual CounterStyle* GetFallback() override;
   virtual uint8_t GetSpeakAs() override;
   virtual bool UseNegativeSign() override;
 
   virtual void CallFallbackStyle(CounterValue aOrdinal,
                                  WritingMode aWritingMode,
-                                 nsSubstring& aResult,
+                                 nsAString& aResult,
                                  bool& aIsRTL) override;
   virtual bool GetInitialCounterText(CounterValue aOrdinal,
                                      WritingMode aWritingMode,
-                                     nsSubstring& aResult,
+                                     nsAString& aResult,
                                      bool& aIsRTL) override;
 
   bool IsExtendsSystem()
   {
     return mSystem == NS_STYLE_COUNTER_SYSTEM_EXTENDS;
   }
 
   void* operator new(size_t sz, nsPresContext* aPresContext)
@@ -1200,24 +1200,24 @@ CustomCounterStyle::ResetDependentData()
     mFlags &= ~(FLAG_NEGATIVE_INITED |
                 FLAG_PREFIX_INITED |
                 FLAG_SUFFIX_INITED |
                 FLAG_PAD_INITED);
   }
 }
 
 /* virtual */ void
-CustomCounterStyle::GetStyleName(nsSubstring& aResult)
+CustomCounterStyle::GetStyleName(nsAString& aResult)
 {
   nsDependentAtomString name(mName);
   aResult.Assign(name);
 }
 
 /* virtual */ void
-CustomCounterStyle::GetPrefix(nsSubstring& aResult)
+CustomCounterStyle::GetPrefix(nsAString& aResult)
 {
   if (!(mFlags & FLAG_PREFIX_INITED)) {
     mFlags |= FLAG_PREFIX_INITED;
 
     const nsCSSValue& value = mRule->GetDesc(eCSSCounterDesc_Prefix);
     if (value.UnitHasStringValue()) {
       value.GetStringValue(mPrefix);
     } else if (IsExtendsSystem()) {
@@ -1225,17 +1225,17 @@ CustomCounterStyle::GetPrefix(nsSubstrin
     } else {
       mPrefix.Truncate();
     }
   }
   aResult = mPrefix;
 }
 
 /* virtual */ void
-CustomCounterStyle::GetSuffix(nsSubstring& aResult)
+CustomCounterStyle::GetSuffix(nsAString& aResult)
 {
   if (!(mFlags & FLAG_SUFFIX_INITED)) {
     mFlags |= FLAG_SUFFIX_INITED;
 
     const nsCSSValue& value = mRule->GetDesc(eCSSCounterDesc_Suffix);
     if (value.UnitHasStringValue()) {
       value.GetStringValue(mSuffix);
     } else if (IsExtendsSystem()) {
@@ -1245,17 +1245,17 @@ CustomCounterStyle::GetSuffix(nsSubstrin
     }
   }
   aResult = mSuffix;
 }
 
 /* virtual */ void
 CustomCounterStyle::GetSpokenCounterText(CounterValue aOrdinal,
                                          WritingMode aWritingMode,
-                                         nsSubstring& aResult,
+                                         nsAString& aResult,
                                          bool& aIsBullet)
 {
   if (GetSpeakAs() != NS_STYLE_COUNTER_SPEAKAS_OTHER) {
     CounterStyle::GetSpokenCounterText(
         aOrdinal, aWritingMode, aResult, aIsBullet);
   } else {
     MOZ_ASSERT(mSpeakAsCounter,
                "mSpeakAsCounter should have been initialized.");
@@ -1416,31 +1416,31 @@ CustomCounterStyle::UseNegativeSign()
     return GetExtendsRoot()->UseNegativeSign();
   }
   return SystemUsesNegativeSign(mSystem);
 }
 
 /* virtual */ void
 CustomCounterStyle::CallFallbackStyle(CounterValue aOrdinal,
                                       WritingMode aWritingMode,
-                                      nsSubstring& aResult,
+                                      nsAString& aResult,
                                       bool& aIsRTL)
 {
   CounterStyle* fallback = GetFallback();
   // If it recursively falls back to this counter style again,
   // it will then fallback to decimal to break the loop.
   mFallback = CounterStyleManager::GetDecimalStyle();
   fallback->GetCounterText(aOrdinal, aWritingMode, aResult, aIsRTL);
   mFallback = fallback;
 }
 
 /* virtual */ bool
 CustomCounterStyle::GetInitialCounterText(CounterValue aOrdinal,
                                           WritingMode aWritingMode,
-                                          nsSubstring& aResult,
+                                          nsAString& aResult,
                                           bool& aIsRTL)
 {
   switch (mSystem) {
     case NS_STYLE_COUNTER_SYSTEM_CYCLIC:
       return GetCyclicCounterText(aOrdinal, aResult, GetSymbols());
     case NS_STYLE_COUNTER_SYSTEM_FIXED: {
       int32_t start = mRule->GetSystemArgument().GetIntValue();
       return GetFixedCounterText(aOrdinal, aResult, start, GetSymbols());
@@ -1687,17 +1687,17 @@ CustomCounterStyle::GetExtendsRoot()
         // is shared by multiple counter styles.
         mExtendsRoot = custom->GetExtendsRoot();
       }
     }
   }
   return mExtendsRoot;
 }
 
-AnonymousCounterStyle::AnonymousCounterStyle(const nsSubstring& aContent)
+AnonymousCounterStyle::AnonymousCounterStyle(const nsAString& aContent)
   : CounterStyle(NS_STYLE_LIST_STYLE_CUSTOM)
   , mSingleString(true)
   , mSystem(NS_STYLE_COUNTER_SYSTEM_CYCLIC)
 {
   mSymbols.SetCapacity(1);
   mSymbols.AppendElement(aContent);
 }
 
@@ -1862,17 +1862,17 @@ CounterStyle::IsDependentStyle() const
     default:
       return false;
   }
 }
 
 void
 CounterStyle::GetCounterText(CounterValue aOrdinal,
                              WritingMode aWritingMode,
-                             nsSubstring& aResult,
+                             nsAString& aResult,
                              bool& aIsRTL)
 {
   bool success = IsOrdinalInRange(aOrdinal);
   aIsRTL = false;
 
   if (success) {
     // generate initial representation
     bool useNegativeSign = UseNegativeSign();
@@ -1926,17 +1926,17 @@ CounterStyle::GetCounterText(CounterValu
   if (!success) {
     CallFallbackStyle(aOrdinal, aWritingMode, aResult, aIsRTL);
   }
 }
 
 /* virtual */ void
 CounterStyle::GetSpokenCounterText(CounterValue aOrdinal,
                                    WritingMode aWritingMode,
-                                   nsSubstring& aResult,
+                                   nsAString& aResult,
                                    bool& aIsBullet)
 {
   bool isRTL; // we don't care about direction for spoken text
   aIsBullet = false;
   switch (GetSpeakAs()) {
     case NS_STYLE_COUNTER_SPEAKAS_BULLETS:
       aResult.Assign(kDiscCharacter);
       aIsBullet = true;
--- a/layout/style/CounterStyleManager.h
+++ b/layout/style/CounterStyleManager.h
@@ -47,26 +47,26 @@ public:
   int32_t GetStyle() const { return mStyle; }
   bool IsNone() const { return mStyle == NS_STYLE_LIST_STYLE_NONE; }
   bool IsCustomStyle() const { return mStyle == NS_STYLE_LIST_STYLE_CUSTOM; }
   // A style is dependent if it depends on the counter style manager.
   // Custom styles are certainly dependent. In addition, some builtin
   // styles are dependent for fallback.
   bool IsDependentStyle() const;
 
-  virtual void GetStyleName(nsSubstring& aResult) = 0;
-  virtual void GetPrefix(nsSubstring& aResult) = 0;
-  virtual void GetSuffix(nsSubstring& aResult) = 0;
+  virtual void GetStyleName(nsAString& aResult) = 0;
+  virtual void GetPrefix(nsAString& aResult) = 0;
+  virtual void GetSuffix(nsAString& aResult) = 0;
   void GetCounterText(CounterValue aOrdinal,
                       WritingMode aWritingMode,
-                      nsSubstring& aResult,
+                      nsAString& aResult,
                       bool& aIsRTL);
   virtual void GetSpokenCounterText(CounterValue aOrdinal,
                                     WritingMode aWritingMode,
-                                    nsSubstring& aResult,
+                                    nsAString& aResult,
                                     bool& aIsBullet);
 
   // XXX This method could be removed once ::-moz-list-bullet and
   //     ::-moz-list-number are completely merged into ::marker.
   virtual bool IsBullet() = 0;
 
   virtual void GetNegative(NegativeType& aResult) = 0;
   /**
@@ -83,33 +83,33 @@ public:
   virtual bool IsOrdinalInAutoRange(CounterValue aOrdinal) = 0;
   virtual void GetPad(PadType& aResult) = 0;
   virtual CounterStyle* GetFallback() = 0;
   virtual uint8_t GetSpeakAs() = 0;
   virtual bool UseNegativeSign() = 0;
 
   virtual void CallFallbackStyle(CounterValue aOrdinal,
                                  WritingMode aWritingMode,
-                                 nsSubstring& aResult,
+                                 nsAString& aResult,
                                  bool& aIsRTL);
   virtual bool GetInitialCounterText(CounterValue aOrdinal,
                                      WritingMode aWritingMode,
-                                     nsSubstring& aResult,
+                                     nsAString& aResult,
                                      bool& aIsRTL) = 0;
 
   virtual AnonymousCounterStyle* AsAnonymous() { return nullptr; }
 
 protected:
   int32_t mStyle;
 };
 
 class AnonymousCounterStyle final : public CounterStyle
 {
 public:
-  explicit AnonymousCounterStyle(const nsSubstring& aContent);
+  explicit AnonymousCounterStyle(const nsAString& aContent);
   AnonymousCounterStyle(uint8_t aSystem, nsTArray<nsString> aSymbols);
   explicit AnonymousCounterStyle(const nsCSSValue::Array* aValue);
 
   virtual void GetStyleName(nsAString& aResult) override;
   virtual void GetPrefix(nsAString& aResult) override;
   virtual void GetSuffix(nsAString& aResult) override;
   virtual bool IsBullet() override;
 
@@ -118,17 +118,17 @@ public:
   virtual bool IsOrdinalInAutoRange(CounterValue aOrdinal) override;
   virtual void GetPad(PadType& aResult) override;
   virtual CounterStyle* GetFallback() override;
   virtual uint8_t GetSpeakAs() override;
   virtual bool UseNegativeSign() override;
 
   virtual bool GetInitialCounterText(CounterValue aOrdinal,
                                      WritingMode aWritingMode,
-                                     nsSubstring& aResult,
+                                     nsAString& aResult,
                                      bool& aIsRTL) override;
 
   virtual AnonymousCounterStyle* AsAnonymous() override { return this; }
 
   bool IsSingleString() const { return mSingleString; }
   uint8_t GetSystem() const { return mSystem; }
   const nsTArray<nsString>& GetSymbols() const { return mSymbols; }
 
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -121,17 +121,17 @@ class SheetLoadData final : public nsIRu
                             public nsIThreadObserver
 {
 protected:
   virtual ~SheetLoadData(void);
 
 public:
   // Data for loading a sheet linked from a document
   SheetLoadData(Loader* aLoader,
-                const nsSubstring& aTitle,
+                const nsAString& aTitle,
                 nsIURI* aURI,
                 StyleSheet* aSheet,
                 nsIStyleSheetLinkingElement* aOwningElement,
                 bool aIsAlternate,
                 nsICSSLoaderObserver* aObserver,
                 nsIPrincipal* aLoaderPrincipal,
                 nsINode* aRequestingNode);
 
@@ -297,17 +297,17 @@ static const char* const gStateStrings[]
 
 /********************************
  * SheetLoadData implementation *
  ********************************/
 NS_IMPL_ISUPPORTS(SheetLoadData, nsIUnicharStreamLoaderObserver, nsIRunnable,
                   nsIThreadObserver)
 
 SheetLoadData::SheetLoadData(Loader* aLoader,
-                             const nsSubstring& aTitle,
+                             const nsAString& aTitle,
                              nsIURI* aURI,
                              StyleSheet* aSheet,
                              nsIStyleSheetLinkingElement* aOwningElement,
                              bool aIsAlternate,
                              nsICSSLoaderObserver* aObserver,
                              nsIPrincipal* aLoaderPrincipal,
                              nsINode* aRequestingNode)
   : mLoader(aLoader),
@@ -1280,18 +1280,18 @@ Loader::CreateSheet(nsIURI* aURI,
 
 /**
  * PrepareSheet() handles setting the media and title on the sheet, as
  * well as setting the enabled state based on the title and whether
  * the sheet had "alternate" in its rel.
  */
 void
 Loader::PrepareSheet(StyleSheet* aSheet,
-                     const nsSubstring& aTitle,
-                     const nsSubstring& aMediaString,
+                     const nsAString& aTitle,
+                     const nsAString& aMediaString,
                      MediaList* aMediaList,
                      Element* aScopeElement,
                      bool aIsAlternate)
 {
   NS_PRECONDITION(aSheet, "Must have a sheet!");
 
   RefPtr<MediaList> mediaList(aMediaList);
 
@@ -2276,17 +2276,17 @@ Loader::LoadChildSheet(StyleSheet* aPare
   StyleSheetState state;
   if (aReusableSheets && aReusableSheets->FindReusableStyleSheet(aURL, sheet)) {
     if (aParentSheet->IsGecko()) {
       aGeckoParentRule->SetSheet(sheet->AsGecko());
     }
     state = eSheetComplete;
   } else {
     bool isAlternate;
-    const nsSubstring& empty = EmptyString();
+    const nsAString& empty = EmptyString();
     // For now, use CORS_NONE for child sheets
     rv = CreateSheet(aURL, nullptr, principal,
                      aParentSheet->ParsingMode(),
                      CORS_NONE, aParentSheet->GetReferrerPolicy(),
                      EmptyString(), // integrity is only checked on main sheet
                      parentData ? parentData->mSyncLoad : false,
                      false, empty, state, &isAlternate, &sheet);
     NS_ENSURE_SUCCESS(rv, rv);
@@ -2416,17 +2416,17 @@ Loader::InternalLoadNonDocumentSheet(nsI
 
   nsresult rv = CheckContentPolicy(aOriginPrincipal, aURL, mDocument, aIsPreload);
   NS_ENSURE_SUCCESS(rv, rv);
 
   StyleSheetState state;
   bool isAlternate;
   RefPtr<StyleSheet> sheet;
   bool syncLoad = (aObserver == nullptr);
-  const nsSubstring& empty = EmptyString();
+  const nsAString& empty = EmptyString();
 
   rv = CreateSheet(aURL, nullptr, aOriginPrincipal, aParsingMode,
                    aCORSMode, aReferrerPolicy, aIntegrity, syncLoad,
                    false, empty, state, &isAlternate, &sheet);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate);
 
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -36,17 +36,17 @@ struct AnimationEventInfo {
   RefPtr<dom::Element> mElement;
   RefPtr<dom::Animation> mAnimation;
   InternalAnimationEvent mEvent;
   TimeStamp mTimeStamp;
 
   AnimationEventInfo(dom::Element* aElement,
                      CSSPseudoElementType aPseudoType,
                      EventMessage aMessage,
-                     const nsSubstring& aAnimationName,
+                     const nsAString& aAnimationName,
                      const StickyTimeDuration& aElapsedTime,
                      const TimeStamp& aTimeStamp,
                      dom::Animation* aAnimation)
     : mElement(aElement)
     , mAnimation(aAnimation)
     , mEvent(true, aMessage)
     , mTimeStamp(aTimeStamp)
   {
@@ -71,17 +71,17 @@ struct AnimationEventInfo {
 };
 
 namespace dom {
 
 class CSSAnimation final : public Animation
 {
 public:
  explicit CSSAnimation(nsIGlobalObject* aGlobal,
-                       const nsSubstring& aAnimationName)
+                       const nsAString& aAnimationName)
     : dom::Animation(aGlobal)
     , mAnimationName(aAnimationName)
     , mIsStylePaused(false)
     , mPauseShouldStick(false)
     , mNeedsNewAnimationIndexWhenRun(false)
     , mPreviousPhase(ComputedTiming::AnimationPhase::Idle)
     , mPreviousIteration(0)
   {
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -197,17 +197,17 @@ public:
                              nsIURI* aBaseURL,
                              nsIPrincipal* aSheetPrincipal,
                              nsCSSValue& aValue);
 
   bool ParseTransformProperty(const nsAString& aPropValue,
                               bool aDisallowRelativeValues,
                               nsCSSValue& aResult);
 
-  void ParseMediaList(const nsSubstring& aBuffer,
+  void ParseMediaList(const nsAString& aBuffer,
                       nsIURI* aURL, // for error reporting
                       uint32_t aLineNumber, // for error reporting
                       nsMediaList* aMediaList);
 
   bool ParseSourceSizeList(const nsAString& aBuffer,
                            nsIURI* aURI, // for error reporting
                            uint32_t aLineNumber, // for error reporting
                            InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
@@ -217,44 +217,44 @@ public:
                      const nsAString& aPropValue,
                      nsIURI* aSheetURL,
                      nsIURI* aBaseURL,
                      nsIPrincipal* aSheetPrincipal,
                      css::Declaration* aDeclaration,
                      bool* aChanged,
                      bool aIsImportant);
 
-  bool ParseFontFamilyListString(const nsSubstring& aBuffer,
+  bool ParseFontFamilyListString(const nsAString& aBuffer,
                                  nsIURI* aURL, // for error reporting
                                  uint32_t aLineNumber, // for error reporting
                                  nsCSSValue& aValue);
 
-  bool ParseColorString(const nsSubstring& aBuffer,
+  bool ParseColorString(const nsAString& aBuffer,
                         nsIURI* aURL, // for error reporting
                         uint32_t aLineNumber, // for error reporting
                         nsCSSValue& aValue,
                         bool aSuppressErrors /* false */);
 
-  bool ParseMarginString(const nsSubstring& aBuffer,
+  bool ParseMarginString(const nsAString& aBuffer,
                          nsIURI* aURL, // for error reporting
                          uint32_t aLineNumber, // for error reporting
                          nsCSSValue& aValue,
                          bool aSuppressErrors /* false */);
 
-  nsresult ParseSelectorString(const nsSubstring& aSelectorString,
+  nsresult ParseSelectorString(const nsAString& aSelectorString,
                                nsIURI* aURL, // for error reporting
                                uint32_t aLineNumber, // for error reporting
                                nsCSSSelectorList **aSelectorList);
 
   already_AddRefed<nsCSSKeyframeRule>
-  ParseKeyframeRule(const nsSubstring& aBuffer,
+  ParseKeyframeRule(const nsAString& aBuffer,
                     nsIURI*            aURL,
                     uint32_t           aLineNumber);
 
-  bool ParseKeyframeSelectorString(const nsSubstring& aSelectorString,
+  bool ParseKeyframeSelectorString(const nsAString& aSelectorString,
                                    nsIURI* aURL, // for error reporting
                                    uint32_t aLineNumber, // for error reporting
                                    InfallibleTArray<float>& aSelectorList);
 
   bool EvaluateSupportsDeclaration(const nsAString& aProperty,
                                    const nsAString& aValue,
                                    nsIURI* aDocURL,
                                    nsIURI* aBaseURL,
@@ -527,17 +527,17 @@ protected:
     MOZ_ASSERT(GetNextTokenLocation(true, &lineAfter, &colAfter) &&
                lineAfter == aLine && colAfter == aCol,
                "shouldn't have consumed any tokens");
   }
 
   bool ExpectSymbol(char16_t aSymbol, bool aSkipWS);
   bool ExpectEndProperty();
   bool CheckEndProperty();
-  nsSubstring* NextIdent();
+  nsAString* NextIdent();
 
   // returns true when the stop symbol is found, and false for EOF
   bool SkipUntil(char16_t aStopSymbol);
   void SkipUntilOneOf(const char16_t* aStopSymbolChars);
   // For each character in aStopSymbolChars from the end of the array
   // to the start, calls SkipUntil with that character.
   typedef AutoTArray<char16_t, 16> StopSymbolCharStack;
   void SkipUntilAllOf(const StopSymbolCharStack& aStopSymbolChars);
@@ -1993,17 +1993,17 @@ CSSParserImpl::ParseVariable(const nsASt
   }
 
   mTempData.AssertInitialState();
 
   ReleaseScanner();
 }
 
 void
-CSSParserImpl::ParseMediaList(const nsSubstring& aBuffer,
+CSSParserImpl::ParseMediaList(const nsAString& aBuffer,
                               nsIURI* aURI, // for error reporting
                               uint32_t aLineNumber, // for error reporting
                               nsMediaList* aMediaList)
 {
   // XXX Are there cases where the caller wants to keep what it already
   // has in case of parser error?  If GatherMedia ever changes to return
   // a value other than true, we probably should avoid modifying aMediaList.
   aMediaList->Clear();
@@ -2106,17 +2106,17 @@ CSSParserImpl::ParseSourceSizeList(const
 
   CLEAR_ERROR();
   ReleaseScanner();
 
   return !aQueries.IsEmpty();
 }
 
 bool
-CSSParserImpl::ParseColorString(const nsSubstring& aBuffer,
+CSSParserImpl::ParseColorString(const nsAString& aBuffer,
                                 nsIURI* aURI, // for error reporting
                                 uint32_t aLineNumber, // for error reporting
                                 nsCSSValue& aValue,
                                 bool aSuppressErrors /* false */)
 {
   nsCSSScanner scanner(aBuffer, aLineNumber);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
   InitScanner(scanner, reporter, aURI, aURI, nullptr);
@@ -2133,17 +2133,17 @@ CSSParserImpl::ParseColorString(const ns
     OUTPUT_ERROR();
   }
 
   ReleaseScanner();
   return colorParsed;
 }
 
 bool
-CSSParserImpl::ParseMarginString(const nsSubstring& aBuffer,
+CSSParserImpl::ParseMarginString(const nsAString& aBuffer,
                                  nsIURI* aURI, // for error reporting
                                  uint32_t aLineNumber, // for error reporting
                                  nsCSSValue& aValue,
                                  bool aSuppressErrors /* false */)
 {
   nsCSSScanner scanner(aBuffer, aLineNumber);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
   InitScanner(scanner, reporter, aURI, aURI, nullptr);
@@ -2159,34 +2159,34 @@ CSSParserImpl::ParseMarginString(const n
     OUTPUT_ERROR();
   }
 
   ReleaseScanner();
   return marginParsed;
 }
 
 bool
-CSSParserImpl::ParseFontFamilyListString(const nsSubstring& aBuffer,
+CSSParserImpl::ParseFontFamilyListString(const nsAString& aBuffer,
                                          nsIURI* aURI, // for error reporting
                                          uint32_t aLineNumber, // for error reporting
                                          nsCSSValue& aValue)
 {
   nsCSSScanner scanner(aBuffer, aLineNumber);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
   InitScanner(scanner, reporter, aURI, aURI, nullptr);
 
   // Parse a font family list, and check that there's nothing else after it.
   bool familyParsed = ParseFamily(aValue) && !GetToken(true);
   OUTPUT_ERROR();
   ReleaseScanner();
   return familyParsed;
 }
 
 nsresult
-CSSParserImpl::ParseSelectorString(const nsSubstring& aSelectorString,
+CSSParserImpl::ParseSelectorString(const nsAString& aSelectorString,
                                    nsIURI* aURI, // for error reporting
                                    uint32_t aLineNumber, // for error reporting
                                    nsCSSSelectorList **aSelectorList)
 {
   nsCSSScanner scanner(aSelectorString, aLineNumber);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
   InitScanner(scanner, reporter, aURI, aURI, nullptr);
 
@@ -2210,17 +2210,17 @@ CSSParserImpl::ParseSelectorString(const
 
   NS_ASSERTION(!*aSelectorList, "Shouldn't have list!");
 
   return NS_ERROR_DOM_SYNTAX_ERR;
 }
 
 
 already_AddRefed<nsCSSKeyframeRule>
-CSSParserImpl::ParseKeyframeRule(const nsSubstring&  aBuffer,
+CSSParserImpl::ParseKeyframeRule(const nsAString&  aBuffer,
                                  nsIURI*             aURI,
                                  uint32_t            aLineNumber)
 {
   nsCSSScanner scanner(aBuffer, aLineNumber);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
   InitScanner(scanner, reporter, aURI, aURI, nullptr);
 
   RefPtr<nsCSSKeyframeRule> result = ParseKeyframeRule();
@@ -2231,17 +2231,17 @@ CSSParserImpl::ParseKeyframeRule(const n
 
   OUTPUT_ERROR();
   ReleaseScanner();
 
   return result.forget();
 }
 
 bool
-CSSParserImpl::ParseKeyframeSelectorString(const nsSubstring& aSelectorString,
+CSSParserImpl::ParseKeyframeSelectorString(const nsAString& aSelectorString,
                                            nsIURI* aURI, // for error reporting
                                            uint32_t aLineNumber, // for error reporting
                                            InfallibleTArray<float>& aSelectorList)
 {
   MOZ_ASSERT(aSelectorList.IsEmpty(), "given list should start empty");
 
   nsCSSScanner scanner(aSelectorString, aLineNumber);
   css::ErrorReporter reporter(scanner, mSheet, mChildLoader, aURI);
@@ -3123,17 +3123,17 @@ CSSParserImpl::ParsePriority()
     REPORT_UNEXPECTED_TOKEN(PEExpectedImportant);
     UngetToken();
     return ePriority_Error;
   }
 
   return ePriority_Important;
 }
 
-nsSubstring*
+nsAString*
 CSSParserImpl::NextIdent()
 {
   // XXX Error reporting?
   if (!GetToken(true)) {
     return nullptr;
   }
   if (eCSSToken_Ident != mToken.mType) {
     UngetToken();
@@ -7289,17 +7289,17 @@ static const nsCSSPropertyID kColumnRule
   eCSSProperty_column_rule_style,
   eCSSProperty_column_rule_color
 };
 
 bool
 CSSParserImpl::ParseEnum(nsCSSValue& aValue,
                          const KTableEntry aKeywordTable[])
 {
-  nsSubstring* ident = NextIdent();
+  nsAString* ident = NextIdent();
   if (nullptr == ident) {
     return false;
   }
   nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(*ident);
   int32_t value;
   if (nsCSSProps::FindKeyword(keyword, aKeywordTable, value)) {
     aValue.SetIntValue(value, eCSSUnit_Enumerated);
     return true;
@@ -7313,17 +7313,17 @@ CSSParserImpl::ParseEnum(nsCSSValue& aVa
 bool
 CSSParserImpl::ParseAlignEnum(nsCSSValue& aValue,
                               const KTableEntry aKeywordTable[])
 {
   MOZ_ASSERT(nsCSSProps::ValueToKeywordEnum(NS_STYLE_ALIGN_BASELINE,
                                             aKeywordTable) !=
                eCSSKeyword_UNKNOWN,
              "Please use ParseEnum instead");
-  nsSubstring* ident = NextIdent();
+  nsAString* ident = NextIdent();
   if (!ident) {
     return false;
   }
   nsCSSKeyword baselinePrefix = eCSSKeyword_first;
   nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(*ident);
   if (keyword == eCSSKeyword_first || keyword == eCSSKeyword_last) {
     baselinePrefix = keyword;
     ident = NextIdent();
@@ -9122,17 +9122,17 @@ bool
 CSSParserImpl::ParseGridTemplateColumnsRows(nsCSSPropertyID aPropID)
 {
   nsCSSValue value;
   if (ParseSingleTokenVariant(value, VARIANT_INHERIT | VARIANT_NONE, nullptr)) {
     AppendValue(aPropID, value);
     return true;
   }
 
-  nsSubstring* ident = NextIdent();
+  nsAString* ident = NextIdent();
   if (ident) {
     if (ident->LowerCaseEqualsLiteral("subgrid")) {
       if (!nsLayoutUtils::IsGridTemplateSubgridValueEnabled()) {
         REPORT_UNEXPECTED(PESubgridNotSupported);
         return false;
       }
       if (!ParseOptionalLineNameListAfterSubgrid(value)) {
         return false;
@@ -9310,17 +9310,17 @@ CSSParserImpl::ParseGridTemplate(bool aF
       return ParseGridTemplateColumnsOrAutoFlow(aForGridShorthand);
     }
     AppendValue(eCSSProperty_grid_template_columns, value);
     return true;
   }
 
   // 'subgrid' can appear either by itself,
   // or as the beginning of <'grid-template-rows'> / <'grid-template-columns'>
-  nsSubstring* ident = NextIdent();
+  nsAString* ident = NextIdent();
   if (ident) {
     if (ident->LowerCaseEqualsLiteral("subgrid")) {
       if (!nsLayoutUtils::IsGridTemplateSubgridValueEnabled()) {
         REPORT_UNEXPECTED(PESubgridNotSupported);
         return false;
       }
       if (!ParseOptionalLineNameListAfterSubgrid(value)) {
         return false;
@@ -17987,17 +17987,17 @@ nsCSSParser::ParseVariable(const nsAStri
                            bool                aIsImportant)
 {
   static_cast<CSSParserImpl*>(mImpl)->
     ParseVariable(aVariableName, aPropValue, aSheetURI, aBaseURI,
                   aSheetPrincipal, aDeclaration, aChanged, aIsImportant);
 }
 
 void
-nsCSSParser::ParseMediaList(const nsSubstring& aBuffer,
+nsCSSParser::ParseMediaList(const nsAString& aBuffer,
                             nsIURI*            aURI,
                             uint32_t           aLineNumber,
                             nsMediaList*       aMediaList)
 {
   static_cast<CSSParserImpl*>(mImpl)->
     ParseMediaList(aBuffer, aURI, aLineNumber, aMediaList);
 }
 
@@ -18008,68 +18008,68 @@ nsCSSParser::ParseSourceSizeList(const n
                                  InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
                                  InfallibleTArray<nsCSSValue>& aValues)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseSourceSizeList(aBuffer, aURI, aLineNumber, aQueries, aValues);
 }
 
 bool
-nsCSSParser::ParseFontFamilyListString(const nsSubstring& aBuffer,
+nsCSSParser::ParseFontFamilyListString(const nsAString& aBuffer,
                                        nsIURI*            aURI,
                                        uint32_t           aLineNumber,
                                        nsCSSValue&        aValue)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseFontFamilyListString(aBuffer, aURI, aLineNumber, aValue);
 }
 
 bool
-nsCSSParser::ParseColorString(const nsSubstring& aBuffer,
+nsCSSParser::ParseColorString(const nsAString& aBuffer,
                               nsIURI*            aURI,
                               uint32_t           aLineNumber,
                               nsCSSValue&        aValue,
                               bool               aSuppressErrors /* false */)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseColorString(aBuffer, aURI, aLineNumber, aValue, aSuppressErrors);
 }
 
 bool
-nsCSSParser::ParseMarginString(const nsSubstring& aBuffer,
+nsCSSParser::ParseMarginString(const nsAString& aBuffer,
                                nsIURI*            aURI,
                                uint32_t           aLineNumber,
                                nsCSSValue&        aValue,
                                bool               aSuppressErrors /* false */)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseMarginString(aBuffer, aURI, aLineNumber, aValue, aSuppressErrors);
 }
 
 nsresult
-nsCSSParser::ParseSelectorString(const nsSubstring&  aSelectorString,
+nsCSSParser::ParseSelectorString(const nsAString&  aSelectorString,
                                  nsIURI*             aURI,
                                  uint32_t            aLineNumber,
                                  nsCSSSelectorList** aSelectorList)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseSelectorString(aSelectorString, aURI, aLineNumber, aSelectorList);
 }
 
 already_AddRefed<nsCSSKeyframeRule>
-nsCSSParser::ParseKeyframeRule(const nsSubstring& aBuffer,
+nsCSSParser::ParseKeyframeRule(const nsAString& aBuffer,
                                nsIURI*            aURI,
                                uint32_t           aLineNumber)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseKeyframeRule(aBuffer, aURI, aLineNumber);
 }
 
 bool
-nsCSSParser::ParseKeyframeSelectorString(const nsSubstring& aSelectorString,
+nsCSSParser::ParseKeyframeSelectorString(const nsAString& aSelectorString,
                                          nsIURI*            aURI,
                                          uint32_t           aLineNumber,
                                          InfallibleTArray<float>& aSelectorList)
 {
   return static_cast<CSSParserImpl*>(mImpl)->
     ParseKeyframeSelectorString(aSelectorString, aURI, aLineNumber,
                                 aSelectorList);
 }
--- a/layout/style/nsCSSParser.h
+++ b/layout/style/nsCSSParser.h
@@ -157,17 +157,17 @@ public:
                      mozilla::css::Declaration* aDeclaration,
                      bool*               aChanged,
                      bool                aIsImportant);
   /**
    * Parse aBuffer into a media list |aMediaList|, which must be non-null,
    * replacing its current contents. |aURL| and |aLineNumber| are used for error
    * reporting.
    */
-  void ParseMediaList(const nsSubstring& aBuffer,
+  void ParseMediaList(const nsAString& aBuffer,
                       nsIURI*            aURL,
                       uint32_t           aLineNumber,
                       nsMediaList*       aMediaList);
 
   /*
    * Parse aBuffer into a list of media queries and their associated values,
    * according to grammar:
    *    <source-size-list> = <source-size>#?
@@ -184,68 +184,68 @@ public:
                            uint32_t aLineNumber, // for error reporting
                            InfallibleTArray< nsAutoPtr<nsMediaQuery> >& aQueries,
                            InfallibleTArray<nsCSSValue>& aValues);
 
   /**
    * Parse aBuffer into a nsCSSValue |aValue|. Will return false
    * if aBuffer is not a valid font family list.
    */
-  bool ParseFontFamilyListString(const nsSubstring& aBuffer,
+  bool ParseFontFamilyListString(const nsAString& aBuffer,
                                  nsIURI*            aURL,
                                  uint32_t           aLineNumber,
                                  nsCSSValue&        aValue);
 
   /**
    * Parse aBuffer into a nsCSSValue |aValue|. Will return false
    * if aBuffer is not a valid CSS color specification.
    * One can use nsRuleNode::ComputeColor to compute an nscolor from
    * the returned nsCSSValue.
    */
-  bool ParseColorString(const nsSubstring& aBuffer,
+  bool ParseColorString(const nsAString& aBuffer,
                         nsIURI*            aURL,
                         uint32_t           aLineNumber,
                         nsCSSValue&        aValue,
                         bool               aSuppressErrors = false);
 
   /**
    * Parse aBuffer into a nsCSSValue |aValue|. Will return false
    * if aBuffer is not a valid CSS margin specification.
    * One can use nsRuleNode::GetRectValue to compute an nsCSSRect from
    * the returned nsCSSValue.
    */
-  bool ParseMarginString(const nsSubstring& aBuffer,
+  bool ParseMarginString(const nsAString& aBuffer,
                          nsIURI*            aURL,
                          uint32_t           aLineNumber,
                          nsCSSValue&        aValue,
                          bool               aSuppressErrors = false);
 
   /**
    * Parse aBuffer into a selector list.  On success, caller must
    * delete *aSelectorList when done with it.
    */
-  nsresult ParseSelectorString(const nsSubstring&  aSelectorString,
+  nsresult ParseSelectorString(const nsAString&  aSelectorString,
                                nsIURI*             aURL,
                                uint32_t            aLineNumber,
                                nsCSSSelectorList** aSelectorList);
 
   /*
    * Parse a keyframe rule (which goes inside an @keyframes rule).
    * Return it if the parse was successful.
    */
   already_AddRefed<nsCSSKeyframeRule>
-  ParseKeyframeRule(const nsSubstring& aBuffer,
+  ParseKeyframeRule(const nsAString& aBuffer,
                     nsIURI*            aURL,
                     uint32_t           aLineNumber);
 
   /*
    * Parse a selector list for a keyframe rule.  Return whether
    * the parse succeeded.
    */
-  bool ParseKeyframeSelectorString(const nsSubstring& aSelectorString,
+  bool ParseKeyframeSelectorString(const nsAString& aSelectorString,
                                    nsIURI*            aURL,
                                    uint32_t           aLineNumber,
                                    InfallibleTArray<float>& aSelectorList);
 
   /**
    * Parse a property and value and return whether the property/value pair
    * is supported.
    */
--- a/layout/style/nsCSSRules.h
+++ b/layout/style/nsCSSRules.h
@@ -299,17 +299,17 @@ private:
   RefPtr<mozilla::css::Declaration>          mDeclaration;
   // lazily created when needed:
   RefPtr<nsCSSKeyframeStyleDeclaration>    mDOMDeclaration;
 };
 
 class nsCSSKeyframesRule final : public mozilla::dom::CSSKeyframesRule
 {
 public:
-  nsCSSKeyframesRule(const nsSubstring& aName,
+  nsCSSKeyframesRule(const nsAString& aName,
                      uint32_t aLineNumber, uint32_t aColumnNumber)
     : mozilla::dom::CSSKeyframesRule(aLineNumber, aColumnNumber)
     , mName(aName)
   {
   }
 private:
   nsCSSKeyframesRule(const nsCSSKeyframesRule& aCopy);
   ~nsCSSKeyframesRule();
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2334,17 +2334,17 @@ struct StyleAnimation
   dom::FillMode GetFillMode() const { return mFillMode; }
   uint8_t GetPlayState() const { return mPlayState; }
   float GetIterationCount() const { return mIterationCount; }
 
   void SetTimingFunction(const nsTimingFunction& aTimingFunction)
     { mTimingFunction = aTimingFunction; }
   void SetDelay(float aDelay) { mDelay = aDelay; }
   void SetDuration(float aDuration) { mDuration = aDuration; }
-  void SetName(const nsSubstring& aName) { mName = aName; }
+  void SetName(const nsAString& aName) { mName = aName; }
   void SetDirection(dom::PlaybackDirection aDirection) { mDirection = aDirection; }
   void SetFillMode(dom::FillMode aFillMode) { mFillMode = aFillMode; }
   void SetPlayState(uint8_t aPlayState) { mPlayState = aPlayState; }
   void SetIterationCount(float aIterationCount)
     { mIterationCount = aIterationCount; }
 
   nsTimingFunction& TimingFunctionSlot() { return mTimingFunction; }
 
--- a/layout/style/nsStyleUtil.cpp
+++ b/layout/style/nsStyleUtil.cpp
@@ -48,18 +48,18 @@ bool nsStyleUtil::DashMatchCompare(const
     else {
       result = StringBeginsWith(aAttributeValue, aSelectorValue, aComparator);
     }
   }
   return result;
 }
 
 bool
-nsStyleUtil::ValueIncludes(const nsSubstring& aValueList,
-                           const nsSubstring& aValue,
+nsStyleUtil::ValueIncludes(const nsAString& aValueList,
+                           const nsAString& aValue,
                            const nsStringComparator& aComparator)
 {
   const char16_t *p = aValueList.BeginReading(),
               *p_end = aValueList.EndReading();
 
   while (p < p_end) {
     // skip leading space
     while (p != p_end && nsContentUtils::IsHTMLWhitespace(*p))
@@ -811,17 +811,17 @@ nsStyleUtil::ObjectPropsMightCauseOverfl
 }
 
 
 /* static */ bool
 nsStyleUtil::CSPAllowsInlineStyle(nsIContent* aContent,
                                   nsIPrincipal* aPrincipal,
                                   nsIURI* aSourceURI,
                                   uint32_t aLineNumber,
-                                  const nsSubstring& aStyleText,
+                                  const nsAString& aStyleText,
                                   nsresult* aRv)
 {
   nsresult rv;
 
   if (aRv) {
     *aRv = NS_OK;
   }
 
--- a/layout/style/nsStyleUtil.h
+++ b/layout/style/nsStyleUtil.h
@@ -26,18 +26,18 @@ struct nsCSSValueList;
 // Style utility functions
 class nsStyleUtil {
 public:
 
  static bool DashMatchCompare(const nsAString& aAttributeValue,
                                 const nsAString& aSelectorValue,
                                 const nsStringComparator& aComparator);
 
- static bool ValueIncludes(const nsSubstring& aValueList,
-                           const nsSubstring& aValue,
+ static bool ValueIncludes(const nsAString& aValueList,
+                           const nsAString& aValue,
                            const nsStringComparator& aComparator);
 
   // Append a quoted (with 'quoteChar') and escaped version of aString
   // to aResult.  'quoteChar' must be ' or ".
   static void AppendEscapedCSSString(const nsAString& aString,
                                      nsAString& aResult,
                                      char16_t quoteChar = '"');
 
@@ -187,17 +187,17 @@ public:
    *      Return error code in case of failure
    *  @return
    *      Does CSP allow application of the specified inline style?
    */
   static bool CSPAllowsInlineStyle(nsIContent* aContent,
                                    nsIPrincipal* aPrincipal,
                                    nsIURI* aSourceURI,
                                    uint32_t aLineNumber,
-                                   const nsSubstring& aStyleText,
+                                   const nsAString& aStyleText,
                                    nsresult* aRv);
 
   template<size_t N>
   static bool MatchesLanguagePrefix(const char16_t* aLang, size_t aLen,
                                     const char16_t (&aPrefix)[N])
   {
     return !nsCRT::strncmp(aLang, aPrefix, N - 1) &&
            (aLen == N - 1 || aLang[N - 1] == '-');
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -189,17 +189,17 @@ private:
   }
 
   DISALLOW_COPY_ASSIGN(SingletonThreadHolder);
 
 public:
   // Must be threadsafe for StaticRefPtr/ClearOnShutdown
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SingletonThreadHolder)
 
-  explicit SingletonThreadHolder(const nsCSubstring& aName)
+  explicit SingletonThreadHolder(const nsACString& aName)
     : mName(aName)
   {
     mParentThread = NS_GetCurrentThread();
   }
 
   nsIThread* GetThread() {
     return mThread;
   }
--- a/netwerk/base/nsBase64Encoder.cpp
+++ b/netwerk/base/nsBase64Encoder.cpp
@@ -48,17 +48,17 @@ nsBase64Encoder::WriteSegments(nsReadSeg
 NS_IMETHODIMP
 nsBase64Encoder::IsNonBlocking(bool* aNonBlocking)
 {
   *aNonBlocking = false;
   return NS_OK;
 }
 
 nsresult
-nsBase64Encoder::Finish(nsCSubstring& result)
+nsBase64Encoder::Finish(nsACString& result)
 {
   char* b64 = PL_Base64Encode(mData.get(), mData.Length(), nullptr);
   if (!b64)
     return NS_ERROR_OUT_OF_MEMORY;
 
   result.Assign(b64);
   PR_Free(b64);
   // Free unneeded memory and allow reusing the object
--- a/netwerk/base/nsBase64Encoder.h
+++ b/netwerk/base/nsBase64Encoder.h
@@ -15,17 +15,17 @@
  */
 class nsBase64Encoder final : public nsIOutputStream {
   public:
     nsBase64Encoder() {}
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOUTPUTSTREAM
 
-    nsresult Finish(nsCSubstring& _result);
+    nsresult Finish(nsACString& _result);
   private:
     ~nsBase64Encoder() {}
 
     /// The data written to this stream. nsCString can deal fine with
     /// binary data.
     nsCString mData;
 };
 
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -648,17 +648,17 @@ nsChannelClassifier::IsHostnameWhitelist
   nsresult rv = aUri->GetHost(host);
   if (NS_FAILED(rv) || host.IsEmpty()) {
     return false;
   }
   ToLowerCase(host);
 
   nsCCharSeparatedTokenizer tokenizer(aWhitelisted, ',');
   while (tokenizer.hasMoreTokens()) {
-    const nsCSubstring& token = tokenizer.nextToken();
+    const nsACString& token = tokenizer.nextToken();
     if (token.Equals(host)) {
       LOG(("nsChannelClassifier[%p]:StartInternal skipping %s (whitelisted)",
            this, host.get()));
       return true;
     }
   }
 
   return false;
--- a/netwerk/base/nsMediaFragmentURIParser.cpp
+++ b/netwerk/base/nsMediaFragmentURIParser.cpp
@@ -337,17 +337,17 @@ bool nsMediaFragmentURIParser::ParseXYWH
 
 void nsMediaFragmentURIParser::Parse(nsACString& aRef)
 {
   // Create an array of possibly-invalid media fragments.
   nsTArray< std::pair<nsCString, nsCString> > fragments;
   nsCCharSeparatedTokenizer tokenizer(aRef, '&');
 
   while (tokenizer.hasMoreTokens()) {
-    const nsCSubstring& nv = tokenizer.nextToken();
+    const nsACString& nv = tokenizer.nextToken();
     int32_t index = nv.FindChar('=');
     if (index >= 0) {
       nsAutoCString name;
       nsAutoCString value;
       NS_UnescapeURL(StringHead(nv, index), esc_Ref | esc_AlwaysCopy, name);
       NS_UnescapeURL(Substring(nv, index + 1, nv.Length()),
                      esc_Ref | esc_AlwaysCopy, value);
       fragments.AppendElement(make_pair(name, value));
--- a/netwerk/base/nsSerializationHelper.cpp
+++ b/netwerk/base/nsSerializationHelper.cpp
@@ -13,17 +13,17 @@
 #include "nsBase64Encoder.h"
 #include "nsAutoPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsStringStream.h"
 
 using namespace mozilla;
 
 nsresult
-NS_SerializeToString(nsISerializable* obj, nsCSubstring& str)
+NS_SerializeToString(nsISerializable* obj, nsACString& str)
 {
   RefPtr<nsBase64Encoder> stream(new nsBase64Encoder());
   if (!stream)
     return NS_ERROR_OUT_OF_MEMORY;
 
   nsCOMPtr<nsIObjectOutputStream> objstream =
       do_CreateInstance("@mozilla.org/binaryoutputstream;1");
   if (!objstream)
@@ -32,17 +32,17 @@ NS_SerializeToString(nsISerializable* ob
   objstream->SetOutputStream(stream);
   nsresult rv =
       objstream->WriteCompoundObject(obj, NS_GET_IID(nsISupports), true);
   NS_ENSURE_SUCCESS(rv, rv);
   return stream->Finish(str);
 }
 
 nsresult
-NS_DeserializeObject(const nsCSubstring& str, nsISupports** obj)
+NS_DeserializeObject(const nsACString& str, nsISupports** obj)
 {
   nsCString decodedData;
   nsresult rv = Base64Decode(str, decodedData);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIInputStream> stream;
   rv = NS_NewCStringInputStream(getter_AddRefs(stream), decodedData);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/netwerk/base/nsSerializationHelper.h
+++ b/netwerk/base/nsSerializationHelper.h
@@ -14,22 +14,22 @@
 #include "mozilla/Attributes.h"
 
 class nsISerializable;
 
 /**
  * Serialize an object to an ASCII string.
  */
 nsresult NS_SerializeToString(nsISerializable* obj,
-                              nsCSubstring& str);
+                              nsACString& str);
 
 /**
  * Deserialize an object.
  */
-nsresult NS_DeserializeObject(const nsCSubstring& str,
+nsresult NS_DeserializeObject(const nsACString& str,
                               nsISupports** obj);
 
 class nsSerializationHelper final : public nsISerializationHelper
 {
   ~nsSerializationHelper() {}
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISERIALIZATIONHELPER
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -426,17 +426,17 @@ nsStandardURL::InvalidateCache(bool inva
 // number of relevant entries in the bases/starts/ends arrays is number of
 // dots + 1.
 // Since the trailing dot is allowed, we pass and adjust "length".
 //
 // length is assumed to be <= host.Length(); the callers is responsible for that
 //
 // Note that the value returned is guaranteed to be in [-1, 3] range.
 inline int32_t
-ValidateIPv4Number(const nsCSubstring& host,
+ValidateIPv4Number(const nsACString& host,
                    int32_t bases[4], int32_t dotIndex[3],
                    bool& onlyBase10, int32_t& length)
 {
     MOZ_ASSERT(length <= (int32_t)host.Length());
     if (length <= 0) {
         return -1;
     }
 
@@ -505,17 +505,17 @@ ValidateIPv4Number(const nsCSubstring& h
             return -1;
         }
     }
 
     return dotCount;
 }
 
 inline nsresult
-ParseIPv4Number10(const nsCSubstring& input, uint32_t& number, uint32_t maxNumber)
+ParseIPv4Number10(const nsACString& input, uint32_t& number, uint32_t maxNumber)
 {
     uint64_t value = 0;
     const char* current = input.BeginReading();
     const char* end = input.EndReading();
     for (; current < end; ++current) {
         char c = *current;
         MOZ_ASSERT(c >= '0' && c <= '9');
         value *= 10;
@@ -527,17 +527,17 @@ ParseIPv4Number10(const nsCSubstring& in
     }
 
     // The error case
     number = 0;
     return NS_ERROR_FAILURE;
 }
 
 inline nsresult
-ParseIPv4Number(const nsCSubstring& input, int32_t base, uint32_t& number, uint32_t maxNumber)
+ParseIPv4Number(const nsACString& input, int32_t base, uint32_t& number, uint32_t maxNumber)
 {
     // Accumulate in the 64-bit value
     uint64_t value = 0;
     const char* current = input.BeginReading();
     const char* end = input.EndReading();
     switch(base) {
       case 16:
         ++current;
@@ -571,17 +571,17 @@ ParseIPv4Number(const nsCSubstring& inpu
 
     // The error case
     number = 0;
     return NS_ERROR_FAILURE;
 }
 
 // IPv4 parser spec: https://url.spec.whatwg.org/#concept-ipv4-parser
 /* static */ nsresult
-nsStandardURL::NormalizeIPv4(const nsCSubstring& host, nsCString& result)
+nsStandardURL::NormalizeIPv4(const nsACString& host, nsCString& result)
 {
     int32_t bases[4] = {10,10,10,10};
     bool onlyBase10 = true;           // Track this as a special case
     int32_t dotIndex[3];              // The positions of the dots in the string
 
     // The length may be adjusted by ValidateIPv4Number (ignoring the trailing period)
     // so use "length", rather than host.Length() after that call.
     int32_t length = static_cast<int32_t>(host.Length());
@@ -628,17 +628,17 @@ nsStandardURL::NormalizeIPv4(const nsCSu
     uint8_t ipSegments[4];
     NetworkEndian::writeUint32(ipSegments, ipv4);
     result = nsPrintfCString("%d.%d.%d.%d", ipSegments[0], ipSegments[1],
                                             ipSegments[2], ipSegments[3]);
     return NS_OK;
 }
 
 nsresult
-nsStandardURL::NormalizeIDN(const nsCSubstring &host, nsCString &result)
+nsStandardURL::NormalizeIDN(const nsACString& host, nsCString& result)
 {
     // If host is ACE, then convert to UTF-8.  Else, if host is already UTF-8,
     // then make sure it is normalized per IDN.
 
     // this function returns true if normalization succeeds.
 
     // NOTE: As a side-effect this function sets mHostEncoding.  While it would
     // be nice to avoid side-effects in this function, the implementation of
@@ -3813,12 +3813,12 @@ nsStandardURL::SizeOfIncludingThis(Mallo
   return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
 }
 
 } // namespace net
 } // namespace mozilla
 
 // For unit tests.  Including nsStandardURL.h seems to cause problems via RustURL.h
 nsresult
-Test_NormalizeIPv4(const nsCSubstring& host, nsCString& result)
+Test_NormalizeIPv4(const nsACString& host, nsCString& result)
 {
     return nsStandardURL::NormalizeIPv4(host, result);
 }
--- a/netwerk/base/nsStandardURL.h
+++ b/netwerk/base/nsStandardURL.h
@@ -140,17 +140,17 @@ public: /* internal -- HPUX compiler can
         const nsACString& EncodeSegment(const nsACString& str,
                                         int16_t mask,
                                         nsCString& buf);
     private:
       const Encoding* mEncoding;
     };
     friend class nsSegmentEncoder;
 
-    static nsresult NormalizeIPv4(const nsCSubstring &host, nsCString &result);
+    static nsresult NormalizeIPv4(const nsACString& host, nsCString& result);
 
 protected:
     // enum used in a few places to specify how .ref attribute should be handled
     enum RefHandlingEnum {
         eIgnoreRef,
         eHonorRef,
         eReplaceRef
     };
@@ -183,17 +183,17 @@ private:
     int32_t  Port() { return mPort == -1 ? mDefaultPort : mPort; }
 
     void     ReplacePortInSpec(int32_t aNewPort);
     void     Clear();
     void     InvalidateCache(bool invalidateCachedFile = true);
 
     bool     ValidIPv6orHostname(const char *host, uint32_t aLen);
     static bool     IsValidOfBase(unsigned char c, const uint32_t base);
-    nsresult NormalizeIDN(const nsCSubstring &host, nsCString &result);
+    nsresult NormalizeIDN(const nsACString& host, nsCString& result);
     void     CoalescePath(netCoalesceFlags coalesceFlag, char *path);
 
     uint32_t AppendSegmentToBuf(char *, uint32_t, const char *,
                                 const URLSegment &input, URLSegment &output,
                                 const nsCString *esc=nullptr,
                                 bool useEsc = false, int32_t* diff = nullptr);
     uint32_t AppendToBuf(char *, uint32_t, const char *, uint32_t);
 
--- a/netwerk/base/nsURLHelper.cpp
+++ b/netwerk/base/nsURLHelper.cpp
@@ -1050,17 +1050,17 @@ net_ParseRequestContentType(const nsACSt
                        &hadCharset, &dummy1, &dummy2, true);
 
     aContentType = contentType;
     aContentCharset = contentCharset;
     *aHadCharset = hadCharset;
 }
 
 bool
-net_IsValidHostName(const nsCSubstring &host)
+net_IsValidHostName(const nsACString& host)
 {
     const char *end = host.EndReading();
     // Use explicit whitelists to select which characters we are
     // willing to send to lower-level DNS logic. This is more
     // self-documenting, and can also be slightly faster than the
     // blacklist approach, since DNS names are the common case, and
     // the commonest characters will tend to be near the start of
     // the list.
--- a/netwerk/base/nsURLHelper.h
+++ b/netwerk/base/nsURLHelper.h
@@ -223,17 +223,17 @@ inline char *net_RFindCharNotInSet(const
 {
     return net_RFindCharNotInSet(str, str + strlen(str), set);
 }
 
 /**
  * This function returns true if the given hostname does not include any
  * restricted characters.  Otherwise, false is returned.
  */
-bool net_IsValidHostName(const nsCSubstring &host);
+bool net_IsValidHostName(const nsACString& host);
 
 /**
  * Checks whether the IPv4 address is valid according to RFC 3986 section 3.2.2.
  */
 bool net_IsValidIPv4Addr(const char *addr, int32_t addrLen);
 
 /**
  * Checks whether the IPv6 address is valid according to RFC 3986 section 3.2.2.
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -1353,17 +1353,17 @@ nsOfflineCacheDevice::InitWithSqlite(moz
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 namespace {
 
 nsresult
-GetGroupForCache(const nsCSubstring &clientID, nsCString &group)
+GetGroupForCache(const nsACString& clientID, nsCString& group)
 {
   group.Assign(clientID);
   group.Truncate(group.FindChar('|'));
   NS_UnescapeURL(group);
 
   return NS_OK;
 }
 
@@ -2786,18 +2786,18 @@ nsOfflineCacheDevice::CacheOpportunistic
   nsAutoCString clientID;
   rv = cache->GetClientID(clientID);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return CacheOpportunistically(clientID, key);
 }
 
 nsresult
-nsOfflineCacheDevice::ActivateCache(const nsCSubstring &group,
-                                    const nsCSubstring &clientID)
+nsOfflineCacheDevice::ActivateCache(const nsACString& group,
+                                    const nsACString& clientID)
 {
   NS_ENSURE_TRUE(Initialized(), NS_ERROR_NOT_INITIALIZED);
 
   AutoResetStatement statement(mStatement_ActivateClient);
   nsresult rv = statement->BindUTF8StringByIndex(0, group);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = statement->BindUTF8StringByIndex(1, clientID);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -2822,18 +2822,18 @@ nsOfflineCacheDevice::ActivateCache(cons
     mActiveCaches.PutEntry(clientID);
     mActiveCachesByGroup.Put(group, new nsCString(clientID));
   }
 
   return NS_OK;
 }
 
 bool
-nsOfflineCacheDevice::IsActiveCache(const nsCSubstring &group,
-                                    const nsCSubstring &clientID)
+nsOfflineCacheDevice::IsActiveCache(const nsACString& group,
+                                    const nsACString& clientID)
 {
   nsCString *active = nullptr;
   MutexAutoLock lock(mLock);
   return mActiveCachesByGroup.Get(group, &active) && *active == clientID;
 }
 
 /**
  * Preference accessors
--- a/netwerk/cache/nsDiskCacheDeviceSQL.h
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.h
@@ -138,20 +138,20 @@ public:
   nsresult                ClearKeysOwnedByDomain(const char *clientID,
                                                  const nsACString &ownerDomain);
   nsresult                EvictUnownedEntries(const char *clientID);
 
   static nsresult         BuildApplicationCacheGroupID(nsIURI *aManifestURL,
                                                        nsACString const &aOriginSuffix,
                                                        nsACString &_result);
 
-  nsresult                ActivateCache(const nsCSubstring &group,
-                                        const nsCSubstring &clientID);
-  bool                    IsActiveCache(const nsCSubstring &group,
-                                        const nsCSubstring &clientID);
+  nsresult                ActivateCache(const nsACString& group,
+                                        const nsACString& clientID);
+  bool                    IsActiveCache(const nsACString& group,
+                                        const nsACString& clientID);
   nsresult                CreateApplicationCache(const nsACString &group,
                                                  nsIApplicationCache **out);
 
   nsresult                GetApplicationCache(const nsACString &clientID,
                                               nsIApplicationCache **out);
   nsresult                GetApplicationCache_Unlocked(const nsACString &clientID,
                                                        nsIApplicationCache **out);
 
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -251,32 +251,32 @@ nsresult CacheEntry::HashingKeyWithStora
 }
 
 nsresult CacheEntry::HashingKey(nsACString &aResult) const
 {
   return HashingKey(EmptyCString(), mEnhanceID, mURI, aResult);
 }
 
 // static
-nsresult CacheEntry::HashingKey(nsCSubstring const& aStorageID,
-                                nsCSubstring const& aEnhanceID,
+nsresult CacheEntry::HashingKey(const nsACString& aStorageID,
+                                const nsACString& aEnhanceID,
                                 nsIURI* aURI,
                                 nsACString &aResult)
 {
   nsAutoCString spec;
   nsresult rv = aURI->GetAsciiSpec(spec);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return HashingKey(aStorageID, aEnhanceID, spec, aResult);
 }
 
 // static
-nsresult CacheEntry::HashingKey(nsCSubstring const& aStorageID,
-                                nsCSubstring const& aEnhanceID,
-                                nsCSubstring const& aURISpec,
+nsresult CacheEntry::HashingKey(const nsACString& aStorageID,
+                                const nsACString& aEnhanceID,
+                                const nsACString& aURISpec,
                                 nsACString &aResult)
 {
   /**
    * This key is used to salt hash that is a base for disk file name.
    * Changing it will cause we will not be able to find files on disk.
    */
 
   aResult.Assign(aStorageID);
--- a/netwerk/cache2/CacheEntry.h
+++ b/netwerk/cache2/CacheEntry.h
@@ -99,24 +99,24 @@ public:
   bool DeferOrBypassRemovalOnPinStatus(bool aPinned);
   bool Purge(uint32_t aWhat);
   void PurgeAndDoom();
   void DoomAlreadyRemoved();
 
   nsresult HashingKeyWithStorage(nsACString &aResult) const;
   nsresult HashingKey(nsACString &aResult) const;
 
-  static nsresult HashingKey(nsCSubstring const& aStorageID,
-                             nsCSubstring const& aEnhanceID,
+  static nsresult HashingKey(const nsACString& aStorageID,
+                             const nsACString& aEnhanceID,
                              nsIURI* aURI,
                              nsACString &aResult);
 
-  static nsresult HashingKey(nsCSubstring const& aStorageID,
-                             nsCSubstring const& aEnhanceID,
-                             nsCSubstring const& aURISpec,
+  static nsresult HashingKey(const nsACString& aStorageID,
+                             const nsACString& aEnhanceID,
+                             const nsACString& aURISpec,
                              nsACString &aResult);
 
   // Accessed only on the service management thread
   double mFrecency;
   ::mozilla::Atomic<uint32_t, ::mozilla::Relaxed> mSortingExpirationTime;
 
   // Memory reporting
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
--- a/netwerk/cache2/CacheFileUtils.cpp
+++ b/netwerk/cache2/CacheFileUtils.cpp
@@ -178,19 +178,19 @@ public:
   {
     result.Assign(idEnhance);
   }
 };
 
 } // namespace
 
 already_AddRefed<nsILoadContextInfo>
-ParseKey(const nsCSubstring &aKey,
-         nsCSubstring *aIdEnhance,
-         nsCSubstring *aURISpec)
+ParseKey(const nsACString& aKey,
+         nsACString* aIdEnhance,
+         nsACString* aURISpec)
 {
   KeyParser parser(aKey);
   RefPtr<LoadContextInfo> info = parser.Parse();
 
   if (info) {
     if (aIdEnhance)
       parser.IdEnhance(*aIdEnhance);
     if (aURISpec)
@@ -223,17 +223,17 @@ AppendKeyPrefix(nsILoadContextInfo* aInf
   }
 
   if (aInfo->IsPrivate()) {
     _retval.AppendLiteral("p,");
   }
 }
 
 void
-AppendTagWithValue(nsACString & aTarget, char const aTag, nsCSubstring const & aValue)
+AppendTagWithValue(nsACString& aTarget, char const aTag, const nsACString& aValue)
 {
   aTarget.Append(aTag);
 
   // First check the value string to save some memory copying
   // for cases we don't need to escape at all (most likely).
   if (!aValue.IsEmpty()) {
     if (!aValue.Contains(',')) {
       // No need to escape
--- a/netwerk/cache2/CacheFileUtils.h
+++ b/netwerk/cache2/CacheFileUtils.h
@@ -17,25 +17,25 @@ class nsACString;
 
 namespace mozilla {
 namespace net {
 namespace CacheFileUtils {
 
 extern const char *kAltDataKey;
 
 already_AddRefed<nsILoadContextInfo>
-ParseKey(const nsCSubstring &aKey,
-         nsCSubstring *aIdEnhance = nullptr,
-         nsCSubstring *aURISpec = nullptr);
+ParseKey(const nsACString& aKey,
+         nsACString* aIdEnhance = nullptr,
+         nsACString* aURISpec = nullptr);
 
 void
 AppendKeyPrefix(nsILoadContextInfo *aInfo, nsACString &_retval);
 
 void
-AppendTagWithValue(nsACString & aTarget, char const aTag, nsCSubstring const & aValue);
+AppendTagWithValue(nsACString& aTarget, char const aTag, const nsACString& aValue);
 
 nsresult
 KeyMatchesLoadContextInfo(const nsACString &aKey,
                           nsILoadContextInfo *aInfo,
                           bool *_retval);
 
 class ValidityPair {
 public:
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -1488,17 +1488,17 @@ CacheStorageService::AddStorageEntry(Cac
                          aStorage->WriteToDisk(),
                          aStorage->SkipSizeCheck(),
                          aStorage->Pinning(),
                          aReplace,
                          aResult);
 }
 
 nsresult
-CacheStorageService::AddStorageEntry(nsCSubstring const& aContextKey,
+CacheStorageService::AddStorageEntry(const nsACString& aContextKey,
                                      const nsACString & aURI,
                                      const nsACString & aIdExtension,
                                      bool aWriteToDisk,
                                      bool aSkipSizeCheck,
                                      bool aPin,
                                      bool aReplace,
                                      CacheEntryHandle** aResult)
 {
@@ -1844,17 +1844,17 @@ CacheStorageService::DoomStorageEntries(
   mozilla::MutexAutoLock lock(mLock);
 
   return DoomStorageEntries(contextKey, aStorage->LoadInfo(),
                             aStorage->WriteToDisk(), aStorage->Pinning(),
                             aCallback);
 }
 
 nsresult
-CacheStorageService::DoomStorageEntries(nsCSubstring const& aContextKey,
+CacheStorageService::DoomStorageEntries(const nsACString& aContextKey,
                                         nsILoadContextInfo* aContext,
                                         bool aDiskStorage,
                                         bool aPinned,
                                         nsICacheEntryDoomCallback* aCallback)
 {
   LOG(("CacheStorageService::DoomStorageEntries [context=%s]", aContextKey.BeginReading()));
 
   mLock.AssertCurrentThreadOwns();
--- a/netwerk/cache2/CacheStorageService.h
+++ b/netwerk/cache2/CacheStorageService.h
@@ -289,22 +289,22 @@ private:
   /**
    * Called on the management thread, removes all expired and then least used
    * entries from the memory, first from the disk pool and then from the memory
    * pool.
    */
   void PurgeOverMemoryLimit();
 
 private:
-  nsresult DoomStorageEntries(nsCSubstring const& aContextKey,
+  nsresult DoomStorageEntries(const nsACString& aContextKey,
                               nsILoadContextInfo* aContext,
                               bool aDiskStorage,
                               bool aPin,
                               nsICacheEntryDoomCallback* aCallback);
-  nsresult AddStorageEntry(nsCSubstring const& aContextKey,
+  nsresult AddStorageEntry(const nsACString& aContextKey,
                            const nsACString & aURI,
                            const nsACString & aIdExtension,
                            bool aWriteToDisk,
                            bool aSkipSizeCheck,
                            bool aPin,
                            bool aReplace,
                            CacheEntryHandle** aResult);
 
--- a/netwerk/cache2/OldWrappers.cpp
+++ b/netwerk/cache2/OldWrappers.cpp
@@ -518,17 +518,17 @@ NS_IMETHODIMP _OldCacheEntryWrapper::Vis
   RefPtr<MetaDataVisitorWrapper> w = new MetaDataVisitorWrapper(cb);
   return mOldDesc->VisitMetaData(w);
 }
 
 namespace {
 
 nsresult
 GetCacheSessionNameForStoragePolicy(
-        nsCSubstring const &scheme,
+        const nsACString& scheme,
         nsCacheStoragePolicy storagePolicy,
         bool isPrivate,
         OriginAttributes const *originAttribs,
         nsACString& sessionName)
 {
   MOZ_ASSERT(!isPrivate || storagePolicy == nsICache::STORE_IN_MEMORY);
 
   // HTTP
@@ -582,17 +582,17 @@ GetCacheSessionNameForStoragePolicy(
   nsAutoCString suffix;
   originAttribs->CreateSuffix(suffix);
   sessionName.Append(suffix);
 
   return NS_OK;
 }
 
 nsresult
-GetCacheSession(nsCSubstring const &aScheme,
+GetCacheSession(const nsACString& aScheme,
                 bool aWriteToDisk,
                 nsILoadContextInfo* aLoadInfo,
                 nsIApplicationCache* aAppCache,
                 nsICacheSession** _result)
 {
   nsresult rv;
 
   nsCacheStoragePolicy storagePolicy;
@@ -648,18 +648,18 @@ GetCacheSession(nsCSubstring const &aSch
   return NS_OK;
 }
 
 } // namespace
 
 
 NS_IMPL_ISUPPORTS_INHERITED(_OldCacheLoad, Runnable, nsICacheListener)
 
-_OldCacheLoad::_OldCacheLoad(nsCSubstring const& aScheme,
-                             nsCSubstring const& aCacheKey,
+_OldCacheLoad::_OldCacheLoad(const nsACString& aScheme,
+                             const nsACString& aCacheKey,
                              nsICacheEntryOpenCallback* aCallback,
                              nsIApplicationCache* aAppCache,
                              nsILoadContextInfo* aLoadInfo,
                              bool aWriteToDisk,
                              uint32_t aFlags)
   : mScheme(aScheme)
   , mCacheKey(aCacheKey)
   , mCallback(aCallback)
@@ -1132,17 +1132,17 @@ nsresult _OldStorage::AssembleCacheKey(n
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   aCacheKey.Append(uriSpec);
 
   return NS_OK;
 }
 
-nsresult _OldStorage::ChooseApplicationCache(nsCSubstring const &cacheKey,
+nsresult _OldStorage::ChooseApplicationCache(const nsACString& cacheKey,
                                              nsIApplicationCache** aCache)
 {
   nsresult rv;
 
   nsCOMPtr<nsIApplicationCacheService> appCacheService =
     do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/netwerk/cache2/OldWrappers.h
+++ b/netwerk/cache2/OldWrappers.h
@@ -182,18 +182,18 @@ private:
 class _OldCacheLoad : public Runnable
                     , public nsICacheListener
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSICACHELISTENER
 
-  _OldCacheLoad(nsCSubstring const& aScheme,
-                nsCSubstring const& aCacheKey,
+  _OldCacheLoad(const nsACString& aScheme,
+                const nsACString& aCacheKey,
                 nsICacheEntryOpenCallback* aCallback,
                 nsIApplicationCache* aAppCache,
                 nsILoadContextInfo* aLoadInfo,
                 bool aWriteToDisk,
                 uint32_t aFlags);
 
   nsresult Start();
 
@@ -236,17 +236,17 @@ public:
               bool aLookupAppCache,
               bool aOfflineStorage,
               nsIApplicationCache* aAppCache);
 
 private:
   virtual ~_OldStorage();
   nsresult AssembleCacheKey(nsIURI *aURI, nsACString const & aIdExtension,
                             nsACString & aCacheKey, nsACString & aScheme);
-  nsresult ChooseApplicationCache(nsCSubstring const &cacheKey, nsIApplicationCache** aCache);
+  nsresult ChooseApplicationCache(const nsACString& cacheKey, nsIApplicationCache** aCache);
 
   nsCOMPtr<nsILoadContextInfo> mLoadInfo;
   nsCOMPtr<nsIApplicationCache> mAppCache;
   bool const mWriteToDisk : 1;
   bool const mLookupAppCache : 1;
   bool const mOfflineStorage : 1;
 };
 
--- a/netwerk/protocol/ftp/nsFTPChannel.h
+++ b/netwerk/protocol/ftp/nsFTPChannel.h
@@ -67,17 +67,17 @@ public:
 
     // Download from this byte offset
     uint64_t StartPos() { return mStartPos; }
 
     // ID of the entity to resume downloading
     const nsCString &EntityID() {
         return mEntityID;
     }
-    void SetEntityID(const nsCSubstring &entityID) {
+    void SetEntityID(const nsACString& entityID) {
         mEntityID = entityID;
     }
 
     NS_IMETHOD GetLastModifiedTime(PRTime* lastModifiedTime) override {
         *lastModifiedTime = mLastModifiedTime;
         return NS_OK;
     }
 
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -1850,17 +1850,17 @@ nsFtpState::StopProcessing()
 
     if (NS_FAILED(broadcastErrorCode))
         CloseWithStatus(broadcastErrorCode);
 
     return NS_OK;
 }
 
 nsresult 
-nsFtpState::SendFTPCommand(const nsCSubstring& command)
+nsFtpState::SendFTPCommand(const nsACString& command)
 {
     NS_ASSERTION(mControlConnection, "null control connection");        
     
     // we don't want to log the password:
     nsAutoCString logcmd(command);
     if (StringBeginsWith(command, NS_LITERAL_CSTRING("PASS "))) 
         logcmd = "PASS xxxxx";
     
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.h
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.h
@@ -127,17 +127,17 @@ private:
 
     // internal methods
     void        MoveToNextState(FTP_STATE nextState);
     nsresult    Process();
 
     void KillControlConnection();
     nsresult StopProcessing();
     nsresult EstablishControlConnection();
-    nsresult SendFTPCommand(const nsCSubstring& command);
+    nsresult SendFTPCommand(const nsACString& command);
     void ConvertFilespecToVMS(nsCString& fileSpec);
     void ConvertDirspecToVMS(nsCString& fileSpec);
     void ConvertDirspecFromVMS(nsCString& fileSpec);
     nsresult BuildStreamConverter(nsIStreamListener** convertStreamListener);
     nsresult SetContentType();
 
     /**
      * This method is called to kick-off the FTP state machine.  mState is
--- a/netwerk/protocol/ftp/nsFtpControlConnection.cpp
+++ b/netwerk/protocol/ftp/nsFtpControlConnection.cpp
@@ -59,17 +59,17 @@ nsFtpControlConnection::OnInputStreamRea
         listener->OnControlError(rv);
     } else {
         listener->OnControlDataAvailable(data, avail);
     }
 
     return NS_OK;
 }
 
-nsFtpControlConnection::nsFtpControlConnection(const nsCSubstring& host,
+nsFtpControlConnection::nsFtpControlConnection(const nsACString& host,
                                                uint32_t port)
     : mServerType(0), mSessionId(gFtpHandler->GetSessionId())
     , mUseUTF8(false), mHost(host), mPort(port)
 {
     LOG_INFO(("FTP:CC created @%p", this));
 }
 
 nsFtpControlConnection::~nsFtpControlConnection() 
@@ -167,17 +167,17 @@ nsFtpControlConnection::Disconnect(nsres
         mSocketInput = nullptr;
         mSocketOutput = nullptr;
     }
 
     return NS_OK;
 }
 
 nsresult 
-nsFtpControlConnection::Write(const nsCSubstring& command)
+nsFtpControlConnection::Write(const nsACString& command)
 {
     NS_ENSURE_STATE(mSocketOutput);
 
     uint32_t len = command.Length();
     uint32_t cnt;
     nsresult rv = mSocketOutput->Write(command.Data(), len, &cnt);
 
     if (NS_FAILED(rv))
--- a/netwerk/protocol/ftp/nsFtpControlConnection.h
+++ b/netwerk/protocol/ftp/nsFtpControlConnection.h
@@ -41,21 +41,21 @@ public:
 class nsFtpControlConnection final : public nsIInputStreamCallback
 {
     ~nsFtpControlConnection();
 
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIINPUTSTREAMCALLBACK
 
-    nsFtpControlConnection(const nsCSubstring& host, uint32_t port);
+    nsFtpControlConnection(const nsACString& host, uint32_t port);
 
     nsresult Connect(nsIProxyInfo* proxyInfo, nsITransportEventSink* eventSink);
     nsresult Disconnect(nsresult status);
-    nsresult Write(const nsCSubstring& command);
+    nsresult Write(const nsACString& command);
 
     bool IsAlive();
 
     nsITransport *Transport()   { return mSocket; }
 
     /**
      * Call this function to be notified asynchronously when there is data
      * available for the socket.  The listener passed to this method replaces
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -344,17 +344,17 @@ Http2Stream::MakeOriginURL(const nsACStr
   return rv;
 }
 
 void
 Http2Stream::CreatePushHashKey(const nsCString &scheme,
                                const nsCString &hostHeader,
                                const mozilla::OriginAttributes &originAttributes,
                                uint64_t serial,
-                               const nsCSubstring &pathInfo,
+                               const nsACString& pathInfo,
                                nsCString &outOrigin,
                                nsCString &outKey)
 {
   nsCString fullOrigin = scheme;
   fullOrigin.AppendLiteral("://");
   fullOrigin.Append(hostHeader);
 
   RefPtr<nsStandardURL> origin;
--- a/netwerk/protocol/http/Http2Stream.h
+++ b/netwerk/protocol/http/Http2Stream.h
@@ -168,17 +168,17 @@ public:
   bool Do0RTT();
   nsresult Finish0RTT(bool aRestart, bool aAlpnIgnored);
 
 protected:
   static void CreatePushHashKey(const nsCString &scheme,
                                 const nsCString &hostHeader,
                                 const mozilla::OriginAttributes &originAttributes,
                                 uint64_t serial,
-                                const nsCSubstring &pathInfo,
+                                const nsACString& pathInfo,
                                 nsCString &outOrigin,
                                 nsCString &outKey);
 
   // These internal states track request generation
   enum upstreamStateType {
     GENERATING_HEADERS,
     GENERATING_BODY,
     SENDING_BODY,
--- a/netwerk/protocol/http/HttpAuthUtils.cpp
+++ b/netwerk/protocol/http/HttpAuthUtils.cpp
@@ -11,18 +11,18 @@
 
 namespace mozilla {
 namespace net {
 namespace auth {
 
 namespace detail {
 
 bool
-MatchesBaseURI(const nsCSubstring &matchScheme,
-               const nsCSubstring &matchHost,
+MatchesBaseURI(const nsACString& matchScheme,
+               const nsACString& matchHost,
                int32_t             matchPort,
                nsDependentCSubstring const& url)
 {
   // check if scheme://host:port matches baseURI
 
   // parse the base URI
   mozilla::Tokenizer t(url);
   mozilla::Tokenizer::Token token;
--- a/netwerk/protocol/http/nsCORSListenerProxy.cpp
+++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp
@@ -1127,17 +1127,17 @@ nsCORSPreflightListener::AddResultToCach
   if (headerVal.IsEmpty()) {
     return;
   }
 
   // Sanitize the string. We only allow 'delta-seconds' as specified by
   // http://dev.w3.org/2006/waf/access-control (digits 0-9 with no leading or
   // trailing non-whitespace characters).
   uint32_t age = 0;
-  nsCSubstring::const_char_iterator iter, end;
+  nsACString::const_char_iterator iter, end;
   headerVal.BeginReading(iter);
   headerVal.EndReading(end);
   while (iter != end) {
     if (*iter < '0' || *iter > '9') {
       return;
     }
     age = age * 10 + (*iter - '0');
     // Cap at 24 hours. This also avoids overflow
--- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
+++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp
@@ -655,20 +655,20 @@ nsHttpChannelAuthProvider::GetCredential
         rv = GetCredentials(challenges, proxyAuth, creds);
     }
 
     return rv;
 }
 
 nsresult
 nsHttpChannelAuthProvider::GetAuthorizationMembers(bool                 proxyAuth,
-                                                   nsCSubstring&        scheme,
+                                                   nsACString&        scheme,
                                                    const char*&         host,
                                                    int32_t&             port,
-                                                   nsCSubstring&        path,
+                                                   nsACString&        path,
                                                    nsHttpAuthIdentity*& ident,
                                                    nsISupports**&       continuationState)
 {
     if (proxyAuth) {
         MOZ_ASSERT (UsingHttpProxy(),
                     "proxyAuth is true, but no HTTP proxy is configured!");
 
         host = ProxyHost();
@@ -1483,17 +1483,17 @@ NS_IMETHODIMP nsHttpChannelAuthProvider:
     mCurrentChallenge.Truncate();
 
     rv = ContinueOnAuthAvailable(nsDependentCString(aGeneratedCreds));
     MOZ_ASSERT(NS_SUCCEEDED(rv));
     return NS_OK;
 }
 
 nsresult
-nsHttpChannelAuthProvider::ContinueOnAuthAvailable(const nsCSubstring& creds)
+nsHttpChannelAuthProvider::ContinueOnAuthAvailable(const nsACString& creds)
 {
     nsresult rv;
     if (mProxyAuth)
         rv = mAuthChannel->SetProxyCredentials(creds);
     else
         rv = mAuthChannel->SetWWWCredentials(creds);
     if (NS_FAILED(rv)) return rv;
 
--- a/netwerk/protocol/http/nsHttpChannelAuthProvider.h
+++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.h
@@ -92,26 +92,26 @@ private:
                                     nsHttpAuthIdentity &ident);
     MOZ_MUST_USE nsresult GetCurrentPath(nsACString &);
     /**
      * Return all information needed to build authorization information,
      * all parameters except proxyAuth are out parameters. proxyAuth specifies
      * with what authorization we work (WWW or proxy).
      */
     MOZ_MUST_USE nsresult
-    GetAuthorizationMembers(bool proxyAuth, nsCSubstring& scheme,
+    GetAuthorizationMembers(bool proxyAuth, nsACString& scheme,
                             const char*& host, int32_t& port,
-                            nsCSubstring& path, nsHttpAuthIdentity*& ident,
+                            nsACString& path, nsHttpAuthIdentity*& ident,
                             nsISupports**& continuationState);
     /**
      * Method called to resume suspended transaction after we got credentials
      * from the user. Called from OnAuthAvailable callback or OnAuthCancelled
      * when credentials for next challenge were obtained synchronously.
      */
-    MOZ_MUST_USE nsresult ContinueOnAuthAvailable(const nsCSubstring& creds);
+    MOZ_MUST_USE nsresult ContinueOnAuthAvailable(const nsACString& creds);
 
     MOZ_MUST_USE nsresult DoRedirectChannelToHttps();
 
     /**
      * A function that takes care of reading STS headers and enforcing STS
      * load rules.  After a secure channel is erected, STS requires the channel
      * to be trusted or any STS header data on the channel is ignored.
      * This is called from ProcessResponse.
--- a/netwerk/protocol/http/nsHttpRequestHead.cpp
+++ b/netwerk/protocol/http/nsHttpRequestHead.cpp
@@ -52,24 +52,24 @@ nsHttpRequestHead::SetHeaders(const nsHt
 void
 nsHttpRequestHead::SetVersion(nsHttpVersion version)
 {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mVersion = version;
 }
 
 void
-nsHttpRequestHead::SetRequestURI(const nsCSubstring &s)
+nsHttpRequestHead::SetRequestURI(const nsACString& s)
 {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mRequestURI = s;
 }
 
 void
-nsHttpRequestHead::SetPath(const nsCSubstring &s)
+nsHttpRequestHead::SetPath(const nsACString& s)
 {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mPath = s;
 }
 
 uint32_t
 nsHttpRequestHead::HeaderCount()
 {
--- a/netwerk/protocol/http/nsHttpRequestHead.h
+++ b/netwerk/protocol/http/nsHttpRequestHead.h
@@ -32,18 +32,18 @@ public:
     const nsHttpHeaderArray &Headers() const;
     void Enter() { mReentrantMonitor.Enter(); }
     void Exit() { mReentrantMonitor.Exit(); }
 
     void SetHeaders(const nsHttpHeaderArray& aHeaders);
 
     void SetMethod(const nsACString &method);
     void SetVersion(nsHttpVersion version);
-    void SetRequestURI(const nsCSubstring &s);
-    void SetPath(const nsCSubstring &s);
+    void SetRequestURI(const nsACString& s);
+    void SetPath(const nsACString& s);
     uint32_t HeaderCount();
 
     // Using this function it is possible to itereate through all headers
     // automatically under one lock.
     MOZ_MUST_USE nsresult
     VisitHeaders(nsIHttpHeaderVisitor *visitor,
                  nsHttpHeaderArray::VisitorFilter filter =
                      nsHttpHeaderArray::eFilterAll);
--- a/netwerk/test/gtest/TestStandardURL.cpp
+++ b/netwerk/test/gtest/TestStandardURL.cpp
@@ -5,17 +5,17 @@
 #include "nsNetCID.h"
 #include "nsIURL.h"
 #include "nsString.h"
 #include "nsPrintfCString.h"
 #include "nsComponentManagerUtils.h"
 
 
 // In nsStandardURL.cpp
-extern nsresult Test_NormalizeIPv4(const nsCSubstring& host, nsCString& result);
+extern nsresult Test_NormalizeIPv4(const nsACString& host, nsCString& result);
 
 
 TEST(TestStandardURL, Simple) {
     nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) );
     ASSERT_TRUE(url);
     ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://example.com")), NS_OK);
 
     nsAutoCString out;
--- a/parser/htmlparser/nsScannerString.cpp
+++ b/parser/htmlparser/nsScannerString.cpp
@@ -195,17 +195,17 @@ nsScannerSubstring::Rebind( const nsAStr
 
     mBufferList = new nsScannerBufferList(AllocBufferFromString(aString));
     mIsDirty    = true;
 
     init_range_from_buffer_list();
     acquire_ownership_of_buffer_list();
   }
 
-const nsSubstring&
+const nsAString&
 nsScannerSubstring::AsString() const
   {
     if (mIsDirty)
       {
         nsScannerSubstring* mutable_this = const_cast<nsScannerSubstring*>(this);
 
         if (mStart.mBuffer == mEnd.mBuffer) {
           // We only have a single fragment to deal with, so just return it
--- a/parser/htmlparser/nsScannerString.h
+++ b/parser/htmlparser/nsScannerString.h
@@ -193,17 +193,17 @@ class nsScannerSubstring
 
       size_type Length() const { return mLength; }
 
       int32_t CountChar( char16_t ) const;
 
       void Rebind( const nsScannerSubstring&, const nsScannerIterator&, const nsScannerIterator& );
       void Rebind( const nsAString& );
 
-      const nsSubstring& AsString() const;
+      const nsAString& AsString() const;
 
       bool GetNextFragment( nsScannerFragment& ) const;
       bool GetPrevFragment( nsScannerFragment& ) const;
 
       static inline Buffer* AllocBufferFromString( const nsAString& aStr ) { return nsScannerBufferList::AllocBufferFromString(aStr); }
       static inline Buffer* AllocBuffer( size_type aCapacity )             { return nsScannerBufferList::AllocBuffer(aCapacity); }
 
     protected:
@@ -289,26 +289,26 @@ class nsScannerSharedSubstring
             ReleaseBuffer();
         }
 
         // Acquire a copy-on-write reference to the given substring.
       void Rebind(const nsScannerIterator& aStart,
                               const nsScannerIterator& aEnd);
 
        // Get a mutable reference to this string
-      nsSubstring& writable()
+      nsAString& writable()
         {
           if (mBufferList)
             MakeMutable();
 
           return mString;
         }
 
         // Get a const reference to this string
-      const nsSubstring& str() const { return mString; }
+      const nsAString& str() const { return mString; }
 
     private:
       typedef nsScannerBufferList::Buffer Buffer;
 
       void ReleaseBuffer();
       void MakeMutable();
 
       nsDependentSubstring  mString;
--- a/rdf/base/nsNameSpaceMap.cpp
+++ b/rdf/base/nsNameSpaceMap.cpp
@@ -28,17 +28,17 @@ nsresult
 nsNameSpaceMap::Put(const nsAString& aURI, nsIAtom* aPrefix)
 {
     nsCString uriUTF8;
     AppendUTF16toUTF8(aURI, uriUTF8);
     return Put(uriUTF8, aPrefix);
 }
 
 nsresult
-nsNameSpaceMap::Put(const nsCSubstring& aURI, nsIAtom* aPrefix)
+nsNameSpaceMap::Put(const nsACString& aURI, nsIAtom* aPrefix)
 {
     Entry* entry;
 
     // Make sure we're not adding a duplicate
     for (entry = mEntries; entry != nullptr; entry = entry->mNext) {
         if (entry->mURI == aURI || entry->mPrefix == aPrefix)
             return NS_ERROR_FAILURE;
     }
@@ -48,17 +48,17 @@ nsNameSpaceMap::Put(const nsCSubstring& 
         return NS_ERROR_OUT_OF_MEMORY;
 
     entry->mNext = mEntries;
     mEntries = entry;
     return NS_OK;
 }
 
 nsNameSpaceMap::const_iterator
-nsNameSpaceMap::GetNameSpaceOf(const nsCSubstring& aURI) const
+nsNameSpaceMap::GetNameSpaceOf(const nsACString& aURI) const
 {
     for (Entry* entry = mEntries; entry != nullptr; entry = entry->mNext) {
         if (StringBeginsWith(aURI, entry->mURI))
             return const_iterator(entry);
     }
 
     return last();
 }
--- a/rdf/base/nsNameSpaceMap.h
+++ b/rdf/base/nsNameSpaceMap.h
@@ -11,17 +11,17 @@
 #include "nsString.h"
 #include "nsIAtom.h"
 
 class nsNameSpaceMap
 {
 public:
     class Entry {
     public:
-        Entry(const nsCSubstring& aURI, nsIAtom* aPrefix)
+        Entry(const nsACString& aURI, nsIAtom* aPrefix)
             : mURI(aURI), mPrefix(aPrefix), mNext(nullptr) {
             MOZ_COUNT_CTOR(nsNameSpaceMap::Entry); }
 
         ~Entry() { MOZ_COUNT_DTOR(nsNameSpaceMap::Entry); }
         
         nsCString mURI;
         nsCOMPtr<nsIAtom> mPrefix; 
 
@@ -30,17 +30,17 @@ public:
 
     nsNameSpaceMap();
     ~nsNameSpaceMap();
 
     nsresult
     Put(const nsAString& aURI, nsIAtom* aPrefix);
 
     nsresult
-    Put(const nsCSubstring& aURI, nsIAtom* aPrefix);
+    Put(const nsACString& aURI, nsIAtom* aPrefix);
 
     class const_iterator {
     protected:
         friend class nsNameSpaceMap;
 
         explicit const_iterator(const Entry* aCurrent)
             : mCurrent(aCurrent) {}
 
@@ -83,16 +83,16 @@ public:
     };
 
     const_iterator first() const {
         return const_iterator(mEntries); }
 
     const_iterator last() const {
         return const_iterator(nullptr); }
 
-    const_iterator GetNameSpaceOf(const nsCSubstring& aURI) const;
+    const_iterator GetNameSpaceOf(const nsACString& aURI) const;
 
 protected:
     Entry* mEntries;
 };
 
 
 #endif // nsNameSpaceMap_h__
--- a/rdf/base/nsRDFXMLSerializer.cpp
+++ b/rdf/base/nsRDFXMLSerializer.cpp
@@ -162,17 +162,17 @@ rdf_BlockingWrite(nsIOutputStream* strea
 
         written += cb;
         remaining -= cb;
     }
     return NS_OK;
 }
 
 static nsresult
-rdf_BlockingWrite(nsIOutputStream* stream, const nsCSubstring& s)
+rdf_BlockingWrite(nsIOutputStream* stream, const nsACString& s)
 {
     return rdf_BlockingWrite(stream, s.BeginReading(), s.Length());
 }
 
 static nsresult
 rdf_BlockingWrite(nsIOutputStream* stream, const nsAString& s)
 {
     NS_ConvertUTF16toUTF8 utf8(s);
--- a/rdf/base/rdfutil.cpp
+++ b/rdf/base/rdfutil.cpp
@@ -32,17 +32,17 @@
 #include "nsXPIDLString.h"
 #include "nsUnicharUtils.h"
 #include "rdfutil.h"
 #include "prtime.h"
 
 ////////////////////////////////////////////////////////////////////////
 
 nsresult
-rdf_MakeRelativeRef(const nsCSubstring& aBaseURI, nsCString& aURI)
+rdf_MakeRelativeRef(const nsACString& aBaseURI, nsCString& aURI)
 {
     // This implementation is extremely simple: e.g., it can't compute
     // relative paths, or anything fancy like that. If the context URI
     // is not a prefix of the URI in question, we'll just bail.
     uint32_t prefixLen = aBaseURI.Length();
     if (prefixLen != 0 && StringBeginsWith(aURI, aBaseURI)) {
         if (prefixLen < aURI.Length() && aURI.CharAt(prefixLen) == '/')
             ++prefixLen; // chop the leading slash so it's not `absolute'
--- a/rdf/base/rdfutil.h
+++ b/rdf/base/rdfutil.h
@@ -22,17 +22,17 @@
 #ifndef rdfutil_h__
 #define rdfutil_h__
 
 
 class nsACString;
 class nsCString;
 
 nsresult
-rdf_MakeRelativeRef(const nsCSubstring& aBaseURI, nsCString& aURI);
+rdf_MakeRelativeRef(const nsACString& aBaseURI, nsCString& aURI);
 
 void
 rdf_FormatDate(PRTime aTime, nsACString &aResult);
 
 PRTime
 rdf_ParseDate(const nsACString &aTime);
 
 #endif // rdfutil_h__
--- a/security/manager/ssl/nsNSSIOLayer.cpp
+++ b/security/manager/ssl/nsNSSIOLayer.cpp
@@ -59,17 +59,17 @@ using namespace mozilla::psm;
                        //file.
 
 namespace {
 
 #define MAX_ALPN_LENGTH 255
 
 void
 getSiteKey(const nsACString& hostName, uint16_t port,
-           /*out*/ nsCSubstring& key)
+           /*out*/ nsACString& key)
 {
   key = hostName;
   key.AppendASCII(":");
   key.AppendInt(port);
 }
 
 } // unnamed namespace
 
@@ -1698,17 +1698,17 @@ nsSSLIOLayerHelpers::setInsecureFallback
 
   if (str.IsEmpty()) {
     return;
   }
 
   nsCCharSeparatedTokenizer toker(str, ',');
 
   while (toker.hasMoreTokens()) {
-    const nsCSubstring& host = toker.nextToken();
+    const nsACString& host = toker.nextToken();
     if (!host.IsEmpty()) {
       mInsecureFallbackSites.PutEntry(host);
     }
   }
 }
 
 void
 nsSSLIOLayerHelpers::initInsecureFallbackSites()
@@ -1741,17 +1741,17 @@ NS_IMETHODIMP
 FallbackPrefRemover::Run()
 {
   MOZ_ASSERT(NS_IsMainThread());
   nsCString oldValue;
   Preferences::GetCString("security.tls.insecure_fallback_hosts", &oldValue);
   nsCCharSeparatedTokenizer toker(oldValue, ',');
   nsCString newValue;
   while (toker.hasMoreTokens()) {
-    const nsCSubstring& host = toker.nextToken();
+    const nsACString& host = toker.nextToken();
     if (host.Equals(mHost)) {
       continue;
     }
     if (!newValue.IsEmpty()) {
       newValue.Append(',');
     }
     newValue.Append(host);
   }
--- a/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
+++ b/security/sandbox/linux/broker/SandboxBrokerPolicyFactory.cpp
@@ -207,17 +207,17 @@ SandboxBrokerPolicyFactory::GetContentPo
     policy(new SandboxBroker::Policy(*mCommonContentPolicy));
 
   // Now read any extra paths, this requires accessing user preferences
   // so we can only do it now. Our constructor is initialized before
   // user preferences are read in.
   nsAdoptingCString extraPathString =
     Preferences::GetCString("security.sandbox.content.write_path_whitelist");
   if (extraPathString) {
-    for (const nsCSubstring& path : extraPathString.Split(',')) {
+    for (const nsACString& path : extraPathString.Split(',')) {
       nsCString trimPath(path);
       trimPath.Trim(" ", true, true);
       policy->AddDynamic(rdwr, trimPath.get());
     }
   }
 
   // Return the common policy.
   return policy;
--- a/toolkit/components/places/nsNavHistoryQuery.cpp
+++ b/toolkit/components/places/nsNavHistoryQuery.cpp
@@ -32,17 +32,17 @@ public:
   //    input : qwerty&key=value&qwerty
   //                  ^   ^     ^
   //          aKeyBegin   |     aPastEnd (may point to null terminator)
   //                      aEquals
   //
   //    Special case: if aKeyBegin == aEquals, then there is only one string
   //    and no equal sign, so we treat the entire thing as a key with no value
 
-  QueryKeyValuePair(const nsCSubstring& aSource, int32_t aKeyBegin,
+  QueryKeyValuePair(const nsACString& aSource, int32_t aKeyBegin,
                     int32_t aEquals, int32_t aPastEnd)
   {
     if (aEquals == aKeyBegin)
       aEquals = aPastEnd;
     key = Substring(aSource, aKeyBegin, aEquals - aKeyBegin);
     if (aPastEnd - aEquals > 0)
       value = Substring(aSource, aEquals + 1, aPastEnd - aEquals - 1);
   }
--- a/toolkit/components/url-classifier/LookupCache.cpp
+++ b/toolkit/components/url-classifier/LookupCache.cpp
@@ -311,17 +311,17 @@ LookupCache::GetLookupFragments(const ns
   aSpec.BeginReading(begin);
   aSpec.EndReading(end);
 
   iter = begin;
   if (!FindCharInReadable('/', iter, end)) {
     return NS_OK;
   }
 
-  const nsCSubstring& host = Substring(begin, iter++);
+  const nsACString& host = Substring(begin, iter++);
   nsAutoCString path;
   path.Assign(Substring(iter, end));
 
   /**
    * From the protocol doc:
    * For the hostname, the client will try at most 5 different strings.  They
    * are:
    * a) The exact hostname of the url
@@ -412,17 +412,17 @@ LookupCache::GetHostKeys(const nsACStrin
   aSpec.BeginReading(begin);
   aSpec.EndReading(end);
 
   iter = begin;
   if (!FindCharInReadable('/', iter, end)) {
     return NS_OK;
   }
 
-  const nsCSubstring& host = Substring(begin, iter);
+  const nsACString& host = Substring(begin, iter);
 
   if (IsCanonicalizedIP(host)) {
     nsCString *key = aHostKeys->AppendElement();
     if (!key)
       return NS_ERROR_OUT_OF_MEMORY;
 
     key->Assign(host);
     key->Append("/");
--- a/toolkit/components/url-classifier/ProtocolParser.cpp
+++ b/toolkit/components/url-classifier/ProtocolParser.cpp
@@ -218,17 +218,17 @@ ProtocolParserV2::ProcessControl(bool* a
 
 nsresult
 ProtocolParserV2::ProcessExpirations(const nsCString& aLine)
 {
   if (!mTableUpdate) {
     NS_WARNING("Got an expiration without a table.");
     return NS_ERROR_FAILURE;
   }
-  const nsCSubstring &list = Substring(aLine, 3);
+  const nsACString& list = Substring(aLine, 3);
   nsACString::const_iterator begin, end;
   list.BeginReading(begin);
   list.EndReading(end);
   while (begin != end) {
     uint32_t first, last;
     if (ParseChunkRange(begin, end, &first, &last)) {
       if (last < first) return NS_ERROR_FAILURE;
       if (last - first > MAX_CHUNK_RANGE) return NS_ERROR_FAILURE;
@@ -324,17 +324,17 @@ ProtocolParserV2::ProcessChunkControl(co
   }
 
   return NS_OK;
 }
 
 nsresult
 ProtocolParserV2::ProcessForward(const nsCString& aLine)
 {
-  const nsCSubstring &forward = Substring(aLine, 2);
+  const nsACString& forward = Substring(aLine, 2);
   return AddForward(forward);
 }
 
 nsresult
 ProtocolParserV2::AddForward(const nsACString& aUrl)
 {
   if (!mTableUpdate) {
     NS_WARNING("Forward without a table name.");
@@ -532,17 +532,17 @@ ProtocolParserV2::ProcessDigestSub(const
 {
   // The ABNF format for sub chunks is (ADDCHUNKNUM HASH)+, where ADDCHUNKNUM
   // is a 4 byte chunk number, and HASH is 32 bytes.
   MOZ_ASSERT(aChunk.Length() % 36 == 0,
              "Chunk length in bytes must be divisible by 36");
   uint32_t start = 0;
   while (start < aChunk.Length()) {
     // Read ADDCHUNKNUM
-    const nsCSubstring& addChunkStr = Substring(aChunk, start, 4);
+    const nsACString& addChunkStr = Substring(aChunk, start, 4);
     start += 4;
 
     uint32_t addChunk;
     memcpy(&addChunk, addChunkStr.BeginReading(), 4);
     addChunk = PR_ntohl(addChunk);
 
     // Read the hash
     Completion hash;
@@ -599,17 +599,17 @@ ProtocolParserV2::ProcessHostSub(const P
                "ProcessHostSub should only be called for prefix hashes.");
 
   if (aNumEntries == 0) {
     if ((*aStart) + 4 > aChunk.Length()) {
       NS_WARNING("Received a zero-entry sub chunk without an associated add.");
       return NS_ERROR_FAILURE;
     }
 
-    const nsCSubstring& addChunkStr = Substring(aChunk, *aStart, 4);
+    const nsACString& addChunkStr = Substring(aChunk, *aStart, 4);
     *aStart += 4;
 
     uint32_t addChunk;
     memcpy(&addChunk, addChunkStr.BeginReading(), 4);
     addChunk = PR_ntohl(addChunk);
 
     PARSER_LOG(("Sub prefix (addchunk=%u)", addChunk));
     nsresult rv = mTableUpdate->NewSubPrefix(addChunk, aDomain, mChunkState.num);
@@ -620,17 +620,17 @@ ProtocolParserV2::ProcessHostSub(const P
   }
 
   if (*aStart + ((PREFIX_SIZE + 4) * aNumEntries) > aChunk.Length()) {
     NS_WARNING("Chunk is not long enough to contain the expected entries.");
     return NS_ERROR_FAILURE;
   }
 
   for (uint8_t i = 0; i < aNumEntries; i++) {
-    const nsCSubstring& addChunkStr = Substring(aChunk, *aStart, 4);
+    const nsACString& addChunkStr = Substring(aChunk, *aStart, 4);
     *aStart += 4;
 
     uint32_t addChunk;
     memcpy(&addChunk, addChunkStr.BeginReading(), 4);
     addChunk = PR_ntohl(addChunk);
 
     Prefix prefix;
     prefix.Assign(Substring(aChunk, *aStart, PREFIX_SIZE));
@@ -696,17 +696,17 @@ ProtocolParserV2::ProcessHostSubComplete
     return NS_ERROR_FAILURE;
   }
 
   for (uint8_t i = 0; i < aNumEntries; i++) {
     Completion hash;
     hash.Assign(Substring(aChunk, *aStart, COMPLETE_SIZE));
     *aStart += COMPLETE_SIZE;
 
-    const nsCSubstring& addChunkStr = Substring(aChunk, *aStart, 4);
+    const nsACString& addChunkStr = Substring(aChunk, *aStart, 4);
     *aStart += 4;
 
     uint32_t addChunk;
     memcpy(&addChunk, addChunkStr.BeginReading(), 4);
     addChunk = PR_ntohl(addChunk);
 
     nsresult rv = mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
     if (NS_FAILED(rv)) {
--- a/toolkit/xre/nsUpdateDriver.cpp
+++ b/toolkit/xre/nsUpdateDriver.cpp
@@ -185,17 +185,17 @@ GetXULRunnerStubPath(const char* argv0, 
     return rv;
 
   lfm.forget(aResult);
   return NS_OK;
 }
 #endif /* XP_MACOSX */
 
 static bool
-GetFile(nsIFile *dir, const nsCSubstring &name, nsCOMPtr<nsIFile> &result)
+GetFile(nsIFile* dir, const nsACString& name, nsCOMPtr<nsIFile>& result)
 {
   nsresult rv;
 
   nsCOMPtr<nsIFile> file;
   rv = dir->Clone(getter_AddRefs(file));
   if (NS_FAILED(rv))
     return false;
 
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1212,17 +1212,17 @@ NS_INTERFACE_MAP_BEGIN(nsExternalAppHand
    NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
    NS_INTERFACE_MAP_ENTRY(nsIHelperAppLauncher)
    NS_INTERFACE_MAP_ENTRY(nsICancelable)
    NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
    NS_INTERFACE_MAP_ENTRY(nsIBackgroundFileSaverObserver)
 NS_INTERFACE_MAP_END_THREADSAFE
 
 nsExternalAppHandler::nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo,
-                                           const nsCSubstring& aTempFileExtension,
+                                           const nsACString& aTempFileExtension,
                                            nsIInterfaceRequestor* aContentContext,
                                            nsIInterfaceRequestor* aWindowContext,
                                            nsExternalHelperAppService *aExtProtSvc,
                                            const nsAString& aSuggestedFilename,
                                            uint32_t aReason, bool aForceSave)
 : mMimeInfo(aMIMEInfo)
 , mContentContext(aContentContext)
 , mWindowContext(aWindowContext)
--- a/uriloader/exthandler/nsExternalHelperAppService.h
+++ b/uriloader/exthandler/nsExternalHelperAppService.h
@@ -232,17 +232,17 @@ public:
    *                        as passed to DoContent. This parameter may be null,
    *                        in which case dialogs will be parented to
    *                        aContentContext.
    * @param mExtProtSvc     nsExternalHelperAppService on creation
    * @param aFileName       The filename to use
    * @param aReason         A constant from nsIHelperAppLauncherDialog indicating
    *                        why the request is handled by a helper app.
    */
-  nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo, const nsCSubstring& aFileExtension,
+  nsExternalAppHandler(nsIMIMEInfo * aMIMEInfo, const nsACString& aFileExtension,
                        nsIInterfaceRequestor * aContentContext,
                        nsIInterfaceRequestor * aWindowContext,
                        nsExternalHelperAppService * aExtProtSvc,
                        const nsAString& aFilename,
                        uint32_t aReason, bool aForceSave);
 
   /**
    * Clean up after the request was diverted to the parent process.
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -823,17 +823,17 @@ nsOfflineManifestItem::HandleManifestLin
                 ++begin == end || static_cast<unsigned char>(*begin) != 0xbf) {
                 mParserState = PARSE_ERROR;
                 LogToConsole("Offline cache manifest BOM error", this);
                 return NS_OK;
             }
             ++begin;
         }
 
-        const nsCSubstring &magic = Substring(begin, end);
+        const nsACString& magic = Substring(begin, end);
 
         if (!magic.EqualsLiteral("CACHE MANIFEST")) {
             mParserState = PARSE_ERROR;
             LogToConsole("Offline cache manifest magic incorrect", this);
             return NS_OK;
         }
 
         mParserState = PARSE_CACHE_ENTRIES;
@@ -843,17 +843,17 @@ nsOfflineManifestItem::HandleManifestLin
     // lines other than the first ignore leading spaces and tabs
     while (begin != end && (*begin == ' ' || *begin == '\t'))
         begin++;
 
     // ignore blank lines and comments
     if (begin == end || *begin == '#')
         return NS_OK;
 
-    const nsCSubstring &line = Substring(begin, end);
+    const nsACString& line = Substring(begin, end);
 
     if (line.EqualsLiteral("CACHE:")) {
         mParserState = PARSE_CACHE_ENTRIES;
         return NS_OK;
     }
 
     if (line.EqualsLiteral("FALLBACK:")) {
         mParserState = PARSE_FALLBACK_ENTRIES;
@@ -1997,17 +1997,17 @@ nsOfflineCacheUpdate::StickDocument(nsIU
 void
 nsOfflineCacheUpdate::SetOwner(nsOfflineCacheUpdateOwner *aOwner)
 {
     NS_ASSERTION(!mOwner, "Tried to set cache update owner twice.");
     mOwner = aOwner;
 }
 
 bool
-nsOfflineCacheUpdate::IsForGroupID(const nsCSubstring &groupID)
+nsOfflineCacheUpdate::IsForGroupID(const nsACString& groupID)
 {
     return mGroupID == groupID;
 }
 
 bool
 nsOfflineCacheUpdate::IsForProfile(nsIFile* aCustomProfileDir)
 {
     if (!mCustomProfileDir && !aCustomProfileDir)
--- a/uriloader/prefetch/nsOfflineCacheUpdate.h
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.h
@@ -218,17 +218,17 @@ public:
 
     void LoadCompleted(nsOfflineCacheUpdateItem *aItem);
     void ManifestCheckCompleted(nsresult aStatus,
                                 const nsCString &aManifestHash);
     void StickDocument(nsIURI *aDocumentURI);
 
     void SetOwner(nsOfflineCacheUpdateOwner *aOwner);
 
-    bool IsForGroupID(const nsCSubstring &groupID);
+    bool IsForGroupID(const nsACString& groupID);
     bool IsForProfile(nsIFile* aCustomProfileDir);
 
     virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) override;
 
 protected:
     ~nsOfflineCacheUpdate();
 
     friend class nsOfflineCacheUpdateItem;
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -220,17 +220,17 @@ LogMessageWithContext(FileLocation& aFil
  *   "flag="no|false|0"
  * @param aFlag The flag to compare.
  * @param aData The tokenized data to check; this is lowercased
  *              before being passed in.
  * @param aResult If the flag is found, the value is assigned here.
  * @return Whether the flag was handled.
  */
 static bool
-CheckFlag(const nsSubstring& aFlag, const nsSubstring& aData, bool& aResult)
+CheckFlag(const nsAString& aFlag, const nsAString& aData, bool& aResult)
 {
   if (!StringBeginsWith(aData, aFlag)) {
     return false;
   }
 
   if (aFlag.Length() == aData.Length()) {
     // the data is simply "flag", which is the same as "flag=yes"
     aResult = true;
@@ -279,18 +279,18 @@ enum TriState
  * @param aData The tokenized data to check; this is lowercased
  *              before being passed in.
  * @param aValue The value that is expected.
  * @param aResult If this is "ok" when passed in, this is left alone.
  *                Otherwise if the flag is found it is set to eBad or eOK.
  * @return Whether the flag was handled.
  */
 static bool
-CheckStringFlag(const nsSubstring& aFlag, const nsSubstring& aData,
-                const nsSubstring& aValue, TriState& aResult)
+CheckStringFlag(const nsAString& aFlag, const nsAString& aData,
+                const nsAString& aValue, TriState& aResult)
 {
   if (aData.Length() < aFlag.Length() + 1) {
     return false;
   }
 
   if (!StringBeginsWith(aData, aFlag)) {
     return false;
   }
@@ -315,18 +315,18 @@ CheckStringFlag(const nsSubstring& aFlag
       aResult = comparison ? eBad : eOK;
     }
   }
 
   return true;
 }
 
 static bool
-CheckOsFlag(const nsSubstring& aFlag, const nsSubstring& aData,
-            const nsSubstring& aValue, TriState& aResult)
+CheckOsFlag(const nsAString& aFlag, const nsAString& aData,
+            const nsAString& aValue, TriState& aResult)
 {
   bool result = CheckStringFlag(aFlag, aData, aValue, aResult);
 #if defined(XP_UNIX) && !defined(XP_DARWIN) && !defined(ANDROID)
   if (result && aResult == eBad) {
     result = CheckStringFlag(aFlag, aData, NS_LITERAL_STRING("likeunix"), aResult);
   }
 #endif
   return result;
--- a/xpcom/ds/nsCharSeparatedTokenizer.h
+++ b/xpcom/ds/nsCharSeparatedTokenizer.h
@@ -165,33 +165,33 @@ private:
   bool mSeparatorOptional;
 };
 
 template<bool IsWhitespace(char16_t) = NS_IsAsciiWhitespace>
 class nsCharSeparatedTokenizerTemplate
   : public nsTCharSeparatedTokenizer<nsDependentSubstring, IsWhitespace>
 {
 public:
-  nsCharSeparatedTokenizerTemplate(const nsSubstring& aSource,
+  nsCharSeparatedTokenizerTemplate(const nsAString& aSource,
                                    char16_t aSeparatorChar,
                                    uint32_t aFlags = 0)
     : nsTCharSeparatedTokenizer<nsDependentSubstring,
                                 IsWhitespace>(aSource, aSeparatorChar, aFlags)
   {
   }
 };
 
 typedef nsCharSeparatedTokenizerTemplate<> nsCharSeparatedTokenizer;
 
 template<bool IsWhitespace(char16_t) = NS_IsAsciiWhitespace>
 class nsCCharSeparatedTokenizerTemplate
   : public nsTCharSeparatedTokenizer<nsDependentCSubstring, IsWhitespace>
 {
 public:
-  nsCCharSeparatedTokenizerTemplate(const nsCSubstring& aSource,
+  nsCCharSeparatedTokenizerTemplate(const nsACString& aSource,
                                     char aSeparatorChar,
                                     uint32_t aFlags = 0)
     : nsTCharSeparatedTokenizer<nsDependentCSubstring,
                                 IsWhitespace>(aSource, aSeparatorChar, aFlags)
   {
   }
 };
 
--- a/xpcom/ds/nsWhitespaceTokenizer.h
+++ b/xpcom/ds/nsWhitespaceTokenizer.h
@@ -81,30 +81,30 @@ private:
   bool mWhitespaceAfterCurrentToken;
 };
 
 template<bool IsWhitespace(char16_t) = NS_IsAsciiWhitespace>
 class nsWhitespaceTokenizerTemplate
   : public nsTWhitespaceTokenizer<nsDependentSubstring, IsWhitespace>
 {
 public:
-  explicit nsWhitespaceTokenizerTemplate(const nsSubstring& aSource)
+  explicit nsWhitespaceTokenizerTemplate(const nsAString& aSource)
     : nsTWhitespaceTokenizer<nsDependentSubstring, IsWhitespace>(aSource)
   {
   }
 };
 
 typedef nsWhitespaceTokenizerTemplate<> nsWhitespaceTokenizer;
 
 template<bool IsWhitespace(char16_t) = NS_IsAsciiWhitespace>
 class nsCWhitespaceTokenizerTemplate
   : public nsTWhitespaceTokenizer<nsDependentCSubstring, IsWhitespace>
 {
 public:
-  explicit nsCWhitespaceTokenizerTemplate(const nsCSubstring& aSource)
+  explicit nsCWhitespaceTokenizerTemplate(const nsACString& aSource)
     : nsTWhitespaceTokenizer<nsDependentCSubstring, IsWhitespace>(aSource)
   {
   }
 };
 
 typedef nsCWhitespaceTokenizerTemplate<> nsCWhitespaceTokenizer;
 
 #endif /* __nsWhitespaceTokenizer_h */
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -478,41 +478,41 @@ NS_EscapeURL(const char* aPart, int32_t 
   if (NS_FAILED(rv)) {
     ::NS_ABORT_OOM(aResult.Length() * sizeof(nsACString::char_type));
   }
 
   return result;
 }
 
 nsresult
-NS_EscapeURL(const nsCSubstring& aStr, uint32_t aFlags, nsCSubstring& aResult,
+NS_EscapeURL(const nsACString& aStr, uint32_t aFlags, nsACString& aResult,
              const mozilla::fallible_t&)
 {
   bool appended = false;
   nsresult rv = T_EscapeURL(aStr.Data(), aStr.Length(), aFlags, aResult, appended);
   if (NS_FAILED(rv)) {
     aResult.Truncate();
     return rv;
   }
 
   if (!appended) {
     aResult = aStr;
   }
 
   return rv;
 }
 
-const nsSubstring&
-NS_EscapeURL(const nsSubstring& aStr, uint32_t aFlags, nsSubstring& aResult)
+const nsAString&
+NS_EscapeURL(const nsAString& aStr, uint32_t aFlags, nsAString& aResult)
 {
   bool result = false;
-  nsresult rv = T_EscapeURL<nsSubstring>(aStr.Data(), aStr.Length(), aFlags, aResult, result);
+  nsresult rv = T_EscapeURL<nsAString>(aStr.Data(), aStr.Length(), aFlags, aResult, result);
 
   if (NS_FAILED(rv)) {
-    ::NS_ABORT_OOM(aResult.Length() * sizeof(nsSubstring::char_type));
+    ::NS_ABORT_OOM(aResult.Length() * sizeof(nsAString::char_type));
   }
 
   if (result) {
     return aResult;
   }
   return aStr;
 }
 
@@ -528,19 +528,19 @@ FindFirstMatchFrom(const nsString& aStr,
     if (mozilla::BinarySearch(aForbidden, 0, len, aStr[j], &unused)) {
       *aIndex = j;
       return true;
     }
   }
   return false;
 }
 
-const nsSubstring&
+const nsAString&
 NS_EscapeURL(const nsString& aStr, const nsTArray<char16_t>& aForbidden,
-             nsSubstring& aResult)
+             nsAString& 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;
         aResult.Truncate();
--- a/xpcom/io/nsEscape.h
+++ b/xpcom/io/nsEscape.h
@@ -147,56 +147,56 @@ inline int32_t
 NS_UnescapeURL(char* aStr)
 {
   return nsUnescapeCount(aStr);
 }
 
 /**
  * String friendly versions...
  */
-inline const nsCSubstring&
-NS_EscapeURL(const nsCSubstring& aStr, uint32_t aFlags, nsCSubstring& aResult)
+inline const nsACString&
+NS_EscapeURL(const nsACString& aStr, uint32_t aFlags, nsACString& aResult)
 {
   if (NS_EscapeURL(aStr.Data(), aStr.Length(), aFlags, aResult)) {
     return aResult;
   }
   return aStr;
 }
 
 /**
  * Fallible version of NS_EscapeURL. On success aResult will point to either
  * the original string or an escaped copy.
  */
 nsresult
-NS_EscapeURL(const nsCSubstring& aStr, uint32_t aFlags, nsCSubstring& aResult,
+NS_EscapeURL(const nsACString& aStr, uint32_t aFlags, nsACString& aResult,
              const mozilla::fallible_t&);
 
-inline const nsCSubstring&
-NS_UnescapeURL(const nsCSubstring& aStr, uint32_t aFlags, nsCSubstring& aResult)
+inline const nsACString&
+NS_UnescapeURL(const nsACString& aStr, uint32_t aFlags, nsACString& aResult)
 {
   if (NS_UnescapeURL(aStr.Data(), aStr.Length(), aFlags, aResult)) {
     return aResult;
   }
   return aStr;
 }
-const nsSubstring&
-NS_EscapeURL(const nsSubstring& aStr, uint32_t aFlags, nsSubstring& aResult);
+const nsAString&
+NS_EscapeURL(const nsAString& aStr, uint32_t aFlags, nsAString& aResult);
 
 /**
  * Percent-escapes all characters in aStr that occurs in aForbidden.
  * @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&
+const nsAString&
 NS_EscapeURL(const nsString& aStr, const nsTArray<char16_t>& aForbidden,
-             nsSubstring& aResult);
+             nsAString& 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,
           nsEscapeMask aMask)
--- a/xpcom/string/nsReadableUtils.cpp
+++ b/xpcom/string/nsReadableUtils.cpp
@@ -747,17 +747,17 @@ public:
       }
       ++cp;
     }
     return aSourceLength;
   }
 };
 
 void
-ToUpperCase(nsCSubstring& aCString)
+ToUpperCase(nsACString& aCString)
 {
   ConvertToUpperCase converter;
   char* start;
   converter.write(aCString.BeginWriting(start), aCString.Length());
 }
 
 /**
  * A character sink for copying with case conversion.
@@ -831,17 +831,17 @@ public:
       }
       ++cp;
     }
     return aSourceLength;
   }
 };
 
 void
-ToLowerCase(nsCSubstring& aCString)
+ToLowerCase(nsACString& aCString)
 {
   ConvertToLowerCase converter;
   char* start;
   converter.write(aCString.BeginWriting(start), aCString.Length());
 }
 
 /**
  * A character sink for copying with case conversion.
--- a/xpcom/string/nsReadableUtils.h
+++ b/xpcom/string/nsReadableUtils.h
@@ -293,19 +293,19 @@ bool ParseString(const nsACString& aAstr
 
 /**
  * Converts case in place in the argument string.
  */
 void ToUpperCase(nsACString&);
 
 void ToLowerCase(nsACString&);
 
-void ToUpperCase(nsCSubstring&);
+void ToUpperCase(nsACString&);
 
-void ToLowerCase(nsCSubstring&);
+void ToLowerCase(nsACString&);
 
 /**
  * Converts case from string aSource to aDest.
  */
 void ToUpperCase(const nsACString& aSource, nsACString& aDest);
 
 void ToLowerCase(const nsACString& aSource, nsACString& aDest);
 
--- a/xpcom/string/nsStringFwd.h
+++ b/xpcom/string/nsStringFwd.h
@@ -19,48 +19,33 @@ namespace mozilla {
 namespace detail {
 
 class nsStringRepr;
 class nsCStringRepr;
 
 } // namespace detail
 } // namespace mozilla
 
-/**
- * double-byte (char16_t) string types
- */
-
+// Double-byte (char16_t) string types.
 class nsAString;
 class nsSubstringTuple;
 class nsString;
 class nsAutoString;
 class nsDependentString;
 class nsDependentSubstring;
 class nsPromiseFlatString;
 class nsStringComparator;
 class nsDefaultStringComparator;
 class nsXPIDLString;
 
-
-/**
- * single-byte (char) string types
- */
-
+// Single-byte (char) string types.
 class nsACString;
 class nsCSubstringTuple;
 class nsCString;
 class nsAutoCString;
 class nsDependentCString;
 class nsDependentCSubstring;
 class nsPromiseFlatCString;
 class nsCStringComparator;
 class nsDefaultCStringComparator;
 class nsXPIDLCString;
 
-
-/**
- * typedefs for backwards compatibility
- */
-
-typedef nsAString             nsSubstring;
-typedef nsACString            nsCSubstring;
-
 #endif /* !defined(nsStringFwd_h___) */
--- a/xpcom/string/nsSubstring.cpp
+++ b/xpcom/string/nsSubstring.cpp
@@ -104,19 +104,19 @@ static nsStringStats gStringStats;
 #define STRING_STAT_INCREMENT(_s)
 #endif
 
 // ---------------------------------------------------------------------------
 
 void
 ReleaseData(void* aData, uint32_t aFlags)
 {
-  if (aFlags & nsSubstring::F_SHARED) {
+  if (aFlags & nsAString::F_SHARED) {
     nsStringBuffer::FromData(aData)->Release();
-  } else if (aFlags & nsSubstring::F_OWNED) {
+  } else if (aFlags & nsAString::F_OWNED) {
     free(aData);
     STRING_STAT_INCREMENT(AdoptFree);
     // Treat this as destruction of a "StringAdopt" object for leak
     // tracking purposes.
     MOZ_LOG_DTOR(aData, "StringAdopt", 1);
   }
   // otherwise, nothing to do.
 }
@@ -278,30 +278,30 @@ nsStringBuffer::Realloc(nsStringBuffer* 
 }
 
 nsStringBuffer*
 nsStringBuffer::FromString(const nsAString& aStr)
 {
   const nsAStringAccessor* accessor =
     static_cast<const nsAStringAccessor*>(&aStr);
 
-  if (!(accessor->flags() & nsSubstring::F_SHARED)) {
+  if (!(accessor->flags() & nsAString::F_SHARED)) {
     return nullptr;
   }
 
   return FromData(accessor->data());
 }
 
 nsStringBuffer*
 nsStringBuffer::FromString(const nsACString& aStr)
 {
   const nsACStringAccessor* accessor =
     static_cast<const nsACStringAccessor*>(&aStr);
 
-  if (!(accessor->flags() & nsCSubstring::F_SHARED)) {
+  if (!(accessor->flags() & nsACString::F_SHARED)) {
     return nullptr;
   }
 
   return FromData(accessor->data());
 }
 
 void
 nsStringBuffer::ToString(uint32_t aLen, nsAString& aStr,
@@ -310,17 +310,17 @@ nsStringBuffer::ToString(uint32_t aLen, 
   char16_t* data = static_cast<char16_t*>(Data());
 
   nsAStringAccessor* accessor = static_cast<nsAStringAccessor*>(&aStr);
   MOZ_DIAGNOSTIC_ASSERT(data[aLen] == char16_t(0),
                         "data should be null terminated");
 
   // preserve class flags
   uint32_t flags = accessor->flags();
-  flags = (flags & 0xFFFF0000) | nsSubstring::F_SHARED | nsSubstring::F_TERMINATED;
+  flags = (flags & 0xFFFF0000) | nsAString::F_SHARED | nsAString::F_TERMINATED;
 
   if (!aMoveOwnership) {
     AddRef();
   }
   accessor->set(data, aLen, flags);
 }
 
 void
@@ -330,17 +330,17 @@ nsStringBuffer::ToString(uint32_t aLen, 
   char* data = static_cast<char*>(Data());
 
   nsACStringAccessor* accessor = static_cast<nsACStringAccessor*>(&aStr);
   MOZ_DIAGNOSTIC_ASSERT(data[aLen] == char(0),
                         "data should be null terminated");
 
   // preserve class flags
   uint32_t flags = accessor->flags();
-  flags = (flags & 0xFFFF0000) | nsCSubstring::F_SHARED | nsCSubstring::F_TERMINATED;
+  flags = (flags & 0xFFFF0000) | nsACString::F_SHARED | nsACString::F_TERMINATED;
 
   if (!aMoveOwnership) {
     AddRef();
   }
   accessor->set(data, aLen, flags);
 }
 
 size_t
@@ -352,23 +352,22 @@ nsStringBuffer::SizeOfIncludingThisIfUns
 size_t
 nsStringBuffer::SizeOfIncludingThisEvenIfShared(mozilla::MallocSizeOf aMallocSizeOf) const
 {
   return aMallocSizeOf(this);
 }
 
 // ---------------------------------------------------------------------------
 
-
-// define nsSubstring
+// define nsAString
 #include "string-template-def-unichar.h"
 #include "nsTSubstring.cpp"
 #include "string-template-undef.h"
 
-// define nsCSubstring
+// define nsACString
 #include "string-template-def-char.h"
 #include "nsTSubstring.cpp"
 #include "string-template-undef.h"
 
 // Provide rust bindings to the nsA[C]String types
 extern "C" {
 
 // This is a no-op on release, so we ifdef it out such that using it in release
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -1037,17 +1037,17 @@ public:
   void StripCRLF();
 
   /**
    * If the string uses a shared buffer, this method
    * clears the pointer without releasing the buffer.
    */
   void ForgetSharedBuffer()
   {
-    if (mFlags & nsSubstring::F_SHARED) {
+    if (mFlags & nsAString::F_SHARED) {
       mData = char_traits::sEmptyBuffer;
       mLength = 0;
       mFlags = F_TERMINATED;
     }
   }
 
 public:
 
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -1013,77 +1013,77 @@ TEST(Strings, Split)
              three("one--three"),
              empty(""),
              delimStart("-two"),
              delimEnd("one-");
 
   nsString wide(u"hello world");
 
   size_t counter = 0;
-  for (const nsCSubstring& token : one.Split(',')) {
+  for (const nsACString& token : one.Split(',')) {
     EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("one")));
     counter++;
   }
   EXPECT_EQ(counter, (size_t)1);
 
   counter = 0;
-  for (const nsCSubstring& token : two.Split(';')) {
+  for (const nsACString& token : two.Split(';')) {
     if (counter == 0) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("one")));
     } else if (counter == 1) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("two")));
     }
     counter++;
   }
   EXPECT_EQ(counter, (size_t)2);
 
   counter = 0;
-  for (const nsCSubstring& token : three.Split('-')) {
+  for (const nsACString& token : three.Split('-')) {
     if (counter == 0) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("one")));
     } else if (counter == 1) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("")));
     } else if (counter == 2) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("three")));
     }
     counter++;
   }
   EXPECT_EQ(counter, (size_t)3);
 
   counter = 0;
-  for (const nsCSubstring& token : empty.Split(',')) {
+  for (const nsACString& token : empty.Split(',')) {
     mozilla::Unused << token;
     counter++;
   }
   EXPECT_EQ(counter, (size_t)0);
 
   counter = 0;
-  for (const nsCSubstring& token : delimStart.Split('-')) {
+  for (const nsACString& token : delimStart.Split('-')) {
     if (counter == 0) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("")));
     } else if (counter == 1) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("two")));
     }
     counter++;
   }
   EXPECT_EQ(counter, (size_t)2);
 
   counter = 0;
-  for (const nsCSubstring& token : delimEnd.Split('-')) {
+  for (const nsACString& token : delimEnd.Split('-')) {
     if (counter == 0) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("one")));
     } else if (counter == 1) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_CSTRING("")));
     }
     counter++;
   }
   EXPECT_EQ(counter, (size_t)2);
 
   counter = 0;
-  for (const nsSubstring& token : wide.Split(' ')) {
+  for (const nsAString& token : wide.Split(' ')) {
     if (counter == 0) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_STRING("hello")));
     } else if (counter == 1) {
       EXPECT_TRUE(token.Equals(NS_LITERAL_STRING("world")));
     }
     counter++;
   }
   EXPECT_EQ(counter, (size_t)2);
--- a/xpcom/threads/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -22,17 +22,17 @@
   } while(0)
 #else
 #define ASSERT_OWNING_THREAD() /* nothing */
 #endif
 
 namespace mozilla {
 
 LazyIdleThread::LazyIdleThread(uint32_t aIdleTimeoutMS,
-                               const nsCSubstring& aName,
+                               const nsACString& aName,
                                ShutdownMethod aShutdownMethod,
                                nsIObserver* aIdleObserver)
   : mMutex("LazyIdleThread::mMutex")
   , mOwningEventTarget(GetCurrentThreadSerialEventTarget())
   , mIdleObserver(aIdleObserver)
   , mQueuedRunnables(nullptr)
   , mIdleTimeoutMS(aIdleTimeoutMS)
   , mPendingEventCount(0)
--- a/xpcom/threads/LazyIdleThread.h
+++ b/xpcom/threads/LazyIdleThread.h
@@ -52,17 +52,17 @@ public:
     ManualShutdown
   };
 
   /**
    * Create a new LazyIdleThread that will destroy its thread after the given
    * number of milliseconds.
    */
   LazyIdleThread(uint32_t aIdleTimeoutMS,
-                 const nsCSubstring& aName,
+                 const nsACString& aName,
                  ShutdownMethod aShutdownMethod = AutomaticShutdown,
                  nsIObserver* aIdleObserver = nullptr);
 
   /**
    * Add an observer that will be notified when the thread is idle and about to
    * be shut down. The aSubject argument can be QueryInterface'd to an nsIThread
    * that can be used to post cleanup events. The aTopic argument will be
    * IDLE_THREAD_TOPIC, and aData will be null. The LazyIdleThread does not add