Implemented bidi.edit.caret_movement_style pref, default is "visual, but logical during selection". bug=330175 r=smontagu sr=roc

This commit is contained in:
uriber%gmail.com 2006-04-08 14:45:48 +00:00
parent 0276ada6af
commit 22b463bc6d
5 changed files with 32 additions and 11 deletions

View File

@ -97,7 +97,8 @@ struct nsPeekOffsetStruct
PRBool aPreferLeft,
PRBool aJumpLines,
PRBool aScrollViewStop,
PRBool aIsKeyboardSelect)
PRBool aIsKeyboardSelect,
PRBool aVisual)
{
mShell=aShell;
mDesiredX=aDesiredX;
@ -109,6 +110,7 @@ struct nsPeekOffsetStruct
mJumpLines = aJumpLines;
mScrollViewStop = aScrollViewStop;
mIsKeyboardSelect = aIsKeyboardSelect;
mVisual = aVisual;
}
nsIPresShell *mShell;
nscoord mDesiredX;
@ -124,6 +126,7 @@ struct nsPeekOffsetStruct
PRBool mJumpLines;
PRBool mScrollViewStop;
PRBool mIsKeyboardSelect;
PRBool mVisual;
};
class nsIScrollableView;

View File

@ -2055,6 +2055,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
PR_TRUE,
aJumpLines,
PR_TRUE, //limit on scrolled views
PR_FALSE,
PR_FALSE);
rv = PeekOffset(aPresContext, &startpos);
if (NS_FAILED(rv))
@ -2069,6 +2070,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack,
PR_FALSE,
aJumpLines,
PR_TRUE, //limit on scrolled views
PR_FALSE,
PR_FALSE);
rv = PeekOffset(aPresContext, &endpos);
if (NS_FAILED(rv))
@ -4496,9 +4498,11 @@ nsFrame::GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *
nsIFrame *firstVisual;
nsIFrame *lastVisual;
result = it->CheckLineOrder(thisLine, &lineIsReordered, &firstVisual, &lastVisual);
if (NS_FAILED(result))
return result;
if (aPos->mVisual) {
result = it->CheckLineOrder(thisLine, &lineIsReordered, &firstVisual, &lastVisual);
if (NS_FAILED(result))
return result;
}
if (lineIsReordered) {
firstFrame = firstVisual;
@ -4575,10 +4579,12 @@ nsFrame::GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *
else
aPos->mStartOffset = -1;
#ifdef IBMBIDI
PRUint8 newLevel = NS_GET_EMBEDDING_LEVEL(traversedFrame);
PRUint8 newBaseLevel = NS_GET_BASE_LEVEL(traversedFrame);
if ((newLevel & 1) != (newBaseLevel & 1)) // The new frame is reverse-direction, go to the other end
aPos->mStartOffset = -1 - aPos->mStartOffset;
if (aPos->mVisual) {
PRUint8 newLevel = NS_GET_EMBEDDING_LEVEL(traversedFrame);
PRUint8 newBaseLevel = NS_GET_BASE_LEVEL(traversedFrame);
if ((newLevel & 1) != (newBaseLevel & 1)) // The new frame is reverse-direction, go to the other end
aPos->mStartOffset = -1 - aPos->mStartOffset;
}
#endif
aPos->mResultFrame = traversedFrame;
return NS_OK;

View File

@ -522,6 +522,8 @@ private:
PRPackedBool mMouseDownState; //for drag purposes
PRPackedBool mMouseDoubleDownState; //has the doubleclick down happened
PRPackedBool mDesiredXSet;
PRInt8 mCaretMovementStyle;
};
class nsSelectionIterator : public nsIBidirectionalEnumerator
@ -1260,6 +1262,7 @@ nsSelection::Init(nsIPresShell *aShell, nsIContent *aLimiter)
mDesiredXSet = PR_FALSE;
mLimiter = aLimiter;
mScrollView = nsnull;
mCaretMovementStyle = nsContentUtils::GetIntPref("bidi.edit.caret_movement_style", 2);
return NS_OK;
}
@ -1376,10 +1379,13 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinueSelection, nsSelection
nsCOMPtr<nsIDOMNode> parentNode;
nsPeekOffsetStruct pos;
PRBool visualMovement = mCaretMovementStyle == 1 ||
(mCaretMovementStyle == 2 && !aContinueSelection);
//set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking
//when we hit scrollable views. If no limiter then just let it go ahead
pos.SetData(mShell, desiredX, aAmount, eDirPrevious, offsetused, PR_FALSE,
PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_TRUE);
PR_TRUE, PR_TRUE, mLimiter != nsnull, PR_TRUE, visualMovement);
nsBidiLevel baseLevel = nsBidiPresUtils::GetFrameBaseLevel(frame);

View File

@ -4515,7 +4515,7 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
// one "on the left" - the first frame on the next
// line.
//
// Note:
// Note (for visual caret movement):
// eDirPrevious means 'left-then-up' if the containing block is LTR,
// 'right-then-up' if it is RTL.
// eDirNext means 'right-then-down' if the containing block is LTR,
@ -4524,7 +4524,8 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
// previous paragraph", and eDirNext means "go to the visual beginning of
// the next paragraph"
PRBool isReverseDirection = (NS_GET_EMBEDDING_LEVEL(this) & 1) != (NS_GET_BASE_LEVEL(this) & 1);
PRBool isReverseDirection = aPos->mVisual ?
(NS_GET_EMBEDDING_LEVEL(this) & 1) != (NS_GET_BASE_LEVEL(this) & 1) : PR_FALSE;
PRBool movementIsInFrameDirection =
((aPos->mDirection == eDirNext) && !isReverseDirection) ||
((aPos->mDirection == eDirPrevious) && isReverseDirection);

View File

@ -932,6 +932,11 @@ pref("bidi.characterset", 1);
// on the first keypress and delete the character on a second keypress
pref("bidi.edit.delete_immediately", false);
// Bidi caret movement style:
// 0 = logical
// 1 = visual
// 2 = visual, but logical during selection
pref("bidi.edit.caret_movement_style", 2);
// used for double-click word selection behavior. Win will override.
pref("layout.word_select.eat_space_to_next_word", false);