From 13878d674cbc66113bab1eedee06da464646b681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 15 Jan 2017 23:51:58 +0100 Subject: [PATCH] Bug 1331213: Implement Device::media_type, without supporting overrides for now. r=heycam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MozReview-Commit-ID: 9AeHViwoX1t Signed-off-by: Emilio Cobos Álvarez --- components/style/gecko/media_queries.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index f69cf1104ac..3dcc53dc39d 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -76,8 +76,17 @@ impl Device { /// Returns the current media type of the device. pub fn media_type(&self) -> MediaType { - // TODO - MediaType::Screen + unsafe { + // FIXME(emilio): Gecko allows emulating random media with + // mIsEmulatingMedia / mMediaEmulated . Refactor both sides so that + // is supported (probably just making MediaType an Atom). + if (*self.pres_context).mMedium == atom!("screen").as_ptr() { + MediaType::Screen + } else { + debug_assert!((*self.pres_context).mMedium == atom!("print").as_ptr()); + MediaType::Print + } + } } /// Returns the current viewport size in app units.