Bug 1247964 - Allow InputBlockState::SetScrolledApzc to accept new APZC when it is an ancestor of the current APZC r=kats

This commit is contained in:
Botond Ballo 2016-03-14 16:36:54 -07:00 коммит произвёл Randall Barker
Родитель a4d714a39f
Коммит 7d02dd23e3
2 изменённых файлов: 29 добавлений и 2 удалений

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

@ -87,11 +87,33 @@ InputBlockState::IsTargetConfirmed() const
return mTargetConfirmed;
}
bool
InputBlockState::IsAncestorOf(AsyncPanZoomController* aA, AsyncPanZoomController* aB)
{
if (aA == aB) {
return true;
}
bool seenA = false;
for (size_t i = 0; i < mOverscrollHandoffChain->Length(); ++i) {
AsyncPanZoomController* apzc = mOverscrollHandoffChain->GetApzcAtIndex(i);
if (apzc == aB) {
return seenA;
}
if (apzc == aA) {
seenA = true;
}
}
return false;
}
void
InputBlockState::SetScrolledApzc(AsyncPanZoomController* aApzc)
{
// An input block should only have one scrolled APZC.
MOZ_ASSERT(!mScrolledApzc || mScrolledApzc == aApzc);
// With immediate handoff disabled, the scrolled APZC cannot move down the handoff chain
// but it can move up the handoff chain if we change scrolling directions.
MOZ_ASSERT(!mScrolledApzc || IsAncestorOf(aApzc, mScrolledApzc));
mScrolledApzc = aApzc;
}

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

@ -56,6 +56,11 @@ public:
protected:
virtual void UpdateTargetApzc(const RefPtr<AsyncPanZoomController>& aTargetApzc);
private:
// Checks whether |aA| is an ancestor of |aB| (or the same as |aB|) in
// |mOverscrollHandoffChain|.
bool IsAncestorOf(AsyncPanZoomController* aA, AsyncPanZoomController* aB);
private:
RefPtr<AsyncPanZoomController> mTargetApzc;
bool mTargetConfirmed;