From 78a505edca3ebc28d7a512a81aac0dc7190eece1 Mon Sep 17 00:00:00 2001 From: "rflint@ryanflint.com" Date: Tue, 13 Nov 2007 06:18:36 -0800 Subject: [PATCH] Backout bug 396278 due to failing reftests --- layout/generic/nsSimplePageSequence.cpp | 31 +++++--- layout/generic/nsSimplePageSequence.h | 1 + .../printing/content/printdialog.js | 1 - .../printing/content/printjoboptions.js | 44 +++++++++--- widget/public/nsIPrintSettings.idl | 22 +----- widget/src/xpwidgets/nsPrintOptionsImpl.cpp | 72 +------------------ widget/src/xpwidgets/nsPrintOptionsImpl.h | 3 - widget/src/xpwidgets/nsPrintSettingsImpl.cpp | 68 ------------------ widget/src/xpwidgets/nsPrintSettingsImpl.h | 1 - xpfe/global/resources/content/printdialog.js | 1 - .../resources/content/unix/printjoboptions.js | 44 +++++++++--- 11 files changed, 98 insertions(+), 190 deletions(-) diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index 9b3f00856706..57d90c895828 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -161,19 +161,30 @@ nsSimplePageSequenceFrame::CreateContinuingPageFrame(nsPresContext* aPresContext CreateContinuingFrame(aPresContext, aPageFrame, this, aContinuingPage); } +void +nsSimplePageSequenceFrame::GetEdgePaperMarginCoord(const char* aPrefName, + nscoord& aCoord) +{ + nsresult rv = mPageData->mPrintOptions-> + GetPrinterPrefInt(mPageData->mPrintSettings, + NS_ConvertASCIItoUTF16(aPrefName).get(), + &aCoord); + + if (NS_SUCCEEDED(rv)) { + nscoord inchInTwips = NS_INCHES_TO_TWIPS(1.0); + aCoord = PR_MAX(NS_INCHES_TO_TWIPS(float(aCoord)/100.0f), 0); + aCoord = PR_MIN(aCoord, inchInTwips); // an inch is still probably excessive + } +} + void nsSimplePageSequenceFrame::GetEdgePaperMargin(nsMargin& aMargin) { - if (NS_SUCCEEDED(mPageData->mPrintSettings->GetEdgeInTwips(aMargin))) { - nscoord inchInTwips = NS_INCHES_TO_TWIPS(1.0); - // sanity check the values. an inch is still probably excessive - aMargin.top = PR_MIN(PR_MAX(aMargin.top, 0), inchInTwips); - aMargin.bottom = PR_MIN(PR_MAX(aMargin.bottom, 0), inchInTwips); - aMargin.left = PR_MIN(PR_MAX(aMargin.left, 0), inchInTwips); - aMargin.right = PR_MIN(PR_MAX(aMargin.right, 0), inchInTwips); - } else { - aMargin.SizeTo(0, 0, 0, 0); - } + aMargin.SizeTo(0,0,0,0); + GetEdgePaperMarginCoord("print_edge_top", aMargin.top); + GetEdgePaperMarginCoord("print_edge_left", aMargin.left); + GetEdgePaperMarginCoord("print_edge_bottom", aMargin.bottom); + GetEdgePaperMarginCoord("print_edge_right", aMargin.right); } NS_IMETHODIMP diff --git a/layout/generic/nsSimplePageSequence.h b/layout/generic/nsSimplePageSequence.h index 5348ec938207..535e6e24c2b1 100644 --- a/layout/generic/nsSimplePageSequence.h +++ b/layout/generic/nsSimplePageSequence.h @@ -149,6 +149,7 @@ protected: void SetDateTimeStr(PRUnichar * aDateTimeStr); void SetPageNumberFormat(PRUnichar * aFormatStr, PRBool aForPageNumOnly); + void GetEdgePaperMarginCoord(const char* aPrefName, nscoord& aCoord); void GetEdgePaperMargin(nsMargin& aMargin); NS_IMETHOD_(nsrefcnt) AddRef(void) {return nsContainerFrame::AddRef();} diff --git a/toolkit/components/printing/content/printdialog.js b/toolkit/components/printing/content/printdialog.js index 3e674af3b424..f3fc8b55b7b6 100644 --- a/toolkit/components/printing/content/printdialog.js +++ b/toolkit/components/printing/content/printdialog.js @@ -408,7 +408,6 @@ function onAccept() if (saveToPrefs && printService != null) { var flags = gPrintSetInterface.kInitSavePaperSize | gPrintSetInterface.kInitSaveColorSpace | - gPrintSetInterface.kInitSaveEdges | gPrintSetInterface.kInitSaveInColor | gPrintSetInterface.kInitSaveResolutionName | gPrintSetInterface.kInitSaveDownloadFonts | diff --git a/toolkit/components/printing/content/printjoboptions.js b/toolkit/components/printing/content/printjoboptions.js index 798ec595089c..ab9901711970 100644 --- a/toolkit/components/printing/content/printjoboptions.js +++ b/toolkit/components/printing/content/printjoboptions.js @@ -836,10 +836,26 @@ function loadDialog() dialog.cmdInput.value = print_command; dialog.jobTitleInput.value = print_jobtitle; - dialog.topInput.value = gPrintSettings.edgeTop.toFixed(2); - dialog.bottomInput.value = gPrintSettings.edgeBottom.toFixed(2); - dialog.leftInput.value = gPrintSettings.edgeLeft.toFixed(2); - dialog.rightInput.value = gPrintSettings.edgeRight.toFixed(2); + /* First initialize with the hardcoded defaults... */ + dialog.topInput.value = "0.04"; + dialog.bottomInput.value = "0.04"; + dialog.leftInput.value = "0.04"; + dialog.rightInput.value = "0.04"; + + try { + /* ... then try to get the generic settings ... */ + dialog.topInput.value = gPrefs.getIntPref("print.print_edge_top") / 100.0; + dialog.bottomInput.value = gPrefs.getIntPref("print.print_edge_bottom") / 100.0; + dialog.leftInput.value = gPrefs.getIntPref("print.print_edge_left") / 100.0; + dialog.rightInput.value = gPrefs.getIntPref("print.print_edge_right") / 100.0; + + /* ... and then the printer specific settings. */ + var printername = gPrintSettings.printerName; + dialog.topInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_top") / 100.0; + dialog.bottomInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_bottom") / 100.0; + dialog.leftInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_left") / 100.0; + dialog.rightInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_right") / 100.0; + } catch (e) { } } //--------------------------------------------------- @@ -906,10 +922,22 @@ function onAccept() gPrintSettings.printCommand = dialog.cmdInput.value; gPrintSettings.title = dialog.jobTitleInput.value; - gPrintSettings.edgeTop = dialog.topInput.value; - gPrintSettings.edgeBottom = dialog.bottomInput.value; - gPrintSettings.edgeLeft = dialog.leftInput.value; - gPrintSettings.edgeRight = dialog.rightInput.value; + // + try { + var printerName = gPrintSettings.printerName; + var i = dialog.topInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_top", i); + + i = dialog.bottomInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_bottom", i); + + i = dialog.leftInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_left", i); + + i = dialog.rightInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_right", i); + } catch (e) { + } if (doDebug) { dump("onAccept******************************\n"); diff --git a/widget/public/nsIPrintSettings.idl b/widget/public/nsIPrintSettings.idl index 52dac49b36c4..9735b980d5b1 100644 --- a/widget/public/nsIPrintSettings.idl +++ b/widget/public/nsIPrintSettings.idl @@ -58,7 +58,7 @@ interface nsIPrintSession; * * @status UNDER_REVIEW */ -[scriptable, uuid(81b8dfee-25cc-479c-ad2c-a5e3875650cb)] +[scriptable, uuid(b1b5e3cc-a52c-4325-a7f6-e1ac6fac19a5)] interface nsIPrintSettings : nsISupports { @@ -80,7 +80,7 @@ interface nsIPrintSettings : nsISupports /* Flag 0x00001000 is unused */ const unsigned long kInitSavePaperData = 0x00002000; /* Flag 0x00004000 is unused */ - const unsigned long kInitSaveEdges = 0x00008000; + /* Flag 0x00008000 is unused */ const unsigned long kInitSaveReversed = 0x00010000; const unsigned long kInitSaveInColor = 0x00020000; @@ -201,21 +201,6 @@ interface nsIPrintSettings : nsISupports attribute long startPageRange; attribute long endPageRange; - /** - * The edge defines the area at the border of the paper - * outside of which the printer cannot print. The headers and footers - * will be placed inside. - */ - attribute double edgeTop; /* these are in inches */ - attribute double edgeLeft; - attribute double edgeBottom; - attribute double edgeRight; - - /** - * The margins define the area of the paper to print the content to. - * The headers and footers are placed outside, but still inside the border - * defined by the edge attributes above. - */ attribute double marginTop; /* these are in inches */ attribute double marginLeft; attribute double marginBottom; @@ -297,8 +282,7 @@ interface nsIPrintSettings : nsISupports /* C++ Helper Functions */ [noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin); - [noscript] void SetEdgeInTwips(in nsNativeMarginRef aEdge); /* Purposely made this an "in" arg */ [noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin); - [noscript] void GetEdgeInTwips(in nsNativeMarginRef aEdge); + }; diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp index 2dfe8324b2d2..a38b9fbeb7c2 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp @@ -67,14 +67,10 @@ NS_IMPL_ISUPPORTS2(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService) // Pref Constants -static const char kMarginTop[] = "print_margin_top"; + static const char kMarginTop[] = "print_margin_top"; static const char kMarginLeft[] = "print_margin_left"; static const char kMarginBottom[] = "print_margin_bottom"; static const char kMarginRight[] = "print_margin_right"; -static const char kEdgeTop[] = "print_edge_top"; -static const char kEdgeLeft[] = "print_edge_left"; -static const char kEdgeBottom[] = "print_edge_bottom"; -static const char kEdgeRight[] = "print_edge_right"; // Prefs for Print Options static const char kPrintEvenPages[] = "print_evenpages"; @@ -267,24 +263,6 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, aPS->SetMarginInTwips(margin); } - if (aFlags & nsIPrintSettings::kInitSaveEdges) { - nsMargin margin; - margin.SizeTo(0,0,0,0); - ReadInchesIntToTwipsPref(GetPrefName(kEdgeTop, aPrinterName), margin.top, - kEdgeTop); - DUMP_INT(kReadStr, kEdgeTop, margin.top); - ReadInchesIntToTwipsPref(GetPrefName(kEdgeLeft, aPrinterName), margin.left, - kEdgeLeft); - DUMP_INT(kReadStr, kEdgeLeft, margin.left); - ReadInchesIntToTwipsPref(GetPrefName(kEdgeBottom, aPrinterName), - margin.bottom, kEdgeBottom); - DUMP_INT(kReadStr, kEdgeBottom, margin.bottom); - ReadInchesIntToTwipsPref(GetPrefName(kEdgeRight, aPrinterName), margin.right, - kEdgeRight); - DUMP_INT(kReadStr, kEdgeRight, margin.right); - aPS->SetEdgeInTwips(margin); - } - PRBool b; nsAutoString str; PRInt32 iVal; @@ -555,24 +533,6 @@ nsPrintOptions::WritePrefs(nsIPrintSettings *aPS, const nsAString& aPrinterName, } } - nsMargin edge; - if (aFlags & nsIPrintSettings::kInitSaveEdges) { - if (NS_SUCCEEDED(aPS->GetEdgeInTwips(edge))) { - WriteInchesIntFromTwipsPref(GetPrefName(kEdgeTop, aPrinterName), - edge.top); - DUMP_INT(kWriteStr, kEdgeTop, edge.top); - WriteInchesIntFromTwipsPref(GetPrefName(kEdgeLeft, aPrinterName), - edge.left); - DUMP_INT(kWriteStr, kEdgeLeft, edge.top); - WriteInchesIntFromTwipsPref(GetPrefName(kEdgeBottom, aPrinterName), - edge.bottom); - DUMP_INT(kWriteStr, kEdgeBottom, edge.top); - WriteInchesIntFromTwipsPref(GetPrefName(kEdgeRight, aPrinterName), - edge.right); - DUMP_INT(kWriteStr, kEdgeRight, edge.top); - } - } - // Paper size prefs are saved as a group if (aFlags & nsIPrintSettings::kInitSavePaperSize) { PRInt16 sizeUnit, sizeType; @@ -1170,36 +1130,6 @@ nsPrintOptions::WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips) mPrefBranch->SetCharPref(aPrefId, inchesStr.get()); } -void -nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, nscoord& aTwips, - const char * aMarginPref) -{ - if (!mPrefBranch) { - return; - } - - PRInt32 value; - nsresult rv = mPrefBranch->GetIntPref(aPrefId, &value); - if (NS_FAILED(rv)) { - rv = mPrefBranch->GetIntPref(aMarginPref, &value); - } - if (NS_SUCCEEDED(rv)) { - aTwips = NS_INCHES_TO_TWIPS(float(value)/100.0f); - } else { - aTwips = 0; - } -} - -void -nsPrintOptions::WriteInchesIntFromTwipsPref(const char * aPrefId, nscoord aTwips) -{ - if (!mPrefBranch) { - return; - } - - mPrefBranch->SetIntPref(aPrefId, PRInt32(NS_TWIPS_TO_INCHES(aTwips)*100.0f + 0.5f)); -} - void nsPrintOptions::ReadJustification(const char * aPrefId, PRInt16& aJust, PRInt16 aInitValue) diff --git a/widget/src/xpwidgets/nsPrintOptionsImpl.h b/widget/src/xpwidgets/nsPrintOptionsImpl.h index 15c07367a581..e9bd345e00f2 100644 --- a/widget/src/xpwidgets/nsPrintOptionsImpl.h +++ b/widget/src/xpwidgets/nsPrintOptionsImpl.h @@ -79,9 +79,6 @@ protected: void ReadInchesToTwipsPref(const char * aPrefId, nscoord& aTwips, const char * aMarginPref); void WriteInchesFromTwipsPref(const char * aPrefId, nscoord aTwips); - void ReadInchesIntToTwipsPref(const char * aPrefId, nscoord& aTwips, - const char * aMarginPref); - void WriteInchesIntFromTwipsPref(const char * aPrefId, nscoord aTwips); nsresult ReadPrefString(const char * aPrefId, nsAString& aString); /** diff --git a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp index b072d46fd6c9..497894a88707 100644 --- a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp +++ b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp @@ -82,7 +82,6 @@ nsPrintSettings::nsPrintSettings() : /* member initializers and constructor code */ nscoord halfInch = NS_INCHES_TO_TWIPS(0.5); mMargin.SizeTo(halfInch, halfInch, halfInch, halfInch); - mEdge.SizeTo(0, 0, 0, 0); mPrintOptions = kPrintOddPages | kPrintEvenPages; @@ -445,58 +444,6 @@ NS_IMETHODIMP nsPrintSettings::SetMarginRight(double aMarginRight) return NS_OK; } -/* attribute double edgeTop; */ -NS_IMETHODIMP nsPrintSettings::GetEdgeTop(double *aEdgeTop) -{ - NS_ENSURE_ARG_POINTER(aEdgeTop); - *aEdgeTop = NS_TWIPS_TO_INCHES(mEdge.top); - return NS_OK; -} -NS_IMETHODIMP nsPrintSettings::SetEdgeTop(double aEdgeTop) -{ - mEdge.top = NS_INCHES_TO_TWIPS(float(aEdgeTop)); - return NS_OK; -} - -/* attribute double edgeLeft; */ -NS_IMETHODIMP nsPrintSettings::GetEdgeLeft(double *aEdgeLeft) -{ - NS_ENSURE_ARG_POINTER(aEdgeLeft); - *aEdgeLeft = NS_TWIPS_TO_INCHES(mEdge.left); - return NS_OK; -} -NS_IMETHODIMP nsPrintSettings::SetEdgeLeft(double aEdgeLeft) -{ - mEdge.left = NS_INCHES_TO_TWIPS(float(aEdgeLeft)); - return NS_OK; -} - -/* attribute double edgeBottom; */ -NS_IMETHODIMP nsPrintSettings::GetEdgeBottom(double *aEdgeBottom) -{ - NS_ENSURE_ARG_POINTER(aEdgeBottom); - *aEdgeBottom = NS_TWIPS_TO_INCHES(mEdge.bottom); - return NS_OK; -} -NS_IMETHODIMP nsPrintSettings::SetEdgeBottom(double aEdgeBottom) -{ - mEdge.bottom = NS_INCHES_TO_TWIPS(float(aEdgeBottom)); - return NS_OK; -} - -/* attribute double edgeRight; */ -NS_IMETHODIMP nsPrintSettings::GetEdgeRight(double *aEdgeRight) -{ - NS_ENSURE_ARG_POINTER(aEdgeRight); - *aEdgeRight = NS_TWIPS_TO_INCHES(mEdge.right); - return NS_OK; -} -NS_IMETHODIMP nsPrintSettings::SetEdgeRight(double aEdgeRight) -{ - mEdge.right = NS_INCHES_TO_TWIPS(float(aEdgeRight)); - return NS_OK; -} - /* attribute double scaling; */ NS_IMETHODIMP nsPrintSettings::GetScaling(double *aScaling) { @@ -947,13 +894,6 @@ nsPrintSettings::SetMarginInTwips(nsMargin& aMargin) return NS_OK; } -NS_IMETHODIMP -nsPrintSettings::SetEdgeInTwips(nsMargin& aEdge) -{ - mEdge = aEdge; - return NS_OK; -} - /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h * @update 6/21/00 dwc @@ -965,13 +905,6 @@ nsPrintSettings::GetMarginInTwips(nsMargin& aMargin) return NS_OK; } -NS_IMETHODIMP -nsPrintSettings::GetEdgeInTwips(nsMargin& aEdge) -{ - aEdge = mEdge; - return NS_OK; -} - /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h */ @@ -1035,7 +968,6 @@ nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) mStartPageNum = rhs.mStartPageNum; mEndPageNum = rhs.mEndPageNum; mMargin = rhs.mMargin; - mEdge = rhs.mEdge; mScaling = rhs.mScaling; mPrintBGColors = rhs.mPrintBGColors; mPrintBGImages = rhs.mPrintBGImages; diff --git a/widget/src/xpwidgets/nsPrintSettingsImpl.h b/widget/src/xpwidgets/nsPrintSettingsImpl.h index 51ea61d4ea06..7f447927f0b5 100644 --- a/widget/src/xpwidgets/nsPrintSettingsImpl.h +++ b/widget/src/xpwidgets/nsPrintSettingsImpl.h @@ -82,7 +82,6 @@ protected: nsWeakPtr mSession; // Should never be touched by Clone or Assign nsMargin mMargin; - nsMargin mEdge; PRInt32 mPrintOptions; // scriptable data members diff --git a/xpfe/global/resources/content/printdialog.js b/xpfe/global/resources/content/printdialog.js index 23d86e910fa2..32ff0e5eb41d 100644 --- a/xpfe/global/resources/content/printdialog.js +++ b/xpfe/global/resources/content/printdialog.js @@ -407,7 +407,6 @@ function onAccept() if (saveToPrefs && printService != null) { var flags = gPrintSetInterface.kInitSavePaperSize | gPrintSetInterface.kInitSaveColorSpace | - gPrintSetInterface.kInitSaveEdges | gPrintSetInterface.kInitSaveInColor | gPrintSetInterface.kInitSaveResolutionName | gPrintSetInterface.kInitSaveDownloadFonts | diff --git a/xpfe/global/resources/content/unix/printjoboptions.js b/xpfe/global/resources/content/unix/printjoboptions.js index cbb7e579df3d..d77235c1c852 100644 --- a/xpfe/global/resources/content/unix/printjoboptions.js +++ b/xpfe/global/resources/content/unix/printjoboptions.js @@ -835,10 +835,26 @@ function loadDialog() dialog.cmdInput.value = print_command; dialog.jobTitleInput.value = print_jobtitle; - dialog.topInput.value = gPrintSettings.edgeTop.toFixed(2); - dialog.bottomInput.value = gPrintSettings.edgeBottom.toFixed(2); - dialog.leftInput.value = gPrintSettings.edgeLeft.toFixed(2); - dialog.rightInput.value = gPrintSettings.edgeRight.toFixed(2); + /* First initialize with the hardcoded defaults... */ + dialog.topInput.value = "0.04"; + dialog.bottomInput.value = "0.04"; + dialog.leftInput.value = "0.04"; + dialog.rightInput.value = "0.04"; + + try { + /* ... then try to get the generic settings ... */ + dialog.topInput.value = gPrefs.getIntPref("print.print_edge_top") / 100.0; + dialog.bottomInput.value = gPrefs.getIntPref("print.print_edge_bottom") / 100.0; + dialog.leftInput.value = gPrefs.getIntPref("print.print_edge_left") / 100.0; + dialog.rightInput.value = gPrefs.getIntPref("print.print_edge_right") / 100.0; + + /* ... and then the printer specific settings. */ + var printername = gPrintSettings.printerName; + dialog.topInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_top") / 100.0; + dialog.bottomInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_bottom") / 100.0; + dialog.leftInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_left") / 100.0; + dialog.rightInput.value = gPrefs.getIntPref("print.printer_"+printername+".print_edge_right") / 100.0; + } catch (e) { } } //--------------------------------------------------- @@ -905,10 +921,22 @@ function onAccept() gPrintSettings.printCommand = dialog.cmdInput.value; gPrintSettings.title = dialog.jobTitleInput.value; - gPrintSettings.edgeTop = dialog.topInput.value; - gPrintSettings.edgeBottom = dialog.bottomInput.value; - gPrintSettings.edgeLeft = dialog.leftInput.value; - gPrintSettings.edgeRight = dialog.rightInput.value; + // + try { + var printerName = gPrintSettings.printerName; + var i = dialog.topInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_top", i); + + i = dialog.bottomInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_bottom", i); + + i = dialog.leftInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_left", i); + + i = dialog.rightInput.value * 100; + gPrefs.setIntPref("print.printer_"+printerName+".print_edge_right", i); + } catch (e) { + } if (doDebug) { dump("onAccept******************************\n");