Bug 430389: Use correct clip-rect to prevent multipage print-selection output from streaming off of page boundaries. r+sr=roc a=damons

git-svn-id: svn://10.0.0.236/trunk@251017 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dholbert%cs.stanford.edu 2008-05-01 06:32:25 +00:00
parent f4eb3edaa1
commit b8f15c6f20

View File

@ -549,6 +549,19 @@ nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
// Make sure we don't draw where we aren't supposed to draw, especially
// when printing selection
nsRect clipRect(nsPoint(0, 0), pageContentFrame->GetSize());
// Note: this computation matches how we compute maxSize.height
// in nsPageFrame::Reflow
nscoord expectedPageContentHeight =
NSToCoordCeil((GetSize().height - mPD->mReflowMargin.TopBottom()) / scale);
if (clipRect.height > expectedPageContentHeight) {
// We're doing print-selection, with one long page-content frame.
// Clip to the appropriate page-content slice for the current page.
NS_ASSERTION(mPageNum > 0, "page num should be positive");
clipRect.y = expectedPageContentHeight * (mPageNum - 1);
clipRect.height = expectedPageContentHeight;
NS_ASSERTION(clipRect.y < pageContentFrame->GetSize().height,
"Should be clipping to region inside the page content bounds");
}
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
const nsStyleBorder* border = GetStyleBorder();