Bug 1490402 - Use UTF-8 strings (in place of UTF-16) for font family/face names in the system font list, to reduce memory footprint. r=lsalzman
authorJonathan Kew <jkew@mozilla.com>
Wed, 12 Sep 2018 20:34:57 +0100
changeset 491803 588fe70e5905480ebc60225b4b093ff276df72d2
parent 491802 643ffcb9063dfb9395c76d81665ed4cd03c0dff3
child 491804 8b3b7ee0fffbe93416ea6f2769366fa330f14556
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1490402
milestone64.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 1490402 - Use UTF-8 strings (in place of UTF-16) for font family/face names in the system font list, to reduce memory footprint. r=lsalzman
accessible/base/TextAttrs.cpp
accessible/windows/sdn/sdnTextAccessible.cpp
dom/events/ContentEventHandler.cpp
dom/ipc/PContent.ipdl
gfx/src/nsThebesFontEnumerator.cpp
gfx/thebes/gfxDWriteFontList.cpp
gfx/thebes/gfxDWriteFontList.h
gfx/thebes/gfxDWriteFonts.cpp
gfx/thebes/gfxFT2FontList.cpp
gfx/thebes/gfxFT2FontList.h
gfx/thebes/gfxFT2Utils.cpp
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFcPlatformFontList.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxFont.h
gfx/thebes/gfxFontEntry.cpp
gfx/thebes/gfxFontEntry.h
gfx/thebes/gfxFontFamilyList.h
gfx/thebes/gfxFontFeatures.cpp
gfx/thebes/gfxFontFeatures.h
gfx/thebes/gfxFontInfoLoader.cpp
gfx/thebes/gfxFontInfoLoader.h
gfx/thebes/gfxFontUtils.cpp
gfx/thebes/gfxFontUtils.h
gfx/thebes/gfxFontVariations.h
gfx/thebes/gfxGDIFont.cpp
gfx/thebes/gfxGDIFontList.cpp
gfx/thebes/gfxGDIFontList.h
gfx/thebes/gfxHarfBuzzShaper.cpp
gfx/thebes/gfxMacFont.cpp
gfx/thebes/gfxMacPlatformFontList.h
gfx/thebes/gfxMacPlatformFontList.mm
gfx/thebes/gfxPlatform.cpp
gfx/thebes/gfxPlatform.h
gfx/thebes/gfxPlatformFontList.cpp
gfx/thebes/gfxPlatformFontList.h
gfx/thebes/gfxPlatformGtk.cpp
gfx/thebes/gfxPlatformGtk.h
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxPlatformMac.h
gfx/thebes/gfxTextRun.cpp
gfx/thebes/gfxTextRun.h
gfx/thebes/gfxUserFontSet.cpp
gfx/thebes/gfxUserFontSet.h
layout/inspector/InspectorFontFace.cpp
layout/style/FontFace.cpp
layout/style/FontFace.h
layout/style/FontFaceSet.cpp
layout/style/FontFaceSet.h
layout/style/ServoBindings.cpp
layout/style/nsFontFaceUtils.cpp
widget/cocoa/nsLookAndFeel.mm
--- a/accessible/base/TextAttrs.cpp
+++ b/accessible/base/TextAttrs.cpp
@@ -475,17 +475,17 @@ TextAttrsMgr::FontFamilyTextAttr::
   GetFontFamily(nsIFrame* aFrame, nsString& aFamily)
 {
   RefPtr<nsFontMetrics> fm =
     nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
 
   gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
   gfxFont* font = fontGroup->GetFirstValidFont();
   gfxFontEntry* fontEntry = font->GetFontEntry();
-  aFamily = fontEntry->FamilyName();
+  aFamily.Append(NS_ConvertUTF8toUTF16(fontEntry->FamilyName()));
   return true;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // FontSizeTextAttr
 ////////////////////////////////////////////////////////////////////////////////
 
--- a/accessible/windows/sdn/sdnTextAccessible.cpp
+++ b/accessible/windows/sdn/sdnTextAccessible.cpp
@@ -158,22 +158,23 @@ sdnTextAccessible::get_fontFamily(BSTR _
 
   nsIFrame* frame = mAccessible->GetFrame();
   if (!frame)
     return E_FAIL;
 
   RefPtr<nsFontMetrics> fm =
     nsLayoutUtils::GetFontMetricsForFrame(frame, 1.0f);
 
-  const nsString& name =
+  const nsCString& name =
     fm->GetThebesFontGroup()->GetFirstValidFont()->GetName();
   if (name.IsEmpty())
     return S_FALSE;
 
-  *aFontFamily = ::SysAllocStringLen(name.get(), name.Length());
+  NS_ConvertUTF8toUTF16 str(name);
+  *aFontFamily = ::SysAllocStringLen(str.get(), str.Length());
   return *aFontFamily ? S_OK : E_OUTOFMEMORY;
 }
 
 nsIFrame*
 sdnTextAccessible::GetPointFromOffset(nsIFrame* aContainingFrame,
                                       int32_t aOffset,
                                       bool aPreferNext,
                                       nsPoint& aOutPoint)
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -936,17 +936,17 @@ ContentEventHandler::AppendFontRanges(Fo
         // Create range for skipped leading chars.
         AppendFontRange(aFontRanges, baseOffset);
         baseOffset += GetTextLengthInRange(
           aContent, lastXPEndOffset, startXPOffset, aLineBreakType);
         lastXPEndOffset = startXPOffset;
       }
 
       FontRange* fontRange = AppendFontRange(aFontRanges, baseOffset);
-      fontRange->mFontName = font->GetName();
+      fontRange->mFontName.Append(NS_ConvertUTF8toUTF16(font->GetName()));
       fontRange->mFontSize = font->GetAdjustedSize();
 
       // The converted original offset may exceed the range,
       // hence we need to clamp it.
       uint32_t endXPOffset =
         iter.ConvertSkippedToOriginal(runIter.GetStringEnd());
       endXPOffset = std::min(frameXPEnd, endXPOffset);
       baseOffset += GetTextLengthInRange(aContent, startXPOffset, endXPOffset,
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -110,32 +110,32 @@ union ChromeRegistryItem
 };
 
 namespace mozilla {
 namespace dom {
 
 // Used on Android/B2G to pass the list of fonts on the device
 // to the child process
 struct FontListEntry {
-    nsString  familyName;
-    nsString  faceName;
+    nsCString familyName;
+    nsCString faceName;
     nsCString filepath;
     uint32_t  weightRange;
     uint32_t  stretchRange;
     uint32_t  styleRange;
     uint8_t   index;
 };
 
 // Used on Mac OS X to pass the list of font families (not faces)
 // from chrome to content processes.
 // The entryType field distinguishes several types of font family
 // record; see gfxMacPlatformFontList.h for values and meaning.
 struct FontFamilyListEntry {
-    nsString familyName;
-    uint8_t  entryType;
+    nsCString familyName;
+    uint8_t   entryType;
 };
 
 // Used on Linux to pass list of font patterns from chrome to content.
 struct FontPatternListEntry {
     nsCString pattern;
     bool      appFontFamily;
 };
 
--- a/gfx/src/nsThebesFontEnumerator.cpp
+++ b/gfx/src/nsThebesFontEnumerator.cpp
@@ -237,17 +237,17 @@ nsThebesFontEnumerator::GetDefaultFont(c
                                        char16_t **aResult)
 {
     if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aLangGroup) ||
         NS_WARN_IF(!aGeneric)) {
         return NS_ERROR_INVALID_ARG;
     }
 
     *aResult = nullptr;
-    nsAutoString defaultFontName(gfxPlatform::GetPlatform()->
+    nsAutoCString defaultFontName(gfxPlatform::GetPlatform()->
         GetDefaultFontName(nsDependentCString(aLangGroup),
                            nsDependentCString(aGeneric)));
     if (!defaultFontName.IsEmpty()) {
         *aResult = ToNewUnicode(defaultFontName);
     }
     return NS_OK;
 }
 
@@ -267,18 +267,18 @@ nsThebesFontEnumerator::GetStandardFamil
     NS_ENSURE_ARG_POINTER(aName);
 
     nsAutoString name(aName);
     if (name.IsEmpty()) {
         *aResult = nullptr;
         return NS_OK;
     }
 
-    nsAutoString family;
-    nsresult rv = gfxPlatform::GetPlatform()->
-        GetStandardFamilyName(nsDependentString(aName), family);
-    if (NS_FAILED(rv) || family.IsEmpty()) {
+    nsAutoCString family;
+    gfxPlatform::GetPlatform()->
+        GetStandardFamilyName(NS_ConvertUTF16toUTF8(aName), family);
+    if (family.IsEmpty()) {
         *aResult = nullptr;
         return NS_OK;
     }
     *aResult = ToNewUnicode(family);
     return NS_OK;
 }
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -43,32 +43,30 @@ using mozilla::intl::OSPreferences;
                                    gfxPlatform::GetLog(eGfxLog_fontinit), \
                                    LogLevel::Debug)
 
 #define LOG_CMAPDATA_ENABLED() MOZ_LOG_TEST( \
                                    gfxPlatform::GetLog(eGfxLog_cmapdata), \
                                    LogLevel::Debug)
 
 static __inline void
-BuildKeyNameFromFontName(nsAString &aName)
+BuildKeyNameFromFontName(nsACString &aName)
 {
-    if (aName.Length() >= LF_FACESIZE)
-        aName.Truncate(LF_FACESIZE - 1);
     ToLowerCase(aName);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // gfxDWriteFontFamily
 
 gfxDWriteFontFamily::~gfxDWriteFontFamily()
 {
 }
 
 static bool
-GetEnglishOrFirstName(nsAString& aName, IDWriteLocalizedStrings* aStrings)
+GetEnglishOrFirstName(nsACString& aName, IDWriteLocalizedStrings* aStrings)
 {
     UINT32 englishIdx = 0;
     BOOL exists;
     HRESULT hr = aStrings->FindLocaleName(L"en-us", &englishIdx, &exists);
     if (FAILED(hr)) {
         return false;
     }
     if (!exists) {
@@ -84,22 +82,23 @@ GetEnglishOrFirstName(nsAString& aName, 
     if (!enName.SetLength(length + 1, fallible)) {
         // Eeep - running out of memory. Unlikely to end well.
         return false;
     }
     hr = aStrings->GetString(englishIdx, enName.Elements(), length + 1);
     if (FAILED(hr)) {
         return false;
     }
-    aName.Assign(enName.Elements());
+    aName.Append(NS_ConvertUTF16toUTF8((const char16_t*)enName.Elements(),
+                                       enName.Length() - 1));
     return true;
 }
 
 static HRESULT
-GetDirectWriteFontName(IDWriteFont *aFont, nsAString& aFontName)
+GetDirectWriteFontName(IDWriteFont *aFont, nsACString& aFontName)
 {
     HRESULT hr;
 
     RefPtr<IDWriteLocalizedStrings> names;
     hr = aFont->GetFaceNames(getter_AddRefs(names));
     if (FAILED(hr)) {
         return hr;
     }
@@ -113,17 +112,17 @@ GetDirectWriteFontName(IDWriteFont *aFon
 
 #define FULLNAME_ID   DWRITE_INFORMATIONAL_STRING_FULL_NAME
 #define PSNAME_ID     DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME
 
 // for use in reading postscript or fullname
 static HRESULT
 GetDirectWriteFaceName(IDWriteFont *aFont,
                        DWRITE_INFORMATIONAL_STRING_ID aWhichName,
-                       nsAString& aFontName)
+                       nsACString& aFontName)
 {
     HRESULT hr;
 
     BOOL exists;
     RefPtr<IDWriteLocalizedStrings> infostrings;
     hr = aFont->GetInformationalStrings(aWhichName, getter_AddRefs(infostrings), &exists);
     if (FAILED(hr) || !exists) {
         return E_FAIL;
@@ -164,18 +163,18 @@ gfxDWriteFontFamily::FindStyleVariations
 
         if (font->GetSimulations() != DWRITE_FONT_SIMULATIONS_NONE) {
             // We don't want these in the font list; we'll apply simulations
             // on the fly when appropriate.
             continue;
         }
 
         // name
-        nsString fullID(mName);
-        nsAutoString faceName;
+        nsCString fullID(mName);
+        nsAutoCString faceName;
         hr = GetDirectWriteFontName(font, faceName);
         if (FAILED(hr)) {
             continue;
         }
         fullID.Append(' ');
         fullID.Append(faceName);
 
         // Ignore italic style's "Meiryo" because "Meiryo (Bold) Italic" has
@@ -191,17 +190,17 @@ gfxDWriteFontFamily::FindStyleVariations
         gfxDWriteFontEntry *fe = new gfxDWriteFontEntry(fullID, font, mIsSystemFontFamily);
         fe->SetForceGDIClassic(mForceGDIClassic);
 
         fe->SetupVariationRanges();
 
         AddFontEntry(fe);
 
         // postscript/fullname if needed
-        nsAutoString psname, fullname;
+        nsAutoCString psname, fullname;
         if (fontInfoShouldHaveFaceNames) {
             aFontInfoData->GetFaceNames(fe->Name(), fullname, psname);
             if (!fullname.IsEmpty()) {
                 fp->AddFullname(fe, fullname);
             }
             if (!psname.IsEmpty()) {
                 fp->AddPostscriptName(fe, psname);
             }
@@ -221,24 +220,24 @@ gfxDWriteFontFamily::FindStyleVariations
             }
         }
 
         if (LOG_FONTLIST_ENABLED()) {
             nsAutoCString weightString;
             fe->Weight().ToString(weightString);
             LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
                  " with style: %s weight: %s stretch: %d psname: %s fullname: %s",
-                 NS_ConvertUTF16toUTF8(fe->Name()).get(),
-                 NS_ConvertUTF16toUTF8(Name()).get(),
+                 fe->Name().get(),
+                 Name().get(),
                  (fe->IsItalic()) ?
                   "italic" : (fe->IsOblique() ? "oblique" : "normal"),
                  weightString.get(),
                  fe->Stretch(),
-                 NS_ConvertUTF16toUTF8(psname).get(),
-                 NS_ConvertUTF16toUTF8(fullname).get()));
+                 psname.get(),
+                 fullname.get()));
         }
     }
 
     // assume that if no error, all postscript/fullnames were initialized
     if (!skipFaceNames) {
         mFaceNamesInitialized = true;
     }
 
@@ -274,17 +273,17 @@ gfxDWriteFontFamily::ReadFaceNames(gfxPl
     if (!mOtherFamilyNamesInitialized || !mFaceNamesInitialized) {
         gfxFontFamily::ReadFaceNames(aPlatformFontList,
                                      aNeedFullnamePostscriptNames,
                                      aFontInfoData);
     }
 }
 
 void
-gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName)
+gfxDWriteFontFamily::LocalizedName(nsACString &aLocalizedName)
 {
     aLocalizedName = Name(); // just return canonical name in case of failure
 
     if (!mDWFamily) {
         return;
     }
 
     HRESULT hr;
@@ -331,17 +330,18 @@ gfxDWriteFontFamily::LocalizedName(nsASt
         return;
     }
 
     hr = names->GetString(idx, famName.Elements(), length + 1);
     if (FAILED(hr)) {
         return;
     }
 
-    aLocalizedName = nsDependentString(famName.Elements());
+    aLocalizedName = NS_ConvertUTF16toUTF8((const char16_t*)famName.Elements(),
+                                           famName.Length() - 1);
 }
 
 bool
 gfxDWriteFontFamily::IsSymbolFontFamily() const
 {
     // Just check the first font in the family
     if (mDWFamily->GetFontCount() > 0) {
         RefPtr<IDWriteFont> font;
@@ -572,23 +572,23 @@ gfxDWriteFontEntry::ReadCMAP(FontInfoDat
         gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
         mCharacterMap = pfl->FindCharMap(charmap);
     } else {
         // if error occurred, initialize to null cmap
         mCharacterMap = new gfxCharacterMap();
     }
 
     LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d hash: %8.8x%s\n",
-                  NS_ConvertUTF16toUTF8(mName).get(),
+                  mName.get(),
                   charmap->SizeOfIncludingThis(moz_malloc_size_of),
                   charmap->mHash, mCharacterMap == charmap ? " new" : ""));
     if (LOG_CMAPDATA_ENABLED()) {
         char prefix[256];
         SprintfLiteral(prefix, "(cmapdata) name: %.220s",
-                       NS_ConvertUTF16toUTF8(mName).get());
+                       mName.get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
     }
 
     return rv;
 }
 
 bool
 gfxDWriteFontEntry::HasVariations()
@@ -934,42 +934,40 @@ gfxDWriteFontList::gfxDWriteFontList()
 
 // bug 602792 - CJK systems default to large CJK fonts which cause excessive
 //   I/O strain during cold startup due to dwrite caching bugs.  Default to
 //   Arial to avoid this.
 
 gfxFontFamily *
 gfxDWriteFontList::GetDefaultFontForPlatform(const gfxFontStyle *aStyle)
 {
-    nsAutoString resolvedName;
-
     // try Arial first
     gfxFontFamily *ff;
-    if ((ff = FindFamily(NS_LITERAL_STRING("Arial")))) {
+    if ((ff = FindFamily(NS_LITERAL_CSTRING("Arial")))) {
         return ff;
     }
 
     // otherwise, use local default
     NONCLIENTMETRICSW ncm;
     ncm.cbSize = sizeof(ncm);
     BOOL status = ::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 
                                           sizeof(ncm), &ncm, 0);
 
     if (status) {
-        ff = FindFamily(nsDependentString(ncm.lfMessageFont.lfFaceName));
+        ff = FindFamily(NS_ConvertUTF16toUTF8(ncm.lfMessageFont.lfFaceName));
         if (ff) {
             return ff;
         }
     }
 
     return nullptr;
 }
 
 gfxFontEntry *
-gfxDWriteFontList::LookupLocalFont(const nsAString& aFontName,
+gfxDWriteFontList::LookupLocalFont(const nsACString& aFontName,
                                    WeightRange aWeightForEntry,
                                    StretchRange aStretchForEntry,
                                    SlantStyleRange aStyleForEntry)
 {
     gfxFontEntry *lookup;
 
     lookup = LookupInFaceNameLists(aFontName);
     if (!lookup) {
@@ -983,17 +981,17 @@ gfxDWriteFontList::LookupLocalFont(const
                                aWeightForEntry,
                                aStretchForEntry,
                                aStyleForEntry);
     fe->SetForceGDIClassic(dwriteLookup->GetForceGDIClassic());
     return fe;
 }
 
 gfxFontEntry *
-gfxDWriteFontList::MakePlatformFont(const nsAString& aFontName,
+gfxDWriteFontList::MakePlatformFont(const nsACString& aFontName,
                                     WeightRange aWeightForEntry,
                                     StretchRange aStretchForEntry,
                                     SlantStyleRange aStyleForEntry,
                                     const uint8_t* aFontData,
                                     uint32_t aLength)
 {
     RefPtr<IDWriteFontFileStream> fontFileStream;
     RefPtr<IDWriteFontFile> fontFile;
@@ -1013,17 +1011,17 @@ gfxDWriteFontList::MakePlatformFont(cons
         return nullptr;
     }
 
     BOOL isSupported;
     DWRITE_FONT_FILE_TYPE fileType;
     UINT32 numFaces;
 
     gfxDWriteFontEntry *entry = 
-        new gfxDWriteFontEntry(uniqueName,
+        new gfxDWriteFontEntry(NS_ConvertUTF16toUTF8(uniqueName),
                                fontFile,
                                fontFileStream,
                                aWeightForEntry,
                                aStretchForEntry,
                                aStyleForEntry);
 
     fontFile->Analyze(&isSupported, &fileType, &entry->mFaceType, &numFaces);
     if (!isSupported || numFaces > 1) {
@@ -1120,33 +1118,33 @@ gfxDWriteFontList::InitFontListForPlatfo
     // with both pre-DW systems and with IE9, which appears to do the same.
     GetDirectWriteSubstitutes();
 
     // bug 551313 - DirectWrite creates a Gill Sans family out of
     // poorly named members of the Gill Sans MT family containing
     // only Ultra Bold weights.  This causes big problems for pages
     // using Gill Sans which is usually only available on OSX
 
-    nsAutoString nameGillSans(L"Gill Sans");
-    nsAutoString nameGillSansMT(L"Gill Sans MT");
+    nsAutoCString nameGillSans("Gill Sans");
+    nsAutoCString nameGillSansMT("Gill Sans MT");
     BuildKeyNameFromFontName(nameGillSans);
     BuildKeyNameFromFontName(nameGillSansMT);
 
     gfxFontFamily *gillSansFamily = mFontFamilies.GetWeak(nameGillSans);
     gfxFontFamily *gillSansMTFamily = mFontFamilies.GetWeak(nameGillSansMT);
 
     if (gillSansFamily && gillSansMTFamily) {
         gillSansFamily->FindStyleVariations();
         nsTArray<RefPtr<gfxFontEntry> >& faces = gillSansFamily->GetFontList();
         uint32_t i;
 
         bool allUltraBold = true;
         for (i = 0; i < faces.Length(); i++) {
             // does the face have 'Ultra Bold' in the name?
-            if (faces[i]->Name().Find(NS_LITERAL_STRING("Ultra Bold")) == -1) {
+            if (faces[i]->Name().Find(NS_LITERAL_CSTRING("Ultra Bold")) == -1) {
                 allUltraBold = false;
                 break;
             }
         }
 
         // if all the Gill Sans faces are Ultra Bold ==> move faces
         // for Gill Sans into Gill Sans MT family
         if (allUltraBold) {
@@ -1158,18 +1156,18 @@ gfxDWriteFontList::InitFontListForPlatfo
                 gillSansMTFamily->AddFontEntry(faces[i]);
 
                 if (LOG_FONTLIST_ENABLED()) {
                     gfxFontEntry *fe = faces[i];
                     nsAutoCString weightString;
                     fe->Weight().ToString(weightString);
                     LOG_FONTLIST(("(fontlist) moved (%s) to family (%s)"
                          " with style: %s weight: %s stretch: %d",
-                         NS_ConvertUTF16toUTF8(fe->Name()).get(),
-                         NS_ConvertUTF16toUTF8(gillSansMTFamily->Name()).get(),
+                         fe->Name().get(),
+                         gillSansMTFamily->Name().get(),
                          (fe->IsItalic()) ?
                           "italic" : (fe->IsOblique() ? "oblique" : "normal"),
                          weightString.get(),
                          fe->Stretch()));
                 }
             }
 
             // remove Gills Sans
@@ -1179,17 +1177,17 @@ gfxDWriteFontList::InitFontListForPlatfo
 
     nsAutoCString classicFamilies;
     nsresult rv = Preferences::GetCString(
       "gfx.font_rendering.cleartype_params.force_gdi_classic_for_families",
       classicFamilies);
     if (NS_SUCCEEDED(rv)) {
         nsCCharSeparatedTokenizer tokenizer(classicFamilies, ',');
         while (tokenizer.hasMoreTokens()) {
-            NS_ConvertUTF8toUTF16 name(tokenizer.nextToken());
+            nsAutoCString name(tokenizer.nextToken());
             BuildKeyNameFromFontName(name);
             gfxFontFamily *family = mFontFamilies.GetWeak(name);
             if (family) {
                 static_cast<gfxDWriteFontFamily*>(family)->SetForceGDIClassic(true);
             }
         }
     }
     mForceGDIClassicMaxFontSize =
@@ -1243,21 +1241,21 @@ gfxDWriteFontList::GetFontsFromCollectio
         aCollection->GetFontFamily(i, getter_AddRefs(family));
 
         RefPtr<IDWriteLocalizedStrings> names;
         HRESULT hr = family->GetFamilyNames(getter_AddRefs(names));
         if (FAILED(hr)) {
             continue;
         }
 
-        nsAutoString name;
+        nsAutoCString name;
         if (!GetEnglishOrFirstName(name, names)) {
             continue;
         }
-        nsAutoString familyName(name); // keep a copy before we lowercase it as a key
+        nsAutoCString familyName(name); // keep a copy before we lowercase it as a key
 
         BuildKeyNameFromFontName(name);
 
         RefPtr<gfxFontFamily> fam;
 
         if (mFontFamilies.GetWeak(name)) {
             continue;
         }
@@ -1302,33 +1300,33 @@ gfxDWriteFontList::GetFontsFromCollectio
                 }
 
                 hr = names->GetString(nameIndex, localizedName.Elements(),
                                       nameLen + 1);
                 if (FAILED(hr)) {
                     continue;
                 }
 
-                nsDependentString locName(localizedName.Elements());
+                NS_ConvertUTF16toUTF8 locName(localizedName.Elements());
 
                 if (!familyName.Equals(locName)) {
                     AddOtherFamilyName(fam, locName);
                 }
             }
         }
 
         // at this point, all family names have been read in
         fam->SetOtherFamilyNamesInitialized();
     }
 }
 
 static void
-RemoveCharsetFromFontSubstitute(nsAString &aName)
+RemoveCharsetFromFontSubstitute(nsACString &aName)
 {
-    int32_t comma = aName.FindChar(char16_t(','));
+    int32_t comma = aName.FindChar(',');
     if (comma >= 0)
         aName.Truncate(comma);
 }
 
 #define MAX_VALUE_NAME 512
 #define MAX_VALUE_DATA 512
 
 nsresult
@@ -1357,91 +1355,91 @@ gfxDWriteFontList::GetFontSubstitutes()
         if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) {
             continue;
         }
 
         if (aliasName[0] == WCHAR('@')) {
             continue;
         }
 
-        nsAutoString substituteName((char16_t*) aliasName);
-        nsAutoString actualFontName((char16_t*) actualName);
+        NS_ConvertUTF16toUTF8 substituteName((char16_t*)aliasName);
+        NS_ConvertUTF16toUTF8 actualFontName((char16_t*)actualName);
         RemoveCharsetFromFontSubstitute(substituteName);
         BuildKeyNameFromFontName(substituteName);
         RemoveCharsetFromFontSubstitute(actualFontName);
         BuildKeyNameFromFontName(actualFontName);
         gfxFontFamily *ff;
         if (!actualFontName.IsEmpty() && 
             (ff = mFontFamilies.GetWeak(actualFontName))) {
             mFontSubstitutes.Put(substituteName, ff);
         } else {
             mNonExistingFonts.AppendElement(substituteName);
         }
     }
     return NS_OK;
 }
 
 struct FontSubstitution {
-    const WCHAR* aliasName;
-    const WCHAR* actualName;
+    const char* aliasName;
+    const char* actualName;
 };
 
 static const FontSubstitution sDirectWriteSubs[] = {
-    { L"MS Sans Serif", L"Microsoft Sans Serif" },
-    { L"MS Serif", L"Times New Roman" },
-    { L"Courier", L"Courier New" },
-    { L"Small Fonts", L"Arial" },
-    { L"Roman", L"Times New Roman" },
-    { L"Script", L"Mistral" }
+    { "MS Sans Serif", "Microsoft Sans Serif" },
+    { "MS Serif", "Times New Roman" },
+    { "Courier", "Courier New" },
+    { "Small Fonts", "Arial" },
+    { "Roman", "Times New Roman" },
+    { "Script", "Mistral" }
 };
 
 void
 gfxDWriteFontList::GetDirectWriteSubstitutes()
 {
     for (uint32_t i = 0; i < ArrayLength(sDirectWriteSubs); ++i) {
         const FontSubstitution& sub(sDirectWriteSubs[i]);
-        nsAutoString substituteName((char16_t*)sub.aliasName);
+        nsAutoCString substituteName(sub.aliasName);
         BuildKeyNameFromFontName(substituteName);
         if (nullptr != mFontFamilies.GetWeak(substituteName)) {
             // don't do the substitution if user actually has a usable font
             // with this name installed
             continue;
         }
-        nsAutoString actualFontName((char16_t*)sub.actualName);
+        nsAutoCString actualFontName(sub.actualName);
         BuildKeyNameFromFontName(actualFontName);
         gfxFontFamily *ff;
         if (nullptr != (ff = mFontFamilies.GetWeak(actualFontName))) {
             mFontSubstitutes.Put(substituteName, ff);
         } else {
             mNonExistingFonts.AppendElement(substituteName);
         }
     }
 }
 
 bool
-gfxDWriteFontList::GetStandardFamilyName(const nsAString& aFontName,
-                                         nsAString& aFamilyName)
+gfxDWriteFontList::GetStandardFamilyName(const nsCString& aFontName,
+                                         nsACString& aFamilyName)
 {
     gfxFontFamily *family = FindFamily(aFontName);
     if (family) {
         family->LocalizedName(aFamilyName);
         return true;
     }
 
     return false;
 }
 
 bool
