зеркало из https://github.com/mozilla/pjs.git
Bug 537890. Part 8: Define MM_PER_INCH_FLOAT. r=dbaron
This commit is contained in:
Родитель
2e0c0f2a86
Коммит
b2bed0c0ce
|
@ -207,7 +207,7 @@ nsSVGLength2::GetMMPerPixel(nsIFrame *aNonSVGFrame)
|
|||
nsPresContext* presContext = aNonSVGFrame->PresContext();
|
||||
float pixelsPerInch =
|
||||
presContext->AppUnitsToFloatCSSPixels(presContext->AppUnitsPerInch());
|
||||
return 25.4f/pixelsPerInch;
|
||||
return MM_PER_INCH_FLOAT/pixelsPerInch;
|
||||
}
|
||||
|
||||
static float
|
||||
|
@ -277,11 +277,11 @@ nsSVGLength2::GetUnitScaleFactor(nsSVGSVGElement *aCtx, PRUint8 aUnitType) const
|
|||
case nsIDOMSVGLength::SVG_LENGTHTYPE_CM:
|
||||
return GetMMPerPixel(aCtx) / 10.0f;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_IN:
|
||||
return GetMMPerPixel(aCtx) / 25.4f;
|
||||
return GetMMPerPixel(aCtx) / MM_PER_INCH_FLOAT;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_PT:
|
||||
return GetMMPerPixel(aCtx) * POINTS_PER_INCH_FLOAT / 25.4f;
|
||||
return GetMMPerPixel(aCtx) * POINTS_PER_INCH_FLOAT / MM_PER_INCH_FLOAT;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_PC:
|
||||
return GetMMPerPixel(aCtx) * POINTS_PER_INCH_FLOAT / 24.4f / 12.0f;
|
||||
return GetMMPerPixel(aCtx) * POINTS_PER_INCH_FLOAT / MM_PER_INCH_FLOAT / 12.0f;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE:
|
||||
return 100.0f / GetAxisLength(aCtx);
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_EMS:
|
||||
|
@ -310,11 +310,11 @@ nsSVGLength2::GetUnitScaleFactor(nsIFrame *aFrame, PRUint8 aUnitType) const
|
|||
case nsIDOMSVGLength::SVG_LENGTHTYPE_CM:
|
||||
return GetMMPerPixel(aFrame) / 10.0f;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_IN:
|
||||
return GetMMPerPixel(aFrame) / 25.4f;
|
||||
return GetMMPerPixel(aFrame) / MM_PER_INCH_FLOAT;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_PT:
|
||||
return GetMMPerPixel(aFrame) * POINTS_PER_INCH_FLOAT / 25.4f;
|
||||
return GetMMPerPixel(aFrame) * POINTS_PER_INCH_FLOAT / MM_PER_INCH_FLOAT;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_PC:
|
||||
return GetMMPerPixel(aFrame) * POINTS_PER_INCH_FLOAT / 24.4f / 12.0f;
|
||||
return GetMMPerPixel(aFrame) * POINTS_PER_INCH_FLOAT / MM_PER_INCH_FLOAT / 12.0f;
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE:
|
||||
return 100.0f / GetAxisLength(aFrame);
|
||||
case nsIDOMSVGLength::SVG_LENGTHTYPE_EMS:
|
||||
|
|
|
@ -317,7 +317,8 @@ nsSVGSVGElement::GetPixelUnitToMillimeterX(float *aPixelUnitToMillimeterX)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
*aPixelUnitToMillimeterX = 25.4f / nsPresContext::AppUnitsToIntCSSPixels(context->AppUnitsPerInch());
|
||||
*aPixelUnitToMillimeterX = MM_PER_INCH_FLOAT /
|
||||
nsPresContext::AppUnitsToIntCSSPixels(context->AppUnitsPerInch());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -340,7 +341,7 @@ nsSVGSVGElement::GetScreenPixelToMillimeterX(float *aScreenPixelToMillimeterX)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
*aScreenPixelToMillimeterX = 25.4f /
|
||||
*aScreenPixelToMillimeterX = MM_PER_INCH_FLOAT /
|
||||
nsPresContext::AppUnitsToIntCSSPixels(context->AppUnitsPerInch());
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -448,6 +448,8 @@ inline float NSCoordScale(nscoord aCoord, PRInt32 aFromAPP, PRInt32 aToAPP)
|
|||
#define TWIPS_PER_POINT_FLOAT 20.0f
|
||||
#define POINTS_PER_INCH_INT 72
|
||||
#define POINTS_PER_INCH_FLOAT 72.0f
|
||||
#define CM_PER_INCH_FLOAT 2.54f
|
||||
#define MM_PER_INCH_FLOAT 25.4f
|
||||
|
||||
/*
|
||||
* Twips/unit conversions
|
||||
|
|
|
@ -313,12 +313,12 @@ nsROCSSPrimitiveValue::GetFloatValue(PRUint16 aUnitType, float* aReturn)
|
|||
case CSS_CM :
|
||||
if (mType != CSS_PX)
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
*aReturn = mValue.mAppUnits * 2.54f / float(mAppUnitsPerInch);
|
||||
*aReturn = mValue.mAppUnits * CM_PER_INCH_FLOAT / float(mAppUnitsPerInch);
|
||||
break;
|
||||
case CSS_MM :
|
||||
if (mType != CSS_PX)
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
*aReturn = mValue.mAppUnits * 25.4f / float(mAppUnitsPerInch);
|
||||
*aReturn = mValue.mAppUnits * MM_PER_INCH_FLOAT / float(mAppUnitsPerInch);
|
||||
break;
|
||||
case CSS_IN :
|
||||
if (mType != CSS_PX)
|
||||
|
|
|
@ -980,7 +980,7 @@ nsChildView::GetDPI()
|
|||
// userSpaceScaleFactor screen pixels. So divide the screen height
|
||||
// by userSpaceScaleFactor to get the number of "device pixels"
|
||||
// available.
|
||||
return (heightPx / scaleFactor) / (heightMM / 25.4f);
|
||||
return (heightPx / scaleFactor) / (heightMM / MM_PER_INCH_FLOAT);
|
||||
}
|
||||
|
||||
LayerManager*
|
||||
|
|
|
@ -40,13 +40,14 @@
|
|||
|
||||
#include "nsPaperPS.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCoord.h"
|
||||
|
||||
#define COUNTOF(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
const nsPaperSizePS_ nsPaperSizePS::mList[] =
|
||||
{
|
||||
#define SIZE_MM(x) (x)
|
||||
#define SIZE_INCH(x) ((x) * 25.4)
|
||||
#define SIZE_INCH(x) ((x) * MM_PER_INCH_FLOAT)
|
||||
{ "A5", SIZE_MM(148), SIZE_MM(210), PR_TRUE },
|
||||
{ "A4", SIZE_MM(210), SIZE_MM(297), PR_TRUE },
|
||||
{ "A3", SIZE_MM(297), SIZE_MM(420), PR_TRUE },
|
||||
|
|
|
@ -826,7 +826,7 @@ nsWindow::GetDPI()
|
|||
{
|
||||
Display *dpy = GDK_DISPLAY();
|
||||
int defaultScreen = DefaultScreen(dpy);
|
||||
double heightInches = DisplayHeightMM(dpy, defaultScreen)/25.4;
|
||||
double heightInches = DisplayHeightMM(dpy, defaultScreen)/MM_PER_INCH_FLOAT;
|
||||
if (heightInches < 0.25) {
|
||||
// Something's broken, but we'd better not crash.
|
||||
return 96.0f;
|
||||
|
|
|
@ -1062,7 +1062,7 @@ float nsWindow::GetDPI()
|
|||
if (!dc)
|
||||
return 96.0f;
|
||||
|
||||
double heightInches = ::GetDeviceCaps(dc, VERTSIZE)/25.4;
|
||||
double heightInches = ::GetDeviceCaps(dc, VERTSIZE)/MM_PER_INCH_FLOAT;
|
||||
int heightPx = ::GetDeviceCaps(dc, VERTRES);
|
||||
::ReleaseDC(mWnd, dc);
|
||||
if (heightInches < 0.25) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче