diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index 93467ed92ca8..cf0d67a21b7b 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -660,6 +660,14 @@ function Startup() gClickSelectsAll = pref.getBoolPref("browser.urlbar.clickSelectsAll"); gClickAtEndSelects = pref.getBoolPref("browser.urlbar.clickAtEndSelects"); + // BiDi UI + gShowBiDi = isBidiEnabled(); + if (gShowBiDi) { + document.getElementById("documentDirection-swap").hidden = false; + document.getElementById("textfieldDirection-separator").hidden = false; + document.getElementById("textfieldDirection-swap").hidden = false; + } + // now load bookmarks after a delay setTimeout(LoadBookmarksCallback, 0); } @@ -2507,3 +2515,47 @@ function updateFileUploadItem() else item.setAttribute('disabled', 'true'); } + +function isBidiEnabled() +{ + var rv = false; + + var systemLocale; + try { + var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"] + .getService(Components.interfaces.nsILocaleService); + systemLocale = localeService.getSystemLocale().getCategory("NSILOCALE_CTYPE"); + rv = /^(he|ar|syr|fa|ur)-/.test(systemLocale); + } catch (e) {} + + if (!rv) { + // check the overriding pref + try { + rv = pref.getBoolPref("bidi.browser.ui"); + } + catch (e) {} + } + + return rv; +} + +function SwitchDocumentDirection(aWindow) +{ + aWindow.document.dir = (aWindow.document.dir == "ltr" ? "rtl" : "ltr"); + + for (var run = 0; run < aWindow.frames.length; run++) + SwitchDocumentDirection(aWindow.frames[run]); +} + +function SwitchFocusedTextEntryDirection() +{ + // The keybinding shoudn't work if the menu item is hidden + if (gShowBiDi) { + var focusedElement = document.commandDispatcher.focusedElement; + if (focusedElement) + if (window.getComputedStyle(focusedElement, "").direction == "ltr") + focusedElement.style.direction = "rtl"; + else + focusedElement.style.direction = "ltr"; + } +} diff --git a/xpfe/browser/resources/content/navigatorOverlay.xul b/xpfe/browser/resources/content/navigatorOverlay.xul index c53be6afab6d..e56fbeafb8c7 100644 --- a/xpfe/browser/resources/content/navigatorOverlay.xul +++ b/xpfe/browser/resources/content/navigatorOverlay.xul @@ -86,7 +86,11 @@ - + + @@ -154,6 +158,7 @@ + @@ -164,7 +169,8 @@ - + + @@ -374,6 +380,13 @@ +