Bug 1676137 - Remove intl.uidirection pref; r=zbraniecki

Differential Revision: https://phabricator.services.mozilla.com/D108789
This commit is contained in:
Dan Minor 2021-03-29 14:22:52 +00:00
parent abe82c07a6
commit 05acd763f8
6 changed files with 5 additions and 27 deletions

View File

@ -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;

View File

@ -49,15 +49,12 @@ void OnPrefChange(const char* aPrefName, void*) {
/* static */
void UIDirectionManager::Initialize() {
DebugOnly<nsresult> 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");
}

View File

@ -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();
}
}

View File

@ -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))) {

View File

@ -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();

View File

@ -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);
}