Bug 1616999 - Rename MozLocale::AddLikelySubtags to Maximize following ECMA402 Intl.Locale convention. r=jfkthame
authorZibi Braniecki <zbraniecki@mozilla.com>
Fri, 21 Feb 2020 21:03:15 +0000
changeset 2648957 d67220ef9a916d94bd7a0423efab707775cbf93a
parent 2648956 2e9a6ba720996ec42d5b2cf7794b8ac6b01afc5a
child 2648958 8a875e45bcf1baa361c5e900083a1a7c2b3ff753
push id490874
push userdvarga@mozilla.com
push dateSat, 22 Feb 2020 10:42:44 +0000
treeherdertry@64a8e247759e [default view] [failures only]
reviewersjfkthame
bugs1616999
milestone75.0a1
Bug 1616999 - Rename MozLocale::AddLikelySubtags to Maximize following ECMA402 Intl.Locale convention. r=jfkthame Differential Revision: https://phabricator.services.mozilla.com/D63561
Cargo.lock
dom/base/nsLineBreaker.cpp
intl/locale/MozLocale.cpp
intl/locale/MozLocale.h
intl/locale/nsLanguageAtomService.cpp
intl/locale/rust/unic-langid-ffi/src/lib.rs
intl/locale/windows/OSPreferences_win.cpp
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1267,16 +1267,17 @@ dependencies = [
 name = "fluent-langneg-ffi"
 version = "0.1.0"
 dependencies = [
  "fluent-langneg",
  "nserror",
  "nsstring",
  "thin-vec",
  "unic-langid",
+ "unic-langid-ffi",
  "xpcom",
 ]
 
 [[package]]
 name = "fnv"
 version = "1.0.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
--- a/dom/base/nsLineBreaker.cpp
+++ b/dom/base/nsLineBreaker.cpp
@@ -462,17 +462,17 @@ nsresult nsLineBreaker::AppendText(nsAto
 void nsLineBreaker::UpdateCurrentWordLanguage(nsAtom* aHyphenationLanguage) {
   if (mCurrentWordLanguage && mCurrentWordLanguage != aHyphenationLanguage) {
     mCurrentWordContainsMixedLang = true;
     mScriptIsChineseOrJapanese = false;
   } else {
     if (aHyphenationLanguage && !mCurrentWordLanguage) {
       Locale loc = Locale(nsAtomCString(aHyphenationLanguage));
       if (loc.GetScript().IsEmpty()) {
-        loc.AddLikelySubtags();
+        loc.Maximize();
       }
       const nsDependentCSubstring& script = loc.GetScript();
       mScriptIsChineseOrJapanese =
           script.EqualsLiteral("Hans") || script.EqualsLiteral("Hant") ||
           script.EqualsLiteral("Jpan") || script.EqualsLiteral("Hrkt");
     }
     mCurrentWordLanguage = aHyphenationLanguage;
   }
--- a/intl/locale/MozLocale.cpp
+++ b/intl/locale/MozLocale.cpp
@@ -47,15 +47,13 @@ bool Locale::Matches(const Locale& aOthe
                      bool aOtherRange) const {
   if (!IsWellFormed() || !aOther.IsWellFormed()) {
     return false;
   }
 
   return unic_langid_matches(mRaw.get(), aOther.Raw(), aThisRange, aOtherRange);
 }
 
-bool Locale::AddLikelySubtags() {
-  return unic_langid_add_likely_subtags(mRaw.get());
-}
+bool Locale::Maximize() { return unic_langid_maximize(mRaw.get()); }
 
 void Locale::ClearVariants() { unic_langid_clear_variants(mRaw.get()); }
 
 void Locale::ClearRegion() { unic_langid_clear_region(mRaw.get()); }
--- a/intl/locale/MozLocale.h
+++ b/intl/locale/MozLocale.h
@@ -105,19 +105,19 @@ class Locale {
   bool Matches(const Locale& aOther, bool aThisRange, bool aOtherRange) const;
 
   /**
    * This operation uses CLDR data to build a more specific version
    * of a generic locale.
    *
    * Example:
    *
-   * Locale("en").AddLikelySubtags().AsString(); // "en-Latn-US"
+   * Locale("en").Maximize().AsString(); // "en-Latn-US"
    */
-  bool AddLikelySubtags();
+  bool Maximize();
 
   /**
    * Clears the variants field of the Locale object.
    */
   void ClearVariants();
 
   /**
    * Clears the region field of the Locale object.
--- a/intl/locale/nsLanguageAtomService.cpp
+++ b/intl/locale/nsLanguageAtomService.cpp
@@ -170,17 +170,17 @@ nsStaticAtom* nsLanguageAtomService::Get
       }
     }
   } else {
     // If the lang code can be parsed as BCP47, look up its (likely) script
     Locale loc(langStr);
     if (loc.IsWellFormed()) {
       // Fill in script subtag if not present.
       if (loc.GetScript().IsEmpty()) {
-        loc.AddLikelySubtags();
+        loc.Maximize();
       }
       // Traditional Chinese has separate prefs for Hong Kong / Taiwan;
       // check the region subtag.
       if (loc.GetScript().EqualsLiteral("Hant")) {
         if (loc.GetRegion().EqualsLiteral("HK")) {
           return nsGkAtoms::HongKongChinese;
         }
         return nsGkAtoms::Taiwanese;
--- a/intl/locale/rust/unic-langid-ffi/src/lib.rs
+++ b/intl/locale/rust/unic-langid-ffi/src/lib.rs
@@ -154,11 +154,11 @@ pub unsafe extern "C" fn unic_langid_mat
     other: &LanguageIdentifier,
     self_as_range: bool,
     other_as_range: bool,
 ) -> bool {
     langid.matches(other, self_as_range, other_as_range)
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn unic_langid_add_likely_subtags(langid: &mut LanguageIdentifier) -> bool {
+pub unsafe extern "C" fn unic_langid_maximize(langid: &mut LanguageIdentifier) -> bool {
     langid.maximize()
 }
--- a/intl/locale/windows/OSPreferences_win.cpp
+++ b/intl/locale/windows/OSPreferences_win.cpp
@@ -61,21 +61,20 @@ bool OSPreferences::ReadSystemLocales(ns
             const wchar_t* text = lang.GetRawBuffer(&length);
             NS_LossyConvertUTF16toASCII loc(text, length);
             if (CanonicalizeLanguageTag(loc)) {
               if (!loc.Contains('-')) {
                 // DirectWrite font-name code doesn't like to be given a bare
                 // language code with no region subtag, but the
                 // GlobalizationPreferences API may give us one (e.g. "ja").
                 // So if there's no hyphen in the string at this point, we use
-                // Locale::AddLikelySubtags to get a suitable region code to
+                // Locale::Maximize to get a suitable region code to
                 // go with it.
                 Locale locale(loc);
-                if (locale.AddLikelySubtags() &&
-                    !locale.GetRegion().IsEmpty()) {
+                if (locale.Maximize() && !locale.GetRegion().IsEmpty()) {
                   loc.Append('-');
                   loc.Append(locale.GetRegion());
                 }
               }
               aLocaleList.AppendElement(loc);
             }
           }
         }