mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Backed out changeset c7174ac72d14 (bug 1347272) for build bustage
--HG-- extra : amend_source : b4f3d5997190ce3db799e3586131cc3cb9ce034d
This commit is contained in:
parent
229fe1f890
commit
394f455b8e
@ -670,13 +670,33 @@ function isBidiEnabled() {
|
||||
if (getBoolPref("bidi.browser.ui", false))
|
||||
return true;
|
||||
|
||||
// now see if the app locale is an RTL one.
|
||||
const isRTL = Services.locale.isAppLocaleRTL;
|
||||
// then check intl.uidirection.<locale>
|
||||
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"].
|
||||
getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
if (chromeReg.isLocaleRTL("global"))
|
||||
return true;
|
||||
|
||||
if (isRTL) {
|
||||
Services.prefs.setBoolPref("bidi.browser.ui", true);
|
||||
}
|
||||
return isRTL;
|
||||
// now see if the system locale is an RTL one.
|
||||
var rv = false;
|
||||
|
||||
try {
|
||||
var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
|
||||
.getService(Components.interfaces.nsILocaleService);
|
||||
var systemLocale = localeService.getSystemLocale().getCategory("NSILOCALE_CTYPE").substr(0, 3);
|
||||
|
||||
switch (systemLocale) {
|
||||
case "ar-":
|
||||
case "he-":
|
||||
case "fa-":
|
||||
case "ug-":
|
||||
case "ur-":
|
||||
case "syr":
|
||||
rv = true;
|
||||
Services.prefs.setBoolPref("bidi.browser.ui", true);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
function openAboutDialog() {
|
||||
|
@ -230,7 +230,9 @@ Converter.prototype = {
|
||||
os = "linux";
|
||||
}
|
||||
|
||||
let dir = Services.locale.isAppLocaleRTL ? "rtl" : "ltr";
|
||||
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIXULChromeRegistry);
|
||||
let dir = chromeReg.isLocaleRTL("global") ? "rtl" : "ltr";
|
||||
|
||||
return "<!DOCTYPE html>\n" +
|
||||
"<html platform=\"" + os + "\" class=\"" + themeClassName +
|
||||
@ -266,7 +268,9 @@ Converter.prototype = {
|
||||
output += "</div><div id=\"json\">" + this.highlightError(data,
|
||||
errorInfo.line, errorInfo.column) + "</div>";
|
||||
|
||||
let dir = Services.locale.isAppLocaleRTL ? "rtl" : "ltr";
|
||||
let chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIXULChromeRegistry);
|
||||
let dir = chromeReg.isLocaleRTL("global") ? "rtl" : "ltr";
|
||||
|
||||
return "<!DOCTYPE html>\n" +
|
||||
"<html><head><title>" + this.htmlEncode(uri + " - Error") + "</title>" +
|
||||
|
@ -43,8 +43,7 @@ mozilla::StaticRefPtr<LocaleService> LocaleService::sInstance;
|
||||
* The BCP47 form should be used for all calls to ICU/Intl APIs.
|
||||
* The canonical form is used for all internal operations.
|
||||
*/
|
||||
static void
|
||||
SanitizeForBCP47(nsACString& aLocale)
|
||||
static void SanitizeForBCP47(nsACString& aLocale)
|
||||
{
|
||||
#ifdef ENABLE_INTL_API
|
||||
// Currently, the only locale code we use that's not BCP47-conformant is
|
||||
@ -397,35 +396,6 @@ LocaleService::NegotiateLanguages(const nsTArray<nsCString>& aRequested,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
LocaleService::IsAppLocaleRTL()
|
||||
{
|
||||
nsAutoCString locale;
|
||||
GetAppLocaleAsBCP47(locale);
|
||||
|
||||
#ifdef ENABLE_INTL_API
|
||||
int pref = Preferences::GetInt("intl.uidirection", -1);
|
||||
if (pref >= 0) {
|
||||
return (pref > 0);
|
||||
}
|
||||
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 dir;
|
||||
Preferences::GetCString(prefString.get(), &dir);
|
||||
if (dir.IsEmpty()) {
|
||||
int32_t hyphen = prefString.FindChar('-');
|
||||
if (hyphen >= 1) {
|
||||
prefString.Truncate(hyphen);
|
||||
Preferences::GetCString(prefString.get(), &dir);
|
||||
}
|
||||
}
|
||||
return dir.EqualsLiteral("rtl");
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocaleService::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
const char16_t *aData)
|
||||
@ -752,12 +722,6 @@ LocaleService::GetAvailableLocales(uint32_t* aCount, char*** aOutArray)
|
||||
|
||||
*aCount = availableLocales.Length();
|
||||
*aOutArray = CreateOutArray(availableLocales);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocaleService::GetIsAppLocaleRTL(bool* aRetVal)
|
||||
{
|
||||
(*aRetVal) = IsAppLocaleRTL();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -167,11 +167,6 @@ public:
|
||||
LangNegStrategy aLangNegStrategy,
|
||||
nsTArray<nsCString>& aRetVal);
|
||||
|
||||
/**
|
||||
* Returns whether the current app locale is RTL.
|
||||
*/
|
||||
bool IsAppLocaleRTL();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Locale object, a BCP47-style tag decomposed into subtags for
|
||||
|
@ -172,9 +172,4 @@ interface mozILocaleService : nsISupports
|
||||
*/
|
||||
void getAvailableLocales([optional] out unsigned long aCount,
|
||||
[retval, array, size_is(aCount)] out string aLocales);
|
||||
|
||||
/**
|
||||
* Returns whether the current app locale is RTL.
|
||||
*/
|
||||
readonly attribute boolean isAppLocaleRTL;
|
||||
};
|
||||
|
@ -57,10 +57,3 @@ TEST(Intl_Locale_LocaleService, GetAppLocaleAsLangTag) {
|
||||
|
||||
ASSERT_TRUE(appLocales[0] == locale);
|
||||
}
|
||||
|
||||
TEST(Intl_Locale_LocaleService, IsAppLocaleRTL) {
|
||||
// For now we can only test if the method doesn't crash.
|
||||
LocaleService::GetInstance()->IsAppLocaleRTL();
|
||||
ASSERT_TRUE(true);
|
||||
|
||||
}
|
||||
|
@ -131,12 +131,6 @@ add_test(function test_setRequestedLocales() {
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
add_test(function test_isAppLocaleRTL() {
|
||||
do_check_true(typeof localeService.isAppLocaleRTL === 'boolean');
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
do_register_cleanup(() => {
|
||||
Services.prefs.clearUserPref(PREF_SELECTED_LOCALE);
|
||||
Services.prefs.clearUserPref(PREF_MATCH_OS_LOCALE);
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "DateTimeFormat.h"
|
||||
#include "nsIndexedToHTML.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "netCore.h"
|
||||
#include "nsStringStream.h"
|
||||
@ -19,14 +18,13 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsITextToSubURI.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include <algorithm>
|
||||
#include "nsIChannel.h"
|
||||
|
||||
using mozilla::intl::LocaleService;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsIndexedToHTML,
|
||||
nsIDirIndexListener,
|
||||
nsIStreamConverter,
|
||||
@ -564,8 +562,14 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
|
||||
}
|
||||
|
||||
nsCString direction(NS_LITERAL_CSTRING("ltr"));
|
||||
if (LocaleService::GetInstance()->IsAppLocaleRTL()) {
|
||||
direction.AssignLiteral("rtl");
|
||||
nsCOMPtr<nsIXULChromeRegistry> reg =
|
||||
mozilla::services::GetXULChromeRegistryService();
|
||||
if (reg) {
|
||||
bool isRTL = false;
|
||||
reg->IsLocaleRTL(NS_LITERAL_CSTRING("global"), &isRTL);
|
||||
if (isRTL) {
|
||||
direction.AssignLiteral("rtl");
|
||||
}
|
||||
}
|
||||
|
||||
buffer.AppendLiteral("</head>\n<body dir=\"");
|
||||
|
@ -630,7 +630,8 @@ LocaleData.prototype = {
|
||||
if (message == "@@ui_locale") {
|
||||
return this.uiLocale;
|
||||
} else if (message.startsWith("@@bidi_")) {
|
||||
let rtl = Services.locale.isAppLocaleRTL;
|
||||
let registry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
|
||||
let rtl = registry.isLocaleRTL("global");
|
||||
|
||||
if (message == "@@bidi_dir") {
|
||||
return rtl ? "rtl" : "ltr";
|
||||
|
@ -17,6 +17,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "NarrateControls", "resource://gre/modul
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Rect", "resource://gre/modules/Geometry.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry", "resource://gre/modules/UITelemetry.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gChromeRegistry",
|
||||
"@mozilla.org/chrome/chrome-registry;1", Ci.nsIXULChromeRegistry);
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
var gStrings = Services.strings.createBundle("chrome://global/locale/aboutReader.properties");
|
||||
@ -731,7 +733,7 @@ AboutReader.prototype = {
|
||||
this._headerElement.setAttribute("dir", article.dir);
|
||||
|
||||
// The native locale could be set differently than the article's text direction.
|
||||
var localeDirection = Services.locale.isAppLocaleRTL ? "rtl" : "ltr";
|
||||
var localeDirection = gChromeRegistry.isLocaleRTL("global") ? "rtl" : "ltr";
|
||||
this._readTimeElement.setAttribute("dir", localeDirection);
|
||||
this._readTimeElement.style.textAlign = article.dir == "rtl" ? "right" : "left";
|
||||
}
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWindowlessBrowser.h"
|
||||
@ -39,7 +40,6 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StartupTimeline.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
|
||||
#include "nsEmbedCID.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
@ -50,7 +50,6 @@
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using mozilla::intl::LocaleService;
|
||||
|
||||
// Default URL for the hidden window, can be overridden by a pref on Mac
|
||||
#define DEFAULT_HIDDENWINDOW_URL "resource://gre-resources/hiddenWindow.html"
|
||||
@ -721,7 +720,15 @@ nsAppShellService::JustCreateTopWindow(nsIXULWindow *aParent,
|
||||
|
||||
bool center = aChromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN;
|
||||
|
||||
widgetInitData.mRTL = LocaleService::GetInstance()->IsAppLocaleRTL();
|
||||
nsCOMPtr<nsIXULChromeRegistry> reg =
|
||||
mozilla::services::GetXULChromeRegistryService();
|
||||
if (reg) {
|
||||
nsAutoCString package;
|
||||
package.AssignLiteral("global");
|
||||
bool isRTL = false;
|
||||
reg->IsLocaleRTL(package, &isRTL);
|
||||
widgetInitData.mRTL = isRTL;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// B2G multi-screen support. Screen ID is for differentiating screens of
|
||||
|
Loading…
Reference in New Issue
Block a user