Skip to content

Commit

Permalink
Bug 1665901 - Remove (Windows-specific) paperData field, as it now ju…
Browse files Browse the repository at this point in the history
…st duplicates the paper id. r=bobowen

Differential Revision: https://phabricator.services.mozilla.com/D90686
  • Loading branch information
jfkthame committed Sep 18, 2020
1 parent 3e6cac3 commit 0702a66
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 51 deletions.
3 changes: 0 additions & 3 deletions toolkit/components/printing/content/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,6 @@ var PrintSettingsViewProxy = {
let paperSize = this.availablePaperSizes[paperId];
target.paperWidth = paperSize.width;
target.paperHeight = paperSize.height;
if (+paperSize.id > 0) {
target.paperData = paperSize.id;
}
target.unwriteableMarginTop = paperSize.unwriteableMarginTop;
target.unwriteableMarginRight = paperSize.unwriteableMarginRight;
target.unwriteableMarginBottom = paperSize.unwriteableMarginBottom;
Expand Down
1 change: 0 additions & 1 deletion toolkit/components/printingui/ipc/PPrintingTypes.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct PrintData {
bool showPrintProgress;

nsString paperName;
short paperData;
double paperWidth;
double paperHeight;
short paperSizeUnit;
Expand Down
3 changes: 1 addition & 2 deletions widget/nsIPrintSettings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface nsIPrintSettings : nsISupports
const unsigned long kInitSaveResolution = 0x00000400;
const unsigned long kInitSaveDuplex = 0x00000800;
/* Flag 0x00001000 is unused */
const unsigned long kInitSavePaperData = 0x00002000;
/* Flag 0x00002000 is unused */
const unsigned long kInitSaveUnwriteableMargins = 0x00004000;
const unsigned long kInitSaveEdges = 0x00008000;

Expand Down Expand Up @@ -202,7 +202,6 @@ interface nsIPrintSettings : nsISupports

/* Additional XP Related */
attribute AString paperName; /* name of paper */
attribute short paperData; /* native data value */
attribute double paperWidth; /* width of the paper in inches or mm */
attribute double paperHeight; /* height of the paper in inches or mm */
attribute short paperSizeUnit; /* paper is in inches or mm */
Expand Down
12 changes: 0 additions & 12 deletions widget/nsPrintSettingsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ nsPrintSettings::nsPrintSettings()
mShowPrintProgress(true),
mShowMarginGuides(false),
mPrintPageDelay(50),
mPaperData(0),
mPaperWidth(8.5),
mPaperHeight(11.0),
mPaperSizeUnit(kPaperSizeInches),
Expand Down Expand Up @@ -660,16 +659,6 @@ NS_IMETHODIMP nsPrintSettings::SetPaperSizeUnit(int16_t aPaperSizeUnit) {
return NS_OK;
}

NS_IMETHODIMP nsPrintSettings::GetPaperData(int16_t* aPaperData) {
NS_ENSURE_ARG_POINTER(aPaperData);
*aPaperData = mPaperData;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::SetPaperData(int16_t aPaperData) {
mPaperData = aPaperData;
return NS_OK;
}

/** ---------------------------------------------------
* See documentation in nsPrintSettingsService.h
* @update 6/21/00 dwc
Expand Down Expand Up @@ -796,7 +785,6 @@ nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) {
mShowPrintProgress = rhs.mShowPrintProgress;
mShowMarginGuides = rhs.mShowMarginGuides;
mPaperName = rhs.mPaperName;
mPaperData = rhs.mPaperData;
mPaperWidth = rhs.mPaperWidth;
mPaperHeight = rhs.mPaperHeight;
mPaperSizeUnit = rhs.mPaperSizeUnit;
Expand Down
1 change: 0 additions & 1 deletion widget/nsPrintSettingsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class nsPrintSettings : public nsIPrintSettings {
nsString mFooterStrs[NUM_HEAD_FOOT];

nsString mPaperName;
int16_t mPaperData;
double mPaperWidth;
double mPaperHeight;
int16_t mPaperSizeUnit;
Expand Down
19 changes: 0 additions & 19 deletions widget/nsPrintSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ static const char kPrintFooterStrRight[] = "print_footerright";
static const char kPrintReversed[] = "print_reversed";
static const char kPrintInColor[] = "print_in_color";
static const char kPrintPaperName[] = "print_paper_name";
static const char kPrintPaperData[] = "print_paper_data";
static const char kPrintPaperSizeUnit[] = "print_paper_size_unit";
static const char kPrintPaperWidth[] = "print_paper_width";
static const char kPrintPaperHeight[] = "print_paper_height";
Expand Down Expand Up @@ -133,7 +132,6 @@ nsPrintSettingsService::SerializeToPrintData(nsIPrintSettings* aSettings,
aSettings->GetShowPrintProgress(&data->showPrintProgress());

aSettings->GetPaperName(data->paperName());
aSettings->GetPaperData(&data->paperData());
aSettings->GetPaperWidth(&data->paperWidth());
aSettings->GetPaperHeight(&data->paperHeight());
aSettings->GetPaperSizeUnit(&data->paperSizeUnit());
Expand Down Expand Up @@ -233,7 +231,6 @@ nsPrintSettingsService::DeserializeToPrintSettings(const PrintData& data,

settings->SetPaperName(data.paperName());

settings->SetPaperData(data.paperData());
settings->SetPaperWidth(data.paperWidth());
settings->SetPaperHeight(data.paperHeight());
settings->SetPaperSizeUnit(data.paperSizeUnit());
Expand Down Expand Up @@ -512,13 +509,6 @@ nsresult nsPrintSettingsService::ReadPrefs(nsIPrintSettings* aPS,
}
}

if (aFlags & nsIPrintSettings::kInitSavePaperData) {
if (GETINTPREF(kPrintPaperData, &iVal)) {
aPS->SetPaperData(iVal);
DUMP_INT(kReadStr, kPrintPaperData, iVal);
}
}

if (aFlags & nsIPrintSettings::kInitSaveOrientation) {
if (GETINTPREF(kPrintOrientation, &iVal)) {
aPS->SetOrientation(iVal);
Expand Down Expand Up @@ -669,7 +659,6 @@ nsresult nsPrintSettingsService::WritePrefs(nsIPrintSettings* aPS,
bool b;
nsString uStr;
int32_t iVal;
int16_t iVal16;
double dbl;

if (aFlags & nsIPrintSettings::kInitSaveOddEvenPages) {
Expand Down Expand Up @@ -759,14 +748,6 @@ nsresult nsPrintSettingsService::WritePrefs(nsIPrintSettings* aPS,
}
}

if (aFlags & nsIPrintSettings::kInitSavePaperData) {
if (NS_SUCCEEDED(aPS->GetPaperData(&iVal16))) {
DUMP_INT(kWriteStr, kPrintPaperData, iVal16);
Preferences::SetInt(GetPrefName(kPrintPaperData, aPrinterName),
int32_t(iVal16));
}
}

if (aFlags & nsIPrintSettings::kInitSaveOrientation) {
if (NS_SUCCEEDED(aPS->GetOrientation(&iVal))) {
DUMP_INT(kWriteStr, kPrintOrientation, iVal);
Expand Down
24 changes: 11 additions & 13 deletions widget/windows/nsPrintSettingsWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ void nsPrintSettingsWin::InitWithInitializer(
}

if (mDevMode->dmFields & DM_PAPERSIZE) {
SetPaperData(mDevMode->dmPaperSize);
nsString paperIdString;
paperIdString.AppendInt(mDevMode->dmPaperSize);
SetPaperName(paperIdString);
if (mDevMode->dmPaperSize > 0 &&
mDevMode->dmPaperSize < int32_t(ArrayLength(kPaperSizeUnits))) {
SetPaperSizeUnit(kPaperSizeUnits[mPaperData]);
SetPaperSizeUnit(kPaperSizeUnits[mDevMode->dmPaperSize]);
}
} else {
SetPaperData(-1);
}

if (mDevMode->dmFields & DM_COLOR) {
Expand Down Expand Up @@ -351,14 +351,13 @@ void nsPrintSettingsWin::CopyFromNative(HDC aHdc, DEVMODEW* aDevMode) {
}

if (aDevMode->dmFields & DM_PAPERSIZE) {
mPaperData = aDevMode->dmPaperSize;
mPaperName.Truncate(0);
mPaperName.AppendInt(aDevMode->dmPaperSize);
// If not a paper size we know about, the unit will be the last one saved.
if (mPaperData > 0 &&
mPaperData < int32_t(mozilla::ArrayLength(kPaperSizeUnits))) {
mPaperSizeUnit = kPaperSizeUnits[mPaperData];
if (aDevMode->dmPaperSize > 0 &&
aDevMode->dmPaperSize < int32_t(ArrayLength(kPaperSizeUnits))) {
mPaperSizeUnit = kPaperSizeUnits[aDevMode->dmPaperSize];
}
} else {
mPaperData = -1;
}

if (aDevMode->dmFields & DM_COLOR) {
Expand Down Expand Up @@ -404,8 +403,8 @@ void nsPrintSettingsWin::CopyFromNative(HDC aHdc, DEVMODEW* aDevMode) {
void nsPrintSettingsWin::CopyToNative(DEVMODEW* aDevMode) {
MOZ_ASSERT(aDevMode);

if (mPaperData >= 0) {
aDevMode->dmPaperSize = mPaperData;
if (!mPaperName.IsEmpty()) {
aDevMode->dmPaperSize = _wtoi((const wchar_t*)mPaperName.BeginReading());
aDevMode->dmFields |= DM_PAPERSIZE;
} else {
aDevMode->dmPaperSize = 0;
Expand Down Expand Up @@ -545,7 +544,6 @@ Tester::Tester() {
ps->SetFooterStrCenter(NS_ConvertUTF8toUTF16("Center").get());
ps->SetFooterStrRight(NS_ConvertUTF8toUTF16("Right").get());
ps->SetPaperName(NS_ConvertUTF8toUTF16("Paper Name").get());
ps->SetPaperData(1);
ps->SetPaperWidth(100.0);
ps->SetPaperHeight(50.0);
ps->SetPaperSizeUnit(nsIPrintSettings::kPaperSizeMillimeters);
Expand Down

0 comments on commit 0702a66

Please sign in to comment.