When measuring text, make sure nsTextTransformer::GetNextWord looks only at the part of the text content covered by the current frame. bug=333769 r+sr=roc

This commit is contained in:
uriber%gmail.com 2006-04-22 13:29:50 +00:00
Родитель 49e00219a8
Коммит d76593004d
2 изменённых файлов: 12 добавлений и 4 удалений

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

@ -6332,14 +6332,14 @@ nsTextFrame::ComputeWordFragmentDimensions(nsPresContext* aPresContext,
PRBool aCanBreakBefore)
{
nsTextTransformer tx(aPresContext);
tx.Init(aNextFrame, aContent, 0);
PRInt32 nextFrameStart, nextFrameEnd;
aNextFrame->GetOffsets(nextFrameStart, nextFrameEnd);
tx.Init(aNextFrame, aContent, nextFrameStart);
PRBool isWhitespace, wasTransformed;
PRInt32 wordLen, contentLen;
nsTextDimensions dimensions;
#ifdef IBMBIDI
if (aNextFrame->GetStateBits() & NS_FRAME_IS_BIDI) {
PRInt32 nextFrameStart, nextFrameEnd;
aNextFrame->GetOffsets(nextFrameStart, nextFrameEnd);
wordLen = nextFrameEnd;
} else {
wordLen = -1;
@ -6367,7 +6367,7 @@ nsTextFrame::ComputeWordFragmentDimensions(nsPresContext* aPresContext,
*aMoreSize = wordLen + aRunningWordLen - aWordBufSize;
return dimensions; // 0
}
if (contentLen < tx.GetContentLength())
if (nextFrameStart + contentLen < nextFrameEnd)
*aMoreSize = -1;
// Convert any spaces in the current word back to nbsp's. This keeps

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

@ -680,6 +680,11 @@ nsTextTransformer::ScanPreData_F(PRInt32* aWordLen,
{
const nsTextFragment* frag = mFrag;
PRInt32 fragLen = frag->GetLength();
#ifdef IBMBIDI
if (*aWordLen > 0 && *aWordLen < fragLen) {
fragLen = *aWordLen;
}
#endif
PRInt32 offset = mOffset;
PRUnichar* bp = mTransformBuf.GetBuffer() + mBufferPos;
PRUnichar* endbp = mTransformBuf.GetBufferEnd();
@ -958,6 +963,9 @@ nsTextTransformer::GetNextWord(PRBool aInWord,
isWhitespace = PR_TRUE;
}
else if (frag->Is2b()) {
#ifdef IBMBIDI
wordLen = *aWordLenResult;
#endif
offset = ScanPreData_F(&wordLen, aWasTransformed);
}
else {