Make display of the directional hook on the caret dependent on the bidi.browser.ui pref. Bug 418513, r=uriber, sr=roc (for core) r=mano, gavin.sharp (for browser)

This commit is contained in:
Simon Montagu 2008-12-14 01:05:39 -08:00
Родитель ab1d632490
Коммит 4a05d428b8
5 изменённых файлов: 27 добавлений и 26 удалений

Просмотреть файл

@ -552,10 +552,6 @@ pref("browser.preferences.animateFadeIn", false);
pref("browser.download.show_plugins_in_list", true);
pref("browser.download.hide_plugins_without_extensions", true);
// Setting this pref to |true| forces BiDi UI menu items and keyboard shortcuts
// to be exposed. By default, only expose it for bidi-associated system locales.
pref("bidi.browser.ui", false);
// Backspace and Shift+Backspace behavior
// 0 goes Back/Forward
// 1 act like PgUp/PgDown

Просмотреть файл

@ -352,6 +352,12 @@ function getShellService()
}
function isBidiEnabled() {
// first check the pref.
if (getBoolPref("browser.bidi.ui", false))
return true;
// if the pref isn't set, check for an RTL locale and force the pref to true
// if we find one.
var rv = false;
try {
@ -366,13 +372,12 @@ function isBidiEnabled() {
case "ur-":
case "syr":
rv = true;
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
pref.setBoolPref("bidi.browser.ui", true);
}
} catch (e) {}
// check the overriding pref
if (!rv)
rv = getBoolPref("bidi.browser.ui");
return rv;
}

Просмотреть файл

@ -163,6 +163,9 @@ nsresult nsCaret::Init(nsIPresShell *inPresShell)
{
StartBlinking();
}
#ifdef IBMBIDI
mBidiUI = nsContentUtils::GetBoolPref("bidi.browser.ui");
#endif
return NS_OK;
}
@ -757,8 +760,7 @@ nsCaret::GetCaretFrameForNodeOffset(nsIContent* aContentNode,
// NS_STYLE_DIRECTION_LTR : LTR or Default
// NS_STYLE_DIRECTION_RTL
// NS_STYLE_DIRECTION_INHERIT
nsPresContext *presContext = presShell->GetPresContext();
if (presContext && presContext->BidiEnabled())
if (mBidiUI)
{
// If there has been a reflow, take the caret Bidi level to be the level of the current frame
if (aBidiLevel & BIDI_LEVEL_UNDEFINED)
@ -1218,7 +1220,6 @@ nsresult nsCaret::UpdateHookRect(nsPresContext* aPresContext,
#ifdef IBMBIDI
// Simon -- make a hook to draw to the left or right of the caret to show keyboard language direction
PRBool bidiEnabled;
PRBool isCaretRTL=PR_FALSE;
nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();
if (!bidiKeyboard || NS_FAILED(bidiKeyboard->IsLangRTL(&isCaretRTL)))
@ -1226,14 +1227,7 @@ nsresult nsCaret::UpdateHookRect(nsPresContext* aPresContext,
// keyboard direction, or the user has no right-to-left keyboard
// installed, so we never draw the hook.
return NS_OK;
if (isCaretRTL)
{
bidiEnabled = PR_TRUE;
aPresContext->SetBidiEnabled();
}
else
bidiEnabled = aPresContext->BidiEnabled();
if (bidiEnabled)
if (mBidiUI)
{
if (isCaretRTL != mKeyboardRTL)
{

Просмотреть файл

@ -292,6 +292,14 @@ protected:
PRPackedBool mReadOnly; // it the caret in readonly state (draws differently)
PRPackedBool mShowDuringSelection; // show when text is selected
PRPackedBool mIgnoreUserModify;
#ifdef IBMBIDI
PRPackedBool mKeyboardRTL; // is the keyboard language right-to-left
PRPackedBool mBidiUI; // is bidi UI turned on
nsRect mHookRect; // directional hook on the caret
PRUint8 mLastBidiLevel; // saved bidi level of the last draw request, to use when we erase
#endif
nsRect mCaretRect; // the last caret rect, in the coodinates of the last frame.
nsCOMPtr<nsIContent> mLastContent; // store the content the caret was last requested to be drawn
@ -303,13 +311,6 @@ protected:
nsFrameSelection::HINT mLastHint; // the hint associated with the last request, see also
// mLastBidiLevel below
PRPackedBool mIgnoreUserModify;
#ifdef IBMBIDI
nsRect mHookRect; // directional hook on the caret
PRUint8 mLastBidiLevel; // saved bidi level of the last draw request, to use when we erase
PRPackedBool mKeyboardRTL; // is the keyboard language right-to-left
#endif
};
nsresult

Просмотреть файл

@ -1037,6 +1037,11 @@ pref("bidi.edit.delete_immediately", false);
// 2 = visual, but logical during selection
pref("bidi.edit.caret_movement_style", 2);
// Setting this pref to |true| forces Bidi UI menu items and keyboard shortcuts
// to be exposed, and enables the directional caret hook. By default, only
// expose it for bidi-associated system locales.
pref("bidi.browser.ui", false);
// used for double-click word selection behavior. Win will override.
pref("layout.word_select.eat_space_to_next_word", false);
pref("layout.word_select.stop_at_punctuation", true);