From f9d081133687da6239314776b5857cb329d3c036 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Fri, 5 Sep 2014 18:37:51 -0400 Subject: [PATCH] Bug 1063224 - Const-correctness improvements in APZ classes. r=kats --HG-- extra : source : 2d5e9cefe9931c97f544e23e14dc5de44ac352e7 --- gfx/layers/apz/src/APZCTreeManager.cpp | 4 ++-- gfx/layers/apz/src/APZCTreeManager.h | 7 ++++--- gfx/layers/apz/src/AsyncPanZoomController.cpp | 10 +++++----- gfx/layers/apz/src/AsyncPanZoomController.h | 10 +++++----- gfx/layers/apz/src/Axis.cpp | 4 ++-- gfx/layers/apz/src/Axis.h | 4 ++-- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index c1d214e92857..447de4d30ed8 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1315,8 +1315,8 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc, required can be generated. */ void -APZCTreeManager::GetInputTransforms(AsyncPanZoomController *aApzc, Matrix4x4& aTransformToApzcOut, - Matrix4x4& aTransformToGeckoOut) +APZCTreeManager::GetInputTransforms(const AsyncPanZoomController *aApzc, Matrix4x4& aTransformToApzcOut, + Matrix4x4& aTransformToGeckoOut) const { MonitorAutoLock lock(mTreeLock); diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index 9e3c0e5242cd..d2d008321bb6 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -361,8 +361,9 @@ public: already_AddRefed GetTargetAPZC(const ScrollableLayerGuid& aGuid); already_AddRefed GetTargetAPZC(const ScreenPoint& aPoint, bool* aOutInOverscrolledApzc); - void GetInputTransforms(AsyncPanZoomController *aApzc, gfx::Matrix4x4& aTransformToApzcOut, - gfx::Matrix4x4& aTransformToGeckoOut); + void GetInputTransforms(const AsyncPanZoomController *aApzc, + gfx::Matrix4x4& aTransformToApzcOut, + gfx::Matrix4x4& aTransformToGeckoOut) const; private: /* Helpers */ AsyncPanZoomController* FindTargetAPZC(AsyncPanZoomController* aApzc, FrameMetrics::ViewID aScrollId); @@ -417,7 +418,7 @@ private: * is considered part of the APZC tree management state. * Finally, the lock needs to be held when accessing mOverscrollHandoffChain. * IMPORTANT: See the note about lock ordering at the top of this file. */ - mozilla::Monitor mTreeLock; + mutable mozilla::Monitor mTreeLock; nsRefPtr mRootApzc; /* This tracks the APZC that should receive all inputs for the current input event block. * This allows touch points to move outside the thing they started on, but still have the diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 4e3e2fa6daef..cf96e314d439 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -927,7 +927,7 @@ AsyncPanZoomController::Destroy() } bool -AsyncPanZoomController::IsDestroyed() +AsyncPanZoomController::IsDestroyed() const { return mTreeManager == nullptr; } @@ -1694,7 +1694,7 @@ nsEventStatus AsyncPanZoomController::OnCancelTap(const TapGestureInput& aEvent) return nsEventStatus_eIgnore; } -float AsyncPanZoomController::PanDistance() { +float AsyncPanZoomController::PanDistance() const { ReentrantMonitorAutoEnter lock(mMonitor); return NS_hypot(mX.PanDistance(), mY.PanDistance()); } @@ -2465,7 +2465,7 @@ void AsyncPanZoomController::SampleContentTransformForFrame(ViewTransform* aOutT } } -ViewTransform AsyncPanZoomController::GetCurrentAsyncTransform() { +ViewTransform AsyncPanZoomController::GetCurrentAsyncTransform() const { ReentrantMonitorAutoEnter lock(mMonitor); CSSPoint lastPaintScrollOffset; @@ -2503,14 +2503,14 @@ ViewTransform AsyncPanZoomController::GetCurrentAsyncTransform() { return ViewTransform(scale, -translation); } -Matrix4x4 AsyncPanZoomController::GetNontransientAsyncTransform() { +Matrix4x4 AsyncPanZoomController::GetNontransientAsyncTransform() const { ReentrantMonitorAutoEnter lock(mMonitor); return Matrix4x4().Scale(mLastContentPaintMetrics.mResolution.scale, mLastContentPaintMetrics.mResolution.scale, 1.0f); } -Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() { +Matrix4x4 AsyncPanZoomController::GetTransformToLastDispatchedPaint() const { ReentrantMonitorAutoEnter lock(mMonitor); // Technically we should be taking the scroll delta in the coordinate space diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index cb34c2941ed6..ff2de9964b5b 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -212,7 +212,7 @@ public: /** * Returns true if Destroy() has already been called on this APZC instance. */ - bool IsDestroyed(); + bool IsDestroyed() const; /** * Returns the incremental transformation corresponding to the async pan/zoom @@ -220,14 +220,14 @@ public: * existing transform, it will make the layer appear with the desired pan/zoom * amount. */ - ViewTransform GetCurrentAsyncTransform(); + ViewTransform GetCurrentAsyncTransform() const; /** * Returns the part of the async transform that will remain once Gecko does a * repaint at the desired metrics. That is, in the steady state: * Matrix4x4(GetCurrentAsyncTransform()) === GetNontransientAsyncTransform() */ - Matrix4x4 GetNontransientAsyncTransform(); + Matrix4x4 GetNontransientAsyncTransform() const; /** * Returns the transform to take something from the coordinate space of the @@ -236,7 +236,7 @@ public: * processed, this is needed to transform input events properly into a space * gecko will understand. */ - Matrix4x4 GetTransformToLastDispatchedPaint(); + Matrix4x4 GetTransformToLastDispatchedPaint() const; /** * Recalculates the displayport. Ideally, this should paint an area bigger @@ -464,7 +464,7 @@ protected: * current touch (this only makes sense if a touch is currently happening and * OnTouchMove() is being invoked). */ - float PanDistance(); + float PanDistance() const; /** * Gets a vector of the velocities of each axis. diff --git a/gfx/layers/apz/src/Axis.cpp b/gfx/layers/apz/src/Axis.cpp index bd25364a5b87..ba1a00976bad 100644 --- a/gfx/layers/apz/src/Axis.cpp +++ b/gfx/layers/apz/src/Axis.cpp @@ -207,11 +207,11 @@ void Axis::ClearOverscroll() { mOverscroll = 0; } -float Axis::PanDistance() { +float Axis::PanDistance() const { return fabsf((mPos - mStartPos).value); } -float Axis::PanDistance(ScreenCoord aPos) { +float Axis::PanDistance(ScreenCoord aPos) const { return fabsf((aPos - mStartPos).value); } diff --git a/gfx/layers/apz/src/Axis.h b/gfx/layers/apz/src/Axis.h index 1068630413b2..f825ac038975 100644 --- a/gfx/layers/apz/src/Axis.h +++ b/gfx/layers/apz/src/Axis.h @@ -123,13 +123,13 @@ public: * startTouch() and the current touch from the last * updateWithTouchAtDevicePoint(). */ - float PanDistance(); + float PanDistance() const; /** * Gets the distance between the starting position of the touch supplied in * startTouch() and the supplied position. */ - float PanDistance(ScreenCoord aPos); + float PanDistance(ScreenCoord aPos) const; /** * Applies friction during a fling, or cancels the fling if the velocity is