scrollable-assertion
author Matt Brubeck <mbrubeck@mozilla.com>
Tue, 01 Oct 2013 21:26:40 -0700
changeset 242 899c5789fafab58522016abaee24403519c12f18
parent 241 779bacbb632aa9fb36f7fb4fd188263631c10f4d
permissions -rw-r--r--
cp

# HG changeset patch
# Parent 28feab0d46d32d7be759381745bbee75537066bb
# User Matt Brubeck <mbrubeck@mozilla.com>
Bug 892684 - Fix an assertion from accessing frame metrics without a monitor

diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -746,16 +746,18 @@ const gfx::Point AsyncPanZoomController:
   return gfx::Point(mX.GetVelocity(), mY.GetVelocity());
 }
 
 const gfx::Point AsyncPanZoomController::GetAccelerationVector() {
   return gfx::Point(mX.GetAccelerationFactor(), mY.GetAccelerationFactor());
 }
 
 nsEventStatus AsyncPanZoomController::StartPanning(const MultiTouchInput& aEvent) {
+  ReentrantMonitorAutoEnter lock(mMonitor);
+
   ScreenIntPoint point = GetFirstTouchScreenPoint(aEvent);
   float dx = mX.PanDistance(point.x);
   float dy = mY.PanDistance(point.y);
 
   // When the touch move breaks through the pan threshold, reposition the touch down origin
   // so the page won't jump when we start panning.
   mX.StartTouch(point.x);
   mY.StartTouch(point.y);
diff --git a/gfx/layers/ipc/Axis.cpp b/gfx/layers/ipc/Axis.cpp
--- a/gfx/layers/ipc/Axis.cpp
+++ b/gfx/layers/ipc/Axis.cpp
@@ -105,17 +105,17 @@ Axis::Axis(AsyncPanZoomController* aAsyn
     mAcceleration(0),
     mScrollingDisabled(false),
     mAsyncPanZoomController(aAsyncPanZoomController)
 {
   InitAxisPrefs();
 }
 
 void Axis::UpdateWithTouchAtDevicePoint(int32_t aPos, const TimeDuration& aTimeDelta) {
-  float newVelocity = Scrollable() ? (mPos - aPos) / aTimeDelta.ToMilliseconds() : 0;
+  float newVelocity = mScrollingDisabled ? 0 : (mPos - aPos) / aTimeDelta.ToMilliseconds();
 
   bool curVelocityBelowThreshold = fabsf(newVelocity) < gVelocityThreshold;
   bool directionChange = (mVelocity > 0) != (newVelocity > 0);
 
   // If we've changed directions, or the current velocity threshold, stop any
   // acceleration we've accumulated.
   if (directionChange || curVelocityBelowThreshold) {
     mAcceleration = 0;
@@ -297,17 +297,17 @@ float Axis::ScaleWillOverscrollAmount(Sc
   case OVERSCROLL_PLUS: return (originAfterScale + GetCompositionLength()) -
                                NS_lround(GetPageEnd() * aScale.scale);
   // Don't handle OVERSCROLL_BOTH. Client code is expected to deal with it.
   default: return 0;
   }
 }
 
 float Axis::GetVelocity() {
-  return Scrollable() ? mVelocity : 0;
+  return mScrollingDisabled ? 0 : mVelocity;
 }
 
 float Axis::GetAccelerationFactor() {
   return powf(gAccelerationMultiplier, std::max(0, (mAcceleration - 4) * 3));
 }
 
 float Axis::GetCompositionEnd() {
   return GetOrigin() + GetCompositionLength();