author | Kartikaya Gupta <kgupta@mozilla.com> |
Tue, 01 Dec 2015 14:21:57 -0500 | |
changeset 274960 | f61e7d37cd1be5679c2ed507e7908dac93c5eb15 |
parent 274959 | 3254063d0c0a5fc412d0685dea8b9fef4b4bfa3c |
child 274961 | 5c0cef9e8bfdbf408376cd0ca894ae667d4a5df1 |
push id | 68733 |
push user | kgupta@mozilla.com |
push date | Tue, 01 Dec 2015 19:22:30 +0000 |
treeherder | mozilla-inbound@f61e7d37cd1b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | backout |
bugs | 1222524, 1227770, 1227789 |
milestone | 45.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
|
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1218,18 +1218,16 @@ nsEventStatus AsyncPanZoomController::On } SetState(TOUCHING); break; } case TOUCHING: case PANNING: case PANNING_LOCKED_X: case PANNING_LOCKED_Y: - case PANNING_LOCKED_X_SMOOTH_SCROLL: - case PANNING_LOCKED_Y_SMOOTH_SCROLL: case PINCHING: NS_WARNING("Received impossible touch in OnTouchStart"); break; default: NS_WARNING("Unhandled case in OnTouchStart"); break; } @@ -1265,18 +1263,16 @@ nsEventStatus AsyncPanZoomController::On } return StartPanning(aEvent); } case PANNING: case PANNING_LOCKED_X: case PANNING_LOCKED_Y: - case PANNING_LOCKED_X_SMOOTH_SCROLL: - case PANNING_LOCKED_Y_SMOOTH_SCROLL: case PAN_MOMENTUM: TrackTouch(aEvent); return nsEventStatus_eConsumeNoDefault; case PINCHING: // The scale gesture listener should have handled this. NS_WARNING("Gesture listener should have handled pinching in OnTouchMove."); return nsEventStatus_eIgnore; @@ -1334,20 +1330,16 @@ nsEventStatus AsyncPanZoomController::On // It's possible we may be overscrolled if the user tapped during a // previous overscroll pan. Make sure to snap back in this situation. if (!SnapBackIfOverscrolled()) { SetState(NOTHING); } } return nsEventStatus_eIgnore; - case PANNING_LOCKED_X_SMOOTH_SCROLL: - case PANNING_LOCKED_Y_SMOOTH_SCROLL: - CancelAnimation(); - MOZ_FALLTHROUGH; case PANNING: case PANNING_LOCKED_X: case PANNING_LOCKED_Y: case PAN_MOMENTUM: { CurrentTouchBlock()->GetOverscrollHandoffChain()->FlushRepaints(); mX.EndTouch(aEvent.mTime); mY.EndTouch(aEvent.mTime); @@ -2143,49 +2135,34 @@ void AsyncPanZoomController::HandlePanni overscrollHandoffChain->CanScrollInDirection(this, Layer::VERTICAL); if (!canScrollHorizontal || !canScrollVertical) { SetState(PANNING); } else if (IsCloseToHorizontal(aAngle, gfxPrefs::APZAxisLockAngle())) { mY.SetAxisLocked(true); if (canScrollHorizontal) { SetState(PANNING_LOCKED_X); - overscrollHandoffChain->RequestSnapOnLock(Layer::VERTICAL); } } else if (IsCloseToVertical(aAngle, gfxPrefs::APZAxisLockAngle())) { mX.SetAxisLocked(true); if (canScrollVertical) { SetState(PANNING_LOCKED_Y); - overscrollHandoffChain->RequestSnapOnLock(Layer::HORIZONTAL); } } else { SetState(PANNING); } } void AsyncPanZoomController::HandlePanningUpdate(const ScreenPoint& aPanDistance) { // If we're axis-locked, check if the user is trying to break the lock if (GetAxisLockMode() == STICKY && !mPanDirRestricted) { double angle = atan2(aPanDistance.y, aPanDistance.x); // range [-pi, pi] angle = fabs(angle); // range [0, pi] - { - // If we can scroll on both axes, we want to allow breaking axis-lock. If - // we can only scroll on one axis, we want to always enable entering to - // axis-lock. - ReentrantMonitorAutoEnter lock(mMonitor); - if (!mX.CanScroll() || !mY.CanScroll()) { - if (mState == PANNING) { - HandlePanning(angle); - } - return; - } - } - float breakThreshold = gfxPrefs::APZAxisBreakoutThreshold() * APZCTreeManager::GetDPI(); if (fabs(aPanDistance.x) > breakThreshold || fabs(aPanDistance.y) > breakThreshold) { if (mState == PANNING_LOCKED_X) { if (!IsCloseToHorizontal(angle, gfxPrefs::APZAxisBreakoutAngle())) { mY.SetAxisLocked(false); SetState(PANNING); } @@ -2445,30 +2422,17 @@ void AsyncPanZoomController::HandleFling void AsyncPanZoomController::HandleSmoothScrollOverscroll(const ParentLayerPoint& aVelocity) { // We must call BuildOverscrollHandoffChain from this deferred callback // function in order to avoid a deadlock when acquiring the tree lock. HandleFlingOverscroll(aVelocity, BuildOverscrollHandoffChain()); } void AsyncPanZoomController::StartSmoothScroll(ScrollSource aSource) { - // Only cancel animation and change state if the user isn't pan-locked. - // Snapping is requested during panning if the opposing axis of an - // unscrollable axis is locked. - if (mState == PANNING_LOCKED_X) { - mY.SetAxisLocked(false); - SetState(PANNING_LOCKED_X_SMOOTH_SCROLL); - } else if (mState == PANNING_LOCKED_Y) { - mX.SetAxisLocked(false); - SetState(PANNING_LOCKED_Y_SMOOTH_SCROLL); - } else { - CancelAnimation(); - SetState(SMOOTH_SCROLL); - } - + SetState(SMOOTH_SCROLL); nsPoint initialPosition = CSSPoint::ToAppUnits(mFrameMetrics.GetScrollOffset()); // Cast velocity from ParentLayerPoints/ms to CSSPoints/ms then convert to // appunits/second nsPoint initialVelocity = CSSPoint::ToAppUnits(CSSPoint(mX.GetVelocity(), mY.GetVelocity())) * 1000.0f; nsPoint destination = CSSPoint::ToAppUnits(mFrameMetrics.GetSmoothScrollOffset()); StartAnimation(new SmoothScrollAnimation(*this, @@ -2873,25 +2837,17 @@ bool AsyncPanZoomController::UpdateAnima *aOutDeferredTasks = mAnimation->TakeDeferredTasks(); if (continueAnimation) { if (mPaintThrottler->TimeSinceLastRequest(aSampleTime) > mAnimation->mRepaintInterval) { RequestContentRepaint(); } } else { mAnimation = nullptr; - if (mState == PANNING_LOCKED_X_SMOOTH_SCROLL) { - mY.SetAxisLocked(true); - SetState(PANNING_LOCKED_X); - } else if (mState == PANNING_LOCKED_Y_SMOOTH_SCROLL) { - mX.SetAxisLocked(true); - SetState(PANNING_LOCKED_Y); - } else { - SetState(NOTHING); - } + SetState(NOTHING); RequestContentRepaint(); } UpdateSharedCompositorFrameMetrics(); return true; } return false; } @@ -3250,16 +3206,18 @@ void AsyncPanZoomController::NotifyLayer // A smooth scroll has been requested for animation on the compositor // thread. This flag will be reset by the main thread when it receives // the scroll update acknowledgement. APZC_LOG("%p smooth scrolling from %s to %s\n", this, Stringify(mFrameMetrics.GetScrollOffset()).c_str(), Stringify(aLayerMetrics.GetSmoothScrollOffset()).c_str()); + CancelAnimation(); + // It's important to not send repaint requests between this // CopySmoothScrollInfo call and the sending of the scroll update // acknowledgement below, otherwise that repaint request will get rejected // on the main thread but mLastPaintRequestMetrics will have the new scroll // generation; this would leave the main thread out of date. mFrameMetrics.CopySmoothScrollInfoFrom(aLayerMetrics); mLastDispatchedPaintMetrics = aLayerMetrics; StartSmoothScroll(ScrollSource::DOM); @@ -3480,20 +3438,17 @@ void AsyncPanZoomController::DispatchSta } } bool AsyncPanZoomController::IsTransformingState(PanZoomState aState) { return !(aState == NOTHING || aState == TOUCHING); } bool AsyncPanZoomController::IsInPanningState() const { - return (mState == PANNING || - mState == PANNING_LOCKED_X || mState == PANNING_LOCKED_Y || - mState == PANNING_LOCKED_X_SMOOTH_SCROLL || - mState == PANNING_LOCKED_Y_SMOOTH_SCROLL); + return (mState == PANNING || mState == PANNING_LOCKED_X || mState == PANNING_LOCKED_Y); } void AsyncPanZoomController::UpdateZoomConstraints(const ZoomConstraints& aConstraints) { APZC_LOG("%p updating zoom constraints to %d %d %f %f\n", this, aConstraints.mAllowZoom, aConstraints.mAllowDoubleTapZoom, aConstraints.mMinZoom.scale, aConstraints.mMaxZoom.scale); if (IsNaN(aConstraints.mMinZoom.scale) || IsNaN(aConstraints.mMaxZoom.scale)) { NS_WARNING("APZC received zoom constraints with NaN values; dropping..."); return; @@ -3600,17 +3555,16 @@ void AsyncPanZoomController::ShareCompos APZC_LOG("%p failed to share FrameMetrics with content process.", this); } } } } void AsyncPanZoomController::RequestSnap() { if (RefPtr<GeckoContentController> controller = GetGeckoContentController()) { - ReentrantMonitorAutoEnter lock(mMonitor); APZC_LOG("%p requesting snap near %s\n", this, Stringify(mFrameMetrics.GetScrollOffset()).c_str()); controller->RequestFlingSnap(mFrameMetrics.GetScrollId(), mFrameMetrics.GetScrollOffset()); } } } // namespace layers
--- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -388,21 +388,16 @@ public: bool CanScrollWithWheel(const ParentLayerPoint& aDelta) const; // Return whether or not there is room to scroll this APZC // in the given direction. bool CanScroll(Layer::ScrollDirection aDirection) const; void NotifyMozMouseScrollEvent(const nsString& aString) const; - // This is called to request that the main thread snap the scroll position - // to a nearby snap position if appropriate. The current scroll position is - // used as the final destination. - void RequestSnap(); - protected: // Protected destructor, to discourage deletion outside of Release(): virtual ~AsyncPanZoomController(); // Returns the cached current frame time. TimeStamp GetFrameTime() const; /** @@ -644,16 +639,21 @@ protected: static AxisLockMode GetAxisLockMode(); // Helper function for OnSingleTapUp() and OnSingleTapConfirmed(). nsEventStatus GenerateSingleTap(const ScreenIntPoint& aPoint, mozilla::Modifiers aModifiers); // Common processing at the end of a touch block. void OnTouchEndOrCancel(); + // This is called to request that the main thread snap the scroll position + // to a nearby snap position if appropriate. The current scroll position is + // used as the final destination. + void RequestSnap(); + uint64_t mLayersId; RefPtr<CompositorParent> mCompositorParent; RefPtr<TaskThrottler> mPaintThrottler; /* Access to the following two fields is protected by the mRefPtrMonitor, since they are accessed on the UI thread but can be cleared on the compositor thread. */ RefPtr<GeckoContentController> mGeckoContentController; @@ -755,22 +755,16 @@ protected: PAN_MOMENTUM, /* like PANNING, but controlled by momentum PanGestureInput events */ PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */ ANIMATING_ZOOM, /* animated zoom to a new rect */ OVERSCROLL_ANIMATION, /* Spring-based animation used to relieve overscroll once the finger is lifted. */ SMOOTH_SCROLL, /* Smooth scrolling to destination. Used by CSSOM-View smooth scroll-behavior */ - - PANNING_LOCKED_X_SMOOTH_SCROLL, /* Smooth scrolling animation initiated - while simultaneously panning the frame - with the X axis locked. */ - PANNING_LOCKED_Y_SMOOTH_SCROLL, /* as above for Y axis. */ - WHEEL_SCROLL /* Smooth scrolling to a destination for a wheel event. */ }; // This is in theory protected by |mMonitor|; that is, it should be held whenever // this is updated. In practice though... see bug 897017. PanZoomState mState; private:
--- a/gfx/layers/apz/src/OverscrollHandoffState.cpp +++ b/gfx/layers/apz/src/OverscrollHandoffState.cpp @@ -107,40 +107,16 @@ OverscrollHandoffChain::SnapBackOverscro uint32_t i = IndexOf(aStart); for (; i < Length(); ++i) { AsyncPanZoomController* apzc = mChain[i]; if (!apzc->IsDestroyed()) { apzc->SnapBackIfOverscrolled(); } } } -void -OverscrollHandoffChain::RequestSnapOnLock(Layer::ScrollDirection aAxis) const -{ - for (uint32_t i = 0; i < Length(); ++i) { - AsyncPanZoomController* apzc = mChain[i]; - if (!apzc->IsDestroyed()) { - switch (aAxis) { - case Layer::HORIZONTAL: - if (!apzc->CanScroll(Layer::VERTICAL)) { - apzc->RequestSnap(); - } - break; - case Layer::VERTICAL: - if (!apzc->CanScroll(Layer::HORIZONTAL)) { - apzc->RequestSnap(); - } - break; - default: - MOZ_ASSERT(false); - break; - } - } - } -} bool OverscrollHandoffChain::CanBePanned(const AsyncPanZoomController* aApzc) const { // Find |aApzc| in the handoff chain. uint32_t i = IndexOf(aApzc); // See whether any APZC in the handoff chain starting from |aApzc|
--- a/gfx/layers/apz/src/OverscrollHandoffState.h +++ b/gfx/layers/apz/src/OverscrollHandoffState.h @@ -66,19 +66,16 @@ public: // Clear overscroll all the way up the chain. void ClearOverscroll() 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; - // Request snap on APZCs that cannot scroll on the opposing axis to |aAxis|. - void RequestSnapOnLock(Layer::ScrollDirection aAxis) const; - // Determine whether the given APZC, or any APZC further in the chain, // has room to be panned. bool CanBePanned(const AsyncPanZoomController* aApzc) const; // Determine whether the given APZC, or any APZC further in the chain, // can scroll in the given direction. bool CanScrollInDirection(const AsyncPanZoomController* aApzc, Layer::ScrollDirection aDirection) const;