Bug 1364622 - Consider async transforms on scroll thumb layers during hit testing. r=kats
MozReview-Commit-ID: 9avcNOKmmqF
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -2203,22 +2203,45 @@ APZCTreeManager::CommonAncestor(AsyncPan
aApzc2 = aApzc2->GetParent();
}
return ancestor.forget();
}
LayerToParentLayerMatrix4x4
APZCTreeManager::ComputeTransformForNode(const HitTestingTreeNode* aNode) const
{
- AsyncPanZoomController* apzc = aNode->GetApzc();
- return aNode->GetTransform() *
- CompleteAsyncTransform(
- apzc
- ? apzc->GetCurrentAsyncTransformWithOverscroll(AsyncPanZoomController::NORMAL)
- : AsyncTransformComponentMatrix());
+ if (AsyncPanZoomController* apzc = aNode->GetApzc()) {
+ // If the node represents scrollable content, apply the async transform
+ // from its APZC.
+ return aNode->GetTransform() *
+ CompleteAsyncTransform(
+ apzc->GetCurrentAsyncTransformWithOverscroll(AsyncPanZoomController::NORMAL));
+ } else if (aNode->IsScrollThumbNode()) {
+ // If the node represents a scrollbar thumb, compute and apply the
+ // transformation that will be applied to the thumb in
+ // AsyncCompositionManager.
+ ScrollableLayerGuid guid{aNode->GetLayersId(), 0, aNode->GetScrollTargetId()};
+ if (RefPtr<HitTestingTreeNode> scrollTargetNode = GetTargetNode(guid, &GuidComparatorIgnoringPresShell)) {
+ AsyncPanZoomController* scrollTargetApzc = scrollTargetNode->GetApzc();
+ MOZ_ASSERT(scrollTargetApzc);
+ return scrollTargetApzc->CallWithLastContentPaintMetrics(
+ [&](const FrameMetrics& aMetrics) {
+ return AsyncCompositionManager::ComputeTransformForScrollThumb(
+ aNode->GetTransform() * AsyncTransformMatrix(),
+ scrollTargetNode->GetTransform().ToUnknownMatrix(),
+ scrollTargetApzc,
+ aMetrics,
+ aNode->GetScrollThumbData(),
+ scrollTargetNode->IsAncestorOf(aNode),
+ nullptr);
+ });
+ }
+ }
+ // Otherwise, the node does not have an async transform.
+ return aNode->GetTransform() * AsyncTransformMatrix();
}
#if defined(MOZ_WIDGET_ANDROID)
void
APZCTreeManager::InitializeDynamicToolbarAnimator(const int64_t& aRootLayerTreeId)
{
MOZ_ASSERT(mToolbarAnimator);
mToolbarAnimator->Initialize(aRootLayerTreeId);