diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 81dc32c7076..2cae03fe27f 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -2402,26 +2402,16 @@ nsPrintEngine::SetupToPrintContent(nsIDeviceContext* aDContext, doSetPixelScale = PR_TRUE; } - // If we are doing "shrink to fit" then request that the first - // reflow is constrained - if (mPrt->mShrinkToFit && !ppIsShrinkToFit) { - mPrt->mPrintOptions->SetDoUncontrainedReflow(PR_TRUE); - } - // Here we reflow all the PrintObjects nsresult rv = ReflowDocList(mPrt->mPrintObject, doSetPixelScale, mPrt->mShrinkToFit); CHECK_RUNTIME_ERROR_CONDITION(nsIDebugObject::PRT_RUNTIME_REFLOWDOCLIST, rv, NS_ERROR_FAILURE); if (NS_FAILED(rv)) { - mPrt->mPrintOptions->SetDoUncontrainedReflow(PR_FALSE); return NS_ERROR_FAILURE; } // Here is where we do the extra reflow for shrinking the content // But skip this step if we are in PrintPreview if (mPrt->mShrinkToFit && !ppIsShrinkToFit) { - // Turn off the request for unconstrained reflow - mPrt->mPrintOptions->SetDoUncontrainedReflow(PR_FALSE); - // Now look for the PO that has the smallest percent for shrink to fit if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) { nsPrintObject* smallestPO = FindSmallestSTF(); @@ -2437,8 +2427,8 @@ nsPrintEngine::SetupToPrintContent(nsIDeviceContext* aDContext, // Only Shrink if we are smaller if (mPrt->mShrinkRatio < 0.998f) { - // Clamp Shrink to Fit to 50% - mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f); + // Clamp Shrink to Fit to 30% + mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.30f); for (PRInt32 i=0;imPrintDocList->Count();i++) { nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i); diff --git a/mozilla/gfx/idl/nsIPrintOptions.idl b/mozilla/gfx/idl/nsIPrintOptions.idl index d96484a9f14..8f2596f6d28 100644 --- a/mozilla/gfx/idl/nsIPrintOptions.idl +++ b/mozilla/gfx/idl/nsIPrintOptions.idl @@ -95,10 +95,6 @@ interface nsIPrintOptions : nsISupports /* Purposely made this an "in" arg */ [noscript] void GetDefaultFont(in nsNativeFontRef aFont); - /* caches bool value so we know how to reflow - This will get picked by the nsSequencePageFrame */ - [noscript] attribute boolean doUncontrainedReflow; - /** * Native data constants */ diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index c666cb0b65e..a71731f0605 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -113,8 +113,7 @@ nsFont* nsPrintOptions::sDefaultFont = nsnull; * See documentation in nsPrintOptionsImpl.h * @update 6/21/00 dwc */ -nsPrintOptions::nsPrintOptions() : - mDoUncontrainedReflow(PR_FALSE) +nsPrintOptions::nsPrintOptions() { NS_INIT_ISUPPORTS(); @@ -260,21 +259,6 @@ nsPrintOptions::GetDefaultFont(nsFont &aFont) return NS_OK; } -/* [noscript] attribute boolean doUncontrainedReflow; */ -NS_IMETHODIMP -nsPrintOptions::GetDoUncontrainedReflow(PRBool *aDoUncontrainedReflow) -{ - NS_ENSURE_ARG_POINTER(aDoUncontrainedReflow); - *aDoUncontrainedReflow = mDoUncontrainedReflow; - return NS_OK; -} -NS_IMETHODIMP -nsPrintOptions::SetDoUncontrainedReflow(PRBool aDoUncontrainedReflow) -{ - mDoUncontrainedReflow = aDoUncontrainedReflow; - return NS_OK; -} - /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h * @update 6/21/00 dwc diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.h b/mozilla/gfx/src/nsPrintOptionsImpl.h index fdb55e25fb9..bf85d3115fe 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.h +++ b/mozilla/gfx/src/nsPrintOptionsImpl.h @@ -69,7 +69,6 @@ protected: nsCOMPtr mGlobalPrintSettings; nsCString mPrefName; - PRBool mDoUncontrainedReflow; static nsFont* sDefaultFont; }; diff --git a/mozilla/layout/generic/nsPageContentFrame.cpp b/mozilla/layout/generic/nsPageContentFrame.cpp index 4cd3ab957e1..3c541f447ea 100644 --- a/mozilla/layout/generic/nsPageContentFrame.cpp +++ b/mozilla/layout/generic/nsPageContentFrame.cpp @@ -91,29 +91,32 @@ NS_IMETHODIMP nsPageContentFrame::Reflow(nsIPresContext* aPresContext, nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight); nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame, maxSize); - // Check to see if we need to do an unconstrained reflow - // If so, then cache the size the page was SUPPOSE to be reflowed to - // so we can use it later to determine a percentage. - PRBool doUnconstrained = PR_FALSE; - if (mPD && mPD->mPrintOptions) { - mPD->mPrintOptions->GetDoUncontrainedReflow(&doUnconstrained); - if (doUnconstrained) { - mPD->mPageContextSize = aReflowState.availableWidth; - maxSize.width = NS_UNCONSTRAINEDSIZE; - kidReflowState.availableWidth = NS_UNCONSTRAINEDSIZE; - kidReflowState.mComputedWidth = NS_UNCONSTRAINEDSIZE; - } - } + mPD->mPageContentSize = aReflowState.availableWidth; // Reflow the page content area to get the child's desired size ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, 0, 0, 0, aStatus); - // This is where we cache the true uncontrained size of the document - // each page may end up with a different constrained size, - // so we must only keep the largest size of all the pages - if (doUnconstrained) { - if (mPD->mPageContextSizeUC == 0 || mPD->mPageContextSizeUC < aDesiredSize.width) { - mPD->mPageContextSizeUC = aDesiredSize.width; + // The document element's background should cover the entire canvas, so + // take into account the combined area and any space taken up by + // absolutely positioned elements + nsMargin border(0,0,0,0); + nsMargin padding(0,0,0,0); + nsFrameState kidState; + + // Ignore the return values for these + // Typically they are zero and if they fail + // we should keep going anyway, there impact is small + kidReflowState.mStyleBorder->GetBorder(border); + kidReflowState.mStylePadding->GetPadding(padding); + frame->GetFrameState(&kidState); + + // First check the combined area + if (NS_FRAME_OUTSIDE_CHILDREN & kidState) { + // The background covers the content area and padding area, so check + // for children sticking outside the child frame's padding edge + nscoord paddingEdgeX = aDesiredSize.width - border.right - padding.right; + if (aDesiredSize.mOverflowArea.XMost() > aDesiredSize.width) { + mPD->mPageContentXMost = aDesiredSize.mOverflowArea.XMost() + border.right + padding.right; } } diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 9a656226364..af670af4815 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -107,7 +107,9 @@ nsSharedPageData::nsSharedPageData() : mShadowSize(0,0), mDeadSpaceMargin(0,0,0,0), mExtraMargin(0,0,0,0), - mEdgePaperMargin(0,0,0,0) + mEdgePaperMargin(0,0,0,0), + mPageContentSize(0), + mPageContentXMost(0) { } @@ -1141,8 +1143,8 @@ nsSimplePageSequenceFrame::GetSTFPercent(float& aSTFPercent) { NS_ENSURE_TRUE(mPageData, NS_ERROR_UNEXPECTED); aSTFPercent = 1.0f; - if (mPageData && (mPageData->mPageContextSizeUC > mPageData->mPageContextSize)) { - aSTFPercent = float(mPageData->mPageContextSize) / float(mPageData->mPageContextSizeUC); + if (mPageData && (mPageData->mPageContentXMost > mPageData->mPageContentSize)) { + aSTFPercent = float(mPageData->mPageContentSize) / float(mPageData->mPageContentXMost); } return NS_OK; } diff --git a/mozilla/layout/generic/nsSimplePageSequence.h b/mozilla/layout/generic/nsSimplePageSequence.h index 8c6c9b93f55..e6552b374c2 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.h +++ b/mozilla/layout/generic/nsSimplePageSequence.h @@ -68,8 +68,8 @@ public: nsCOMPtr mPrintSettings; nsCOMPtr mPrintOptions; - nscoord mPageContextSizeUC; // unconstrained size (width) - nscoord mPageContextSize; // constrained size (width) + nscoord mPageContentXMost; // xmost size from Reflow(width) + nscoord mPageContentSize; // constrained size (width) }; // Simple page sequence frame class. Used when we're in paginated mode diff --git a/mozilla/layout/html/base/src/nsPageContentFrame.cpp b/mozilla/layout/html/base/src/nsPageContentFrame.cpp index 4cd3ab957e1..3c541f447ea 100644 --- a/mozilla/layout/html/base/src/nsPageContentFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageContentFrame.cpp @@ -91,29 +91,32 @@ NS_IMETHODIMP nsPageContentFrame::Reflow(nsIPresContext* aPresContext, nsSize maxSize(aReflowState.availableWidth, aReflowState.availableHeight); nsHTMLReflowState kidReflowState(aPresContext, aReflowState, frame, maxSize); - // Check to see if we need to do an unconstrained reflow - // If so, then cache the size the page was SUPPOSE to be reflowed to - // so we can use it later to determine a percentage. - PRBool doUnconstrained = PR_FALSE; - if (mPD && mPD->mPrintOptions) { - mPD->mPrintOptions->GetDoUncontrainedReflow(&doUnconstrained); - if (doUnconstrained) { - mPD->mPageContextSize = aReflowState.availableWidth; - maxSize.width = NS_UNCONSTRAINEDSIZE; - kidReflowState.availableWidth = NS_UNCONSTRAINEDSIZE; - kidReflowState.mComputedWidth = NS_UNCONSTRAINEDSIZE; - } - } + mPD->mPageContentSize = aReflowState.availableWidth; // Reflow the page content area to get the child's desired size ReflowChild(frame, aPresContext, aDesiredSize, kidReflowState, 0, 0, 0, aStatus); - // This is where we cache the true uncontrained size of the document - // each page may end up with a different constrained size, - // so we must only keep the largest size of all the pages - if (doUnconstrained) { - if (mPD->mPageContextSizeUC == 0 || mPD->mPageContextSizeUC < aDesiredSize.width) { - mPD->mPageContextSizeUC = aDesiredSize.width; + // The document element's background should cover the entire canvas, so + // take into account the combined area and any space taken up by + // absolutely positioned elements + nsMargin border(0,0,0,0); + nsMargin padding(0,0,0,0); + nsFrameState kidState; + + // Ignore the return values for these + // Typically they are zero and if they fail + // we should keep going anyway, there impact is small + kidReflowState.mStyleBorder->GetBorder(border); + kidReflowState.mStylePadding->GetPadding(padding); + frame->GetFrameState(&kidState); + + // First check the combined area + if (NS_FRAME_OUTSIDE_CHILDREN & kidState) { + // The background covers the content area and padding area, so check + // for children sticking outside the child frame's padding edge + nscoord paddingEdgeX = aDesiredSize.width - border.right - padding.right; + if (aDesiredSize.mOverflowArea.XMost() > aDesiredSize.width) { + mPD->mPageContentXMost = aDesiredSize.mOverflowArea.XMost() + border.right + padding.right; } } diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index 9a656226364..af670af4815 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -107,7 +107,9 @@ nsSharedPageData::nsSharedPageData() : mShadowSize(0,0), mDeadSpaceMargin(0,0,0,0), mExtraMargin(0,0,0,0), - mEdgePaperMargin(0,0,0,0) + mEdgePaperMargin(0,0,0,0), + mPageContentSize(0), + mPageContentXMost(0) { } @@ -1141,8 +1143,8 @@ nsSimplePageSequenceFrame::GetSTFPercent(float& aSTFPercent) { NS_ENSURE_TRUE(mPageData, NS_ERROR_UNEXPECTED); aSTFPercent = 1.0f; - if (mPageData && (mPageData->mPageContextSizeUC > mPageData->mPageContextSize)) { - aSTFPercent = float(mPageData->mPageContextSize) / float(mPageData->mPageContextSizeUC); + if (mPageData && (mPageData->mPageContentXMost > mPageData->mPageContentSize)) { + aSTFPercent = float(mPageData->mPageContentSize) / float(mPageData->mPageContentXMost); } return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.h b/mozilla/layout/html/base/src/nsSimplePageSequence.h index 8c6c9b93f55..e6552b374c2 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.h +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.h @@ -68,8 +68,8 @@ public: nsCOMPtr mPrintSettings; nsCOMPtr mPrintOptions; - nscoord mPageContextSizeUC; // unconstrained size (width) - nscoord mPageContextSize; // constrained size (width) + nscoord mPageContentXMost; // xmost size from Reflow(width) + nscoord mPageContentSize; // constrained size (width) }; // Simple page sequence frame class. Used when we're in paginated mode diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 81dc32c7076..2cae03fe27f 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -2402,26 +2402,16 @@ nsPrintEngine::SetupToPrintContent(nsIDeviceContext* aDContext, doSetPixelScale = PR_TRUE; } - // If we are doing "shrink to fit" then request that the first - // reflow is constrained - if (mPrt->mShrinkToFit && !ppIsShrinkToFit) { - mPrt->mPrintOptions->SetDoUncontrainedReflow(PR_TRUE); - } - // Here we reflow all the PrintObjects nsresult rv = ReflowDocList(mPrt->mPrintObject, doSetPixelScale, mPrt->mShrinkToFit); CHECK_RUNTIME_ERROR_CONDITION(nsIDebugObject::PRT_RUNTIME_REFLOWDOCLIST, rv, NS_ERROR_FAILURE); if (NS_FAILED(rv)) { - mPrt->mPrintOptions->SetDoUncontrainedReflow(PR_FALSE); return NS_ERROR_FAILURE; } // Here is where we do the extra reflow for shrinking the content // But skip this step if we are in PrintPreview if (mPrt->mShrinkToFit && !ppIsShrinkToFit) { - // Turn off the request for unconstrained reflow - mPrt->mPrintOptions->SetDoUncontrainedReflow(PR_FALSE); - // Now look for the PO that has the smallest percent for shrink to fit if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) { nsPrintObject* smallestPO = FindSmallestSTF(); @@ -2437,8 +2427,8 @@ nsPrintEngine::SetupToPrintContent(nsIDeviceContext* aDContext, // Only Shrink if we are smaller if (mPrt->mShrinkRatio < 0.998f) { - // Clamp Shrink to Fit to 50% - mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f); + // Clamp Shrink to Fit to 30% + mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.30f); for (PRInt32 i=0;imPrintDocList->Count();i++) { nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);