From 2c5ee7ad68feb35499b112924b1b18e556acc58a Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Sat, 10 Sep 2005 11:14:48 +0000 Subject: [PATCH] Caret drawn at incorrect position after typing a single LTR character in a blank RTL input field (or vice versa) while caret is visible. b=307533 r=uriber sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@179957 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCaret.cpp | 34 +++++++++++++++++++-------------- mozilla/layout/base/nsCaret.h | 3 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 57538b0387b..e7802e7f771 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -100,6 +100,7 @@ nsCaret::nsCaret() , mLastContentOffset(0) , mLastHint(nsIFrameSelection::HINTLEFT) #ifdef IBMBIDI +, mLastBidiLevel(0) , mKeyboardRTL(PR_FALSE) #endif { @@ -534,22 +535,27 @@ nsCaret::DrawAtPositionWithHint(nsIDOMNode* aNode, nsPresContext *presContext = presShell->GetPresContext(); if (presContext && presContext->BidiEnabled()) { - presShell->GetCaretBidiLevel(&bidiLevel); - if (bidiLevel & BIDI_LEVEL_UNDEFINED) - { - PRUint8 newBidiLevel; - bidiLevel &= ~BIDI_LEVEL_UNDEFINED; - // There has been a reflow, so we reset the cursor Bidi level to the level of the current frame - if (!presContext) // Use the style default or default to 0 + if (mDrawn) { + bidiLevel = mLastBidiLevel; + } else { + presShell->GetCaretBidiLevel(&bidiLevel); + if (bidiLevel & BIDI_LEVEL_UNDEFINED) { - newBidiLevel = theFrame->GetStyleVisibility()->mDirection; - } - else - { - newBidiLevel = NS_GET_EMBEDDING_LEVEL(theFrame); - presShell->SetCaretBidiLevel(newBidiLevel); - bidiLevel = newBidiLevel; + PRUint8 newBidiLevel; + bidiLevel &= ~BIDI_LEVEL_UNDEFINED; + // There has been a reflow, so we reset the cursor Bidi level to the level of the current frame + if (!presContext) // Use the style default or default to 0 + { + newBidiLevel = theFrame->GetStyleVisibility()->mDirection; + } + else + { + newBidiLevel = NS_GET_EMBEDDING_LEVEL(theFrame); + presShell->SetCaretBidiLevel(newBidiLevel); + bidiLevel = newBidiLevel; + } } + mLastBidiLevel = bidiLevel; } PRInt32 start; diff --git a/mozilla/layout/base/nsCaret.h b/mozilla/layout/base/nsCaret.h index ff5b97dcc9a..21815f7b6de 100644 --- a/mozilla/layout/base/nsCaret.h +++ b/mozilla/layout/base/nsCaret.h @@ -121,10 +121,11 @@ protected: nsCOMPtr mLastContent; // store the content the caret was last requested to be drawn in (by DrawAtPosition()/DrawCaret()), // note that this can be different than where it was actually drawn (anon
in text control) PRInt32 mLastContentOffset; // the offset for the last request - nsIFrameSelection::HINT mLastHint; // the hint associated with the last request + nsIFrameSelection::HINT mLastHint; // the hint associated with the last request, see also mLastBidiLevel below #ifdef IBMBIDI nsRect mHookRect; // directional hook on the caret nsCOMPtr mBidiKeyboard; // Bidi keyboard object to set and query keyboard language + 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 };