Bug 1498812 - Part 10: Return whether SetVisualViewportOffset was a no-op. r=botond
authorJan Henning <jh+bugzilla@buttercookie.de>
Fri, 11 Jan 2019 19:50:17 +0000
changeset 453554 f0f5124781cc
parent 453553 39207d39e5c2
child 453555 a99bf382e5f7
push id35360
push usernbeleuzu@mozilla.com
push dateSat, 12 Jan 2019 09:39:47 +0000
treeherdermozilla-central@cb35977ae7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1498812
milestone66.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 1498812 - Part 10: Return whether SetVisualViewportOffset was a no-op. r=botond So that the caller doesn't have to retrieve and compare the previous viewport offset himself. Differential Revision: https://phabricator.services.mozilla.com/D15785
layout/base/PresShell.cpp
layout/base/nsIPresShell.h
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -10086,27 +10086,30 @@ void nsIPresShell::SetVisualViewportSize
     MarkFixedFramesForReflow(nsIPresShell::eResize);
 
     if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
       window->VisualViewport()->PostResizeEvent();
     }
   }
 }
 
-void nsIPresShell::SetVisualViewportOffset(
+bool nsIPresShell::SetVisualViewportOffset(
     const nsPoint& aScrollOffset, const nsPoint& aPrevLayoutScrollPos) {
+  bool didChange = false;
   if (mVisualViewportOffset != aScrollOffset) {
     nsPoint prevOffset = mVisualViewportOffset;
     mVisualViewportOffset = aScrollOffset;
+    didChange = true;
 
     if (auto* window = nsGlobalWindowInner::Cast(mDocument->GetInnerWindow())) {
       window->VisualViewport()->PostScrollEvent(prevOffset,
                                                 aPrevLayoutScrollPos);
     }
   }
+  return didChange;
 }
 
 nsPoint nsIPresShell::GetVisualViewportOffsetRelativeToLayoutViewport() const {
   return GetVisualViewportOffset() - GetLayoutViewportOffset();
 }
 
 nsPoint nsIPresShell::GetLayoutViewportOffset() const {
   nsPoint result;
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -1645,17 +1645,20 @@ class nsIPresShell : public nsStubDocume
   void SetVisualViewportSize(nscoord aWidth, nscoord aHeight);
   bool IsVisualViewportSizeSet() { return mVisualViewportSizeSet; }
   nsSize GetVisualViewportSize() {
     NS_ASSERTION(mVisualViewportSizeSet,
                  "asking for visual viewport size when its not set?");
     return mVisualViewportSize;
   }
 
-  void SetVisualViewportOffset(const nsPoint& aScrollOffset,
+  /**
+   * The return value indicates whether the offset actually changed.
+   */
+  bool SetVisualViewportOffset(const nsPoint& aScrollOffset,
                                const nsPoint& aPrevLayoutScrollPos);
 
   nsPoint GetVisualViewportOffset() const { return mVisualViewportOffset; }
 
   nsPoint GetVisualViewportOffsetRelativeToLayoutViewport() const;
 
   // Ask APZ in the next transaction to scroll to the given visual viewport 
   // offset (relative to the document).