Bug 951793 - Add a few utility functions to expose the overscroll behavior in relevant places in APZ. r=kats

MozReview-Commit-ID: 4wFfUY5p6J5
This commit is contained in:
Botond Ballo 2017-10-20 19:31:02 -04:00 коммит произвёл Emilio Cobos Álvarez
Родитель 41aac0b97c
Коммит df8a5f5637
4 изменённых файлов: 46 добавлений и 0 удалений

Просмотреть файл

@ -3929,6 +3929,11 @@ const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() const {
return mFrameMetrics;
}
const ScrollMetadata& AsyncPanZoomController::GetScrollMetadata() const {
mRecursiveMutex.AssertCurrentThreadIn();
return mScrollMetadata;
}
APZCTreeManager* AsyncPanZoomController::GetApzcTreeManager() const {
mRecursiveMutex.AssertNotCurrentThreadIn();
return mTreeManager;

Просмотреть файл

@ -668,6 +668,12 @@ protected:
*/
const FrameMetrics& GetFrameMetrics() const;
/**
* Gets the current scroll metadata. This is *not* the Gecko copy stored in
* the layers code/
*/
const ScrollMetadata& GetScrollMetadata() const;
/**
* Gets the pointer to the apzc tree manager. All the access to tree manager
* should be made via this method and not via private variable since this method

Просмотреть файл

@ -491,6 +491,21 @@ const FrameMetrics& Axis::GetFrameMetrics() const {
return mAsyncPanZoomController->GetFrameMetrics();
}
const ScrollMetadata& Axis::GetScrollMetadata() const {
return mAsyncPanZoomController->GetScrollMetadata();
}
bool Axis::OverscrollBehaviorAllowsHandoff() const {
// Scroll handoff is a "non-local" overscroll behavior, so it's allowed
// with "auto" and disallowed with "contain" and "none".
return GetOverscrollBehavior() == OverscrollBehavior::Auto;
}
bool Axis::OverscrollBehaviorAllowsOverscrollEffect() const {
// An overscroll effect is a "local" overscroll behavior, so it's allowed
// with "auto" and "contain" and disallowed with "none".
return GetOverscrollBehavior() != OverscrollBehavior::None;
}
AxisX::AxisX(AsyncPanZoomController* aAsyncPanZoomController)
: Axis(aAsyncPanZoomController)
@ -528,6 +543,11 @@ const char* AxisX::Name() const
return "X";
}
OverscrollBehavior AxisX::GetOverscrollBehavior() const
{
return GetScrollMetadata().GetOverscrollBehavior().mBehaviorX;
}
AxisY::AxisY(AsyncPanZoomController* aAsyncPanZoomController)
: Axis(aAsyncPanZoomController)
{
@ -564,5 +584,10 @@ const char* AxisY::Name() const
return "Y";
}
OverscrollBehavior AxisY::GetOverscrollBehavior() const
{
return GetScrollMetadata().GetOverscrollBehavior().mBehaviorY;
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -249,6 +249,9 @@ public:
ParentLayerCoord GetPos() const { return mPos; }
bool OverscrollBehaviorAllowsHandoff() const;
bool OverscrollBehaviorAllowsOverscrollEffect() const;
virtual ParentLayerCoord GetPointOffset(const ParentLayerPoint& aPoint) const = 0;
virtual ParentLayerCoord GetRectLength(const ParentLayerRect& aRect) const = 0;
virtual ParentLayerCoord GetRectOffset(const ParentLayerRect& aRect) const = 0;
@ -286,6 +289,9 @@ protected:
nsTArray<std::pair<uint32_t, float> > mVelocityQueue;
const FrameMetrics& GetFrameMetrics() const;
const ScrollMetadata& GetScrollMetadata() const;
virtual OverscrollBehavior GetOverscrollBehavior() const = 0;
// Adjust a requested overscroll amount for resistance, yielding a smaller
// actual overscroll amount.
@ -307,6 +313,8 @@ public:
virtual CSSToParentLayerScale GetScaleForAxis(const CSSToParentLayerScale2D& aScale) const override;
virtual ScreenPoint MakePoint(ScreenCoord aCoord) const override;
virtual const char* Name() const override;
private:
virtual OverscrollBehavior GetOverscrollBehavior() const override;
};
class AxisY : public Axis {
@ -318,6 +326,8 @@ public:
virtual CSSToParentLayerScale GetScaleForAxis(const CSSToParentLayerScale2D& aScale) const override;
virtual ScreenPoint MakePoint(ScreenCoord aCoord) const override;
virtual const char* Name() const override;
private:
virtual OverscrollBehavior GetOverscrollBehavior() const override;
};
} // namespace layers