Bug 382105. Yet another word caret movement fix to ensure we stop at punctuation.

This commit is contained in:
roc+@cs.cmu.edu 2007-06-14 22:37:08 -07:00
parent 35bfb90b83
commit 250e787eff

View File

@ -4748,7 +4748,7 @@ nsTextFrame::PeekOffsetWord(PRBool aForward, PRBool aWordSelectEatSpace, PRBool
return PR_FALSE;
PRBool stopAfterPunctuation = nsTextTransformer::GetWordSelectStopAtPunctuation();
PRBool stopBeforePunctuation = stopAfterPunctuation && aIsKeyboardSelect;
PRBool stopBeforePunctuation = stopAfterPunctuation && !aIsKeyboardSelect;
PRInt32 offset = mContentOffset + (*aOffset < 0 ? mContentLength : *aOffset);
ClusterIterator cIter(this, offset, aForward ? 1 : -1);
PRBool firstCluster = PR_TRUE;
@ -4756,9 +4756,10 @@ nsTextFrame::PeekOffsetWord(PRBool aForward, PRBool aWordSelectEatSpace, PRBool
while (cIter.NextCluster()) {
if (aWordSelectEatSpace == cIter.IsWhitespace() && !*aSawBeforeType) {
*aSawBeforeType = PR_TRUE;
} else {
if (!firstCluster && ((*aSawBeforeType && cIter.HaveWordBreakBefore()) ||
(stopBeforePunctuation && cIter.IsPunctuation()))) {
} else if (*aSawBeforeType) {
if (!firstCluster &&
(cIter.IsPunctuation() ? stopBeforePunctuation
: cIter.HaveWordBreakBefore())) {
*aOffset = cIter.GetBeforeOffset() - mContentOffset;
return PR_TRUE;
}