Skip to content

Commit

Permalink
Bug 1779144 - Factor out a helper shared by the touch event and tap e…
Browse files Browse the repository at this point in the history
…vent handling codepaths. r=dlrobertson

Depends on D151939

Differential Revision: https://phabricator.services.mozilla.com/D151940
  • Loading branch information
theres-waldo committed Jul 18, 2022
1 parent d6e6ccf commit a4bfaaf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
51 changes: 22 additions & 29 deletions gfx/layers/apz/src/APZCTreeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions gfx/layers/apz/src/APZCTreeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a4bfaaf

Please sign in to comment.