-gfxDWriteFontList::FindAndAddFamilies(const nsAString& aFamily,
+gfxDWriteFontList::FindAndAddFamilies(const nsACString& aFamily,
                                       nsTArray<FamilyAndGeneric>* aOutput,
                                       FindFamiliesFlags aFlags,
                                       gfxFontStyle* aStyle,
                                       gfxFloat aDevToCssSize)
 {
-    nsAutoString keyName(aFamily);
+    nsAutoCString keyName(aFamily);
     BuildKeyNameFromFontName(keyName);
 
     gfxFontFamily *ff = mFontSubstitutes.GetWeak(keyName);
     if (ff) {
         aOutput->AppendElement(FamilyAndGeneric(ff));
         return true;
     }
 
@@ -1482,17 +1480,17 @@ gfxDWriteFontList::AddSizeOfExcludingThi
 void
 gfxDWriteFontList::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
                                           FontListSizes* aSizes) const
 {
     aSizes->mFontListSize += aMallocSizeOf(this);
     AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
 }
 
-static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
+static HRESULT GetFamilyName(IDWriteFont *aFont, nsCString& aFamilyName)
 {
     HRESULT hr;
     RefPtr<IDWriteFontFamily> family;
 
     // clean out previous value
     aFamilyName.Truncate();
 
     hr = aFont->GetFontFamily(getter_AddRefs(family));
@@ -1650,54 +1648,47 @@ public:
 #ifdef MOZ_BUNDLED_FONTS
         , mBundledFonts(aBundledFonts)
 #endif
     {}
 
     virtual ~DirectWriteFontInfo() {}
 
     // loads font data for all members of a given family
-    virtual void LoadFontFamilyData(const nsAString& aFamilyName);
+    virtual void LoadFontFamilyData(const nsACString& aFamilyName);
 
 private:
     RefPtr<IDWriteFontCollection> mSystemFonts;
 #ifdef MOZ_BUNDLED_FONTS
     RefPtr<IDWriteFontCollection> mBundledFonts;
 #endif
 };
 
 void
-DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
+DirectWriteFontInfo::LoadFontFamilyData(const nsACString& aFamilyName)
 {
     // lookup the family
-    AutoTArray<wchar_t, 32> famName;
-
-    uint32_t len = aFamilyName.Length();
-    if(!famName.SetLength(len + 1, fallible)) {
-        return;
-    }
-    memcpy(famName.Elements(), aFamilyName.BeginReading(), len * sizeof(char16_t));
-    famName[len] = 0;
+    NS_ConvertUTF8toUTF16 famName(aFamilyName);
 
     HRESULT hr;
     BOOL exists = false;
 
     uint32_t index;
     RefPtr<IDWriteFontFamily> family;
-    hr = mSystemFonts->FindFamilyName(famName.Elements(), &index, &exists);
+    hr = mSystemFonts->FindFamilyName((const wchar_t*)famName.get(), &index, &exists);
     if (SUCCEEDED(hr) && exists) {
         mSystemFonts->GetFontFamily(index, getter_AddRefs(family));
         if (!family) {
             return;
         }
     }
 
 #ifdef MOZ_BUNDLED_FONTS
     if (!family && mBundledFonts) {
-        hr = mBundledFonts->FindFamilyName(famName.Elements(), &index, &exists);
+        hr = mBundledFonts->FindFamilyName((const wchar_t*)famName.get(), &index, &exists);
         if (SUCCEEDED(hr) && exists) {
             mBundledFonts->GetFontFamily(index, getter_AddRefs(family));
         }
     }
 #endif
 
     if (!family) {
         return;
@@ -1720,18 +1711,18 @@ DirectWriteFontInfo::LoadFontFamilyData(
             // We don't want these in the font list; we'll apply simulations
             // on the fly when appropriate.
             continue;
         }
 
         mLoadStats.fonts++;
 
         // get the name of the face
-        nsString fullID(aFamilyName);
-        nsAutoString fontName;
+        nsCString fullID(aFamilyName);
+        nsAutoCString fontName;
         hr = GetDirectWriteFontName(dwFont, fontName);
         if (FAILED(hr)) {
             continue;
         }
         fullID.Append(' ');
         fullID.Append(fontName);
 
         FontFaceData fontData;
@@ -1844,17 +1835,17 @@ gfxDWriteFontList::CreateFontInfoData()
                                 , mBundledFonts
 #endif
                                );
 
     return fi.forget();
 }
 
 gfxFontFamily*
-gfxDWriteFontList::CreateFontFamily(const nsAString& aName) const
+gfxDWriteFontList::CreateFontFamily(const nsACString& aName) const
 {
     return new gfxDWriteFontFamily(aName, nullptr);
 }
 
 
 #ifdef MOZ_BUNDLED_FONTS
 
 #define IMPL_QI_FOR_DWRITE(_interface)                                        \
--- a/gfx/thebes/gfxDWriteFontList.h
+++ b/gfx/thebes/gfxDWriteFontList.h
@@ -53,26 +53,26 @@ public:
 
     /**
      * Constructs a new DWriteFont Family.
      *
      * \param aName Name identifying the family
      * \param aFamily IDWriteFontFamily object representing the directwrite
      * family object.
      */
-    gfxDWriteFontFamily(const nsAString& aName,
+    gfxDWriteFontFamily(const nsACString& aName,
                         IDWriteFontFamily *aFamily,
                         bool aIsSystemFontFamily = false)
       : gfxFontFamily(aName), mDWFamily(aFamily),
         mIsSystemFontFamily(aIsSystemFontFamily), mForceGDIClassic(false) {}
     virtual ~gfxDWriteFontFamily();
     
     void FindStyleVariations(FontInfoData *aFontInfoData = nullptr) final;
 
-    void LocalizedName(nsAString& aLocalizedName) final;
+    void LocalizedName(nsACString& aLocalizedName) final;
 
     void ReadFaceNames(gfxPlatformFontList *aPlatformFontList,
                        bool aNeedFullnamePostscriptNames,
                        FontInfoData *aFontInfoData = nullptr) final;
 
     void SetForceGDIClassic(bool aForce) { mForceGDIClassic = aForce; }
 
     void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
@@ -102,17 +102,17 @@ class gfxDWriteFontEntry : public gfxFon
 {
 public:
     /**
      * Constructs a font entry.
      *
      * \param aFaceName The name of the corresponding font face.
      * \param aFont DirectWrite font object
      */
-    gfxDWriteFontEntry(const nsAString& aFaceName,
+    gfxDWriteFontEntry(const nsACString& aFaceName,
                        IDWriteFont *aFont,
                        bool aIsSystemFont = false)
       : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr),
         mIsSystemFont(aIsSystemFont), mForceGDIClassic(false),
         mHasVariations(false), mHasVariationsInitialized(false)
     {
         DWRITE_FONT_STYLE dwriteStyle = aFont->GetStyle();
         FontSlantStyle style =
@@ -139,17 +139,17 @@ public:
      * font source.
      *
      * \param aFaceName The name of the corresponding font face.
      * \param aFont DirectWrite font object
      * \param aWeight Weight of the font
      * \param aStretch Stretch of the font
      * \param aStyle italic or oblique of font
      */
-    gfxDWriteFontEntry(const nsAString& aFaceName,
+    gfxDWriteFontEntry(const nsACString& aFaceName,
                        IDWriteFont *aFont,
                        WeightRange aWeight,
                        StretchRange aStretch,
                        SlantStyleRange aStyle)
       : gfxFontEntry(aFaceName), mFont(aFont), mFontFile(nullptr),
         mIsSystemFont(false), mForceGDIClassic(false),
         mHasVariations(false), mHasVariationsInitialized(false)
     {
@@ -165,17 +165,17 @@ public:
      *
      * \param aFaceName The name of the corresponding font face.
      * \param aFontFile DirectWrite fontfile object
      * \param aFontFileStream DirectWrite fontfile stream object
      * \param aWeight Weight of the font
      * \param aStretch Stretch of the font
      * \param aStyle italic or oblique of font
      */
-    gfxDWriteFontEntry(const nsAString& aFaceName,
+    gfxDWriteFontEntry(const nsACString& aFaceName,
                               IDWriteFontFile *aFontFile,
                               IDWriteFontFileStream *aFontFileStream,
                               WeightRange aWeight,
                               StretchRange aStretch,
                               SlantStyleRange aStyle)
       : gfxFontEntry(aFaceName), mFont(nullptr),
         mFontFile(aFontFile), mFontFileStream(aFontFileStream),
         mIsSystemFont(false), mForceGDIClassic(false),
@@ -380,58 +380,58 @@ public:
             *ppvObject = nullptr;
             return E_FAIL;
         }
 
         this->AddRef();
         return S_OK;
     }
 
-    const nsString& FallbackFamilyName() { return mFamilyName; }
+    const nsCString& FallbackFamilyName() { return mFamilyName; }
 
 protected:
     long mRefCount;
     RefPtr<IDWriteFontCollection> mSystemFonts;
-    nsString mFamilyName;
+    nsCString mFamilyName;
 };
 
 
 
 class gfxDWriteFontList : public gfxPlatformFontList {
 public:
     gfxDWriteFontList();
 
     static gfxDWriteFontList* PlatformFontList() {
         return static_cast<gfxDWriteFontList*>(sPlatformFontList);
     }
 
     // initialize font lists
     virtual nsresult InitFontListForPlatform() override;
 
-    gfxFontFamily* CreateFontFamily(const nsAString& aName) const override;
+    gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
 
-    virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
+    virtual gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
                                           WeightRange aWeightForEntry,
                                           StretchRange aStretchForEntry,
                                           SlantStyleRange aStyleForEntry);
 
-    virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
+    virtual gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
                                            WeightRange aWeightForEntry,
                                            StretchRange aStretchForEntry,
                                            SlantStyleRange aStyleForEntry,
                                            const uint8_t* aFontData,
                                            uint32_t aLength);
     
-    bool GetStandardFamilyName(const nsAString& aFontName,
-                                 nsAString& aFamilyName);
+    bool GetStandardFamilyName(const nsCString& aFontName,
+                                 nsACString& aFamilyName);
 
     IDWriteGdiInterop *GetGDIInterop() { return mGDIInterop; }
     bool UseGDIFontTableAccess() { return mGDIFontTableAccess; }
 
-    bool FindAndAddFamilies(const nsAString& aFamily,
+    bool FindAndAddFamilies(const nsACString& aFamily,
                             nsTArray<FamilyAndGeneric>* aOutput,
                             FindFamiliesFlags aFlags,
                             gfxFontStyle* aStyle = nullptr,
                             gfxFloat aDevToCssSize = 1.0) override;
 
     gfxFloat GetForceGDIClassicMaxFontSize() { return mForceGDIClassicMaxFontSize; }
 
     virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
@@ -466,17 +466,17 @@ private:
     already_AddRefed<IDWriteFontCollection>
     CreateBundledFontsCollection(IDWriteFactory* aFactory);
 #endif
 
     /**
      * Fonts listed in the registry as substitutes but for which no actual
      * font family is found.
      */
-    nsTArray<nsString> mNonExistingFonts;
+    nsTArray<nsCString> mNonExistingFonts;
 
     /**
      * Table of font substitutes, we grab this from the registry to get
      * alternative font names.
      */
     FontFamilyTable mFontSubstitutes;
 
     virtual already_AddRefed<FontInfoData> CreateFontInfoData();
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -133,17 +133,17 @@ gfxDWriteFont::GetHorizontalMetrics()
 bool
 gfxDWriteFont::GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics)
 {
     gfxFontStyle style(mStyle);
     style.weight = FontWeight(700);
 
     gfxFontEntry* fe =
         gfxPlatformFontList::PlatformFontList()->
-            FindFontForFamily(NS_LITERAL_STRING("Arial"), &style);
+            FindFontForFamily(NS_LITERAL_CSTRING("Arial"), &style);
     if (!fe || fe == mFontEntry) {
         return false;
     }
 
     RefPtr<gfxFont> font = fe->FindOrMakeFont(&style);
     gfxDWriteFont *dwFont = static_cast<gfxDWriteFont*>(font.get());
     dwFont->mFontFace->GetMetrics(aFontMetrics);
 
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -60,17 +60,17 @@ static LazyLogModule sFontInfoLog("fontI
 
 #undef LOG
 #define LOG(args) MOZ_LOG(sFontInfoLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() MOZ_LOG_TEST(sFontInfoLog, mozilla::LogLevel::Debug)
 
 static cairo_user_data_key_t sFTUserFontDataKey;
 
 static __inline void
-BuildKeyNameFromFontName(nsAString &aName)
+BuildKeyNameFromFontName(nsACString &aName)
 {
     ToLowerCase(aName);
 }
 
 // Helper to access the FT_Face for a given FT2FontEntry,
 // creating a temporary face if the entry does not have one yet.
 // This allows us to read font names, tables, etc if necessary
 // without permanently instantiating a freetype face and consuming
@@ -261,17 +261,17 @@ FT2FontEntry::CreateFontInstance(const g
                                    ftFace ? ftFace : mFTFace,
                                    this, aFontStyle);
     cairo_scaled_font_destroy(scaledFont);
     return font;
 }
 
 /* static */
 FT2FontEntry*
-FT2FontEntry::CreateFontEntry(const nsAString& aFontName,
+FT2FontEntry::CreateFontEntry(const nsACString& aFontName,
                               WeightRange aWeight,
                               StretchRange aStretch,
                               SlantStyleRange aStyle,
                               const uint8_t* aFontData,
                               uint32_t aLength)
 {
     // Ownership of aFontData is passed in here; the fontEntry must
     // retain it as long as the FT_Face needs it, and ensure it is
@@ -388,17 +388,17 @@ FTFaceGetWeight(FT_Face aFace)
 // but unless we have been passed font data (i.e. for a user font),
 // we do *not* save a reference to it, nor create a cairo face,
 // as we don't want to keep a freetype face for every installed font
 // permanently in memory.
 /* static */
 FT2FontEntry*
 FT2FontEntry::CreateFontEntry(FT_Face aFace,
                               const char* aFilename, uint8_t aIndex,
-                              const nsAString& aName,
+                              const nsACString& aName,
                               const uint8_t* aFontData,
                               uint32_t aLength)
 {
     FT2FontEntry *fe = new FT2FontEntry(aName);
     fe->mStyleRange = SlantStyleRange(FTFaceIsItalic(aFace)
                                       ? FontSlantStyle::Italic()
                                       : FontSlantStyle::Normal());
     fe->mWeightRange = WeightRange(FTFaceGetWeight(aFace));
@@ -422,21 +422,20 @@ FT2FontEntry::CreateFontEntry(FT_Face aF
 // construct font entry name for an installed font from names in the FT_Face,
 // and then create our FT2FontEntry
 static FT2FontEntry*
 CreateNamedFontEntry(FT_Face aFace, const char* aFilename, uint8_t aIndex)
 {
     if (!aFace->family_name) {
         return nullptr;
     }
-    nsAutoString fontName;
-    AppendUTF8toUTF16(mozilla::MakeStringSpan(aFace->family_name), fontName);
+    nsAutoCString fontName(aFace->family_name);
     if (aFace->style_name && strcmp("Regular", aFace->style_name)) {
         fontName.Append(' ');
-        AppendUTF8toUTF16(mozilla::MakeStringSpan(aFace->style_name), fontName);
+        fontName.Append(aFace->style_name);
     }
     return FT2FontEntry::CreateFontEntry(aFace, aFilename, aIndex, fontName);
 }
 
 FT2FontEntry*
 gfxFT2Font::GetFontEntry()
 {
     return static_cast<FT2FontEntry*> (mFontEntry.get());
@@ -993,24 +992,24 @@ void
 gfxFT2FontList::AppendFacesFromCachedFaceList(
     const nsCString& aFileName,
     const nsCString& aFaceList,
     StandardFile aStdFile)
 {
     const char *beginning = aFaceList.get();
     const char *end = strchr(beginning, ',');
     while (end) {
-        NS_ConvertUTF8toUTF16 familyName(beginning, end - beginning);
+        nsAutoCString familyName(beginning, end - beginning);
         ToLowerCase(familyName);
 
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
-        NS_ConvertUTF8toUTF16 faceName(beginning, end - beginning);
+        nsAutoCString faceName(beginning, end - beginning);
 
         beginning = end + 1;
         if (!(end = strchr(beginning, ','))) {
             break;
         }
         uint32_t index = strtoul(beginning, nullptr, 10);
 
         beginning = end + 1;
@@ -1063,21 +1062,21 @@ gfxFT2FontList::AppendFacesFromCachedFac
 
         beginning = end + 1;
         end = strchr(beginning, ',');
     }
 }
 
 static void
 AppendToFaceList(nsCString& aFaceList,
-                 nsAString& aFamilyName, FT2FontEntry* aFontEntry)
+                 nsACString& aFamilyName, FT2FontEntry* aFontEntry)
 {
-    aFaceList.Append(NS_ConvertUTF16toUTF8(aFamilyName));
+    aFaceList.Append(aFamilyName);
     aFaceList.Append(',');
-    aFaceList.Append(NS_ConvertUTF16toUTF8(aFontEntry->Name()));
+    aFaceList.Append(aFontEntry->Name());
     aFaceList.Append(',');
     aFaceList.AppendInt(aFontEntry->mFTFontIndex);
     aFaceList.Append(',');
     // Note that ToString() appends to the destination string without
     // replacing existing contents (see FontPropertyTypes.h)
     aFontEntry->SlantStyle().Min().ToString(aFaceList);
     aFaceList.Append(':');
     aFontEntry->SlantStyle().Max().ToString(aFaceList);
@@ -1219,17 +1218,17 @@ gfxFT2FontList::AddFaceToList(const nsCS
     }
 
     // build the font entry name and create an FT2FontEntry,
     // but do -not- keep a reference to the FT_Face
     RefPtr<FT2FontEntry> fe =
         CreateNamedFontEntry(aFace, aEntryName.get(), aIndex);
 
     if (fe) {
-        NS_ConvertUTF8toUTF16 name(aFace->family_name);
+        nsAutoCString name(aFace->family_name);
         BuildKeyNameFromFontName(name);
         RefPtr<gfxFontFamily> family = mFontFamilies.GetWeak(name);
         if (!family) {
             family = new FT2FontFamily(name);
             mFontFamilies.Put(name, family);
             if (mSkipSpaceLookupCheckFamilies.Contains(name)) {
                 family->SetSkipSpaceFeatureCheck(true);
             }
@@ -1245,18 +1244,18 @@ gfxFT2FontList::AddFaceToList(const nsCS
         AppendToFaceList(aFaceList, name, fe);
         if (LOG_ENABLED()) {
             nsAutoCString weightString;
             fe->Weight().ToString(weightString);
             nsAutoCString stretchString;
             fe->Stretch().ToString(stretchString);
             LOG(("(fontinit) added (%s) to family (%s)"
                  " with style: %s weight: %s stretch: %s",
-                 NS_ConvertUTF16toUTF8(fe->Name()).get(),
-                 NS_ConvertUTF16toUTF8(family->Name()).get(),
+                 fe->Name().get(),
+                 family->Name().get(),
                  fe->IsItalic() ? "italic" : "normal",
                  weightString.get(),
                  stretchString.get()));
         }
     }
 }
 
 void
@@ -1314,17 +1313,17 @@ gfxFT2FontList::AppendFacesFromOmnijarEn
         aCache->CacheFileInfo(aEntryName, faceList, 0, bufSize);
     }
 }
 
 // Called on each family after all fonts are added to the list;
 // this will sort faces to give priority to "standard" font files
 // if aUserArg is non-null (i.e. we're using it as a boolean flag)
 static void
-FinalizeFamilyMemberList(nsStringHashKey::KeyType aKey,
+FinalizeFamilyMemberList(nsCStringHashKey::KeyType aKey,
                          RefPtr<gfxFontFamily>& aFamily,
                          bool aSortFaces)
 {
     gfxFontFamily *family = aFamily.get();
 
     family->SetHasStyles(true);
 
     if (aSortFaces) {
@@ -1353,17 +1352,17 @@ gfxFT2FontList::FindFonts()
             // We don't need to identify "standard" font files here,
             // as the faces are already sorted.
             AppendFaceFromFontListEntry(fonts[i], kUnknown);
         }
         // Passing null for userdata tells Finalize that it does not need
         // to sort faces (because they were already sorted by chrome,
         // so we just maintain the existing order)
         for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
-            nsStringHashKey::KeyType key = iter.Key();
+            nsCStringHashKey::KeyType key = iter.Key();
             RefPtr<gfxFontFamily>& family = iter.Data();
             FinalizeFamilyMemberList(key, family, /* aSortFaces */ false);
         }
 
         LOG(("got font list from chrome process: %" PRIdPTR " faces in %"
              PRIu32 " families",
             fonts.Length(), mFontFamilies.Count()));
         return;
@@ -1432,17 +1431,17 @@ gfxFT2FontList::FindFonts()
             FindFontsInDir(localPath, mFontNameCache.get());
         }
     }
 
     // Finalize the families by sorting faces into standard order
     // and marking "simple" families.
     // Passing non-null userData here says that we want faces to be sorted.
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
-        nsStringHashKey::KeyType key = iter.Key();
+        nsCStringHashKey::KeyType key = iter.Key();
         RefPtr<gfxFontFamily>& family = iter.Data();
         FinalizeFamilyMemberList(key, family, /* aSortFaces */ true);
     }
 }
 
 void
 gfxFT2FontList::FindFontsInDir(const nsCString& aDir,
                                FontNameCache *aFNC)
@@ -1503,25 +1502,24 @@ gfxFT2FontList::FindFontsInDir(const nsC
 
 void
 gfxFT2FontList::AppendFaceFromFontListEntry(const FontListEntry& aFLE,
                                             StandardFile aStdFile)
 {
     FT2FontEntry* fe = FT2FontEntry::CreateFontEntry(aFLE);
     if (fe) {
         fe->mStandardFace = (aStdFile == kStandard);
-        nsAutoString name(aFLE.familyName());
-        RefPtr<gfxFontFamily> family = mFontFamilies.GetWeak(name);
+        RefPtr<gfxFontFamily> family = mFontFamilies.GetWeak(aFLE.familyName());
         if (!family) {
-            family = new FT2FontFamily(name);
-            mFontFamilies.Put(name, family);
-            if (mSkipSpaceLookupCheckFamilies.Contains(name)) {
+            family = new FT2FontFamily(aFLE.familyName());
+            mFontFamilies.Put(aFLE.familyName(), family);
+            if (mSkipSpaceLookupCheckFamilies.Contains(aFLE.familyName())) {
                 family->SetSkipSpaceFeatureCheck(true);
             }
-            if (mBadUnderlineFamilyNames.Contains(name)) {
+            if (mBadUnderlineFamilyNames.Contains(aFLE.familyName())) {
                 family->SetBadUnderlineFamily();
             }
         }
         family->AddFontEntry(fe);
 
         fe->CheckForBrokenFont(family);
     }
 }
@@ -1531,26 +1529,26 @@ gfxFT2FontList::GetSystemFontList(Infall
 {
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
         auto family = static_cast<FT2FontFamily*>(iter.Data().get());
         family->AddFacesToFontList(retValue);
     }
 }
 
 static void
-LoadSkipSpaceLookupCheck(nsTHashtable<nsStringHashKey>& aSkipSpaceLookupCheck)
+LoadSkipSpaceLookupCheck(nsTHashtable<nsCStringHashKey>& aSkipSpaceLookupCheck)
 {
     AutoTArray<nsString, 5> skiplist;
     gfxFontUtils::GetPrefsFontList(
         "font.whitelist.skip_default_features_space_check",
         skiplist);
     uint32_t numFonts = skiplist.Length();
     for (uint32_t i = 0; i < numFonts; i++) {
         ToLowerCase(skiplist[i]);
-        aSkipSpaceLookupCheck.PutEntry(skiplist[i]);
+        aSkipSpaceLookupCheck.PutEntry(NS_ConvertUTF16toUTF8(skiplist[i]));
     }
 }
 
 nsresult
 gfxFT2FontList::InitFontListForPlatform()
 {
     LoadSkipSpaceLookupCheck(mSkipSpaceLookupCheckFamilies);
 
@@ -1558,47 +1556,46 @@ gfxFT2FontList::InitFontListForPlatform(
 
     return NS_OK;
 }
 
 // called for each family name, based on the assumption that the
 // first part of the full name is the family name
 
 gfxFontEntry*
-gfxFT2FontList::LookupLocalFont(const nsAString& aFontName,
+gfxFT2FontList::LookupLocalFont(const nsACString& aFontName,
                                 WeightRange aWeightForEntry,
                                 StretchRange aStretchForEntry,
                                 SlantStyleRange aStyleForEntry)
 {
     // walk over list of names
     FT2FontEntry* fontEntry = nullptr;
-    nsString fullName(aFontName);
 
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
         // Check family name, based on the assumption that the
         // first part of the full name is the family name
         RefPtr<gfxFontFamily>& fontFamily = iter.Data();
 
         // does the family name match up to the length of the family name?
-        const nsString& family = fontFamily->Name();
-        nsString fullNameFamily;
+        const nsCString& family = fontFamily->Name();
 
-        fullName.Left(fullNameFamily, family.Length());
+        const nsAutoCString fullNameFamily(
+            Substring(aFontName, 0, family.Length()));
 
         // if so, iterate over faces in this family to see if there is a match
-        if (family.Equals(fullNameFamily, nsCaseInsensitiveStringComparator())) {
+        if (family.Equals(fullNameFamily, nsCaseInsensitiveCStringComparator())) {
             nsTArray<RefPtr<gfxFontEntry> >& fontList = fontFamily->GetFontList();
             int index, len = fontList.Length();
             for (index = 0; index < len; index++) {
                 gfxFontEntry* fe = fontList[index];
                 if (!fe) {
                     continue;
                 }
-                if (fe->Name().Equals(fullName,
-                                      nsCaseInsensitiveStringComparator())) {
+                if (fe->Name().Equals(aFontName,
+                                      nsCaseInsensitiveCStringComparator())) {
                     fontEntry = static_cast<FT2FontEntry*>(fe);
                     goto searchDone;
                 }
             }
         }
     }
 
 searchDone:
@@ -1630,27 +1627,27 @@ searchDone:
     return fe;
 }
 
 gfxFontFamily*
 gfxFT2FontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle)
 {
     gfxFontFamily *ff = nullptr;
 #if defined(MOZ_WIDGET_ANDROID)
-    ff = FindFamily(NS_LITERAL_STRING("Roboto"));
+    ff = FindFamily(NS_LITERAL_CSTRING("Roboto"));
     if (!ff) {
-        ff = FindFamily(NS_LITERAL_STRING("Droid Sans"));
+        ff = FindFamily(NS_LITERAL_CSTRING("Droid Sans"));
     }
 #endif
     /* TODO: what about Qt or other platforms that may use this? */
     return ff;
 }
 
 gfxFontEntry*
-gfxFT2FontList::MakePlatformFont(const nsAString& aFontName,
+gfxFT2FontList::MakePlatformFont(const nsACString& aFontName,
                                  WeightRange aWeightForEntry,
                                  StretchRange aStretchForEntry,
                                  SlantStyleRange aStyleForEntry,
                                  const uint8_t* aFontData,
                                  uint32_t aLength)
 {
     // The FT2 font needs the font data to persist, so we do NOT free it here
     // but instead pass ownership to the font entry.
@@ -1667,17 +1664,17 @@ gfxFT2FontList::GetFontFamilyList(nsTArr
 {
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
         RefPtr<gfxFontFamily>& family = iter.Data();
         aFamilyArray.AppendElement(family);
     }
 }
 
 gfxFontFamily*
-gfxFT2FontList::CreateFontFamily(const nsAString& aName) const
+gfxFT2FontList::CreateFontFamily(const nsACString& aName) const
 {
     return new FT2FontFamily(aName);
 }
 
 void
 gfxFT2FontList::WillShutdown()
 {
     mozilla::scache::StartupCache* cache =
--- a/gfx/thebes/gfxFT2FontList.h
+++ b/gfx/thebes/gfxFT2FontList.h
@@ -19,35 +19,35 @@ using mozilla::dom::FontListEntry;
 
 class FontNameCache;
 typedef struct FT_FaceRec_* FT_Face;
 class nsZipArchive;
 
 class FT2FontEntry : public gfxFontEntry
 {
 public:
-    explicit FT2FontEntry(const nsAString& aFaceName) :
+    explicit FT2FontEntry(const nsACString& aFaceName) :
         gfxFontEntry(aFaceName),
         mFTFace(nullptr),
         mFontFace(nullptr),
         mFTFontIndex(0)
     {
     }
 
     ~FT2FontEntry();
 
     gfxFontEntry* Clone() const override;
 
-    const nsString& GetName() const {
+    const nsCString& GetName() const {
         return Name();
     }
 
     // create a font entry for a downloaded font
     static FT2FontEntry* 
-    CreateFontEntry(const nsAString& aFontName,
+    CreateFontEntry(const nsACString& aFontName,
                     WeightRange aWeight,
                     StretchRange aStretch,
                     SlantStyleRange aStyle,
                     const uint8_t* aFontData,
                     uint32_t aLength);
 
     // create a font entry representing an installed font, identified by
     // a FontListEntry; the freetype and cairo faces will not be instantiated
@@ -58,17 +58,17 @@ public:
     // Create a font entry for a given freetype face; if it is an installed font,
     // also record the filename and index.
     // aFontData (if non-nullptr) is NS_Malloc'ed data that aFace depends on,
     // to be freed after the face is destroyed.
     // aLength is the length of aFontData.
     static FT2FontEntry* 
     CreateFontEntry(FT_Face aFace,
                     const char *aFilename, uint8_t aIndex,
-                    const nsAString& aName,
+                    const nsACString& aName,
                     const uint8_t* aFontData = nullptr,
                     uint32_t aLength = 0);
 
     gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle) override;
 
     // Create (if necessary) and return the cairo_font_face for this font.
     // This may fail and return null, so caller must be prepared to handle this.
     // If a style is passed, any variationSettings in the style will be applied
@@ -114,50 +114,50 @@ public:
     bool mHasVariations = false;
     bool mHasVariationsInitialized = false;
     bool mMMVarInitialized = false;
 };
 
 class FT2FontFamily : public gfxFontFamily
 {
 public:
-    explicit FT2FontFamily(const nsAString& aName) :
+    explicit FT2FontFamily(const nsACString& aName) :
         gfxFontFamily(aName) { }
 
     // Append this family's faces to the IPC fontlist
     void AddFacesToFontList(InfallibleTArray<FontListEntry>* aFontList);
 };
 
 class gfxFT2FontList : public gfxPlatformFontList
 {
 public:
     gfxFT2FontList();
     virtual ~gfxFT2FontList();
 
-    virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
+    virtual gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
                                           WeightRange aWeightForEntry,
                                           StretchRange aStretchForEntry,
                                           SlantStyleRange aStyleForEntry) override;
 
-    virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
+    virtual gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
                                            WeightRange aWeightForEntry,
                                            StretchRange aStretchForEntry,
                                            SlantStyleRange aStyleForEntry,
                                            const uint8_t* aFontData,
                                            uint32_t aLength) override;
 
     void GetSystemFontList(InfallibleTArray<FontListEntry>* retValue);
 
     static gfxFT2FontList* PlatformFontList() {
         return static_cast<gfxFT2FontList*>(gfxPlatformFontList::PlatformFontList());
     }
 
     virtual void GetFontFamilyList(nsTArray<RefPtr<gfxFontFamily> >& aFamilyArray) override;
 
-    gfxFontFamily* CreateFontFamily(const nsAString& aName) const override;
+    gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
 
     void WillShutdown();
 
 protected:
     typedef enum {
         kUnknown,
         kStandard
     } StandardFile;
@@ -190,17 +190,17 @@ protected:
 
     void FindFontsInOmnijar(FontNameCache *aCache);
 
     void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC);
 
     virtual gfxFontFamily*
     GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
 
-    nsTHashtable<nsStringHashKey> mSkipSpaceLookupCheckFamilies;
+    nsTHashtable<nsCStringHashKey> mSkipSpaceLookupCheckFamilies;
 
 private:
     mozilla::UniquePtr<FontNameCache> mFontNameCache;
     int64_t mJarModifiedTime;
     nsCOMPtr<nsIObserver> mObserver;
 };
 
 #endif /* GFX_FT2FONTLIST_H */
--- a/gfx/thebes/gfxFT2Utils.cpp
+++ b/gfx/thebes/gfxFT2Utils.cpp
@@ -112,17 +112,17 @@ gfxFT2Utils::GetVariationAxes(const FT_M
     aAxes.SetCapacity(aMMVar->num_axis);
     for (unsigned i = 0; i < aMMVar->num_axis; i++) {
         const auto& a = aMMVar->axis[i];
         gfxFontVariationAxis axis;
         axis.mMinValue = a.minimum / 65536.0;
         axis.mMaxValue = a.maximum / 65536.0;
         axis.mDefaultValue = a.def / 65536.0;
         axis.mTag = a.tag;
-        axis.mName.Assign(NS_ConvertUTF8toUTF16(a.name));
+        axis.mName = a.name;
         aAxes.AppendElement(axis);
     }
 }
 
 /*static*/
 void
 gfxFT2Utils::GetVariationInstances(
     gfxFontEntry* aFontEntry,
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -119,47 +119,47 @@ FindCanonicalNameIndex(FcPattern* aFont,
             break;
         }
         n++;
     }
     return en;
 }
 
 static void
-GetFaceNames(FcPattern* aFont, const nsAString& aFamilyName,
-             nsAString& aPostscriptName, nsAString& aFullname)
+GetFaceNames(FcPattern* aFont, const nsACString& aFamilyName,
+             nsACString& aPostscriptName, nsACString& aFullname)
 {
     // get the Postscript name
     FcChar8* psname;
     if (FcPatternGetString(aFont, FC_POSTSCRIPT_NAME, 0, &psname) == FcResultMatch) {
-      AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(psname)), aPostscriptName);
+      aPostscriptName = ToCharPtr(psname);
     }
 
     // get the canonical fullname (i.e. en name or first name)
     uint32_t en = FindCanonicalNameIndex(aFont, FC_FULLNAMELANG);
     FcChar8* fullname;
     if (FcPatternGetString(aFont, FC_FULLNAME, en, &fullname) == FcResultMatch) {
-      AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(fullname)), aFullname);
+      aFullname = ToCharPtr(fullname);
     }
 
     // if have fullname, done
     if (!aFullname.IsEmpty()) {
         return;
     }
 
     // otherwise, set the fullname to family + style name [en] and use that
-    aFullname.Append(aFamilyName);
+    aFullname = aFamilyName;
 
     // figure out the en style name
     en = FindCanonicalNameIndex(aFont, FC_STYLELANG);
-    nsAutoString style;
+    nsAutoCString style;
     FcChar8* stylename = nullptr;
     FcPatternGetString(aFont, FC_STYLE, en, &stylename);
     if (stylename) {
-      AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(stylename)), style);
+      style = ToCharPtr(stylename);
     }
 
     if (!style.IsEmpty() && !style.EqualsLiteral("Regular")) {
         aFullname.Append(' ');
         aFullname.Append(style);
     }
 }
 
@@ -225,17 +225,17 @@ MapFcWidth(int aFcWidth)
         return FontStretch::Expanded();
     }
     if (aFcWidth <= (FC_WIDTH_EXTRAEXPANDED + FC_WIDTH_ULTRAEXPANDED) / 2) {
         return FontStretch::ExtraExpanded();
     }
     return FontStretch::UltraExpanded();
 }
 
-gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
+gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsACString& aFaceName,
                                                FcPattern* aFontPattern,
                                                bool aIgnoreFcCharmap)
         : gfxFontEntry(aFaceName), mFontPattern(aFontPattern),
           mFTFace(nullptr), mFTFaceInitialized(false),
           mIgnoreFcCharmap(aIgnoreFcCharmap),
           mHasVariationsInitialized(false),
           mAspect(0.0), mFontData(nullptr), mLength(0)
 {
@@ -310,17 +310,17 @@ CreateFaceForPattern(FcPattern* aPattern
     }
     int index;
     if (FcPatternGetInteger(aPattern, FC_INDEX, 0, &index) != FcResultMatch) {
         index = 0; // default to 0 if not found in pattern
     }
     return Factory::NewFTFace(nullptr, ToCharPtr(filename), index);
 }
 
-gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
+gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsACString& aFaceName,
                                                WeightRange aWeight,
                                                StretchRange aStretch,
                                                SlantStyleRange aStyle,
                                                const uint8_t *aData,
                                                uint32_t aLength,
                                                FT_Face aFace)
     : gfxFontEntry(aFaceName),
       mFTFace(aFace), mFTFaceInitialized(true),
@@ -333,17 +333,17 @@ gfxFontconfigFontEntry::gfxFontconfigFon
     mStretchRange = aStretch;
     mIsDataUserFont = true;
 
     mFontPattern = CreatePatternForFace(mFTFace);
 
     mUserFontData = new FTUserFontData(mFTFace, mFontData);
 }
 
-gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsAString& aFaceName,
+gfxFontconfigFontEntry::gfxFontconfigFontEntry(const nsACString& aFaceName,
                                                FcPattern* aFontPattern,
                                                WeightRange aWeight,
                                                StretchRange aStretch,
                                                SlantStyleRange aStyle)
         : gfxFontEntry(aFaceName), mFontPattern(aFontPattern),
           mFTFace(nullptr), mFTFaceInitialized(false),
           mHasVariationsInitialized(false),
           mAspect(0.0), mFontData(nullptr), mLength(0)
@@ -441,23 +441,23 @@ gfxFontconfigFontEntry::ReadCMAP(FontInf
         gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
         mCharacterMap = pfl->FindCharMap(charmap);
     } else {
         // if error occurred, initialize to null cmap
         mCharacterMap = new gfxCharacterMap();
     }
 
     LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %zu hash: %8.8x%s\n",
-                  NS_ConvertUTF16toUTF8(mName).get(),
+                  mName.get(),
                   charmap->SizeOfIncludingThis(moz_malloc_size_of),
                   charmap->mHash, mCharacterMap == charmap ? " new" : ""));
     if (LOG_CMAPDATA_ENABLED()) {
         char prefix[256];
         SprintfLiteral(prefix, "(cmapdata) name: %.220s",
-                       NS_ConvertUTF16toUTF8(mName).get());
+                       mName.get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
     }
 
     return rv;
 }
 
 static bool
 HasChar(FcPattern *aFont, FcChar32 aCh)
@@ -1187,19 +1187,19 @@ gfxFontconfigFontFamily::FindStyleVariat
     // add font entries for each of the faces
     uint32_t numFonts = mFontPatterns.Length();
     NS_ASSERTION(numFonts, "font family containing no faces!!");
     uint32_t numRegularFaces = 0;
     for (uint32_t i = 0; i < numFonts; i++) {
         FcPattern* face = mFontPatterns[i];
 
         // figure out the psname/fullname and choose which to use as the facename
-        nsAutoString psname, fullname;
+        nsAutoCString psname, fullname;
         GetFaceNames(face, mName, psname, fullname);
-        const nsAutoString& faceName = !psname.IsEmpty() ? psname : fullname;
+        const nsAutoCString& faceName = !psname.IsEmpty() ? psname : fullname;
 
         gfxFontconfigFontEntry *fontEntry =
             new gfxFontconfigFontEntry(faceName, face, mContainsAppFonts);
 
         if (gfxPlatform::GetPlatform()->HasVariationFontSupport()) {
             fontEntry->SetupVariationRanges();
         }
 
@@ -1214,23 +1214,23 @@ gfxFontconfigFontFamily::FindStyleVariat
             fontEntry->Weight().ToString(weightString);
             nsAutoCString stretchString;
             fontEntry->Stretch().ToString(stretchString);
             nsAutoCString styleString;
             fontEntry->SlantStyle().ToString(styleString);
             LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
                  " with style: %s weight: %s stretch: %s"
                  " psname: %s fullname: %s",
-                 NS_ConvertUTF16toUTF8(fontEntry->Name()).get(),
-                 NS_ConvertUTF16toUTF8(Name()).get(),
+                 fontEntry->Name().get(),
+                 Name().get(),
                  styleString.get(),
                  weightString.get(),
                  stretchString.get(),
-                 NS_ConvertUTF16toUTF8(psname).get(),
-                 NS_ConvertUTF16toUTF8(fullname).get()));
+                 psname.get(),
+                 fullname.get()));
         }
     }
 
     // somewhat arbitrary, but define a family with two or more regular
     // faces as a family for which intra-family fallback should be used
     if (numRegularFaces > 1) {
         mCheckForFallbackFaces = true;
     }
@@ -1524,17 +1524,17 @@ gfxFcPlatformFontList::AddFontSetFamilie
 
     if (!aFontSet) {
         NS_WARNING("AddFontSetFamilies called with a null font set.");
         return;
     }
 
     FcChar8* lastFamilyName = (FcChar8*)"";
     RefPtr<gfxFontconfigFontFamily> fontFamily;
