Not part of the build (barely). Don't allow PeekOffsetWord to break before the first cluster. Avoids a fencepost error in ClusterIterator where going backwards we might try to look at one past the end of mWordBreaks.

This commit is contained in:
roc+@cs.cmu.edu 2007-06-13 11:25:14 -07:00
parent 3f7e3e99ea
commit 5c7dda1060

View File

@ -4751,13 +4751,14 @@ nsTextFrame::PeekOffsetWord(PRBool aForward, PRBool aWordSelectEatSpace, PRBool
PRBool stopBeforePunctuation = stopAfterPunctuation && aIsKeyboardSelect;
PRInt32 offset = mContentOffset + (*aOffset < 0 ? mContentLength : *aOffset);
ClusterIterator cIter(this, offset, aForward ? 1 : -1);
PRBool firstCluster = PR_TRUE;
while (cIter.NextCluster()) {
if (aWordSelectEatSpace == cIter.IsWhitespace() && !*aSawBeforeType) {
*aSawBeforeType = PR_TRUE;
} else {
if ((*aSawBeforeType && cIter.HaveWordBreakBefore()) ||
(stopBeforePunctuation && cIter.IsPunctuation())) {
if (!firstCluster && ((*aSawBeforeType && cIter.HaveWordBreakBefore()) ||
(stopBeforePunctuation && cIter.IsPunctuation()))) {
*aOffset = cIter.GetBeforeOffset() - mContentOffset;
return PR_TRUE;
}
@ -4766,6 +4767,7 @@ nsTextFrame::PeekOffsetWord(PRBool aForward, PRBool aWordSelectEatSpace, PRBool
return PR_TRUE;
}
}
firstCluster = PR_FALSE;
}
*aOffset = cIter.GetAfterOffset() - mContentOffset;
return PR_FALSE;