Bug 1402860 - Remove ENABLE_INTL_API conditional from nsChromeRegistry. r=smaug
--- a/chrome/nsChromeRegistry.cpp
+++ b/chrome/nsChromeRegistry.cpp
@@ -27,19 +27,17 @@
#include "nsIWindowMediator.h"
#include "nsIPrefService.h"
#include "mozilla/Preferences.h"
#include "mozilla/Printf.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/dom/Location.h"
-#ifdef ENABLE_INTL_API
#include "unicode/uloc.h"
-#endif
nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
// DO NOT use namespace mozilla; it'll break due to a naming conflict between
// mozilla::TextRange and a TextRange in OSX headers.
using mozilla::StyleSheet;
using mozilla::dom::IsChromeURI;
using mozilla::dom::Location;
@@ -633,46 +631,23 @@ nsChromeRegistry::MustLoadURLRemotely(ns
*aResult = !!(flags & REMOTE_REQUIRED);
}
return NS_OK;
}
bool
nsChromeRegistry::GetDirectionForLocale(const nsACString& aLocale)
{
-#ifdef ENABLE_INTL_API
int pref = mozilla::Preferences::GetInt("intl.uidirection", -1);
if (pref >= 0) {
return (pref > 0);
}
nsAutoCString locale(aLocale);
SanitizeForBCP47(locale);
return uloc_isRightToLeft(locale.get());
-#else
- // first check the intl.uidirection.<locale> preference, and if that is not
- // set, check the same preference but with just the first two characters of
- // the locale. If that isn't set, default to left-to-right.
- nsAutoCString prefString = NS_LITERAL_CSTRING("intl.uidirection.") + aLocale;
- nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID));
- if (!prefBranch) {
- return false;
- }
-
- nsCString dir;
- prefBranch->GetCharPref(prefString.get(), getter_Copies(dir));
- if (dir.IsEmpty()) {
- int32_t hyphen = prefString.FindChar('-');
- if (hyphen >= 1) {
- nsAutoCString shortPref(Substring(prefString, 0, hyphen));
- prefBranch->GetCharPref(shortPref.get(), getter_Copies(dir));
- }
- }
-
- return dir.EqualsLiteral("rtl");
-#endif
}
NS_IMETHODIMP_(bool)
nsChromeRegistry::WrappersEnabled(nsIURI *aURI)
{
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aURI));
if (!chromeURL)
return false;
@@ -710,33 +685,23 @@ nsChromeRegistry::GetSingleton()
return nullptr;
return cr.forget();
}
void
nsChromeRegistry::SanitizeForBCP47(nsACString& aLocale)
{
-#ifdef ENABLE_INTL_API
// 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);
}
-#else
- // This is only really needed for Intl API purposes, AFAIK,
- // so probably won't be used in a non-ENABLE_INTL_API build.
- // But let's fix up the single anomalous code we actually ship,
- // just in case:
- if (aLocale.EqualsLiteral("ja-JP-mac")) {
- aLocale.AssignLiteral("ja-JP");
- }
-#endif
}