From 05acd763f8e45276f923900ee21dcdf653374974 Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Mon, 29 Mar 2021 14:22:52 +0000 Subject: [PATCH] Bug 1676137 - Remove intl.uidirection pref; r=zbraniecki Differential Revision: https://phabricator.services.mozilla.com/D108789 --- browser/components/syncedtabs/SyncedTabsDeckComponent.js | 4 +--- dom/base/UIDirectionManager.cpp | 5 +---- intl/l10n/Localization.cpp | 7 ++----- intl/locale/LocaleService.cpp | 7 ------- intl/locale/LocaleService.h | 3 +-- intl/locale/tests/gtest/TestLocaleService.cpp | 6 ------ 6 files changed, 5 insertions(+), 27 deletions(-) diff --git a/browser/components/syncedtabs/SyncedTabsDeckComponent.js b/browser/components/syncedtabs/SyncedTabsDeckComponent.js index 5956c2bbb34b..e328a76d4f8f 100644 --- a/browser/components/syncedtabs/SyncedTabsDeckComponent.js +++ b/browser/components/syncedtabs/SyncedTabsDeckComponent.js @@ -99,7 +99,6 @@ SyncedTabsDeckComponent.prototype = { // Add app locale change support for HTML sidebar Services.obs.addObserver(this, "intl:app-locales-changed"); - Services.prefs.addObserver("intl.uidirection", this); Services.prefs.addObserver("intl.l10n.pseudo", this); this.updateDir(); @@ -125,7 +124,6 @@ SyncedTabsDeckComponent.prototype = { Services.obs.removeObserver(this, this._SyncedTabs.TOPIC_TABS_CHANGED); Services.obs.removeObserver(this, UIState.ON_UPDATE); Services.obs.removeObserver(this, "intl:app-locales-changed"); - Services.prefs.removeObserver("intl.uidirection", this); Services.prefs.removeObserver("intl.l10n.pseudo", this); this._deckView.destroy(); }, @@ -143,7 +141,7 @@ SyncedTabsDeckComponent.prototype = { this.updateDir(); break; case "nsPref:changed": - if (data == "intl.uidirection" || data == "intl.l10n.pseudo") { + if (data == "intl.l10n.pseudo") { this.updateDir(); } break; diff --git a/dom/base/UIDirectionManager.cpp b/dom/base/UIDirectionManager.cpp index 8b738e24de32..a54c42c748b2 100644 --- a/dom/base/UIDirectionManager.cpp +++ b/dom/base/UIDirectionManager.cpp @@ -49,15 +49,12 @@ void OnPrefChange(const char* aPrefName, void*) { /* static */ void UIDirectionManager::Initialize() { DebugOnly rv = - Preferences::RegisterCallback(OnPrefChange, "intl.uidirection"); - MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"intl.uidirection\""); - rv = Preferences::RegisterCallback(OnPrefChange, "intl.l10n.pseudo"); + Preferences::RegisterCallback(OnPrefChange, "intl.l10n.pseudo"); MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"intl.l10n.pseudo\""); } /* static */ void UIDirectionManager::Shutdown() { - Preferences::UnregisterCallback(OnPrefChange, "intl.uidirection"); Preferences::UnregisterCallback(OnPrefChange, "intl.l10n.pseudo"); } diff --git a/intl/l10n/Localization.cpp b/intl/l10n/Localization.cpp index bc3f133f1a0c..23cfbb1f3ba1 100644 --- a/intl/l10n/Localization.cpp +++ b/intl/l10n/Localization.cpp @@ -15,10 +15,8 @@ #define INTL_APP_LOCALES_CHANGED "intl:app-locales-changed" #define L10N_PSEUDO_PREF "intl.l10n.pseudo" -#define INTL_UI_DIRECTION_PREF "intl.uidirection" -static const char* kObservedPrefs[] = {L10N_PSEUDO_PREF, INTL_UI_DIRECTION_PREF, - nullptr}; +static const char* kObservedPrefs[] = {L10N_PSEUDO_PREF, nullptr}; using namespace mozilla::intl; using namespace mozilla::dom; @@ -172,8 +170,7 @@ Localization::Observe(nsISupports* aSubject, const char* aTopic, } else { MOZ_ASSERT(!strcmp("nsPref:changed", aTopic)); nsDependentString pref(aData); - if (pref.EqualsLiteral(L10N_PSEUDO_PREF) || - pref.EqualsLiteral(INTL_UI_DIRECTION_PREF)) { + if (pref.EqualsLiteral(L10N_PSEUDO_PREF)) { OnChange(); } } diff --git a/intl/locale/LocaleService.cpp b/intl/locale/LocaleService.cpp index d8b629787770..022d41cab2e2 100644 --- a/intl/locale/LocaleService.cpp +++ b/intl/locale/LocaleService.cpp @@ -243,13 +243,6 @@ bool LocaleService::IsLocaleRTL(const nsACString& aLocale) { } bool LocaleService::IsAppLocaleRTL() { - // First, let's check if there's a manual override - // preference for directionality set. - int pref = Preferences::GetInt("intl.uidirection", -1); - if (pref >= 0) { - return (pref > 0); - } - // Next, check if there is a pseudo locale `bidi` set. nsAutoCString pseudoLocale; if (NS_SUCCEEDED(Preferences::GetCString("intl.l10n.pseudo", pseudoLocale))) { diff --git a/intl/locale/LocaleService.h b/intl/locale/LocaleService.h index b3c2e575c0c6..919b55c5d5d7 100644 --- a/intl/locale/LocaleService.h +++ b/intl/locale/LocaleService.h @@ -163,9 +163,8 @@ class LocaleService final : public mozILocaleService, /** * Returns whether the current app locale is RTL. * - * This method respects two overrides: + * This method respects this override: * - `intl.l10n.pseudo` - * - `intl.uidirection` */ bool IsAppLocaleRTL(); diff --git a/intl/locale/tests/gtest/TestLocaleService.cpp b/intl/locale/tests/gtest/TestLocaleService.cpp index 32bdff61d60c..ddb811417ba3 100644 --- a/intl/locale/tests/gtest/TestLocaleService.cpp +++ b/intl/locale/tests/gtest/TestLocaleService.cpp @@ -145,10 +145,4 @@ TEST(Intl_Locale_LocaleService, IsAppLocaleRTL) mozilla::Preferences::SetCString("intl.l10n.pseudo", "bidi"); ASSERT_TRUE(LocaleService::GetInstance()->IsAppLocaleRTL()); mozilla::Preferences::ClearUser("intl.l10n.pseudo"); - - mozilla::Preferences::SetInt("intl.uidirection", 0); - ASSERT_FALSE(LocaleService::GetInstance()->IsAppLocaleRTL()); - mozilla::Preferences::SetInt("intl.uidirection", 1); - ASSERT_TRUE(LocaleService::GetInstance()->IsAppLocaleRTL()); - mozilla::Preferences::SetInt("intl.uidirection", -1); }