From 2c4a8779e8e05df4fd3cdfa99c55a2f39df28d2e Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 15 Jan 2015 10:37:54 -0500 Subject: [PATCH] Bug 1119497 - Don't continue searching if we hit a layer that has no containing APZC. r=botond --- gfx/layers/apz/src/APZCTreeManager.cpp | 8 ++--- .../gtest/TestAsyncPanZoomController.cpp | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index f24f68ab19af..7bd1c9f26d2f 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1348,7 +1348,7 @@ APZCTreeManager::GetAPZCAtPoint(HitTestingTreeNode* aNode, } // If we didn't match anything in the subtree, check |node|. - if (!result) { + if (*aOutHitResult == NoApzcHit) { APZCTM_LOG("Testing ParentLayer point %s (Layer %s) against node %p\n", Stringify(aHitTestPoint).c_str(), hitTestPointForChildLayers ? Stringify(hitTestPointForChildLayers.ref()).c_str() : "nil", @@ -1367,14 +1367,14 @@ APZCTreeManager::GetAPZCAtPoint(HitTestingTreeNode* aNode, // If we are overscrolled, and the point matches us or one of our children, // the result is inside an overscrolled APZC, inform our caller of this // (callers typically ignore events targeted at overscrolled APZCs). - if (result && apzc && apzc->IsOverscrolled()) { + if (*aOutHitResult != NoApzcHit && apzc && apzc->IsOverscrolled()) { APZCTM_LOG("Result is inside overscrolled APZC %p\n", apzc); *aOutHitResult = OverscrolledApzc; return nullptr; } - if (result) { - if (!gfxPrefs::LayoutEventRegionsEnabled()) { + if (*aOutHitResult != NoApzcHit) { + if (result && !gfxPrefs::LayoutEventRegionsEnabled()) { // When event-regions are disabled, we treat scrollinfo layers as // regular scrollable layers. Unfortunately, their "hit region" (which // we create from the composition bounds) is their full area, and they diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index 735a9bb79d4f..db73ee9ed5b7 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -2552,6 +2552,25 @@ protected: rootApzc = ApzcOf(root); } + void CreateBug1119497LayerTree() { + const char* layerTreeSyntax = "c(tt)"; + // LayerID 0 12 + // 0 is the root and doesn't have an APZC + // 1 is behind 2 and does have an APZC + // 2 entirely covers 1 and should take all the input events + nsIntRegion layerVisibleRegions[] = { + nsIntRegion(nsIntRect(0, 0, 100, 100)), + nsIntRegion(nsIntRect(0, 0, 100, 100)), + nsIntRegion(nsIntRect(0, 0, 100, 100)), + }; + root = CreateLayerTree(layerTreeSyntax, layerVisibleRegions, nullptr, lm, layers); + + SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1); + + registration = MakeUnique(0, root, mcc); + manager->UpdateHitTestingTree(nullptr, root, false, 0, 0); + } + void CreateBug1117712LayerTree() { const char* layerTreeSyntax = "c(c(t)t)"; // LayerID 0 1 2 3 @@ -2679,6 +2698,19 @@ TEST_F(APZEventRegionsTester, Obscuration) { EXPECT_EQ(HitTestResult::ApzcHitRegion, result); } +TEST_F(APZEventRegionsTester, Bug1119497) { + SCOPED_GFX_PREF(LayoutEventRegionsEnabled, bool, true); + + CreateBug1119497LayerTree(); + + HitTestResult result; + nsRefPtr hit = manager->GetTargetAPZC(ScreenPoint(50, 50), &result); + // We should hit layers[2], so |result| will be ApzcHitRegion but there's no + // actual APZC in that parent chain, so |hit| should be nullptr. + EXPECT_EQ(nullptr, hit.get()); + EXPECT_EQ(HitTestResult::ApzcHitRegion, result); +} + TEST_F(APZEventRegionsTester, Bug1117712) { SCOPED_GFX_PREF(LayoutEventRegionsEnabled, bool, true);