Bug 1073618 - When starting a snap-back after a fling, only consider APZCs along the handoff chain from the flinging APZC onwards. r=kats
authorBotond Ballo <botond@mozilla.com>
Wed, 01 Oct 2014 13:26:37 -0400
changeset 231456 acf16a586d9f62c01ef1a6eb1b6e34461b135cdd
parent 231455 d954ed24e7952f4d32d8dc0e073ceb6365a671e3
child 231457 7f08e93cc2a5f66ea8b0ab0ef950a8f6d41c8c84
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1073618
milestone35.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 1073618 - When starting a snap-back after a fling, only consider APZCs along the handoff chain from the flinging APZC onwards. r=kats
gfx/layers/apz/src/APZCTreeManager.h
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/OverscrollHandoffState.cpp
gfx/layers/apz/src/OverscrollHandoffState.h
--- a/gfx/layers/apz/src/APZCTreeManager.h
+++ b/gfx/layers/apz/src/APZCTreeManager.h
@@ -336,18 +336,16 @@ public:
    * the caller uses this return value to determine whether it should consume
    * the excess fling itself by going into an overscroll fling.
    */
   bool DispatchFling(AsyncPanZoomController* aApzc,
                      ScreenPoint aVelocity,
                      nsRefPtr<const OverscrollHandoffChain> aOverscrollHandoffChain,
                      bool aHandoff);
 
-  void SnapBackOverscrolledApzc(AsyncPanZoomController* aStart);
-
   /*
    * Build the chain of APZCs that will handle overscroll for a pan starting at |aInitialTarget|.
    */
   nsRefPtr<const OverscrollHandoffChain> BuildOverscrollHandoffChain(const nsRefPtr<AsyncPanZoomController>& aInitialTarget);
 protected:
   // Protected destructor, to discourage deletion outside of Release():
   virtual ~APZCTreeManager();
 
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -515,17 +515,18 @@ public:
       // This APZC or an APZC further down the handoff chain may be be overscrolled.
       // Start a snap-back animation on the overscrolled APZC.
       // Note:
       //   This needs to be a deferred task even though it can safely run
       //   while holding mMonitor, because otherwise, if the overscrolled APZC
       //   is this one, then the SetState(NOTHING) in UpdateAnimation will
       //   stomp on the SetState(SNAP_BACK) it does.
       mDeferredTasks.append(NewRunnableMethod(mOverscrollHandoffChain.get(),
-                                              &OverscrollHandoffChain::SnapBackOverscrolledApzc));
+                                              &OverscrollHandoffChain::SnapBackOverscrolledApzc,
+                                              &mApzc));
       return false;
     }
 
     // AdjustDisplacement() zeroes out the Axis velocity if we're in overscroll.
     // Since we need to hand off the velocity to the tree manager in such a case,
     // we save it here. Would be ScreenVector instead of ScreenPoint if we had
     // vector classes.
     ScreenPoint velocity(mApzc.mX.GetVelocity(), mApzc.mY.GetVelocity());
--- a/gfx/layers/apz/src/OverscrollHandoffState.cpp
+++ b/gfx/layers/apz/src/OverscrollHandoffState.cpp
@@ -83,28 +83,29 @@ OverscrollHandoffChain::CancelAnimations
 
 void
 OverscrollHandoffChain::ClearOverscroll() const
 {
   ForEachApzc(&AsyncPanZoomController::ClearOverscroll);
 }
 
 void
-OverscrollHandoffChain::SnapBackOverscrolledApzc() const
+OverscrollHandoffChain::SnapBackOverscrolledApzc(const AsyncPanZoomController* aStart) const
 {
-  uint32_t i = 0;
-  for (i = 0; i < Length(); ++i) {
+  uint32_t i = IndexOf(aStart);
+  for (; i < Length(); ++i) {
     AsyncPanZoomController* apzc = mChain[i];
     if (!apzc->IsDestroyed() && apzc->SnapBackIfOverscrolled()) {
-      // At most one APZC along the hand-off chain can be overscrolled.
+      // At most one APZC from |aStart| onwards can be overscrolled.
       break;
     }
   }
 
-  // In debug builds, verify our assumption that only one APZC is overscrolled.
+  // In debug builds, verify our assumption that only one APZC from |aStart|
+  // onwards is overscrolled.
 #ifdef DEBUG
   ++i;
   for (; i < Length(); ++i) {
     AsyncPanZoomController* apzc = mChain[i];
     if (!apzc->IsDestroyed()) {
       MOZ_ASSERT(!apzc->IsOverscrolled());
     }
   }
--- a/gfx/layers/apz/src/OverscrollHandoffState.h
+++ b/gfx/layers/apz/src/OverscrollHandoffState.h
@@ -93,18 +93,19 @@ public:
   void FlushRepaints() const;
 
   // Cancel animations all the way up the chain.
   void CancelAnimations() const;
 
   // Clear overscroll all the way up the chain.
   void ClearOverscroll() const;
 
-  // Snap back the APZC that is overscrolled, if any.
-  void SnapBackOverscrolledApzc() const;
+  // Snap back the APZC that is overscrolled on the subset of the chain from
+  // |aStart| onwards, if any.
+  void SnapBackOverscrolledApzc(const AsyncPanZoomController* aStart) const;
 
   // Determine whether the given APZC, or any APZC further in the chain,
   // has room to be panned.
   bool CanBePanned(const AsyncPanZoomController* aApzc) const;
 private:
   std::vector<nsRefPtr<AsyncPanZoomController>> mChain;
 
   typedef void (AsyncPanZoomController::*APZCMethod)();