Skip to content

Commit

Permalink
Fix another inappropriate overscroll glow.
Browse files Browse the repository at this point in the history
r259729 fixed one bad overscroll glow, but introduced a regression in another
case.  When a scroll amount fell between 0.01 and 0.1, the early break caused
the amount to fail to be subtracted from unused_scroll_delta at all, so all such
scrolls resulted in a glow.

BUG=358093

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261241 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sataya.m@samsung.com committed Apr 3, 2014
1 parent 3682c77 commit 5b8a865
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
18 changes: 9 additions & 9 deletions cc/trees/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,15 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
applied_delta = ScrollLayerWithLocalDelta(layer_impl, pending_delta);
}

if (layer_impl == InnerViewportScrollLayer()) {
unused_root_delta.Subtract(applied_delta);
const float kOverscrollEpsilon = 0.01f;
if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon)
unused_root_delta.set_x(0.0f);
if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon)
unused_root_delta.set_y(0.0f);
}

// If the layer wasn't able to move, try the next one in the hierarchy.
float move_threshold = 0.1f;
bool did_move_layer_x = std::abs(applied_delta.x()) > move_threshold;
Expand All @@ -2284,15 +2293,6 @@ bool LayerTreeHostImpl::ScrollBy(const gfx::Point& viewport_point,
break;
}

if (layer_impl == InnerViewportScrollLayer()) {
unused_root_delta.Subtract(applied_delta);
const float kOverscrollEpsilon = 0.01f;
if (std::abs(unused_root_delta.x()) < kOverscrollEpsilon)
unused_root_delta.set_x(0.0f);
if (std::abs(unused_root_delta.y()) < kOverscrollEpsilon)
unused_root_delta.set_y(0.0f);
}

did_lock_scrolling_layer_ = true;
if (!should_bubble_scrolls_) {
active_tree_->SetCurrentlyScrollingLayer(layer_impl);
Expand Down
22 changes: 18 additions & 4 deletions cc/trees/layer_tree_host_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3171,10 +3171,7 @@ TEST_F(LayerTreeHostImplTest, OverscrollAlways) {
EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll());
}

TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) {
// Edge glow effect should be applicable only upon reaching Edges
// of the content. unnecessary glow effect calls shouldn't be
// called while scrolling up without reaching the edge of the content.
TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) {
gfx::Size surface_size(100, 100);
gfx::Size content_size(200, 200);
scoped_ptr<LayerImpl> root_clip =
Expand All @@ -3195,6 +3192,9 @@ TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) {
host_impl_->active_tree()->DidBecomeActive();
DrawFrame();
{
// Edge glow effect should be applicable only upon reaching Edges
// of the content. unnecessary glow effect calls shouldn't be
// called while scrolling up without reaching the edge of the content.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel));
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100));
Expand All @@ -3204,6 +3204,20 @@ TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) {
EXPECT_EQ(gfx::Vector2dF().ToString(),
host_impl_->accumulated_root_overscroll().ToString());
host_impl_->ScrollEnd();
// unusedrootDelta should be subtracted from applied delta so that
// unwanted glow effect calls are not called.
EXPECT_EQ(InputHandler::ScrollStarted,
host_impl_->ScrollBegin(gfx::Point(0, 0),
InputHandler::NonBubblingGesture));
EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin());
host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20));
EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(),
host_impl_->accumulated_root_overscroll().ToString());

host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f));
EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(),
host_impl_->accumulated_root_overscroll().ToString());
host_impl_->ScrollEnd();
}
}

Expand Down

0 comments on commit 5b8a865

Please sign in to comment.