Bug 1404097: stylo: restore MediaExpressionValue::from_css_value to only accept one type of unit (pixels). draft
authorBrad Werth <bwerth@mozilla.com>
Thu, 28 Sep 2017 14:25:44 -0700
changeset 672187 7bb9553fa489fe23ee763d7a51e6bd63b1d4536b
parent 672186 71d3a9b01ce031dedca166a1b6642cc275195b5d
child 733743 8828e96b3238b8f468f85f816dd80dfdb9e732f8
push id82183
push userbwerth@mozilla.com
push dateThu, 28 Sep 2017 21:26:15 +0000
bugs1404097
milestone58.0a1
Bug 1404097: stylo: restore MediaExpressionValue::from_css_value to only accept one type of unit (pixels). MozReview-Commit-ID: Hn3twVa8xLo
servo/components/style/gecko/media_queries.rs
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -368,28 +368,18 @@ 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 => {
-                // 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))
+                debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
+                Some(MediaExpressionValue::Resolution(Resolution::Dppx(css_value.float_unchecked())))
             }
             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 {