Bug 1463884 - Part 2: Remove always-true argument aCheckEnvironment from gfxFcPlatformFontList::GetSampleLangForGroup. r=emilio, a=RyanVM
authorJonathan Kew <jkew@mozilla.com>
Mon, 28 May 2018 10:09:25 +0100
changeset 802279 5755188b40c5d312d59bacda773251d8ef34d267
parent 802278 cbe2ef9e7e4a7cb522ef9810bf79aeca628b1804
child 802280 42be6252c7370b23fc143f6e4f4a6898748d822b
push id111850
push userbmo:tom@mozilla.com
push dateThu, 31 May 2018 16:41:37 +0000
reviewersemilio, RyanVM
bugs1463884
milestone60.0.2
Bug 1463884 - Part 2: Remove always-true argument aCheckEnvironment from gfxFcPlatformFontList::GetSampleLangForGroup. r=emilio, a=RyanVM
gfx/thebes/gfxFcPlatformFontList.cpp
gfx/thebes/gfxFcPlatformFontList.h
--- a/gfx/thebes/gfxFcPlatformFontList.cpp
+++ b/gfx/thebes/gfxFcPlatformFontList.cpp
@@ -2432,18 +2432,17 @@ gfxFcPlatformFontList::TryLangForGroup(c
     }
 
     nsAtom *atom = mLangService->LookupLanguage(aFcLang);
     return atom == aLangGroup;
 }
 
 void
 gfxFcPlatformFontList::GetSampleLangForGroup(nsAtom* aLanguage,
-                                             nsACString& aLangStr,
-                                             bool aCheckEnvironment)
+                                             nsACString& aLangStr)
 {
     aLangStr.Truncate();
     if (!aLanguage) {
         return;
     }
 
     // set up lang string
     const MozLangGroupData *mozLangGroup = nullptr;
@@ -2462,42 +2461,40 @@ gfxFcPlatformFontList::GetSampleLangForG
         // Not a special mozilla language group.
         // Use aLanguage as a language code.
         aLanguage->ToUTF8String(aLangStr);
         return;
     }
 
     // -- check the environment for the user's preferred language that
     //    corresponds to this mozilla lang group.
-    if (aCheckEnvironment) {
-        const char *languages = getenv("LANGUAGE");
-        if (languages) {
-            const char separator = ':';
+    const char *languages = getenv("LANGUAGE");
+    if (languages) {
+        const char separator = ':';
 
-            for (const char *pos = languages; true; ++pos) {
-                if (*pos == '\0' || *pos == separator) {
-                    if (languages < pos &&
-                        TryLangForGroup(Substring(languages, pos),
-                                        aLanguage, aLangStr)) {
-                        return;
-                    }
+        for (const char *pos = languages; true; ++pos) {
+            if (*pos == '\0' || *pos == separator) {
+                if (languages < pos &&
+                    TryLangForGroup(Substring(languages, pos),
+                                    aLanguage, aLangStr)) {
+                    return;
+                }
 
-                    if (*pos == '\0') {
-                        break;
-                    }
+                if (*pos == '\0') {
+                    break;
+                }
 
-                    languages = pos + 1;
-                }
+                languages = pos + 1;
             }
         }
-        const char *ctype = setlocale(LC_CTYPE, nullptr);
-        if (ctype &&
-            TryLangForGroup(nsDependentCString(ctype), aLanguage, aLangStr)) {
-            return;
-        }
+    }
+    const char *ctype = setlocale(LC_CTYPE, nullptr);
+    if (ctype &&
+        TryLangForGroup(nsDependentCString(ctype), aLanguage, aLangStr)) {
+        return;
     }
 
     if (mozLangGroup->defaultLang) {
         aLangStr.Assign(mozLangGroup->defaultLang);
     } else {
         aLangStr.Truncate();
     }
 }
--- a/gfx/thebes/gfxFcPlatformFontList.h
+++ b/gfx/thebes/gfxFcPlatformFontList.h
@@ -316,18 +316,17 @@ public:
     void ClearLangGroupPrefFonts() override;
 
     // clear out cached generic-lang ==> family-list mappings
     void ClearGenericMappings() {
         mGenericMappings.Clear();
     }
 
     // map lang group ==> lang string
-    void GetSampleLangForGroup(nsAtom* aLanguage, nsACString& aLangStr,
-                               bool aCheckEnvironment = true);
+    void GetSampleLangForGroup(nsAtom* aLanguage, nsACString& aLangStr);
 
     static FT_Library GetFTLibrary();
 
 protected:
     virtual ~gfxFcPlatformFontList();
 
 #ifdef MOZ_CONTENT_SANDBOX
     typedef mozilla::SandboxBroker::Policy SandboxPolicy;