зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1416564: Remove mozmm CSS unit. r=heycam
MozReview-Commit-ID: AU4CUq09tw4
This commit is contained in:
Родитель
6950ac6b52
Коммит
f9b153f761
|
@ -323,6 +323,19 @@ nsDOMWindowUtils::GetDocCharsetIsForced(bool *aIsForced)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetPhysicalMillimeterInCSSPixels(float* aPhysicalMillimeter)
|
||||
{
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
if (!presContext) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
*aPhysicalMillimeter = presContext->AppUnitsToFloatCSSPixels(
|
||||
presContext->PhysicalMillimetersToAppUnits(1));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetDocumentMetadata(const nsAString& aName,
|
||||
nsAString& aValue)
|
||||
|
|
|
@ -79,6 +79,11 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||
*/
|
||||
readonly attribute boolean docCharsetIsForced;
|
||||
|
||||
/**
|
||||
* Return the conversion of a physical millimeter in CSS pixels.
|
||||
*/
|
||||
readonly attribute float physicalMillimeterInCSSPixels;
|
||||
|
||||
/**
|
||||
* Function to get metadata associated with the window's current document
|
||||
* @param aName the name of the metadata. This should be all lowercase.
|
||||
|
|
|
@ -3095,6 +3095,14 @@ nsPresContext::AppUnitsToGfxUnits(nscoord aAppUnits) const
|
|||
return mDeviceContext->AppUnitsToGfxUnits(aAppUnits);
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsPresContext::PhysicalMillimetersToAppUnits(float aMM) const
|
||||
{
|
||||
float inches = aMM / MM_PER_INCH_FLOAT;
|
||||
return NSToCoordFloorClamped(
|
||||
inches * float(DeviceContext()->AppUnitsPerPhysicalInch()));
|
||||
}
|
||||
|
||||
bool
|
||||
nsPresContext::IsDeviceSizePageSize()
|
||||
{
|
||||
|
|
|
@ -717,6 +717,8 @@ public:
|
|||
{ return NSToCoordRound(aPoints * mozilla::AppUnitsPerCSSInch() /
|
||||
POINTS_PER_INCH_FLOAT); }
|
||||
|
||||
nscoord PhysicalMillimetersToAppUnits(float aMM) const;
|
||||
|
||||
nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
|
||||
{ return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); }
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
</head>
|
||||
<body id="body" onload="setTimeout(runTest, 0)" style="margin:0; width:100%; height:100%; overflow:hidden">
|
||||
<div id="content">
|
||||
<div id="ruler" style="position:absolute; left:0; top:0; width:1mozmm; height:0;"></div>
|
||||
<div class="target" id="t"></div>
|
||||
</div>
|
||||
<pre id="test">
|
||||
|
@ -52,7 +51,7 @@ function testWithAndWithoutBodyListener(aX, aY, aExpectedId, aMsg) {
|
|||
|
||||
var mm;
|
||||
function runTest() {
|
||||
mm = document.getElementById("ruler").getBoundingClientRect().width;
|
||||
mm = SpecialPowers.getDOMWindowUtils(parent).physicalMillimeterInCSSPixels;
|
||||
parent.ok(4*mm >= 10, "WARNING: mm " + mm + " too small in this configuration. Test results will be bogus");
|
||||
|
||||
// Test near the target, check it hits the target
|
||||
|
|
|
@ -15,8 +15,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=780847
|
|||
<body id="body" onload="setTimeout(startTest, 0)" style="margin:0; width:100%; height:100%; overflow:hidden">
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<div id="ruler" style="position:absolute; left:0; top:0; width:1mozmm; height:0;"></div>
|
||||
|
||||
<!-- XXX Though B2G isn't supported anymore, we probably want to keep this
|
||||
test's B2G special-cases around, and just make them apply to Android.
|
||||
(We may need to do so, for this test to be runnable on Android...?)
|
||||
|
@ -113,7 +111,7 @@ function runTest() {
|
|||
SpecialPowers.getDOMWindowUtils(window.top).getResolution(out);
|
||||
resolution = 1.0 / out.value;
|
||||
}
|
||||
mm = document.getElementById("ruler").getBoundingClientRect().width * resolution;
|
||||
mm = SpecialPowers.getDOMWindowUtils(window.top).physicalMillimeterInCSSPixels * resolution;
|
||||
ok(4*mm >= 10, "WARNING: mm " + mm + " too small in this configuration. Test results will be bogus");
|
||||
|
||||
// Test basic functionality: clicks sufficiently close to the element
|
||||
|
|
|
@ -219,9 +219,6 @@ nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
|
|||
{
|
||||
NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit");
|
||||
|
||||
if (aCSSValue.IsFixedLengthUnit()) {
|
||||
return aCSSValue.GetFixedLength(aPresContext);
|
||||
}
|
||||
if (aCSSValue.IsPixelLengthUnit()) {
|
||||
return aCSSValue.GetPixelLength();
|
||||
}
|
||||
|
|
|
@ -7361,7 +7361,6 @@ const UnitInfo UnitData[] = {
|
|||
{ STR_WITH_LEN("ch"), eCSSUnit_Char, VARIANT_LENGTH },
|
||||
{ STR_WITH_LEN("rem"), eCSSUnit_RootEM, VARIANT_LENGTH },
|
||||
{ STR_WITH_LEN("mm"), eCSSUnit_Millimeter, VARIANT_LENGTH },
|
||||
{ STR_WITH_LEN("mozmm"), eCSSUnit_PhysicalMillimeter, VARIANT_LENGTH },
|
||||
{ STR_WITH_LEN("vw"), eCSSUnit_ViewportWidth, VARIANT_LENGTH },
|
||||
{ STR_WITH_LEN("vh"), eCSSUnit_ViewportHeight, VARIANT_LENGTH },
|
||||
{ STR_WITH_LEN("vmin"), eCSSUnit_ViewportMin, VARIANT_LENGTH },
|
||||
|
|
|
@ -384,16 +384,6 @@ nsCSSValue::GetPossiblyStaticImageValue(nsIDocument* aDocument,
|
|||
return nsContentUtils::GetStaticRequest(aDocument, req);
|
||||
}
|
||||
|
||||
nscoord nsCSSValue::GetFixedLength(nsPresContext* aPresContext) const
|
||||
{
|
||||
MOZ_ASSERT(mUnit == eCSSUnit_PhysicalMillimeter,
|
||||
"not a fixed length unit");
|
||||
|
||||
float inches = mValue.mFloat / MM_PER_INCH_FLOAT;
|
||||
return NSToCoordFloorClamped(inches *
|
||||
float(aPresContext->DeviceContext()->AppUnitsPerPhysicalInch()));
|
||||
}
|
||||
|
||||
nscoord nsCSSValue::GetPixelLength() const
|
||||
{
|
||||
MOZ_ASSERT(IsPixelLengthUnit(), "not a fixed length unit");
|
||||
|
@ -2064,7 +2054,6 @@ nsCSSValue::AppendToString(nsCSSPropertyID aProperty,
|
|||
|
||||
case eCSSUnit_Inch: aResult.AppendLiteral("in"); break;
|
||||
case eCSSUnit_Millimeter: aResult.AppendLiteral("mm"); break;
|
||||
case eCSSUnit_PhysicalMillimeter: aResult.AppendLiteral("mozmm"); break;
|
||||
case eCSSUnit_Centimeter: aResult.AppendLiteral("cm"); break;
|
||||
case eCSSUnit_Point: aResult.AppendLiteral("pt"); break;
|
||||
case eCSSUnit_Pica: aResult.AppendLiteral("pc"); break;
|
||||
|
@ -2249,7 +2238,6 @@ nsCSSValue::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
|||
// Float: nothing extra to measure.
|
||||
case eCSSUnit_Percent:
|
||||
case eCSSUnit_Number:
|
||||
case eCSSUnit_PhysicalMillimeter:
|
||||
case eCSSUnit_ViewportWidth:
|
||||
case eCSSUnit_ViewportHeight:
|
||||
case eCSSUnit_ViewportMin:
|
||||
|
|
|
@ -534,9 +534,6 @@ enum nsCSSUnit {
|
|||
eCSSUnit_Percent = 100, // (float) 1.0 == 100%) value is percentage of something
|
||||
eCSSUnit_Number = 101, // (float) value is numeric (usually multiplier, different behavior than percent)
|
||||
|
||||
// Physical length units
|
||||
eCSSUnit_PhysicalMillimeter = 200, // (float) 1/25.4 inch
|
||||
|
||||
// Length units - relative
|
||||
// Viewport relative measure
|
||||
eCSSUnit_ViewportWidth = 700, // (float) 1% of the width of the initial containing block
|
||||
|
@ -644,16 +641,9 @@ public:
|
|||
|
||||
nsCSSUnit GetUnit() const { return mUnit; }
|
||||
bool IsLengthUnit() const
|
||||
{ return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
||||
{ return eCSSUnit_ViewportWidth <= mUnit && mUnit <= eCSSUnit_Pixel; }
|
||||
bool IsLengthPercentCalcUnit() const
|
||||
{ return IsLengthUnit() || mUnit == eCSSUnit_Percent || IsCalcUnit(); }
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
bool IsFixedLengthUnit() const
|
||||
{ return mUnit == eCSSUnit_PhysicalMillimeter; }
|
||||
/**
|
||||
* What the spec calls relative length units is, for us, split
|
||||
* between relative length units and pixel length units.
|
||||
|
@ -885,7 +875,6 @@ public:
|
|||
already_AddRefed<imgRequestProxy> GetPossiblyStaticImageValue(
|
||||
nsIDocument* aDocument, nsPresContext* aPresContext) const;
|
||||
|
||||
nscoord GetFixedLength(nsPresContext* aPresContext) const;
|
||||
nscoord GetPixelLength() const;
|
||||
|
||||
nsCSSValueFloatColor* GetFloatColorValue() const
|
||||
|
|
|
@ -545,9 +545,6 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
|
|||
"Must have style context or specify aUseProvidedRootEmSize");
|
||||
NS_ASSERTION(aPresContext, "Must have prescontext");
|
||||
|
||||
if (aValue.IsFixedLengthUnit()) {
|
||||
return aValue.GetFixedLength(aPresContext);
|
||||
}
|
||||
if (aValue.IsPixelLengthUnit()) {
|
||||
return aValue.GetPixelLength();
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
<div id="in" style="width:1in; height:1in; background:magenta;">in</div>
|
||||
<div id="q" style="width:101.6q; height:101.6q; background:blue;">q</div>
|
||||
|
||||
<div id="mozmm" style="width:25.4mozmm; height:25.4mozmm; background:cyan;">mozmm</div>
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
@ -47,25 +45,13 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.dpi', dpi=96]]}, test1);
|
||||
|
||||
var mozmmSize;
|
||||
function test1() {
|
||||
var mozmm = document.getElementById("mozmm");
|
||||
mozmmSize = mozmm.getBoundingClientRect().width;
|
||||
is(Math.round(mozmmSize), Math.round(mozmm.getBoundingClientRect().height),
|
||||
"mozmm div should be square");
|
||||
|
||||
checkPixelRelativeUnits();
|
||||
|
||||
SpecialPowers.pushPrefEnv({'set': [['layout.css.dpi', dpi=192]]}, test2);
|
||||
}
|
||||
|
||||
function test2() {
|
||||
// At 192 dpi, a one-inch box should be twice the number of device pixels,
|
||||
// and since we haven't changed the device-pixels-per-CSS-pixel ratio, the
|
||||
// mozmm box should be twice the size in CSS pixels.
|
||||
check("mozmm", mozmmSize*2);
|
||||
checkPixelRelativeUnits();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче