OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 vertical_scrollbar.get()); | 752 vertical_scrollbar.get()); |
753 | 753 |
754 // Trying to scroll with a vertical scrollbar will succeed. | 754 // Trying to scroll with a vertical scrollbar will succeed. |
755 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 755 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
756 gfx::Point(), SCROLL_FORWARD)); | 756 gfx::Point(), SCROLL_FORWARD)); |
757 EXPECT_FLOAT_EQ(875.f, host_impl_->RootScrollLayer()->ScrollDelta().y()); | 757 EXPECT_FLOAT_EQ(875.f, host_impl_->RootScrollLayer()->ScrollDelta().y()); |
758 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 758 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
759 gfx::Point(), SCROLL_BACKWARD)); | 759 gfx::Point(), SCROLL_BACKWARD)); |
760 } | 760 } |
761 | 761 |
762 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | |
763 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | |
764 host_impl_->SetViewportSize(gfx::Size(100, 100)); | |
765 | |
766 gfx::Size overflow_size(400, 400); | |
767 ASSERT_EQ(1, scroll_layer->children().size()); | |
768 LayerImpl* overflow = scroll_layer->children()[0]; | |
769 overflow->SetBounds(overflow_size); | |
770 overflow->SetContentBounds(overflow_size); | |
771 overflow->SetScrollable(true); | |
772 overflow->SetMaxScrollOffset(gfx::Vector2d(overflow_size.width(), | |
773 overflow_size.height())); | |
774 overflow->SetScrollOffset(gfx::Vector2d()); | |
775 overflow->SetPosition(gfx::PointF()); | |
776 overflow->SetAnchorPoint(gfx::PointF()); | |
777 | |
778 InitializeRendererAndDrawFrame(); | |
779 gfx::Point scroll_position(10, 10); | |
780 | |
781 EXPECT_EQ(InputHandler::ScrollStarted, | |
782 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | |
783 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | |
784 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset()); | |
785 | |
786 gfx::Vector2dF scroll_delta(10, 10); | |
787 host_impl_->ScrollBy(scroll_position, scroll_delta); | |
788 host_impl_->ScrollEnd(); | |
789 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | |
790 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset()); | |
791 | |
792 overflow->SetUserScrollable(false, true); | |
jamesr
2013/10/21 22:36:34
callsites like this are really hard to read - what
sadrul
2013/10/21 22:39:03
Should this be done for the blink change in https:
sadrul
2013/10/21 23:11:17
Done (replaced LayerImpl::SetUserScrollable() with
| |
793 | |
794 EXPECT_EQ(InputHandler::ScrollStarted, | |
795 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | |
796 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | |
797 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset()); | |
798 | |
799 host_impl_->ScrollBy(scroll_position, scroll_delta); | |
800 host_impl_->ScrollEnd(); | |
801 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | |
802 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | |
803 | |
804 overflow->SetUserScrollable(false, false); | |
805 | |
806 EXPECT_EQ(InputHandler::ScrollStarted, | |
807 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | |
808 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | |
809 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | |
810 | |
811 host_impl_->ScrollBy(scroll_position, scroll_delta); | |
812 host_impl_->ScrollEnd(); | |
813 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); | |
814 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | |
815 } | |
816 | |
762 TEST_F(LayerTreeHostImplTest, | 817 TEST_F(LayerTreeHostImplTest, |
763 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { | 818 ClearRootRenderSurfaceAndHitTestTouchHandlerRegion) { |
764 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 819 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
765 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 820 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
766 InitializeRendererAndDrawFrame(); | 821 InitializeRendererAndDrawFrame(); |
767 | 822 |
768 // We should be able to hit test for touch event handlers even if the root | 823 // We should be able to hit test for touch event handlers even if the root |
769 // layer loses its render surface after the most recent render. | 824 // layer loses its render surface after the most recent render. |
770 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); | 825 host_impl_->active_tree()->root_layer()->ClearRenderSurface(); |
771 host_impl_->active_tree()->set_needs_update_draw_properties(); | 826 host_impl_->active_tree()->set_needs_update_draw_properties(); |
(...skipping 4657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5429 // The root should have scrolled. | 5484 // The root should have scrolled. |
5430 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 5485 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
5431 ExpectContains(*scroll_info.get(), | 5486 ExpectContains(*scroll_info.get(), |
5432 host_impl_->active_tree()->root_layer()->id(), | 5487 host_impl_->active_tree()->root_layer()->id(), |
5433 gfx::Vector2d(0, 10)); | 5488 gfx::Vector2d(0, 10)); |
5434 } | 5489 } |
5435 } | 5490 } |
5436 | 5491 |
5437 } // namespace | 5492 } // namespace |
5438 } // namespace cc | 5493 } // namespace cc |
OLD | NEW |