зеркало из https://github.com/mozilla/gecko-dev.git
This partially backs out the previous patch. We no longer need to set/get anything in the nsIPrintOptions.
What this does is: 1) Reflows the first time constrained and remembers mOverflowArea.XMost() of the HTML frame and then later uses that for the calculation of the ratio. 2) Renames some variables 3) This also changes the the maximum STF ratio from 0.5 to 0.3 to match the dropdown in PP Bug 168961 r=dcone sr=kin
This commit is contained in:
Родитель
e158e4b617
Коммит
7b4aca7912
|
@ -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;i<mPrt->mPrintDocList->Count();i++) {
|
||||
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -69,7 +69,6 @@ protected:
|
|||
nsCOMPtr<nsIPrintSettings> mGlobalPrintSettings;
|
||||
|
||||
nsCString mPrefName;
|
||||
PRBool mDoUncontrainedReflow;
|
||||
|
||||
static nsFont* sDefaultFont;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ public:
|
|||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
nsCOMPtr<nsIPrintOptions> 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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -68,8 +68,8 @@ public:
|
|||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
nsCOMPtr<nsIPrintOptions> 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
|
||||
|
|
|
@ -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;i<mPrt->mPrintDocList->Count();i++) {
|
||||
nsPrintObject* po = (nsPrintObject*)mPrt->mPrintDocList->ElementAt(i);
|
||||
|
|
Загрузка…
Ссылка в новой задаче