Bug 1575097 Part 4: Make nsMediaFeatures::GetDeviceSize return unscaled browser sizes for RDM documents. r=emilio
authorBrad Werth <bwerth@mozilla.com>
Sun, 25 Aug 2019 23:54:16 +0000
changeset 489817 79b515c90d54fc738c24e3c6a7dbd2426b9b6a20
parent 489816 651580f22a7c17e0718326bcee79b4cc5b49ee0b
child 489818 47099c4e63468f0c5f2648421c1b89d9828babc1
push id36489
push userdluca@mozilla.com
push dateMon, 26 Aug 2019 09:42:55 +0000
treeherdermozilla-central@c75d6a0539eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1575097
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575097 Part 4: Make nsMediaFeatures::GetDeviceSize return unscaled browser sizes for RDM documents. r=emilio Differential Revision: https://phabricator.services.mozilla.com/D42986
layout/style/nsMediaFeatures.cpp
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -61,31 +61,30 @@ static nsSize GetSize(const Document* aD
     //
     // FIXME(emilio, bug 1414600): Not quite!
     return pc->GetPageSize();
   }
 
   return pc->GetVisibleArea().Size();
 }
 
-static bool IsDeviceSizePageSize(const Document* aDocument) {
-  nsIDocShell* docShell = aDocument->GetDocShell();
-  if (!docShell) {
-    return false;
-  }
-  return docShell->GetDeviceSizeIsPageSize();
-}
-
 // A helper for three features below.
 static nsSize GetDeviceSize(const Document* aDocument) {
-  if (nsContentUtils::ShouldResistFingerprinting(aDocument) ||
-      IsDeviceSizePageSize(aDocument)) {
+  if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
     return GetSize(aDocument);
   }
 
+  // Media queries in documents in an RDM pane should use the simulated
+  // device size.
+  Maybe<CSSIntSize> deviceSize =
+      nsGlobalWindowOuter::GetRDMDeviceSize(*aDocument);
+  if (deviceSize.isSome()) {
+    return CSSPixel::ToAppUnits(deviceSize.value());
+  }
+
   nsPresContext* pc = aDocument->GetPresContext();
   // NOTE(emilio): We should probably figure out how to return an appropriate
   // device size here, though in a multi-screen world that makes no sense
   // really.
   if (!pc) {
     return {};
   }