Bug 382490. Fix trimming in BreakAndMeasureText so when we back up to a break opportunity, we back up the trimming state too. r=pavlov

This commit is contained in:
roc+@cs.cmu.edu 2007-05-30 22:04:24 -07:00
Родитель f1997a6a30
Коммит 937adf97c7
1 изменённых файлов: 9 добавлений и 1 удалений

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

@ -1264,9 +1264,13 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
gfxFloat width = 0;
gfxFloat advance = 0;
gfxFloat trimmableAdvance = 0;
// The number of space characters that can be trimmed
PRUint32 trimmableChars = 0;
// The amount of space removed by ignoring trimmableChars
gfxFloat trimmableAdvance = 0;
PRInt32 lastBreak = -1;
PRInt32 lastBreakTrimmableChars = -1;
gfxFloat lastBreakTrimmableAdvance = -1;
PRBool aborted = PR_FALSE;
PRUint32 end = aStart + aMaxLength;
PRBool lastBreakUsedHyphenation = PR_FALSE;
@ -1303,6 +1307,8 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
if (lastBreak < 0 || width + hyphenatedAdvance - trimmableAdvance <= aWidth) {
// We can break here.
lastBreak = i;
lastBreakTrimmableChars = trimmableChars;
lastBreakTrimmableAdvance = trimmableAdvance;
lastBreakUsedHyphenation = hyphenation;
}
@ -1364,6 +1370,8 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
charsFit = aMaxLength;
} else if (lastBreak >= 0) {
charsFit = lastBreak - aStart;
trimmableChars = lastBreakTrimmableChars;
trimmableAdvance = lastBreakTrimmableAdvance;
} else {
charsFit = aMaxLength;
}