Bug 1349750 - If APZ hit testing hits a scrollbar node, return the node for later use. r=kats
MozReview-Commit-ID: Lgz5N3nkPlb
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -784,19 +784,20 @@ APZCTreeManager::ReceiveInputEvent(Input
if (DragTracker::StartsDrag(mouseInput)) {
// If this is the start of a drag we need to unambiguously know if it's
// going to land on a scrollbar or not. We can't apply an untransform
// here without knowing that, so we need to ensure the untransform is
// a no-op.
FlushRepaintsToClearScreenToGeckoTransform();
}
- bool hitScrollbar = false;
+ HitTestingTreeNode* hitScrollbarNode = nullptr;
RefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(mouseInput.mOrigin,
- &hitResult, &hitScrollbar);
+ &hitResult, &hitScrollbarNode);
+ bool hitScrollbar = hitScrollbarNode;
// When the mouse is outside the window we still want to handle dragging
// but we won't find an APZC. Fallback to root APZC then.
{ // scope lock
MutexAutoLock lock(mTreeLock);
if (!apzc && mRootNode) {
apzc = mRootNode->GetApzc();
}
@@ -1646,17 +1647,17 @@ APZCTreeManager::GetTargetNode(const Scr
}
);
return target.forget();
}
already_AddRefed<AsyncPanZoomController>
APZCTreeManager::GetTargetAPZC(const ScreenPoint& aPoint,
HitTestResult* aOutHitResult,
- bool* aOutHitScrollbar)
+ HitTestingTreeNode** aOutHitScrollbar)
{
MutexAutoLock lock(mTreeLock);
HitTestResult hitResult = HitNothing;
ParentLayerPoint point = ViewAs<ParentLayerPixel>(aPoint,
PixelCastJustification::ScreenIsParentLayerForRoot);
RefPtr<AsyncPanZoomController> target = GetAPZCAtPoint(mRootNode, point,
&hitResult, aOutHitScrollbar);
@@ -1787,17 +1788,17 @@ APZCTreeManager::GetTargetApzcForNode(Hi
}
return nullptr;
}
AsyncPanZoomController*
APZCTreeManager::GetAPZCAtPoint(HitTestingTreeNode* aNode,
const ParentLayerPoint& aHitTestPoint,
HitTestResult* aOutHitResult,
- bool* aOutHitScrollbar)
+ HitTestingTreeNode** aOutScrollbarNode)
{
mTreeLock.AssertCurrentThreadOwns();
// This walks the tree in depth-first, reverse order, so that it encounters
// APZCs front-to-back on the screen.
HitTestingTreeNode* resultNode;
HitTestingTreeNode* root = aNode;
std::stack<ParentLayerPoint> hitTestPoints;
@@ -1840,18 +1841,18 @@ APZCTreeManager::GetAPZCAtPoint(HitTesti
return TraversalFlag::Continue;
}
);
if (*aOutHitResult != HitNothing) {
MOZ_ASSERT(resultNode);
for (HitTestingTreeNode* n = resultNode; n; n = n->GetParent()) {
if (n->IsScrollbarNode()) {
- if (aOutHitScrollbar) {
- *aOutHitScrollbar = true;
+ if (aOutScrollbarNode) {
+ *aOutScrollbarNode = n;
}
// If we hit a scrollbar, target the APZC for the content scrolled
// by the scrollbar. (The scrollbar itself doesn't scroll with the
// scrolled content, so it doesn't carry the scrolled content's
// scroll metadata).
ScrollableLayerGuid guid(n->GetLayersId(), 0, n->GetScrollTargetId());
if (RefPtr<HitTestingTreeNode> scrollTarget = GetTargetNode(guid, &GuidComparatorIgnoringPresShell)) {
MOZ_ASSERT(scrollTarget->GetApzc());
--- a/gfx/layers/apz/src/APZCTreeManager.h
+++ b/gfx/layers/apz/src/APZCTreeManager.h
@@ -433,17 +433,17 @@ public:
lock the tree of APZCs while they find the right one, and then return an addref'd
pointer to it. This allows caller code to just use the target APZC without worrying
about it going away. These are public for testing code and generally should not be
used by other production code.
*/
RefPtr<HitTestingTreeNode> GetRootNode() const;
already_AddRefed<AsyncPanZoomController> GetTargetAPZC(const ScreenPoint& aPoint,
HitTestResult* aOutHitResult,
- bool* aOutHitScrollbar = nullptr);
+ HitTestingTreeNode** aOutScrollbarNode = nullptr);
ScreenToParentLayerMatrix4x4 GetScreenToApzcTransform(const AsyncPanZoomController *aApzc) const;
ParentLayerToScreenMatrix4x4 GetApzcToGeckoTransform(const AsyncPanZoomController *aApzc) const;
/**
* Process touch velocity.
* Sometimes the touch move event will have a velocity even though no scrolling
* is occurring such as when the toolbar is being hidden/shown in Fennec.
* This function can be called to have the y axis' velocity queue updated.
@@ -468,17 +468,17 @@ private:
GuidComparator aComparator);
HitTestingTreeNode* FindTargetNode(HitTestingTreeNode* aNode,
const ScrollableLayerGuid& aGuid,
GuidComparator aComparator);
AsyncPanZoomController* GetTargetApzcForNode(HitTestingTreeNode* aNode);
AsyncPanZoomController* GetAPZCAtPoint(HitTestingTreeNode* aNode,
const ParentLayerPoint& aHitTestPoint,
HitTestResult* aOutHitResult,
- bool* aOutHitScrollbar);
+ HitTestingTreeNode** aOutScrollbarNode);
AsyncPanZoomController* FindRootApzcForLayersId(uint64_t aLayersId) const;
AsyncPanZoomController* FindRootContentApzcForLayersId(uint64_t aLayersId) const;
AsyncPanZoomController* FindRootContentOrRootApzc() const;
already_AddRefed<AsyncPanZoomController> GetMultitouchTarget(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const;
already_AddRefed<AsyncPanZoomController> CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2) const;
already_AddRefed<AsyncPanZoomController> GetTouchInputBlockAPZC(const MultiTouchInput& aEvent,
nsTArray<TouchBehaviorFlags>* aOutTouchBehaviors,
HitTestResult* aOutHitResult);