Backed out changeset 5df4d8778602 (bug 1384835)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 28 Jul 2017 10:29:29 +0200
changeset 420317 04539e21f0d579a537e1a6abab75d9b88258d6cd
parent 420316 88e14ba4308e1ca878548a2b1616276c7b543c39
child 420318 b57e8e2ae846d39319c45bd3446eb4d9e974ac5b
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1384835
milestone56.0a1
backs out5df4d877860281f66dc14b512de963539dc443b0
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
Backed out changeset 5df4d8778602 (bug 1384835)
caps/nsScriptSecurityManager.cpp
dom/audiochannel/AudioChannelService.cpp
dom/base/Navigator.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDocument.cpp
dom/base/nsGlobalWindow.cpp
dom/html/HTMLInputElement.cpp
dom/media/CubebUtils.cpp
dom/media/DecoderDoctorDiagnostics.cpp
dom/svg/SVGSwitchElement.cpp
dom/svg/SVGTests.cpp
dom/workers/RuntimeService.cpp
editor/composer/nsEditorSpellCheck.cpp
gfx/src/DriverCrashGuard.cpp
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFontUtils.cpp
gfx/thebes/gfxPlatform.cpp
layout/base/StaticPresData.cpp
layout/base/nsPresContext.cpp
layout/xul/nsTextBoxFrame.cpp
modules/libpref/Preferences.cpp
modules/libpref/Preferences.h
security/manager/ssl/nsNSSComponent.cpp
toolkit/xre/nsXREDirProvider.cpp
widget/android/PrefsHelper.h
widget/cocoa/nsDeviceContextSpecX.mm
widget/windows/IMMHandler.cpp
widget/windows/PDFiumEngineShim.cpp
widget/windows/nsDeviceContextSpecWin.cpp
widget/windows/nsWindow.cpp
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -1650,19 +1650,17 @@ nsScriptSecurityManager::EnsureFileURIWh
         // Grab the current policy name.
         bound = SkipUntil<IsWhitespaceOrComma>(policies, base);
         auto policyName = Substring(policies, base, bound - base);
 
         // Figure out if this policy allows loading file:// URIs. If not, we can skip it.
         nsCString checkLoadURIPrefName = NS_LITERAL_CSTRING("capability.policy.") +
                                          policyName +
                                          NS_LITERAL_CSTRING(".checkloaduri.enabled");
-        nsAutoString value;
-        nsresult rv = Preferences::GetString(checkLoadURIPrefName.get(), value);
-        if (NS_FAILED(rv) || !value.LowerCaseEqualsLiteral("allaccess")) {
+        if (!Preferences::GetString(checkLoadURIPrefName.get()).LowerCaseEqualsLiteral("allaccess")) {
             continue;
         }
 
         // Grab the list of domains associated with this policy.
         nsCString domainPrefName = NS_LITERAL_CSTRING("capability.policy.") +
                                    policyName +
                                    NS_LITERAL_CSTRING(".sites");
         auto siteList = Preferences::GetCString(domainPrefName.get());
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -558,18 +558,17 @@ AudioChannelService::GetAudioChannel(con
   }
 
   return AudioChannel::Normal;
 }
 
 /* static */ AudioChannel
 AudioChannelService::GetDefaultAudioChannel()
 {
-  nsAutoString audioChannel;
-  Preferences::GetString("media.defaultAudioChannel", audioChannel);
+  nsAutoString audioChannel(Preferences::GetString("media.defaultAudioChannel"));
   if (audioChannel.IsEmpty()) {
     return AudioChannel::Normal;
   }
 
   for (uint32_t i = 0; kMozAudioChannelAttributeTable[i].tag; ++i) {
     if (audioChannel.EqualsASCII(kMozAudioChannelAttributeTable[i].tag)) {
       return static_cast<AudioChannel>(kMozAudioChannelAttributeTable[i].value);
     }
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -374,18 +374,18 @@ Navigator::GetAppName(nsAString& aAppNam
 /* static */ void
 Navigator::GetAcceptLanguages(nsTArray<nsString>& aLanguages)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   aLanguages.Clear();
 
   // E.g. "de-de, en-us,en".
-  nsAutoString acceptLang;
-  Preferences::GetLocalizedString("intl.accept_languages", acceptLang);
+  const nsAdoptingString& acceptLang =
+    Preferences::GetLocalizedString("intl.accept_languages");
 
   // Split values on commas.
   nsCharSeparatedTokenizer langTokenizer(acceptLang, ',');
   while (langTokenizer.hasMoreTokens()) {
     nsDependentSubstring lang = langTokenizer.nextToken();
 
     // Replace "_" with "-" to avoid POSIX/Windows "en_US" notation.
     // NOTE: we should probably rely on the pref being set correctly.
@@ -468,19 +468,20 @@ Navigator::GetOscpu(nsAString& aOSCPU, C
   if (aCallerType != CallerType::System) {
     // If fingerprinting resistance is on, we will spoof this value. See nsRFPService.h
     // for details about spoofed values.
     if (nsContentUtils::ShouldResistFingerprinting()) {
       aOSCPU.AssignLiteral(SPOOFED_OSCPU);
       return;
     }
 
-    nsAutoString override;
-    nsresult rv = Preferences::GetString("general.oscpu.override", override);
-    if (NS_SUCCEEDED(rv)) {
+    const nsAdoptingString& override =
+      Preferences::GetString("general.oscpu.override");
+
+    if (override) {
       aOSCPU = override;
       return;
     }
   }
 
   nsresult rv;
   nsCOMPtr<nsIHttpProtocolHandler>
     service(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv));
@@ -647,19 +648,20 @@ Navigator::GetBuildID(nsAString& aBuildI
 {
   if (aCallerType != CallerType::System) {
     // If fingerprinting resistance is on, we will spoof this value. See nsRFPService.h
     // for details about spoofed values.
     if (nsContentUtils::ShouldResistFingerprinting()) {
       aBuildID.AssignLiteral(LEGACY_BUILD_ID);
       return;
     }
-    nsAutoString override;
-    nsresult rv = Preferences::GetString("general.buildID.override", override);
-    if (NS_SUCCEEDED(rv)) {
+    const nsAdoptingString& override =
+      Preferences::GetString("general.buildID.override");
+
+    if (override) {
       aBuildID = override;
       return;
     }
   }
 
   nsCOMPtr<nsIXULAppInfo> appInfo =
     do_GetService("@mozilla.org/xre/app-info;1");
   if (!appInfo) {
@@ -697,18 +699,17 @@ Navigator::GetDoNotTrack(nsAString &aRes
 }
 
 bool
 Navigator::JavaEnabled(CallerType aCallerType, ErrorResult& aRv)
 {
   Telemetry::AutoTimer<Telemetry::CHECK_JAVA_ENABLED> telemetryTimer;
 
   // Return true if we have a handler for the java mime
-  nsAutoString javaMIME;
-  Preferences::GetString("plugin.java.mime", javaMIME);
+  nsAdoptingString javaMIME = Preferences::GetString("plugin.java.mime");
   NS_ENSURE_TRUE(!javaMIME.IsEmpty(), false);
 
   if (!mMimeTypes) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return false;
     }
     mMimeTypes = new nsMimeTypeArray(mWindow);
@@ -1777,21 +1778,20 @@ Navigator::GetPlatform(nsAString& aPlatf
 
   if (aUsePrefOverriddenValue) {
     // If fingerprinting resistance is on, we will spoof this value. See nsRFPService.h
     // for details about spoofed values.
     if (nsContentUtils::ShouldResistFingerprinting()) {
       aPlatform.AssignLiteral(SPOOFED_PLATFORM);
       return NS_OK;
     }
-    nsAutoString override;
-    nsresult rv =
-      mozilla::Preferences::GetString("general.platform.override", override);
+    const nsAdoptingString& override =
+      mozilla::Preferences::GetString("general.platform.override");
 
-    if (NS_SUCCEEDED(rv)) {
+    if (override) {
       aPlatform = override;
       return NS_OK;
     }
   }
 
   nsresult rv;
 
   nsCOMPtr<nsIHttpProtocolHandler>
@@ -1829,21 +1829,20 @@ Navigator::GetAppVersion(nsAString& aApp
 
   if (aUsePrefOverriddenValue) {
     // If fingerprinting resistance is on, we will spoof this value. See nsRFPService.h
     // for details about spoofed values.
     if (nsContentUtils::ShouldResistFingerprinting()) {
       aAppVersion.AssignLiteral(SPOOFED_APPVERSION);
       return NS_OK;
     }
-    nsAutoString override;
-    nsresult rv =
-      mozilla::Preferences::GetString("general.appversion.override", override);
+    const nsAdoptingString& override =
+      mozilla::Preferences::GetString("general.appversion.override");
 
-    if (NS_SUCCEEDED(rv)) {
+    if (override) {
       aAppVersion = override;
       return NS_OK;
     }
   }
 
   nsresult rv;
 
   nsCOMPtr<nsIHttpProtocolHandler>
@@ -1874,21 +1873,20 @@ Navigator::AppName(nsAString& aAppName, 
   if (aUsePrefOverriddenValue) {
     // If fingerprinting resistance is on, we will spoof this value. See nsRFPService.h
     // for details about spoofed values.
     if (nsContentUtils::ShouldResistFingerprinting()) {
       aAppName.AssignLiteral(SPOOFED_APPNAME);
       return;
     }
 
-    nsAutoString override;
-    nsresult rv =
-      mozilla::Preferences::GetString("general.appname.override", override);
+    const nsAdoptingString& override =
+      mozilla::Preferences::GetString("general.appname.override");
 
-    if (NS_SUCCEEDED(rv)) {
+    if (override) {
       aAppName = override;
       return;
     }
   }
 
   aAppName.AssignLiteral("Netscape");
 }
 
@@ -1904,21 +1902,20 @@ Navigator::GetUserAgent(nsPIDOMWindowInn
                         nsAString& aUserAgent)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // We will skip the override and pass to httpHandler to get spoofed userAgent
   // when 'privacy.resistFingerprinting' is true.
   if (!aIsCallerChrome &&
       !nsContentUtils::ShouldResistFingerprinting()) {
-    nsAutoString override;
-    nsresult rv =
-      mozilla::Preferences::GetString("general.useragent.override", override);
+    const nsAdoptingString& override =
+      mozilla::Preferences::GetString("general.useragent.override");
 
-    if (NS_SUCCEEDED(rv)) {
+    if (override) {
       aUserAgent = override;
       return NS_OK;
     }
   }
 
   nsresult rv;
   nsCOMPtr<nsIHttpProtocolHandler>
     service(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &rv));
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5572,18 +5572,17 @@ nsContentUtils::GetTopLevelWidget(nsIWid
 }
 
 /* static */
 const nsDependentString
 nsContentUtils::GetLocalizedEllipsis()
 {
   static char16_t sBuf[4] = { 0, 0, 0, 0 };
   if (!sBuf[0]) {
-    nsAutoString tmp;
-    Preferences::GetLocalizedString("intl.ellipsis", tmp);
+    nsAdoptingString tmp = Preferences::GetLocalizedString("intl.ellipsis");
     uint32_t len = std::min(uint32_t(tmp.Length()),
                           uint32_t(ArrayLength(sBuf) - 1));
     CopyUnicodeTo(tmp, 0, sBuf, len);
     if (!sBuf[0])
       sBuf[0] = char16_t(0x2026);
   }
   return nsDependentString(sBuf);
 }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2759,19 +2759,18 @@ nsDocument::InitCSP(nsIChannel* aChannel
       csp->AppendPolicy(addonCSP, false, false);
     }
   }
 
   // ----- if the doc is a signed content, apply the default CSP.
   // Note that when the content signing becomes a standard, we might have
   // to restrict this enforcement to "remote content" only.
   if (applySignedContentCSP) {
-    nsAutoString signedContentCSP;
-    Preferences::GetString("security.signed_content.CSP.default",
-                           signedContentCSP);
+    nsAdoptingString signedContentCSP =
+      Preferences::GetString("security.signed_content.CSP.default");
     csp->AppendPolicy(signedContentCSP, false, false);
   }
 
   // ----- if there's a full-strength CSP header, apply it.
   if (!cspHeaderValue.IsEmpty()) {
     rv = CSP_AppendCSPFromHeader(csp, cspHeaderValue, false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8041,18 +8041,18 @@ void
 nsGlobalWindow::HomeOuter(nsIPrincipal& aSubjectPrincipal, ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
   if (!mDocShell) {
     return;
   }
 
-  nsAutoString homeURL;
-  Preferences::GetLocalizedString(PREF_BROWSER_STARTUP_HOMEPAGE, homeURL);
+  nsAdoptingString homeURL =
+    Preferences::GetLocalizedString(PREF_BROWSER_STARTUP_HOMEPAGE);
 
   if (homeURL.IsEmpty()) {
     // if all else fails, use this
 #ifdef DEBUG_seth
     printf("all else failed.  using %s as the home page\n", DEFAULT_HOME_PAGE);
 #endif
     CopyASCIItoUTF16(DEFAULT_HOME_PAGE, homeURL);
   }
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -479,17 +479,17 @@ NS_IMPL_ISUPPORTS(UploadLastDir::Content
 
 NS_IMETHODIMP
 UploadLastDir::ContentPrefCallback::HandleCompletion(uint16_t aReason)
 {
   nsCOMPtr<nsIFile> localFile;
   nsAutoString prefStr;
 
   if (aReason == nsIContentPrefCallback2::COMPLETE_ERROR || !mResult) {
-    Preferences::GetString("dom.input.fallbackUploadDir", prefStr);
+    prefStr = Preferences::GetString("dom.input.fallbackUploadDir");
   }
 
   if (prefStr.IsEmpty() && mResult) {
     nsCOMPtr<nsIVariant> pref;
     mResult->GetValue(getter_AddRefs(pref));
     pref->GetAsAString(prefStr);
   }
 
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -157,23 +157,23 @@ static const uint32_t CUBEB_NORMAL_LATEN
 // Consevative default that can work on all platforms.
 static const uint32_t CUBEB_NORMAL_LATENCY_FRAMES = 1024;
 
 namespace CubebUtils {
 
 void PrefChanged(const char* aPref, void* aClosure)
 {
   if (strcmp(aPref, PREF_VOLUME_SCALE) == 0) {
-    nsAutoCString value;
-    Preferences::GetCString(aPref, value);
+    nsAdoptingString value = Preferences::GetString(aPref);
     StaticMutexAutoLock lock(sMutex);
     if (value.IsEmpty()) {
       sVolumeScale = 1.0;
     } else {
-      sVolumeScale = std::max<double>(0, PR_strtod(value.get(), nullptr));
+      NS_ConvertUTF16toUTF8 utf8(value);
+      sVolumeScale = std::max<double>(0, PR_strtod(utf8.get(), nullptr));
     }
   } else if (strcmp(aPref, PREF_CUBEB_LATENCY_PLAYBACK) == 0) {
     // Arbitrary default stream latency of 100ms.  The higher this
     // value, the longer stream volume changes will take to become
     // audible.
     sCubebPlaybackLatencyPrefSet = Preferences::HasUserValue(aPref);
     uint32_t value = Preferences::GetUint(aPref, CUBEB_NORMAL_LATENCY_MS);
     StaticMutexAutoLock lock(sMutex);
@@ -183,38 +183,38 @@ void PrefChanged(const char* aPref, void
     uint32_t value = Preferences::GetUint(aPref, CUBEB_NORMAL_LATENCY_FRAMES);
     StaticMutexAutoLock lock(sMutex);
     // 128 is the block size for the Web Audio API, which limits how low the
     // latency can be here.
     // We don't want to limit the upper limit too much, so that people can
     // experiment.
     sCubebMSGLatencyInFrames = std::min<uint32_t>(std::max<uint32_t>(value, 128), 1e6);
   } else if (strcmp(aPref, PREF_CUBEB_LOGGING_LEVEL) == 0) {
-    nsAutoCString value;
-    Preferences::GetCString(aPref, value);
+    nsAdoptingString value = Preferences::GetString(aPref);
+    NS_ConvertUTF16toUTF8 utf8(value);
     LogModule* cubebLog = LogModule::Get("cubeb");
-    if (value.EqualsLiteral("verbose")) {
+    if (strcmp(utf8.get(), "verbose") == 0) {
       cubeb_set_log_callback(CUBEB_LOG_VERBOSE, CubebLogCallback);
       cubebLog->SetLevel(LogLevel::Verbose);
-    } else if (value.EqualsLiteral("normal")) {
+    } else if (strcmp(utf8.get(), "normal") == 0) {
       cubeb_set_log_callback(CUBEB_LOG_NORMAL, CubebLogCallback);
       cubebLog->SetLevel(LogLevel::Error);
-    } else if (value.IsEmpty()) {
+    } else if (utf8.IsEmpty()) {
       cubeb_set_log_callback(CUBEB_LOG_DISABLED, nullptr);
       cubebLog->SetLevel(LogLevel::Disabled);
     }
   } else if (strcmp(aPref, PREF_CUBEB_BACKEND) == 0) {
-    nsAutoCString value;
-    Preferences::GetCString(aPref, value);
+    nsAdoptingString value = Preferences::GetString(aPref);
     if (value.IsEmpty()) {
       sCubebBackendName = nullptr;
     } else {
-      sCubebBackendName = new char[value.Length() + 1];
-      PodCopy(sCubebBackendName.get(), value.get(), value.Length());
-      sCubebBackendName[value.Length()] = 0;
+      NS_LossyConvertUTF16toASCII ascii(value);
+      sCubebBackendName = new char[ascii.Length() + 1];
+      PodCopy(sCubebBackendName.get(), ascii.get(), ascii.Length());
+      sCubebBackendName[ascii.Length()] = 0;
     }
   }
 }
 
 bool GetFirstStream()
 {
   static bool sFirstStream = true;
 
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -623,18 +623,18 @@ DecoderDoctorDocumentWatcher::Synthesize
       { &supportedKeySystems, &playableFormats };
     // For each type of notification, retrieve the pref that contains formats/
     // key systems with issues.
     for (const NotificationAndReportStringId* id :
            sAllNotificationsAndReportStringIds) {
       nsAutoCString formatsPref("media.decoder-doctor.");
       formatsPref += id->mReportStringId;
       formatsPref += ".formats";
-      nsAutoString formatsWithIssues;
-      Preferences::GetString(formatsPref.Data(), formatsWithIssues);
+      nsAdoptingString formatsWithIssues =
+        Preferences::GetString(formatsPref.Data());
       if (formatsWithIssues.IsEmpty()) {
         continue;
       }
       // See if that list of formats-with-issues contains any formats that are
       // now playable/supported.
       bool solved = false;
       for (const nsAString* workingFormats : workingFormatsArray) {
         for (const auto& workingFormat : MakeStringListRange(*workingFormats)) {
--- a/dom/svg/SVGSwitchElement.cpp
+++ b/dom/svg/SVGSwitchElement.cpp
@@ -122,18 +122,18 @@ SVGSwitchElement::IsAttributeMapped(cons
 }
 
 //----------------------------------------------------------------------
 // Implementation Helpers:
 
 nsIContent *
 SVGSwitchElement::FindActiveChild() const
 {
-  nsAutoString acceptLangs;
-  Preferences::GetLocalizedString("intl.accept_languages", acceptLangs);
+  const nsAdoptingString& acceptLangs =
+    Preferences::GetLocalizedString("intl.accept_languages");
 
   if (!acceptLangs.IsEmpty()) {
     int32_t bestLanguagePreferenceRank = -1;
     nsIContent *bestChild = nullptr;
     nsIContent *defaultChild = nullptr;
     for (nsIContent* child = nsINode::GetFirstChild();
          child;
          child = child->GetNextSibling()) {
--- a/dom/svg/SVGTests.cpp
+++ b/dom/svg/SVGTests.cpp
@@ -142,22 +142,18 @@ SVGTests::PassesConditionalProcessingTes
   // prefix of one of the languages given in the value of this parameter such
   // that the first tag character following the prefix is "-".
   if (mStringListAttributes[LANGUAGE].IsExplicitlySet()) {
     if (mStringListAttributes[LANGUAGE].IsEmpty()) {
       return false;
     }
 
     // Get our language preferences
-    nsAutoString acceptLangs;
-    if (aAcceptLangs) {
-      acceptLangs.Assign(*aAcceptLangs);
-    } else {
-      Preferences::GetLocalizedString("intl.accept_languages", acceptLangs);
-    }
+    const nsAutoString acceptLangs(aAcceptLangs ? *aAcceptLangs :
+      Preferences::GetLocalizedString("intl.accept_languages"));
 
     if (acceptLangs.IsEmpty()) {
       NS_WARNING("no default language specified for systemLanguage conditional test");
       return false;
     }
 
     const nsDefaultStringComparator defaultComparator;
 
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1318,46 +1318,46 @@ PrefLanguagesChanged(const char* /* aPre
   }
 }
 
 void
 AppNameOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
 {
   AssertIsOnMainThread();
 
-  nsAutoString override;
-  Preferences::GetString("general.appname.override", override);
+  const nsAdoptingString& override =
+    mozilla::Preferences::GetString("general.appname.override");
 
   RuntimeService* runtime = RuntimeService::GetService();
   if (runtime) {
     runtime->UpdateAppNameOverridePreference(override);
   }
 }
 
 void
 AppVersionOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
 {
   AssertIsOnMainThread();
 
-  nsAutoString override;
-  Preferences::GetString("general.appversion.override", override);
+  const nsAdoptingString& override =
+    mozilla::Preferences::GetString("general.appversion.override");
 
   RuntimeService* runtime = RuntimeService::GetService();
   if (runtime) {
     runtime->UpdateAppVersionOverridePreference(override);
   }
 }
 
 void
 PlatformOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
 {
   AssertIsOnMainThread();
 
-  nsAutoString override;
-  Preferences::GetString("general.platform.override", override);
+  const nsAdoptingString& override =
+    mozilla::Preferences::GetString("general.platform.override");
 
   RuntimeService* runtime = RuntimeService::GetService();
   if (runtime) {
     runtime->UpdatePlatformOverridePreference(override);
   }
 }
 
 class BackgroundChildCallback final
--- a/editor/composer/nsEditorSpellCheck.cpp
+++ b/editor/composer/nsEditorSpellCheck.cpp
@@ -899,17 +899,17 @@ nsEditorSpellCheck::SetFallbackDictionar
   nsAutoString dictName(mPreferredLang);
 #ifdef DEBUG_DICT
   printf("***** Assigned from element/doc |%s|\n",
          NS_ConvertUTF16toUTF8(dictName).get());
 #endif
 
   // Get the preference value.
   nsAutoString preferredDict;
-  Preferences::GetLocalizedString("spellchecker.dictionary", preferredDict);
+  preferredDict = Preferences::GetLocalizedString("spellchecker.dictionary");
 
   if (!dictName.IsEmpty()) {
     // RFC 5646 explicitly states that matches should be case-insensitive.
     BuildDictionaryList(dictName, dictList, DICT_COMPARE_CASE_INSENSITIVE,
                         tryDictList);
 
 #ifdef DEBUG_DICT
     printf("***** Trying from element/doc |%s| \n",
--- a/gfx/src/DriverCrashGuard.cpp
+++ b/gfx/src/DriverCrashGuard.cpp
@@ -346,18 +346,17 @@ DriverCrashGuard::CheckAndUpdateBoolPref
   return true;
 }
 
 bool
 DriverCrashGuard::CheckAndUpdatePref(const char* aPrefName, const nsAString& aCurrentValue)
 {
   std::string pref = GetFullPrefName(aPrefName);
 
-  nsAutoString oldValue;
-  Preferences::GetString(pref.c_str(), oldValue);
+  nsAdoptingString oldValue = Preferences::GetString(pref.c_str());
   if (oldValue == aCurrentValue) {
     return false;
   }
   Preferences::SetString(pref.c_str(), aCurrentValue);
   return true;
 }
 
 std::string
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -1693,31 +1693,27 @@ gfxFcPlatformFontList::AddGenericFonts(m
 
     // By default, most font prefs on Linux map to "use fontconfig"
     // keywords. So only need to explicitly lookup font pref if
     // non-default settings exist
     NS_ConvertASCIItoUTF16 genericToLookup(generic);
     if ((!mAlwaysUseFontconfigGenerics && aLanguage) ||
         aLanguage == nsGkAtoms::x_math) {
         nsIAtom* langGroup = GetLangGroup(aLanguage);
-        nsAutoString fontlistValue;
-        Preferences::GetString(NamePref(generic, langGroup).get(),
-                               fontlistValue);
-        nsresult rv;
+        nsAdoptingString fontlistValue =
+            Preferences::GetString(NamePref(generic, langGroup).get());
         if (fontlistValue.IsEmpty()) {
             // The font name list may have two or more family names as comma
             // separated list.  In such case, not matching with generic font
             // name is fine because if the list prefers specific font, we
             // should try to use the pref with complicated path.
-            rv = Preferences::GetString(NameListPref(generic, langGroup).get(),
-                                        fontlistValue);
-        } else {
-            rv = NS_OK;
+            fontlistValue =
+                 Preferences::GetString(NameListPref(generic, langGroup).get());
         }
-        if (NS_SUCCEEDED(rv)) {
+        if (fontlistValue) {
             if (!fontlistValue.EqualsLiteral("serif") &&
                 !fontlistValue.EqualsLiteral("sans-serif") &&
                 !fontlistValue.EqualsLiteral("monospace")) {
                 usePrefFontList = true;
             } else {
                 // serif, sans-serif or monospace was specified
                 genericToLookup.Assign(fontlistValue);
             }
--- a/gfx/thebes/gfxFontUtils.cpp
+++ b/gfx/thebes/gfxFontUtils.cpp
@@ -855,19 +855,18 @@ void gfxFontUtils::ParseFontList(const n
         ++p;
     }
 }
 
 void gfxFontUtils::AppendPrefsFontList(const char *aPrefName,
                                        nsTArray<nsString>& aFontList)
 {
     // get the list of single-face font families
-    nsAutoString fontlistValue;
-    nsresult rv = Preferences::GetString(aPrefName, fontlistValue);
-    if (NS_FAILED(rv)) {
+    nsAdoptingString fontlistValue = Preferences::GetString(aPrefName);
+    if (!fontlistValue) {
         return;
     }
 
     ParseFontList(fontlistValue, aFontList);
 }
 
 void gfxFontUtils::GetPrefsFontList(const char *aPrefName,
                                     nsTArray<nsString>& aFontList)
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -565,19 +565,19 @@ gfxPlatform::InitChild(const ContentDevi
   Init();
   gContentDeviceInitData = nullptr;
 }
 
 void RecordingPrefChanged(const char *aPrefName, void *aClosure)
 {
   if (Preferences::GetBool("gfx.2d.recording", false)) {
     nsAutoCString fileName;
-    nsAutoString prefFileName;
-    nsresult rv = Preferences::GetString("gfx.2d.recordingfile", prefFileName);
-    if (NS_SUCCEEDED(rv)) {
+    nsAdoptingString prefFileName = Preferences::GetString("gfx.2d.recordingfile");
+
+    if (prefFileName) {
       fileName.Append(NS_ConvertUTF16toUTF8(prefFileName));
     } else {
       nsCOMPtr<nsIFile> tmpFile;
       if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)))) {
         return;
       }
       fileName.AppendPrintf("moz2drec_%i_%i.aer", XRE_GetProcessType(), getpid());
 
--- a/layout/base/StaticPresData.cpp
+++ b/layout/base/StaticPresData.cpp
@@ -158,29 +158,28 @@ LangGroupFontPrefs::Initialize(nsIAtom* 
     nsFont* font = fontTypes[eType];
 
     // set the default variable font (the other fonts are seen as 'generic' fonts
     // in GFX and will be queried there when hunting for alternative fonts)
     if (eType == eDefaultFont_Variable) {
       // XXX "font.name.variable."?  There is no such pref...
       MAKE_FONT_PREF_KEY(pref, "font.name.variable.", langGroup);
 
-      nsAutoString value;
-      Preferences::GetString(pref.get(), value);
+      nsAdoptingString value = Preferences::GetString(pref.get());
       if (!value.IsEmpty()) {
         FontFamilyName defaultVariableName = FontFamilyName::Convert(value);
         FontFamilyType defaultType = defaultVariableName.mType;
         NS_ASSERTION(defaultType == eFamily_serif ||
                      defaultType == eFamily_sans_serif,
                      "default type must be serif or sans-serif");
         mDefaultVariableFont.fontlist = FontFamilyList(defaultType);
       }
       else {
         MAKE_FONT_PREF_KEY(pref, "font.default.", langGroup);
-        Preferences::GetString(pref.get(), value);
+        value = Preferences::GetString(pref.get());
         if (!value.IsEmpty()) {
           FontFamilyName defaultVariableName = FontFamilyName::Convert(value);
           FontFamilyType defaultType = defaultVariableName.mType;
           NS_ASSERTION(defaultType == eFamily_serif ||
                        defaultType == eFamily_sans_serif,
                        "default type must be serif or sans-serif");
           mDefaultVariableFont.fontlist = FontFamilyList(defaultType);
         }
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -511,23 +511,25 @@ nsPresContext::GetDocumentColorPreferenc
   if (sUseStandinsForNativeColors) {
     // Once the preference "ui.use_standins_for_native_colors" is enabled,
     // use fixed color values instead of prefered colors and system colors.
     mDefaultColor = LookAndFeel::GetColorUsingStandins(
         LookAndFeel::eColorID_windowtext, NS_RGB(0x00, 0x00, 0x00));
     mBackgroundColor = LookAndFeel::GetColorUsingStandins(
         LookAndFeel::eColorID_window, NS_RGB(0xff, 0xff, 0xff));
   } else if (usePrefColors) {
-    nsAutoString colorStr;
-    Preferences::GetString("browser.display.foreground_color", colorStr);
+    nsAdoptingString colorStr =
+      Preferences::GetString("browser.display.foreground_color");
+
     if (!colorStr.IsEmpty()) {
       mDefaultColor = MakeColorPref(colorStr);
     }
 
-    Preferences::GetString("browser.display.background_color", colorStr);
+    colorStr = Preferences::GetString("browser.display.background_color");
+
     if (!colorStr.IsEmpty()) {
       mBackgroundColor = MakeColorPref(colorStr);
     }
   }
   else {
     mDefaultColor =
       LookAndFeel::GetColor(LookAndFeel::eColorID_WindowForeground,
                             NS_RGB(0x00, 0x00, 0x00));
@@ -576,44 +578,48 @@ nsPresContext::GetUserPreferences()
   mSendAfterPaintToContent =
     Preferences::GetBool("dom.send_after_paint_to_content",
                          mSendAfterPaintToContent);
 
   // * link colors
   mUnderlineLinks =
     Preferences::GetBool("browser.underline_anchors", mUnderlineLinks);
 
-  nsAutoString colorStr;
-  Preferences::GetString("browser.anchor_color", colorStr);
+  nsAdoptingString colorStr = Preferences::GetString("browser.anchor_color");
+
   if (!colorStr.IsEmpty()) {
     mLinkColor = MakeColorPref(colorStr);
   }
 
-  Preferences::GetString("browser.active_color", colorStr);
+  colorStr = Preferences::GetString("browser.active_color");
+
   if (!colorStr.IsEmpty()) {
     mActiveLinkColor = MakeColorPref(colorStr);
   }
 
-  Preferences::GetString("browser.visited_color", colorStr);
+  colorStr = Preferences::GetString("browser.visited_color");
+
   if (!colorStr.IsEmpty()) {
     mVisitedLinkColor = MakeColorPref(colorStr);
   }
 
   mUseFocusColors =
     Preferences::GetBool("browser.display.use_focus_colors", mUseFocusColors);
 
   mFocusTextColor = mDefaultColor;
   mFocusBackgroundColor = mBackgroundColor;
 
-  Preferences::GetString("browser.display.focus_text_color", colorStr);
+  colorStr = Preferences::GetString("browser.display.focus_text_color");
+
   if (!colorStr.IsEmpty()) {
     mFocusTextColor = MakeColorPref(colorStr);
   }
 
-  Preferences::GetString("browser.display.focus_background_color", colorStr);
+  colorStr = Preferences::GetString("browser.display.focus_background_color");
+
   if (!colorStr.IsEmpty()) {
     mFocusBackgroundColor = MakeColorPref(colorStr);
   }
 
   mFocusRingWidth =
     Preferences::GetInt("browser.display.focus_ring_width", mFocusRingWidth);
 
   mFocusRingOnAnything =
--- a/layout/xul/nsTextBoxFrame.cpp
+++ b/layout/xul/nsTextBoxFrame.cpp
@@ -141,33 +141,31 @@ nsTextBoxFrame::DestroyFrom(nsIFrame* aD
 bool
 nsTextBoxFrame::AlwaysAppendAccessKey()
 {
   if (!gAccessKeyPrefInitialized)
   {
     gAccessKeyPrefInitialized = true;
 
     const char* prefName = "intl.menuitems.alwaysappendaccesskeys";
-    nsAutoString val;
-    Preferences::GetLocalizedString(prefName, val);
+    nsAdoptingString val = Preferences::GetLocalizedString(prefName);
     gAlwaysAppendAccessKey = val.EqualsLiteral("true");
   }
   return gAlwaysAppendAccessKey;
 }
 
 bool
 nsTextBoxFrame::InsertSeparatorBeforeAccessKey()
 {
   if (!gInsertSeparatorPrefInitialized)
   {
     gInsertSeparatorPrefInitialized = true;
 
     const char* prefName = "intl.menuitems.insertseparatorbeforeaccesskeys";
-    nsAutoString val;
-    Preferences::GetLocalizedString(prefName, val);
+    nsAdoptingString val = Preferences::GetLocalizedString(prefName);
     gInsertSeparatorBeforeAccessKey = val.EqualsLiteral("true");
   }
   return gInsertSeparatorBeforeAccessKey;
 }
 
 class nsAsyncAccesskeyUpdate final : public nsIReflowCallback
 {
 public:
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -1670,16 +1670,25 @@ nsAdoptingCString
 Preferences::GetCString(const char* aPref)
 {
   nsAdoptingCString result;
   PREF_CopyCharPref(aPref, getter_Copies(result), false);
   return result;
 }
 
 // static
+nsAdoptingString
+Preferences::GetString(const char* aPref)
+{
+  nsAdoptingString result;
+  GetString(aPref, result);
+  return result;
+}
+
+// static
 nsresult
 Preferences::GetCString(const char* aPref, nsACString& aResult)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsAutoCString result;
   nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
   if (NS_SUCCEEDED(rv)) {
     aResult = result;
@@ -1705,16 +1714,25 @@ nsAdoptingCString
 Preferences::GetLocalizedCString(const char* aPref)
 {
   nsAdoptingCString result;
   GetLocalizedCString(aPref, result);
   return result;
 }
 
 // static
+nsAdoptingString
+Preferences::GetLocalizedString(const char* aPref)
+{
+  nsAdoptingString result;
+  GetLocalizedString(aPref, result);
+  return result;
+}
+
+// static
 nsresult
 Preferences::GetLocalizedCString(const char* aPref, nsACString& aResult)
 {
   nsAutoString result;
   nsresult rv = GetLocalizedString(aPref, result);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF16toUTF8(result, aResult);
   }
@@ -2227,25 +2245,43 @@ Preferences::GetDefaultLocalizedString(c
   if (NS_SUCCEEDED(rv)) {
     NS_ASSERTION(prefLocalString, "Succeeded but the result is NULL");
     prefLocalString->GetData(getter_Copies(aResult));
   }
   return rv;
 }
 
 // static
+nsAdoptingString
+Preferences::GetDefaultString(const char* aPref)
+{
+  nsAdoptingString result;
+  GetDefaultString(aPref, result);
+  return result;
+}
+
+// static
 nsAdoptingCString
 Preferences::GetDefaultCString(const char* aPref)
 {
   nsAdoptingCString result;
   PREF_CopyCharPref(aPref, getter_Copies(result), true);
   return result;
 }
 
 // static
+nsAdoptingString
+Preferences::GetDefaultLocalizedString(const char* aPref)
+{
+  nsAdoptingString result;
+  GetDefaultLocalizedString(aPref, result);
+  return result;
+}
+
+// static
 nsAdoptingCString
 Preferences::GetDefaultLocalizedCString(const char* aPref)
 {
   nsAdoptingCString result;
   GetDefaultLocalizedCString(aPref, result);
   return result;
 }
 
--- a/modules/libpref/Preferences.h
+++ b/modules/libpref/Preferences.h
@@ -16,16 +16,17 @@
 #include "nsIObserver.h"
 #include "nsCOMPtr.h"
 #include "nsTArray.h"
 #include "nsWeakReference.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/MemoryReporting.h"
 
 class nsIFile;
+class nsAdoptingString;
 class nsAdoptingCString;
 
 #ifndef have_PrefChangedFunc_typedef
 typedef void (*PrefChangedFunc)(const char *, void *);
 #define have_PrefChangedFunc_typedef
 #endif
 
 #ifdef DEBUG
@@ -164,17 +165,19 @@ public:
    * if (!value.get()) {
    *   // the condition is always FALSE!!
    * }
    *
    * The value.get() doesn't return nullptr. You must use nsAdoptingString
    * when you need to check whether it was failure or not.
    */
   static nsAdoptingCString GetCString(const char* aPref);
+  static nsAdoptingString GetString(const char* aPref);
   static nsAdoptingCString GetLocalizedCString(const char* aPref);
+  static nsAdoptingString GetLocalizedString(const char* aPref);
 
   /**
    * Gets int, float, or bool type pref value with raw return value of
    * nsIPrefBranch.
    *
    * @param aPref       A pref name.
    * @param aResult     Must not be nullptr.  The value is never modified
    *                    when these methods fail.
@@ -379,17 +382,19 @@ public:
   /**
    * Gets the default value of the char type pref.
    * If the get() of the result returned nullptr, that meant the value didn't
    * have default value.
    *
    * See the comment at definition at GetString() and GetCString() for more
    * details of the result.
    */
+  static nsAdoptingString GetDefaultString(const char* aPref);
   static nsAdoptingCString GetDefaultCString(const char* aPref);
+  static nsAdoptingString GetDefaultLocalizedString(const char* aPref);
   static nsAdoptingCString GetDefaultLocalizedCString(const char* aPref);
 
   static nsresult GetDefaultCString(const char* aPref, nsACString& aResult);
   static nsresult GetDefaultString(const char* aPref, nsAString& aResult);
   static nsresult GetDefaultLocalizedCString(const char* aPref,
                                              nsACString& aResult);
   static nsresult GetDefaultLocalizedString(const char* aPref,
                                             nsAString& aResult);
--- a/security/manager/ssl/nsNSSComponent.cpp
+++ b/security/manager/ssl/nsNSSComponent.cpp
@@ -1945,21 +1945,21 @@ nsNSSComponent::InitializeNSS()
 
   MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("NSS Initialization done\n"));
 
   {
     MutexAutoLock lock(mMutex);
 
     // ensure we have initial values for various root hashes
 #ifdef DEBUG
-    Preferences::GetString("security.test.built_in_root_hash",
-                           mTestBuiltInRootHash);
+    mTestBuiltInRootHash =
+      Preferences::GetString("security.test.built_in_root_hash");
 #endif
-    Preferences::GetString("security.content.signature.root_hash",
-                           mContentSigningRootHash);
+    mContentSigningRootHash =
+      Preferences::GetString("security.content.signature.root_hash");
 
     mNSSInitialized = true;
   }
 
   return NS_OK;
 }
 
 void
@@ -2117,25 +2117,24 @@ nsNSSComponent::Observe(nsISupports* aSu
                prefName.EqualsLiteral("security.pki.name_matching_mode") ||
                prefName.EqualsLiteral("security.pki.netscape_step_up_policy") ||
                prefName.EqualsLiteral("security.OCSP.timeoutMilliseconds.soft") ||
                prefName.EqualsLiteral("security.OCSP.timeoutMilliseconds.hard")) {
       setValidationOptions(false);
 #ifdef DEBUG
     } else if (prefName.EqualsLiteral("security.test.built_in_root_hash")) {
       MutexAutoLock lock(mMutex);
-      Preferences::GetString("security.test.built_in_root_hash",
-                             mTestBuiltInRootHash);
+      mTestBuiltInRootHash = Preferences::GetString("security.test.built_in_root_hash");
 #endif // DEBUG
     } else if (prefName.Equals(kFamilySafetyModePref)) {
       MaybeEnableFamilySafetyCompatibility();
     } else if (prefName.EqualsLiteral("security.content.signature.root_hash")) {
       MutexAutoLock lock(mMutex);
-      Preferences::GetString("security.content.signature.root_hash",
-                             mContentSigningRootHash);
+      mContentSigningRootHash =
+        Preferences::GetString("security.content.signature.root_hash");
     } else if (prefName.Equals(kEnterpriseRootModePref)) {
       MaybeImportEnterpriseRoots();
     } else {
       clearSessionCache = false;
     }
     if (clearSessionCache)
       SSL_ClearSessionCache();
   }
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -774,19 +774,18 @@ static already_AddRefed<nsIFile>
 CreateContentProcessSandboxTempDir()
 {
   if (IsContentSandboxDisabled()) {
     return nullptr;
   }
 
   // Get (and create if blank) temp directory suffix pref.
   nsresult rv;
-  nsAutoString tempDirSuffix;
-  Preferences::GetString("security.sandbox.content.tempDirSuffix",
-                         tempDirSuffix);
+  nsAdoptingString tempDirSuffix =
+    Preferences::GetString("security.sandbox.content.tempDirSuffix");
   if (tempDirSuffix.IsEmpty()) {
     nsCOMPtr<nsIUUIDGenerator> uuidgen =
       do_GetService("@mozilla.org/uuid-generator;1", &rv);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return nullptr;
     }
 
     nsID uuid;
--- a/widget/android/PrefsHelper.h
+++ b/widget/android/PrefsHelper.h
@@ -133,17 +133,17 @@ class PrefsHelper
 public:
     static void GetPrefs(const jni::Class::LocalRef& aCls,
                          jni::ObjectArray::Param aPrefNames,
                          jni::Object::Param aPrefHandler)
     {
         nsTArray<jni::Object::LocalRef> nameRefArray(aPrefNames->GetElements());
         nsCOMPtr<nsIObserverService> obsServ;
         nsCOMPtr<nsIWritableVariant> value;
-        nsAutoString strVal;
+        nsAdoptingString strVal;
 
         for (jni::Object::LocalRef& nameRef : nameRefArray) {
             jni::String::LocalRef nameStr(mozilla::Move(nameRef));
             const nsCString& name = nameStr->ToCString();
 
             int32_t type = java::PrefsHelper::PREF_INVALID;
             bool boolVal = false;
             int32_t intVal = 0;
@@ -154,25 +154,24 @@ public:
                     boolVal = Preferences::GetBool(name.get());
                     break;
 
                 case nsIPrefBranch::PREF_INT:
                     type = java::PrefsHelper::PREF_INT;
                     intVal = Preferences::GetInt(name.get());
                     break;
 
-                case nsIPrefBranch::PREF_STRING: {
+                case nsIPrefBranch::PREF_STRING:
                     type = java::PrefsHelper::PREF_STRING;
-                    nsresult rv =
-                      Preferences::GetLocalizedString(name.get(), strVal);
-                    if (NS_FAILED(rv)) {
-                        Preferences::GetString(name.get(), strVal);
+                    strVal = Preferences::GetLocalizedString(name.get());
+                    if (!strVal) {
+                        strVal = Preferences::GetString(name.get());
                     }
                     break;
-                }
+
                 default:
                     // Pref not found; try to find it.
                     if (!obsServ) {
                         obsServ = services::GetObserverService();
                         if (!obsServ) {
                             continue;
                         }
                     }
@@ -284,36 +283,34 @@ public:
 
     static void OnPrefChange(const char16_t* aData)
     {
         const nsCString& name = NS_LossyConvertUTF16toASCII(aData);
 
         int32_t type = -1;
         bool boolVal = false;
         int32_t intVal = false;
-        nsAutoString strVal;
+        nsAdoptingString strVal;
 
         switch (Preferences::GetType(name.get())) {
             case nsIPrefBranch::PREF_BOOL:
                 type = java::PrefsHelper::PREF_BOOL;
                 boolVal = Preferences::GetBool(name.get());
                 break;
             case nsIPrefBranch::PREF_INT:
                 type = java::PrefsHelper::PREF_INT;
                 intVal = Preferences::GetInt(name.get());
                 break;
-            case nsIPrefBranch::PREF_STRING: {
+            case nsIPrefBranch::PREF_STRING:
                 type = java::PrefsHelper::PREF_STRING;
-                nsresult rv =
-                  Preferences::GetLocalizedString(name.get(), strVal);
-                if (NS_FAILED(rv)) {
-                    Preferences::GetString(name.get(), strVal);
+                strVal = Preferences::GetLocalizedString(name.get());
+                if (!strVal) {
+                    strVal = Preferences::GetString(name.get());
                 }
                 break;
-            }
             default:
                 NS_WARNING(nsPrintfCString("Invalid pref %s",
                                            name.get()).get());
                 return;
         }
 
         java::PrefsHelper::OnPrefChange(
                 name, type, boolVal, intVal,
--- a/widget/cocoa/nsDeviceContextSpecX.mm
+++ b/widget/cocoa/nsDeviceContextSpecX.mm
@@ -75,19 +75,19 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init
   }
 
   mPrintSession = settings->GetPMPrintSession();
   ::PMRetain(mPrintSession);
   mPageFormat = settings->GetPMPageFormat();
   mPrintSettings = settings->GetPMPrintSettings();
 
 #ifdef MOZ_ENABLE_SKIA_PDF
-  nsAutoString printViaPdf;
-  mozilla::Preferences::GetString("print.print_via_pdf_encoder", printViaPdf);
-  if (printViaPdf.EqualsLiteral("skia-pdf")) {
+  const nsAdoptingString& printViaPdf =
+    mozilla::Preferences::GetString("print.print_via_pdf_encoder");
+  if (printViaPdf == NS_LITERAL_STRING("skia-pdf")) {
     // Annoyingly, PMPrinterPrintWithFile does not pay attention to the
     // kPMDestination* value set in the PMPrintSession; it always sends the PDF
     // to the specified printer.  This means that if we create the PDF using
     // SkPDF then we need to manually handle user actions like "Open PDF in
     // Preview" and "Save as PDF...".
     // TODO: Currently we do not support using SkPDF for kPMDestinationFax or
     // kPMDestinationProcessPDF ("Add PDF to iBooks, etc.), and we only support
     // it for kPMDestinationFile if the destination file is a PDF.
--- a/widget/windows/IMMHandler.cpp
+++ b/widget/windows/IMMHandler.cpp
@@ -358,18 +358,18 @@ IMMHandler::InitKeyboardLayout(nsWindow*
                    (PWSTR)&sCodePage, sizeof(sCodePage) / sizeof(WCHAR));
   sIMEProperty = ::ImmGetProperty(aKeyboardLayout, IGP_PROPERTY);
   sIMEUIProperty = ::ImmGetProperty(aKeyboardLayout, IGP_UI);
 
   // If active IME is a TIP of TSF, we cannot retrieve the name with IMM32 API.
   // For hacking some bugs of some TIP, we should set an IME name from the
   // pref.
   if (sCodePage == 932 && sIMEName.IsEmpty()) {
-    Preferences::GetString("intl.imm.japanese.assume_active_tip_name_as",
-                           sIMEName);
+    sIMEName =
+      Preferences::GetString("intl.imm.japanese.assume_active_tip_name_as");
   }
 
   // Whether the IME supports vertical writing mode might be changed or
   // some IMEs may need specific font for their UI.  Therefore, we should
   // update composition font forcibly here.
   if (aWindow) {
     MaybeAdjustCompositionFont(aWindow, sWritingModeOfCompositionFont, true);
   }
@@ -2533,22 +2533,18 @@ IMMHandler::AdjustCompositionFont(nsWind
                                   const IMEContext& aContext,
                                   const WritingMode& aWritingMode,
                                   bool aForceUpdate)
 {
   // An instance of IMMHandler is destroyed when active IME is changed.
   // Therefore, we need to store the information which are set to the IM
   // context to static variables since IM context is never recreated.
   static bool sCompositionFontsInitialized = false;
-  static nsString sCompositionFont;
-  static bool sCompositionFontPrefDone = false;
-  if (!sCompositionFontPrefDone) {
-    sCompositionFontPrefDone = true;
-    Preferences::GetString("intl.imm.composition_font", sCompositionFont);
-  }
+  static nsString sCompositionFont =
+    Preferences::GetString("intl.imm.composition_font");
 
   // If composition font is customized by pref, we need to modify the
   // composition font of the IME context at first time even if the writing mode
   // is horizontal.
   bool setCompositionFontForcibly = aForceUpdate ||
     (!sCompositionFontsInitialized && !sCompositionFont.IsEmpty());
 
   static WritingMode sCurrentWritingMode;
@@ -2587,18 +2583,18 @@ IMMHandler::AdjustCompositionFont(nsWind
       ("AdjustCompositionFont, sCompositionFont=\"%s\" is initialized",
        NS_ConvertUTF16toUTF8(sCompositionFont).get()));
   }
 
   static nsString sCompositionFontForJapanist2003;
   if (IsJapanist2003Active() && sCompositionFontForJapanist2003.IsEmpty()) {
     const char* kCompositionFontForJapanist2003 =
       "intl.imm.composition_font.japanist_2003";
-    Preferences::GetString(kCompositionFontForJapanist2003,
-                           sCompositionFontForJapanist2003);
+    sCompositionFontForJapanist2003 =
+      Preferences::GetString(kCompositionFontForJapanist2003);
     // If the font name is not specified properly, let's use
     // "MS PGothic" instead.
     if (sCompositionFontForJapanist2003.IsEmpty() ||
         sCompositionFontForJapanist2003.Length() > LF_FACESIZE - 2 ||
         sCompositionFontForJapanist2003[0] == '@') {
       sCompositionFontForJapanist2003.AssignLiteral("MS PGothic");
     }
   }
--- a/widget/windows/PDFiumEngineShim.cpp
+++ b/widget/windows/PDFiumEngineShim.cpp
@@ -60,18 +60,18 @@ PDFiumEngineShim::~PDFiumEngineShim()
 bool
 PDFiumEngineShim::Init()
 {
   if (mInitialized) {
     return true;
   }
 
 #ifdef USE_EXTERNAL_PDFIUM
-  nsAutoString PDFiumPath;
-  mozilla::Preferences::GetString("print.load_external_pdfium", PDFiumPath);
+  const nsAdoptingString& PDFiumPath =
+    mozilla::Preferences::GetString("print.load_external_pdfium");
   NS_ENSURE_FALSE(PDFiumPath.IsEmpty(), false);
 
   nsAutoCString filePath = NS_ConvertUTF16toUTF8(PDFiumPath);
   mPRLibrary = PR_LoadLibrary(filePath.get());
   NS_ENSURE_TRUE(mPRLibrary, false);
 
   mFPDF_InitLibrary = (FPDF_InitLibrary_Pfn)PR_FindFunctionSymbol(
     mPRLibrary, "FPDF_InitLibrary");
@@ -164,9 +164,9 @@ PDFiumEngineShim::RenderPage(HDC aDC, FP
                              int aRotate, int aFlags)
 {
   MOZ_ASSERT(mInitialized);
   mFPDF_RenderPage(aDC, aPage, aStartX, aStartY,
                    aSizeX, aSizeY, aRotate, aFlags);
 }
 
 } // namespace widget
-} // namespace mozilla
+} // namespace mozilla
\ No newline at end of file
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -148,19 +148,20 @@ NS_IMETHODIMP nsDeviceContextSpecWin::In
                                            nsIPrintSettings* aPrintSettings,
                                            bool aIsPrintPreview)
 {
   mPrintSettings = aPrintSettings;
 
   nsresult rv = NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
   if (aPrintSettings) {
 #ifdef MOZ_ENABLE_SKIA_PDF
-    nsAutoString printViaPdf;
-    Preferences::GetString("print.print_via_pdf_encoder", printViaPdf);
-    if (printViaPdf.EqualsLiteral("skia-pdf")) {
+    const nsAdoptingString& printViaPdf =
+      mozilla::Preferences::GetString("print.print_via_pdf_encoder");
+
+    if (printViaPdf == NS_LITERAL_STRING("skia-pdf")) {
       mPrintViaSkPDF = true;
     }
 #endif
 
     // If we're in the child and printing via the parent or we're printing to
     // PDF we only need information from the print settings.
     mPrintSettings->GetOutputFormat(&mOutputFormat);
     if ((XRE_IsContentProcess() &&
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -8122,18 +8122,18 @@ bool nsWindow::CanTakeFocus()
   return false;
 }
 
 /* static */ const wchar_t*
 nsWindow::GetMainWindowClass()
 {
   static const wchar_t* sMainWindowClass = nullptr;
   if (!sMainWindowClass) {
-    nsAutoString className;
-    Preferences::GetString("ui.window_class_override", className);
+    nsAdoptingString className =
+      Preferences::GetString("ui.window_class_override");
     if (!className.IsEmpty()) {
       sMainWindowClass = wcsdup(className.get());
     } else {
       sMainWindowClass = kClassNameGeneral;
     }
   }
   return sMainWindowClass;
 }