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 672182 b6061e5f1659887edb49e0476d20a2df4d520123
parent 672004 03ec7c491f3d34d5555089cb69735cde261d156c
child 672183 ed873ec042967d9954b63f445f75031e511f21d7
child 672189 c3e89ba97e7ae4b6ffaf97862f88593594501479
push id82182
push userbwerth@mozilla.com
push dateThu, 28 Sep 2017 21:21:24 +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 {