Skip to content

Commit

Permalink
Bug 1616912 - Remove unused locale related code from nsChromeRegistry…
Browse files Browse the repository at this point in the history
…. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D63523

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Zibi Braniecki committed Feb 22, 2020
1 parent 809eeb5 commit 4bef3a1
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 91 deletions.
19 changes: 0 additions & 19 deletions chrome/nsChromeRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/dom/Location.h"

#include "unicode/uloc.h"

nsChromeRegistry* nsChromeRegistry::gChromeRegistry;

// DO NOT use namespace mozilla; it'll break due to a naming conflict between
Expand Down Expand Up @@ -391,20 +389,3 @@ already_AddRefed<nsChromeRegistry> nsChromeRegistry::GetSingleton() {

return cr.forget();
}

void nsChromeRegistry::SanitizeForBCP47(nsACString& aLocale) {
// Currently, the only locale code we use that's not BCP47-conformant is
// "ja-JP-mac" on OS X, but let's try to be more general than just
// hard-coding that here.
const int32_t LANG_TAG_CAPACITY = 128;
char langTag[LANG_TAG_CAPACITY];
nsAutoCString locale(aLocale);
UErrorCode err = U_ZERO_ERROR;
// This is a fail-safe method that will set langTag to "und" if it cannot
// match any part of the input locale code.
int32_t len =
uloc_toLanguageTag(locale.get(), langTag, LANG_TAG_CAPACITY, false, &err);
if (U_SUCCESS(err) && len > 0) {
aLocale.Assign(langTag, len);
}
}
2 changes: 0 additions & 2 deletions chrome/nsChromeRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class nsChromeRegistry : public nsIToolkitChromeRegistry,
static nsresult GetProviderAndPath(nsIURI* aChromeURL, nsACString& aProvider,
nsACString& aPath);

void SanitizeForBCP47(nsACString& aLocale);

public:
static already_AddRefed<nsChromeRegistry> GetSingleton();

Expand Down
7 changes: 1 addition & 6 deletions chrome/nsChromeRegistryChrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ nsChromeRegistryChrome::IsLocaleRTL(const nsACString& package, bool* aResult) {
*aResult = false;

nsAutoCString locale;
GetSelectedLocale(package, false, locale);
GetSelectedLocale(package, locale);
if (locale.Length() < 2) return NS_OK;

*aResult = LocaleService::IsLocaleRTL(locale);
Expand All @@ -146,7 +146,6 @@ nsChromeRegistryChrome::IsLocaleRTL(const nsACString& package, bool* aResult) {
* LocaleService::GetAppLocaleAsBCP47.
*/
nsresult nsChromeRegistryChrome::GetSelectedLocale(const nsACString& aPackage,
bool aAsBCP47,
nsACString& aLocale) {
nsAutoCString reqLocale;
if (aPackage.EqualsLiteral("global")) {
Expand All @@ -166,10 +165,6 @@ nsresult nsChromeRegistryChrome::GetSelectedLocale(const nsACString& aPackage,
aLocale = entry->locales.GetSelected(reqLocale, nsProviderArray::LOCALE);
if (aLocale.IsEmpty()) return NS_ERROR_FAILURE;

if (aAsBCP47) {
SanitizeForBCP47(aLocale);
}

return NS_OK;
}

Expand Down
3 changes: 1 addition & 2 deletions chrome/nsChromeRegistryChrome.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class nsChromeRegistryChrome : public nsChromeRegistry {
NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
nsIUTF8StringEnumerator** aResult) override;
NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;
NS_IMETHOD GetSelectedLocale(const nsACString& aPackage, bool aAsBCP47,
nsACString& aLocale) override;
nsresult GetSelectedLocale(const nsACString& aPackage, nsACString& aLocale);
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* someData) override;

Expand Down
14 changes: 0 additions & 14 deletions chrome/nsChromeRegistryContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,6 @@ nsChromeRegistryContent::IsLocaleRTL(const nsACString& aPackage,
return NS_OK;
}

NS_IMETHODIMP
nsChromeRegistryContent::GetSelectedLocale(const nsACString& aPackage,
bool aAsBCP47, nsACString& aLocale) {
if (aPackage != nsDependentCString("global")) {
NS_ERROR("Uh-oh, caller wanted something other than 'some local'");
return NS_ERROR_NOT_AVAILABLE;
}
aLocale = mLocale;
if (aAsBCP47) {
SanitizeForBCP47(aLocale);
}
return NS_OK;
}

NS_IMETHODIMP
nsChromeRegistryContent::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
Expand Down
2 changes: 0 additions & 2 deletions chrome/nsChromeRegistryContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class nsChromeRegistryContent : public nsChromeRegistry {
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) override;
NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;
NS_IMETHOD GetSelectedLocale(const nsACString& aPackage, bool aAsBCP47,
nsACString& aLocale) override;

void RegisterPackage(const ChromePackage& aPackage);
void RegisterOverride(const OverrideMapping& aOverride);
Expand Down
7 changes: 0 additions & 7 deletions chrome/nsIChromeRegistry.idl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ interface nsIChromeRegistry : nsISupports
[scriptable, uuid(93251ddf-5e85-4172-ac2a-31780562974f)]
interface nsIXULChromeRegistry : nsIChromeRegistry
{
// If the optional asBCP47 parameter is true, the locale code will be
// converted to a BCP47 language tag; in particular, this means that
// "ja-JP-mac" will be returned as "ja-JP-x-lvariant-mac", which can be
// passed to ECMA402 Intl API methods without throwing a RangeError.
ACString getSelectedLocale(in ACString packageName,
[optional] in boolean asBCP47);

// Get whether the default writing direction of the locale is RTL
// (or may be overridden by intl.uidirection pref)
boolean isLocaleRTL(in ACString package);
Expand Down
38 changes: 0 additions & 38 deletions chrome/test/unit/test_bug848297.js

This file was deleted.

1 change: 0 additions & 1 deletion chrome/test/unit/xpcshell.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ support-files = data/**
[test_bug415367.js]
[test_bug564667.js]
tags = addons
[test_bug848297.js]
[test_crlf.js]
[test_data_protocol_registration.js]
[test_no_remote_registration.js]
Expand Down

0 comments on commit 4bef3a1

Please sign in to comment.