mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 537890. Part 11: Introduce _TO_INT_TWIPS macros and have some _TO_TWIPS callers use _TO_INT_TWIPS instead. r=dbaron
This commit is contained in:
parent
20c2a19d6a
commit
8d6e97edd5
@ -474,6 +474,9 @@ inline float NSTwipsToUnits(float aTwips, float aUnitsPerPoint)
|
||||
|
||||
#define NS_PICAS_TO_TWIPS(x) NSUnitsToTwips((x), 12.0f) // 12 points per pica
|
||||
|
||||
#define NS_POINTS_TO_INT_TWIPS(x) NSToIntRound(NS_POINTS_TO_TWIPS(x))
|
||||
#define NS_INCHES_TO_INT_TWIPS(x) NSToIntRound(NS_INCHES_TO_TWIPS(x))
|
||||
|
||||
#define NS_TWIPS_TO_POINTS(x) NSTwipsToUnits((x), 1.0f)
|
||||
#define NS_TWIPS_TO_INCHES(x) NSTwipsToUnits((x), 1.0f / POINTS_PER_INCH_FLOAT)
|
||||
|
||||
|
@ -200,7 +200,7 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
||||
mPageData->mPrintSettings->GetEdgeInTwips(edgeTwips);
|
||||
|
||||
// sanity check the values. three inches are sometimes needed
|
||||
PRInt32 inchInTwips = NS_INCHES_TO_TWIPS(3.0);
|
||||
PRInt32 inchInTwips = NS_INCHES_TO_INT_TWIPS(3.0);
|
||||
edgeTwips.top = NS_MIN(NS_MAX(edgeTwips.top, 0), inchInTwips);
|
||||
edgeTwips.bottom = NS_MIN(NS_MAX(edgeTwips.bottom, 0), inchInTwips);
|
||||
edgeTwips.left = NS_MIN(NS_MAX(edgeTwips.left, 0), inchInTwips);
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
NS_IMETHOD SetTotalNumPages(PRInt32 aTotal) { mTotalPages = aTotal; return NS_OK; }
|
||||
|
||||
// Gets the dead space (the gray area) around the Print Preview Page
|
||||
NS_IMETHOD GetDeadSpaceValue(nscoord* aValue) { *aValue = NS_INCHES_TO_TWIPS(0.25); return NS_OK; }
|
||||
NS_IMETHOD GetDeadSpaceValue(nscoord* aValue) { *aValue = NS_INCHES_TO_INT_TWIPS(0.25); return NS_OK; }
|
||||
|
||||
// For Shrink To Fit
|
||||
NS_IMETHOD GetSTFPercent(float& aSTFPercent);
|
||||
|
@ -116,10 +116,10 @@ NS_IMETHODIMP nsPrintSettingsX::InitUnwriteableMargin()
|
||||
PMPageFormat pageFormat = GetPMPageFormat();
|
||||
::PMGetPageFormatPaper(pageFormat, &paper);
|
||||
::PMPaperGetMargins(paper, &paperMargin);
|
||||
mUnwriteableMargin.top = NS_POINTS_TO_TWIPS(paperMargin.top);
|
||||
mUnwriteableMargin.left = NS_POINTS_TO_TWIPS(paperMargin.left);
|
||||
mUnwriteableMargin.bottom = NS_POINTS_TO_TWIPS(paperMargin.bottom);
|
||||
mUnwriteableMargin.right = NS_POINTS_TO_TWIPS(paperMargin.right);
|
||||
mUnwriteableMargin.top = NS_POINTS_TO_INT_TWIPS(paperMargin.top);
|
||||
mUnwriteableMargin.left = NS_POINTS_TO_INT_TWIPS(paperMargin.left);
|
||||
mUnwriteableMargin.bottom = NS_POINTS_TO_INT_TWIPS(paperMargin.bottom);
|
||||
mUnwriteableMargin.right = NS_POINTS_TO_INT_TWIPS(paperMargin.right);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
|
@ -591,10 +591,10 @@ void
|
||||
nsPrintSettingsGTK::InitUnwriteableMargin()
|
||||
{
|
||||
mUnwriteableMargin.SizeTo(
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_left_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_top_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_right_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_TWIPS(gtk_page_setup_get_bottom_margin(mPageSetup, GTK_UNIT_INCH))
|
||||
NS_INCHES_TO_INT_TWIPS(gtk_page_setup_get_left_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_INT_TWIPS(gtk_page_setup_get_top_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_INT_TWIPS(gtk_page_setup_get_right_margin(mPageSetup, GTK_UNIT_INCH)),
|
||||
NS_INCHES_TO_INT_TWIPS(gtk_page_setup_get_bottom_margin(mPageSetup, GTK_UNIT_INCH))
|
||||
);
|
||||
}
|
||||
|
||||
@ -721,8 +721,8 @@ nsPrintSettingsGTK::SetPaperSizeUnit(PRInt16 aPaperSizeUnit)
|
||||
NS_IMETHODIMP
|
||||
nsPrintSettingsGTK::GetEffectivePageSize(double *aWidth, double *aHeight)
|
||||
{
|
||||
*aWidth = NS_INCHES_TO_TWIPS(gtk_paper_size_get_width(mPaperSize, GTK_UNIT_INCH));
|
||||
*aHeight = NS_INCHES_TO_TWIPS(gtk_paper_size_get_height(mPaperSize, GTK_UNIT_INCH));
|
||||
*aWidth = NS_INCHES_TO_INT_TWIPS(gtk_paper_size_get_width(mPaperSize, GTK_UNIT_INCH));
|
||||
*aHeight = NS_INCHES_TO_INT_TWIPS(gtk_paper_size_get_height(mPaperSize, GTK_UNIT_INCH));
|
||||
|
||||
GtkPageOrientation gtkOrient = gtk_page_setup_get_orientation(mPageSetup);
|
||||
|
||||
|
@ -250,7 +250,7 @@ nsPrintOptions::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
|
||||
NS_ENSURE_ARG_POINTER(aPS);
|
||||
|
||||
if (aFlags & nsIPrintSettings::kInitSaveMargins) {
|
||||
PRInt32 halfInch = NS_INCHES_TO_TWIPS(0.5);
|
||||
PRInt32 halfInch = NS_INCHES_TO_INT_TWIPS(0.5);
|
||||
nsIntMargin margin(halfInch, halfInch, halfInch, halfInch);
|
||||
ReadInchesToTwipsPref(GetPrefName(kMarginTop, aPrinterName), margin.top,
|
||||
kMarginTop);
|
||||
@ -1182,7 +1182,7 @@ nsPrintOptions::ReadInchesToTwipsPref(const char * aPrefId, PRInt32& aTwips,
|
||||
PRInt32 errCode;
|
||||
float inches = justStr.ToFloat(&errCode);
|
||||
if (NS_SUCCEEDED(errCode)) {
|
||||
aTwips = NS_INCHES_TO_TWIPS(inches);
|
||||
aTwips = NS_INCHES_TO_INT_TWIPS(inches);
|
||||
} else {
|
||||
aTwips = 0;
|
||||
}
|
||||
@ -1218,7 +1218,7 @@ nsPrintOptions::ReadInchesIntToTwipsPref(const char * aPrefId, PRInt32& aTwips,
|
||||
rv = mPrefBranch->GetIntPref(aMarginPref, &value);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aTwips = NS_INCHES_TO_TWIPS(float(value)/100.0f);
|
||||
aTwips = NS_INCHES_TO_INT_TWIPS(float(value)/100.0f);
|
||||
} else {
|
||||
aTwips = 0;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ nsPrintSettings::nsPrintSettings() :
|
||||
{
|
||||
|
||||
/* member initializers and constructor code */
|
||||
PRInt32 marginWidth = NS_INCHES_TO_TWIPS(DEFAULT_MARGIN_WIDTH);
|
||||
PRInt32 marginWidth = NS_INCHES_TO_INT_TWIPS(DEFAULT_MARGIN_WIDTH);
|
||||
mMargin.SizeTo(marginWidth, marginWidth, marginWidth, marginWidth);
|
||||
mEdge.SizeTo(0, 0, 0, 0);
|
||||
mUnwriteableMargin.SizeTo(0,0,0,0);
|
||||
@ -404,7 +404,7 @@ NS_IMETHODIMP nsPrintSettings::GetMarginTop(double *aMarginTop)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetMarginTop(double aMarginTop)
|
||||
{
|
||||
mMargin.top = NS_INCHES_TO_TWIPS(float(aMarginTop));
|
||||
mMargin.top = NS_INCHES_TO_INT_TWIPS(float(aMarginTop));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -417,7 +417,7 @@ NS_IMETHODIMP nsPrintSettings::GetMarginLeft(double *aMarginLeft)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetMarginLeft(double aMarginLeft)
|
||||
{
|
||||
mMargin.left = NS_INCHES_TO_TWIPS(float(aMarginLeft));
|
||||
mMargin.left = NS_INCHES_TO_INT_TWIPS(float(aMarginLeft));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ NS_IMETHODIMP nsPrintSettings::GetMarginBottom(double *aMarginBottom)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetMarginBottom(double aMarginBottom)
|
||||
{
|
||||
mMargin.bottom = NS_INCHES_TO_TWIPS(float(aMarginBottom));
|
||||
mMargin.bottom = NS_INCHES_TO_INT_TWIPS(float(aMarginBottom));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ NS_IMETHODIMP nsPrintSettings::GetMarginRight(double *aMarginRight)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetMarginRight(double aMarginRight)
|
||||
{
|
||||
mMargin.right = NS_INCHES_TO_TWIPS(float(aMarginRight));
|
||||
mMargin.right = NS_INCHES_TO_INT_TWIPS(float(aMarginRight));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -456,7 +456,7 @@ NS_IMETHODIMP nsPrintSettings::GetEdgeTop(double *aEdgeTop)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetEdgeTop(double aEdgeTop)
|
||||
{
|
||||
mEdge.top = NS_INCHES_TO_TWIPS(float(aEdgeTop));
|
||||
mEdge.top = NS_INCHES_TO_INT_TWIPS(float(aEdgeTop));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -469,7 +469,7 @@ NS_IMETHODIMP nsPrintSettings::GetEdgeLeft(double *aEdgeLeft)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetEdgeLeft(double aEdgeLeft)
|
||||
{
|
||||
mEdge.left = NS_INCHES_TO_TWIPS(float(aEdgeLeft));
|
||||
mEdge.left = NS_INCHES_TO_INT_TWIPS(float(aEdgeLeft));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ NS_IMETHODIMP nsPrintSettings::GetEdgeBottom(double *aEdgeBottom)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetEdgeBottom(double aEdgeBottom)
|
||||
{
|
||||
mEdge.bottom = NS_INCHES_TO_TWIPS(float(aEdgeBottom));
|
||||
mEdge.bottom = NS_INCHES_TO_INT_TWIPS(float(aEdgeBottom));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ NS_IMETHODIMP nsPrintSettings::GetEdgeRight(double *aEdgeRight)
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetEdgeRight(double aEdgeRight)
|
||||
{
|
||||
mEdge.right = NS_INCHES_TO_TWIPS(float(aEdgeRight));
|
||||
mEdge.right = NS_INCHES_TO_INT_TWIPS(float(aEdgeRight));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginTop(double *aUnwriteableMargi
|
||||
NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginTop(double aUnwriteableMarginTop)
|
||||
{
|
||||
if (aUnwriteableMarginTop >= 0.0) {
|
||||
mUnwriteableMargin.top = NS_INCHES_TO_TWIPS(aUnwriteableMarginTop);
|
||||
mUnwriteableMargin.top = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginTop);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -524,7 +524,7 @@ NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginLeft(double *aUnwriteableMarg
|
||||
NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft)
|
||||
{
|
||||
if (aUnwriteableMarginLeft >= 0.0) {
|
||||
mUnwriteableMargin.left = NS_INCHES_TO_TWIPS(aUnwriteableMarginLeft);
|
||||
mUnwriteableMargin.left = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginLeft);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -539,7 +539,7 @@ NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginBottom(double *aUnwriteableMa
|
||||
NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom)
|
||||
{
|
||||
if (aUnwriteableMarginBottom >= 0.0) {
|
||||
mUnwriteableMargin.bottom = NS_INCHES_TO_TWIPS(aUnwriteableMarginBottom);
|
||||
mUnwriteableMargin.bottom = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginBottom);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -554,7 +554,7 @@ NS_IMETHODIMP nsPrintSettings::GetUnwriteableMarginRight(double *aUnwriteableMar
|
||||
NS_IMETHODIMP nsPrintSettings::SetUnwriteableMarginRight(double aUnwriteableMarginRight)
|
||||
{
|
||||
if (aUnwriteableMarginRight >= 0.0) {
|
||||
mUnwriteableMargin.right = NS_INCHES_TO_TWIPS(aUnwriteableMarginRight);
|
||||
mUnwriteableMargin.right = NS_INCHES_TO_INT_TWIPS(aUnwriteableMarginRight);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user