--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -319,16 +319,29 @@ nsDOMWindowUtils::GetDocCharsetIsForced(
nsIDocument* doc = GetDocument();
*aIsForced = doc &&
doc->GetDocumentCharacterSetSource() >= kCharsetFromParentForced;
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)
{
nsIDocument* doc = GetDocument();
if (doc) {
RefPtr<nsAtom> name = NS_Atomize(aName);
doc->GetHeaderData(name, aValue);
return NS_OK;
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -75,16 +75,21 @@ interface nsIDOMWindowUtils : nsISupport
/**
* Whether the charset of the window's current document has been forced by
* the user.
* Cannot be accessed from unprivileged context (not content-accessible)
*/
readonly attribute boolean docCharsetIsForced;
/**
+ * Return a 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.
* @return the value of the metadata, or the empty string if it's not set
*
* Will throw a DOM security error if called without chrome privileges.
*/
AString getDocumentMetadata(in AString aName);
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -3090,16 +3090,24 @@ nsPresContext::GfxUnitsToAppUnits(gfxFlo
}
gfxFloat
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()
{
bool isDeviceSizePageSize = false;
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell) {
isDeviceSizePageSize = docShell->GetDeviceSizeIsPageSize();
}
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -712,16 +712,18 @@ public:
CSSTwipsToAppUnits(float(marginInTwips.right)),
CSSTwipsToAppUnits(float(marginInTwips.bottom)),
CSSTwipsToAppUnits(float(marginInTwips.left))); }
static nscoord CSSPointsToAppUnits(float aPoints)
{ return NSToCoordRound(aPoints * mozilla::AppUnitsPerCSSInch() /
POINTS_PER_INCH_FLOAT); }
+ nscoord PhysicalMillimetersToAppUnits(float aMM) const;
+
nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
{ return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); }
/**
* This checks the root element and the HTML BODY, if any, for an "overflow"
* property that should be applied to the viewport. If one is found then we
* return the element that we took the overflow from (which should then be
* treated as "overflow: visible"), and we store the overflow style here.
--- a/layout/base/tests/bug1093686_inner.html
+++ b/layout/base/tests/bug1093686_inner.html
@@ -6,17 +6,16 @@
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
.target { position:absolute; left:200px; top:200px; width:200px; height:200px; background:blue; }
</style>
</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">
<script type="application/javascript">
var eventTarget;
window.onmousedown = function(event) { eventTarget = event.target; };
// Make sure the target div is "clickable" by adding a click listener on it.
@@ -47,17 +46,17 @@ function testWithAndWithoutBodyListener(
testMouseClick(aX, aY, aExpectedId, aMsg + " with listener on body");
document.body.removeEventListener("click", func);
}
// Main tests
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
testWithAndWithoutBodyListener(200 - 2*mm, 200 - 2*mm, "t", "basic click retargeting");
// Test on the target, check it hits the target
testWithAndWithoutBodyListener(200 + 2*mm, 200 + 2*mm, "t", "direct click");
// Test outside the target, check it hits the root
testWithAndWithoutBodyListener(40, 40, "body", "click way outside target");
--- a/layout/base/tests/test_event_target_radius.html
+++ b/layout/base/tests/test_event_target_radius.html
@@ -10,18 +10,16 @@ https://bugzilla.mozilla.org/show_bug.cg
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
.target { position:absolute; left:100px; top:100px; width:100px; height:100px; background:blue; }
</style>
</head>
<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...?)
See bug 1355206 for more.
-->
<!-- the iframe holding this test is only 300px tall on B2G, so we need to
make the t target shorter than normal to test the bottom edge fluffing
-->
@@ -108,17 +106,17 @@ function runTest() {
if (SpecialPowers.Services.appinfo.name == "B2G") {
// This test runs on B2G as well, zoomed out. Therefore we need to account
// for the resolution as well, because the fluff area is relative to screen
// pixels rather than CSS pixels.
let out = {};
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
// should be allowed to hit the element. We test points just inside and
// just outside the edges we set up in the prefs.
testMouseClick("t", 100 + 13*mm, 10, "body", "basic functionality");
testMouseClick("t", 100 + 11*mm, 10, "t", "basic functionality");
testMouseClick("t", 10, 80 + 9*mm, "body", "basic functionality");
--- a/layout/mathml/nsMathMLFrame.cpp
+++ b/layout/mathml/nsMathMLFrame.cpp
@@ -214,19 +214,16 @@ nsMathMLFrame::GetAxisHeight(DrawTarget*
/* static */ nscoord
nsMathMLFrame::CalcLength(nsPresContext* aPresContext,
nsStyleContext* aStyleContext,
const nsCSSValue& aCSSValue,
float aFontSizeInflation)
{
NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit");
- if (aCSSValue.IsFixedLengthUnit()) {
- return aCSSValue.GetFixedLength(aPresContext);
- }
if (aCSSValue.IsPixelLengthUnit()) {
return aCSSValue.GetPixelLength();
}
nsCSSUnit unit = aCSSValue.GetUnit();
if (eCSSUnit_EM == unit) {
const nsStyleFont* font = aStyleContext->StyleFont();
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -7356,17 +7356,16 @@ const UnitInfo UnitData[] = {
{ STR_WITH_LEN("em"), eCSSUnit_EM, VARIANT_LENGTH },
{ STR_WITH_LEN("ex"), eCSSUnit_XHeight, VARIANT_LENGTH },
{ STR_WITH_LEN("pt"), eCSSUnit_Point, VARIANT_LENGTH },
{ STR_WITH_LEN("in"), eCSSUnit_Inch, VARIANT_LENGTH },
{ STR_WITH_LEN("cm"), eCSSUnit_Centimeter, VARIANT_LENGTH },
{ 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 },
{ STR_WITH_LEN("vmax"), eCSSUnit_ViewportMax, VARIANT_LENGTH },
{ STR_WITH_LEN("pc"), eCSSUnit_Pica, VARIANT_LENGTH },
{ STR_WITH_LEN("q"), eCSSUnit_Quarter, VARIANT_LENGTH },
{ STR_WITH_LEN("deg"), eCSSUnit_Degree, VARIANT_ANGLE },
{ STR_WITH_LEN("grad"), eCSSUnit_Grad, VARIANT_ANGLE },
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -379,26 +379,16 @@ nsCSSValue::GetPossiblyStaticImageValue(
{
imgRequestProxy* req = GetImageValue(aDocument);
if (aPresContext->IsDynamic()) {
return do_AddRef(req);
}
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");
double scaleFactor;
switch (mUnit) {
case eCSSUnit_Pixel: return nsPresContext::CSSPixelsToAppUnits(mValue.mFloat);
case eCSSUnit_Pica: scaleFactor = 16.0; break;
@@ -2059,17 +2049,16 @@ nsCSSValue::AppendToString(nsCSSProperty
case eCSSUnit_ListDep: break;
case eCSSUnit_SharedList: break;
case eCSSUnit_PairList: break;
case eCSSUnit_PairListDep: break;
case eCSSUnit_GridTemplateAreas: break;
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;
case eCSSUnit_Quarter: aResult.AppendLiteral("q"); break;
case eCSSUnit_ViewportWidth: aResult.AppendLiteral("vw"); break;
case eCSSUnit_ViewportHeight: aResult.AppendLiteral("vh"); break;
case eCSSUnit_ViewportMin: aResult.AppendLiteral("vmin"); break;
@@ -2244,17 +2233,16 @@ nsCSSValue::SizeOfExcludingThis(mozilla:
// Complex Color
case eCSSUnit_ComplexColor:
n += mValue.mComplexColor->SizeOfIncludingThis(aMallocSizeOf);
break;
// Float: nothing extra to measure.
case eCSSUnit_Percent:
case eCSSUnit_Number:
- case eCSSUnit_PhysicalMillimeter:
case eCSSUnit_ViewportWidth:
case eCSSUnit_ViewportHeight:
case eCSSUnit_ViewportMin:
case eCSSUnit_ViewportMax:
case eCSSUnit_EM:
case eCSSUnit_XHeight:
case eCSSUnit_Char:
case eCSSUnit_RootEM:
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -529,19 +529,16 @@ enum nsCSSUnit {
// allowed.
eCSSUnit_HSLColor = 89, // (nsCSSValueFloatColor*)
eCSSUnit_HSLAColor = 90, // (nsCSSValueFloatColor*)
eCSSUnit_ComplexColor = 91, // (ComplexColorValue*)
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
eCSSUnit_ViewportHeight = 701, // (float) 1% of the height of the initial containing block
eCSSUnit_ViewportMin = 702, // (float) smaller of ViewportWidth and ViewportHeight
eCSSUnit_ViewportMax = 703, // (float) larger of ViewportWidth and ViewportHeight
// Font relative measure
@@ -639,27 +636,20 @@ public:
/**
* Serialize |this| as a specified value for |aProperty| and append
* it to |aResult|.
*/
void AppendToString(nsCSSPropertyID aProperty, nsAString& aResult) const;
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.
*
* A "relative" length unit is a multiple of some derived metric,
* such as a font em-size, which itself was controlled by an input CSS
* length. Relative length units should not be scaled by zooming, since
* the underlying CSS length would already have been scaled.
*/
@@ -880,17 +870,16 @@ public:
// all over.
imgRequestProxy* GetImageValue(nsIDocument* aDocument) const;
// Like GetImageValue, but additionally will pass the imgRequestProxy
// through nsContentUtils::GetStaticRequest if aPresContent is static.
already_AddRefed<imgRequestProxy> GetPossiblyStaticImageValue(
nsIDocument* aDocument, nsPresContext* aPresContext) const;
- nscoord GetFixedLength(nsPresContext* aPresContext) const;
nscoord GetPixelLength() const;
nsCSSValueFloatColor* GetFloatColorValue() const
{
MOZ_ASSERT(IsFloatColorUnit(), "not a float color value");
return mValue.mFloatColor;
}
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -510,19 +510,16 @@ static nscoord CalcLengthWith(const nsCS
NS_ASSERTION(aValue.IsLengthUnit() || aValue.IsCalcUnit(),
"not a length or calc unit");
NS_ASSERTION(aStyleFont || aStyleContext,
"Must have style data");
NS_ASSERTION(aStyleContext || aUseProvidedRootEmSize,
"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();
}
if (aValue.IsCalcUnit()) {
// For properties for which lengths are the *only* units accepted in
// calc(), we can handle calc() here and just compute a final
// result. We ensure that we don't get to this code for other
// properties by not calling CalcLength in those cases: SetCoord
--- a/layout/style/test/test_pixel_lengths.html
+++ b/layout/style/test/test_pixel_lengths.html
@@ -10,18 +10,16 @@
<div id="pt" style="width:90pt; height:90pt; background:lime;">pt</div>
<div id="pc" style="width:5pc; height:5pc; background:yellow;">pc</div>
<div id="mm" style="width:25.4mm; height:25.4mm; background:orange;">mm</div>
<div id="cm" style="width:2.54cm; height:2.54cm; background:purple;">cm</div>
<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">
var oldDPI = SpecialPowers.getIntPref("layout.css.dpi");
var dpi = oldDPI;
function check(id, val) {
@@ -42,34 +40,22 @@ function checkPixelRelativeUnits() {
}
checkPixelRelativeUnits();
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();
}
</script>
</pre>
</body>
</html>
--- a/servo/components/style/values/computed/length.rs
+++ b/servo/components/style/values/computed/length.rs
@@ -31,19 +31,16 @@ impl ToComputedValue for specified::NoCa
specified::NoCalcLength::Absolute(length) =>
length.to_computed_value(context),
specified::NoCalcLength::FontRelative(length) =>
length.to_computed_value(context, FontBaseSize::CurrentStyle),
specified::NoCalcLength::ViewportPercentage(length) =>
length.to_computed_value(context.viewport_size_for_viewport_unit_resolution()),
specified::NoCalcLength::ServoCharacterWidth(length) =>
length.to_computed_value(context.style().get_font().clone_font_size().size()),
- #[cfg(feature = "gecko")]
- specified::NoCalcLength::Physical(length) =>
- length.to_computed_value(context),
}
}
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
specified::NoCalcLength::Absolute(AbsoluteLength::Px(computed.px()))
}
}
--- a/servo/components/style/values/specified/calc.rs
+++ b/servo/components/style/values/specified/calc.rs
@@ -72,18 +72,16 @@ pub struct CalcLengthOrPercentage {
pub vh: Option<CSSFloat>,
pub vmin: Option<CSSFloat>,
pub vmax: Option<CSSFloat>,
pub em: Option<CSSFloat>,
pub ex: Option<CSSFloat>,
pub ch: Option<CSSFloat>,
pub rem: Option<CSSFloat>,
pub percentage: Option<computed::Percentage>,
- #[cfg(feature = "gecko")]
- pub mozmm: Option<CSSFloat>,
}
impl ToCss for CalcLengthOrPercentage {
/// <https://drafts.csswg.org/css-values/#calc-serialize>
///
/// FIXME(emilio): Should this simplify away zeros?
#[allow(unused_assignments)]
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
@@ -137,24 +135,17 @@ impl ToCss for CalcLengthOrPercentage {
val.abs().to_css(dest)?;
}
// NOTE(emilio): The order here it's very intentional, and alphabetic
// per the spec linked above.
serialize!(ch);
serialize_abs!(Cm);
serialize!(em, ex);
- serialize_abs!(In);
-
- #[cfg(feature = "gecko")]
- {
- serialize!(mozmm);
- }
-
- serialize_abs!(Mm, Pc, Pt, Px, Q);
+ serialize_abs!(In, Mm, Pc, Pt, Px, Q);
serialize!(rem, vh, vmax, vmin, vw);
dest.write_str(")")
}
}
impl CalcNode {
/// Tries to parse a single element in the expression, that is, a
@@ -393,26 +384,16 @@ impl CalcNode {
ret.vmax = Some(ret.vmax.unwrap_or(0.) + vmax * factor)
}
ViewportPercentageLength::Vmin(vmin) => {
ret.vmin = Some(ret.vmin.unwrap_or(0.) + vmin * factor)
}
}
}
NoCalcLength::ServoCharacterWidth(..) => unreachable!(),
- #[cfg(feature = "gecko")]
- NoCalcLength::Physical(physical) => {
- use values::specified::length::PhysicalLength;
-
- match physical {
- PhysicalLength::Mozmm(mozmm) => {
- ret.mozmm = Some(ret.mozmm.unwrap_or(0.) + mozmm * factor);
- }
- }
- }
}
}
CalcNode::Sub(ref a, ref b) => {
a.add_length_or_percentage_to(ret, factor)?;
b.add_length_or_percentage_to(ret, factor * -1.0)?;
}
CalcNode::Sum(ref a, ref b) => {
a.add_length_or_percentage_to(ret, factor)?;
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -354,70 +354,16 @@ impl Add<AbsoluteLength> for AbsoluteLen
(AbsoluteLength::Q(x), AbsoluteLength::Q(y)) => AbsoluteLength::Q(x + y),
(AbsoluteLength::Pt(x), AbsoluteLength::Pt(y)) => AbsoluteLength::Pt(x + y),
(AbsoluteLength::Pc(x), AbsoluteLength::Pc(y)) => AbsoluteLength::Pc(x + y),
_ => AbsoluteLength::Px(self.to_px() + rhs.to_px()),
}
}
}
-/// Represents a physical length based on DPI.
-///
-/// FIXME(emilio): Unship (https://bugzilla.mozilla.org/show_bug.cgi?id=1416564)
-#[derive(Clone, Copy, Debug, PartialEq, ToCss)]
-#[derive(MallocSizeOf)]
-pub enum PhysicalLength {
- /// A physical length in millimetres.
- #[css(dimension)]
- Mozmm(CSSFloat),
-}
-
-impl PhysicalLength {
- /// Checks whether the length value is zero.
- pub fn is_zero(&self) -> bool {
- match *self {
- PhysicalLength::Mozmm(v) => v == 0.,
- }
- }
-
- /// Computes the given character width.
- #[cfg(feature = "gecko")]
- pub fn to_computed_value(&self, context: &Context) -> CSSPixelLength {
- use gecko_bindings::bindings;
- use std::f32;
-
- // Same as Gecko
- const INCH_PER_MM: f32 = 1. / 25.4;
-
- let au_per_physical_inch = unsafe {
- bindings::Gecko_GetAppUnitsPerPhysicalInch(context.device().pres_context()) as f32
- };
-
- let px_per_physical_inch = au_per_physical_inch / AU_PER_PX;
-
- let mm = match *self {
- PhysicalLength::Mozmm(v) => v,
- };
-
- let pixel = mm * px_per_physical_inch * INCH_PER_MM;
- CSSPixelLength::new(pixel.min(f32::MAX).max(f32::MIN))
- }
-}
-
-impl Mul<CSSFloat> for PhysicalLength {
- type Output = Self ;
-
- #[inline]
- fn mul(self, scalar: CSSFloat) -> Self {
- match self {
- PhysicalLength::Mozmm(v) => PhysicalLength::Mozmm(v * scalar),
- }
- }
-}
-
/// A `<length>` without taking `calc` expressions into account
///
/// <https://drafts.csswg.org/css-values/#lengths>
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToCss)]
pub enum NoCalcLength {
/// An absolute length
///
/// <https://drafts.csswg.org/css-values/#absolute-length>
@@ -434,34 +380,28 @@ pub enum NoCalcLength {
ViewportPercentage(ViewportPercentageLength),
/// HTML5 "character width", as defined in HTML5 § 14.5.4.
///
/// This cannot be specified by the user directly and is only generated by
/// `Stylist::synthesize_rules_for_legacy_attributes()`.
#[css(function)]
ServoCharacterWidth(CharacterWidth),
-
- /// A physical length (mozmm) based on DPI
- #[cfg(feature = "gecko")]
- Physical(PhysicalLength),
}
impl Mul<CSSFloat> for NoCalcLength {
type Output = NoCalcLength;
#[inline]
fn mul(self, scalar: CSSFloat) -> NoCalcLength {
match self {
NoCalcLength::Absolute(v) => NoCalcLength::Absolute(v * scalar),
NoCalcLength::FontRelative(v) => NoCalcLength::FontRelative(v * scalar),
NoCalcLength::ViewportPercentage(v) => NoCalcLength::ViewportPercentage(v * scalar),
NoCalcLength::ServoCharacterWidth(_) => panic!("Can't multiply ServoCharacterWidth!"),
- #[cfg(feature = "gecko")]
- NoCalcLength::Physical(v) => NoCalcLength::Physical(v * scalar),
}
}
}
impl NoCalcLength {
/// Parse a given absolute or relative dimension.
pub fn parse_dimension(context: &ParserContext, value: CSSFloat, unit: &str)
-> Result<NoCalcLength, ()> {
@@ -499,35 +439,31 @@ impl NoCalcLength {
Ok(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vmin(value)))
},
"vmax" => {
if in_page_rule {
return Err(())
}
Ok(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vmax(value)))
},
- #[cfg(feature = "gecko")]
- "mozmm" => Ok(NoCalcLength::Physical(PhysicalLength::Mozmm(value))),
_ => Err(())
}
}
#[inline]
/// Returns a `zero` length.
pub fn zero() -> NoCalcLength {
NoCalcLength::Absolute(AbsoluteLength::Px(0.))
}
#[inline]
/// Checks whether the length value is zero.
pub fn is_zero(&self) -> bool {
match *self {
NoCalcLength::Absolute(length) => length.is_zero(),
- #[cfg(feature = "gecko")]
- NoCalcLength::Physical(length) => length.is_zero(),
_ => false
}
}
/// Get an absolute length from a px value.
#[inline]
pub fn from_px(px_value: CSSFloat) -> NoCalcLength {
NoCalcLength::Absolute(AbsoluteLength::Px(px_value))
--- a/servo/components/style_derive/to_css.rs
+++ b/servo/components/style_derive/to_css.rs
@@ -54,21 +54,16 @@ pub fn derive(input: DeriveInput) -> Tok
}}
} else {
quote! {
::std::fmt::Write::write_str(dest, #identifier)
}
};
if variant_attrs.dimension {
- // FIXME(emilio): Remove when bug 1416564 lands.
- if identifier == "-mozmm" {
- identifier = "mozmm".into();
- }
-
expr = quote! {
#expr?;
::std::fmt::Write::write_str(dest, #identifier)
}
} else if variant_attrs.function {
identifier.push_str("(");
expr = quote! {
::std::fmt::Write::write_str(dest, #identifier)?;
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -3155,28 +3155,27 @@ pub extern "C" fn Servo_DeclarationBlock
property: nsCSSPropertyID,
value: f32,
unit: structs::nsCSSUnit,
) {
use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands::_moz_script_min_size::SpecifiedValue as MozScriptMinSize;
use style::properties::longhands::width::SpecifiedValue as Width;
use style::values::specified::MozLength;
- use style::values::specified::length::{AbsoluteLength, FontRelativeLength, PhysicalLength};
+ use style::values::specified::length::{AbsoluteLength, FontRelativeLength};
use style::values::specified::length::{LengthOrPercentage, NoCalcLength};
let long = get_longhand_from_id!(property);
let nocalc = match unit {
structs::nsCSSUnit::eCSSUnit_EM => NoCalcLength::FontRelative(FontRelativeLength::Em(value)),
structs::nsCSSUnit::eCSSUnit_XHeight => NoCalcLength::FontRelative(FontRelativeLength::Ex(value)),
structs::nsCSSUnit::eCSSUnit_Pixel => NoCalcLength::Absolute(AbsoluteLength::Px(value)),
structs::nsCSSUnit::eCSSUnit_Inch => NoCalcLength::Absolute(AbsoluteLength::In(value)),
structs::nsCSSUnit::eCSSUnit_Centimeter => NoCalcLength::Absolute(AbsoluteLength::Cm(value)),
structs::nsCSSUnit::eCSSUnit_Millimeter => NoCalcLength::Absolute(AbsoluteLength::Mm(value)),
- structs::nsCSSUnit::eCSSUnit_PhysicalMillimeter => NoCalcLength::Physical(PhysicalLength::Mozmm(value)),
structs::nsCSSUnit::eCSSUnit_Point => NoCalcLength::Absolute(AbsoluteLength::Pt(value)),
structs::nsCSSUnit::eCSSUnit_Pica => NoCalcLength::Absolute(AbsoluteLength::Pc(value)),
structs::nsCSSUnit::eCSSUnit_Quarter => NoCalcLength::Absolute(AbsoluteLength::Q(value)),
_ => unreachable!("Unknown unit {:?} passed to SetLengthValue", unit)
};
let prop = match_wrap_declared! { long,
Width => Width(MozLength::LengthOrPercentageOrAuto(nocalc.into())),