From f5b747b20b8de1e1ba818e9d2d5ee2fc334bc8d7 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Tue, 6 Nov 2001 14:34:00 +0000 Subject: [PATCH] Minor fix up to my PrintPreview Checkin Bug 107562 git-svn-id: svn://10.0.0.236/trunk@107452 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsPageFrame.cpp | 66 +++---------------- .../layout/generic/nsSimplePageSequence.cpp | 6 +- mozilla/layout/html/base/src/nsPageFrame.cpp | 66 +++---------------- .../html/base/src/nsSimplePageSequence.cpp | 6 +- 4 files changed, 26 insertions(+), 118 deletions(-) diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 95d196a6d6b..0c222aff4f9 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -220,16 +220,20 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext, kidReflowState.availableHeight = maxSize.height; // Get the child's desired size - ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, mPD->mReflowMargin.left, mPD->mReflowMargin.top, 0, aStatus); + ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, + mPD->mReflowMargin.left+mPD->mExtraMargin.left, + mPD->mReflowMargin.top+mPD->mExtraMargin.top, 0, aStatus); + + // Place and size the child + FinishReflowChild(frame, aPresContext, aDesiredSize, + mPD->mReflowMargin.left+mPD->mExtraMargin.left, + mPD->mReflowMargin.top+mPD->mExtraMargin.top, 0); // Make sure the child is at least as tall as our max size (the containing window) if (aDesiredSize.height < aReflowState.availableHeight) { aDesiredSize.height = aReflowState.availableHeight; } - // Place and size the child - FinishReflowChild(frame, aPresContext, aDesiredSize, mPD->mReflowMargin.left, mPD->mReflowMargin.top, 0); - // Is the frame complete? if (NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* childNextInFlow; @@ -561,56 +565,6 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, rect = mRect; } -#ifdef DEBUG_PRINTING - if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - nsRect pr = rect; - pr.x = 0; - pr.y = 0; - nsCOMPtr ppContext = do_QueryInterface(aPresContext); - nsRect pageSize; - nsRect adjSize; - aPresContext->GetPageDim(&pageSize, &adjSize); - if (ppContext && pageSize == adjSize) { - pr.width -= mPD->mShadowSize.width; - pr.height -= mPD->mShadowSize.height; - - // paint just the page - aRenderingContext.SetColor(NS_RGB(192,208,240)); - aRenderingContext.FillRect(pr); - pr.Deflate(mPD->mReflowMargin); - aRenderingContext.SetColor(NS_RGB(255,255,255)); - aRenderingContext.FillRect(pr); - } else { - nsRect pr = rect; - aRenderingContext.SetColor(NS_RGB(255,255,255)); - pr.x = 0; - pr.y = 0; - aRenderingContext.FillRect(rect); - aRenderingContext.SetColor(NS_RGB(0,0,0)); - mPD->mPrintOptions->GetMarginInTwips(mMargin); - rect.Deflate(mMargin); - aRenderingContext.DrawRect(mRect); - } - - if (mPD->mShadowSize.width > 0 && mPD->mShadowSize.height > 0) { - aRenderingContext.SetColor(NS_RGB(0,0,0)); - nsRect r(0,0, mRect.width, mRect.height); - nsRect shadowRect; - shadowRect.x = r.x + r.width - mPD->mShadowSize.width; - shadowRect.y = r.y + mPD->mShadowSize.height; - shadowRect.width = mPD->mShadowSize.width; - shadowRect.height = r.height - mPD->mShadowSize.height; - aRenderingContext.FillRect(shadowRect); - - shadowRect.x = r.x + mPD->mShadowSize.width; - shadowRect.y = r.y + r.height - mPD->mShadowSize.height; - shadowRect.width = r.width - mPD->mShadowSize.width; - shadowRect.height = mPD->mShadowSize.height; - aRenderingContext.FillRect(shadowRect); - } - - } -#else if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { nsCOMPtr ppContext = do_QueryInterface(aPresContext); if (ppContext) { @@ -639,7 +593,6 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, } } } -#endif nsresult rv = nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); @@ -661,10 +614,11 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, #if defined(DEBUG_rods) || defined(DEBUG_dcone) { - nsRect rct(0, 0, mRect.width, mRect.height); + nsRect rct = rect; // XXX Paint a one-pixel border around the page so it's easy to see where // each page begins and ends when we're rct.Deflate(mMargin); + rct.Deflate(mPD->mExtraMargin); //float p2t; //aPresContext->GetPixelsToTwips(&p2t); //rect.Deflate(NSToCoordRound(p2t), NSToCoordRound(p2t)); diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index dab9f7f845a..09e3896c935 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -372,6 +372,9 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, } } + mPageData->mShadowSize = shadowSize; + mPageData->mExtraMargin = extraMargin; + // absolutely ignore all other types of reflows // we only want to have done the Initial Reflow if (eReflowReason_Resize == aReflowState.reason || @@ -499,9 +502,6 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, pageTot++; } - mPageData->mShadowSize = shadowSize; - mPageData->mExtraMargin = extraMargin; - // Set Page Number Info PRInt32 pageNum = 1; for (page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) { diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 95d196a6d6b..0c222aff4f9 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -220,16 +220,20 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext, kidReflowState.availableHeight = maxSize.height; // Get the child's desired size - ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, mPD->mReflowMargin.left, mPD->mReflowMargin.top, 0, aStatus); + ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, + mPD->mReflowMargin.left+mPD->mExtraMargin.left, + mPD->mReflowMargin.top+mPD->mExtraMargin.top, 0, aStatus); + + // Place and size the child + FinishReflowChild(frame, aPresContext, aDesiredSize, + mPD->mReflowMargin.left+mPD->mExtraMargin.left, + mPD->mReflowMargin.top+mPD->mExtraMargin.top, 0); // Make sure the child is at least as tall as our max size (the containing window) if (aDesiredSize.height < aReflowState.availableHeight) { aDesiredSize.height = aReflowState.availableHeight; } - // Place and size the child - FinishReflowChild(frame, aPresContext, aDesiredSize, mPD->mReflowMargin.left, mPD->mReflowMargin.top, 0); - // Is the frame complete? if (NS_FRAME_IS_COMPLETE(aStatus)) { nsIFrame* childNextInFlow; @@ -561,56 +565,6 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, rect = mRect; } -#ifdef DEBUG_PRINTING - if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { - nsRect pr = rect; - pr.x = 0; - pr.y = 0; - nsCOMPtr ppContext = do_QueryInterface(aPresContext); - nsRect pageSize; - nsRect adjSize; - aPresContext->GetPageDim(&pageSize, &adjSize); - if (ppContext && pageSize == adjSize) { - pr.width -= mPD->mShadowSize.width; - pr.height -= mPD->mShadowSize.height; - - // paint just the page - aRenderingContext.SetColor(NS_RGB(192,208,240)); - aRenderingContext.FillRect(pr); - pr.Deflate(mPD->mReflowMargin); - aRenderingContext.SetColor(NS_RGB(255,255,255)); - aRenderingContext.FillRect(pr); - } else { - nsRect pr = rect; - aRenderingContext.SetColor(NS_RGB(255,255,255)); - pr.x = 0; - pr.y = 0; - aRenderingContext.FillRect(rect); - aRenderingContext.SetColor(NS_RGB(0,0,0)); - mPD->mPrintOptions->GetMarginInTwips(mMargin); - rect.Deflate(mMargin); - aRenderingContext.DrawRect(mRect); - } - - if (mPD->mShadowSize.width > 0 && mPD->mShadowSize.height > 0) { - aRenderingContext.SetColor(NS_RGB(0,0,0)); - nsRect r(0,0, mRect.width, mRect.height); - nsRect shadowRect; - shadowRect.x = r.x + r.width - mPD->mShadowSize.width; - shadowRect.y = r.y + mPD->mShadowSize.height; - shadowRect.width = mPD->mShadowSize.width; - shadowRect.height = r.height - mPD->mShadowSize.height; - aRenderingContext.FillRect(shadowRect); - - shadowRect.x = r.x + mPD->mShadowSize.width; - shadowRect.y = r.y + r.height - mPD->mShadowSize.height; - shadowRect.width = r.width - mPD->mShadowSize.width; - shadowRect.height = mPD->mShadowSize.height; - aRenderingContext.FillRect(shadowRect); - } - - } -#else if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) { nsCOMPtr ppContext = do_QueryInterface(aPresContext); if (ppContext) { @@ -639,7 +593,6 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, } } } -#endif nsresult rv = nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); @@ -661,10 +614,11 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, #if defined(DEBUG_rods) || defined(DEBUG_dcone) { - nsRect rct(0, 0, mRect.width, mRect.height); + nsRect rct = rect; // XXX Paint a one-pixel border around the page so it's easy to see where // each page begins and ends when we're rct.Deflate(mMargin); + rct.Deflate(mPD->mExtraMargin); //float p2t; //aPresContext->GetPixelsToTwips(&p2t); //rect.Deflate(NSToCoordRound(p2t), NSToCoordRound(p2t)); diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index dab9f7f845a..09e3896c935 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -372,6 +372,9 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, } } + mPageData->mShadowSize = shadowSize; + mPageData->mExtraMargin = extraMargin; + // absolutely ignore all other types of reflows // we only want to have done the Initial Reflow if (eReflowReason_Resize == aReflowState.reason || @@ -499,9 +502,6 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, pageTot++; } - mPageData->mShadowSize = shadowSize; - mPageData->mExtraMargin = extraMargin; - // Set Page Number Info PRInt32 pageNum = 1; for (page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {