Bug 1779144 - Factor out a helper shared by the touch event and tap event handling codepaths. r=dlrobertson

Depends on D151939

Differential Revision: https://phabricator.services.mozilla.com/D151940
This commit is contained in:
Botond Ballo 2022-07-18 21:37:48 +00:00
Родитель d6e6ccf103
Коммит a4bfaaf34b
2 изменённых файлов: 25 добавлений и 29 удалений

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

@ -2046,23 +2046,8 @@ void APZCTreeManager::ProcessTouchInput(InputHandlingState& aState,
return;
}
touchData.mScreenPoint = *untransformedScreenPoint;
if (mTouchBlockHitResult.mFixedPosSides != SideBits::eNone) {
MutexAutoLock lock(mMapLock);
touchData.mScreenPoint -= RoundedToInt(apz::ComputeFixedMarginsOffset(
GetCompositorFixedLayerMargins(lock),
mTouchBlockHitResult.mFixedPosSides, mGeckoFixedLayerMargins));
} else if (mTouchBlockHitResult.mNode &&
mTouchBlockHitResult.mNode->GetStickyPositionAnimationId()) {
SideBits sideBits = SideBits::eNone;
{
RecursiveMutexAutoLock lock(mTreeLock);
sideBits =
SidesStuckToRootContent(mTouchBlockHitResult.mNode.Get(lock));
}
MutexAutoLock lock(mMapLock);
touchData.mScreenPoint -= RoundedToInt(apz::ComputeFixedMarginsOffset(
GetCompositorFixedLayerMargins(lock), sideBits, ScreenMargin()));
}
AdjustEventPointForDynamicToolbar(touchData.mScreenPoint,
mTouchBlockHitResult);
}
}
}
@ -2078,6 +2063,25 @@ void APZCTreeManager::ProcessTouchInput(InputHandlingState& aState,
}
}
void APZCTreeManager::AdjustEventPointForDynamicToolbar(
ScreenIntPoint& aEventPoint, const HitTestResult& aHit) {
if (aHit.mFixedPosSides != SideBits::eNone) {
MutexAutoLock lock(mMapLock);
aEventPoint -= RoundedToInt(apz::ComputeFixedMarginsOffset(
GetCompositorFixedLayerMargins(lock), aHit.mFixedPosSides,
mGeckoFixedLayerMargins));
} else if (aHit.mNode && aHit.mNode->GetStickyPositionAnimationId()) {
SideBits sideBits = SideBits::eNone;
{
RecursiveMutexAutoLock lock(mTreeLock);
sideBits = SidesStuckToRootContent(mTouchBlockHitResult.mNode.Get(lock));
}
MutexAutoLock lock(mMapLock);
aEventPoint -= RoundedToInt(apz::ComputeFixedMarginsOffset(
GetCompositorFixedLayerMargins(lock), sideBits, ScreenMargin()));
}
}
static MouseInput::MouseType MultiTouchTypeToMouseType(
MultiTouchInput::MultiTouchType aType) {
switch (aType) {
@ -3262,18 +3266,7 @@ Maybe<ScreenIntPoint> APZCTreeManager::ConvertToGecko(
Maybe<ScreenIntPoint> geckoPoint =
UntransformBy(transformScreenToGecko, aPoint);
if (geckoPoint) {
if (hit.mFixedPosSides != SideBits::eNone) {
MutexAutoLock mapLock(mMapLock);
*geckoPoint -= RoundedToInt(apz::ComputeFixedMarginsOffset(
GetCompositorFixedLayerMargins(mapLock), hit.mFixedPosSides,
mGeckoFixedLayerMargins));
} else if (hit.mNode && hit.mNode->GetStickyPositionAnimationId()) {
SideBits sideBits = SidesStuckToRootContent(hit.mNode.Get(lock));
MutexAutoLock mapLock(mMapLock);
*geckoPoint -= RoundedToInt(apz::ComputeFixedMarginsOffset(
GetCompositorFixedLayerMargins(mapLock), sideBits, ScreenMargin()));
}
AdjustEventPointForDynamicToolbar(*geckoPoint, hit);
}
return geckoPoint;
}

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

@ -566,6 +566,9 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge {
ScreenMargin GetCompositorFixedLayerMargins() const;
void AdjustEventPointForDynamicToolbar(ScreenIntPoint& aEventPoint,
const HitTestResult& aHit);
APZScrollGeneration NewAPZScrollGeneration() {
// In the production code this function gets only called from the sampler
// thread but in tests using nsIDOMWindowUtils.setAsyncScrollOffset this