Bug 1152479 - Do not call nsIDOMWindowUtils::SetScrollPositionClampingScrollPortSize from C++ code. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Mon, 13 Apr 2015 16:58:47 -0400
changeset 257072 604ab2c08aff3693427fac1117f09f16fb73a5bd
parent 257071 419557fd7781a5d353fe3d910ae696e848857f5d
child 257073 fd77c6d2b5e1b9a109c3d205c88215e278fb6270
push id1521
push userbballo@mozilla.com
push dateTue, 14 Apr 2015 15:47:38 +0000
reviewerskats
bugs1152479
milestone40.0a1
Bug 1152479 - Do not call nsIDOMWindowUtils::SetScrollPositionClampingScrollPortSize from C++ code. r=kats
dom/ipc/TabChild.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -388,21 +388,20 @@ TabChildBase::HandlePossibleViewportChan
   metrics.SetCumulativeResolution(metrics.GetZoom()
                                 / metrics.GetDevPixelsPerCSSPixel()
                                 * ParentLayerToLayerScale(1));
   // This is the root layer, so the cumulative resolution is the same
   // as the resolution.
   metrics.SetPresShellResolution(metrics.GetCumulativeResolution().ToScaleFactor().scale);
   if (shell) {
     nsLayoutUtils::SetResolutionAndScaleTo(shell, metrics.GetPresShellResolution());
+    nsLayoutUtils::SetScrollPositionClampingScrollPortSize(shell,
+        metrics.CalculateCompositedSizeInCssPixels());
   }
 
-  CSSSize scrollPort = metrics.CalculateCompositedSizeInCssPixels();
-  utils->SetScrollPositionClampingScrollPortSize(scrollPort.width, scrollPort.height);
-
   // The call to GetPageSize forces a resize event to content, so we need to
   // make sure that we have the right CSS viewport and
   // scrollPositionClampingScrollPortSize set up before that happens.
 
   CSSSize pageSize = GetPageSize(document, viewport);
   if (!pageSize.width) {
     // Return early rather than divide by 0.
     return false;
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -207,17 +207,17 @@ APZCCallbackHelper::UpdateRootFrame(nsID
   // be 100, and gecko would limit the maximum scroll offset to 400 (so as to prevent
   // overscroll). Note that if the content here was zoomed to 2x, the document would
   // be 1000 pixels long but the frame would still be 100 pixels, and so the maximum
   // scroll range would be 900. Therefore this calculation depends on the zoom applied
   // to the content relative to the container.
   // Note that this needs to happen before scrolling the frame (in UpdateFrameCommon),
   // otherwise the scroll position may get clamped incorrectly.
   CSSSize scrollPort = aMetrics.CalculateCompositedSizeInCssPixels();
-  aUtils->SetScrollPositionClampingScrollPortSize(scrollPort.width, scrollPort.height);
+  nsLayoutUtils::SetScrollPositionClampingScrollPortSize(aPresShell, scrollPort);
 
   nsIContent* content = nsLayoutUtils::FindContentFor(aMetrics.GetScrollId());
   ScrollFrame(content, aMetrics);
 
   // The pres shell resolution is updated by the the async zoom since the
   // last paint.
   presShellResolution = aMetrics.GetPresShellResolution()
                       * aMetrics.GetAsyncZoom().scale;