Skip to content

Commit

Permalink
Touch flings should not bubble.
Browse files Browse the repository at this point in the history
Currently touch flings can bubble out of an accelerated overflow scrolling div,
but this should not happen.

Looking at InputHandlerProxy::HandleGestureFling, FlingScrollBegin appears to be used for touch fling. Given that this is the case, I've set should_bubble_scrolls_ to false there.

Tests:
TouchFlingShouldNotBubble
 - checks that this fling doesn't bubble.
WheelFlingShouldBubble
 - checks that this does.

R=danakj@chromium.org,aelias@chromium.org
BUG=270281

Review URL: https://codereview.chromium.org/26470004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227585 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vollick@chromium.org committed Oct 8, 2013
1 parent 62aec85 commit df0c423
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cc/trees/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,9 @@ InputHandler::ScrollStatus LayerTreeHostImpl::FlingScrollBegin() {
return ScrollIgnored;
}

if (!wheel_scrolling_)
should_bubble_scrolls_ = false;

return ScrollStarted;
}

Expand Down
78 changes: 77 additions & 1 deletion cc/trees/layer_tree_host_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class LayerTreeHostImplTest : public testing::Test,
times_encountered++;
}

ASSERT_EQ(times_encountered, 1);
ASSERT_EQ(1, times_encountered);
}

static void ExpectNone(const ScrollAndScaleSet& scroll_info, int id) {
Expand Down Expand Up @@ -5306,5 +5306,81 @@ TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) {
EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures());
}

TEST_F(LayerTreeHostImplTest, TouchFlingShouldNotBubble) {
// When flinging via touch, only the child should scroll (we should not
// bubble).
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size);
scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size);

root->AddChild(child.Pass());

host_impl_->SetViewportSize(surface_size);
host_impl_->active_tree()->SetRootLayer(root.Pass());
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(),
InputHandler::Gesture));

EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->FlingScrollBegin());

gfx::Vector2d scroll_delta(0, 100);
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
host_impl_->ScrollBy(gfx::Point(), scroll_delta);

host_impl_->ScrollEnd();

scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();

// Only the child should have scrolled.
ASSERT_EQ(1u, scroll_info->scrolls.size());
ExpectNone(*scroll_info.get(),
host_impl_->active_tree()->root_layer()->id());
}
}

TEST_F(LayerTreeHostImplTest, WheelFlingShouldBubble) {
// When flinging via wheel, the root should eventually scroll (we should
// bubble).
gfx::Size surface_size(10, 10);
gfx::Size content_size(20, 20);
scoped_ptr<LayerImpl> root = CreateScrollableLayer(1, content_size);
scoped_ptr<LayerImpl> child = CreateScrollableLayer(2, content_size);

root->AddChild(child.Pass());

host_impl_->SetViewportSize(surface_size);
host_impl_->active_tree()->SetRootLayer(root.Pass());
host_impl_->active_tree()->DidBecomeActive();
InitializeRendererAndDrawFrame();
{
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel));

EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->FlingScrollBegin());

gfx::Vector2d scroll_delta(0, 100);
host_impl_->ScrollBy(gfx::Point(), scroll_delta);
host_impl_->ScrollBy(gfx::Point(), scroll_delta);

host_impl_->ScrollEnd();

scoped_ptr<ScrollAndScaleSet> scroll_info =
host_impl_->ProcessScrollDeltas();

// Only the root should have scrolled.
ASSERT_EQ(2u, scroll_info->scrolls.size());
ExpectContains(*scroll_info.get(),
host_impl_->active_tree()->root_layer()->id(),
gfx::Vector2d(0, 10));
}
}

} // namespace
} // namespace cc

0 comments on commit df0c423

Please sign in to comment.