mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 537890. Part 5: Make pc, in, mm and cm be a fixed number of CSS pixels. r=dbaron
This commit is contained in:
parent
bd0e4c32ea
commit
3e8e830840
@ -234,35 +234,9 @@ imgIRequest* nsCSSValue::GetImageValue() const
|
||||
|
||||
nscoord nsCSSValue::GetFixedLength(nsPresContext* aPresContext) const
|
||||
{
|
||||
NS_ASSERTION(IsFixedLengthUnit(), "not a fixed length unit");
|
||||
|
||||
float twips;
|
||||
switch (mUnit) {
|
||||
case eCSSUnit_Inch:
|
||||
twips = NS_INCHES_TO_TWIPS(mValue.mFloat);
|
||||
break;
|
||||
|
||||
case eCSSUnit_Millimeter:
|
||||
twips = NS_MILLIMETERS_TO_TWIPS(mValue.mFloat);
|
||||
break;
|
||||
|
||||
case eCSSUnit_PhysicalMillimeter:
|
||||
twips = NS_MILLIMETERS_TO_TWIPS(mValue.mFloat);
|
||||
break;
|
||||
|
||||
case eCSSUnit_Centimeter:
|
||||
twips = NS_CENTIMETERS_TO_TWIPS(mValue.mFloat);
|
||||
break;
|
||||
|
||||
case eCSSUnit_Pica:
|
||||
twips = NS_PICAS_TO_TWIPS(mValue.mFloat);
|
||||
break;
|
||||
|
||||
default:
|
||||
NS_ERROR("should never get here");
|
||||
return 0;
|
||||
}
|
||||
NS_ASSERTION(mUnit == eCSSUnit_PhysicalMillimeter, "not a fixed length unit");
|
||||
|
||||
float twips = NS_MILLIMETERS_TO_TWIPS(mValue.mFloat);
|
||||
return aPresContext->TwipsToAppUnits(twips);
|
||||
}
|
||||
|
||||
@ -270,17 +244,19 @@ nscoord nsCSSValue::GetPixelLength() const
|
||||
{
|
||||
NS_ASSERTION(IsPixelLengthUnit(), "not a fixed length unit");
|
||||
|
||||
double scaleFactor;
|
||||
switch (mUnit) {
|
||||
case eCSSUnit_Pixel:
|
||||
return nsPresContext::CSSPixelsToAppUnits(mValue.mFloat);
|
||||
|
||||
case eCSSUnit_Point:
|
||||
return nsPresContext::CSSPixelsToAppUnits(mValue.mFloat*4/3);
|
||||
|
||||
case eCSSUnit_Pixel: return nsPresContext::CSSPixelsToAppUnits(mValue.mFloat);
|
||||
case eCSSUnit_Pica: scaleFactor = 16.0; break;
|
||||
case eCSSUnit_Point: scaleFactor = 4/3.0; break;
|
||||
case eCSSUnit_Inch: scaleFactor = 96.0; break;
|
||||
case eCSSUnit_Millimeter: scaleFactor = 96/25.4; break;
|
||||
case eCSSUnit_Centimeter: scaleFactor = 96/2.54; break;
|
||||
default:
|
||||
NS_ERROR("should never get here");
|
||||
return 0;
|
||||
}
|
||||
return nsPresContext::CSSPixelsToAppUnits(float(mValue.mFloat*scaleFactor));
|
||||
}
|
||||
|
||||
void nsCSSValue::DoReset()
|
||||
|
@ -147,17 +147,8 @@ enum nsCSSUnit {
|
||||
eCSSUnit_Percent = 90, // (float) 1.0 == 100%) value is percentage of something
|
||||
eCSSUnit_Number = 91, // (float) value is numeric (usually multiplier, different behavior that percent)
|
||||
|
||||
// Length units - fixed
|
||||
// US English
|
||||
eCSSUnit_Inch = 100, // (float) 0.0254 meters
|
||||
|
||||
// Metric
|
||||
eCSSUnit_Millimeter = 207, // (float) 1/1000 meter
|
||||
eCSSUnit_PhysicalMillimeter = 208, // (float) 1/1000 meter
|
||||
eCSSUnit_Centimeter = 209, // (float) 1/100 meter
|
||||
|
||||
// US Typographic
|
||||
eCSSUnit_Pica = 301, // (float) 12 points == 1/6 inch
|
||||
// Physical length units
|
||||
eCSSUnit_PhysicalMillimeter = 200, // (float) 1/25.4 inch
|
||||
|
||||
// Length units - relative
|
||||
// Font relative measure
|
||||
@ -168,7 +159,11 @@ enum nsCSSUnit {
|
||||
|
||||
// Screen relative measure
|
||||
eCSSUnit_Point = 900, // (float) 4/3 of a CSS pixel
|
||||
eCSSUnit_Pixel = 901, // (float) CSS pixel unit
|
||||
eCSSUnit_Inch = 901, // (float) 96 CSS pixels
|
||||
eCSSUnit_Millimeter = 902, // (float) 96/25.4 CSS pixels
|
||||
eCSSUnit_Centimeter = 903, // (float) 96/2.54 CSS pixels
|
||||
eCSSUnit_Pica = 904, // (float) 12 points == 16 CSS pixls
|
||||
eCSSUnit_Pixel = 905, // (float) CSS pixel unit
|
||||
|
||||
// Angular units
|
||||
eCSSUnit_Degree = 1000, // (float) 360 per circle
|
||||
@ -230,14 +225,14 @@ public:
|
||||
|
||||
nsCSSUnit GetUnit() const { return mUnit; }
|
||||
PRBool IsLengthUnit() const
|
||||
{ return eCSSUnit_Inch <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
||||
{ return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
||||
/**
|
||||
* A "fixed" length unit is one that means a specific physical length
|
||||
* which we try to match based on the physical characteristics of an
|
||||
* output device.
|
||||
*/
|
||||
PRBool IsFixedLengthUnit() const
|
||||
{ return eCSSUnit_Inch <= mUnit && mUnit <= eCSSUnit_Pica; }
|
||||
{ return mUnit == eCSSUnit_PhysicalMillimeter; }
|
||||
/**
|
||||
* What the spec calls relative length units is, for us, split
|
||||
* between relative length units and pixel length units.
|
||||
|
Loading…
Reference in New Issue
Block a user