Bug 1573720 - Convert intl.charset.fallback.tld to a static pref. r=mccr8
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 15 Aug 2019 05:30:56 +0000
changeset 488378 1dea742635b1f839f4230e82eab1b50b72965d99
parent 488377 cf470b2c90c8d9b6a46559302cb2ee60ea0e02a6
child 488379 fbb952df34648f42973d2a58404d1edd50e77e09
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1573720
milestone70.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 1573720 - Convert intl.charset.fallback.tld to a static pref. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D41917
dom/encoding/FallbackEncoding.cpp
dom/encoding/FallbackEncoding.h
dom/html/nsHTMLDocument.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/encoding/FallbackEncoding.cpp
+++ b/dom/encoding/FallbackEncoding.cpp
@@ -50,17 +50,16 @@ static const EncodingProp domainsFallbac
 
 static constexpr nsUConvProp nonParticipatingDomains[] = {
 #include "nonparticipatingdomains.properties.h"
 };
 
 NS_IMPL_ISUPPORTS(FallbackEncoding, nsIObserver)
 
 StaticRefPtr<FallbackEncoding> FallbackEncoding::sInstance;
-bool FallbackEncoding::sGuessFallbackFromTopLevelDomain = true;
 
 FallbackEncoding::FallbackEncoding() : mFallback(nullptr) {
   MOZ_ASSERT(!FallbackEncoding::sInstance, "Singleton already exists.");
 }
 
 NotNull<const Encoding*> FallbackEncoding::Get() {
   if (mFallback) {
     return WrapNotNull(mFallback);
@@ -134,18 +133,16 @@ FallbackEncoding::Observe(nsISupports* a
 }
 
 void FallbackEncoding::Initialize() {
   MOZ_ASSERT(!FallbackEncoding::sInstance,
              "Initializing pre-existing fallback cache.");
   FallbackEncoding::sInstance = new FallbackEncoding;
   Preferences::RegisterCallback(FallbackEncoding::PrefChanged,
                                 "intl.charset.fallback.override");
-  Preferences::AddBoolVarCache(&sGuessFallbackFromTopLevelDomain,
-                               "intl.charset.fallback.tld");
 
   nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
   if (obs) {
     obs->AddObserver(sInstance, "intl:requested-locales-changed", true);
   }
 }
 
 void FallbackEncoding::Shutdown() {
--- a/dom/encoding/FallbackEncoding.h
+++ b/dom/encoding/FallbackEncoding.h
@@ -18,21 +18,16 @@ class Encoding;
 namespace dom {
 
 class FallbackEncoding : public nsIObserver, nsSupportsWeakReference {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   /**
-   * Whether FromTopLevelDomain() should be used.
-   */
-  static bool sGuessFallbackFromTopLevelDomain;
-
-  /**
    * Gets the locale-dependent fallback encoding for legacy HTML and plain
    * text content.
    *
    * @param aFallback the outparam for the fallback encoding
    */
   static NotNull<const Encoding*> FromLocale();
 
   /**
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHTMLDocument.h"
 
 #include "nsIContentPolicy.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/PresShell.h"
+#include "mozilla/StaticPrefs_intl.h"
 #include "nsCommandManager.h"
 #include "nsCOMPtr.h"
 #include "nsGlobalWindow.h"
 #include "nsString.h"
 #include "nsPrintfCString.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsIContentSecurityPolicy.h"
@@ -337,17 +338,17 @@ void nsHTMLDocument::TryParentCharset(ns
   }
 }
 
 void nsHTMLDocument::TryTLD(int32_t& aCharsetSource,
                             NotNull<const Encoding*>& aEncoding) {
   if (aCharsetSource >= kCharsetFromTopLevelDomain) {
     return;
   }
-  if (!FallbackEncoding::sGuessFallbackFromTopLevelDomain) {
+  if (!StaticPrefs::intl_charset_fallback_tld()) {
     return;
   }
   if (!mDocumentURI) {
     return;
   }
   nsAutoCString host;
   mDocumentURI->GetAsciiHost(host);
   if (host.IsEmpty()) {
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -3524,16 +3524,21 @@
 
 # Whether ISO-2022-JP is a permitted content-based encoding detection
 # outcome.
 - name: intl.charset.detector.iso2022jp.allowed
   type: bool
   value: true
   mirror: always
 
+- name: intl.charset.fallback.tld
+  type: bool
+  value: true
+  mirror: always
+
 #---------------------------------------------------------------------------
 # Prefs starting with "javascript."
 #---------------------------------------------------------------------------
 
 - name: javascript.options.compact_on_user_inactive
   type: bool
   value: true
   mirror: always
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2284,17 +2284,16 @@ pref("converter.html2txt.header_strategy
 // we want to be able to pref-off it if user doesn't like it.
 pref("converter.html2txt.always_include_ruby", false);
 
 pref("intl.accept_languages",               "chrome://global/locale/intl.properties");
 pref("intl.menuitems.alwaysappendaccesskeys","chrome://global/locale/intl.properties");
 pref("intl.menuitems.insertseparatorbeforeaccesskeys","chrome://global/locale/intl.properties");
 pref("intl.charset.detector",               "chrome://global/locale/intl.properties");
 pref("intl.charset.fallback.override",      "");
-pref("intl.charset.fallback.tld",           true);
 pref("intl.ellipsis",                       "chrome://global-platform/locale/intl.properties");
 // this pref allows user to request that all internationalization formatters
 // like date/time formatting, unit formatting, calendars etc. should use
 // OS locale set instead of the app locale set.
 pref("intl.regional_prefs.use_os_locales",  false);
 // fallback charset list for Unicode conversion (converting from Unicode)
 // currently used for mail send only to handle symbol characters (e.g Euro, trademark, smartquotes)
 // for ISO-8859-1