Bug 1202713 - Fix the CSS viewport dimensions for desktop mode. r=snorp
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 01 Oct 2015 11:48:22 -0400
changeset 265623 f89a4c296fb1dfdad6e4580ad36ba339f34f3c15
parent 265622 95fb2b552c0da3cd3264d45be56bcab2fedfe424
child 265624 df9c8be97792b91c541089b6f9b1267bc42ce72c
push id15472
push usercbook@mozilla.com
push dateFri, 02 Oct 2015 11:51:34 +0000
treeherderfx-team@2c33ef6b27e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1202713
milestone44.0a1
Bug 1202713 - Fix the CSS viewport dimensions for desktop mode. r=snorp The CSS viewport computation for desktop mode was incorrect. The end result was that the right amount of CSS pixels was visible on the screen, but the layout properties were incorrect (so elements that were width:100% would use a different width than intended). This caused content to be truncated and otherwise mis-rendered in desktop mode.
dom/base/nsDocument.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7844,22 +7844,23 @@ nsDocument::GetViewportInfo(const Screen
 
   CSSToScreenScale defaultScale = layoutDeviceScale
                                 * LayoutDeviceToScreenScale(1.0);
 
   // Special behaviour for desktop mode, provided we are not on an about: page
   nsPIDOMWindow* win = GetWindow();
   if (win && win->IsDesktopModeViewport() && !IsAboutPage())
   {
-    float viewportWidth = gfxPrefs::DesktopViewportWidth() / fullZoom;
-    float scaleToFit = aDisplaySize.width / viewportWidth;
+    CSSCoord viewportWidth = gfxPrefs::DesktopViewportWidth() / fullZoom;
+    CSSToScreenScale scaleToFit(aDisplaySize.width / viewportWidth);
     float aspectRatio = (float)aDisplaySize.height / aDisplaySize.width;
-    ScreenSize viewportSize(viewportWidth, viewportWidth * aspectRatio);
-    return nsViewportInfo(RoundedToInt(viewportSize),
-                          CSSToScreenScale(scaleToFit),
+    CSSSize viewportSize(viewportWidth, viewportWidth * aspectRatio);
+    ScreenIntSize fakeDesktopSize = RoundedToInt(viewportSize * scaleToFit);
+    return nsViewportInfo(fakeDesktopSize,
+                          scaleToFit,
                           /*allowZoom*/ true);
   }
 
   if (!gfxPrefs::MetaViewportEnabled()) {
     return nsViewportInfo(aDisplaySize,
                           defaultScale,
                           /*allowZoom*/ false);
   }