Bug 1478335 - Use the visual viewport offset to compute the visible area in CalculateRectToZoomTo(). r=kats
authorBotond Ballo <botond@mozilla.com>
Mon, 10 Sep 2018 20:25:06 +0000
changeset 435562 edc165c5253a00a58c110b4bc5c51cc2c9f738b0
parent 435561 488aac2379c3298b07bc407e1e68da9eb45385e8
child 435563 a6c99402d0015024878eabdfca34dc79af89eb8a
push id34615
push usercsabou@mozilla.com
push dateTue, 11 Sep 2018 10:05:56 +0000
treeherdermozilla-central@cb28a4b17303 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1478335
milestone64.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 1478335 - Use the visual viewport offset to compute the visible area in CalculateRectToZoomTo(). r=kats Differential Revision: https://phabricator.services.mozilla.com/D5462
gfx/layers/apz/util/DoubleTapToZoom.cpp
layout/base/nsLayoutUtils.h
--- a/gfx/layers/apz/util/DoubleTapToZoom.cpp
+++ b/gfx/layers/apz/util/DoubleTapToZoom.cpp
@@ -115,17 +115,18 @@ CalculateRectToZoomTo(const nsCOMPtr<nsI
     element = element->GetParentElement();
   }
 
   if (!element) {
     return zoomOut;
   }
 
   FrameMetrics metrics = nsLayoutUtils::CalculateBasicFrameMetrics(rootScrollFrame);
-  CSSRect compositedArea(metrics.GetScrollOffset(), metrics.CalculateCompositedSizeInCssPixels());
+  CSSRect compositedArea(CSSPoint::FromAppUnits(shell->GetVisualViewportOffset()),
+                         metrics.CalculateCompositedSizeInCssPixels());
   const CSSCoord margin = 15;
   CSSRect rect = nsLayoutUtils::GetBoundingContentRect(element, rootScrollFrame);
 
   // If the element is taller than the visible area of the page scale
   // the height of the |rect| so that it has the same aspect ratio as
   // the root frame.  The clipped |rect| is centered on the y value of
   // the touch point. This allows tall narrow elements to be zoomed.
   if (!rect.IsEmpty() && compositedArea.Width() > 0.0f) {
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2794,16 +2794,20 @@ public:
   }
 
   /**
    * Calculate a basic FrameMetrics with enough fields set to perform some
    * layout calculations. The fields set are dev-to-css ratio, pres shell
    * resolution, cumulative resolution, zoom, composition size, root
    * composition size, scroll offset and scrollable rect.
    *
+   * Note that for the RCD-RSF, the scroll offset returned is the layout
+   * viewport offset; if you need the visual viewport offset, that needs to
+   * be queried independently via nsIPresShell::GetVisualViewportOffset().
+   *
    * By contrast, ComputeFrameMetrics() computes all the fields, but requires
    * extra inputs and can only be called during frame layer building.
    */
   static FrameMetrics CalculateBasicFrameMetrics(nsIScrollableFrame* aScrollFrame);
 
   /**
    * Calculate a default set of displayport margins for the given scrollframe
    * and set them on the scrollframe's content element. The margins are set with