Bug 1548896 Part 1: Prevent MobileViewportManager::GetCompositionSize from returning negative sizes. r=botond
authorBrad Werth <bwerth@mozilla.com>
Mon, 13 May 2019 17:26:34 +0000
changeset 532470 0eff48265098e8bac99128577b2baccde799611e
parent 532469 7d59f5e3db1b3f0cbd4b095752535c2d5ef09208
child 532471 b0c2b45643a2be2ea68e114630cad0c546f23e8b
push id11268
push usercsabou@mozilla.com
push dateTue, 14 May 2019 15:24:22 +0000
treeherdermozilla-beta@5fb7fcd568d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1548896
milestone68.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 1548896 Part 1: Prevent MobileViewportManager::GetCompositionSize from returning negative sizes. r=botond Differential Revision: https://phabricator.services.mozilla.com/D30736
layout/base/MobileViewportManager.cpp
--- a/layout/base/MobileViewportManager.cpp
+++ b/layout/base/MobileViewportManager.cpp
@@ -412,18 +412,20 @@ ScreenIntSize MobileViewportManager::Get
 
   ScreenIntSize compositionSize(aDisplaySize);
   ScreenMargin scrollbars =
       mContext->ScrollbarAreaToExcludeFromCompositionBounds()
       // Scrollbars are not subject to resolution scaling, so LD pixels =
       // Screen pixels for them.
       * LayoutDeviceToScreenScale(1.0f);
 
-  compositionSize.width -= scrollbars.LeftRight();
-  compositionSize.height -= scrollbars.TopBottom();
+  compositionSize.width =
+      std::max(0.0f, compositionSize.width - scrollbars.LeftRight());
+  compositionSize.height =
+      std::max(0.0f, compositionSize.height - scrollbars.TopBottom());
 
   return compositionSize;
 }
 
 void MobileViewportManager::UpdateVisualViewportSize(
     const ScreenIntSize& aDisplaySize, const CSSToScreenScale& aZoom) {
   if (!mContext) {
     return;