Bug 1522264 - Translate the visual viewport offset to be relative to the scroll port. r=botond, a=lizzard
authorRyan Hunt <rhunt@eqrion.net>
Mon, 28 Jan 2019 19:48:00 +0000
changeset 516009 fd38f2049853b553a04f037456a1f2efd7e5c41e
parent 516008 2705a920610a3b56aaf84b45166fd9e06e118fae
child 516010 6121ff0b5a68421eb8cf23bce86b1b2c67eb3563
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond, lizzard
bugs1522264
milestone66.0
Bug 1522264 - Translate the visual viewport offset to be relative to the scroll port. r=botond, a=lizzard This was lost in the change to only use the visual viewport if both the size and offset were set. Differential Revision: https://phabricator.services.mozilla.com/D17752
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3988,17 +3988,18 @@ nsPoint ScrollFrameHelper::GetVisualView
   return GetScrollPosition();
 }
 
 nsRect ScrollFrameHelper::GetVisualOptimalViewingRect() const {
   nsIPresShell* presShell = mOuter->PresShell();
 
   if (mIsRoot && presShell->IsVisualViewportSizeSet() &&
       presShell->IsVisualViewportOffsetSet()) {
-    return nsRect(presShell->GetVisualViewportOffset(),
+    return nsRect(mScrollPort.TopLeft() - GetScrollPosition() +
+                      presShell->GetVisualViewportOffset(),
                   presShell->GetVisualViewportSize());
   }
   return mScrollPort;
 }
 
 static void AdjustForWholeDelta(int32_t aDelta, nscoord* aCoord) {
   if (aDelta < 0) {
     *aCoord = nscoord_MIN;
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -224,17 +224,18 @@ class ScrollFrameHelper : public nsIRefl
   nsRect GetScrollRange() const;
   // Get the scroll range assuming the viewport has size (aWidth, aHeight).
   nsRect GetScrollRange(nscoord aWidth, nscoord aHeight) const;
   nsSize GetVisualViewportSize() const;
   nsPoint GetVisualViewportOffset() const;
 
   /**
    * Return the 'optimal viewing region' [1] as a rect suitable for use by
-   * scroll anchoring.
+   * scroll anchoring. This rect is in the same coordinate space as
+   * 'GetScrollPortRect'.
    *
    * [1] https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region
    */
   nsRect GetVisualOptimalViewingRect() const;
 
   /**
    * For LTR frames, this is the same as GetVisualViewportOffset().
    * For RTL frames, we take the offset from the top right corner of the frame