summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsataya.m@samsung.com <sataya.m@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 00:35:51 +0000
committersataya.m@samsung.com <sataya.m@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 00:35:51 +0000
commit5b8a865c45fd7758e2b82af4f8e3f75e57686eac (patch)
treec905a05965fe7a96f8536e08be27fee57a1cacd2
parent3682c7736e9cb6cf952c644cf967591bebd5f93a (diff)
downloadchromium_src-5b8a865c45fd7758e2b82af4f8e3f75e57686eac.zip
chromium_src-5b8a865c45fd7758e2b82af4f8e3f75e57686eac.tar.gz
chromium_src-5b8a865c45fd7758e2b82af4f8e3f75e57686eac.tar.bz2
Fix another inappropriate overscroll glow.
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
-rw-r--r--cc/trees/layer_tree_host_impl.cc18
-rw-r--r--cc/trees/layer_tree_host_impl_unittest.cc22
2 files changed, 27 insertions, 13 deletions
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index efd3b99..45e1ec1 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -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;
@@ -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);
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 977f3db..01cb870 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -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 =
@@ -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));
@@ -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();
}
}