NPOTB, new-text-frame. Fix mouse events targeting after the end of a textframe.

git-svn-id: svn://10.0.0.236/trunk@226421 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
roc+%cs.cmu.edu 2007-05-15 05:23:19 +00:00
parent bac4685d57
commit 68e11bba0d

View File

@ -3868,27 +3868,30 @@ nsTextFrame::IsVisibleInSelection(nsISelection* aSelection)
return found;
}
/**
* Compute the longest prefix of text whose width is <= aWidth. Return
* the length of the prefix. Also returns the width of the prefix in aFitWidth.
*/
static PRUint32
CountCharsFit(gfxTextRun* aTextRun, PRUint32 aStart, PRUint32 aLength,
gfxFloat aWidth, PropertyProvider* aProvider,
gfxFloat* aFitWidth)
{
PRUint32 last = 0;
gfxFloat totalWidth = 0;
gfxFloat width = 0;
PRUint32 i;
for (i = 1; i <= aLength; ++i) {
if (i == aLength || aTextRun->IsClusterStart(aStart + i)) {
gfxFloat lastWidth = totalWidth;
totalWidth += aTextRun->GetAdvanceWidth(aStart + last, i - last, aProvider);
if (totalWidth > aWidth) {
*aFitWidth = lastWidth;
return last;
}
gfxFloat nextWidth = width +
aTextRun->GetAdvanceWidth(aStart + last, i - last, aProvider);
if (nextWidth > aWidth)
break;
last = i;
width = nextWidth;
}
}
*aFitWidth = 0;
return 0;
*aFitWidth = width;
return last;
}
nsIFrame::ContentOffsets