-    nsAutoString familyName;
+    nsAutoCString familyName;
     for (int f = 0; f < aFontSet->nfont; f++) {
         FcPattern* pattern = aFontSet->fonts[f];
 
         // Skip any fonts that aren't readable for us (e.g. due to restrictive
         // file ownership/permissions).
         FcChar8* path;
         if (FcPatternGetString(pattern, FC_FILE, 0, &path) != FcResultMatch) {
             continue;
@@ -1555,17 +1555,17 @@ gfxFcPlatformFontList::AddFontSetFamilie
         AddPatternToFontList(pattern, lastFamilyName,
                              familyName, fontFamily, aAppFonts);
     }
 }
 
 void
 gfxFcPlatformFontList::AddPatternToFontList(FcPattern* aFont,
                                             FcChar8*& aLastFamilyName,
-                                            nsAString& aFamilyName,
+                                            nsACString& aFamilyName,
                                             RefPtr<gfxFontconfigFontFamily>& aFontFamily,
                                             bool aAppFonts)
 {
     // get canonical name
     uint32_t cIndex = FindCanonicalNameIndex(aFont, FC_FAMILYLANG);
     FcChar8* canonical = nullptr;
     FcPatternGetString(aFont, FC_FAMILY, cIndex, &canonical);
     if (!canonical) {
@@ -1573,18 +1573,18 @@ gfxFcPlatformFontList::AddPatternToFontL
     }
 
     // same as the last one? no need to add a new family, skip
     if (FcStrCmp(canonical, aLastFamilyName) != 0) {
         aLastFamilyName = canonical;
 
         // add new family if one doesn't already exist
         aFamilyName.Truncate();
-        AppendUTF8toUTF16(MakeStringSpan(ToCharPtr(canonical)), aFamilyName);
-        nsAutoString keyName(aFamilyName);
+        aFamilyName = ToCharPtr(canonical);
+        nsAutoCString keyName(aFamilyName);
         ToLowerCase(keyName);
 
         aFontFamily = static_cast<gfxFontconfigFontFamily*>
             (mFontFamilies.GetWeak(keyName));
         if (!aFontFamily) {
             aFontFamily = new gfxFontconfigFontFamily(aFamilyName);
             mFontFamilies.Put(keyName, aFontFamily);
         }
@@ -1597,30 +1597,30 @@ gfxFcPlatformFontList::AddPatternToFontL
 
         // Add pointers to other localized family names. Most fonts
         // only have a single name, so the first call to GetString
         // will usually not match
         FcChar8* otherName;
         int n = (cIndex == 0 ? 1 : 0);
         while (FcPatternGetString(aFont, FC_FAMILY, n, &otherName) ==
                FcResultMatch) {
-            NS_ConvertUTF8toUTF16 otherFamilyName(ToCharPtr(otherName));
+            nsAutoCString otherFamilyName(ToCharPtr(otherName));
             AddOtherFamilyName(aFontFamily, otherFamilyName);
             n++;
             if (n == int(cIndex)) {
                 n++; // skip over canonical name
             }
         }
     }
 
     MOZ_ASSERT(aFontFamily, "font must belong to a font family");
     aFontFamily->AddFontPattern(aFont);
 
     // map the psname, fullname ==> font family for local font lookups
-    nsAutoString psname, fullname;
+    nsAutoCString psname, fullname;
     GetFaceNames(aFont, aFamilyName, psname, fullname);
     if (!psname.IsEmpty()) {
         ToLowerCase(psname);
         mLocalNames.Put(psname, aFont);
     }
     if (!fullname.IsEmpty()) {
         ToLowerCase(fullname);
         mLocalNames.Put(fullname, aFont);
@@ -1642,17 +1642,17 @@ gfxFcPlatformFontList::InitFontListForPl
 
     if (XRE_IsContentProcess()) {
         // Content process: use the font list passed from the chrome process,
         // because we can't rely on fontconfig in the presence of sandboxing;
         // it may report fonts that we can't actually access.
 
         FcChar8* lastFamilyName = (FcChar8*)"";
         RefPtr<gfxFontconfigFontFamily> fontFamily;
-        nsAutoString familyName;
+        nsAutoCString familyName;
 
         // Get font list that was passed during XPCOM startup
         // or in an UpdateFontList message.
         auto& fontList = dom::ContentChild::GetSingleton()->SystemFontList();
 
         // For fontconfig versions between 2.10.94 and 2.11.1 inclusive,
         // we need to escape any leading space in the charset element,
         // otherwise FcNameParse will fail. :(
@@ -1869,38 +1869,39 @@ gfxFcPlatformFontList::GetDefaultFontFor
     NS_ASSERTION(prefFonts, "null list of generic fonts");
     if (prefFonts && !prefFonts->IsEmpty()) {
         return (*prefFonts)[0];
     }
     return nullptr;
 }
 
 gfxFontEntry*
-gfxFcPlatformFontList::LookupLocalFont(const nsAString& aFontName,
+gfxFcPlatformFontList::LookupLocalFont(const nsACString& aFontName,
                                        WeightRange aWeightForEntry,
                                        StretchRange aStretchForEntry,
                                        SlantStyleRange aStyleForEntry)
 {
-    nsAutoString keyName(aFontName);
+    nsAutoCString keyName(aFontName);
     ToLowerCase(keyName);
 
     // if name is not in the global list, done
     FcPattern* fontPattern = mLocalNames.Get(keyName);
     if (!fontPattern) {
         return nullptr;
     }
 
-    return new gfxFontconfigFontEntry(aFontName, fontPattern,
+    return new gfxFontconfigFontEntry(aFontName,
+                                      fontPattern,
                                       aWeightForEntry,
                                       aStretchForEntry,
                                       aStyleForEntry);
 }
 
 gfxFontEntry*
-gfxFcPlatformFontList::MakePlatformFont(const nsAString& aFontName,
+gfxFcPlatformFontList::MakePlatformFont(const nsACString& aFontName,
                                         WeightRange aWeightForEntry,
                                         StretchRange aStretchForEntry,
                                         SlantStyleRange aStyleForEntry,
                                         const uint8_t* aFontData,
                                         uint32_t aLength)
 {
     FT_Face face = Factory::NewFTFaceFromData(nullptr, aFontData, aLength, 0);
     if (!face) {
@@ -1916,41 +1917,42 @@ gfxFcPlatformFontList::MakePlatformFont(
     return new gfxFontconfigFontEntry(aFontName,
                                       aWeightForEntry,
                                       aStretchForEntry,
                                       aStyleForEntry,
                                       aFontData, aLength, face);
 }
 
 bool
-gfxFcPlatformFontList::FindAndAddFamilies(const nsAString& aFamily,
+gfxFcPlatformFontList::FindAndAddFamilies(const nsACString& aFamily,
                                           nsTArray<FamilyAndGeneric>* aOutput,
                                           FindFamiliesFlags aFlags,
                                           gfxFontStyle* aStyle,
                                           gfxFloat aDevToCssSize)
 {
-    nsAutoString familyName(aFamily);
+    nsAutoCString familyName(aFamily);
     ToLowerCase(familyName);
     nsAtom* language = (aStyle ? aStyle->language.get() : nullptr);
 
     // deprecated generic names are explicitly converted to standard generics
     bool isDeprecatedGeneric = false;
     if (familyName.EqualsLiteral("sans") ||
         familyName.EqualsLiteral("sans serif")) {
         familyName.AssignLiteral("sans-serif");
         isDeprecatedGeneric = true;
     } else if (familyName.EqualsLiteral("mono")) {
         familyName.AssignLiteral("monospace");
         isDeprecatedGeneric = true;
     }
 
     // fontconfig generics? use fontconfig to determine the family for lang
+    NS_ConvertUTF8toUTF16 family16(familyName);
     if (isDeprecatedGeneric ||
-        mozilla::FontFamilyName::Convert(familyName).IsGeneric()) {
-        PrefFontList* prefFonts = FindGenericFamilies(familyName, language);
+        mozilla::FontFamilyName::Convert(family16).IsGeneric()) {
+        PrefFontList* prefFonts = FindGenericFamilies(family16, language);
         if (prefFonts && !prefFonts->IsEmpty()) {
             aOutput->AppendElements(*prefFonts);
             return true;
         }
         return false;
     }
 
     // fontconfig allows conditional substitutions in such a way that it's
@@ -1964,19 +1966,18 @@ gfxFcPlatformFontList::FindAndAddFamilie
     //   serif ==> DejaVu Serif, ...
     //   Helvetica, serif ==> Helvetica, TeX Gyre Heros, Nimbus Sans L, DejaVu Serif
     //
     // In this case fontconfig is including Tex Gyre Heros and
     // Nimbus Sans L as alternatives for Helvetica.
 
     // Because the FcConfigSubstitute call is quite expensive, we cache the
     // actual font families found via this process. So check the cache first:
-    NS_ConvertUTF16toUTF8 familyToFind(familyName);
     AutoTArray<FamilyAndGeneric,10> cachedFamilies;
-    if (mFcSubstituteCache.Get(familyToFind, &cachedFamilies)) {
+    if (mFcSubstituteCache.Get(familyName, &cachedFamilies)) {
         if (cachedFamilies.IsEmpty()) {
             return false;
         }
         aOutput->AppendElements(cachedFamilies);
         return true;
     }
 
     // It wasn't in the cache, so we need to ask fontconfig...
@@ -1985,50 +1986,50 @@ gfxFcPlatformFontList::FindAndAddFamilie
     nsAutoRef<FcPattern> sentinelSubst(FcPatternCreate());
     FcPatternAddString(sentinelSubst, FC_FAMILY, kSentinelName);
     FcConfigSubstitute(nullptr, sentinelSubst, FcMatchPattern);
     FcPatternGetString(sentinelSubst, FC_FAMILY, 0, &sentinelFirstFamily);
 
     // substitutions for font, -moz-sentinel pattern
     nsAutoRef<FcPattern> fontWithSentinel(FcPatternCreate());
     FcPatternAddString(fontWithSentinel, FC_FAMILY,
-                       ToFcChar8Ptr(familyToFind.get()));
+                       ToFcChar8Ptr(familyName.get()));
     FcPatternAddString(fontWithSentinel, FC_FAMILY, kSentinelName);
     FcConfigSubstitute(nullptr, fontWithSentinel, FcMatchPattern);
 
     // Add all font family matches until reaching the sentinel.
     FcChar8* substName = nullptr;
     for (int i = 0;
          FcPatternGetString(fontWithSentinel, FC_FAMILY,
                             i, &substName) == FcResultMatch;
          i++)
     {
-        NS_ConvertUTF8toUTF16 subst(ToCharPtr(substName));
         if (sentinelFirstFamily &&
             FcStrCmp(substName, sentinelFirstFamily) == 0) {
             break;
         }
-        gfxPlatformFontList::FindAndAddFamilies(subst,
-                                                &cachedFamilies,
-                                                aFlags);
+        gfxPlatformFontList::FindAndAddFamilies(
+            nsDependentCString(ToCharPtr(substName)),
+            &cachedFamilies,
+            aFlags);
     }
 
     // Cache the resulting list, so we don't have to do this again.
-    mFcSubstituteCache.Put(familyToFind, cachedFamilies);
+    mFcSubstituteCache.Put(familyName, cachedFamilies);
 
     if (cachedFamilies.IsEmpty()) {
         return false;
     }
     aOutput->AppendElements(cachedFamilies);
     return true;
 }
 
 bool
-gfxFcPlatformFontList::GetStandardFamilyName(const nsAString& aFontName,
-                                             nsAString& aFamilyName)
+gfxFcPlatformFontList::GetStandardFamilyName(const nsCString& aFontName,
+                                             nsACString& aFamilyName)
 {
     aFamilyName.Truncate();
 
     // The fontconfig list of fonts includes generic family names in the
     // font list. For these, just use the generic name.
     if (aFontName.EqualsLiteral("serif") ||
         aFontName.EqualsLiteral("sans-serif") ||
         aFontName.EqualsLiteral("monospace")) {
@@ -2042,18 +2043,17 @@ gfxFcPlatformFontList::GetStandardFamily
     }
 
     nsAutoRef<FcObjectSet> os(FcObjectSetBuild(FC_FAMILY, nullptr));
     if (!os) {
         return true;
     }
 
     // add the family name to the pattern
-    NS_ConvertUTF16toUTF8 familyName(aFontName);
-    FcPatternAddString(pat, FC_FAMILY, ToFcChar8Ptr(familyName.get()));
+    FcPatternAddString(pat, FC_FAMILY, ToFcChar8Ptr(aFontName.get()));
 
     nsAutoRef<FcFontSet> givenFS(FcFontList(nullptr, pat, os));
     if (!givenFS) {
         return true;
     }
 
     // See if there is a font face with first family equal to the given family
     // (needs to be in sync with names coming from GetFontList())
@@ -2066,17 +2066,17 @@ gfxFcPlatformFontList::GetStandardFamily
         {
             continue;
         }
 
         nsDependentCString first(firstFamily);
         if (!candidates.Contains(first)) {
             candidates.AppendElement(first);
 
-            if (familyName.Equals(first)) {
+            if (aFontName.Equals(first)) {
                 aFamilyName.Assign(aFontName);
                 return true;
             }
         }
     }
 
     // Because fontconfig conflates different family name types, need to
     // double check that the candidate name is not simply a different
@@ -2102,17 +2102,17 @@ gfxFcPlatformFontList::GetStandardFamily
         bool equal = true;
         for (int i = 0; i < givenFS->nfont; ++i) {
             if (!FcPatternEqual(candidateFS->fonts[i], givenFS->fonts[i])) {
                 equal = false;
                 break;
             }
         }
         if (equal) {
-            AppendUTF8toUTF16(candidates[j], aFamilyName);
+            aFamilyName = candidates[j];
             return true;
         }
     }
 
     // didn't find localized name, leave family name blank
     return true;
 }
 
@@ -2284,17 +2284,17 @@ gfxFcPlatformFontList::FindGenericFamili
     uint32_t limit = gfxPlatformGtk::GetPlatform()->MaxGenericSubstitions();
     bool foundFontWithLang = false;
     for (int i = 0; i < faces->nfont; i++) {
         FcPattern* font = faces->fonts[i];
         FcChar8* mappedGeneric = nullptr;
 
         FcPatternGetString(font, FC_FAMILY, 0, &mappedGeneric);
         if (mappedGeneric) {
-            NS_ConvertUTF8toUTF16 mappedGenericName(ToCharPtr(mappedGeneric));
+            nsAutoCString mappedGenericName(ToCharPtr(mappedGeneric));
             AutoTArray<FamilyAndGeneric,1> genericFamilies;
             if (gfxPlatformFontList::FindAndAddFamilies(mappedGenericName,
                                                         &genericFamilies,
                                                         FindFamiliesFlags(0))) {
                 MOZ_ASSERT(genericFamilies.Length() == 1,
                            "expected a single family");
                 if (!prefFonts->Contains(genericFamilies[0].mFamily)) {
                     prefFonts->AppendElement(genericFamilies[0].mFamily);
@@ -2387,17 +2387,17 @@ gfxFcPlatformFontList::CheckFontUpdates(
         pfl->UpdateFontList();
         pfl->ForceGlobalReflow();
 
         mozilla::dom::ContentParent::NotifyUpdatedFonts();
     }
 }
 
 gfxFontFamily*
-gfxFcPlatformFontList::CreateFontFamily(const nsAString& aName) const
+gfxFcPlatformFontList::CreateFontFamily(const nsACString& aName) const
 {
     return new gfxFontconfigFontFamily(aName);
 }
 
 // mapping of moz lang groups ==> default lang
 struct MozLangGroupData {
     nsAtom* const& mozLangGroup;
     const char *defaultLang;
--- a/gfx/thebes/gfxFcPlatformFontList.h
+++ b/gfx/thebes/gfxFcPlatformFontList.h
@@ -82,32 +82,32 @@ private:
 
 // The names for the font entry and font classes should really
 // the common 'Fc' abbreviation but the gfxPangoFontGroup code already
 // defines versions of these, so use the verbose name for now.
 
 class gfxFontconfigFontEntry : public gfxFontEntry {
 public:
     // used for system fonts with explicit patterns
-    explicit gfxFontconfigFontEntry(const nsAString& aFaceName,
+    explicit gfxFontconfigFontEntry(const nsACString& aFaceName,
                                     FcPattern* aFontPattern,
                                     bool aIgnoreFcCharmap);
 
     // used for data fonts where the fontentry takes ownership
     // of the font data and the FT_Face
-    explicit gfxFontconfigFontEntry(const nsAString& aFaceName,
+    explicit gfxFontconfigFontEntry(const nsACString& aFaceName,
                                     WeightRange aWeight,
                                     StretchRange aStretch,
                                     SlantStyleRange aStyle,
                                     const uint8_t *aData,
                                     uint32_t aLength,
                                     FT_Face aFace);
 
     // used for @font-face local system fonts with explicit patterns
-    explicit gfxFontconfigFontEntry(const nsAString& aFaceName,
+    explicit gfxFontconfigFontEntry(const nsACString& aFaceName,
                                     FcPattern* aFontPattern,
                                     WeightRange aWeight,
                                     StretchRange aStretch,
                                     SlantStyleRange aStyle);
 
     gfxFontEntry* Clone() const override;
 
     FcPattern* GetPattern() { return mFontPattern; }
@@ -203,17 +203,17 @@ protected:
     // Because of FreeType bug 52955, we keep the FT_MM_Var struct when it is
     // first loaded, rather than releasing it and re-fetching it as needed.
     FT_MM_Var* mMMVar = nullptr;
     bool mMMVarInitialized = false;
 };
 
 class gfxFontconfigFontFamily : public gfxFontFamily {
 public:
-    explicit gfxFontconfigFontFamily(const nsAString& aName) :
+    explicit gfxFontconfigFontFamily(const nsACString& aName) :
         gfxFontFamily(aName),
         mContainsAppFonts(false),
         mHasNonScalableFaces(false),
         mForceScalable(false)
     { }
 
     template<typename Func>
     void AddFacesToFontList(Func aAddPatternFunc);
@@ -287,37 +287,37 @@ public:
     void GetFontList(nsAtom *aLangGroup,
                      const nsACString& aGenericFamily,
                      nsTArray<nsString>& aListOfFonts) override;
 
     void ReadSystemFontList(
         InfallibleTArray<mozilla::dom::SystemFontListEntry>* retValue);
 
     gfxFontEntry*
-    LookupLocalFont(const nsAString& aFontName,
+    LookupLocalFont(const nsACString& aFontName,
                     WeightRange aWeightForEntry,
                     StretchRange aStretchForEntry,
                     SlantStyleRange aStyleForEntry) override;
 
     gfxFontEntry*
-    MakePlatformFont(const nsAString& aFontName,
+    MakePlatformFont(const nsACString& aFontName,
                      WeightRange aWeightForEntry,
                      StretchRange aStretchForEntry,
                      SlantStyleRange aStyleForEntry,
                      const uint8_t* aFontData,
                      uint32_t aLength) override;
 
-    bool FindAndAddFamilies(const nsAString& aFamily,
+    bool FindAndAddFamilies(const nsACString& aFamily,
                             nsTArray<FamilyAndGeneric>* aOutput,
                             FindFamiliesFlags aFlags,
                             gfxFontStyle* aStyle = nullptr,
                             gfxFloat aDevToCssSize = 1.0) override;
 
-    bool GetStandardFamilyName(const nsAString& aFontName,
-                               nsAString& aFamilyName) override;
+    bool GetStandardFamilyName(const nsCString& aFontName,
+                               nsACString& aFamilyName) override;
 
     FcConfig* GetLastConfig() const { return mLastConfig; }
 
     // override to use fontconfig lookup for generics
     void AddGenericFonts(mozilla::FontFamilyType aGenericType,
                          nsAtom* aLanguage,
                          nsTArray<FamilyAndGeneric>& aFamilyList) override;
 
@@ -349,48 +349,48 @@ protected:
 
     // Add all the font families found in a font set.
     // aAppFonts indicates whether this is the system or application fontset.
     void AddFontSetFamilies(FcFontSet* aFontSet, const SandboxPolicy* aPolicy,
                             bool aAppFonts);
 
     // Helper for above, to add a single font pattern.
     void AddPatternToFontList(FcPattern* aFont, FcChar8*& aLastFamilyName,
-                              nsAString& aFamilyName,
+                              nsACString& aFamilyName,
                               RefPtr<gfxFontconfigFontFamily>& aFontFamily,
                               bool aAppFonts);
 
     // figure out which families fontconfig maps a generic to
     // (aGeneric assumed already lowercase)
     PrefFontList* FindGenericFamilies(const nsAString& aGeneric,
                                       nsAtom* aLanguage);
 
     // are all pref font settings set to use fontconfig generics?
     bool PrefFontListsUseOnlyGenerics();
 
     static void CheckFontUpdates(nsITimer *aTimer, void *aThis);
 
     virtual gfxFontFamily*
     GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
 
-    gfxFontFamily* CreateFontFamily(const nsAString& aName) const override;
+    gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
 
     // helper method for finding an appropriate lang string
     bool TryLangForGroup(const nsACString& aOSLang, nsAtom* aLangGroup,
                          nsACString& aLang, bool aForFontEnumerationThread);
 
 #ifdef MOZ_BUNDLED_FONTS
     void ActivateBundledFonts();
     nsCString mBundledFontsPath;
     bool mBundledFontsInitialized;
 #endif
 
     // to avoid enumerating all fonts, maintain a mapping of local font
     // names to family
-    nsBaseHashtable<nsStringHashKey,
+    nsBaseHashtable<nsCStringHashKey,
                     nsCountedRef<FcPattern>,
                     FcPattern*> mLocalNames;
 
     // caching generic/lang ==> font family list
     nsClassHashtable<nsCStringHashKey,
                      PrefFontList> mGenericMappings;
 
     // Caching family lookups as found by FindAndAddFamilies after resolving
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -357,17 +357,17 @@ gfxFontCache::AddSizeOfIncludingThis(Mal
     AddSizeOfExcludingThis(aMallocSizeOf, aSizes);
 }
 
 #define MAX_SSXX_VALUE 99
 #define MAX_CVXX_VALUE 99
 
 static void
 LookupAlternateValues(gfxFontFeatureValueSet *featureLookup,
-                      const nsAString& aFamily,
+                      const nsACString& aFamily,
                       const nsTArray<gfxAlternateValue>& altValue,
                       nsTArray<gfxFontFeature>& aFontFeatures)
 {
     uint32_t numAlternates = altValue.Length();
     for (uint32_t i = 0; i < numAlternates; i++) {
         const gfxAlternateValue& av = altValue.ElementAt(i);
         AutoTArray<uint32_t,4> values;
 
@@ -445,17 +445,17 @@ LookupAlternateValues(gfxFontFeatureValu
     }
 }
 
 /* static */ void
 gfxFontShaper::MergeFontFeatures(
     const gfxFontStyle *aStyle,
     const nsTArray<gfxFontFeature>& aFontFeatures,
     bool aDisableLigatures,
-    const nsAString& aFamilyName,
+    const nsACString& aFamilyName,
     bool aAddSmallCaps,
     void (*aHandleFeature)(const uint32_t&, uint32_t&, void*),
     void* aHandleFeatureData)
 {
     uint32_t numAlts = aStyle->alternateValues.Length();
     const nsTArray<gfxFontFeature>& styleRuleFeatures =
         aStyle->featureSettings;
 
@@ -1325,17 +1325,17 @@ gfxFont::CheckForFeaturesInvolvingSpace(
 
     if (MOZ_UNLIKELY(log)) {
         TimeDuration elapsed = TimeStamp::Now() - start;
         LOG_FONTINIT((
             "(fontinit-spacelookups) font: %s - "
             "subst default: %8.8x %8.8x %8.8x %8.8x "
             "subst non-default: %8.8x %8.8x %8.8x %8.8x "
             "kerning: %s non-kerning: %s time: %6.3f\n",
-            NS_ConvertUTF16toUTF8(mFontEntry->Name()).get(),
+            mFontEntry->Name().get(),
             mFontEntry->mDefaultSubSpaceFeatures[3],
             mFontEntry->mDefaultSubSpaceFeatures[2],
             mFontEntry->mDefaultSubSpaceFeatures[1],
             mFontEntry->mDefaultSubSpaceFeatures[0],
             mFontEntry->mNonDefaultSubSpaceFeatures[3],
             mFontEntry->mNonDefaultSubSpaceFeatures[2],
             mFontEntry->mNonDefaultSubSpaceFeatures[1],
             mFontEntry->mNonDefaultSubSpaceFeatures[0],
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -710,17 +710,17 @@ public:
                            gfxShapedText  *aShapedText) = 0;
 
     gfxFont *GetFont() const { return mFont; }
 
     static void
     MergeFontFeatures(const gfxFontStyle *aStyle,
                       const nsTArray<gfxFontFeature>& aFontFeatures,
                       bool aDisableLigatures,
-                      const nsAString& aFamilyName,
+                      const nsACString& aFamilyName,
                       bool aAddSmallCaps,
                       void (*aHandleFeature)(const uint32_t&,
                                              uint32_t&, void*),
                       void* aHandleFeatureData);
 
 protected:
     // the font this shaper is working with. The font owns a UniquePtr reference
     // to this object, and will destroy it before it dies. Thus, mFont will always
@@ -1553,17 +1553,17 @@ public:
             // antialiasing behavior of the platform; currently the
             // distinction is only implemented in the gfxWindowsFont
             // subclass, because of ClearType's tendency to paint
             // outside the hinted outline.
             // Also NOTE: it is relatively expensive to request this,
             // as it does not use cached glyph extents in the font.
     } BoundingBoxType;
 
-    const nsString& GetName() const { return mFontEntry->Name(); }
+    const nsCString& GetName() const { return mFontEntry->Name(); }
     const gfxFontStyle *GetStyle() const { return &mStyle; }
 
     cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; }
 
     virtual mozilla::UniquePtr<gfxFont>
     CopyWithAntialiasOption(AntialiasOption anAAOption) {
         // platforms where this actually matters should override
         return nullptr;
--- a/gfx/thebes/gfxFontEntry.cpp
+++ b/gfx/thebes/gfxFontEntry.cpp
@@ -83,17 +83,17 @@ gfxFontEntry::gfxFontEntry() :
     mGrFaceInitialized(false),
     mCheckedForColorGlyph(false),
     mCheckedForVariationAxes(false)
 {
     memset(&mDefaultSubSpaceFeatures, 0, sizeof(mDefaultSubSpaceFeatures));
     memset(&mNonDefaultSubSpaceFeatures, 0, sizeof(mNonDefaultSubSpaceFeatures));
 }
 
-gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) :
+gfxFontEntry::gfxFontEntry(const nsACString& aName, bool aIsStandardFace) :
     mName(aName),
     mFixedPitch(false),
     mIsBadUnderlineFont(false),
     mIsUserFontContainer(false),
     mIsDataUserFont(false),
     mIsLocalUserFont(false),
     mStandardFace(aIsStandardFace),
     mIgnoreGDEF(false),
@@ -229,22 +229,22 @@ bool gfxFontEntry::SupportsScriptInGSUB(
 
 nsresult gfxFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
 {
     NS_ASSERTION(false, "using default no-op implementation of ReadCMAP");
     mCharacterMap = new gfxCharacterMap();
     return NS_OK;
 }
 
-nsString
+nsCString
 gfxFontEntry::RealFaceName()
 {
     AutoTable nameTable(this, TRUETYPE_TAG('n','a','m','e'));
     if (nameTable) {
-        nsAutoString name;
+        nsAutoCString name;
         nsresult rv = gfxFontUtils::GetFullNameFromTable(nameTable, name);
         if (NS_SUCCEEDED(rv)) {
             return std::move(name);
         }
     }
     return Name();
 }
 
@@ -1824,17 +1824,17 @@ gfxFontFamily::ContainsFace(gfxFontEntry
                 return true;
             }
         }
     }
     return false;
 }
 #endif
 
-void gfxFontFamily::LocalizedName(nsAString& aLocalizedName)
+void gfxFontFamily::LocalizedName(nsACString& aLocalizedName)
 {
     // just return the primary name; subclasses should override
     aLocalizedName = mName;
 }
 
 void
 gfxFontFamily::FindFontForChar(GlobalFontMatch* aMatchData)
 {
@@ -1860,17 +1860,17 @@ gfxFontFamily::FindFontForChar(GlobalFon
         if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Debug))) {
             uint32_t unicodeRange = FindCharUnicodeRange(aMatchData->mCh);
             Script script = GetScriptCode(aMatchData->mCh);
             MOZ_LOG(log, LogLevel::Debug,\
                    ("(textrun-systemfallback-fonts) char: u+%6.6x "
                     "unicode-range: %d script: %d match: [%s]\n",
                     aMatchData->mCh,
                     unicodeRange, int(script),
-                    NS_ConvertUTF16toUTF8(fe->Name()).get()));
+                    fe->Name().get()));
         }
 
         distance = WeightStyleStretchDistance(fe, aMatchData->mStyle);
     } else if (!fe->IsNormalStyle()) {
         // If style/weight/stretch was not Normal, see if we can
         // fall back to a next-best face (e.g. Arial Black -> Bold,
         // or Arial Narrow -> Regular).
         GlobalFontMatch data(aMatchData->mCh, aMatchData->mStyle);
@@ -1918,20 +1918,20 @@ gfxFontFamily::SearchAllFontsForChar(Glo
 /*virtual*/
 gfxFontFamily::~gfxFontFamily()
 {
     // Should not be dropped by stylo
     MOZ_ASSERT(NS_IsMainThread());
 }
 
 /*static*/ void
-gfxFontFamily::ReadOtherFamilyNamesForFace(const nsAString& aFamilyName,
+gfxFontFamily::ReadOtherFamilyNamesForFace(const nsACString& aFamilyName,
                                            const char *aNameData,
                                            uint32_t aDataLength,
-                                           nsTArray<nsString>& aOtherFamilyNames,
+                                           nsTArray<nsCString>& aOtherFamilyNames,
                                            bool useFullName)
 {
     const gfxFontUtils::NameHeader *nameHeader =
         reinterpret_cast<const gfxFontUtils::NameHeader*>(aNameData);
 
     uint32_t nameCount = nameHeader->count;
     if (nameCount * sizeof(gfxFontUtils::NameRecord) > aDataLength) {
         NS_WARNING("invalid font (name records)");
@@ -1950,17 +1950,17 @@ gfxFontFamily::ReadOtherFamilyNamesForFa
             NS_WARNING("invalid font (name table strings)");
             return;
         }
 
         uint16_t nameID = nameRecord->nameID;
         if ((useFullName && nameID == gfxFontUtils::NAME_ID_FULL) ||
             (!useFullName && (nameID == gfxFontUtils::NAME_ID_FAMILY ||
                               nameID == gfxFontUtils::NAME_ID_PREFERRED_FAMILY))) {
-            nsAutoString otherFamilyName;
+            nsAutoCString otherFamilyName;
             bool ok = gfxFontUtils::DecodeFontName(aNameData + stringsBase + nameOff,
                                                      nameLen,
                                                      uint32_t(nameRecord->platformID),
                                                      uint32_t(nameRecord->encodingID),
                                                      uint32_t(nameRecord->languageID),
                                                      otherFamilyName);
             // add if not same as canonical family name
             if (ok && otherFamilyName != aFamilyName) {
@@ -1973,17 +1973,17 @@ gfxFontFamily::ReadOtherFamilyNamesForFa
 // returns true if other names were found, false otherwise
 bool
 gfxFontFamily::ReadOtherFamilyNamesForFace(gfxPlatformFontList *aPlatformFontList,
                                            hb_blob_t           *aNameTable,
                                            bool                 useFullName)
 {
     uint32_t dataLength;
     const char *nameData = hb_blob_get_data(aNameTable, &dataLength);
-    AutoTArray<nsString,4> otherFamilyNames;
+    AutoTArray<nsCString,4> otherFamilyNames;
 
     ReadOtherFamilyNamesForFace(mName, nameData, dataLength,
                                 otherFamilyNames, useFullName);
 
     uint32_t n = otherFamilyNames.Length();
     for (uint32_t i = 0; i < n; i++) {
         aPlatformFontList->AddOtherFamilyName(this, otherFamilyNames[i]);
     }
@@ -2035,20 +2035,20 @@ gfxFontFamily::ReadOtherFamilyNames(gfxP
         if (!nameTable) {
             continue;
         }
         ReadOtherFamilyNamesForFace(aPlatformFontList, nameTable);
     }
 }
 
 static bool
-LookForLegacyFamilyName(const nsAString& aCanonicalName,
+LookForLegacyFamilyName(const nsACString& aCanonicalName,
                         const char* aNameData,
                         uint32_t aDataLength,
-                        nsAString& aLegacyName /* outparam */)
+                        nsACString& aLegacyName /* outparam */)
 {
     const gfxFontUtils::NameHeader* nameHeader =
         reinterpret_cast<const gfxFontUtils::NameHeader*>(aNameData);
 
     uint32_t nameCount = nameHeader->count;
     if (nameCount * sizeof(gfxFontUtils::NameRecord) > aDataLength) {
         NS_WARNING("invalid font (name records)");
         return false;
@@ -2101,17 +2101,17 @@ gfxFontFamily::CheckForLegacyFamilyNames
     for (auto& fe : faces) {
         if (!fe) {
             continue;
         }
         gfxFontEntry::AutoTable nameTable(fe, kNAME);
         if (!nameTable) {
             continue;
         }
-        nsAutoString legacyName;
+        nsAutoCString legacyName;
         uint32_t dataLength;
         const char* nameData = hb_blob_get_data(nameTable, &dataLength);
         if (LookForLegacyFamilyName(Name(), nameData, dataLength,
                                     legacyName)) {
             if (aFontList->AddWithLegacyFamilyName(legacyName, fe)) {
                 added = true;
             }
         }
@@ -2131,17 +2131,17 @@ gfxFontFamily::ReadFaceNames(gfxPlatform
 
     bool asyncFontLoaderDisabled = false;
 
     if (!mOtherFamilyNamesInitialized &&
         aFontInfoData &&
         aFontInfoData->mLoadOtherNames &&
         !asyncFontLoaderDisabled)
     {
-        AutoTArray<nsString,4> otherFamilyNames;
+        AutoTArray<nsCString,4> otherFamilyNames;
         bool foundOtherNames =
             aFontInfoData->GetOtherFamilyNames(mName, otherFamilyNames);
         if (foundOtherNames) {
             uint32_t i, n = otherFamilyNames.Length();
             for (i = 0; i < n; i++) {
                 aPlatformFontList->AddOtherFamilyName(this, otherFamilyNames[i]);
             }
         }
@@ -2167,17 +2167,17 @@ gfxFontFamily::ReadFaceNames(gfxPlatform
 
     bool firstTime = true, readAllFaces = false;
     for (i = 0; i < numFonts; ++i) {
         gfxFontEntry *fe = mAvailableFonts[i];
         if (!fe) {
             continue;
         }
 
-        nsAutoString fullname, psname;
+        nsAutoCString fullname, psname;
         bool foundFaceNames = false;
         if (!mFaceNamesInitialized &&
             aNeedFullnamePostscriptNames &&
             aFontInfoData &&
             aFontInfoData->mLoadFaceNames) {
             aFontInfoData->GetFaceNames(fe->Name(), fullname, psname);
             if (!fullname.IsEmpty()) {
                 aPlatformFontList->AddFullname(fe, fullname);
@@ -2233,17 +2233,17 @@ gfxFontFamily::ReadFaceNames(gfxPlatform
     }
 
     mFaceNamesInitialized = true;
     mOtherFamilyNamesInitialized = true;
 }
 
 
 gfxFontEntry*
-gfxFontFamily::FindFont(const nsAString& aPostscriptName)
+gfxFontFamily::FindFont(const nsACString& aPostscriptName)
 {
     // find the font using a simple linear search
     uint32_t numFonts = mAvailableFonts.Length();
     for (uint32_t i = 0; i < numFonts; i++) {
         gfxFontEntry *fe = mAvailableFonts[i].get();
         if (fe && fe->Name() == aPostscriptName)
             return fe;
     }
--- a/gfx/thebes/gfxFontEntry.h
+++ b/gfx/thebes/gfxFontEntry.h
@@ -121,39 +121,39 @@ public:
     typedef mozilla::FontStretch FontStretch;
     typedef mozilla::WeightRange WeightRange;
     typedef mozilla::SlantStyleRange SlantStyleRange;
     typedef mozilla::StretchRange StretchRange;
 
     // Used by stylo
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontEntry)
 
-    explicit gfxFontEntry(const nsAString& aName, bool aIsStandardFace = false);
+    explicit gfxFontEntry(const nsACString& aName, bool aIsStandardFace = false);
 
     // Create a new entry that refers to the same font as this, but without
     // additional state that may have been set up (such as family name).
     // (This is only to be used for system fonts in the platform font list,
     // not user fonts.)
     virtual gfxFontEntry* Clone() const = 0;
 
     // unique name for the face, *not* the family; not necessarily the
     // "real" or user-friendly name, may be an internal identifier
-    const nsString& Name() const { return mName; }
+    const nsCString& Name() const { return mName; }
 
     // family name
-    const nsString& FamilyName() const { return mFamilyName; }
+    const nsCString& FamilyName() const { return mFamilyName; }
 
     // The following two methods may be relatively expensive, as they
     // will (usually, except on Linux) load and parse the 'name' table;
     // they are intended only for the font-inspection API, not for
     // perf-critical layout/drawing work.
 
     // The "real" name of the face, if available from the font resource;
     // returns Name() if nothing better is available.
-    virtual nsString RealFaceName();
+    virtual nsCString RealFaceName();
 
     WeightRange Weight() const { return mWeightRange; }
     StretchRange Stretch() const { return mStretchRange; }
     SlantStyleRange SlantStyle() const { return mStyleRange; }
 
     bool IsUserFont() const { return mIsDataUserFont || mIsLocalUserFont; }
     bool IsLocalUserFont() const { return mIsLocalUserFont; }
     bool IsFixedPitch() const { return mFixedPitch; }
@@ -396,18 +396,18 @@ public:
                                const gfxFontStyle& aStyle);
 
     // Get the font's list of features (if any) for DevTools support.
     void GetFeatureInfo(nsTArray<gfxFontFeatureInfo>& aFeatureInfo);
 
     // This is only called on platforms where we use FreeType.
     virtual FT_MM_Var* GetMMVar() { return nullptr; }
 
-    nsString         mName;
-    nsString         mFamilyName;
+    nsCString         mName;
+    nsCString         mFamilyName;
 
     RefPtr<gfxCharacterMap> mCharacterMap;
 
     mozilla::UniquePtr<uint8_t[]> mUVSData;
     mozilla::UniquePtr<gfxUserFontData> mUserFontData;
     mozilla::UniquePtr<gfxSVGGlyphs> mSVGGlyphs;
     // list of gfxFonts that are using SVG glyphs
     nsTArray<gfxFont*> mFontsUsingSVGGlyphs;
@@ -711,33 +711,33 @@ struct GlobalFontMatch {
     float                  mMatchDistance; // metric indicating closest match
 };
 
 class gfxFontFamily {
 public:
     // Used by stylo
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(gfxFontFamily)
 
-    explicit gfxFontFamily(const nsAString& aName) :
+    explicit gfxFontFamily(const nsACString& aName) :
         mName(aName),
         mOtherFamilyNamesInitialized(false),
         mHasOtherFamilyNames(false),
         mFaceNamesInitialized(false),
         mHasStyles(false),
         mIsSimpleFamily(false),
         mIsBadUnderlineFamily(false),
         mFamilyCharacterMapInitialized(false),
         mSkipDefaultFeatureSpaceCheck(false),
         mCheckForFallbackFaces(false),
         mCheckedForLegacyFamilyNames(false)
         { }
 
-    const nsString& Name() { return mName; }
+    const nsCString& Name() { return mName; }
 
-    virtual void LocalizedName(nsAString& aLocalizedName);
+    virtual void LocalizedName(nsACString& aLocalizedName);
     virtual bool HasOtherFamilyNames();
 
     // See https://bugzilla.mozilla.org/show_bug.cgi?id=835204:
     // check the font's 'name' table to see if it has a legacy family name
     // that would have been used by GDI (e.g. to split extra-bold or light
     // faces in a large family into separate "styled families" because of
     // GDI's 4-faces-per-family limitation). If found, the styled family
     // name will be added to the font list's "other family names" table.
@@ -796,20 +796,20 @@ public:
     // checks all fonts for a matching font within the family
     void SearchAllFontsForChar(GlobalFontMatch* aMatchData);
 
     // read in other family names, if any, and use functor to add each into cache
     virtual void ReadOtherFamilyNames(gfxPlatformFontList *aPlatformFontList);
 
     // helper method for reading localized family names from the name table
     // of a single face
-    static void ReadOtherFamilyNamesForFace(const nsAString& aFamilyName,
+    static void ReadOtherFamilyNamesForFace(const nsACString& aFamilyName,
                                             const char *aNameData,
                                             uint32_t aDataLength,
-                                            nsTArray<nsString>& aOtherFamilyNames,
+                                            nsTArray<nsCString>& aOtherFamilyNames,
                                             bool useFullName);
 
     // set when other family names have been read in
     void SetOtherFamilyNamesInitialized() {
         mOtherFamilyNamesInitialized = true;
     }
 
     // read in other localized family names, fullnames and Postscript names
@@ -818,17 +818,17 @@ public:
                                bool aNeedFullnamePostscriptNames,
                                FontInfoData *aFontInfoData = nullptr);
 
     // find faces belonging to this family (platform implementations override this;
     // should be made pure virtual once all subclasses have been updated)
     virtual void FindStyleVariations(FontInfoData *aFontInfoData = nullptr) { }
 
     // search for a specific face using the Postscript name
-    gfxFontEntry* FindFont(const nsAString& aPostscriptName);
+    gfxFontEntry* FindFont(const nsACString& aPostscriptName);
 
     // read in cmaps for all the faces
     void ReadAllCMAPs(FontInfoData *aFontInfoData = nullptr);
 
     bool TestCharacterMap(uint32_t aCh) {
         if (!mFamilyCharacterMapInitialized) {
             ReadAllCMAPs();
         }
@@ -898,17 +898,17 @@ protected:
         uint32_t i, numFonts = mAvailableFonts.Length();
         for (i = 0; i < numFonts; i++) {
             if (mAvailableFonts[i]) {
                 mAvailableFonts[i]->mIsBadUnderlineFont = true;
             }
         }
     }
 
-    nsString mName;
+    nsCString mName;
     nsTArray<RefPtr<gfxFontEntry> >  mAvailableFonts;
     gfxSparseBitSet mFamilyCharacterMap;
     bool mOtherFamilyNamesInitialized : 1;
     bool mHasOtherFamilyNames : 1;
     bool mFaceNamesInitialized : 1;
     bool mHasStyles : 1;
     bool mIsSimpleFamily : 1;
     bool mIsBadUnderlineFamily : 1;
--- a/gfx/thebes/gfxFontFamilyList.h
+++ b/gfx/thebes/gfxFontFamilyList.h
@@ -61,16 +61,22 @@ struct FontFamilyName final {
 
     // named font family - e.g. Helvetica
     explicit FontFamilyName(const nsAString& aFamilyName,
                             QuotedName aQuoted = eUnquotedName) {
         mType = (aQuoted == eQuotedName) ? eFamily_named_quoted : eFamily_named;
         mName = aFamilyName;
     }
 
+    explicit FontFamilyName(const nsACString& aFamilyName,
+                            QuotedName aQuoted = eUnquotedName) {
+        mType = (aQuoted == eQuotedName) ? eFamily_named_quoted : eFamily_named;
+        mName.Append(NS_ConvertUTF8toUTF16(aFamilyName));
+    }
+
     // generic font family - e.g. sans-serif
     explicit FontFamilyName(FontFamilyType aType) {
         NS_ASSERTION(aType != eFamily_named &&
                      aType != eFamily_named_quoted &&
                      aType != eFamily_none,
                      "expected a generic font type");
         mName.Truncate();
         mType = aType;
@@ -188,16 +194,21 @@ public:
     {
     }
 
     SharedFontList(const nsAString& aFamilyName, QuotedName aQuoted)
         : mNames { FontFamilyName(aFamilyName, aQuoted) }
     {
     }
 
+    SharedFontList(const nsACString& aFamilyName, QuotedName aQuoted)
+        : mNames { FontFamilyName(aFamilyName, aQuoted) }
+    {
+    }
+
     explicit SharedFontList(const FontFamilyName& aName)
         : mNames { aName }
     {
     }
 
     explicit SharedFontList(nsTArray<FontFamilyName>&& aNames)
         : mNames(std::move(aNames))
     {
@@ -269,16 +280,23 @@ public:
 
     FontFamilyList(const nsAString& aFamilyName,
                    QuotedName aQuoted)
         : mFontlist(MakeNotNull<SharedFontList*>(aFamilyName, aQuoted))
         , mDefaultFontType(eFamily_none)
     {
     }
 
+    FontFamilyList(const nsACString& aFamilyName,
+                   QuotedName aQuoted)
+        : mFontlist(MakeNotNull<SharedFontList*>(aFamilyName, aQuoted))
+        , mDefaultFontType(eFamily_none)
+    {
+    }
+
     explicit FontFamilyList(const FontFamilyName& aName)
         : mFontlist(MakeNotNull<SharedFontList*>(aName))
         , mDefaultFontType(eFamily_none)
     {
     }
 
     explicit FontFamilyList(nsTArray<FontFamilyName>&& aNames)
         : mFontlist(MakeNotNull<SharedFontList*>(std::move(aNames)))
--- a/gfx/thebes/gfxFontFeatures.cpp
+++ b/gfx/thebes/gfxFontFeatures.cpp
@@ -10,22 +10,22 @@
 using namespace mozilla;
 
 gfxFontFeatureValueSet::gfxFontFeatureValueSet()
     : mFontFeatureValues(8)
 {
 }
 
 bool
-gfxFontFeatureValueSet::GetFontFeatureValuesFor(const nsAString& aFamily,
+gfxFontFeatureValueSet::GetFontFeatureValuesFor(const nsACString& aFamily,
                                                 uint32_t aVariantProperty,
                                                 const nsAString& aName,
                                                 nsTArray<uint32_t>& aValues)
 {
-    nsAutoString family(aFamily);
+    nsAutoCString family(aFamily);
     ToLowerCase(family);
     FeatureValueHashKey key(family, aVariantProperty, aName);
 
     aValues.Clear();
     FeatureValueHashEntry *entry = mFontFeatureValues.GetEntry(key);
     if (entry) {
         NS_ASSERTION(entry->mValues.Length() > 0,
                      "null array of font feature values");
@@ -33,20 +33,20 @@ gfxFontFeatureValueSet::GetFontFeatureVa
         return true;
     }
 
     return false;
 }
 
 
 void
-gfxFontFeatureValueSet::AddFontFeatureValues(const nsAString& aFamily,
+gfxFontFeatureValueSet::AddFontFeatureValues(const nsACString& aFamily,
                  const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aValues)
 {
-    nsAutoString family(aFamily);
+    nsAutoCString family(aFamily);
     ToLowerCase(family);
 
     uint32_t i, numFeatureValues = aValues.Length();
     for (i = 0; i < numFeatureValues; i++) {
         const FeatureValues& fv = aValues.ElementAt(i);
         uint32_t alternate = fv.alternate;
         uint32_t j, numValues = fv.valuelist.Length();
         for (j = 0; j < numValues; j++) {
@@ -54,17 +54,17 @@ gfxFontFeatureValueSet::AddFontFeatureVa
             auto* array = AppendFeatureValueHashEntry(family, v.name, alternate);
             *array = v.featureSelectors;
         }
     }
 }
 
 
 nsTArray<uint32_t>*
-gfxFontFeatureValueSet::AppendFeatureValueHashEntry(const nsAString& aFamily,
+gfxFontFeatureValueSet::AppendFeatureValueHashEntry(const nsACString& aFamily,
                                                     const nsAString& aName,
                                                     uint32_t aAlternate)
 {
     FeatureValueHashKey key(aFamily, aAlternate, aName);
     FeatureValueHashEntry *entry = mFontFeatureValues.PutEntry(key);
     entry->mKey = key;
     return &entry->mValues;
 }
--- a/gfx/thebes/gfxFontFeatures.h
+++ b/gfx/thebes/gfxFontFeatures.h
@@ -64,44 +64,44 @@ public:
 
     struct FeatureValues {
         uint32_t             alternate;
         nsTArray<ValueList>  valuelist;
     };
 
     // returns true if found, false otherwise
     bool
-    GetFontFeatureValuesFor(const nsAString& aFamily,
+    GetFontFeatureValuesFor(const nsACString& aFamily,
                             uint32_t aVariantProperty,
                             const nsAString& aName,
                             nsTArray<uint32_t>& aValues);
     void
-    AddFontFeatureValues(const nsAString& aFamily,
+    AddFontFeatureValues(const nsACString& aFamily,
                 const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aValues);
 
     // Appends a new hash entry with given key values and returns a pointer to
     // mValues array to fill. This should be filled first.
     nsTArray<uint32_t>*
-    AppendFeatureValueHashEntry(const nsAString& aFamily,
+    AppendFeatureValueHashEntry(const nsACString& aFamily,
                                 const nsAString& aName,
                                 uint32_t aAlternate);
 
 private:
     // Private destructor, to discourage deletion outside of Release():
     ~gfxFontFeatureValueSet() {}
 
     struct FeatureValueHashKey {
-        nsString mFamily;
+        nsCString mFamily;
         uint32_t mPropVal;
         nsString mName;
 
         FeatureValueHashKey()
             : mPropVal(0)
         { }
-        FeatureValueHashKey(const nsAString& aFamily,
+        FeatureValueHashKey(const nsACString& aFamily,
                             uint32_t aPropVal,
                             const nsAString& aName)
             : mFamily(aFamily), mPropVal(aPropVal), mName(aName)
         { }
         FeatureValueHashKey(const FeatureValueHashKey& aKey)
             : mFamily(aKey.mFamily), mPropVal(aKey.mPropVal), mName(aKey.mName)
         { }
     };
--- a/gfx/thebes/gfxFontInfoLoader.cpp
+++ b/gfx/thebes/gfxFontInfoLoader.cpp
@@ -31,17 +31,17 @@ FontInfoData::Load()
     mLoadStats.families = n;
     for (i = 0; i < n && !mCanceled; i++) {
         // font file memory mapping sometimes causes exceptions - bug 1100949
         MOZ_SEH_TRY {
             LoadFontFamilyData(mFontFamiliesToLoad[i]);
         } MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
             gfxCriticalError() <<
                 "Exception occurred reading font data for " <<
-                NS_ConvertUTF16toUTF8(mFontFamiliesToLoad[i]).get();
+                mFontFamiliesToLoad[i].get();
         }
     }
 
     mLoadTime = TimeStamp::Now() - start;
 }
 
 class FontInfoLoadCompleteEvent : public Runnable {
     virtual ~FontInfoLoadCompleteEvent() {}
--- a/gfx/thebes/gfxFontInfoLoader.h
+++ b/gfx/thebes/gfxFontInfoLoader.h
@@ -25,18 +25,18 @@ struct FontFaceData {
 
     FontFaceData(const FontFaceData& aFontFaceData) {
         mFullName = aFontFaceData.mFullName;
         mPostscriptName = aFontFaceData.mPostscriptName;
         mCharacterMap = aFontFaceData.mCharacterMap;
         mUVSOffset = aFontFaceData.mUVSOffset;
     }
 
-    nsString mFullName;
-    nsString mPostscriptName;
+    nsCString mFullName;
+    nsCString mPostscriptName;
     RefPtr<gfxCharacterMap> mCharacterMap;
     uint32_t mUVSOffset;
 };
 
 // base class used to contain cached system-wide font info.
 // methods in this class are called on off-main threads so
 // all methods use only static methods or other thread-safe
 // font data access API's. specifically, no use is made of
@@ -46,17 +46,16 @@ struct FontFaceData {
 class FontInfoData {
 public:
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FontInfoData)
 
     FontInfoData(bool aLoadOtherNames,
                  bool aLoadFaceNames,
                  bool aLoadCmaps) :
         mCanceled(false),
-        mLoadStats(),
         mLoadOtherNames(aLoadOtherNames),
         mLoadFaceNames(aLoadFaceNames),
         mLoadCmaps(aLoadCmaps)
     {
         MOZ_COUNT_CTOR(FontInfoData);
     }
 
 protected:
@@ -65,58 +64,58 @@ protected:
         MOZ_COUNT_DTOR(FontInfoData);
     }
 
 public:
     virtual void Load();
 
     // loads font data for all fonts of a given family
     // (called on async thread)
-    virtual void LoadFontFamilyData(const nsAString& aFamilyName) = 0;
+    virtual void LoadFontFamilyData(const nsACString& aFamilyName) = 0;
 
     // -- methods overriden by platform-specific versions --
 
     // fetches cmap data for a particular font from cached font data
     virtual already_AddRefed<gfxCharacterMap>
-    GetCMAP(const nsAString& aFontName,
+    GetCMAP(const nsACString& aFontName,
             uint32_t& aUVSOffset)
     {
         FontFaceData faceData;
         if (!mFontFaceData.Get(aFontName, &faceData) ||
             !faceData.mCharacterMap) {
             return nullptr;
         }
 
         aUVSOffset = faceData.mUVSOffset;
         RefPtr<gfxCharacterMap> cmap = faceData.mCharacterMap;
         return cmap.forget();
     }
 
     // fetches fullname/postscript names from cached font data
-    virtual void GetFaceNames(const nsAString& aFontName,
-                              nsAString& aFullName,
-                              nsAString& aPostscriptName)
+    virtual void GetFaceNames(const nsACString& aFontName,
+                              nsACString& aFullName,
+                              nsACString& aPostscriptName)
     {
         FontFaceData faceData;
         if (!mFontFaceData.Get(aFontName, &faceData)) {
             return;
         }
 
         aFullName = faceData.mFullName;
         aPostscriptName = faceData.mPostscriptName;
     }
 
     // fetches localized family name data from cached font data
-    virtual bool GetOtherFamilyNames(const nsAString& aFamilyName,
-                                     nsTArray<nsString>& aOtherFamilyNames)
+    virtual bool GetOtherFamilyNames(const nsACString& aFamilyName,
+                                     nsTArray<nsCString>& aOtherFamilyNames)
     {
         return mOtherFamilyNames.Get(aFamilyName, &aOtherFamilyNames); 
     }
 
-    nsTArray<nsString> mFontFamiliesToLoad;
+    nsTArray<nsCString> mFontFamiliesToLoad;
 
     // currently non-issue but beware,
     // this is also set during cleanup after finishing
     mozilla::Atomic<bool> mCanceled;
 
     // time spent on the loader thread
     mozilla::TimeDuration mLoadTime;
 
@@ -130,20 +129,20 @@ public:
 
     FontCounts mLoadStats;
 
     bool mLoadOtherNames;
     bool mLoadFaceNames;
     bool mLoadCmaps;
 
     // face name ==> per-face data
-    nsDataHashtable<nsStringHashKey, FontFaceData> mFontFaceData;
+    nsDataHashtable<nsCStringHashKey, FontFaceData> mFontFaceData;
 
     // canonical family name ==> array of localized family names
-    nsDataHashtable<nsStringHashKey, nsTArray<nsString> > mOtherFamilyNames;
+    nsDataHashtable<nsCStringHashKey, nsTArray<nsCString> > mOtherFamilyNames;
 };
 
 // gfxFontInfoLoader - helper class for loading font info on async thread
 // For large, "all fonts on system" data, data needed on a given platform
 // (e.g. localized names, face names, cmaps) are loaded async.
 
 // helper class for loading in font info on a separate async thread
 // once async thread completes, completion process is run on regular
--- a/gfx/thebes/gfxFontUtils.cpp
+++ b/gfx/thebes/gfxFontUtils.cpp
@@ -930,31 +930,16 @@ IsValidSFNTVersion(uint32_t version)
 {
     // normally 0x00010000, CFF-style OT fonts == 'OTTO' and Apple TT fonts = 'true'
     // 'typ1' is also possible for old Type 1 fonts in a SFNT container but not supported
     return version == 0x10000 ||
            version == TRUETYPE_TAG('O','T','T','O') ||
            version == TRUETYPE_TAG('t','r','u','e');
 }
 
-// Copy and swap UTF-16 values, assume no surrogate pairs, can be in place.
-// aInBuf and aOutBuf are NOT necessarily 16-bit-aligned, so we should avoid
-// accessing them directly as uint16_t* values.
-// aLen is count of UTF-16 values, so the byte buffers are twice that.
-static void
-CopySwapUTF16(const char* aInBuf, char* aOutBuf, uint32_t aLen)
-{
-    const char* end = aInBuf + aLen * 2;
-    while (aInBuf < end) {
-        uint8_t b0 = *aInBuf++;
-        *aOutBuf++ = *aInBuf++;
-        *aOutBuf++ = b0;
-    }
-}
-
 gfxUserFontType
 gfxFontUtils::DetermineFontDataType(const uint8_t *aFontData, uint32_t aFontDataLength)
 {
     // test for OpenType font data
     // problem: EOT-Lite with 0x10000 length will look like TrueType!
     if (aFontDataLength >= sizeof(SFNTHeader)) {
         const SFNTHeader *sfntHeader = reinterpret_cast<const SFNTHeader*>(aFontData);
         uint32_t sfntVersion = sfntHeader->sfntVersion;
@@ -1159,19 +1144,19 @@ gfxFontUtils::RenameFont(const nsAString
 }
 
 // This is only called after the basic validity of the downloaded sfnt
 // data has been checked, so it should never fail to find the name table
 // (though it might fail to read it, if memory isn't available);
 // other checks here are just for extra paranoia.
 nsresult
 gfxFontUtils::GetFullNameFromSFNT(const uint8_t* aFontData, uint32_t aLength,
-                                  nsAString& aFullName)
+                                  nsACString& aFullName)
 {
-    aFullName.AssignLiteral("(MISSING NAME)"); // should always get replaced
+    aFullName = "(MISSING NAME)"; // should always get replaced
 
     const TableDirEntry *dirEntry =
         FindTableDirEntry(aFontData, TRUETYPE_TAG('n','a','m','e'));
 
     // should never fail, as we're only called after font validation succeeded
     NS_ENSURE_TRUE(dirEntry, NS_ERROR_NOT_AVAILABLE);
 
     uint32_t len = dirEntry->length;
@@ -1184,57 +1169,57 @@ gfxFontUtils::GetFullNameFromSFNT(const 
     nsresult rv = GetFullNameFromTable(nameBlob, aFullName);
     hb_blob_destroy(nameBlob);
 
     return rv;
 }
 
 nsresult
 gfxFontUtils::GetFullNameFromTable(hb_blob_t *aNameTable,
-                                   nsAString& aFullName)
+                                   nsACString& aFullName)
 {
-    nsAutoString name;
+    nsAutoCString name;
     nsresult rv =
         gfxFontUtils::ReadCanonicalName(aNameTable,
                                         gfxFontUtils::NAME_ID_FULL,
                                         name);
     if (NS_SUCCEEDED(rv) && !name.IsEmpty()) {
         aFullName = name;
         return NS_OK;
     }
     rv = gfxFontUtils::ReadCanonicalName(aNameTable,
                                          gfxFontUtils::NAME_ID_FAMILY,
                                          name);
     if (NS_SUCCEEDED(rv) && !name.IsEmpty()) {
-        nsAutoString styleName;
+        nsAutoCString styleName;
         rv = gfxFontUtils::ReadCanonicalName(aNameTable,
                                              gfxFontUtils::NAME_ID_STYLE,
                                              styleName);
         if (NS_SUCCEEDED(rv) && !styleName.IsEmpty()) {
             name.Append(' ');
             name.Append(styleName);
             aFullName = name;
         }
         return NS_OK;
     }
 
     return NS_ERROR_NOT_AVAILABLE;
 }
 
 nsresult
 gfxFontUtils::GetFamilyNameFromTable(hb_blob_t *aNameTable,
-                                     nsAString& aFullName)
+                                     nsACString& aFamilyName)
 {
-    nsAutoString name;
+    nsAutoCString name;
     nsresult rv =
         gfxFontUtils::ReadCanonicalName(aNameTable,
                                         gfxFontUtils::NAME_ID_FAMILY,
                                         name);
     if (NS_SUCCEEDED(rv) && !name.IsEmpty()) {
-        aFullName = name;
+        aFamilyName = name;
         return NS_OK;
     }
     return NS_ERROR_NOT_AVAILABLE;
 }
 
 enum {
 #if defined(XP_MACOSX)
     CANONICAL_LANG_ID = gfxFontUtils::LANG_ID_MAC_ENGLISH,
@@ -1243,38 +1228,38 @@ enum {
     CANONICAL_LANG_ID = gfxFontUtils::LANG_ID_MICROSOFT_EN_US,
     PLATFORM_ID       = gfxFontUtils::PLATFORM_ID_MICROSOFT
 #endif
 };
 
 nsresult
 gfxFontUtils::ReadNames(const char *aNameData, uint32_t aDataLen,
                         uint32_t aNameID, int32_t aPlatformID,
-                        nsTArray<nsString>& aNames)
+                        nsTArray<nsCString>& aNames)
 {
     return ReadNames(aNameData, aDataLen, aNameID, LANG_ALL,
                      aPlatformID, aNames);
 }
 
 nsresult
 gfxFontUtils::ReadCanonicalName(hb_blob_t *aNameTable, uint32_t aNameID,
-                                nsString& aName)
+                                nsCString& aName)
 {
     uint32_t nameTableLen;
     const char *nameTable = hb_blob_get_data(aNameTable, &nameTableLen);
     return ReadCanonicalName(nameTable, nameTableLen, aNameID, aName);
 }
 
 nsresult
 gfxFontUtils::ReadCanonicalName(const char *aNameData, uint32_t aDataLen,
-                                uint32_t aNameID, nsString& aName)
+                                uint32_t aNameID, nsCString& aName)
 {
     nsresult rv;
 
-    nsTArray<nsString> names;
+    nsTArray<nsCString> names;
 
     // first, look for the English name (this will succeed 99% of the time)
     rv = ReadNames(aNameData, aDataLen, aNameID, CANONICAL_LANG_ID,
                    PLATFORM_ID, names);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // otherwise, grab names for all languages
     if (names.Length() == 0) {
@@ -1445,17 +1430,17 @@ StartsWith(const nsACString& string, con
   return memcmp(string.Data(), prefix, N - 1) == 0;
 }
 
 // convert a raw name from the name table to an nsString, if possible;
 // return value indicates whether conversion succeeded
 bool
 gfxFontUtils::DecodeFontName(const char *aNameData, int32_t aByteLen,
                              uint32_t aPlatformCode, uint32_t aScriptCode,
-                             uint32_t aLangCode, nsAString& aName)
+                             uint32_t aLangCode, nsACString& aName)
 {
     if (aByteLen <= 0) {
         NS_WARNING("empty font name");
         aName.SetLength(0);
         return true;
     }
 
     auto encoding = GetCharsetForFontName(aPlatformCode, aScriptCode, aLangCode);
@@ -1468,62 +1453,51 @@ gfxFontUtils::DecodeFontName(const char 
             aByteLen = 64;
         SprintfLiteral(warnBuf, "skipping font name, unknown charset %d:%d:%d for <%.*s>",
                        aPlatformCode, aScriptCode, aLangCode, aByteLen, aNameData);
         NS_WARNING(warnBuf);
 #endif
         return false;
     }
 
-    if (encoding == UTF_16BE_ENCODING) {
-        // no need to instantiate a converter
-        uint32_t strLen = aByteLen / 2;
-        aName.SetLength(strLen);
-#ifdef IS_LITTLE_ENDIAN
-        CopySwapUTF16(aNameData, reinterpret_cast<char*>(aName.BeginWriting()),
-                      strLen);
-#else
-        memcpy(aName.BeginWriting(), aNameData, strLen * 2);
-#endif
-        return true;
-    }
-
     if (encoding == X_USER_DEFINED_ENCODING) {
 #ifdef XP_MACOSX
         // Special case for macOS only: support legacy Mac encodings
         // that aren't part of the Encoding Standard.
         if (aPlatformCode == PLATFORM_ID_MAC) {
             CFStringRef str =
                 CFStringCreateWithBytes(kCFAllocatorDefault,
                                         (const UInt8*)aNameData, aByteLen,
                                         aScriptCode, false);
             if (str) {
                 CFIndex length = CFStringGetLength(str);
-                aName.SetLength(length);
+                nsAutoString name16;
+                name16.SetLength(length);
                 CFStringGetCharacters(str, CFRangeMake(0, length),
-                                      (UniChar*)aName.BeginWriting());
+                                      (UniChar*)name16.BeginWriting());
                 CFRelease(str);
+                CopyUTF16toUTF8(name16, aName);
                 return true;
             }
         }
 #endif
         NS_WARNING("failed to get the decoder for a font name string");
         return false;
     }
 
     auto rv = encoding->DecodeWithoutBOMHandling(
-      AsBytes(MakeSpan(aNameData, aByteLen)), aName);
+        nsDependentCSubstring(aNameData, aByteLen), aName);
     return NS_SUCCEEDED(rv);
 }
 
 nsresult
 gfxFontUtils::ReadNames(const char *aNameData, uint32_t aDataLen,
                         uint32_t aNameID,
                         int32_t aLangID, int32_t aPlatformID,
-                        nsTArray<nsString>& aNames)
+                        nsTArray<nsCString>& aNames)
 {
     NS_ASSERTION(aDataLen != 0, "null name table");
 
     if (!aDataLen) {
         return NS_ERROR_FAILURE;
     }
 
     // -- name table data
@@ -1572,17 +1546,17 @@ gfxFontUtils::ReadNames(const char *aNam
 
         if (nameStringsBase + uint64_t(nameoff) + uint64_t(namelen)
                 > aDataLen) {
             NS_WARNING("invalid font (name table strings)");
             return NS_ERROR_FAILURE;
         }
 
         // -- decode if necessary and make nsString
-        nsAutoString name;
+        nsAutoCString name;
 
         DecodeFontName(aNameData + nameStringsBase + nameoff, namelen,
                        platformID, uint32_t(nameRecord->encodingID),
                        uint32_t(nameRecord->languageID), name);
 
         uint32_t k, numNames;
         bool foundName = false;
 
--- a/gfx/thebes/gfxFontUtils.h
+++ b/gfx/thebes/gfxFontUtils.h
@@ -824,28 +824,28 @@ public:
     DetermineFontDataType(const uint8_t *aFontData, uint32_t aFontDataLength);
 
     // Read the fullname from the sfnt data (used to save the original name
     // prior to renaming the font for installation).
     // This is called with sfnt data that has already been validated,
     // so it should always succeed in finding the name table.
     static nsresult
     GetFullNameFromSFNT(const uint8_t* aFontData, uint32_t aLength,
-                        nsAString& aFullName);
+                        nsACString& aFullName);
 
     // helper to get fullname from name table, constructing from family+style
     // if no explicit fullname is present
     static nsresult
     GetFullNameFromTable(hb_blob_t *aNameTable,
-                         nsAString& aFullName);
+                         nsACString& aFullName);
 
     // helper to get family name from name table
     static nsresult
     GetFamilyNameFromTable(hb_blob_t *aNameTable,
-                           nsAString& aFamilyName);
+                           nsACString& aFamilyName);
 
     // Find the table directory entry for a given table tag, in a (validated)
     // buffer of 'sfnt' data. Returns null if the tag is not present.
     static mozilla::TableDirEntry*
     FindTableDirEntry(const void* aFontData, uint32_t aTableTag);
 
     // Return a blob that wraps a table found within a buffer of font data.
     // The blob does NOT own its data; caller guarantees that the buffer
@@ -860,35 +860,35 @@ public:
     // appended on the end, returns true on success
     static nsresult
     RenameFont(const nsAString& aName, const uint8_t *aFontData, 
                uint32_t aFontDataLength, FallibleTArray<uint8_t> *aNewFont);
     
     // read all names matching aNameID, returning in aNames array
     static nsresult
     ReadNames(const char *aNameData, uint32_t aDataLen, uint32_t aNameID,
-              int32_t aPlatformID, nsTArray<nsString>& aNames);
+              int32_t aPlatformID, nsTArray<nsCString>& aNames);
 
     // reads English or first name matching aNameID, returning in aName
     // platform based on OS
     static nsresult
     ReadCanonicalName(hb_blob_t *aNameTable, uint32_t aNameID,
-                      nsString& aName);
+                      nsCString& aName);
 
     static nsresult
     ReadCanonicalName(const char *aNameData, uint32_t aDataLen,
-                      uint32_t aNameID, nsString& aName);
+                      uint32_t aNameID, nsCString& aName);
 
     // convert a name from the raw name table data into an nsString,
     // provided we know how; return true if successful, or false
     // if we can't handle the encoding
     static bool
     DecodeFontName(const char *aBuf, int32_t aLength, 
                    uint32_t aPlatformCode, uint32_t aScriptCode,
-                   uint32_t aLangCode, nsAString& dest);
+                   uint32_t aLangCode, nsACString& dest);
 
     static inline bool IsJoinCauser(uint32_t ch) {
         return (ch == 0x200D);
     }
 
     // We treat Combining Grapheme Joiner (U+034F) together with the join
     // controls (ZWJ, ZWNJ) here, because (like them) it is an invisible
     // char that will be handled by the shaper even if not explicitly
@@ -994,17 +994,17 @@ public:
     GetVariationInstances(gfxFontEntry* aFontEntry,
                           nsTArray<gfxFontVariationInstance>& aInstances);
 
 protected:
     friend struct MacCharsetMappingComparator;
 
     static nsresult
     ReadNames(const char *aNameData, uint32_t aDataLen, uint32_t aNameID,
-              int32_t aLangID, int32_t aPlatformID, nsTArray<nsString>& aNames);
+              int32_t aLangID, int32_t aPlatformID, nsTArray<nsCString>& aNames);
 
     // convert opentype name-table platform/encoding/language values to an
     // Encoding object we can use to convert the name data to unicode
     static const mozilla::Encoding*
     GetCharsetForFontName(uint16_t aPlatform, uint16_t aScript, uint16_t aLanguage);
 
     struct MacFontNameCharsetMapping {
         uint16_t    mScript;
--- a/gfx/thebes/gfxFontVariations.h
+++ b/gfx/thebes/gfxFontVariations.h
@@ -12,30 +12,30 @@
 #include "nsTArray.h"
 
 typedef mozilla::gfx::FontVariation gfxFontVariation;
 
 // Structure that describes a single axis of variation in an
 // OpenType Variation or Multiple-Master font.
 struct gfxFontVariationAxis {
     uint32_t mTag;
-    nsString mName; // may be empty
+    nsCString mName; // may be empty
     float    mMinValue;
     float    mMaxValue;
     float    mDefaultValue;
 };
 
 // A single <axis, value> pair that may be applied to a variation font.
 struct gfxFontVariationValue {
     uint32_t mAxis;
     float    mValue;
 };
 
 // Structure that describes a named instance of a variation font:
 // a name like "Light Condensed" or "Black Ultra Extended" etc.,
 // and a list of the corresponding <variation-axis, value> pairs
 // to be used.
 struct gfxFontVariationInstance {
-    nsString mName;
+    nsCString mName;
     nsTArray<gfxFontVariationValue> mValues;
 };
 
 #endif
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -414,28 +414,28 @@ gfxGDIFont::Initialize()
                                            &ctm, fontOptions);
     cairo_font_options_destroy(fontOptions);
 
     if (!mScaledFont ||
         cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
 #ifdef DEBUG
         char warnBuf[1024];
         SprintfLiteral(warnBuf, "Failed to create scaled font: %s status: %d",
-                       NS_ConvertUTF16toUTF8(mFontEntry->Name()).get(),
+                       mFontEntry->Name().get(),
                        mScaledFont ? cairo_scaled_font_status(mScaledFont) : 0);
         NS_WARNING(warnBuf);
 #endif
         mIsValid = false;
     } else {
         mIsValid = true;
     }
 
 #if 0
     printf("Font: %p (%s) size: %f adjusted size: %f valid: %s\n", this,
-           NS_ConvertUTF16toUTF8(GetName()).get(), mStyle.size, mAdjustedSize, (mIsValid ? "yes" : "no"));
+           GetName().get(), mStyle.size, mAdjustedSize, (mIsValid ? "yes" : "no"));
     printf("    emHeight: %f emAscent: %f emDescent: %f\n", mMetrics->emHeight, mMetrics->emAscent, mMetrics->emDescent);
     printf("    maxAscent: %f maxDescent: %f maxAdvance: %f\n", mMetrics->maxAscent, mMetrics->maxDescent, mMetrics->maxAdvance);
     printf("    internalLeading: %f externalLeading: %f\n", mMetrics->internalLeading, mMetrics->externalLeading);
     printf("    spaceWidth: %f aveCharWidth: %f\n", mMetrics->spaceWidth, mMetrics->aveCharWidth);
     printf("    xHeight: %f capHeight: %f\n", mMetrics->xHeight, mMetrics->capHeight);
     printf("    uOff: %f uSize: %f stOff: %f stSize: %f\n",
            mMetrics->underlineOffset, mMetrics->underlineSize, mMetrics->strikeoutOffset, mMetrics->strikeoutSize);
 #endif
--- a/gfx/thebes/gfxGDIFontList.cpp
+++ b/gfx/thebes/gfxGDIFontList.cpp
@@ -108,17 +108,17 @@ FontTypeToOutPrecision(uint8_t fontType)
 }
 
 /***************************************************************
  *
  * GDIFontEntry
  *
  */
 
-GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
+GDIFontEntry::GDIFontEntry(const nsACString& aFaceName,
                            gfxWindowsFontType aFontType,
                            SlantStyleRange aStyle,
                            WeightRange aWeight,
                            StretchRange aStretch,
                            gfxUserFontData *aUserFontData)
     : gfxFontEntry(aFaceName),
       mFontType(aFontType),
       mForceGDI(false),
@@ -189,23 +189,23 @@ GDIFontEntry::ReadCMAP(FontInfoData *aFo
         // if error occurred, initialize to null cmap
         mCharacterMap = new gfxCharacterMap();
         // For fonts where we failed to read the character map,
         // we can take a slow path to look up glyphs character by character
         mCharacterMap->mBuildOnTheFly = true;
     }
 
     LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %d hash: %8.8x%s\n",
-                  NS_ConvertUTF16toUTF8(mName).get(),
+                  mName.get(),
                   charmap->SizeOfIncludingThis(moz_malloc_size_of),
                   charmap->mHash, mCharacterMap == charmap ? " new" : ""));
     if (LOG_CMAPDATA_ENABLED()) {
         char prefix[256];
         SprintfLiteral(prefix, "(cmapdata) name: %.220s",
-                       NS_ConvertUTF16toUTF8(mName).get());
+                       mName.get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
     }
 
     return rv;
 }
 
 gfxFont *
 GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle)
@@ -356,17 +356,17 @@ GDIFontEntry::TestCharacterMap(uint32_t 
         // font had a cmap so simply check that
         return mCharacterMap->test(aCh);
     }
 
     return false;
 }
 
 void
-GDIFontEntry::InitLogFont(const nsAString& aName,
+GDIFontEntry::InitLogFont(const nsACString& aName,
                           gfxWindowsFontType aFontType)
 {
 #define CLIP_TURNOFF_FONTASSOCIATION 0x40
 
     mLogFont.lfHeight = -1;
 
     // Fill in logFont structure
     mLogFont.lfWidth          = 0;
@@ -381,23 +381,24 @@ GDIFontEntry::InitLogFont(const nsAStrin
     mLogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
     // always force lfItalic if we want it.  Font selection code will
     // do its best to give us an italic font entry, but if no face exists
     // it may give us a regular one based on weight.  Windows should
     // do fake italic for us in that case.
     mLogFont.lfItalic         = !IsUpright();
     mLogFont.lfWeight         = Weight().Min().ToIntRounded();
 
-    int len = std::min<int>(aName.Length(), LF_FACESIZE - 1);
-    memcpy(&mLogFont.lfFaceName, aName.BeginReading(), len * sizeof(char16_t));
+    NS_ConvertUTF8toUTF16 name(aName);
+    int len = std::min<int>(name.Length(), LF_FACESIZE - 1);
+    memcpy(&mLogFont.lfFaceName, name.BeginReading(), len * sizeof(char16_t));
     mLogFont.lfFaceName[len] = '\0';
 }
 
 GDIFontEntry* 
-GDIFontEntry::CreateFontEntry(const nsAString& aName,
+GDIFontEntry::CreateFontEntry(const nsACString& aName,
                               gfxWindowsFontType aFontType,
                               SlantStyleRange aStyle,
                               WeightRange aWeight,
                               StretchRange aStretch,
                               gfxUserFontData* aUserFontData)
 {
     // jtdfix - need to set charset, unicode ranges, pitch/family
 
@@ -417,25 +418,25 @@ GDIFontEntry::AddSizeOfIncludingThis(Mal
 
 /***************************************************************
  *
  * GDIFontFamily
  *
  */
 
 static bool
-ShouldIgnoreItalicStyle(const nsAString& aName)
+ShouldIgnoreItalicStyle(const nsACString& aName)
 {
     // Ignore italic style's "Meiryo" because "Meiryo (Bold) Italic" has
     // non-italic style glyphs as Japanese characters.  However, using it
     // causes serious problem if web pages wants some elements to be
     // different style from others only with font-style.  For example,
     // <em> and <i> should be rendered as italic in the default style.
     return aName.EqualsLiteral("Meiryo") ||
-           aName.Equals(NS_LITERAL_STRING(u"\x30E1\x30A4\x30EA\x30AA"));
+           aName.EqualsLiteral("\xe3\x83\xa1\xe3\x82\xa4\xe3\x83\xaa\xe3\x82\xaa");
 }
 
 int CALLBACK
 GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
                                         const NEWTEXTMETRICEXW *nmetrics,
                                         DWORD fontType, LPARAM data)
 {
     const NEWTEXTMETRICW& metrics = nmetrics->ntmTm;
@@ -477,17 +478,17 @@ GDIFontFamily::FamilyAddStylesProc(const
         }
     }
 
     // We can't set the hasItalicFace flag correctly here,
     // because we might not have seen the family's italic face(s) yet.
     // So we'll set that flag for all members after loading all the faces.
     auto italicStyle = (logFont.lfItalic == 0xFF ?
                            FontSlantStyle::Italic() : FontSlantStyle::Normal());
-    fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName),
+    fe = GDIFontEntry::CreateFontEntry(NS_ConvertUTF16toUTF8(lpelfe->elfFullName),
                                        feType, SlantStyleRange(italicStyle),
                                        WeightRange(FontWeight(int32_t(logFont.lfWeight))),
                                        StretchRange(FontStretch::Normal()),
                                        nullptr);
     if (!fe)
         return 1;
 
     ff->AddFontEntry(fe);
@@ -505,18 +506,18 @@ GDIFontFamily::FamilyAddStylesProc(const
                 fe->mUnicodeRanges.set(x++, (range & (1 << k)) != 0);
             }
         }
     }
 
     if (LOG_FONTLIST_ENABLED()) {
         LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
              " with style: %s weight: %d stretch: normal",
-             NS_ConvertUTF16toUTF8(fe->Name()).get(),
-             NS_ConvertUTF16toUTF8(ff->Name()).get(),
+             fe->Name().get(),
+             ff->Name().get(),
              (logFont.lfItalic == 0xff) ? "italic" : "normal",
              logFont.lfWeight));
     }
     return 1;
 }
 
 void
 GDIFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
@@ -527,25 +528,26 @@ GDIFontFamily::FindStyleVariations(FontI
 
     HDC hdc = GetDC(nullptr);
     SetGraphicsMode(hdc, GM_ADVANCED);
 
     LOGFONTW logFont;
     memset(&logFont, 0, sizeof(LOGFONTW));
     logFont.lfCharSet = DEFAULT_CHARSET;
     logFont.lfPitchAndFamily = 0;
-    uint32_t l = std::min<uint32_t>(mName.Length(), LF_FACESIZE - 1);
-    memcpy(logFont.lfFaceName, mName.get(), l * sizeof(char16_t));
+    NS_ConvertUTF8toUTF16 name(mName);
+    uint32_t l = std::min<uint32_t>(name.Length(), LF_FACESIZE - 1);
+    memcpy(logFont.lfFaceName, name.get(), l * sizeof(char16_t));
 
     EnumFontFamiliesExW(hdc, &logFont,
                         (FONTENUMPROCW)GDIFontFamily::FamilyAddStylesProc,
                         (LPARAM)this, 0);
     if (LOG_FONTLIST_ENABLED() && mAvailableFonts.Length() == 0) {
         LOG_FONTLIST(("(fontlist) no styles available in family \"%s\"",
-                      NS_ConvertUTF16toUTF8(mName).get()));
+                      mName.get()));
     }
 
     ReleaseDC(nullptr, hdc);
 
     if (mIsBadUnderlineFamily) {
         SetBadUnderlineFonts();
     }
 }
@@ -608,38 +610,42 @@ gfxGDIFontList::GetFontSubstitutes()
 
         nsAutoString substituteName((char16_t*) aliasName);
         nsAutoString actualFontName((char16_t*) actualName);
         RemoveCharsetFromFontSubstitute(substituteName);
         BuildKeyNameFromFontName(substituteName);
         RemoveCharsetFromFontSubstitute(actualFontName);
         BuildKeyNameFromFontName(actualFontName);
         gfxFontFamily *ff;
-        if (!actualFontName.IsEmpty() && 
-            (ff = mFontFamilies.GetWeak(actualFontName))) {
-            mFontSubstitutes.Put(substituteName, ff);
+        NS_ConvertUTF16toUTF8 substitute(substituteName);
+        NS_ConvertUTF16toUTF8 actual(actualFontName);
+        if (!actual.IsEmpty() && 
+            (ff = mFontFamilies.GetWeak(actual))) {
+            mFontSubstitutes.Put(substitute, ff);
         } else {
-            mNonExistingFonts.AppendElement(substituteName);
+            mNonExistingFonts.AppendElement(substitute);
         }
     }
 
     // "Courier" on a default Windows install is an ugly bitmap font.
     // If there is no substitution for Courier in the registry
     // substitute "Courier" with "Courier New".
     nsAutoString substituteName;
     substituteName.AssignLiteral("Courier");
     BuildKeyNameFromFontName(substituteName);
-    if (!mFontSubstitutes.GetWeak(substituteName)) {
+    NS_ConvertUTF16toUTF8 substitute(substituteName);
+    if (!mFontSubstitutes.GetWeak(substitute)) {
         gfxFontFamily *ff;
         nsAutoString actualFontName;
         actualFontName.AssignLiteral("Courier New");
         BuildKeyNameFromFontName(actualFontName);
-        ff = mFontFamilies.GetWeak(actualFontName);
+        NS_ConvertUTF16toUTF8 actual(actualFontName);
+        ff = mFontFamilies.GetWeak(actual);
         if (ff) {
-            mFontSubstitutes.Put(substituteName, ff);
+            mFontSubstitutes.Put(substitute, ff);
         }
     }
     return NS_OK;
 }
 
 nsresult
 gfxGDIFontList::InitFontListForPlatform()
 {
@@ -676,46 +682,48 @@ gfxGDIFontList::EnumFontFamExProc(ENUMLO
 
     if (lf.lfFaceName[0] == '@') {
         return 1;
     }
 
     nsAutoString name(lf.lfFaceName);
     BuildKeyNameFromFontName(name);
 
+    NS_ConvertUTF16toUTF8 key(name);
+
     gfxGDIFontList *fontList = PlatformFontList();
 
-    if (!fontList->mFontFamilies.GetWeak(name)) {
-        nsDependentString faceName(lf.lfFaceName);
+    if (!fontList->mFontFamilies.GetWeak(key)) {
+        NS_ConvertUTF16toUTF8 faceName(lf.lfFaceName);
         RefPtr<GDIFontFamily> family = new GDIFontFamily(faceName);
-        fontList->mFontFamilies.Put(name, family);
+        fontList->mFontFamilies.Put(key, family);
 
         // if locale is such that CJK font names are the default coming from
         // GDI, then if a family name is non-ASCII immediately read in other
         // family names.  This assures that MS Gothic, MS Mincho are all found
         // before lookups begin.
         if (!IsASCII(faceName)) {
             family->ReadOtherFamilyNames(gfxPlatformFontList::PlatformFontList());
         }
 
-        if (fontList->mBadUnderlineFamilyNames.Contains(name))
+        if (fontList->mBadUnderlineFamilyNames.Contains(key))
             family->SetBadUnderlineFamily();
 
         family->mWindowsFamily = lf.lfPitchAndFamily & 0xF0;
         family->mWindowsPitch = lf.lfPitchAndFamily & 0x0F;
 
         // mark the charset bit
         family->mCharset.set(metrics.tmCharSet);
     }
 
     return 1;
 }
 
 gfxFontEntry* 
-gfxGDIFontList::LookupLocalFont(const nsAString& aFontName,
+gfxGDIFontList::LookupLocalFont(const nsACString& aFontName,
                                 WeightRange aWeightForEntry,
                                 StretchRange aStretchForEntry,
                                 SlantStyleRange aStyleForEntry)
 {
     gfxFontEntry *lookup;
 
     lookup = LookupInFaceNameLists(aFontName);
     if (!lookup) {
@@ -798,17 +806,17 @@ FixupSymbolEncodedFont(uint8_t* aFontDat
                 gfxFontUtils::ENCODING_ID_MICROSOFT_UNICODEBMP;
             return true;
         }
     }
     return false;
 }
 
 gfxFontEntry*
-gfxGDIFontList::MakePlatformFont(const nsAString& aFontName,
+gfxGDIFontList::MakePlatformFont(const nsACString& aFontName,
                                  WeightRange aWeightForEntry,
                                  StretchRange aStretchForEntry,
                                  SlantStyleRange aStyleForEntry,
                                  const uint8_t* aFontData,
                                  uint32_t aLength)
 {
     // MakePlatformFont is responsible for deleting the font data with free
     // so we set up a stack object to ensure it is freed even if we take an
@@ -864,36 +872,37 @@ gfxGDIFontList::MakePlatformFont(const n
     // the font is referenced via the name this can be ignored
     if (fontRef && numFonts > 2) {
         RemoveFontMemResourceEx(fontRef);
         return nullptr;
     }
 
     // make a new font entry using the unique name
     WinUserFontData *winUserFontData = new WinUserFontData(fontRef);
-    GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName,
+    GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(NS_ConvertUTF16toUTF8(uniqueName),
         gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
         aStyleForEntry, aWeightForEntry, aStretchForEntry, winUserFontData);
 
     if (fe) {
       fe->mIsDataUserFont = true;
     }
 
     return fe;
 }
 
 bool
-gfxGDIFontList::FindAndAddFamilies(const nsAString& aFamily,
+gfxGDIFontList::FindAndAddFamilies(const nsACString& aFamily,
                                    nsTArray<FamilyAndGeneric>* aOutput,
                                    FindFamiliesFlags aFlags,
                                    gfxFontStyle* aStyle,
                                    gfxFloat aDevToCssSize)
 {
-    nsAutoString keyName(aFamily);
-    BuildKeyNameFromFontName(keyName);
+    NS_ConvertUTF8toUTF16 key16(aFamily);
+    BuildKeyNameFromFontName(key16);
+    NS_ConvertUTF16toUTF8 keyName(key16);
 
     gfxFontFamily *ff = mFontSubstitutes.GetWeak(keyName);
     if (ff) {
         aOutput->AppendElement(FamilyAndGeneric(ff));
         return true;
     }
 
     if (mNonExistingFonts.Contains(keyName)) {
@@ -913,27 +922,27 @@ gfxGDIFontList::GetDefaultFontForPlatfor
     gfxFontFamily *ff = nullptr;
 
     // this really shouldn't fail to find a font....
     NONCLIENTMETRICSW ncm;
     ncm.cbSize = sizeof(ncm);
     BOOL status = ::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 
                                           sizeof(ncm), &ncm, 0);
     if (status) {
-        ff = FindFamily(nsDependentString(ncm.lfMessageFont.lfFaceName));
+        ff = FindFamily(NS_ConvertUTF16toUTF8(ncm.lfMessageFont.lfFaceName));
         if (ff) {
             return ff;
         }
     }
 
     // ...but just in case, try another (long-deprecated) approach as well
     HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
     LOGFONTW logFont;
     if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont)) {
-        ff = FindFamily(nsDependentString(logFont.lfFaceName));
+        ff = FindFamily(NS_ConvertUTF16toUTF8(logFont.lfFaceName));
     }
 
     return ff;
 }
 
 void
 gfxGDIFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
                                        FontListSizes* aSizes) const
@@ -971,36 +980,36 @@ public:
     virtual void Load() {
         mHdc = GetDC(nullptr);
         SetGraphicsMode(mHdc, GM_ADVANCED);
         FontInfoData::Load();
         ReleaseDC(nullptr, mHdc);
     }
 
     // loads font data for all members of a given family
-    virtual void LoadFontFamilyData(const nsAString& aFamilyName);
+    virtual void LoadFontFamilyData(const nsACString& aFamilyName);
 
     // callback for GDI EnumFontFamiliesExW call
     static int CALLBACK EnumerateFontsForFamily(const ENUMLOGFONTEXW *lpelfe,
                                                 const NEWTEXTMETRICEXW *nmetrics,
                                                 DWORD fontType, LPARAM data);
 
     HDC mHdc;
 };
 
 struct EnumerateFontsForFamilyData {
-    EnumerateFontsForFamilyData(const nsAString& aFamilyName,
+    EnumerateFontsForFamilyData(const nsACString& aFamilyName,
                                 GDIFontInfo& aFontInfo)
         : mFamilyName(aFamilyName), mFontInfo(aFontInfo)
     {}
 
-    nsString mFamilyName;
-    nsTArray<nsString> mOtherFamilyNames;
+    nsCString mFamilyName;
+    nsTArray<nsCString> mOtherFamilyNames;
     GDIFontInfo& mFontInfo;
-    nsString mPreviousFontName;
+    nsCString mPreviousFontName;
 };
 
 int CALLBACK GDIFontInfo::EnumerateFontsForFamily(
                  const ENUMLOGFONTEXW *lpelfe,
                  const NEWTEXTMETRICEXW *nmetrics,
                  DWORD fontType, LPARAM data)
 {
     EnumerateFontsForFamilyData *famData =
@@ -1010,17 +1019,17 @@ int CALLBACK GDIFontInfo::EnumerateFonts
     const NEWTEXTMETRICW& metrics = nmetrics->ntmTm;
 
     AutoSelectFont font(hdc, &logFont);
     if (!font.IsValid()) {
         return 1;
     }
 
     FontFaceData fontData;
-    nsDependentString fontName(lpelfe->elfFullName);
+    NS_ConvertUTF16toUTF8 fontName(lpelfe->elfFullName);
 
     // callback called for each style-charset so return if style already seen
     if (fontName.Equals(famData->mPreviousFontName)) {
         return 1;
     }
     famData->mPreviousFontName = fontName;
     famData->mFontInfo.mLoadStats.fonts++;
 
@@ -1098,25 +1107,26 @@ int CALLBACK GDIFontInfo::EnumerateFonts
     if (cmapLoaded || nameDataLoaded) {
         famData->mFontInfo.mFontFaceData.Put(fontName, fontData);
     }
 
     return famData->mFontInfo.mCanceled ? 0 : 1;
 }
 
 void
-GDIFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
+GDIFontInfo::LoadFontFamilyData(const nsACString& aFamilyName)
 {
     // iterate over the family
     LOGFONTW logFont;
     memset(&logFont, 0, sizeof(LOGFONTW));
     logFont.lfCharSet = DEFAULT_CHARSET;
     logFont.lfPitchAndFamily = 0;
-    uint32_t l = std::min<uint32_t>(aFamilyName.Length(), LF_FACESIZE - 1);
-    memcpy(logFont.lfFaceName, aFamilyName.BeginReading(), l * sizeof(char16_t));
+    NS_ConvertUTF8toUTF16 name(aFamilyName);
+    uint32_t l = std::min<uint32_t>(name.Length(), LF_FACESIZE - 1);
+    memcpy(logFont.lfFaceName, name.BeginReading(), l * sizeof(char16_t));
 
     EnumerateFontsForFamilyData data(aFamilyName, *this);
 
     EnumFontFamiliesExW(mHdc, &logFont,
                         (FONTENUMPROCW)GDIFontInfo::EnumerateFontsForFamily,
                         (LPARAM)(&data), 0);
 
     // if found other names, insert them
@@ -1134,17 +1144,17 @@ gfxGDIFontList::CreateFontInfoData()
 
     RefPtr<GDIFontInfo> fi =
         new GDIFontInfo(true, NeedFullnamePostscriptNames(), loadCmaps);
 
     return fi.forget();
 }
 
 gfxFontFamily*
-gfxGDIFontList::CreateFontFamily(const nsAString& aName) const
+gfxGDIFontList::CreateFontFamily(const nsACString& aName) const
 {
     return new GDIFontFamily(aName);
 }
 
 #ifdef MOZ_BUNDLED_FONTS
 
 void
 gfxGDIFontList::ActivateBundledFonts()
--- a/gfx/thebes/gfxGDIFontList.h
+++ b/gfx/thebes/gfxGDIFontList.h
@@ -164,36 +164,36 @@ public:
     gfxFontEntry* Clone() const override;
 
     // GDI backend doesn't support font variations:
     bool HasVariations() override { return false; }
     void GetVariationAxes(nsTArray<gfxFontVariationAxis>&) override {}
     void GetVariationInstances(nsTArray<gfxFontVariationInstance>&) override {}
 
     // create a font entry for a font with a given name
-    static GDIFontEntry* CreateFontEntry(const nsAString& aName,
+    static GDIFontEntry* CreateFontEntry(const nsACString& aName,
                                          gfxWindowsFontType aFontType,
                                          SlantStyleRange aStyle,
                                          WeightRange aWeight,
                                          StretchRange aStretch,
                                          gfxUserFontData* aUserFontData);
 
     gfxWindowsFontType mFontType;
     bool mForceGDI;
 
     gfxSparseBitSet mUnicodeRanges;
 
 protected:
     friend class gfxGDIFont;
 
-    GDIFontEntry(const nsAString& aFaceName, gfxWindowsFontType aFontType,
+    GDIFontEntry(const nsACString& aFaceName, gfxWindowsFontType aFontType,
                  SlantStyleRange aStyle, WeightRange aWeight, StretchRange aStretch,
                  gfxUserFontData *aUserFontData);
 
-    void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);
+    void InitLogFont(const nsACString& aName, gfxWindowsFontType aFontType);
 
     gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle) override;
 
     virtual nsresult CopyFontTable(uint32_t aTableTag,
                                    nsTArray<uint8_t>& aBuffer) override;
 
     already_AddRefed<mozilla::gfx::UnscaledFontGDI> LookupUnscaledFont(HFONT aFont);
 
@@ -201,17 +201,17 @@ protected:
 
     mozilla::ThreadSafeWeakPtr<mozilla::gfx::UnscaledFontGDI> mUnscaledFont;
 };
 
 // a single font family, referencing one or more faces
 class GDIFontFamily : public gfxFontFamily
 {
 public:
-    explicit GDIFontFamily(const nsAString& aName) :
+    explicit GDIFontFamily(const nsACString& aName) :
         gfxFontFamily(aName),
         mWindowsFamily(0),
         mWindowsPitch(0),
         mCharset()
     {}
 
     virtual void FindStyleVariations(FontInfoData *aFontInfoData = nullptr);
 
@@ -318,30 +318,30 @@ class gfxGDIFontList : public gfxPlatfor
 public:
     static gfxGDIFontList* PlatformFontList() {
         return static_cast<gfxGDIFontList*>(sPlatformFontList);
     }
 
     // initialize font lists
     virtual nsresult InitFontListForPlatform() override;
 
-    gfxFontFamily* CreateFontFamily(const nsAString& aName) const override;
+    gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
 
-    bool FindAndAddFamilies(const nsAString& aFamily,
+    bool FindAndAddFamilies(const nsACString& aFamily,
                             nsTArray<FamilyAndGeneric>* aOutput,
                             FindFamiliesFlags aFlags,
                             gfxFontStyle* aStyle = nullptr,
                             gfxFloat aDevToCssSize = 1.0) override;
 
-    virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
+    virtual gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
                                           WeightRange aWeightForEntry,
                                           StretchRange aStretchForEntry,
                                           SlantStyleRange aStyleForEntry);
 
-    virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
+    virtual gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
                                            WeightRange aWeightForEntry,
                                            StretchRange aStretchForEntry,
                                            SlantStyleRange aStyleForEntry,
                                            const uint8_t* aFontData,
                                            uint32_t aLength);
 
     virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                         FontListSizes* aSizes) const;
@@ -366,12 +366,12 @@ private:
 
     virtual already_AddRefed<FontInfoData> CreateFontInfoData();
 
 #ifdef MOZ_BUNDLED_FONTS
     void ActivateBundledFonts();
 #endif
 
     FontFamilyTable mFontSubstitutes;
-    nsTArray<nsString> mNonExistingFonts;
+    nsTArray<nsCString> mNonExistingFonts;
 };
 
 #endif /* GFX_GDIFONTLIST_H */
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -959,17 +959,17 @@ gfxHarfBuzzShaper::GetHKerning(uint16_t 
             default:
                 // TODO: implement support for other formats,
                 // if they're ever used in practice
 #if DEBUG
                 {
                     char buf[1024];
                     SprintfLiteral(buf, "unknown kern subtable in %s: "
                                         "ver 0 format %d\n",
-                                   NS_ConvertUTF16toUTF8(mFont->GetName()).get(),
+                                   mFont->GetName().get(),
                                    format);
                     NS_WARNING(buf);
                 }
 #endif
                 break;
             }
         }
     } else {
@@ -1021,17 +1021,17 @@ gfxHarfBuzzShaper::GetHKerning(uint16_t 
                     // Note that format 1 cannot be supported here,
                     // as it requires the full glyph array to run the FSM,
                     // not just the current glyph pair.
 #if DEBUG
                     {
                         char buf[1024];
                         SprintfLiteral(buf, "unknown kern subtable in %s: "
                                             "ver 0 format %d\n",
-                                       NS_ConvertUTF16toUTF8(mFont->GetName()).get(),
+                                       mFont->GetName().get(),
                                        format);
                         NS_WARNING(buf);
                     }
 #endif
                     break;
                 }
             }
         }
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -131,17 +131,17 @@ gfxMacFont::gfxMacFont(const RefPtr<Unsc
 
     cairo_status_t cairoerr = cairo_font_face_status(mFontFace);
     if (cairoerr != CAIRO_STATUS_SUCCESS) {
         mIsValid = false;
 #ifdef DEBUG
         char warnBuf[1024];
         SprintfLiteral(warnBuf,
                        "Failed to create Cairo font face: %s status: %d",
-                       NS_ConvertUTF16toUTF8(GetName()).get(), cairoerr);
+                       GetName().get(), cairoerr);
         NS_WARNING(warnBuf);
 #endif
         return;
     }
 
     cairo_matrix_t sizeMatrix, ctm;
     cairo_matrix_init_identity(&ctm);
     cairo_matrix_init_scale(&sizeMatrix, mAdjustedSize, mAdjustedSize);
@@ -163,17 +163,17 @@ gfxMacFont::gfxMacFont(const RefPtr<Unsc
     cairo_font_options_destroy(fontOptions);
 
     cairoerr = cairo_scaled_font_status(mScaledFont);
     if (cairoerr != CAIRO_STATUS_SUCCESS) {
         mIsValid = false;
 #ifdef DEBUG
         char warnBuf[1024];
         SprintfLiteral(warnBuf, "Failed to create scaled font: %s status: %d",
-                       NS_ConvertUTF16toUTF8(GetName()).get(), cairoerr);
+                       GetName().get(), cairoerr);
         NS_WARNING(warnBuf);
 #endif
     }
 }
 
 gfxMacFont::~gfxMacFont()
 {
     if (mCGFont) {
@@ -308,17 +308,17 @@ gfxMacFont::InitMetrics()
     }
 
     if (upem < 16 || upem > 16384) {
         // See http://www.microsoft.com/typography/otspec/head.htm
 #ifdef DEBUG
         char warnBuf[1024];
         SprintfLiteral(warnBuf,
                        "Bad font metrics for: %s (invalid unitsPerEm value)",
-                       NS_ConvertUTF16toUTF8(mFontEntry->Name()).get());
+                       mFontEntry->Name().get());
         NS_WARNING(warnBuf);
 #endif
         return;
     }
 
     mAdjustedSize = std::max(mStyle.size, 1.0);
     mFUnitsConvFactor = mAdjustedSize / upem;
 
--- a/gfx/thebes/gfxMacPlatformFontList.h
+++ b/gfx/thebes/gfxMacPlatformFontList.h
@@ -27,22 +27,22 @@ class gfxMacPlatformFontList;
 
 // a single member of a font family (i.e. a single face, such as Times Italic)
 class MacOSFontEntry : public gfxFontEntry
 {
 public:
     friend class gfxMacPlatformFontList;
     friend class gfxMacFont;
 
-    MacOSFontEntry(const nsAString& aPostscriptName, WeightRange aWeight,
+    MacOSFontEntry(const nsACString& aPostscriptName, WeightRange aWeight,
                    bool aIsStandardFace = false,
                    double aSizeHint = 0.0);
 
     // for use with data fonts
-    MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
+    MacOSFontEntry(const nsACString& aPostscriptName, CGFontRef aFontRef,
                    WeightRange aWeight, StretchRange aStretch, SlantStyleRange aStyle,
                    bool aIsDataUserFont, bool aIsLocal);
 
     virtual ~MacOSFontEntry() {
         if (mTrakTable) {
             hb_blob_destroy(mTrakTable);
         }
         ::CGFontRelease(mFontRef);
@@ -132,45 +132,45 @@ protected:
 };
 
 class gfxMacPlatformFontList : public gfxPlatformFontList {
 public:
     static gfxMacPlatformFontList* PlatformFontList() {
         return static_cast<gfxMacPlatformFontList*>(sPlatformFontList);
     }
 
-    gfxFontFamily* CreateFontFamily(const nsAString& aName) const override;
+    gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
 
     static int32_t AppleWeightToCSSWeight(int32_t aAppleWeight);
 
-    bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) override;
+    bool GetStandardFamilyName(const nsCString& aFontName, nsACString& aFamilyName) override;
 
-    gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
+    gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
                                   WeightRange aWeightForEntry,
                                   StretchRange aStretchForEntry,
                                   SlantStyleRange aStyleForEntry) override;
 
-    gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
+    gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
                                    WeightRange aWeightForEntry,
                                    StretchRange aStretchForEntry,
                                    SlantStyleRange aStyleForEntry,
                                    const uint8_t* aFontData,
                                    uint32_t aLength) override;
 
-    bool FindAndAddFamilies(const nsAString& aFamily,
+    bool FindAndAddFamilies(const nsACString& aFamily,
                             nsTArray<FamilyAndGeneric>* aOutput,
                             FindFamiliesFlags aFlags,
                             gfxFontStyle* aStyle = nullptr,
                             gfxFloat aDevToCssSize = 1.0) override;
 
     // lookup the system font for a particular system font type and set
     // the name and style characteristics
     void LookupSystemFont(mozilla::LookAndFeel::FontID aSystemFontID,
-                          nsAString& aSystemFontName,
-                          gfxFontStyle &aFontStyle,
+                          nsACString& aSystemFontName,
+                          gfxFontStyle& aFontStyle,
                           float aDevPixPerCSSPixel);
 
     // Values for the entryType field in FontFamilyListEntry records passed
     // from chrome to content process.
     enum FontFamilyEntryType {
         kStandardFontFamily = 0, // a standard installed font family
         kHiddenSystemFontFamily = 1, // hidden system family, not exposed to UI
         kTextSizeSystemFontFamily = 2, // name of 'system' font at text sizes
@@ -194,17 +194,17 @@ private:
 
     // special case font faces treated as font families (set via prefs)
     void InitSingleFaceList();
 
     // initialize system fonts
     void InitSystemFontNames();
 
     // helper function to lookup in both hidden system fonts and normal fonts
-    gfxFontFamily* FindSystemFontFamily(const nsAString& aFamily);
+    gfxFontFamily* FindSystemFontFamily(const nsACString& aFamily);
 
     static void
     RegisteredFontsChangedNotificationCallback(CFNotificationCenterRef center,
                                                void *observer,
                                                CFStringRef name,
                                                const void *object,
                                                CFDictionaryRef userInfo);
 
@@ -222,17 +222,17 @@ private:
 
     // Add the specified family to mSystemFontFamilies or mFontFamilies.
     // Ideally we'd use NSString* instead of CFStringRef here, but this header
     // file is included in .cpp files, so we can't use objective C classes here.
     // But CFStringRef and NSString* are the same thing anyway (they're
     // toll-free bridged).
     void AddFamily(CFStringRef aFamily);
 
-    void AddFamily(const nsAString& aFamilyName, bool aSystemFont);
+    void AddFamily(const nsACString& aFamilyName, bool aSystemFont);
 
     void ActivateFontsFromDir(nsIFile* aDir);
 
 #ifdef MOZ_BUNDLED_FONTS
     void ActivateBundledFonts();
 #endif
 
     enum {
@@ -246,13 +246,13 @@ private:
     // for different locales (e.g. .Helvetica Neue UI, .SF NS Text)
     FontFamilyTable mSystemFontFamilies;
 
     // font families that -apple-system maps to
     // Pre-10.11 this was always a single font family, such as Lucida Grande
     // or Helvetica Neue. For OSX 10.11, Apple uses pair of families
     // for the UI, one for text sizes and another for display sizes
     bool mUseSizeSensitiveSystemFont;
-    nsString mSystemTextFontFamilyName;
-    nsString mSystemDisplayFontFamilyName; // only used on OSX 10.11
+    nsCString mSystemTextFontFamilyName;
+    nsCString mSystemDisplayFontFamilyName; // only used on OSX 10.11
 };
 
 #endif /* gfxMacPlatformFontList_H_ */
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -108,20 +108,20 @@ static const int gAppleWeightToCSSWeight
     9, // 12. W9, ultrabold
     9, // 13
     9  // 14
 };
 
 // cache Cocoa's "shared font manager" for performance
 static NSFontManager *sFontManager;
 
-static void GetStringForNSString(const NSString *aSrc, nsAString& aDist)
+static void GetStringForNSString(const NSString *aSrc, nsAString& aDest)
 {
-    aDist.SetLength([aSrc length]);
-    [aSrc getCharacters:reinterpret_cast<unichar*>(aDist.BeginWriting())];
+    aDest.SetLength([aSrc length]);
+    [aSrc getCharacters:reinterpret_cast<unichar*>(aDest.BeginWriting())];
 }
 
 static NSString* GetNSStringForString(const nsAString& aSrc)
 {
     return [NSString stringWithCharacters:reinterpret_cast<const unichar*>(aSrc.BeginReading())
                                    length:aSrc.Length()];
 }
 
@@ -249,23 +249,23 @@ MacOSFontEntry::ReadCMAP(FontInfoData *a
         gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
         mCharacterMap = pfl->FindCharMap(charmap);
     } else {
         // if error occurred, initialize to null cmap
         mCharacterMap = new gfxCharacterMap();
     }
 
     LOG_FONTLIST(("(fontlist-cmap) name: %s, size: %zu hash: %8.8x%s\n",
-                  NS_ConvertUTF16toUTF8(mName).get(),
+                  mName.get(),
                   charmap->SizeOfIncludingThis(moz_malloc_size_of),
                   charmap->mHash, mCharacterMap == charmap ? " new" : ""));
     if (LOG_CMAPDATA_ENABLED()) {
         char prefix[256];
         SprintfLiteral(prefix, "(cmapdata) name: %.220s",
-                       NS_ConvertUTF16toUTF8(mName).get());
+                       mName.get());
         charmap->Dump(prefix, eGfxLog_cmapdata);
     }
 
     return rv;
 }
 
 gfxFont*
 MacOSFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle)
@@ -360,17 +360,17 @@ MacOSFontEntry::IsCFF()
     if (!mIsCFFInitialized) {
         mIsCFFInitialized = true;
         mIsCFF = HasFontTable(TRUETYPE_TAG('C','F','F',' '));
     }
 
     return mIsCFF;
 }
 
-MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
+MacOSFontEntry::MacOSFontEntry(const nsACString& aPostscriptName,
                                WeightRange aWeight,
                                bool aIsStandardFace,
                                double aSizeHint)
     : gfxFontEntry(aPostscriptName, aIsStandardFace),
       mFontRef(NULL),
       mSizeHint(aSizeHint),
       mFontRefInitialized(false),
       mRequiresAAT(false),
@@ -385,17 +385,17 @@ MacOSFontEntry::MacOSFontEntry(const nsA
       mTrakTable(nullptr),
       mTrakValues(nullptr),
       mTrakSizeTable(nullptr),
       mNumTrakSizes(0)
 {
     mWeightRange = aWeight;
 }
 
-MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
+MacOSFontEntry::MacOSFontEntry(const nsACString& aPostscriptName,
                                CGFontRef aFontRef,
                                WeightRange aWeight,
                                StretchRange aStretch,
                                SlantStyleRange aStyle,
                                bool aIsDataUserFont,
                                bool aIsLocalUserFont)
     : gfxFontEntry(aPostscriptName, false),
       mFontRef(NULL),
@@ -442,17 +442,17 @@ MacOSFontEntry::Clone() const
     return fe;
 }
 
 CGFontRef
 MacOSFontEntry::GetFontRef()
 {
     if (!mFontRefInitialized) {
         mFontRefInitialized = true;
-        NSString *psname = GetNSStringForString(mName);
+        NSString *psname = GetNSStringForString(NS_ConvertUTF8toUTF16(mName));
         mFontRef = ::CGFontCreateWithFontName(CFStringRef(psname));
         if (!mFontRef) {
             // This happens on macOS 10.12 for font entry names that start with
             // .AppleSystemUIFont. For those fonts, we need to go through NSFont
             // to get the correct CGFontRef.
             // Both the Text and the Display variant of the display font use
             // .AppleSystemUIFontSomethingSomething as their member names.
             // That's why we're carrying along mSizeHint to this place so that
@@ -784,57 +784,59 @@ MacOSFontEntry::AddSizeOfIncludingThis(M
 }
 
 /* gfxMacFontFamily */
 #pragma mark-
 
 class gfxMacFontFamily : public gfxFontFamily
 {
 public:
-    explicit gfxMacFontFamily(const nsAString& aName, double aSizeHint) :
+    explicit gfxMacFontFamily(const nsACString& aName, double aSizeHint) :
         gfxFontFamily(aName),
         mSizeHint(aSizeHint)
     {}
 
     virtual ~gfxMacFontFamily() {}
 
-    virtual void LocalizedName(nsAString& aLocalizedName);
+    virtual void LocalizedName(nsACString& aLocalizedName);
 
     virtual void FindStyleVariations(FontInfoData *aFontInfoData = nullptr);
 
     virtual bool IsSingleFaceFamily() const
     {
         return false;
     }
 
 protected:
     double mSizeHint;
 };
 
 void
-gfxMacFontFamily::LocalizedName(nsAString& aLocalizedName)
+gfxMacFontFamily::LocalizedName(nsACString& aLocalizedName)
 {
     nsAutoreleasePool localPool;
 
     // It's unsafe to call HasOtherFamilyNames off the main thread because
     // it entrains FindStyleVariations, which calls GetWeightOverride, which
     // retrieves prefs.  And the pref names can change (via user overrides),
     // so we can't use gfxPrefs to access them.
     if (NS_IsMainThread() && !HasOtherFamilyNames()) {
         aLocalizedName = mName;
         return;
     }
 
-    NSString *family = GetNSStringForString(mName);
+    NSString *family = GetNSStringForString(NS_ConvertUTF8toUTF16(mName));
     NSString *localized = [sFontManager
                            localizedNameForFamily:family
                                              face:nil];
 
     if (localized) {
-        GetStringForNSString(localized, aLocalizedName);
+        nsAutoString locName;
+        GetStringForNSString(localized, locName);
+        CopyUTF16toUTF8(locName, aLocalizedName);
         return;
     }
 
     // failed to get localized name, just use the canonical one
     aLocalizedName = mName;
 }
 
 // Return the CSS weight value to use for the given face, overriding what
@@ -854,17 +856,17 @@ GetWeightOverride(const nsAString& aPSNa
 void
 gfxMacFontFamily::FindStyleVariations(FontInfoData *aFontInfoData)
 {
     if (mHasStyles)
         return;
 
     nsAutoreleasePool localPool;
 
-    NSString *family = GetNSStringForString(mName);
+    NSString *family = GetNSStringForString(NS_ConvertUTF8toUTF16(mName));
 
     // create a font entry for each face
     NSArray *fontfaces = [sFontManager
                           availableMembersOfFontFamily:family];  // returns an array of [psname, style name, weight, traits] elements, goofy api
     int faceCount = [fontfaces count];
     int faceIndex;
 
     for (faceIndex = 0; faceIndex < faceCount; faceIndex++) {
@@ -905,17 +907,17 @@ gfxMacFontFamily::FindStyleVariations(Fo
             [facename isEqualToString:@"Bold Italic"] ||
             [facename isEqualToString:@"Bold Oblique"])
         {
             isStandardFace = true;
         }
 
         // create a font entry
         MacOSFontEntry *fontEntry =
-            new MacOSFontEntry(postscriptFontName,
+            new MacOSFontEntry(NS_ConvertUTF16toUTF8(postscriptFontName),
                                WeightRange(FontWeight(cssWeight)),
                                isStandardFace, mSizeHint);
         if (!fontEntry) {
             break;
         }
 
         // set additional properties based on the traits reported by Cocoa
         if (macTraits & (NSCondensedFontMask | NSNarrowFontMask | NSCompressedFontMask)) {
@@ -942,18 +944,18 @@ gfxMacFontFamily::FindStyleVariations(Fo
         if (LOG_FONTLIST_ENABLED()) {
             nsAutoCString weightString;
             fontEntry->Weight().ToString(weightString);
             nsAutoCString stretchString;
             fontEntry->Stretch().ToString(stretchString);
             LOG_FONTLIST(("(fontlist) added (%s) to family (%s)"
                  " with style: %s weight: %s stretch: %s"
                  " (apple-weight: %d macTraits: %8.8x)",
-                 NS_ConvertUTF16toUTF8(fontEntry->Name()).get(),
-                 NS_ConvertUTF16toUTF8(Name()).get(),
+                 fontEntry->Name().get(),
+                 Name().get(),
                  fontEntry->IsItalic() ? "italic" : "normal",
                  weightString.get(),
                  stretchString.get(),
                  appKitWeight, macTraits));
         }
 
         // insert into font entry array of family
         AddFontEntry(fontEntry);
@@ -968,51 +970,53 @@ gfxMacFontFamily::FindStyleVariations(Fo
 }
 
 /* gfxSingleFaceMacFontFamily */
 #pragma mark-
 
 class gfxSingleFaceMacFontFamily : public gfxFontFamily
 {
 public:
-    explicit gfxSingleFaceMacFontFamily(const nsAString& aName) :
+    explicit gfxSingleFaceMacFontFamily(const nsACString& aName) :
         gfxFontFamily(aName)
     {
         mFaceNamesInitialized = true; // omit from face name lists
     }
 
     virtual ~gfxSingleFaceMacFontFamily() {}
 
-    virtual void LocalizedName(nsAString& aLocalizedName);
+    virtual void LocalizedName(nsACString& aLocalizedName);
 
     virtual void ReadOtherFamilyNames(gfxPlatformFontList *aPlatformFontList);
 
     virtual bool IsSingleFaceFamily() const
     {
         return true;
     }
 };
 
 void
-gfxSingleFaceMacFontFamily::LocalizedName(nsAString& aLocalizedName)
+gfxSingleFaceMacFontFamily::LocalizedName(nsACString& aLocalizedName)
 {
     nsAutoreleasePool localPool;
 
     if (!HasOtherFamilyNames()) {
         aLocalizedName = mName;
         return;
     }
 
     gfxFontEntry *fe = mAvailableFonts[0];
-    NSFont *font = [NSFont fontWithName:GetNSStringForString(fe->Name())
+    NSFont *font = [NSFont fontWithName:GetNSStringForString(NS_ConvertUTF8toUTF16(fe->Name()))
                                    size:0.0];
     if (font) {
         NSString *localized = [font displayName];
         if (localized) {
-            GetStringForNSString(localized, aLocalizedName);
+            nsAutoString locName;
+            GetStringForNSString(localized, locName);
+            CopyUTF16toUTF8(locName, aLocalizedName);
             return;
         }
     }
 
     // failed to get localized name, just use the canonical one
     aLocalizedName = mName;
 }
 
@@ -1097,29 +1101,29 @@ gfxMacPlatformFontList::~gfxMacPlatformF
     }
 
     if (mDefaultFont) {
         ::CFRelease(mDefaultFont);
     }
 }
 
 void
-gfxMacPlatformFontList::AddFamily(const nsAString& aFamilyName,
+gfxMacPlatformFontList::AddFamily(const nsACString& aFamilyName,
                                   bool aSystemFont)
 {
     FontFamilyTable& table =
         aSystemFont ? mSystemFontFamilies : mFontFamilies;
 
     double sizeHint = 0.0;
     if (aSystemFont && mUseSizeSensitiveSystemFont &&
         mSystemDisplayFontFamilyName.Equals(aFamilyName)) {
         sizeHint = 128.0;
     }
 
-    nsAutoString key;
+    nsAutoCString key;
     ToLowerCase(aFamilyName, key);
 
     RefPtr<gfxFontFamily> familyEntry =
         new gfxMacFontFamily(aFamilyName, sizeHint);
     table.Put(key, familyEntry);
 
     // check the bad underline blacklist
     if (mBadUnderlineFamilyNames.Contains(key)) {
@@ -1139,17 +1143,17 @@ gfxMacPlatformFontList::AddFamily(CFStri
         [family caseInsensitiveCompare:@".LastResort"] == NSOrderedSame) {
         return;
     }
 
     nsAutoString familyName;
     nsCocoaUtils::GetStringForNSString(family, familyName);
 
     bool isHiddenSystemFont = familyName[0] == '.';
-    AddFamily(familyName, isHiddenSystemFont);
+    AddFamily(NS_ConvertUTF16toUTF8(familyName), isHiddenSystemFont);
 }
 
 void
 gfxMacPlatformFontList::ReadSystemFontList(
     InfallibleTArray<SystemFontListEntry>* aList)
 {
     // Note: We rely on the records for mSystemTextFontFamilyName and
     // mSystemDisplayFontFamilyName (if present) being *before* the main
@@ -1248,25 +1252,25 @@ gfxMacPlatformFontList::InitSingleFaceLi
                       NS_ConvertUTF16toUTF8(singleFaceFamily).get()));
         // Each entry in the "single face families" list is expected to be a
         // colon-separated pair of FaceName:Family,
         // where FaceName is the individual face name (psname) of a font
         // that should be exposed as a separate family name,
         // and Family is the standard family to which that face belongs.
         // The only such face listed by default is
         //    Osaka-Mono:Osaka
-        nsAutoString familyName(singleFaceFamily);
+        NS_ConvertUTF16toUTF8 familyName(singleFaceFamily);
         auto colon = familyName.FindChar(':');
         if (colon == kNotFound) {
             continue;
         }
 
         // Look for the parent family in the main font family list,
         // and ensure we have loaded its list of available faces.
-        nsAutoString key(Substring(familyName, colon + 1));
+        nsAutoCString key(Substring(familyName, colon + 1));
         ToLowerCase(key);
         gfxFontFamily* family = mFontFamilies.GetWeak(key);
         if (!family) {
             continue;
         }
         family->FindStyleVariations();
 
         // Truncate the entry from prefs at the colon, so now it is just the
@@ -1283,35 +1287,35 @@ gfxMacPlatformFontList::InitSingleFaceLi
         }
         if (!fe) {
             continue;
         }
 
         // We found the correct face, so create the single-face family record.
         GenerateFontListKey(familyName, key);
         LOG_FONTLIST(("(fontlist-singleface) family name: %s, key: %s\n",
-                      NS_ConvertUTF16toUTF8(familyName).get(),
-                      NS_ConvertUTF16toUTF8(key).get()));
+                      familyName.get(),
+                      key.get()));
 
         // add only if doesn't exist already
         if (!mFontFamilies.GetWeak(key)) {
             RefPtr<gfxFontFamily> familyEntry =
                 new gfxSingleFaceMacFontFamily(familyName);
             // We need a separate font entry, because its family name will
             // differ from the one we found in the main list.
             MacOSFontEntry* fontEntry =
                 new MacOSFontEntry(fe->Name(), fe->Weight(), true,
                                    static_cast<const MacOSFontEntry*>(fe)->
                                        mSizeHint);
             familyEntry->AddFontEntry(fontEntry);
             familyEntry->SetHasStyles(true);
             mFontFamilies.Put(key, familyEntry);
             LOG_FONTLIST(("(fontlist-singleface) added new family: %s, key: %s\n",
-                          NS_ConvertUTF16toUTF8(familyName).get(),
-                          NS_ConvertUTF16toUTF8(key).get()));
+                          familyName.get(),
+                          key.get()));
         }
     }
 }
 
 // System fonts under OSX may contain weird "meta" names but if we create
 // a new font using just the Postscript name, the NSFont api returns an object
 // with the actual real family name. For example, under OSX 10.11:
 //
@@ -1342,24 +1346,24 @@ gfxMacPlatformFontList::InitSystemFontNa
         mUseSizeSensitiveSystemFont = true;
     }
 
     // text font family
     NSFont* sys = [NSFont systemFontOfSize: 0.0];
     NSString* textFamilyName = GetRealFamilyName(sys);
     nsAutoString familyName;
     nsCocoaUtils::GetStringForNSString(textFamilyName, familyName);
-    mSystemTextFontFamilyName = familyName;
+    CopyUTF16toUTF8(familyName, mSystemTextFontFamilyName);
 
     // display font family, if on OSX 10.11
     if (mUseSizeSensitiveSystemFont) {
         NSFont* displaySys = [NSFont systemFontOfSize: 128.0];
         NSString* displayFamilyName = GetRealFamilyName(displaySys);
         nsCocoaUtils::GetStringForNSString(displayFamilyName, familyName);
-        mSystemDisplayFontFamilyName = familyName;
+        CopyUTF16toUTF8(familyName, mSystemDisplayFontFamilyName);
 
 #if DEBUG
         // confirm that the optical size switch is at 20.0
         NS_ASSERTION([textFamilyName compare:displayFamilyName] != NSOrderedSame,
                      "system text/display fonts are the same!");
         NSString* fam19 = GetRealFamilyName([NSFont systemFontOfSize:
                                              (kTextDisplayCrossover - 1.0)]);
         NSString* fam20 = GetRealFamilyName([NSFont systemFontOfSize:
@@ -1379,19 +1383,19 @@ gfxMacPlatformFontList::InitSystemFontNa
         [sysFamily compare:GetRealFamilyName([NSFont toolTipsFontOfSize:0.0])] != NSOrderedSame) {
         NS_WARNING("system font types map to different font families"
                    " -- please log a bug!!");
     }
 #endif
 }
 
 gfxFontFamily*
-gfxMacPlatformFontList::FindSystemFontFamily(const nsAString& aFamily)
+gfxMacPlatformFontList::FindSystemFontFamily(const nsACString& aFamily)
 {
-    nsAutoString key;
+    nsAutoCString key;
     GenerateFontListKey(aFamily, key);
 
     gfxFontFamily* familyEntry;
 
     // lookup in hidden system family name list
     if ((familyEntry = mSystemFontFamilies.GetWeak(key))) {
         return CheckFamily(familyEntry);
     }
@@ -1400,17 +1404,18 @@ gfxMacPlatformFontList::FindSystemFontFa
     if ((familyEntry = mFontFamilies.GetWeak(key))) {
         return CheckFamily(familyEntry);
     }
 
     return nullptr;
 }
 
 bool
-gfxMacPlatformFontList::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
+gfxMacPlatformFontList::GetStandardFamilyName(const nsCString& aFontName,
+                                              nsACString& aFamilyName)
 {
     gfxFontFamily *family = FindFamily(aFontName);
     if (family) {
         family->LocalizedName(aFamilyName);
         return true;
     }
 
     return false;
@@ -1488,17 +1493,18 @@ gfxMacPlatformFontList::PlatformGlobalFo
                               kCFCompareCaseInsensitive) != kCFCompareEqualTo)
         {
             AutoTArray<UniChar, 1024> buffer;
             CFIndex familyNameLen = ::CFStringGetLength(familyNameRef);
             buffer.SetLength(familyNameLen+1);
             ::CFStringGetCharacters(familyNameRef, ::CFRangeMake(0, familyNameLen),
                                     buffer.Elements());
             buffer[familyNameLen] = 0;
-            nsDependentString familyNameString(reinterpret_cast<char16_t*>(buffer.Elements()), familyNameLen);
+            NS_ConvertUTF16toUTF8 familyNameString(
+                reinterpret_cast<char16_t*>(buffer.Elements()), familyNameLen);
 
             gfxFontFamily *family = FindSystemFontFamily(familyNameString);
             if (family) {
                 fontEntry = family->FindFontForStyle(*aMatchStyle);
                 if (fontEntry) {
                     if (fontEntry->HasCharacter(aCh)) {
                         *aMatchedFamily = family;
                     } else {
@@ -1527,38 +1533,38 @@ gfxFontFamily*
 gfxMacPlatformFontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle)
 {
     nsAutoreleasePool localPool;
 
     NSString *defaultFamily = [[NSFont userFontOfSize:aStyle->size] familyName];
     nsAutoString familyName;
 
     GetStringForNSString(defaultFamily, familyName);
-    return FindFamily(familyName);
+    return FindFamily(NS_ConvertUTF16toUTF8(familyName));
 }
 
 int32_t
 gfxMacPlatformFontList::AppleWeightToCSSWeight(int32_t aAppleWeight)
 {
     if (aAppleWeight < 1)
         aAppleWeight = 1;
     else if (aAppleWeight > kAppleMaxWeight)
         aAppleWeight = kAppleMaxWeight;
     return gAppleWeightToCSSWeight[aAppleWeight];
 }
 
 gfxFontEntry*
-gfxMacPlatformFontList::LookupLocalFont(const nsAString& aFontName,
+gfxMacPlatformFontList::LookupLocalFont(const nsACString& aFontName,
                                         WeightRange aWeightForEntry,
                                         StretchRange aStretchForEntry,
                                         SlantStyleRange aStyleForEntry)
 {
     nsAutoreleasePool localPool;
 
-    NSString *faceName = GetNSStringForString(aFontName);
+    NSString *faceName = GetNSStringForString(NS_ConvertUTF8toUTF16(aFontName));
     MacOSFontEntry *newFontEntry;
 
     // lookup face based on postscript or full name
     CGFontRef fontRef = ::CGFontCreateWithFontName(CFStringRef(faceName));
     if (!fontRef) {
         return nullptr;
     }
 
@@ -1572,17 +1578,17 @@ gfxMacPlatformFontList::LookupLocalFont(
 }
 
 static void ReleaseData(void *info, const void *data, size_t size)
 {
     free((void*)data);
 }
 
 gfxFontEntry*
-gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
+gfxMacPlatformFontList::MakePlatformFont(const nsACString& aFontName,
                                          WeightRange aWeightForEntry,
                                          StretchRange aStretchForEntry,
                                          SlantStyleRange aStyleForEntry,
                                          const uint8_t* aFontData,
                                          uint32_t aLength)
 {
     NS_ASSERTION(aFontData, "MakePlatformFont called with null data");
 
@@ -1600,17 +1606,17 @@ gfxMacPlatformFontList::MakePlatformFont
     CGFontRef fontRef = ::CGFontCreateWithDataProvider(provider);
     ::CGDataProviderRelease(provider);
 
     if (!fontRef) {
         return nullptr;
     }
 
     auto newFontEntry =
-        MakeUnique<MacOSFontEntry>(uniqueName, fontRef, aWeightForEntry,
+        MakeUnique<MacOSFontEntry>(NS_ConvertUTF16toUTF8(uniqueName), fontRef, aWeightForEntry,
                                    aStretchForEntry, aStyleForEntry,
                                    true, false);
     ::CFRelease(fontRef);
 
     // if succeeded and font cmap is good, return the new font
     if (NS_SUCCEEDED(newFontEntry->ReadCMAP())) {
         return newFontEntry.release();
     }
@@ -1624,17 +1630,17 @@ gfxMacPlatformFontList::MakePlatformFont
     return nullptr;
 }
 
 // Webkit code uses a system font meta name, so mimic that here
 // WebCore/platform/graphics/mac/FontCacheMac.mm
 static const char kSystemFont_system[] = "-apple-system";
 
 bool
-gfxMacPlatformFontList::FindAndAddFamilies(const nsAString& aFamily,
+gfxMacPlatformFontList::FindAndAddFamilies(const nsACString& aFamily,
                                            nsTArray<FamilyAndGeneric>* aOutput,
                                            FindFamiliesFlags aFlags,
                                            gfxFontStyle* aStyle,
                                            gfxFloat aDevToCssSize)
 {
     // search for special system font name, -apple-system
     if (aFamily.EqualsLiteral(kSystemFont_system)) {
         if (mUseSizeSensitiveSystemFont &&
@@ -1650,17 +1656,17 @@ gfxMacPlatformFontList::FindAndAddFamili
                                                    aOutput,
                                                    aFlags,
                                                    aStyle,
                                                    aDevToCssSize);
 }
 
 void
 gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
-                                         nsAString& aSystemFontName,
+                                         nsACString& aSystemFontName,
                                          gfxFontStyle &aFontStyle,
                                          float aDevPixPerCSSPixel)
 {
     // code moved here from widget/cocoa/nsLookAndFeel.mm
     NSFont *font = nullptr;
     char* systemFontName = nullptr;
     switch (aSystemFontID) {
         case LookAndFeel::eFont_MessageBox:
@@ -1737,40 +1743,40 @@ public:
     virtual ~MacFontInfo() {}
 
     virtual void Load() {
         nsAutoreleasePool localPool;
         FontInfoData::Load();
     }
 
     // loads font data for all members of a given family
-    virtual void LoadFontFamilyData(const nsAString& aFamilyName);
+    virtual void LoadFontFamilyData(const nsACString& aFamilyName);
 };
 
 void
-MacFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
+MacFontInfo::LoadFontFamilyData(const nsACString& aFamilyName)
 {
     // family name ==> CTFontDescriptor
-    NSString *famName = GetNSStringForString(aFamilyName);
+    NSString *famName = GetNSStringForString(NS_ConvertUTF8toUTF16(aFamilyName));
     CFStringRef family = CFStringRef(famName);
 
     CFMutableDictionaryRef attr =
         CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
                                   &kCFTypeDictionaryValueCallBacks);
     CFDictionaryAddValue(attr, kCTFontFamilyNameAttribute, family);
     CTFontDescriptorRef fd = CTFontDescriptorCreateWithAttributes(attr);
     CFRelease(attr);
     CFArrayRef matchingFonts =
         CTFontDescriptorCreateMatchingFontDescriptors(fd, NULL);
     CFRelease(fd);
     if (!matchingFonts) {
         return;
     }
 
-    nsTArray<nsString> otherFamilyNames;
+    nsTArray<nsCString> otherFamilyNames;
     bool hasOtherFamilyNames = true;
 
     // iterate over faces in the family
     int f, numFaces = (int) CFArrayGetCount(matchingFonts);
     for (f = 0; f < numFaces; f++) {
         mLoadStats.fonts++;
 
         CTFontDescriptorRef faceDesc =
@@ -1791,18 +1797,18 @@ MacFontInfo::LoadFontFamilyData(const ns
                 CTFontDescriptorCopyAttribute(faceDesc, kCTFontNameAttribute);
 
             AutoTArray<UniChar, 1024> buffer;
             CFIndex len = CFStringGetLength(faceName);
             buffer.SetLength(len+1);
             CFStringGetCharacters(faceName, ::CFRangeMake(0, len),
                                     buffer.Elements());
             buffer[len] = 0;
-            nsAutoString fontName(reinterpret_cast<char16_t*>(buffer.Elements()),
-                                  len);
+            NS_ConvertUTF16toUTF8 fontName(
+                reinterpret_cast<char16_t*>(buffer.Elements()), len);
 
             // load the cmap data
             FontFaceData fontData;
             CFDataRef cmapTable = CTFontCopyTable(fontRef, kCTFontTableCmap,
                                                   kCTFontTableOptionNoOptions);
 
             if (cmapTable) {
                 const uint8_t *cmapData =
@@ -1859,17 +1865,17 @@ gfxMacPlatformFontList::CreateFontInfoDa
         gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback();
 
     RefPtr<MacFontInfo> fi =
         new MacFontInfo(true, NeedFullnamePostscriptNames(), loadCmaps);
     return fi.forget();
 }
 
 gfxFontFamily*
-gfxMacPlatformFontList::CreateFontFamily(const nsAString& aName) const
+gfxMacPlatformFontList::CreateFontFamily(const nsACString& aName) const
 {
     return new gfxMacFontFamily(aName, 0.0);
 }
 
 void
 gfxMacPlatformFontList::ActivateFontsFromDir(nsIFile* aDir)
 {
     bool isDir;
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1640,32 +1640,31 @@ gfxPlatform::GetFontList(nsAtom *aLangGr
 
 nsresult
 gfxPlatform::UpdateFontList()
 {
     gfxPlatformFontList::PlatformFontList()->UpdateFontList();
     return NS_OK;
 }
 
-nsresult
-gfxPlatform::GetStandardFamilyName(const nsAString& aFontName,
-                                   nsAString& aFamilyName)
+void
+gfxPlatform::GetStandardFamilyName(const nsCString& aFontName,
+                                   nsACString& aFamilyName)
 {
     gfxPlatformFontList::PlatformFontList()->GetStandardFamilyName(aFontName,
                                                                    aFamilyName);
-    return NS_OK;
 }
 
-nsAutoString
+nsAutoCString
 gfxPlatform::GetDefaultFontName(const nsACString& aLangGroup,
                                 const nsACString& aGenericFamily)
 {
     // To benefit from Return Value Optimization, all paths here must return
     // this one variable:
-    nsAutoString result;
+    nsAutoCString result;
 
     gfxFontFamily* fontFamily = gfxPlatformFontList::PlatformFontList()->
         GetDefaultFontFamily(aLangGroup, aGenericFamily);
     if (fontFamily) {
       fontFamily->LocalizedName(result);
     } // (else, leave 'result' empty)
 
     return result;
@@ -1760,28 +1759,28 @@ gfxPlatform::IsFontFormatSupported(uint3
         return false;
     }
 
     // no format hint set, need to look at data
     return true;
 }
 
 gfxFontEntry*
-gfxPlatform::LookupLocalFont(const nsAString& aFontName,
+gfxPlatform::LookupLocalFont(const nsACString& aFontName,
                              WeightRange aWeightForEntry,
                              StretchRange aStretchForEntry,
                              SlantStyleRange aStyleForEntry)
 {
     return gfxPlatformFontList::PlatformFontList()->
         LookupLocalFont(aFontName, aWeightForEntry, aStretchForEntry,
                         aStyleForEntry);
 }
 
 gfxFontEntry*
-gfxPlatform::MakePlatformFont(const nsAString& aFontName,
+gfxPlatform::MakePlatformFont(const nsACString& aFontName,
                               WeightRange aWeightForEntry,
                               StretchRange aStretchForEntry,
                               SlantStyleRange aStyleForEntry,
                               const uint8_t* aFontData,
                               uint32_t aLength)
 {
     return gfxPlatformFontList::PlatformFontList()->
         MakePlatformFont(aFontName, aWeightForEntry, aStretchForEntry,
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -363,27 +363,27 @@ public:
                                "gfxPlatformFontList implementation");
         return nullptr;
     }
 
     /**
      * Resolving a font name to family name. The result MUST be in the result of GetFontList().
      * If the name doesn't in the system, aFamilyName will be empty string, but not failed.
      */
-    virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
+    void GetStandardFamilyName(const nsCString& aFontName, nsACString& aFamilyName);
 
     /**
      * Returns default font name (localized family name) for aLangGroup and
      * aGenericFamily.  The result is typically the first font in
      * font.name-list.<aGenericFamily>.<aLangGroup>.  However, if it's not
      * available in the system, this may return second or later font in the
      * pref.  If there are no available fonts in the pref, returns empty string.
      */
-    nsAutoString GetDefaultFontName(const nsACString& aLangGroup,
-                                    const nsACString& aGenericFamily);
+    nsAutoCString GetDefaultFontName(const nsACString& aLangGroup,
+                                     const nsACString& aGenericFamily);
 
     /**
      * Create the appropriate platform font group
      */
     virtual gfxFontGroup*
     CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
                     const gfxFontStyle *aStyle,
                     gfxTextPerfMetrics* aTextPerf,
@@ -391,30 +391,30 @@ public:
                     gfxFloat aDevToCssSize) = 0;
 
     /**
      * Look up a local platform font using the full font face name.
      * (Needed to support @font-face src local().)
      * Ownership of the returned gfxFontEntry is passed to the caller,
      * who must either AddRef() or delete.
      */
-    gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
+    gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
                                   WeightRange aWeightForEntry,
                                   StretchRange aStretchForEntry,
                                   SlantStyleRange aStyleForEntry);
 
     /**
      * Activate a platform font.  (Needed to support @font-face src url().)
      * aFontData is a NS_Malloc'ed block that must be freed by this function
      * (or responsibility passed on) when it is no longer needed; the caller
      * will NOT free it.
      * Ownership of the returned gfxFontEntry is passed to the caller,
      * who must either AddRef() or delete.
      */
-    gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
+    gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
                                    WeightRange aWeightForEntry,
                                    StretchRange aStretchForEntry,
                                    SlantStyleRange aStyleForEntry,
                                    const uint8_t* aFontData,
                                    uint32_t aLength);
 
     /**
      * Whether to allow downloadable fonts via @font-face rules
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -277,41 +277,41 @@ gfxPlatformFontList::ApplyWhitelist()
 {
     nsTArray<nsString> list;
     gfxFontUtils::GetPrefsFontList(kFontSystemWhitelistPref, list);
     uint32_t numFonts = list.Length();
     mFontFamilyWhitelistActive = (numFonts > 0);
     if (!mFontFamilyWhitelistActive) {
         return;
     }
-    nsTHashtable<nsStringHashKey> familyNamesWhitelist;
+    nsTHashtable<nsCStringHashKey> familyNamesWhitelist;
     for (uint32_t i = 0; i < numFonts; i++) {
-        nsString key;
-        ToLowerCase(list[i], key);
+        nsAutoCString key;
+        ToLowerCase(NS_ConvertUTF16toUTF8(list[i]), key);
         familyNamesWhitelist.PutEntry(key);
     }
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
         // Don't continue if we only have one font left.
         if (mFontFamilies.Count() == 1) {
             break;
         }
-        nsString fontFamilyName(iter.Key());
+        nsAutoCString fontFamilyName(iter.Key());
         ToLowerCase(fontFamilyName);
         if (!familyNamesWhitelist.Contains(fontFamilyName)) {
             iter.Remove();
         }
     }
 }
 
 bool
-gfxPlatformFontList::AddWithLegacyFamilyName(const nsAString& aLegacyName,
+gfxPlatformFontList::AddWithLegacyFamilyName(const nsACString& aLegacyName,
                                              gfxFontEntry* aFontEntry)
 {
     bool added = false;
-    nsAutoString key;
+    nsAutoCString key;
     ToLowerCase(aLegacyName, key);
     gfxFontFamily* family = mOtherFamilyNames.GetWeak(key);
     if (!family) {
         family = CreateFontFamily(aLegacyName);
         family->SetHasStyles(true); // we don't want the family to search for
                                     // faces, we're adding them directly here
         mOtherFamilyNames.Put(key, family);
         added = true;
@@ -371,16 +371,23 @@ gfxPlatformFontList::InitFontList()
 
 void
 gfxPlatformFontList::GenerateFontListKey(const nsAString& aKeyName, nsAString& aResult)
 {
     aResult = aKeyName;
     ToLowerCase(aResult);
 }
 
+void
+gfxPlatformFontList::GenerateFontListKey(const nsACString& aKeyName, nsACString& aResult)
+{
+    aResult = aKeyName;
+    ToLowerCase(aResult);
+}
+
 #define OTHERNAMES_TIMEOUT 200
 
 void
 gfxPlatformFontList::InitOtherFamilyNames(bool aDeferOtherFamilyNamesLoading)
 {
     if (mOtherFamilyNamesInitialized) {
         return;
     }
@@ -402,30 +409,30 @@ gfxPlatformFontList::InitOtherFamilyName
         InitOtherFamilyNamesInternal(false);
     }
 }
 
 // time limit for loading facename lists (ms)
 #define NAMELIST_TIMEOUT  200
 
 gfxFontEntry*
-gfxPlatformFontList::SearchFamiliesForFaceName(const nsAString& aFaceName)
+gfxPlatformFontList::SearchFamiliesForFaceName(const nsACString& aFaceName)
 {
     TimeStamp start = TimeStamp::Now();
     bool timedOut = false;
     // if mFirstChar is not 0, only load facenames for families
     // that start with this character
     char16_t firstChar = 0;
     gfxFontEntry *lookup = nullptr;
 
     // iterate over familes starting with the same letter
     firstChar = ToLowerCase(aFaceName.CharAt(0));
 
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
-        nsStringHashKey::KeyType key = iter.Key();
+        nsCStringHashKey::KeyType key = iter.Key();
         RefPtr<gfxFontFamily>& family = iter.Data();
 
         // when filtering, skip names that don't start with the filter character
         if (firstChar && ToLowerCase(key.CharAt(0)) != firstChar) {
             continue;
         }
 
         family->ReadFaceNames(this, NeedFullnamePostscriptNames());
@@ -449,32 +456,32 @@ gfxPlatformFontList::SearchFamiliesForFa
                       (lookup ? "found name" : ""),
                       (timedOut ? "timeout" : "")));
     }
 
     return lookup;
 }
 
 gfxFontEntry*
-gfxPlatformFontList::FindFaceName(const nsAString& aFaceName)
+gfxPlatformFontList::FindFaceName(const nsACString& aFaceName)
 {
     gfxFontEntry *lookup;
 
     // lookup in name lookup tables, return null if not found
     if (mExtraNames &&
         ((lookup = mExtraNames->mPostscriptNames.GetWeak(aFaceName)) ||
          (lookup = mExtraNames->mFullnames.GetWeak(aFaceName)))) {
         return lookup;
     }
 
     return nullptr;
 }
 
 gfxFontEntry*
-gfxPlatformFontList::LookupInFaceNameLists(const nsAString& aFaceName)
+gfxPlatformFontList::LookupInFaceNameLists(const nsACString& aFaceName)
 {
     gfxFontEntry *lookup = nullptr;
 
     // initialize facename lookup tables if needed
     // note: this can terminate early or time out, in which case
     //       mFaceNameListsInitialized remains false
     if (!mFaceNameListsInitialized) {
         lookup = SearchFamiliesForFaceName(aFaceName);
@@ -483,35 +490,35 @@ gfxPlatformFontList::LookupInFaceNameLis
         }
     }
 
     // lookup in name lookup tables, return null if not found
     if (!(lookup = FindFaceName(aFaceName))) {
         // names not completely initialized, so keep track of lookup misses
         if (!mFaceNameListsInitialized) {
             if (!mFaceNamesMissed) {
-                mFaceNamesMissed = MakeUnique<nsTHashtable<nsStringHashKey>>(2);
+                mFaceNamesMissed = MakeUnique<nsTHashtable<nsCStringHashKey>>(2);
             }
             mFaceNamesMissed->PutEntry(aFaceName);
         }
     }
 
     return lookup;
 }
 
 void
 gfxPlatformFontList::PreloadNamesList()
 {
     AutoTArray<nsString, 10> preloadFonts;
     gfxFontUtils::GetPrefsFontList("font.preload-names-list", preloadFonts);
 
     uint32_t numFonts = preloadFonts.Length();
     for (uint32_t i = 0; i < numFonts; i++) {
-        nsAutoString key;
-        GenerateFontListKey(preloadFonts[i], key);
+        nsAutoCString key;
+        GenerateFontListKey(NS_ConvertUTF16toUTF8(preloadFonts[i]), key);
 
         // only search canonical names!
         gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key);
         if (familyEntry) {
             familyEntry->ReadOtherFamilyNames(this);
         }
     }
 
@@ -519,18 +526,18 @@ gfxPlatformFontList::PreloadNamesList()
 
 void
 gfxPlatformFontList::LoadBadUnderlineList()
 {
     AutoTArray<nsString, 10> blacklist;
     gfxFontUtils::GetPrefsFontList("font.blacklist.underline_offset", blacklist);
     uint32_t numFonts = blacklist.Length();
     for (uint32_t i = 0; i < numFonts; i++) {
-        nsAutoString key;
-        GenerateFontListKey(blacklist[i], key);
+        nsAutoCString key;
+        GenerateFontListKey(NS_ConvertUTF16toUTF8(blacklist[i]), key);
         mBadUnderlineFamilyNames.PutEntry(key);
     }
 }
 
 void
 gfxPlatformFontList::UpdateFontList()
 {
     InitFontList();
@@ -541,19 +548,19 @@ void
 gfxPlatformFontList::GetFontList(nsAtom *aLangGroup,
                                  const nsACString& aGenericFamily,
                                  nsTArray<nsString>& aListOfFonts)
 {
     MutexAutoLock lock(mFontFamiliesMutex);
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
         RefPtr<gfxFontFamily>& family = iter.Data();
         if (family->FilterForFontList(aLangGroup, aGenericFamily)) {
-            nsAutoString localizedFamilyName;
+            nsAutoCString localizedFamilyName;
             family->LocalizedName(localizedFamilyName);
-            aListOfFonts.AppendElement(localizedFamilyName);
+            aListOfFonts.AppendElement(NS_ConvertUTF8toUTF16(localizedFamilyName));
         }
     }
 
     aListOfFonts.Sort();
     aListOfFonts.Compact();
 }
 
 void
@@ -615,17 +622,17 @@ gfxPlatformFontList::SystemFindFontForCh
         uint32_t unicodeRange = FindCharUnicodeRange(aCh);
         Script script = mozilla::unicode::GetScriptCode(aCh);
         MOZ_LOG(log, LogLevel::Warning,\
                ("(textrun-systemfallback-%s) char: u+%6.6x "
                  "unicode-range: %d script: %d match: [%s]"
                 " time: %dus cmaps: %d\n",
                 (common ? "common" : "global"), aCh,
                 unicodeRange, static_cast<int>(script),
-                (fontEntry ? NS_ConvertUTF16toUTF8(fontEntry->Name()).get() :
+                (fontEntry ? fontEntry->Name().get() :
                     "<none>"),
                 int32_t(elapsed.ToMicroseconds()),
                 cmapCount));
     }
 
     // no match? add to set of non-matching codepoints
     if (!fontEntry) {
         mCodepointsWithNoFonts.set(aCh);
@@ -661,20 +668,17 @@ gfxPlatformFontList::CommonFontFallback(
     AutoTArray<const char*,NUM_FALLBACK_FONTS> defaultFallbacks;
     uint32_t i, numFallbacks;
 
     gfxPlatform::GetPlatform()->GetCommonFallbackFonts(aCh, aNextCh,
                                                        aRunScript,
                                                        defaultFallbacks);
     numFallbacks = defaultFallbacks.Length();
     for (i = 0; i < numFallbacks; i++) {
-        nsAutoString familyName;
-        const char *fallbackFamily = defaultFallbacks[i];
-
-        familyName.AppendASCII(fallbackFamily);
+        nsAutoCString familyName(defaultFallbacks[i]);
         gfxFontFamily *fallback = FindFamilyByCanonicalName(familyName);
         if (!fallback) {
             continue;
         }
 
         gfxFontEntry *fontEntry;
 
         // use first font in list that supports a given character
@@ -743,33 +747,33 @@ gfxPlatformFontList::CheckFamily(gfxFont
 {
     if (aFamily && !aFamily->HasStyles()) {
         aFamily->FindStyleVariations();
         aFamily->CheckForSimpleFamily();
     }
 
     if (aFamily && aFamily->GetFontList().Length() == 0) {
         // failed to load any faces for this family, so discard it
-        nsAutoString key;
+        nsAutoCString key;
         GenerateFontListKey(aFamily->Name(), key);
         mFontFamilies.Remove(key);
         return nullptr;
     }
 
     return aFamily;
 }
 
 bool
-gfxPlatformFontList::FindAndAddFamilies(const nsAString& aFamily,
+gfxPlatformFontList::FindAndAddFamilies(const nsACString& aFamily,
                                         nsTArray<FamilyAndGeneric>* aOutput,
                                         FindFamiliesFlags aFlags,
                                         gfxFontStyle* aStyle,
                                         gfxFloat aDevToCssSize)
 {
-    nsAutoString key;
+    nsAutoCString key;
     GenerateFontListKey(aFamily, key);
 
     NS_ASSERTION(mFontFamilies.Count() != 0, "system font list was not initialized correctly");
 
     // lookup in canonical (i.e. English) family name list
     gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key);
 
     // if not found, lookup in other family names list (mostly localized names)
@@ -785,32 +789,32 @@ gfxPlatformFontList::FindAndAddFamilies(
     if (!familyEntry && !mOtherFamilyNamesInitialized && !IsASCII(aFamily)) {
         InitOtherFamilyNames(!(aFlags & FindFamiliesFlags::eForceOtherFamilyNamesLoading));
         familyEntry = mOtherFamilyNames.GetWeak(key);
         if (!familyEntry && !mOtherFamilyNamesInitialized &&
             !(aFlags & FindFamiliesFlags::eNoAddToNamesMissedWhenSearching)) {
             // localized family names load timed out, add name to list of
             // names to check after localized names are loaded
             if (!mOtherNamesMissed) {
-                mOtherNamesMissed = MakeUnique<nsTHashtable<nsStringHashKey>>(2);
+                mOtherNamesMissed = MakeUnique<nsTHashtable<nsCStringHashKey>>(2);
             }
             mOtherNamesMissed->PutEntry(key);
         }
     }
 
     familyEntry = CheckFamily(familyEntry);
 
     // If we failed to find the requested family, check for a space in the
     // name; if found, and if the "base" name (up to the last space) exists
     // as a family, then this might be a legacy GDI-style family name for
     // an additional weight/width. Try searching the faces of the base family
     // and create any corresponding legacy families.
     if (!familyEntry && !(aFlags & FindFamiliesFlags::eNoSearchForLegacyFamilyNames)) {
         // We don't have nsAString::RFindChar, so look for a space manually
-        const char16_t* data = aFamily.BeginReading();
+        const char* data = aFamily.BeginReading();
         int32_t index = aFamily.Length();
         while (--index > 0) {
             if (data[index] == ' ') {
                 break;
             }
         }
         if (index > 0) {
             gfxFontFamily* base =
@@ -829,75 +833,77 @@ gfxPlatformFontList::FindAndAddFamilies(
         aOutput->AppendElement(FamilyAndGeneric(familyEntry));
         return true;
     }
 
     return false;
 }
 
 gfxFontEntry*
-gfxPlatformFontList::FindFontForFamily(const nsAString& aFamily,
+gfxPlatformFontList::FindFontForFamily(const nsACString& aFamily,
                                        const gfxFontStyle* aStyle)
 {
     gfxFontFamily *familyEntry = FindFamily(aFamily);
 
     if (familyEntry)
         return familyEntry->FindFontForStyle(*aStyle);
 
     return nullptr;
 }
 
 void 
-gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName)
+gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsCString& aOtherFamilyName)
 {
-    nsAutoString key;
+    nsAutoCString key;
     GenerateFontListKey(aOtherFamilyName, key);
 
     if (!mOtherFamilyNames.GetWeak(key)) {
         mOtherFamilyNames.Put(key, aFamilyEntry);
         LOG_FONTLIST(("(fontlist-otherfamily) canonical family: %s, "
                       "other family: %s\n",
-                      NS_ConvertUTF16toUTF8(aFamilyEntry->Name()).get(),
-                      NS_ConvertUTF16toUTF8(aOtherFamilyName).get()));
+                      aFamilyEntry->Name().get(),
+                      aOtherFamilyName.get()));
         if (mBadUnderlineFamilyNames.Contains(key))
             aFamilyEntry->SetBadUnderlineFamily();
     }
 }
 
 void
-gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname)
+gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, const nsCString& aFullname)
 {
     if (!mExtraNames->mFullnames.GetWeak(aFullname)) {
         mExtraNames->mFullnames.Put(aFullname, aFontEntry);
         LOG_FONTLIST(("(fontlist-fullname) name: %s, fullname: %s\n",
-                      NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
-                      NS_ConvertUTF16toUTF8(aFullname).get()));
+                      aFontEntry->Name().get(),
+                      aFullname.get()));
     }
 }
 
 void
-gfxPlatformFontList::AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName)
+gfxPlatformFontList::AddPostscriptName(gfxFontEntry *aFontEntry,
+                                       const nsCString& aPostscriptName)
 {
     if (!mExtraNames->mPostscriptNames.GetWeak(aPostscriptName)) {
         mExtraNames->mPostscriptNames.Put(aPostscriptName, aFontEntry);
         LOG_FONTLIST(("(fontlist-postscript) name: %s, psname: %s\n",
-                      NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
-                      NS_ConvertUTF16toUTF8(aPostscriptName).get()));
+                      aFontEntry->Name().get(),
+                      aPostscriptName.get()));
     }
 }
 
 bool
-gfxPlatformFontList::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
+gfxPlatformFontList::GetStandardFamilyName(const nsCString& aFontName,
+                                           nsACString& aFamilyName)
 {
     aFamilyName.Truncate();
     gfxFontFamily *ff = FindFamily(aFontName);
     if (!ff) {
         return false;
     }
-    aFamilyName.Assign(ff->Name());
+    aFamilyName = ff->Name();
     return true;
 }
 
 gfxFontFamily*
 gfxPlatformFontList::GetDefaultFontFamily(const nsACString& aLangGroup,
                                           const nsACString& aGenericFamily)
 {
     if (NS_WARN_IF(aLangGroup.IsEmpty()) ||
@@ -905,17 +911,17 @@ gfxPlatformFontList::GetDefaultFontFamil
         return nullptr;
     }
 
     AutoTArray<nsString,4> names;
     gfxFontUtils::AppendPrefsFontList(
         NameListPref(aGenericFamily, aLangGroup).get(), names);
 
     for (nsString& name : names) {
-        gfxFontFamily* fontFamily = FindFamily(name);
+        gfxFontFamily* fontFamily = FindFamily(NS_ConvertUTF16toUTF8(name));
         if (fontFamily) {
             return fontFamily;
         }
     }
     return nullptr;
 }
 
 gfxCharacterMap*
@@ -1015,17 +1021,18 @@ gfxPlatformFontList::GetFontFamiliesFrom
     nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies)
 {
     // lookup and add platform fonts uniquely
     for (const nsString& genericFamily : aGenericNameFamilies) {
         gfxFontStyle style;
         style.language = aLangGroup;
         style.systemFont = false;
         AutoTArray<FamilyAndGeneric,10> families;
-        FindAndAddFamilies(genericFamily, &families, FindFamiliesFlags(0),
+        FindAndAddFamilies(NS_ConvertUTF16toUTF8(genericFamily),
+                           &families, FindFamiliesFlags(0),
                            &style);
         for (const FamilyAndGeneric& f : families) {
             if (!aGenericFamilies->Contains(f.mFamily)) {
                 aGenericFamilies->AppendElement(f.mFamily);
             }
         }
     }
 }
@@ -1393,17 +1400,17 @@ gfxPlatformFontList::GetDefaultFont(cons
     // Something has gone wrong and we were unable to retrieve a default font
     // from the platform. (Likely the whitelist has blocked all potential
     // default fonts.) As a last resort, we return the first font listed in
     // mFontFamilies.
     return mFontFamilies.Iter().Data();
 }
 
 void
-gfxPlatformFontList::GetFontFamilyNames(nsTArray<nsString>& aFontFamilyNames)
+gfxPlatformFontList::GetFontFamilyNames(nsTArray<nsCString>& aFontFamilyNames)
 {
     for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
         RefPtr<gfxFontFamily>& family = iter.Data();
         aFontFamilyNames.AppendElement(family->Name());
     }
 }
 
 nsAtom*
@@ -1475,17 +1482,17 @@ gfxPlatformFontList::LoadFontInfo()
 {
     TimeStamp start = TimeStamp::Now();
     uint32_t i, endIndex = mNumFamilies;
     bool loadCmaps = !UsesSystemFallback() ||
         gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback();
 
     // for each font family, load in various font info
     for (i = mStartIndex; i < endIndex; i++) {
-        nsAutoString key;
+        nsAutoCString key;
         gfxFontFamily *familyEntry;
         GenerateFontListKey(mFontInfo->mFontFamiliesToLoad[i], key);
 
         // lookup in canonical (i.e. English) family name list
         if (!(familyEntry = mFontFamilies.GetWeak(key))) {
             continue;
         }
 
--- a/gfx/thebes/gfxPlatformFontList.h
+++ b/gfx/thebes/gfxPlatformFontList.h
@@ -160,73 +160,73 @@ public:
         // If set, FindAndAddFamilies will not add a missing entry to mOtherNamesMissed
         eNoAddToNamesMissedWhenSearching = 1 << 2
     };
 
     // Find family(ies) matching aFamily and append to the aOutput array
     // (there may be multiple results in the case of fontconfig aliases, etc).
     // Return true if any match was found and appended, false if none.
     virtual bool
-    FindAndAddFamilies(const nsAString& aFamily,
+    FindAndAddFamilies(const nsACString& aFamily,
                        nsTArray<FamilyAndGeneric>* aOutput,
                        FindFamiliesFlags aFlags,
                        gfxFontStyle* aStyle = nullptr,
                        gfxFloat aDevToCssSize = 1.0);
 
-    gfxFontEntry* FindFontForFamily(const nsAString& aFamily,
+    gfxFontEntry* FindFontForFamily(const nsACString& aFamily,
                                     const gfxFontStyle* aStyle);
 
     // name lookup table methods
 
-    void AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName);
+    void AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsCString& aOtherFamilyName);
 
-    void AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname);
+    void AddFullname(gfxFontEntry *aFontEntry, const nsCString& aFullname);
 
-    void AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName);
+    void AddPostscriptName(gfxFontEntry *aFontEntry, const nsCString& aPostscriptName);
 
     bool NeedFullnamePostscriptNames() { return mExtraNames != nullptr; }
 
     // pure virtual functions, to be provided by concrete subclasses
 
     // get the system default font family
     gfxFontFamily* GetDefaultFont(const gfxFontStyle* aStyle);
 
     /**
      * Look up a font by name on the host platform.
      *
      * Note that the style attributes (weight, stretch, style) are NOT used in
      * selecting the platform font, which is looked up by name only; these are
      * values to be recorded in the new font entry.
      */
-    virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
+    virtual gfxFontEntry* LookupLocalFont(const nsACString& aFontName,
                                           WeightRange aWeightForEntry,
                                           StretchRange aStretchForEntry,
                                           SlantStyleRange aStyleForEntry) = 0;
 
     /**
      * Create a new platform font from downloaded data (@font-face).
      *
      * Note that the style attributes (weight, stretch, style) are NOT related
      * (necessarily) to any values within the font resource itself; these are
      * values to be recorded in the new font entry and used for face selection,
      * in place of whatever inherent style attributes the resource may have.
      *
      * This method takes ownership of the data block passed in as aFontData,
      * and must ensure it is free()'d when no longer required.
      */
-    virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
+    virtual gfxFontEntry* MakePlatformFont(const nsACString& aFontName,
                                            WeightRange aWeightForEntry,
                                            StretchRange aStretchForEntry,
                                            SlantStyleRange aStyleForEntry,
                                            const uint8_t* aFontData,
                                            uint32_t aLength) = 0;
 
     // get the standard family name on the platform for a given font name
     // (platforms may override, eg Mac)
-    virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
+    virtual bool GetStandardFamilyName(const nsCString& aFontName, nsACString& aFamilyName);
 
     // get the default font name which is available on the system from
     // font.name-list.*.  if there are no available fonts in the pref,
     // returns nullptr.
     gfxFontFamily* GetDefaultFontFamily(const nsACString& aLangGroup,
                                         const nsACString& aGenericFamily);
 
     virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
@@ -297,17 +297,17 @@ public:
     mozilla::FontFamilyType
     GetDefaultGeneric(eFontPrefLang aLang);
 
     // Returns true if the font family whitelist is not empty.
     bool IsFontFamilyWhitelistActive();
 
     static void FontWhitelistPrefChanged(const char *aPref, void *aClosure);
 
-    bool AddWithLegacyFamilyName(const nsAString& aLegacyName,
+    bool AddWithLegacyFamilyName(const nsACString& aLegacyName,
                                  gfxFontEntry* aFontEntry);
 
     static const char* GetGenericName(mozilla::FontFamilyType aGenericType);
 
 protected:
     class InitOtherFamilyNamesRunnable : public mozilla::CancelableRunnable
     {
     public:
@@ -398,34 +398,34 @@ protected:
 
     explicit gfxPlatformFontList(bool aNeedFullnamePostscriptNames = true);
 
     static gfxPlatformFontList *sPlatformFontList;
 
     // Convenience method to return the first matching family (if any) as found
     // by FindAndAddFamilies().
     gfxFontFamily*
-    FindFamily(const nsAString& aFamily,
+    FindFamily(const nsACString& aFamily,
                FindFamiliesFlags aFlags = FindFamiliesFlags(0),
                gfxFontStyle* aStyle = nullptr,
                gfxFloat aDevToCssSize = 1.0)
     {
         AutoTArray<FamilyAndGeneric,1> families;
         return FindAndAddFamilies(aFamily,
                                   &families,
                                   aFlags,
                                   aStyle,
                                   aDevToCssSize)
                ? families[0].mFamily : nullptr;
     }
 
     // Lookup family name in global family list without substitutions or
     // localized family name lookup. Used for common font fallback families.
-    gfxFontFamily* FindFamilyByCanonicalName(const nsAString& aFamily) {
-        nsAutoString key;
+    gfxFontFamily* FindFamilyByCanonicalName(const nsACString& aFamily) {
+        nsAutoCString key;
         gfxFontFamily *familyEntry;
         GenerateFontListKey(aFamily, key);
         if ((familyEntry = mFontFamilies.GetWeak(key))) {
             return CheckFamily(familyEntry);
         }
         return nullptr;
     }
 
@@ -467,34 +467,35 @@ protected:
     // initialize localized family names
     void InitOtherFamilyNames(bool aDeferOtherFamilyNamesLoading);
     void InitOtherFamilyNamesInternal(bool aDeferOtherFamilyNamesLoading);
     void CancelInitOtherFamilyNamesTask();
 
     // search through font families, looking for a given name, initializing
     // facename lists along the way. first checks all families with names
     // close to face name, then searchs all families if not found.
-    gfxFontEntry* SearchFamiliesForFaceName(const nsAString& aFaceName);
+    gfxFontEntry* SearchFamiliesForFaceName(const nsACString& aFaceName);
 
     // helper method for finding fullname/postscript names in facename lists
-    gfxFontEntry* FindFaceName(const nsAString& aFaceName);
+    gfxFontEntry* FindFaceName(const nsACString& aFaceName);
 
     // look up a font by name, for cases where platform font list
     // maintains explicit mappings of fullname/psname ==> font
-    virtual gfxFontEntry* LookupInFaceNameLists(const nsAString& aFontName);
+    virtual gfxFontEntry* LookupInFaceNameLists(const nsACString& aFontName);
 
     // commonly used fonts for which the name table should be loaded at startup
     virtual void PreloadNamesList();
 
     // load the bad underline blacklist from pref.
     void LoadBadUnderlineList();
 
     void GenerateFontListKey(const nsAString& aKeyName, nsAString& aResult);
+    void GenerateFontListKey(const nsACString& aKeyName, nsACString& aResult);
 
-    virtual void GetFontFamilyNames(nsTArray<nsString>& aFontFamilyNames);
+    virtual void GetFontFamilyNames(nsTArray<nsCString>& aFontFamilyNames);
 
     // helper function to map lang to lang group
     nsAtom* GetLangGroup(nsAtom* aLanguage);
 
     // gfxFontInfoLoader overrides, used to load in font cmaps
     virtual void InitLoader() override;
     virtual bool LoadFontInfo() override;
     virtual void CleanupLoader() override;
@@ -524,20 +525,20 @@ protected:
         nsTArray<RefPtr<gfxFontFamily>>* aFontFamilies);
 
     virtual nsresult InitFontListForPlatform() = 0;
 
     void ApplyWhitelist();
 
     // Create a new gfxFontFamily of the appropriate subclass for the platform,
     // used when AddWithLegacyFamilyName needs to create a new family.
-    virtual gfxFontFamily* CreateFontFamily(const nsAString& aName) const = 0;
+    virtual gfxFontFamily* CreateFontFamily(const nsACString& aName) const = 0;
 
-    typedef nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> FontFamilyTable;
-    typedef nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> FontEntryTable;
+    typedef nsRefPtrHashtable<nsCStringHashKey, gfxFontFamily> FontFamilyTable;
+    typedef nsRefPtrHashtable<nsCStringHashKey, gfxFontEntry> FontEntryTable;
 
     // used by memory reporter to accumulate sizes of family names in the table
     static size_t
     SizeOfFontFamilyTableExcludingThis(const FontFamilyTable& aTable,
                                        mozilla::MallocSizeOf aMallocSizeOf);
     static size_t
     SizeOfFontEntryTableExcludingThis(const FontEntryTable& aTable,
                                       mozilla::MallocSizeOf aMallocSizeOf);
@@ -571,20 +572,20 @@ protected:
       // fullname ==> font entry (unique, one name per font entry)
       FontEntryTable mFullnames;
       // Postscript name ==> font entry (unique, one name per font entry)
       FontEntryTable mPostscriptNames;
     };
     mozilla::UniquePtr<ExtraNames> mExtraNames;
 
     // face names missed when face name loading takes a long time
-    mozilla::UniquePtr<nsTHashtable<nsStringHashKey> > mFaceNamesMissed;
+    mozilla::UniquePtr<nsTHashtable<nsCStringHashKey> > mFaceNamesMissed;
 
     // localized family names missed when face name loading takes a long time
-    mozilla::UniquePtr<nsTHashtable<nsStringHashKey> > mOtherNamesMissed;
+    mozilla::UniquePtr<nsTHashtable<nsCStringHashKey> > mOtherNamesMissed;
 
     typedef nsTArray<RefPtr<gfxFontFamily>> PrefFontList;
     typedef mozilla::RangedArray<mozilla::UniquePtr<PrefFontList>,
                                  mozilla::eFamily_generic_first,
                                  mozilla::eFamily_generic_count> PrefFontsForLangGroup;
     mozilla::RangedArray<PrefFontsForLangGroup,
                          eFontPrefLang_First,
                          eFontPrefLang_Count> mLangGroupPrefFonts;
@@ -592,17 +593,17 @@ protected:
 
     // when system-wide font lookup fails for a character, cache it to skip future searches
     gfxSparseBitSet mCodepointsWithNoFonts;
 
     // the family to use for U+FFFD fallback, to avoid expensive search every time
     // on pages with lots of problems
     RefPtr<gfxFontFamily> mReplacementCharFallbackFamily;
 
-    nsTHashtable<nsStringHashKey> mBadUnderlineFamilyNames;
+    nsTHashtable<nsCStringHashKey> mBadUnderlineFamilyNames;
 
     // character map data shared across families
     // contains weak ptrs to cmaps shared by font entry objects
     nsTHashtable<CharMapHashKey> mSharedCmaps;
 
     // data used as part of the font cmap loading process
     nsTArray<RefPtr<gfxFontFamily> > mFontFamiliesToLoad;
     uint32_t mStartIndex;
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -259,24 +259,16 @@ gfxPlatformGtk::CreatePlatformFontList()
     gfxPlatformFontList* list = new gfxFcPlatformFontList();
     if (NS_SUCCEEDED(list->InitFontList())) {
         return list;
     }
     gfxPlatformFontList::Shutdown();
     return nullptr;
 }
 
-nsresult
-gfxPlatformGtk::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
-{
-    gfxPlatformFontList::PlatformFontList()->
-        GetStandardFamilyName(aFontName, aFamilyName);
-    return NS_OK;
-}
-
 gfxFontGroup *
 gfxPlatformGtk::CreateFontGroup(const FontFamilyList& aFontFamilyList,
                                 const gfxFontStyle* aStyle,
                                 gfxTextPerfMetrics* aTextPerf,
                                 gfxUserFontSet* aUserFontSet,
                                 gfxFloat aDevToCssSize)
 {
     return new gfxFontGroup(aFontFamilyList, aStyle, aTextPerf,
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -46,19 +46,16 @@ public:
 
     virtual void
     GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
                            Script aRunScript,
                            nsTArray<const char*>& aFontList) override;
 
     virtual gfxPlatformFontList* CreatePlatformFontList() override;
 
-    virtual nsresult GetStandardFamilyName(const nsAString& aFontName,
-                                           nsAString& aFamilyName) override;
-
     gfxFontGroup*
     CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
                     const gfxFontStyle *aStyle,
                     gfxTextPerfMetrics* aTextPerf,
                     gfxUserFontSet *aUserFontSet,
                     gfxFloat aDevToCssSize) override;
 
     /**
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -346,17 +346,17 @@ gfxPlatformMac::GetCommonFallbackFonts(u
     }
 
     // Arial Unicode MS has lots of glyphs for obscure, use it as a last resort
     aFontList.AppendElement(kFontArialUnicodeMS);
 }
 
 /*static*/ void
 gfxPlatformMac::LookupSystemFont(mozilla::LookAndFeel::FontID aSystemFontID,
-                                 nsAString& aSystemFontName,
+                                 nsACString& aSystemFontName,
                                  gfxFontStyle& aFontStyle,
                                  float aDevPixPerCSSPixel)
 {
     gfxMacPlatformFontList* pfl = gfxMacPlatformFontList::PlatformFontList();
     return pfl->LookupSystemFont(aSystemFontID, aSystemFontName, aFontStyle,
                                  aDevPixPerCSSPixel);
 }
 
--- a/gfx/thebes/gfxPlatformMac.h
+++ b/gfx/thebes/gfxPlatformMac.h
@@ -51,17 +51,17 @@ public:
     virtual void GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
                                         Script aRunScript,
                                         nsTArray<const char*>& aFontList) override;
 
     // lookup the system font for a particular system font type and set
     // the name and style characteristics
     static void
     LookupSystemFont(mozilla::LookAndFeel::FontID aSystemFontID,
-                     nsAString& aSystemFontName,
+                     nsACString& aSystemFontName,
                      gfxFontStyle &aFontStyle,
                      float aDevPixPerCSSPixel);
 
     virtual bool SupportsApzWheelInput() const override {
       return true;
     }
 
     bool RespectsFontStyleSmoothing() const override {
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -1772,23 +1772,22 @@ gfxTextRun::Dump(FILE* aOutput) {
     uint32_t numGlyphRuns;
     const GlyphRun* glyphRuns = GetGlyphRuns(&numGlyphRuns);
     for (uint32_t i = 0; i < numGlyphRuns; ++i) {
         if (i > 0) {
             fputc(',', aOutput);
         }
         gfxFont* font = glyphRuns[i].mFont;
         const gfxFontStyle* style = font->GetStyle();
-        NS_ConvertUTF16toUTF8 fontName(font->GetName());
         nsAutoString styleString;
         nsStyleUtil::AppendFontSlantStyle(style->style, styleString);
         nsAutoCString lang;
         style->language->ToUTF8String(lang);
         fprintf(aOutput, "%d: %s %f/%g/%s/%s", glyphRuns[i].mCharacterOffset,
-                fontName.get(), style->size,
+                font->GetName().get(), style->size,
                 style->weight.ToFloat(),
                 NS_ConvertUTF16toUTF8(styleString).get(),
                 lang.get());
     }
     fputc(']', aOutput);
 }
 #endif
 
@@ -1826,17 +1825,17 @@ gfxFontGroup::BuildFontList()
 {
     // initialize fonts in the font family list
     AutoTArray<FamilyAndGeneric,10> fonts;
     gfxPlatformFontList *pfl = gfxPlatformFontList::PlatformFontList();
 
     // lookup fonts in the fontlist
     for (const FontFamilyName& name : mFamilyList.GetFontlist()->mNames) {
         if (name.IsNamed()) {
-            AddPlatformFont(name.mName, fonts);
+            AddPlatformFont(NS_ConvertUTF16toUTF8(name.mName), fonts);
         } else {
             pfl->AddGenericFonts(name.mType, mStyle.language, fonts);
             if (mTextPerf) {
                 mTextPerf->current.genericLookups++;
             }
         }
     }
 
@@ -1852,17 +1851,17 @@ gfxFontGroup::BuildFontList()
 
     // build the fontlist from the specified families
     for (const auto& f : fonts) {
         AddFamilyToFontList(f.mFamily, f.mGeneric);
     }
 }
 
 void
-gfxFontGroup::AddPlatformFont(const nsAString& aName,
+gfxFontGroup::AddPlatformFont(const nsACString& aName,
                               nsTArray<FamilyAndGeneric>& aFamilyList)
 {
     // First, look up in the user font set...
     // If the fontSet matches the family, we must not look for a platform
     // font of the same name, even if we fail to actually get a fontEntry
     // here; we'll fall back to the next name in the CSS font-family list.
     if (mUserFontSet) {
         // Add userfonts to the fontlist whether already loaded
@@ -3299,17 +3298,17 @@ void gfxFontGroup::ComputeRanges(nsTArra
             if (r.matchType & gfxTextRange::MatchType::kPrefsFallback) {
                 if (!matchTypes.IsEmpty()) {
                     matchTypes.AppendLiteral(",");
                 }
                 matchTypes.AppendLiteral("sys");
             }
             fontMatches.AppendPrintf(" [%u:%u] %.200s (%s)", r.start, r.end,
                 (r.font.get() ?
-                 NS_ConvertUTF16toUTF8(r.font->GetName()).get() : "<null>"),
+                 r.font->GetName().get() : "<null>"),
                 matchTypes.get());
         }
         MOZ_LOG(log, LogLevel::Debug,\
                ("(%s-fontmatching) fontgroup: [%s] default: %s lang: %s script: %d"
                 "%s\n",
                 (mStyle.systemFont ? "textrunui" : "textrun"),
                 NS_ConvertUTF16toUTF8(families).get(),
                 (mFamilyList.GetDefaultFontType() == eFamily_serif ?
--- a/gfx/thebes/gfxTextRun.h
+++ b/gfx/thebes/gfxTextRun.h
@@ -1270,17 +1270,17 @@ protected:
     // search all faces in a family for a fallback in cases where it's unclear
     // whether the family might have a font for a given character
     gfxFont*
     FindFallbackFaceForChar(gfxFontFamily* aFamily, uint32_t aCh);
 
    // helper methods for looking up fonts
 
     // lookup and add a font with a given name (i.e. *not* a generic!)
-    void AddPlatformFont(const nsAString& aName,
+    void AddPlatformFont(const nsACString& aName,
                          nsTArray<FamilyAndGeneric>& aFamilyList);
 
     // do style selection and add entries to list
     void AddFamilyToFontList(gfxFontFamily* aFamily,
                              mozilla::FontFamilyType aGeneric);
 };
 
 // A "missing font recorder" is to be used during text-run creation to keep
--- a/gfx/thebes/gfxUserFontSet.cpp
+++ b/gfx/thebes/gfxUserFontSet.cpp
@@ -109,17 +109,17 @@ gfxUserFontEntry::gfxUserFontEntry(gfxUs
              StretchRange aStretch,
              SlantStyleRange aStyle,
              const nsTArray<gfxFontFeature>& aFeatureSettings,
              const nsTArray<gfxFontVariation>& aVariationSettings,
              uint32_t aLanguageOverride,
              gfxCharacterMap* aUnicodeRanges,
              uint8_t aFontDisplay,
              RangeFlags aRangeFlags)
-    : gfxFontEntry(NS_LITERAL_STRING("userfont")),
+    : gfxFontEntry(NS_LITERAL_CSTRING("userfont")),
       mUserFontLoadState(STATUS_NOT_LOADED),
       mFontDataLoadingState(NOT_LOADING),
       mUnsupportedFormat(false),
       mFontDisplay(aFontDisplay),
       mLoader(nullptr),
       mFontSet(aFontSet)
 {
     mIsUserFontContainer = true;
@@ -281,17 +281,17 @@ gfxUserFontEntry::SanitizeOpenTypeData(c
 
     aSaneLength = output.Tell();
     return static_cast<const uint8_t*>(output.forget());
 }
 
 void
 gfxUserFontEntry::StoreUserFontData(gfxFontEntry* aFontEntry,
                                     bool aPrivate,
-                                    const nsAString& aOriginalName,
+                                    const nsACString& aOriginalName,
                                     FallibleTArray<uint8_t>* aMetadata,
                                     uint32_t aMetaOrigLen,
                                     uint8_t aCompression)
 {
     if (!aFontEntry->mUserFontData) {
         aFontEntry->mUserFontData = MakeUnique<gfxUserFontData>();
     }
     gfxUserFontData* userFontData = aFontEntry->mUserFontData.get();
@@ -345,17 +345,17 @@ gfxFontFaceSrc::LoadPrincipal(const gfxU
   }
   return aFontSet.GetStandardFontLoadPrincipal();
 }
 
 void
 gfxUserFontEntry::GetFamilyNameAndURIForLogging(nsACString& aFamilyName,
                                                 nsACString& aURI)
 {
-  aFamilyName.Assign(NS_ConvertUTF16toUTF8(mFamilyName));
+  aFamilyName = mFamilyName;
 
   aURI.Truncate();
   if (mSrcIndex == mSrcList.Length()) {
     aURI.AppendLiteral("(end of source list)");
   } else {
     if (mSrcList[mSrcIndex].mURI) {
       mSrcList[mSrcIndex].mURI->GetSpec(aURI);
       // If the source URI was very long, elide the middle of it.
@@ -526,39 +526,39 @@ gfxUserFontEntry::DoLoadNextSrc(bool aFo
             for (gfxUserFontSet* fontSet : fontSets) {
                 // We need to note on each gfxUserFontSet that contains the user
                 // font entry that we used a local() rule.
                 fontSet->SetLocalRulesUsed();
             }
             if (fe) {
                 LOG(("userfonts (%p) [src %d] loaded local: (%s) for (%s) gen: %8.8x\n",
                      mFontSet, mSrcIndex,
-                     NS_ConvertUTF16toUTF8(currSrc.mLocalName).get(),
-                     NS_ConvertUTF16toUTF8(mFamilyName).get(),
+                     currSrc.mLocalName.get(),
+                     mFamilyName.get(),
                      uint32_t(mFontSet->mGeneration)));
                 fe->mFeatureSettings.AppendElements(mFeatureSettings);
                 fe->mVariationSettings.AppendElements(mVariationSettings);
                 fe->mLanguageOverride = mLanguageOverride;
                 fe->mFamilyName = mFamilyName;
                 fe->mRangeFlags = mRangeFlags;
                 // For src:local(), we don't care whether the request is from
                 // a private window as there's no issue of caching resources;
                 // local fonts are just available all the time.
-                StoreUserFontData(fe, false, nsString(), nullptr, 0,
+                StoreUserFontData(fe, false, nsCString(), nullptr, 0,
                                   gfxUserFontData::kUnknownCompression);
                 mPlatformFontEntry = fe;
                 SetLoadState(STATUS_LOADED);
                 Telemetry::Accumulate(Telemetry::WEBFONT_SRCTYPE,
                                       currSrc.mSourceType + 1);
                 return;
             } else {
                 LOG(("userfonts (%p) [src %d] failed local: (%s) for (%s)\n",
                      mFontSet, mSrcIndex,
-                     NS_ConvertUTF16toUTF8(currSrc.mLocalName).get(),
-                     NS_ConvertUTF16toUTF8(mFamilyName).get()));
+                     currSrc.mLocalName.get(),
+                     mFamilyName.get()));
             }
         }
 
         // src url ==> start the load process
         else if (currSrc.mSourceType == gfxFontFaceSrc::eSourceType_URL) {
             if (gfxPlatform::GetPlatform()->IsFontFormatSupported(
                     currSrc.mFormatFlags)) {
 
@@ -581,17 +581,17 @@ gfxUserFontEntry::DoLoadNextSrc(bool aFo
                 if (fe) {
                     mPlatformFontEntry = fe;
                     SetLoadState(STATUS_LOADED);
                     if (LOG_ENABLED()) {
                         LOG(("userfonts (%p) [src %d] "
                              "loaded uri from cache: (%s) for (%s)\n",
                              mFontSet, mSrcIndex,
                              currSrc.mURI->GetSpecOrDefault().get(),
-                             NS_ConvertUTF16toUTF8(mFamilyName).get()));
+                             mFamilyName.get()));
                     }
                     return;
                 }
 
                 if (ServoStyleSet* set = ServoStyleSet::Current()) {
                     // If we need to start a font load and we're on a style
                     // worker thread, we have to defer it.
                     set->AppendTask(PostTraversalTask::LoadFontEntry(this));
@@ -632,17 +632,17 @@ gfxUserFontEntry::DoLoadNextSrc(bool aFo
                     nsresult rv = mFontSet->StartLoad(this, &currSrc);
                     bool loadOK = NS_SUCCEEDED(rv);
 
                     if (loadOK) {
                         if (LOG_ENABLED()) {
                             LOG(("userfonts (%p) [src %d] loading uri: (%s) for (%s)\n",
                                  mFontSet, mSrcIndex,
                                  currSrc.mURI->GetSpecOrDefault().get(),
-                                 NS_ConvertUTF16toUTF8(mFamilyName).get()));
+                                 mFamilyName.get()));
                         }
                         return;
                     } else {
                         mFontSet->LogMessage(this,
                                              "download failed",
                                              nsIScriptError::errorFlag,
                                              rv);
                     }
@@ -683,17 +683,17 @@ gfxUserFontEntry::DoLoadNextSrc(bool aFo
 
     if (mUnsupportedFormat) {
         mFontSet->LogMessage(this, "no supported format found",
                              nsIScriptError::warningFlag);
     }
 
     // all src's failed; mark this entry as unusable (so fallback will occur)
     LOG(("userfonts (%p) failed all src for (%s)\n",
-        mFontSet, NS_ConvertUTF16toUTF8(mFamilyName).get()));
+        mFontSet, mFamilyName.get()));
     mFontDataLoadingState = LOADING_FAILED;
     SetLoadState(STATUS_FAILED);
 }
 
 void
 gfxUserFontEntry::SetLoadState(UserFontLoadState aLoadState)
 {
     mUserFontLoadState = aLoadState;
@@ -718,17 +718,17 @@ gfxUserFontEntry::LoadPlatformFont(const
     Telemetry::Accumulate(Telemetry::WEBFONT_FONTTYPE, uint32_t(fontType));
 
     // Unwrap/decompress/sanitize or otherwise munge the downloaded data
     // to make a usable sfnt structure.
 
     // Because platform font activation code may replace the name table
     // in the font with a synthetic one, we save the original name so that
     // it can be reported via the InspectorUtils API.
-    nsAutoString originalFullName;
+    nsAutoCString originalFullName;
 
     // Call the OTS sanitizer; this will also decode WOFF to sfnt
     // if necessary. The original data in aFontData is left unchanged.
     uint32_t saneLen;
     uint32_t fontCompressionRatio = 0;
     size_t computedSize = 0;
     const uint8_t* saneData =
         SanitizeOpenTypeData(aFontData, aLength, saneLen, fontType);
@@ -813,29 +813,29 @@ gfxUserFontEntry::LoadPlatformFont(const
         fe->mRangeFlags = mRangeFlags;
         StoreUserFontData(fe, mFontSet->GetPrivateBrowsing(), originalFullName,
                           &metadata, metaOrigLen, compression);
         if (LOG_ENABLED()) {
             LOG(("userfonts (%p) [src %d] loaded uri: (%s) for (%s) "
                  "(%p) gen: %8.8x compress: %d%%\n",
                  mFontSet, mSrcIndex,
                  mSrcList[mSrcIndex].mURI->GetSpecOrDefault().get(),
-                 NS_ConvertUTF16toUTF8(mFamilyName).get(),
+                 mFamilyName.get(),
                  this, uint32_t(mFontSet->mGeneration), fontCompressionRatio));
         }
         mPlatformFontEntry = fe;
         SetLoadState(STATUS_LOADED);
         gfxUserFontSet::UserFontCache::CacheFont(fe);
     } else {
         if (LOG_ENABLED()) {
             LOG(("userfonts (%p) [src %d] failed uri: (%s) for (%s)"
                  " error making platform font\n",
                  mFontSet, mSrcIndex,
                  mSrcList[mSrcIndex].mURI->GetSpecOrDefault().get(),
-                 NS_ConvertUTF16toUTF8(mFamilyName).get()));
+                 mFamilyName.get()));
         }
     }
 
     // The downloaded data can now be discarded; the font entry is using the
     // sanitized copy
     free((void*)aFontData);
 
     return fe != nullptr;
@@ -939,17 +939,17 @@ gfxUserFontSet::~gfxUserFontSet()
     gfxPlatformFontList* fp = gfxPlatformFontList::PlatformFontList();
     if (fp) {
         fp->RemoveUserFontSet(this);
     }
 }
 
 already_AddRefed<gfxUserFontEntry>
 gfxUserFontSet::FindOrCreateUserFontEntry(
-                               const nsAString& aFamilyName,
+                               const nsACString& aFamilyName,
                                const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
                                WeightRange aWeight,
                                StretchRange aStretch,
                                SlantStyleRange aStyle,
                                const nsTArray<gfxFontFeature>& aFeatureSettings,
                                const nsTArray<gfxFontVariation>& aVariationSettings,
                                uint32_t aLanguageOverride,
                                gfxCharacterMap* aUnicodeRanges,
@@ -1019,30 +1019,30 @@ gfxUserFontSet::FindExistingUserFontEntr
 
         return existingUserFontEntry;
     }
 
     return nullptr;
 }
 
 void
-gfxUserFontSet::AddUserFontEntry(const nsAString& aFamilyName,
+gfxUserFontSet::AddUserFontEntry(const nsCString& aFamilyName,
                                  gfxUserFontEntry* aUserFontEntry)
 {
     gfxUserFontFamily* family = GetFamily(aFamilyName);
     family->AddFontEntry(aUserFontEntry);
 
     if (LOG_ENABLED()) {
         nsAutoCString weightString;
         aUserFontEntry->Weight().ToString(weightString);
         nsAutoCString stretchString;
         aUserFontEntry->Stretch().ToString(stretchString);
         LOG(("userfonts (%p) added to \"%s\" (%p) style: %s weight: %s "
              "stretch: %s display: %d",
-             this, NS_ConvertUTF16toUTF8(aFamilyName).get(), aUserFontEntry,
+             this, aFamilyName.get(), aUserFontEntry,
              (aUserFontEntry->IsItalic() ? "italic" :
               (aUserFontEntry->IsOblique() ? "oblique" : "normal")),
              weightString.get(),
              stretchString.get(),
              aUserFontEntry->GetFontDisplay()));
     }
 }
 
@@ -1064,43 +1064,43 @@ gfxUserFontSet::RebuildLocalRules()
 {
     if (mLocalRulesUsed) {
         mRebuildLocalRules = true;
         DoRebuildUserFontSet();
     }
 }
 
 gfxUserFontFamily*
-gfxUserFontSet::LookupFamily(const nsAString& aFamilyName) const
+gfxUserFontSet::LookupFamily(const nsACString& aFamilyName) const
 {
-    nsAutoString key(aFamilyName);
+    nsAutoCString key(aFamilyName);
     ToLowerCase(key);
 
     return mFontFamilies.GetWeak(key);
 }
 
 bool
 gfxUserFontSet::ContainsUserFontSetFonts(const FontFamilyList& aFontList) const
 {
     for (const FontFamilyName& name : aFontList.GetFontlist()->mNames) {
         if (name.mType != eFamily_named &&
             name.mType != eFamily_named_quoted) {
             continue;
         }
-        if (LookupFamily(name.mName)) {
+        if (LookupFamily(NS_ConvertUTF16toUTF8(name.mName))) {
             return true;
         }
     }
     return false;
 }
 
 gfxUserFontFamily*
-gfxUserFontSet::GetFamily(const nsAString& aFamilyName)
+gfxUserFontSet::GetFamily(const nsACString& aFamilyName)
 {
-    nsAutoString key(aFamilyName);
+    nsAutoCString key(aFamilyName);
     ToLowerCase(key);
 
     gfxUserFontFamily* family = mFontFamilies.GetWeak(key);
     if (!family) {
         family = new gfxUserFontFamily(aFamilyName);
         mFontFamilies.Put(key, family);
     }
     return family;
@@ -1323,18 +1323,17 @@ gfxUserFontSet::UserFontCache::Entry::Re
     nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize)
 {
     MOZ_ASSERT(mFontEntry);
     nsAutoCString path("explicit/gfx/user-fonts/font(");
 
     if (aAnonymize) {
         path.AppendPrintf("<anonymized-%p>", this);
     } else {
-        NS_ConvertUTF16toUTF8 familyName(mFontEntry->mFamilyName);
-        path.AppendPrintf("family=%s", familyName.get());
+        path.AppendPrintf("family=%s", mFontEntry->mFamilyName.get());
         if (mURI) {
             nsCString spec = mURI->GetSpecOrDefault();
             spec.ReplaceChar('/', '\\');
             // Some fonts are loaded using horrendously-long data: URIs;
             // truncate those before reporting them.
             bool isData;
             if (NS_SUCCEEDED(mURI->get()->SchemeIs("data", &isData)) && isData &&
                 spec.Length() > 255) {
@@ -1418,17 +1417,17 @@ gfxUserFontSet::UserFontCache::Entry::Du
     }
 
     NS_ASSERTION(mURI, "null URI in userfont cache entry");
 
     printf("userfontcache fontEntry: %p fonturihash: %8.8x "
            "family: %s domainset: %s principal: [%s]\n",
            mFontEntry,
            mURI->Hash(),
-           NS_ConvertUTF16toUTF8(mFontEntry->FamilyName()).get(),
+           mFontEntry->FamilyName().get(),
            setDomain ? "true" : "false",
            principalURISpec.get());
 }
 
 void
 gfxUserFontSet::UserFontCache::Dump()
 {
     if (!sUserFonts) {
--- a/gfx/thebes/gfxUserFontSet.h
+++ b/gfx/thebes/gfxUserFontSet.h
@@ -52,17 +52,17 @@ struct gfxFontFaceSrc {
     // if url, whether to use the origin principal or not
     bool                   mUseOriginPrincipal;
 
     // format hint flags, union of all possible formats
     // (e.g. TrueType, EOT, SVG, etc.)
     // see FLAG_FORMAT_* enum values below
     uint32_t               mFormatFlags;
 
-    nsString               mLocalName;     // full font name if local
+    nsCString              mLocalName;     // full font name if local
     RefPtr<gfxFontSrcURI>  mURI;           // uri if url
     nsCOMPtr<nsIURI>       mReferrer;      // referrer url if url
     mozilla::net::ReferrerPolicy mReferrerPolicy;
     RefPtr<gfxFontSrcPrincipal> mOriginPrincipal; // principal if url
 
     RefPtr<gfxFontFaceBufferSource> mBuffer;
 
     // The principal that should be used for the load. Should only be used for
@@ -114,18 +114,18 @@ public:
     { }
     virtual ~gfxUserFontData() { }
 
     size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
     nsTArray<uint8_t> mMetadata;  // woff metadata block (compressed), if any
     RefPtr<gfxFontSrcURI>  mURI;       // URI of the source, if it was url()
     RefPtr<gfxFontSrcPrincipal> mPrincipal; // principal for the download, if url()
-    nsString          mLocalName; // font name used for the source, if local()
-    nsString          mRealName;  // original fullname from the font resource
+    nsCString         mLocalName; // font name used for the source, if local()
+    nsCString         mRealName;  // original fullname from the font resource
     uint32_t          mSrcIndex;  // index in the rule's source list
     uint32_t          mFormat;    // format hint for the source used, if any
     uint32_t          mMetaOrigLen; // length needed to decompress metadata
     uint8_t           mCompression; // compression type
     bool              mPrivate;   // whether font belongs to a private window
     bool              mIsBuffer;  // whether the font source was a buffer
 
     enum {
@@ -137,17 +137,17 @@ public:
 
 // initially contains a set of userfont font entry objects, replaced with
 // platform/user fonts as downloaded
 
 class gfxUserFontFamily : public gfxFontFamily {
 public:
     friend class gfxUserFontSet;
 
-    explicit gfxUserFontFamily(const nsAString& aName)
+    explicit gfxUserFontFamily(const nsACString& aName)
         : gfxFontFamily(aName) { }
 
     virtual ~gfxUserFontFamily();
 
     // add the given font entry to the end of the family's list
     void AddFontEntry(gfxFontEntry* aFontEntry) {
         // keep ref while removing existing entry
         RefPtr<gfxFontEntry> fe = aFontEntry;
@@ -156,18 +156,18 @@ public:
         // insert at the beginning so that the last-defined font is the first
         // one in the fontlist used for matching, as per CSS Fonts spec
         mAvailableFonts.InsertElementAt(0, aFontEntry);
 
         if (aFontEntry->mFamilyName.IsEmpty()) {
             aFontEntry->mFamilyName = Name();
         } else {
 #ifdef DEBUG
-            nsString thisName = Name();
-            nsString entryName = aFontEntry->mFamilyName;
+            nsCString thisName = Name();
+            nsCString entryName = aFontEntry->mFamilyName;
             ToLowerCase(thisName);
             ToLowerCase(entryName);
             MOZ_ASSERT(thisName.Equals(entryName));
 #endif
         }
         ResetCharacterMap();
     }
 
@@ -245,41 +245,41 @@ public:
                               uint32_t aLanguageOverride,
                               gfxCharacterMap* aUnicodeRanges,
                               uint8_t aFontDisplay,
                               RangeFlags aRangeFlags) = 0;
 
     // creates a font face for the specified family, or returns an existing
     // matching entry on the family if there is one
     already_AddRefed<gfxUserFontEntry> FindOrCreateUserFontEntry(
-                               const nsAString& aFamilyName,
+                               const nsACString& aFamilyName,
                                const nsTArray<gfxFontFaceSrc>& aFontFaceSrcList,
                                WeightRange aWeight,
                                StretchRange aStretch,
                                SlantStyleRange aStyle,
                                const nsTArray<gfxFontFeature>& aFeatureSettings,
                                const nsTArray<gfxFontVariation>& aVariationSettings,
                                uint32_t aLanguageOverride,
                                gfxCharacterMap* aUnicodeRanges,
                                uint8_t aFontDisplay,
                                RangeFlags aRangeFlags);
 
     // add in a font face for which we have the gfxUserFontEntry already
-    void AddUserFontEntry(const nsAString& aFamilyName,
+    void AddUserFontEntry(const nsCString& aFamilyName,
                           gfxUserFontEntry* aUserFontEntry);
 
     // Whether there is a face with this family name
-    bool HasFamily(const nsAString& aFamilyName) const
+    bool HasFamily(const nsACString& aFamilyName) const
     {
         return LookupFamily(aFamilyName) != nullptr;
     }
 
     // Look up and return the gfxUserFontFamily in mFontFamilies with
     // the given name
-    gfxUserFontFamily* LookupFamily(const nsAString& aName) const;
+    gfxUserFontFamily* LookupFamily(const nsACString& aName) const;
 
     // Look up names in a fontlist and return true if any are in the set
     bool ContainsUserFontSetFonts(const mozilla::FontFamilyList& aFontList) const;
 
     virtual gfxFontSrcPrincipal* GetStandardFontLoadPrincipal() const = 0;
 
     // check whether content policies allow the given URI to load.
     virtual bool IsFontLoadAllowed(const gfxFontFaceSrc&) = 0;
@@ -514,20 +514,20 @@ protected:
                                    const nsTArray<gfxFontVariation>& aVariationSettings,
                                    uint32_t aLanguageOverride,
                                    gfxCharacterMap* aUnicodeRanges,
                                    uint8_t aFontDisplay,
                                    RangeFlags aRangeFlags);
 
     // creates a new gfxUserFontFamily in mFontFamilies, or returns an existing
     // family if there is one
-    gfxUserFontFamily* GetFamily(const nsAString& aFamilyName);
+    gfxUserFontFamily* GetFamily(const nsACString& aFamilyName);
 
     // font families defined by @font-face rules
-    nsRefPtrHashtable<nsStringHashKey, gfxUserFontFamily> mFontFamilies;
+    nsRefPtrHashtable<nsCStringHashKey, gfxUserFontFamily> mFontFamilies;
 
     uint64_t        mGeneration;        // bumped on any font load change
     uint64_t        mRebuildGeneration; // only bumped on rebuilds
 
     // true when local names have been looked up, false otherwise
     bool mLocalRulesUsed;
 
     // true when rules using local names need to be redone
@@ -684,17 +684,17 @@ protected:
     // returns true if platform font creation successful
     // Ownership of aFontData is passed in here; the font must
     // ensure that it is eventually deleted with free().
     bool LoadPlatformFont(const uint8_t* aFontData, uint32_t& aLength);
 
     // store metadata and src details for current src into aFontEntry
     void StoreUserFontData(gfxFontEntry*      aFontEntry,
                            bool               aPrivate,
-                           const nsAString&   aOriginalName,
+                           const nsACString&  aOriginalName,
                            FallibleTArray<uint8_t>* aMetadata,
                            uint32_t           aMetaOrigLen,
                            uint8_t            aCompression);
 
     // Clears and then adds to aResult all of the user font sets that this user
     // font entry has been added to.  This will at least include mFontSet, the
     // owner of this user font entry.
     virtual void GetUserFontSets(nsTArray<gfxUserFontSet*>& aResult);
--- a/layout/inspector/InspectorFontFace.cpp
+++ b/layout/inspector/InspectorFontFace.cpp
@@ -39,26 +39,26 @@ InspectorFontFace::FromSystemFallback()
   return bool(mMatchType & gfxTextRange::MatchType::kSystemFallback);
 }
 
 void
 InspectorFontFace::GetName(nsAString& aName)
 {
   if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
     NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
-    aName = mFontEntry->mUserFontData->mRealName;
+    aName.Append(NS_ConvertUTF8toUTF16(mFontEntry->mUserFontData->mRealName));
   } else {
-    aName = mFontEntry->RealFaceName();
+    aName.Append(NS_ConvertUTF8toUTF16(mFontEntry->RealFaceName()));
   }
 }
 
 void
 InspectorFontFace::GetCSSFamilyName(nsAString& aCSSFamilyName)
 {
-  aCSSFamilyName = mFontEntry->FamilyName();
+  aCSSFamilyName.Append(NS_ConvertUTF8toUTF16(mFontEntry->FamilyName()));
 }
 
 void
 InspectorFontFace::GetCSSGeneric(nsAString& aName)
 {
   auto genericType =
     FontFamilyType(mMatchType & gfxTextRange::MatchType::kGenericMask);
   if (genericType >= FontFamilyType::eFamily_generic_first &&
@@ -124,21 +124,20 @@ InspectorFontFace::GetURI(nsAString& aUR
       AppendUTF8toUTF16(spec, aURI);
     }
   }
 }
 
 void
 InspectorFontFace::GetLocalName(nsAString& aLocalName)
 {
+  aLocalName.Truncate();
   if (mFontEntry->IsLocalUserFont()) {
     NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
-    aLocalName = mFontEntry->mUserFontData->mLocalName;
-  } else {
-    aLocalName.Truncate();
+    aLocalName.Append(NS_ConvertUTF8toUTF16(mFontEntry->mUserFontData->mLocalName));
   }
 }
 
 static void
 AppendToFormat(nsAString& aResult, const char* aFormat)
 {
   if (!aResult.IsEmpty()) {
     aResult.Append(',');
@@ -252,17 +251,17 @@ InspectorFontFace::GetVariationAxes(nsTA
   MOZ_ASSERT(!axes.IsEmpty());
   if (!aResult.SetCapacity(axes.Length(), mozilla::fallible)) {
     aRV.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
   for (auto a : axes) {
     InspectorVariationAxis& axis = *aResult.AppendElement();
     AppendTagAsASCII(axis.mTag, a.mTag);
-    axis.mName = a.mName;
+    axis.mName.Append(NS_ConvertUTF8toUTF16(a.mName));
     axis.mMinValue = a.mMinValue;
     axis.mMaxValue = a.mMaxValue;
     axis.mDefaultValue = a.mDefaultValue;
   }
 }
 
 void
 InspectorFontFace::GetVariationInstances(
@@ -275,17 +274,17 @@ InspectorFontFace::GetVariationInstances
   AutoTArray<gfxFontVariationInstance,16> instances;
   mFontEntry->GetVariationInstances(instances);
   if (!aResult.SetCapacity(instances.Length(), mozilla::fallible)) {
     aRV.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
   for (auto i : instances) {
     InspectorVariationInstance& inst = *aResult.AppendElement();
-    inst.mName = i.mName;
+    inst.mName.Append(NS_ConvertUTF8toUTF16(i.mName));
     // inst.mValues is a webidl sequence<>, which is a fallible array,
     // so we are required to use fallible SetCapacity and AppendElement calls,
     // and check the result. In practice we don't expect failure here; the
     // list of values cannot get huge because of limits in the font format.
     if (!inst.mValues.SetCapacity(i.mValues.Length(), mozilla::fallible)) {
       aRV.Throw(NS_ERROR_OUT_OF_MEMORY);
       return;
     }
--- a/layout/style/FontFace.cpp
+++ b/layout/style/FontFace.cpp
@@ -658,25 +658,25 @@ FontFace::SetUserFontEntry(gfxUserFontEn
       LoadStateToStatus(mUserFontEntry->LoadState());
     if (newStatus > mStatus) {
       SetStatus(newStatus);
     }
   }
 }
 
 bool
-FontFace::GetFamilyName(nsString& aResult)
+FontFace::GetFamilyName(nsCString& aResult)
 {
   nsCSSValue value;
   GetDesc(eCSSFontDesc_Family, value);
 
   if (value.GetUnit() == eCSSUnit_String) {
     nsString familyname;
     value.GetStringValue(familyname);
-    aResult.Append(familyname);
+    AppendUTF16toUTF8(familyname, aResult);
   }
 
   return !aResult.IsEmpty();
 }
 
 void
 FontFace::DisconnectFromRule()
 {
--- a/layout/style/FontFace.h
+++ b/layout/style/FontFace.h
@@ -103,17 +103,17 @@ public:
 
   FontFaceSet* GetPrimaryFontFaceSet() const { return mFontFaceSet; }
 
   /**
    * Gets the family name of the FontFace as a raw string (such as 'Times', as
    * opposed to GetFamily, which returns a CSS-escaped string, such as
    * '"Times"').  Returns whether a valid family name was available.
    */
-  bool GetFamilyName(nsString& aResult);
+  bool GetFamilyName(nsCString& aResult);
 
   /**
    * Returns whether this object is CSS-connected, i.e. reflecting an
    * @font-face rule.
    */
   bool HasRule() const { return mRule; }
 
   /**
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -291,17 +291,17 @@ FontFaceSet::FindMatchingFontFaces(const
   arrays[0] = &mNonRuleFaces;
   arrays[1] = &mRuleFaces;
 
   // Set of FontFaces that we want to return.
   nsTHashtable<nsPtrHashKey<FontFace>> matchingFaces;
 
   for (const FontFamilyName& fontFamilyName : familyList->mNames) {
     RefPtr<gfxFontFamily> family =
-      mUserFontSet->LookupFamily(fontFamilyName.mName);
+      mUserFontSet->LookupFamily(NS_ConvertUTF16toUTF8(fontFamilyName.mName));
 
     if (!family) {
       continue;
     }
 
     AutoTArray<gfxFontEntry*,4> entries;
     family->FindAllFontsForStyle(style, entries);
 
@@ -847,17 +847,17 @@ FontFaceSet::IncrementGeneration(bool aI
   MOZ_ASSERT(mUserFontSet);
   mUserFontSet->IncrementGeneration(aIsRebuild);
 }
 
 void
 FontFaceSet::InsertNonRuleFontFace(FontFace* aFontFace,
                                    bool& aFontSetModified)
 {
-  nsAutoString fontfamily;
+  nsAutoCString fontfamily;
   if (!aFontFace->GetFamilyName(fontfamily)) {
     // If there is no family name, this rule cannot contribute a
     // usable font, so there is no point in processing it further.
     return;
   }
 
   // Just create a new font entry if we haven't got one already.
   if (!aFontFace->GetUserFontEntry()) {
@@ -876,17 +876,17 @@ FontFaceSet::InsertNonRuleFontFace(FontF
   mUserFontSet->AddUserFontEntry(fontfamily, aFontFace->GetUserFontEntry());
 }
 
 void
 FontFaceSet::InsertRuleFontFace(FontFace* aFontFace, SheetType aSheetType,
                                 nsTArray<FontFaceRecord>& aOldRecords,
                                 bool& aFontSetModified)
 {
-  nsAutoString fontfamily;
+  nsAutoCString fontfamily;
   if (!aFontFace->GetFamilyName(fontfamily)) {
     // If there is no family name, this rule cannot contribute a
     // usable font, so there is no point in processing it further.
     return;
   }
 
   bool remove = false;
   size_t removeIndex;
@@ -976,17 +976,17 @@ FontFaceSet::InsertRuleFontFace(FontFace
   // calls, will automatically remove the earlier occurrence of the same
   // userfont entry.
   mUserFontSet->AddUserFontEntry(fontfamily, entry);
 }
 
 /* static */ already_AddRefed<gfxUserFontEntry>
 FontFaceSet::FindOrCreateUserFontEntryFromFontFace(FontFace* aFontFace)
 {
-  nsAutoString fontfamily;
+  nsAutoCString fontfamily;
   if (!aFontFace->GetFamilyName(fontfamily)) {
     // If there is no family name, this rule cannot contribute a
     // usable font, so there is no point in processing it further.
     return nullptr;
   }
 
   return FindOrCreateUserFontEntryFromFontFace(fontfamily, aFontFace,
                                                SheetType::Doc);
@@ -1082,17 +1082,17 @@ GetStretchRangeForDescriptor(const nsCSS
   if (aVal.GetUnit() == eCSSUnit_Pair) {
     return StretchRange(GetStretchForDescriptor(aVal.GetPairValue().mXValue),
                        GetStretchForDescriptor(aVal.GetPairValue().mYValue));
   }
   return StretchRange(GetStretchForDescriptor(aVal));
 }
 
 /* static */ already_AddRefed<gfxUserFontEntry>
-FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
+FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsACString& aFamilyName,
                                                    FontFace* aFontFace,
                                                    SheetType aSheetType)
 {
   FontFaceSet* set = aFontFace->GetPrimaryFontFaceSet();
 
   nsCSSValue val;
   nsCSSUnit unit;
 
@@ -1190,23 +1190,26 @@ FontFaceSet::FindOrCreateUserFontEntryFr
         val = srcArr->Item(i);
         unit = val.GetUnit();
         gfxFontFaceSrc* face = srcArray.AppendElements(1);
         if (!face)
           return nullptr;
 
         switch (unit) {
 
-        case eCSSUnit_Local_Font:
-          val.GetStringValue(face->mLocalName);
+        case eCSSUnit_Local_Font: {
+          nsAutoString localName;
+          val.GetStringValue(localName);
+          face->mLocalName.Append(NS_ConvertUTF16toUTF8(localName));
           face->mSourceType = gfxFontFaceSrc::eSourceType_Local;
           face->mURI = nullptr;
           face->mFormatFlags = 0;
           face->mReferrerPolicy = mozilla::net::RP_Unset;
           break;
+        }
         case eCSSUnit_URL: {
           face->mSourceType = gfxFontFaceSrc::eSourceType_URL;
           nsIURI* uri = val.GetURLValue();
           face->mURI = uri ? new gfxFontSrcURI(uri) : nullptr;
           URLValue* url = val.GetURLStructValue();
           face->mReferrer = url->mExtraData->GetReferrer();
           face->mReferrerPolicy = set->mDocument->GetReferrerPolicy();
           face->mOriginPrincipal =
--- a/layout/style/FontFaceSet.h
+++ b/layout/style/FontFaceSet.h
@@ -265,17 +265,17 @@ private:
 
     // When true, indicates that when finished loading, the FontFace should be
     // included in the subsequent loadingdone/loadingerror event fired at the
     // FontFaceSet.
     bool mLoadEventShouldFire;
   };
 
   static already_AddRefed<gfxUserFontEntry> FindOrCreateUserFontEntryFromFontFace(
-                                                   const nsAString& aFamilyName,
+                                                   const nsACString& aFamilyName,
                                                    FontFace* aFontFace,
                                                    SheetType aSheetType);
 
   // search for @font-face rule that matches a userfont font entry
   RawServoFontFaceRule* FindRuleForUserFontEntry(gfxUserFontEntry* aUserFontEntry);
 
   nsresult StartLoad(gfxUserFontEntry* aUserFontEntry,
                      const gfxFontFaceSrc* aFontFaceSrc);
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1226,17 +1226,17 @@ Gecko_ConstructFontFeatureValueSet()
 nsTArray<unsigned int>*
 Gecko_AppendFeatureValueHashEntry(gfxFontFeatureValueSet* aFontFeatureValues,
                                   nsAtom* aFamily, uint32_t aAlternate, nsAtom* aName)
 {
   MOZ_ASSERT(NS_IsMainThread());
   static_assert(sizeof(unsigned int) == sizeof(uint32_t),
                 "sizeof unsigned int and uint32_t must be the same");
   return aFontFeatureValues->AppendFeatureValueHashEntry(
-    nsDependentAtomString(aFamily),
+    nsAtomCString(aFamily),
     nsDependentAtomString(aName),
     aAlternate
   );
 }
 
 void
 Gecko_nsFont_SetFontFeatureValuesLookup(nsFont* aFont,
                                         const RawGeckoPresContext* aPresContext)
--- a/layout/style/nsFontFaceUtils.cpp
+++ b/layout/style/nsFontFaceUtils.cpp
@@ -26,17 +26,17 @@ ComputedStyleContainsFont(ComputedStyle*
   // downloadable fonts
   if (!aFont) {
     const mozilla::FontFamilyList& fontlist =
       aComputedStyle->StyleFont()->mFont.fontlist;
     return aUserFontSet->ContainsUserFontSetFonts(fontlist);
   }
 
   // first, check if the family name is in the fontlist
-  const nsString& familyName = aFont->FamilyName();
+  NS_ConvertUTF8toUTF16 familyName(aFont->FamilyName());
   if (!aComputedStyle->StyleFont()->mFont.fontlist.Contains(familyName)) {
     return false;
   }
 
   // family name is in the fontlist, check to see if the font group
   // associated with the frame includes the specific userfont
   RefPtr<nsFontMetrics> fm =
     nsLayoutUtils::GetFontMetricsForComputedStyle(aComputedStyle,
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -630,18 +630,20 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
         aFontStyle.stretch    = mozilla::FontStretch::Normal();
         aFontStyle.size       = 14 * aDevPixPerCSSPixel;
         aFontStyle.systemFont = true;
 
         aFontName.AssignLiteral("sans-serif");
         return true;
     }
 
-    gfxPlatformMac::LookupSystemFont(aID, aFontName, aFontStyle,
+    nsAutoCString name;
+    gfxPlatformMac::LookupSystemFont(aID, name, aFontStyle,
                                      aDevPixPerCSSPixel);
+    aFontName.Append(NS_ConvertUTF8toUTF16(name));
 
     return true;
 
     NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
 }
 
 nsTArray<LookAndFeelInt>
 nsLookAndFeel::GetIntCacheImpl()