diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc index 6db7af763c2e1..65970d9511a8c 100644 --- a/cc/layer_impl.cc +++ b/cc/layer_impl.cc @@ -215,8 +215,9 @@ InputHandlerClient::ScrollStatus LayerImpl::tryScroll(const gfx::PointF& screenS if (!nonFastScrollableRegion().IsEmpty()) { bool clipped = false; - gfx::PointF hitTestPointInLocalSpace = MathUtil::projectPoint(screenSpaceTransform().inverse(), screenSpacePoint, clipped); - if (!clipped && nonFastScrollableRegion().Contains(gfx::ToFlooredPoint(hitTestPointInLocalSpace))) { + gfx::PointF hitTestPointInContentSpace = MathUtil::projectPoint(screenSpaceTransform().inverse(), screenSpacePoint, clipped); + gfx::PointF hitTestPointInLayerSpace = hitTestPointInContentSpace.Scale(1 / contentsScaleX(), 1 / contentsScaleY()); + if (!clipped && nonFastScrollableRegion().Contains(gfx::ToRoundedPoint(hitTestPointInLayerSpace))) { TRACE_EVENT0("cc", "LayerImpl::tryScroll: Failed nonFastScrollableRegion"); return InputHandlerClient::ScrollOnMainThread; } diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc index ddd393d1f036e..61c7d272261cc 100644 --- a/cc/layer_tree_host_impl_unittest.cc +++ b/cc/layer_tree_host_impl_unittest.cc @@ -432,11 +432,13 @@ TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionBasic) { setupScrollAndContentsLayers(gfx::Size(200, 200)); m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); - initializeRendererAndDrawFrame(); - LayerImpl* root = m_hostImpl->rootLayer(); + LayerImpl* root = m_hostImpl->rootLayer(); + root->setContentsScale(2, 2); root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); + initializeRendererAndDrawFrame(); + // All scroll types inside the non-fast scrollable region should fail. EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wheel), InputHandlerClient::ScrollOnMainThread); EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Gesture), InputHandlerClient::ScrollOnMainThread); @@ -454,10 +456,12 @@ TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) { setupScrollAndContentsLayers(gfx::Size(200, 200)); m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); - LayerImpl* root = m_hostImpl->rootLayer(); + LayerImpl* root = m_hostImpl->rootLayer(); + root->setContentsScale(2, 2); root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); root->setPosition(gfx::PointF(-25, 0)); + initializeRendererAndDrawFrame(); // This point would fall into the non-fast scrollable region except that we've moved the layer down by 25 pixels.