Bug 256252 ctrl+right arrow sometimes skip a word

r/sr=roc, patch=ginn.chen@sun.com
This commit is contained in:
kyle.yuan%sun.com 2004-10-09 06:14:44 +00:00
Родитель 6e688d8ca1
Коммит eefa1edd1b
4 изменённых файлов: 58 добавлений и 62 удалений

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

@ -3587,32 +3587,22 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
PRInt32 newOffset = newContent->IndexOf(mContent);
if (aPos->mStartOffset < 0)//start at "end"
aPos->mStartOffset = newOffset + 1;
if ((aPos->mDirection == eDirNext && newOffset < aPos->mStartOffset) || //need to go to next one
(aPos->mDirection == eDirPrevious && newOffset >= aPos->mStartOffset))
{
result = GetFrameFromDirection(aPresContext, aPos);
if (NS_FAILED(result))
return result;
PRBool selectable = PR_FALSE;
if (aPos->mResultFrame)
aPos->mResultFrame->IsSelectable(&selectable, nsnull);
if (NS_FAILED(result) || !aPos->mResultFrame || !selectable)
{
return result?result:NS_ERROR_FAILURE;
}
return aPos->mResultFrame->PeekOffset(aPresContext, aPos);
}
if (aPos->mDirection == eDirNext)
aPos->mContentOffset = newOffset + 1;
else
aPos->mContentOffset = newOffset;//to beginning of frame
result = GetFrameFromDirection(aPresContext, aPos);
if (NS_FAILED(result))
return result;
PRBool selectable = PR_FALSE;
if (aPos->mResultFrame)
aPos->mResultFrame->IsSelectable(&selectable, nsnull);
if (NS_FAILED(result) || !aPos->mResultFrame || !selectable)
{
if (aPos->mDirection == eDirNext)
aPos->mContentOffset = newOffset +1;
else
aPos->mContentOffset = newOffset;//to beginning of frame
return NS_OK;
return result?result:NS_ERROR_FAILURE;
}
return aPos->mResultFrame->PeekOffset(aPresContext, aPos);
}
}
break;
@ -3992,7 +3982,6 @@ nsFrame::GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *
if (aPos->mDirection == eDirNext)
{
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
aPos->mAmount = eSelectNoAmount;
}
}

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

@ -4194,19 +4194,21 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
if ((wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace) || !aPos->mEatingWS) {
aPos->mContentOffset = aPos->mStartOffset + contentLen;
keepSearching = PR_TRUE;
aPos->mEatingWS = !wordSelectEatSpaceAfter;
if (wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
aPos->mEatingWS = PR_TRUE;
#ifdef IBMBIDI
wordLen = (mState & NS_FRAME_IS_BIDI)
? mContentOffset + mContentLength : -1;
#endif // IBMBIDI
while (tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE, aPos->mIsKeyboardSelect))
{
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
if (wordSelectEatSpaceAfter ? !isWhitespace : aPos->mEatingWS)
break;
if (aPos->mStartOffset + contentLen >= (mContentLength + mContentOffset))
goto TryNextFrame;
if (wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
aPos->mContentOffset += contentLen;
else
break;
aPos->mEatingWS = PR_TRUE;
aPos->mContentOffset += contentLen;
#ifdef IBMBIDI
wordLen = (mState & NS_FRAME_IS_BIDI)
? mContentOffset + mContentLength : -1;
@ -4221,7 +4223,6 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
aPos->mContentOffset = mContentOffset;
found = PR_TRUE;
}
aPos->mEatingWS = isWhitespace;
}
TryNextFrame:
@ -4233,7 +4234,15 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
{
aPos->mContentOffset = PR_MIN(aPos->mContentOffset, mContentOffset + mContentLength);
aPos->mContentOffset = PR_MAX(aPos->mContentOffset, mContentOffset);
result = GetFrameFromDirection(aPresContext, aPos);
if (wordSelectEatSpaceAfter && aPos->mDirection == eDirNext && aPos->mEatingWS) {
//If we want to stop at beginning of the next word
//GetFrameFromDirction should not return NS_ERROR_FAILURE at end of line
aPos->mEatingWS = PR_FALSE;
result = GetFrameFromDirection(aPresContext, aPos);
aPos->mEatingWS = PR_TRUE;
}
else
result = GetFrameFromDirection(aPresContext, aPos);
if (NS_SUCCEEDED(result) && aPos->mResultFrame && aPos->mResultFrame!= this)
{
if (NS_SUCCEEDED(result = aPos->mResultFrame->PeekOffset(aPresContext, aPos)))

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

@ -3587,32 +3587,22 @@ nsFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
PRInt32 newOffset = newContent->IndexOf(mContent);
if (aPos->mStartOffset < 0)//start at "end"
aPos->mStartOffset = newOffset + 1;
if ((aPos->mDirection == eDirNext && newOffset < aPos->mStartOffset) || //need to go to next one
(aPos->mDirection == eDirPrevious && newOffset >= aPos->mStartOffset))
{
result = GetFrameFromDirection(aPresContext, aPos);
if (NS_FAILED(result))
return result;
PRBool selectable = PR_FALSE;
if (aPos->mResultFrame)
aPos->mResultFrame->IsSelectable(&selectable, nsnull);
if (NS_FAILED(result) || !aPos->mResultFrame || !selectable)
{
return result?result:NS_ERROR_FAILURE;
}
return aPos->mResultFrame->PeekOffset(aPresContext, aPos);
}
if (aPos->mDirection == eDirNext)
aPos->mContentOffset = newOffset + 1;
else
aPos->mContentOffset = newOffset;//to beginning of frame
result = GetFrameFromDirection(aPresContext, aPos);
if (NS_FAILED(result))
return result;
PRBool selectable = PR_FALSE;
if (aPos->mResultFrame)
aPos->mResultFrame->IsSelectable(&selectable, nsnull);
if (NS_FAILED(result) || !aPos->mResultFrame || !selectable)
{
if (aPos->mDirection == eDirNext)
aPos->mContentOffset = newOffset +1;
else
aPos->mContentOffset = newOffset;//to beginning of frame
return NS_OK;
return result?result:NS_ERROR_FAILURE;
}
return aPos->mResultFrame->PeekOffset(aPresContext, aPos);
}
}
break;
@ -3992,7 +3982,6 @@ nsFrame::GetFrameFromDirection(nsPresContext* aPresContext, nsPeekOffsetStruct *
if (aPos->mDirection == eDirNext)
{
aPos->mPreferLeft = (PRBool)!(aPos->mPreferLeft);//drift to other side
aPos->mAmount = eSelectNoAmount;
}
}

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

@ -4194,19 +4194,21 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
if ((wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace) || !aPos->mEatingWS) {
aPos->mContentOffset = aPos->mStartOffset + contentLen;
keepSearching = PR_TRUE;
aPos->mEatingWS = !wordSelectEatSpaceAfter;
if (wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
aPos->mEatingWS = PR_TRUE;
#ifdef IBMBIDI
wordLen = (mState & NS_FRAME_IS_BIDI)
? mContentOffset + mContentLength : -1;
#endif // IBMBIDI
while (tx.GetNextWord(PR_FALSE, &wordLen, &contentLen, &isWhitespace, &wasTransformed, PR_TRUE, PR_FALSE, aPos->mIsKeyboardSelect))
{
if (aPos->mStartOffset + contentLen > (mContentLength + mContentOffset))
if (wordSelectEatSpaceAfter ? !isWhitespace : aPos->mEatingWS)
break;
if (aPos->mStartOffset + contentLen >= (mContentLength + mContentOffset))
goto TryNextFrame;
if (wordSelectEatSpaceAfter ? isWhitespace : !isWhitespace)
aPos->mContentOffset += contentLen;
else
break;
aPos->mEatingWS = PR_TRUE;
aPos->mContentOffset += contentLen;
#ifdef IBMBIDI
wordLen = (mState & NS_FRAME_IS_BIDI)
? mContentOffset + mContentLength : -1;
@ -4221,7 +4223,6 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
aPos->mContentOffset = mContentOffset;
found = PR_TRUE;
}
aPos->mEatingWS = isWhitespace;
}
TryNextFrame:
@ -4233,7 +4234,15 @@ nsTextFrame::PeekOffset(nsPresContext* aPresContext, nsPeekOffsetStruct *aPos)
{
aPos->mContentOffset = PR_MIN(aPos->mContentOffset, mContentOffset + mContentLength);
aPos->mContentOffset = PR_MAX(aPos->mContentOffset, mContentOffset);
result = GetFrameFromDirection(aPresContext, aPos);
if (wordSelectEatSpaceAfter && aPos->mDirection == eDirNext && aPos->mEatingWS) {
//If we want to stop at beginning of the next word
//GetFrameFromDirction should not return NS_ERROR_FAILURE at end of line
aPos->mEatingWS = PR_FALSE;
result = GetFrameFromDirection(aPresContext, aPos);
aPos->mEatingWS = PR_TRUE;
}
else
result = GetFrameFromDirection(aPresContext, aPos);
if (NS_SUCCEEDED(result) && aPos->mResultFrame && aPos->mResultFrame!= this)
{
if (NS_SUCCEEDED(result = aPos->mResultFrame->PeekOffset(aPresContext, aPos)))