Bug 1331213: Implement the resolution override. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 16 Jan 2017 10:42:10 +0100
changeset 461275 506db96fb87733282ac26e6cfcda70482e10098c
parent 461274 901f11573e7312490251ee7683a88e03fde7334c
child 542274 4a8c0e0b7000bcabafe5e0f19122a923dbbd8ef3
push id41626
push userbmo:emilio+bugs@crisal.io
push dateMon, 16 Jan 2017 09:45:21 +0000
reviewersheycam
bugs1331213
milestone53.0a1
Bug 1331213: Implement the resolution override. r?heycam MozReview-Commit-ID: LFGam2hDoh7 Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
servo/components/style/gecko/media_queries.rs
--- a/servo/components/style/gecko/media_queries.rs
+++ b/servo/components/style/gecko/media_queries.rs
@@ -527,21 +527,26 @@ impl Expression {
             }
             (&Integer(one), &Integer(ref other)) => one.cmp(other),
             (&BoolInteger(one), &BoolInteger(ref other)) => one.cmp(other),
             (&Float(one), &Float(ref other)) => one.partial_cmp(other).unwrap(),
             (&IntRatio(one_num, one_den), &IntRatio(other_num, other_den)) => {
                 (one_num * other_den).partial_cmp(&(other_num * one_den)).unwrap()
             }
             (&Resolution(ref one), &Resolution(ref other)) => {
-                // FIXME(emilio): The pres context may override the DPPX of the
-                // `other` resolution, we need to look at that here, but I'm
-                // skipping that for now (we should check if bindgen can
-                // generate nsPresContext correctly now).
-                one.to_dpi().partial_cmp(&other.to_dpi()).unwrap()
+                let actual_dpi = unsafe {
+                    if (*device.pres_context).mOverrideDPPX > 0.0 {
+                        self::Resolution::Dppx((*device.pres_context).mOverrideDPPX)
+                            .to_dpi()
+                    } else {
+                        other.to_dpi()
+                    }
+                };
+
+                one.to_dpi().partial_cmp(&actual_dpi).unwrap()
             }
             (&Ident(ref one), &Ident(ref other)) => {
                 debug_assert!(self.feature.mRangeType != nsMediaFeature_RangeType::eMinMaxAllowed);
                 return one == other;
             }
             (&Enumerated(..), &Enumerated(..)) => {
                 // TODO(emilio)
                 unimplemented!();