0

LayerImpl::tryScroll must convert its content-space point to layer space before comparing to the nonFastScrollableRegion.

The hit test resulting point that the tryScroll() method gets is in content
space, since it is the result of mapping via the inverse screenSpaceTransform.
However, the nonFastScrollableRegion is in layer space, so it should not compare
the point against the region directly. We add a conversion from content to layer
space before doing the test.

This is now covered by the following tests. Because the layer is given a
contentsScale, the tests fail without the above change made to tryScroll.

Tests:
cc_unittests:LayerTreeHostImplTest.nonFastScrollableRegionBasic
cc_unittests:LayerTreeHostImplTest.nonFastScrollableRegionWithOffset

R=enne
BUG=159676


Review URL: https://chromiumcodereview.appspot.com/11377006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166353 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
danakj@chromium.org
2012-11-07 04:48:24 +00:00
parent c7ba6ab7d5
commit a90aa708ce
2 changed files with 10 additions and 5 deletions

@ -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;
}

@ -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.