diff -r e96e8a131979 -r 6971d1c87c9a textrendering/textformatting/tbox/LAYEMU.CPP --- a/textrendering/textformatting/tbox/LAYEMU.CPP Sat Feb 20 00:37:46 2010 +0200 +++ b/textrendering/textformatting/tbox/LAYEMU.CPP Fri Mar 12 15:51:09 2010 +0200 @@ -4012,7 +4012,9 @@ if (aDy > 0) // text moves down; iBandTop decreases { if (aTopNoLimitBorder) - iBandTop = desired_bandtop; + { + iBandTop = Max(0 - iText->LayoutHeight(),desired_bandtop); + } else iBandTop = Max(0,desired_bandtop);//Disallow text scrolled beyond top border @@ -4056,6 +4058,19 @@ if (!AddFormattingAtEndL(param, height_increase,paragraphs_increase)) break; } + + // Shift the whole band upwards if we're at the very end of the text + // and there's no more text to format. This prevents a situation were + // iText->LayoutHeight() < BandHeightInPixels. + if ( aBottomNoLimitBorder && iText->LayoutHeight() - iBandTop < visible_height ) + { + if ( iText->EndChar() > iText->Source()->DocumentLength() ) + { + iBandTop = desired_bandtop; + return pixels_scrolled; + } + } + } // Scroll blank space off the display if desired.