Bug 1376931 Part 1: Change Servo media queries of resolution to compare in dppx units without unit conversion. draft
authorBrad Werth <bwerth@mozilla.com>
Thu, 28 Sep 2017 11:50:42 -0700
changeset 673785 a6d6cb6e6145e47ce7fa9f0e09fc8eb30d48488f
parent 673329 97efdde466f18cf580fda9673cf4c38ee21fc7b7
child 673786 63f473b584a15d0c082a4f376682473fbb3eaefc
child 674013 50713f782fc17dc62ea9b3a919a27c0b7fc417bb
push id82646
push userbwerth@mozilla.com
push dateMon, 02 Oct 2017 20:25:07 +0000
bugs1376931
milestone58.0a1
Bug 1376931 Part 1: Change Servo media queries of resolution to compare in dppx units without unit conversion. MozReview-Commit-ID: 7wYlixTQTIC
servo/components/style/gecko/media_queries.rs
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -368,18 +368,28 @@ impl MediaExpressionValue {
             }
             nsMediaFeature_ValueType::eBoolInteger => {
                 debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Integer);
                 let i = css_value.integer_unchecked();
                 debug_assert!(i == 0 || i == 1);
                 Some(MediaExpressionValue::BoolInteger(i == 1))
             }
             nsMediaFeature_ValueType::eResolution => {
-                debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Inch);
-                Some(MediaExpressionValue::Resolution(Resolution::Dpi(css_value.float_unchecked())))
+                // This is temporarily more complicated to allow Gecko Bug
+                // 1376931 to land. Parts of that bug will supply pixel values
+                // and expect them to be passed through without conversion.
+                // After all parts of that bug have landed, Bug 1404097 will
+                // return this function to once again only allow one type of
+                // value to be accepted: this time, only pixel values.
+                let res = match css_value.mUnit {
+                    nsCSSUnit::eCSSUnit_Pixel => Resolution::Dppx(css_value.float_unchecked()),
+                    nsCSSUnit::eCSSUnit_Inch  => Resolution::Dpi(css_value.float_unchecked()),
+                    _                         => unreachable!(),
+                };
+                Some(MediaExpressionValue::Resolution(res))
             }
             nsMediaFeature_ValueType::eEnumerated => {
                 let value = css_value.integer_unchecked() as i16;
                 Some(MediaExpressionValue::Enumerated(value))
             }
             nsMediaFeature_ValueType::eIdent => {
                 debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Ident);
                 let string = unsafe {