Commit aaf257b6 authored by dholbert@cs.stanford.edu's avatar dholbert@cs.stanford.edu
Browse files

Bug 430389: Use correct clip-rect to prevent multipage print-selection output...

Bug 430389: Use correct clip-rect to prevent multipage print-selection output from streaming off of page boundaries. r+sr=roc a=damons
parent 1df2b532
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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();