diff options
author | sujiths.s <sujiths.s@samsung.com> | 2014-11-07 19:04:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-08 03:04:30 +0000 |
commit | 344435e974a2f4322735f04a0a3118aa262a6910 (patch) | |
tree | daea5072f6ead643559c17421d0cc43a6a273cfc | |
parent | 43760591658239084cf4b92ec4dd4decbb9c5fe6 (diff) | |
download | chromium_src-344435e974a2f4322735f04a0a3118aa262a6910.zip chromium_src-344435e974a2f4322735f04a0a3118aa262a6910.tar.gz chromium_src-344435e974a2f4322735f04a0a3118aa262a6910.tar.bz2 |
[android] Remove unused scroll delta in TopControls
In TopControlsManager, current_scroll_delta_ is consuming scroll delta
which is not been used by either top controls or the root layer.
So removing the unused scroll delta from the top controls so that top
controls will be shown before the glow effect.
BUG=424068
Review URL: https://codereview.chromium.org/661643004
Cr-Commit-Position: refs/heads/master@{#303367}
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 7 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl_unittest.cc | 70 |
3 files changed, 73 insertions, 5 deletions
@@ -443,6 +443,7 @@ Subrahmanya Praveen Munukutla <sataya.m@samsung.com> Suchit Agrawal <a.suchit@samsung.com> Sudarsana Babu Nagineni <sudarsana.nagineni@intel.com> Sudarshan Parthasarathy <sudarshan.p@samsung.com> +Sujith S S <sujiths.s@samsung.com> Sungguk Lim <limasdf@gmail.com> Sungmann Cho <sungmann.cho@gmail.com> Sungmann Cho <sungmann.cho@navercorp.com> diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index e26ed7a..a305dc0 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -2629,11 +2629,8 @@ bool LayerTreeHostImpl::ShouldTopControlsConsumeScroll( CurrentlyScrollingLayer() != OuterViewportScrollLayer()) return false; - if (InnerViewportScrollLayer()->MaxScrollOffset().y() > 0) - return true; - - if (OuterViewportScrollLayer() && - OuterViewportScrollLayer()->MaxScrollOffset().y() > 0) + if (active_tree()->TotalScrollOffset().y() < + active_tree()->TotalMaxScrollOffset().y()) return true; return false; diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index 45d636a..7bfafbf 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc @@ -2592,6 +2592,14 @@ TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); host_impl_->ScrollBy(gfx::Point(), scroll_delta); + + // scrolling down at the max extents no longer hides the top controls + EXPECT_EQ(0.f, + settings_.top_controls_height - + host_impl_->active_tree()->total_top_controls_content_offset()); + + // forcefully hide the top controls by 25px + host_impl_->top_controls_manager()->ScrollBy(scroll_delta); host_impl_->ScrollEnd(); EXPECT_EQ(scroll_delta.y(), @@ -7301,6 +7309,68 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); } +TEST_F(LayerTreeHostImplWithTopControlsTest, + TopControlsScrollDeltaInOverScroll) { + // test varifies that the overscroll delta should not have accumulated in + // the top controls if we do a hide and show without releasing finger. + + LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); + host_impl_->SetViewportSize(gfx::Size(100, 100)); + host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, + false); + DrawFrame(); + + EXPECT_EQ(InputHandler::ScrollStarted, + host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); + EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); + + float offset = 50; + EXPECT_TRUE( + host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); + EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); + EXPECT_EQ(gfx::Vector2dF().ToString(), + scroll_layer->TotalScrollOffset().ToString()); + + EXPECT_TRUE( + host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); + EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), + scroll_layer->TotalScrollOffset().ToString()); + + EXPECT_TRUE( + host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); + + // Should have fully scrolled + EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), + scroll_layer->TotalScrollOffset().ToString()); + + float overscrollamount = 10; + + // Overscroll the content + EXPECT_FALSE( + host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) + .did_scroll); + EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), + scroll_layer->TotalScrollOffset().ToString()); + EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), + host_impl_->accumulated_root_overscroll().ToString()); + + EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) + .did_scroll); + EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), + scroll_layer->TotalScrollOffset().ToString()); + EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); + + EXPECT_TRUE( + host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); + EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), + scroll_layer->TotalScrollOffset().ToString()); + + // Top controls should be fully visible + EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); + + host_impl_->ScrollEnd(); +} + class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { public: void SetupVirtualViewportLayers(const gfx::Size& content_size, |