| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "cc/animation/animation_events.h" | 18 #include "cc/animation/animation_events.h" |
| 19 #include "cc/animation/animation_host.h" | 19 #include "cc/animation/animation_host.h" |
| 20 #include "cc/animation/animation_id_provider.h" | 20 #include "cc/animation/animation_id_provider.h" |
| 21 #include "cc/animation/transform_operations.h" | 21 #include "cc/animation/transform_operations.h" |
| 22 #include "cc/base/math_util.h" | 22 #include "cc/base/math_util.h" |
| 23 #include "cc/input/browser_controls_offset_manager.h" |
| 23 #include "cc/input/main_thread_scrolling_reason.h" | 24 #include "cc/input/main_thread_scrolling_reason.h" |
| 24 #include "cc/input/page_scale_animation.h" | 25 #include "cc/input/page_scale_animation.h" |
| 25 #include "cc/input/scrollbar_animation_controller_thinning.h" | 26 #include "cc/input/scrollbar_animation_controller_thinning.h" |
| 26 #include "cc/input/top_controls_manager.h" | |
| 27 #include "cc/layers/append_quads_data.h" | 27 #include "cc/layers/append_quads_data.h" |
| 28 #include "cc/layers/heads_up_display_layer_impl.h" | 28 #include "cc/layers/heads_up_display_layer_impl.h" |
| 29 #include "cc/layers/layer_impl.h" | 29 #include "cc/layers/layer_impl.h" |
| 30 #include "cc/layers/painted_scrollbar_layer_impl.h" | 30 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 31 #include "cc/layers/render_surface_impl.h" | 31 #include "cc/layers/render_surface_impl.h" |
| 32 #include "cc/layers/solid_color_layer_impl.h" | 32 #include "cc/layers/solid_color_layer_impl.h" |
| 33 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 33 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 34 #include "cc/layers/texture_layer_impl.h" | 34 #include "cc/layers/texture_layer_impl.h" |
| 35 #include "cc/layers/video_layer_impl.h" | 35 #include "cc/layers/video_layer_impl.h" |
| 36 #include "cc/layers/viewport.h" | 36 #include "cc/layers/viewport.h" |
| (...skipping 3860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3897 pending_outer_layer->layer_tree_impl() | 3897 pending_outer_layer->layer_tree_impl() |
| 3898 ->property_trees() | 3898 ->property_trees() |
| 3899 ->scroll_tree.UpdateScrollOffsetBaseForTesting(pending_outer_layer->id(), | 3899 ->scroll_tree.UpdateScrollOffsetBaseForTesting(pending_outer_layer->id(), |
| 3900 pending_scroll); | 3900 pending_scroll); |
| 3901 | 3901 |
| 3902 host_impl_->ActivateSyncTree(); | 3902 host_impl_->ActivateSyncTree(); |
| 3903 // Scrolloffsets on the active tree will be clamped after activation. | 3903 // Scrolloffsets on the active tree will be clamped after activation. |
| 3904 EXPECT_EQ(active_outer_layer->CurrentScrollOffset(), gfx::ScrollOffset(0, 0)); | 3904 EXPECT_EQ(active_outer_layer->CurrentScrollOffset(), gfx::ScrollOffset(0, 0)); |
| 3905 } | 3905 } |
| 3906 | 3906 |
| 3907 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { | 3907 class LayerTreeHostImplBrowserControlsTest : public LayerTreeHostImplTest { |
| 3908 public: | 3908 public: |
| 3909 LayerTreeHostImplTopControlsTest() | 3909 LayerTreeHostImplBrowserControlsTest() |
| 3910 // Make the clip size the same as the layer (content) size so the layer is | 3910 // Make the clip size the same as the layer (content) size so the layer is |
| 3911 // non-scrollable. | 3911 // non-scrollable. |
| 3912 : layer_size_(10, 10), | 3912 : layer_size_(10, 10), |
| 3913 clip_size_(layer_size_), | 3913 clip_size_(layer_size_), |
| 3914 top_controls_height_(50) { | 3914 top_controls_height_(50) { |
| 3915 viewport_size_ = gfx::Size(clip_size_.width(), | 3915 viewport_size_ = gfx::Size(clip_size_.width(), |
| 3916 clip_size_.height() + top_controls_height_); | 3916 clip_size_.height() + top_controls_height_); |
| 3917 } | 3917 } |
| 3918 | 3918 |
| 3919 bool CreateHostImpl( | 3919 bool CreateHostImpl( |
| 3920 const LayerTreeSettings& settings, | 3920 const LayerTreeSettings& settings, |
| 3921 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override { | 3921 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override { |
| 3922 bool init = LayerTreeHostImplTest::CreateHostImpl( | 3922 bool init = LayerTreeHostImplTest::CreateHostImpl( |
| 3923 settings, std::move(compositor_frame_sink)); | 3923 settings, std::move(compositor_frame_sink)); |
| 3924 if (init) { | 3924 if (init) { |
| 3925 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 3925 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 3926 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 3926 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f); |
| 3927 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3927 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3928 } | 3928 } |
| 3929 return init; | 3929 return init; |
| 3930 } | 3930 } |
| 3931 | 3931 |
| 3932 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 3932 void SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 3933 const gfx::Size& inner_viewport_size, | 3933 const gfx::Size& inner_viewport_size, |
| 3934 const gfx::Size& outer_viewport_size, | 3934 const gfx::Size& outer_viewport_size, |
| 3935 const gfx::Size& scroll_layer_size) { | 3935 const gfx::Size& scroll_layer_size) { |
| 3936 settings_ = DefaultSettings(); | 3936 settings_ = DefaultSettings(); |
| 3937 CreateHostImpl(settings_, CreateCompositorFrameSink()); | 3937 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 3938 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3938 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 3939 host_impl_->active_tree(), inner_viewport_size, outer_viewport_size, | 3939 host_impl_->active_tree(), inner_viewport_size, outer_viewport_size, |
| 3940 scroll_layer_size); | 3940 scroll_layer_size); |
| 3941 } | 3941 } |
| 3942 | 3942 |
| 3943 void SetupTopControlsAndScrollLayerWithVirtualViewport( | 3943 void SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 3944 LayerTreeImpl* tree_impl, | 3944 LayerTreeImpl* tree_impl, |
| 3945 const gfx::Size& inner_viewport_size, | 3945 const gfx::Size& inner_viewport_size, |
| 3946 const gfx::Size& outer_viewport_size, | 3946 const gfx::Size& outer_viewport_size, |
| 3947 const gfx::Size& scroll_layer_size) { | 3947 const gfx::Size& scroll_layer_size) { |
| 3948 tree_impl->set_top_controls_shrink_blink_size(true); | 3948 tree_impl->set_browser_controls_shrink_blink_size(true); |
| 3949 tree_impl->set_top_controls_height(top_controls_height_); | 3949 tree_impl->set_top_controls_height(top_controls_height_); |
| 3950 tree_impl->SetCurrentTopControlsShownRatio(1.f); | 3950 tree_impl->SetCurrentBrowserControlsShownRatio(1.f); |
| 3951 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3951 tree_impl->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3952 host_impl_->DidChangeTopControlsPosition(); | 3952 host_impl_->DidChangeBrowserControlsPosition(); |
| 3953 | 3953 |
| 3954 std::unique_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1); | 3954 std::unique_ptr<LayerImpl> root = LayerImpl::Create(tree_impl, 1); |
| 3955 std::unique_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2); | 3955 std::unique_ptr<LayerImpl> root_clip = LayerImpl::Create(tree_impl, 2); |
| 3956 std::unique_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3); | 3956 std::unique_ptr<LayerImpl> page_scale = LayerImpl::Create(tree_impl, 3); |
| 3957 | 3957 |
| 3958 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); | 3958 std::unique_ptr<LayerImpl> outer_scroll = LayerImpl::Create(tree_impl, 4); |
| 3959 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); | 3959 std::unique_ptr<LayerImpl> outer_clip = LayerImpl::Create(tree_impl, 5); |
| 3960 | 3960 |
| 3961 root_clip->SetBounds(inner_viewport_size); | 3961 root_clip->SetBounds(inner_viewport_size); |
| 3962 root->SetScrollClipLayer(root_clip->id()); | 3962 root->SetScrollClipLayer(root_clip->id()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3993 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); | 3993 EXPECT_EQ(inner_viewport_size, root_clip_ptr->bounds()); |
| 3994 } | 3994 } |
| 3995 | 3995 |
| 3996 protected: | 3996 protected: |
| 3997 gfx::Size layer_size_; | 3997 gfx::Size layer_size_; |
| 3998 gfx::Size clip_size_; | 3998 gfx::Size clip_size_; |
| 3999 gfx::Size viewport_size_; | 3999 gfx::Size viewport_size_; |
| 4000 float top_controls_height_; | 4000 float top_controls_height_; |
| 4001 | 4001 |
| 4002 LayerTreeSettings settings_; | 4002 LayerTreeSettings settings_; |
| 4003 }; // class LayerTreeHostImplTopControlsTest | 4003 }; // class LayerTreeHostImplBrowserControlsTest |
| 4004 | 4004 |
| 4005 // Tests that, on a page with content the same size as the viewport, hiding | 4005 // Tests that, on a page with content the same size as the viewport, hiding |
| 4006 // the top controls also increases the ScrollableSize (i.e. the content size). | 4006 // the browser controls also increases the ScrollableSize (i.e. the content |
| 4007 // Since the viewport got larger, the effective scrollable "content" also did. | 4007 // size). Since the viewport got larger, the effective scrollable "content" also |
| 4008 // This ensures, for one thing, that the overscroll glow is shown in the right | 4008 // did. This ensures, for one thing, that the overscroll glow is shown in the |
| 4009 // place. | 4009 // right place. |
| 4010 TEST_F(LayerTreeHostImplTopControlsTest, | 4010 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4011 HidingTopControlsExpandsScrollableSize) { | 4011 HidingBrowserControlsExpandsScrollableSize) { |
| 4012 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4012 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4013 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); | 4013 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); |
| 4014 | 4014 |
| 4015 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 4015 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 4016 | 4016 |
| 4017 // Create a content layer beneath the outer viewport scroll layer. | 4017 // Create a content layer beneath the outer viewport scroll layer. |
| 4018 int id = host_impl_->OuterViewportScrollLayer()->id(); | 4018 int id = host_impl_->OuterViewportScrollLayer()->id(); |
| 4019 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild( | 4019 host_impl_->OuterViewportScrollLayer()->test_properties()->AddChild( |
| 4020 LayerImpl::Create(host_impl_->active_tree(), id + 2)); | 4020 LayerImpl::Create(host_impl_->active_tree(), id + 2)); |
| 4021 LayerImpl* content = | 4021 LayerImpl* content = |
| 4022 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; | 4022 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; |
| 4023 content->SetBounds(gfx::Size(50, 50)); | 4023 content->SetBounds(gfx::Size(50, 50)); |
| 4024 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4024 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4025 | 4025 |
| 4026 DrawFrame(); | 4026 DrawFrame(); |
| 4027 | 4027 |
| 4028 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 4028 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
| 4029 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 4029 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
| 4030 | 4030 |
| 4031 // The top controls should start off showing so the viewport should be shrunk. | 4031 // The browser controls should start off showing so the viewport should be |
| 4032 // shrunk. |
| 4032 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); | 4033 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); |
| 4033 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); | 4034 ASSERT_EQ(gfx::Size(50, 50), outer_container->bounds()); |
| 4034 | 4035 |
| 4035 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); | 4036 EXPECT_EQ(gfx::SizeF(50, 50), active_tree->ScrollableSize()); |
| 4036 | 4037 |
| 4037 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4038 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4038 host_impl_ | 4039 host_impl_ |
| 4039 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4040 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4040 InputHandler::TOUCHSCREEN) | 4041 InputHandler::TOUCHSCREEN) |
| 4041 .thread); | 4042 .thread); |
| 4042 | 4043 |
| 4043 host_impl_->top_controls_manager()->ScrollBegin(); | 4044 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4044 | 4045 |
| 4045 // Hide the top controls by a bit, the scrollable size should increase but the | 4046 // Hide the browser controls by a bit, the scrollable size should increase but |
| 4046 // actual content bounds shouldn't. | 4047 // the actual content bounds shouldn't. |
| 4047 { | 4048 { |
| 4048 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); | 4049 host_impl_->browser_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); |
| 4049 ASSERT_EQ(gfx::Size(50, 75), inner_container->bounds()); | 4050 ASSERT_EQ(gfx::Size(50, 75), inner_container->bounds()); |
| 4050 ASSERT_EQ(gfx::Size(50, 75), outer_container->bounds()); | 4051 ASSERT_EQ(gfx::Size(50, 75), outer_container->bounds()); |
| 4051 EXPECT_EQ(gfx::SizeF(50, 75), active_tree->ScrollableSize()); | 4052 EXPECT_EQ(gfx::SizeF(50, 75), active_tree->ScrollableSize()); |
| 4052 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); | 4053 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); |
| 4053 } | 4054 } |
| 4054 | 4055 |
| 4055 // Fully hide the top controls. | 4056 // Fully hide the browser controls. |
| 4056 { | 4057 { |
| 4057 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); | 4058 host_impl_->browser_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); |
| 4058 ASSERT_EQ(gfx::Size(50, 100), inner_container->bounds()); | 4059 ASSERT_EQ(gfx::Size(50, 100), inner_container->bounds()); |
| 4059 ASSERT_EQ(gfx::Size(50, 100), outer_container->bounds()); | 4060 ASSERT_EQ(gfx::Size(50, 100), outer_container->bounds()); |
| 4060 EXPECT_EQ(gfx::SizeF(50, 100), active_tree->ScrollableSize()); | 4061 EXPECT_EQ(gfx::SizeF(50, 100), active_tree->ScrollableSize()); |
| 4061 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); | 4062 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); |
| 4062 } | 4063 } |
| 4063 | 4064 |
| 4064 // Scrolling additionally shouldn't have any effect. | 4065 // Scrolling additionally shouldn't have any effect. |
| 4065 { | 4066 { |
| 4066 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); | 4067 host_impl_->browser_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 25.f)); |
| 4067 ASSERT_EQ(gfx::Size(50, 100), inner_container->bounds()); | 4068 ASSERT_EQ(gfx::Size(50, 100), inner_container->bounds()); |
| 4068 ASSERT_EQ(gfx::Size(50, 100), outer_container->bounds()); | 4069 ASSERT_EQ(gfx::Size(50, 100), outer_container->bounds()); |
| 4069 EXPECT_EQ(gfx::SizeF(50, 100), active_tree->ScrollableSize()); | 4070 EXPECT_EQ(gfx::SizeF(50, 100), active_tree->ScrollableSize()); |
| 4070 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); | 4071 EXPECT_EQ(gfx::SizeF(50, 50), content->BoundsForScrolling()); |
| 4071 } | 4072 } |
| 4072 | 4073 |
| 4073 host_impl_->top_controls_manager()->ScrollEnd(); | 4074 host_impl_->browser_controls_manager()->ScrollEnd(); |
| 4074 host_impl_->ScrollEnd(EndState().get()); | 4075 host_impl_->ScrollEnd(EndState().get()); |
| 4075 } | 4076 } |
| 4076 | 4077 |
| 4077 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { | 4078 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4078 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4079 ScrollBrowserControlsByFractionalAmount) { |
| 4080 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4079 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); | 4081 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); |
| 4080 DrawFrame(); | 4082 DrawFrame(); |
| 4081 | 4083 |
| 4082 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4084 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4083 host_impl_ | 4085 host_impl_ |
| 4084 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4086 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4085 InputHandler::TOUCHSCREEN) | 4087 InputHandler::TOUCHSCREEN) |
| 4086 .thread); | 4088 .thread); |
| 4087 | 4089 |
| 4088 // Make the test scroll delta a fractional amount, to verify that the | 4090 // Make the test scroll delta a fractional amount, to verify that the |
| 4089 // fixed container size delta is (1) non-zero, and (2) fractional, and | 4091 // fixed container size delta is (1) non-zero, and (2) fractional, and |
| 4090 // (3) matches the movement of the top controls. | 4092 // (3) matches the movement of the browser controls. |
| 4091 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); | 4093 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); |
| 4092 host_impl_->top_controls_manager()->ScrollBegin(); | 4094 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4093 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4095 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 4094 host_impl_->top_controls_manager()->ScrollEnd(); | 4096 host_impl_->browser_controls_manager()->ScrollEnd(); |
| 4095 | 4097 |
| 4096 LayerImpl* inner_viewport_scroll_layer = | 4098 LayerImpl* inner_viewport_scroll_layer = |
| 4097 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4099 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4098 DCHECK(inner_viewport_scroll_layer); | 4100 DCHECK(inner_viewport_scroll_layer); |
| 4099 host_impl_->ScrollEnd(EndState().get()); | 4101 host_impl_->ScrollEnd(EndState().get()); |
| 4100 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), | 4102 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), |
| 4101 inner_viewport_scroll_layer->FixedContainerSizeDelta().y()); | 4103 inner_viewport_scroll_layer->FixedContainerSizeDelta().y()); |
| 4102 } | 4104 } |
| 4103 | 4105 |
| 4104 // In this test, the outer viewport is initially unscrollable. We test that a | 4106 // In this test, the outer viewport is initially unscrollable. We test that a |
| 4105 // scroll initiated on the inner viewport, causing the top controls to show and | 4107 // scroll initiated on the inner viewport, causing the browser controls to show |
| 4106 // thus making the outer viewport scrollable, still scrolls the outer viewport. | 4108 // and thus making the outer viewport scrollable, still scrolls the outer |
| 4107 TEST_F(LayerTreeHostImplTopControlsTest, | 4109 // viewport. |
| 4108 TopControlsOuterViewportBecomesScrollable) { | 4110 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4109 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4111 BrowserControlsOuterViewportBecomesScrollable) { |
| 4112 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4110 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); | 4113 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); |
| 4111 DrawFrame(); | 4114 DrawFrame(); |
| 4112 | 4115 |
| 4113 LayerImpl* inner_scroll = | 4116 LayerImpl* inner_scroll = |
| 4114 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4117 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4115 inner_scroll->SetDrawsContent(true); | 4118 inner_scroll->SetDrawsContent(true); |
| 4116 LayerImpl* inner_container = | 4119 LayerImpl* inner_container = |
| 4117 host_impl_->active_tree()->InnerViewportContainerLayer(); | 4120 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 4118 LayerImpl* outer_scroll = | 4121 LayerImpl* outer_scroll = |
| 4119 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4122 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4120 outer_scroll->SetDrawsContent(true); | 4123 outer_scroll->SetDrawsContent(true); |
| 4121 LayerImpl* outer_container = | 4124 LayerImpl* outer_container = |
| 4122 host_impl_->active_tree()->OuterViewportContainerLayer(); | 4125 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 4123 | 4126 |
| 4124 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. | 4127 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
| 4125 outer_scroll->SetDrawsContent(true); | 4128 outer_scroll->SetDrawsContent(true); |
| 4126 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 4129 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 4127 | 4130 |
| 4128 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4131 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4129 host_impl_ | 4132 host_impl_ |
| 4130 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4133 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4131 InputHandler::TOUCHSCREEN) | 4134 InputHandler::TOUCHSCREEN) |
| 4132 .thread); | 4135 .thread); |
| 4133 host_impl_->ScrollBy( | 4136 host_impl_->ScrollBy( |
| 4134 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 50.f)).get()); | 4137 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 50.f)).get()); |
| 4135 | 4138 |
| 4136 // The entire scroll delta should have been used to hide the top controls. | 4139 // The entire scroll delta should have been used to hide the browser controls. |
| 4137 // The viewport layers should be resized back to their full sizes. | 4140 // The viewport layers should be resized back to their full sizes. |
| 4138 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4141 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4139 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 4142 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 4140 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 4143 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
| 4141 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 4144 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
| 4142 | 4145 |
| 4143 // The inner viewport should be scrollable by 50px * page_scale. | 4146 // The inner viewport should be scrollable by 50px * page_scale. |
| 4144 host_impl_->ScrollBy( | 4147 host_impl_->ScrollBy( |
| 4145 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 100.f)).get()); | 4148 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, 100.f)).get()); |
| 4146 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); | 4149 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
| 4147 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 4150 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 4148 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 4151 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
| 4149 | 4152 |
| 4150 host_impl_->ScrollEnd(EndState().get()); | 4153 host_impl_->ScrollEnd(EndState().get()); |
| 4151 | 4154 |
| 4152 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4155 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4153 host_impl_ | 4156 host_impl_ |
| 4154 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4157 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4155 InputHandler::TOUCHSCREEN) | 4158 InputHandler::TOUCHSCREEN) |
| 4156 .thread); | 4159 .thread); |
| 4157 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), outer_scroll); | 4160 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), outer_scroll); |
| 4158 | 4161 |
| 4159 host_impl_->ScrollBy( | 4162 host_impl_->ScrollBy( |
| 4160 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); | 4163 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); |
| 4161 | 4164 |
| 4162 // The entire scroll delta should have been used to show the top controls. | 4165 // The entire scroll delta should have been used to show the browser controls. |
| 4163 // The outer viewport should be resized to accomodate and scrolled to the | 4166 // The outer viewport should be resized to accomodate and scrolled to the |
| 4164 // bottom of the document to keep the viewport in place. | 4167 // bottom of the document to keep the viewport in place. |
| 4165 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4168 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4166 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 4169 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
| 4167 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 4170 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
| 4168 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); | 4171 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
| 4169 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); | 4172 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
| 4170 | 4173 |
| 4171 // Now when we continue scrolling, make sure the outer viewport gets scrolled | 4174 // Now when we continue scrolling, make sure the outer viewport gets scrolled |
| 4172 // since it wasn't scrollable when the scroll began. | 4175 // since it wasn't scrollable when the scroll began. |
| 4173 host_impl_->ScrollBy( | 4176 host_impl_->ScrollBy( |
| 4174 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -20.f)).get()); | 4177 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -20.f)).get()); |
| 4175 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); | 4178 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
| 4176 EXPECT_EQ(15.f, inner_scroll->CurrentScrollOffset().y()); | 4179 EXPECT_EQ(15.f, inner_scroll->CurrentScrollOffset().y()); |
| 4177 | 4180 |
| 4178 host_impl_->ScrollBy( | 4181 host_impl_->ScrollBy( |
| 4179 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -30.f)).get()); | 4182 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -30.f)).get()); |
| 4180 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); | 4183 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
| 4181 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 4184 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 4182 | 4185 |
| 4183 host_impl_->ScrollBy( | 4186 host_impl_->ScrollBy( |
| 4184 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); | 4187 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); |
| 4185 host_impl_->ScrollEnd(EndState().get()); | 4188 host_impl_->ScrollEnd(EndState().get()); |
| 4186 | 4189 |
| 4187 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 4190 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 4188 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 4191 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 4189 } | 4192 } |
| 4190 | 4193 |
| 4191 // Test that the fixed position container delta is appropriately adjusted | 4194 // Test that the fixed position container delta is appropriately adjusted |
| 4192 // by the top controls showing/hiding and page scale doesn't affect it. | 4195 // by the browser controls showing/hiding and page scale doesn't affect it. |
| 4193 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { | 4196 TEST_F(LayerTreeHostImplBrowserControlsTest, FixedContainerDelta) { |
| 4194 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4197 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4195 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); | 4198 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 4196 DrawFrame(); | 4199 DrawFrame(); |
| 4197 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 4200 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 4198 | 4201 |
| 4199 float page_scale = 1.5f; | 4202 float page_scale = 1.5f; |
| 4200 LayerImpl* outer_viewport_scroll_layer = | 4203 LayerImpl* outer_viewport_scroll_layer = |
| 4201 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4204 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4202 | 4205 |
| 4203 // Zoom in, since the fixed container is the outer viewport, the delta should | 4206 // Zoom in, since the fixed container is the outer viewport, the delta should |
| 4204 // not be scaled. | 4207 // not be scaled. |
| 4205 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 4208 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
| 4206 | 4209 |
| 4207 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4210 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4208 host_impl_ | 4211 host_impl_ |
| 4209 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4212 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4210 InputHandler::TOUCHSCREEN) | 4213 InputHandler::TOUCHSCREEN) |
| 4211 .thread); | 4214 .thread); |
| 4212 | 4215 |
| 4213 // Scroll down, the top controls hiding should expand the viewport size so | 4216 // Scroll down, the browser controls hiding should expand the viewport size so |
| 4214 // the delta should be equal to the scroll distance. | 4217 // the delta should be equal to the scroll distance. |
| 4215 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); | 4218 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); |
| 4216 host_impl_->top_controls_manager()->ScrollBegin(); | 4219 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4217 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4220 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 4218 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), | 4221 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), |
| 4219 host_impl_->top_controls_manager()->ContentTopOffset()); | 4222 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4220 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), | 4223 EXPECT_FLOAT_EQ(top_controls_scroll_delta.y(), |
| 4221 outer_viewport_scroll_layer->FixedContainerSizeDelta().y()); | 4224 outer_viewport_scroll_layer->FixedContainerSizeDelta().y()); |
| 4222 host_impl_->ScrollEnd(EndState().get()); | 4225 host_impl_->ScrollEnd(EndState().get()); |
| 4223 | 4226 |
| 4224 // Scroll past the maximum extent. The delta shouldn't be greater than the | 4227 // Scroll past the maximum extent. The delta shouldn't be greater than the |
| 4225 // top controls height. | 4228 // browser controls height. |
| 4226 host_impl_->top_controls_manager()->ScrollBegin(); | 4229 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4227 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4230 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 4228 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4231 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 4229 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 4232 host_impl_->browser_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 4230 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4233 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4231 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_), | 4234 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, top_controls_height_), |
| 4232 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 4235 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 4233 host_impl_->ScrollEnd(EndState().get()); | 4236 host_impl_->ScrollEnd(EndState().get()); |
| 4234 | 4237 |
| 4235 // Scroll in the direction to make the top controls show. | 4238 // Scroll in the direction to make the browser controls show. |
| 4236 host_impl_->top_controls_manager()->ScrollBegin(); | 4239 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4237 host_impl_->top_controls_manager()->ScrollBy(-top_controls_scroll_delta); | 4240 host_impl_->browser_controls_manager()->ScrollBy(-top_controls_scroll_delta); |
| 4238 EXPECT_EQ(top_controls_scroll_delta.y(), | 4241 EXPECT_EQ(top_controls_scroll_delta.y(), |
| 4239 host_impl_->top_controls_manager()->ContentTopOffset()); | 4242 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4240 EXPECT_VECTOR_EQ( | 4243 EXPECT_VECTOR_EQ( |
| 4241 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), | 4244 gfx::Vector2dF(0, top_controls_height_ - top_controls_scroll_delta.y()), |
| 4242 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 4245 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| 4243 host_impl_->top_controls_manager()->ScrollEnd(); | 4246 host_impl_->browser_controls_manager()->ScrollEnd(); |
| 4244 } | 4247 } |
| 4245 | 4248 |
| 4246 // Push a top controls ratio from the main thread that we didn't send as a delta | 4249 // Push a browser controls ratio from the main thread that we didn't send as a |
| 4247 // and make sure that the ratio is clamped to the [0, 1] range. | 4250 // delta and make sure that the ratio is clamped to the [0, 1] range. |
| 4248 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsPushUnsentRatio) { | 4251 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsPushUnsentRatio) { |
| 4249 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4252 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4250 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); | 4253 gfx::Size(10, 50), gfx::Size(10, 50), gfx::Size(10, 100)); |
| 4251 DrawFrame(); | 4254 DrawFrame(); |
| 4252 | 4255 |
| 4253 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. | 4256 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
| 4254 LayerImpl* inner_scroll = | 4257 LayerImpl* inner_scroll = |
| 4255 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4258 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4256 inner_scroll->SetDrawsContent(true); | 4259 inner_scroll->SetDrawsContent(true); |
| 4257 LayerImpl* outer_scroll = | 4260 LayerImpl* outer_scroll = |
| 4258 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4261 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4259 outer_scroll->SetDrawsContent(true); | 4262 outer_scroll->SetDrawsContent(true); |
| 4260 | 4263 |
| 4261 host_impl_->active_tree()->PushTopControlsFromMainThread(1); | 4264 host_impl_->active_tree()->PushBrowserControlsFromMainThread(1); |
| 4262 ASSERT_EQ(1.0f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4265 ASSERT_EQ(1.0f, |
| 4266 host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4263 | 4267 |
| 4264 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.5f); | 4268 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(0.5f); |
| 4265 ASSERT_EQ(0.5f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4269 ASSERT_EQ(0.5f, |
| 4270 host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4266 | 4271 |
| 4267 host_impl_->active_tree()->PushTopControlsFromMainThread(0); | 4272 host_impl_->active_tree()->PushBrowserControlsFromMainThread(0); |
| 4268 | 4273 |
| 4269 ASSERT_EQ(0, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4274 ASSERT_EQ(0, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4270 } | 4275 } |
| 4271 | 4276 |
| 4272 // Test that if only the top controls are scrolled, we shouldn't request a | 4277 // Test that if only the browser controls are scrolled, we shouldn't request a |
| 4273 // commit. | 4278 // commit. |
| 4274 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsDontTriggerCommit) { | 4279 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsDontTriggerCommit) { |
| 4275 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4280 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4276 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); | 4281 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 4277 DrawFrame(); | 4282 DrawFrame(); |
| 4278 | 4283 |
| 4279 // Show top controls | 4284 // Show browser controls |
| 4280 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4285 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4281 | 4286 |
| 4282 // Scroll 25px to hide top controls | 4287 // Scroll 25px to hide browser controls |
| 4283 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4288 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4284 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4289 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4285 host_impl_ | 4290 host_impl_ |
| 4286 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4291 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4287 InputHandler::TOUCHSCREEN) | 4292 InputHandler::TOUCHSCREEN) |
| 4288 .thread); | 4293 .thread); |
| 4289 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4294 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4290 EXPECT_FALSE(did_request_commit_); | 4295 EXPECT_FALSE(did_request_commit_); |
| 4291 } | 4296 } |
| 4292 | 4297 |
| 4293 // Test that if a scrollable sublayer doesn't consume the scroll, | 4298 // Test that if a scrollable sublayer doesn't consume the scroll, |
| 4294 // top controls should hide when scrolling down. | 4299 // browser controls should hide when scrolling down. |
| 4295 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollableSublayer) { | 4300 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4301 BrowserControlsScrollableSublayer) { |
| 4296 gfx::Size sub_content_size(100, 400); | 4302 gfx::Size sub_content_size(100, 400); |
| 4297 gfx::Size sub_content_layer_size(100, 300); | 4303 gfx::Size sub_content_layer_size(100, 300); |
| 4298 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4304 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4299 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); | 4305 gfx::Size(100, 50), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 4300 DrawFrame(); | 4306 DrawFrame(); |
| 4301 | 4307 |
| 4302 // Show top controls | 4308 // Show browser controls |
| 4303 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4309 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4304 | 4310 |
| 4305 LayerImpl* outer_viewport_scroll_layer = | 4311 LayerImpl* outer_viewport_scroll_layer = |
| 4306 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4312 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4307 int id = outer_viewport_scroll_layer->id(); | 4313 int id = outer_viewport_scroll_layer->id(); |
| 4308 | 4314 |
| 4309 std::unique_ptr<LayerImpl> child = | 4315 std::unique_ptr<LayerImpl> child = |
| 4310 LayerImpl::Create(host_impl_->active_tree(), id + 2); | 4316 LayerImpl::Create(host_impl_->active_tree(), id + 2); |
| 4311 std::unique_ptr<LayerImpl> child_clip = | 4317 std::unique_ptr<LayerImpl> child_clip = |
| 4312 LayerImpl::Create(host_impl_->active_tree(), id + 3); | 4318 LayerImpl::Create(host_impl_->active_tree(), id + 3); |
| 4313 | 4319 |
| 4314 child_clip->SetBounds(sub_content_layer_size); | 4320 child_clip->SetBounds(sub_content_layer_size); |
| 4315 child->SetScrollClipLayer(child_clip->id()); | 4321 child->SetScrollClipLayer(child_clip->id()); |
| 4316 child->SetBounds(sub_content_size); | 4322 child->SetBounds(sub_content_size); |
| 4317 child->SetPosition(gfx::PointF()); | 4323 child->SetPosition(gfx::PointF()); |
| 4318 child->SetDrawsContent(true); | 4324 child->SetDrawsContent(true); |
| 4319 child->test_properties()->is_container_for_fixed_position_layers = true; | 4325 child->test_properties()->is_container_for_fixed_position_layers = true; |
| 4320 | 4326 |
| 4321 // scroll child to limit | 4327 // scroll child to limit |
| 4322 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); | 4328 SetScrollOffsetDelta(child.get(), gfx::Vector2dF(0, 100.f)); |
| 4323 child_clip->test_properties()->AddChild(std::move(child)); | 4329 child_clip->test_properties()->AddChild(std::move(child)); |
| 4324 outer_viewport_scroll_layer->test_properties()->AddChild( | 4330 outer_viewport_scroll_layer->test_properties()->AddChild( |
| 4325 std::move(child_clip)); | 4331 std::move(child_clip)); |
| 4326 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4332 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4327 | 4333 |
| 4328 // Scroll 25px to hide top controls | 4334 // Scroll 25px to hide browser controls |
| 4329 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4335 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4330 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4336 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4331 host_impl_ | 4337 host_impl_ |
| 4332 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4338 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4333 InputHandler::TOUCHSCREEN) | 4339 InputHandler::TOUCHSCREEN) |
| 4334 .thread); | 4340 .thread); |
| 4335 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4341 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4336 host_impl_->ScrollEnd(EndState().get()); | 4342 host_impl_->ScrollEnd(EndState().get()); |
| 4337 | 4343 |
| 4338 // Top controls should be hidden | 4344 // Browser controls should be hidden |
| 4339 EXPECT_EQ(scroll_delta.y(), | 4345 EXPECT_EQ(scroll_delta.y(), |
| 4340 top_controls_height_ - | 4346 top_controls_height_ - |
| 4341 host_impl_->top_controls_manager()->ContentTopOffset()); | 4347 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4342 } | 4348 } |
| 4343 | 4349 |
| 4344 // Ensure setting the top controls position explicitly using the setters on the | 4350 // Ensure setting the browser controls position explicitly using the setters on |
| 4345 // TreeImpl correctly affects the top controls manager and viewport bounds. | 4351 // the TreeImpl correctly affects the browser controls manager and viewport |
| 4346 TEST_F(LayerTreeHostImplTopControlsTest, PositionTopControlsExplicitly) { | 4352 // bounds. |
| 4353 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4354 PositionBrowserControlsExplicitly) { |
| 4347 settings_ = DefaultSettings(); | 4355 settings_ = DefaultSettings(); |
| 4348 CreateHostImpl(settings_, CreateCompositorFrameSink()); | 4356 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4349 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4357 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4350 layer_size_, layer_size_, layer_size_); | 4358 layer_size_, layer_size_, layer_size_); |
| 4351 DrawFrame(); | 4359 DrawFrame(); |
| 4352 | 4360 |
| 4353 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4361 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(0.f); |
| 4354 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4362 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4355 30.f / top_controls_height_); | 4363 30.f / top_controls_height_); |
| 4356 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4364 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4357 EXPECT_FLOAT_EQ(30.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4365 EXPECT_FLOAT_EQ(30.f, |
| 4366 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4358 EXPECT_FLOAT_EQ(-20.f, | 4367 EXPECT_FLOAT_EQ(-20.f, |
| 4359 host_impl_->top_controls_manager()->ControlsTopOffset()); | 4368 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 4360 | 4369 |
| 4361 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4370 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(0.f); |
| 4362 EXPECT_FLOAT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4371 EXPECT_FLOAT_EQ(0.f, |
| 4372 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4363 EXPECT_FLOAT_EQ(-50.f, | 4373 EXPECT_FLOAT_EQ(-50.f, |
| 4364 host_impl_->top_controls_manager()->ControlsTopOffset()); | 4374 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 4365 | 4375 |
| 4366 host_impl_->DidChangeTopControlsPosition(); | 4376 host_impl_->DidChangeBrowserControlsPosition(); |
| 4367 | 4377 |
| 4368 // Now that top controls have moved, expect the clip to resize. | 4378 // Now that browser controls have moved, expect the clip to resize. |
| 4369 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4379 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4370 ->test_properties() | 4380 ->test_properties() |
| 4371 ->parent->test_properties() | 4381 ->parent->test_properties() |
| 4372 ->parent; | 4382 ->parent; |
| 4373 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4383 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4374 } | 4384 } |
| 4375 | 4385 |
| 4376 // Test that the top_controls delta and sent delta are appropriately | 4386 // Test that the top_controls delta and sent delta are appropriately |
| 4377 // applied on sync tree activation. The total top controls offset shouldn't | 4387 // applied on sync tree activation. The total browser controls offset shouldn't |
| 4378 // change after the activation. | 4388 // change after the activation. |
| 4379 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { | 4389 TEST_F(LayerTreeHostImplBrowserControlsTest, ApplyDeltaOnTreeActivation) { |
| 4380 settings_ = DefaultSettings(); | 4390 settings_ = DefaultSettings(); |
| 4381 CreateHostImpl(settings_, CreateCompositorFrameSink()); | 4391 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4382 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4392 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4383 layer_size_, layer_size_, layer_size_); | 4393 layer_size_, layer_size_, layer_size_); |
| 4384 DrawFrame(); | 4394 DrawFrame(); |
| 4385 | 4395 |
| 4386 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4396 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4387 20.f / top_controls_height_); | 4397 20.f / top_controls_height_); |
| 4388 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4398 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4389 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( | 4399 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio( |
| 4390 15.f / top_controls_height_); | 4400 15.f / top_controls_height_); |
| 4391 host_impl_->active_tree() | 4401 host_impl_->active_tree() |
| 4392 ->top_controls_shown_ratio() | 4402 ->top_controls_shown_ratio() |
| 4393 ->PullDeltaForMainThread(); | 4403 ->PullDeltaForMainThread(); |
| 4394 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4404 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(0.f); |
| 4395 host_impl_->sync_tree()->PushTopControlsFromMainThread(15.f / | 4405 host_impl_->sync_tree()->PushBrowserControlsFromMainThread( |
| 4396 top_controls_height_); | 4406 15.f / top_controls_height_); |
| 4397 | 4407 |
| 4398 host_impl_->DidChangeTopControlsPosition(); | 4408 host_impl_->DidChangeBrowserControlsPosition(); |
| 4399 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4409 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4400 ->test_properties() | 4410 ->test_properties() |
| 4401 ->parent->test_properties() | 4411 ->parent->test_properties() |
| 4402 ->parent; | 4412 ->parent; |
| 4403 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4413 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4404 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4414 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4405 | 4415 |
| 4406 host_impl_->ActivateSyncTree(); | 4416 host_impl_->ActivateSyncTree(); |
| 4407 | 4417 |
| 4408 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4418 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4409 ->test_properties() | 4419 ->test_properties() |
| 4410 ->parent->test_properties() | 4420 ->parent->test_properties() |
| 4411 ->parent; | 4421 ->parent; |
| 4412 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4422 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4413 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4423 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4414 | 4424 |
| 4415 EXPECT_FLOAT_EQ( | 4425 EXPECT_FLOAT_EQ( |
| 4416 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * | 4426 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * |
| 4417 top_controls_height_); | 4427 top_controls_height_); |
| 4418 EXPECT_FLOAT_EQ( | 4428 EXPECT_FLOAT_EQ( |
| 4419 15.f, | 4429 15.f, |
| 4420 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * | 4430 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * |
| 4421 top_controls_height_); | 4431 top_controls_height_); |
| 4422 } | 4432 } |
| 4423 | 4433 |
| 4424 // Test that changing the top controls layout height is correctly applied to | 4434 // Test that changing the browser controls layout height is correctly applied to |
| 4425 // the inner viewport container bounds. That is, the top controls layout | 4435 // the inner viewport container bounds. That is, the browser controls layout |
| 4426 // height is the amount that the inner viewport container was shrunk outside | 4436 // height is the amount that the inner viewport container was shrunk outside |
| 4427 // the compositor to accommodate the top controls. | 4437 // the compositor to accommodate the browser controls. |
| 4428 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsLayoutHeightChanged) { | 4438 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4439 BrowserControlsLayoutHeightChanged) { |
| 4429 settings_ = DefaultSettings(); | 4440 settings_ = DefaultSettings(); |
| 4430 CreateHostImpl(settings_, CreateCompositorFrameSink()); | 4441 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4431 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4442 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4432 layer_size_, layer_size_, layer_size_); | 4443 layer_size_, layer_size_, layer_size_); |
| 4433 DrawFrame(); | 4444 DrawFrame(); |
| 4434 | 4445 |
| 4435 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); | 4446 host_impl_->sync_tree()->PushBrowserControlsFromMainThread(1.f); |
| 4436 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 4447 host_impl_->sync_tree()->set_browser_controls_shrink_blink_size(true); |
| 4437 | 4448 |
| 4438 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4449 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4439 1.f); | 4450 1.f); |
| 4440 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4451 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4441 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4452 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(0.f); |
| 4442 | 4453 |
| 4443 host_impl_->DidChangeTopControlsPosition(); | 4454 host_impl_->DidChangeBrowserControlsPosition(); |
| 4444 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4455 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4445 ->test_properties() | 4456 ->test_properties() |
| 4446 ->parent->test_properties() | 4457 ->parent->test_properties() |
| 4447 ->parent; | 4458 ->parent; |
| 4448 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4459 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4449 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4460 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4450 | 4461 |
| 4451 host_impl_->sync_tree()->root_layer_for_testing()->SetBounds( | 4462 host_impl_->sync_tree()->root_layer_for_testing()->SetBounds( |
| 4452 gfx::Size(inner_clip_ptr->bounds().width(), | 4463 gfx::Size(inner_clip_ptr->bounds().width(), |
| 4453 inner_clip_ptr->bounds().height() - 50.f)); | 4464 inner_clip_ptr->bounds().height() - 50.f)); |
| 4454 | 4465 |
| 4455 host_impl_->ActivateSyncTree(); | 4466 host_impl_->ActivateSyncTree(); |
| 4456 | 4467 |
| 4457 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4468 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4458 ->test_properties() | 4469 ->test_properties() |
| 4459 ->parent->test_properties() | 4470 ->parent->test_properties() |
| 4460 ->parent; | 4471 ->parent; |
| 4461 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4472 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4462 | 4473 |
| 4463 // The total bounds should remain unchanged since the bounds delta should | 4474 // The total bounds should remain unchanged since the bounds delta should |
| 4464 // account for the difference between the layout height and the current | 4475 // account for the difference between the layout height and the current |
| 4465 // top controls offset. | 4476 // browser controls offset. |
| 4466 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4477 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4467 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); | 4478 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); |
| 4468 | 4479 |
| 4469 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 4480 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f); |
| 4470 host_impl_->DidChangeTopControlsPosition(); | 4481 host_impl_->DidChangeBrowserControlsPosition(); |
| 4471 | 4482 |
| 4472 EXPECT_EQ(1.f, host_impl_->top_controls_manager()->TopControlsShownRatio()); | 4483 EXPECT_EQ(1.f, |
| 4473 EXPECT_EQ(50.f, host_impl_->top_controls_manager()->TopControlsHeight()); | 4484 host_impl_->browser_controls_manager()->TopControlsShownRatio()); |
| 4474 EXPECT_EQ(50.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4485 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->TopControlsHeight()); |
| 4486 EXPECT_EQ(50.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4475 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), inner_clip_ptr->bounds_delta()); | 4487 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 0.f), inner_clip_ptr->bounds_delta()); |
| 4476 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), | 4488 EXPECT_EQ(gfx::Size(viewport_size_.width(), viewport_size_.height() - 50.f), |
| 4477 inner_clip_ptr->bounds()); | 4489 inner_clip_ptr->bounds()); |
| 4478 } | 4490 } |
| 4479 | 4491 |
| 4480 // Test that showing/hiding the top controls when the viewport is fully scrolled | 4492 // Test that showing/hiding the browser controls when the viewport is fully |
| 4481 // doesn't incorrectly change the viewport offset due to clamping from changing | 4493 // scrolled doesn't incorrectly change the viewport offset due to clamping from |
| 4482 // viewport bounds. | 4494 // changing viewport bounds. |
| 4483 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsViewportOffsetClamping) { | 4495 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4484 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4496 BrowserControlsViewportOffsetClamping) { |
| 4497 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4485 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 4498 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 4486 DrawFrame(); | 4499 DrawFrame(); |
| 4487 | 4500 |
| 4488 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4501 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4489 | 4502 |
| 4490 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 4503 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 4491 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 4504 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 4492 | 4505 |
| 4493 // Scroll the viewports to max scroll offset. | 4506 // Scroll the viewports to max scroll offset. |
| 4494 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); | 4507 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); |
| 4495 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); | 4508 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); |
| 4496 | 4509 |
| 4497 gfx::ScrollOffset viewport_offset = | 4510 gfx::ScrollOffset viewport_offset = |
| 4498 host_impl_->active_tree()->TotalScrollOffset(); | 4511 host_impl_->active_tree()->TotalScrollOffset(); |
| 4499 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 4512 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
| 4500 | 4513 |
| 4501 // Hide the top controls by 25px. | 4514 // Hide the browser controls by 25px. |
| 4502 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4515 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4503 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4516 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4504 host_impl_ | 4517 host_impl_ |
| 4505 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4518 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4506 InputHandler::TOUCHSCREEN) | 4519 InputHandler::TOUCHSCREEN) |
| 4507 .thread); | 4520 .thread); |
| 4508 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4521 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4509 | 4522 |
| 4510 // scrolling down at the max extents no longer hides the top controls | 4523 // scrolling down at the max extents no longer hides the browser controls |
| 4511 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 4524 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4512 | 4525 |
| 4513 // forcefully hide the top controls by 25px | 4526 // forcefully hide the browser controls by 25px |
| 4514 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); | 4527 host_impl_->browser_controls_manager()->ScrollBy(scroll_delta); |
| 4515 host_impl_->ScrollEnd(EndState().get()); | 4528 host_impl_->ScrollEnd(EndState().get()); |
| 4516 | 4529 |
| 4517 EXPECT_FLOAT_EQ(scroll_delta.y(), | 4530 EXPECT_FLOAT_EQ( |
| 4518 top_controls_height_ - | 4531 scroll_delta.y(), |
| 4519 host_impl_->top_controls_manager()->ContentTopOffset()); | 4532 top_controls_height_ - |
| 4533 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4520 | 4534 |
| 4521 inner_scroll->ClampScrollToMaxScrollOffset(); | 4535 inner_scroll->ClampScrollToMaxScrollOffset(); |
| 4522 outer_scroll->ClampScrollToMaxScrollOffset(); | 4536 outer_scroll->ClampScrollToMaxScrollOffset(); |
| 4523 | 4537 |
| 4524 // We should still be fully scrolled. | 4538 // We should still be fully scrolled. |
| 4525 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 4539 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 4526 host_impl_->active_tree()->TotalScrollOffset()); | 4540 host_impl_->active_tree()->TotalScrollOffset()); |
| 4527 | 4541 |
| 4528 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 4542 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
| 4529 | 4543 |
| 4530 // Bring the top controls down by 25px. | 4544 // Bring the browser controls down by 25px. |
| 4531 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 4545 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
| 4532 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4546 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4533 host_impl_ | 4547 host_impl_ |
| 4534 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4548 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4535 InputHandler::TOUCHSCREEN) | 4549 InputHandler::TOUCHSCREEN) |
| 4536 .thread); | 4550 .thread); |
| 4537 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4551 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4538 host_impl_->ScrollEnd(EndState().get()); | 4552 host_impl_->ScrollEnd(EndState().get()); |
| 4539 | 4553 |
| 4540 // The viewport offset shouldn't have changed. | 4554 // The viewport offset shouldn't have changed. |
| 4541 EXPECT_EQ(viewport_offset, | 4555 EXPECT_EQ(viewport_offset, |
| 4542 host_impl_->active_tree()->TotalScrollOffset()); | 4556 host_impl_->active_tree()->TotalScrollOffset()); |
| 4543 | 4557 |
| 4544 // Scroll the viewports to max scroll offset. | 4558 // Scroll the viewports to max scroll offset. |
| 4545 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); | 4559 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); |
| 4546 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); | 4560 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); |
| 4547 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 4561 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 4548 host_impl_->active_tree()->TotalScrollOffset()); | 4562 host_impl_->active_tree()->TotalScrollOffset()); |
| 4549 } | 4563 } |
| 4550 | 4564 |
| 4551 // Test that the top controls coming in and out maintains the same aspect ratio | 4565 // Test that the browser controls coming in and out maintains the same aspect |
| 4552 // between the inner and outer viewports. | 4566 // ratio between the inner and outer viewports. |
| 4553 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { | 4567 TEST_F(LayerTreeHostImplBrowserControlsTest, BrowserControlsAspectRatio) { |
| 4554 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4568 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4555 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 4569 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 4556 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f); | 4570 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 2.f); |
| 4557 DrawFrame(); | 4571 DrawFrame(); |
| 4558 | 4572 |
| 4559 EXPECT_FLOAT_EQ(top_controls_height_, | 4573 EXPECT_FLOAT_EQ(top_controls_height_, |
| 4560 host_impl_->top_controls_manager()->ContentTopOffset()); | 4574 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4561 | 4575 |
| 4562 gfx::Vector2dF scroll_delta(0.f, 25.f); | 4576 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 4563 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4577 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4564 host_impl_ | 4578 host_impl_ |
| 4565 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4579 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4566 InputHandler::TOUCHSCREEN) | 4580 InputHandler::TOUCHSCREEN) |
| 4567 .thread); | 4581 .thread); |
| 4568 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4582 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4569 host_impl_->ScrollEnd(EndState().get()); | 4583 host_impl_->ScrollEnd(EndState().get()); |
| 4570 | 4584 |
| 4571 EXPECT_FLOAT_EQ(scroll_delta.y(), | 4585 EXPECT_FLOAT_EQ( |
| 4572 top_controls_height_ - | 4586 scroll_delta.y(), |
| 4573 host_impl_->top_controls_manager()->ContentTopOffset()); | 4587 top_controls_height_ - |
| 4588 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4574 | 4589 |
| 4575 // Top controls were hidden by 25px so the inner viewport should have expanded | 4590 // Browser controls were hidden by 25px so the inner viewport should have |
| 4576 // by that much. | 4591 // expanded by that much. |
| 4577 LayerImpl* outer_container = | 4592 LayerImpl* outer_container = |
| 4578 host_impl_->active_tree()->OuterViewportContainerLayer(); | 4593 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 4579 LayerImpl* inner_container = | 4594 LayerImpl* inner_container = |
| 4580 host_impl_->active_tree()->InnerViewportContainerLayer(); | 4595 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 4581 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), | 4596 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), |
| 4582 inner_container->BoundsForScrolling()); | 4597 inner_container->BoundsForScrolling()); |
| 4583 | 4598 |
| 4584 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. | 4599 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. |
| 4585 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 4600 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
| 4586 inner_container->BoundsForScrolling().height(); | 4601 inner_container->BoundsForScrolling().height(); |
| 4587 gfx::SizeF expected = | 4602 gfx::SizeF expected = |
| 4588 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); | 4603 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); |
| 4589 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); | 4604 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); |
| 4590 EXPECT_EQ(expected, | 4605 EXPECT_EQ(expected, |
| 4591 host_impl_->InnerViewportScrollLayer()->BoundsForScrolling()); | 4606 host_impl_->InnerViewportScrollLayer()->BoundsForScrolling()); |
| 4592 } | 4607 } |
| 4593 | 4608 |
| 4594 // Test that scrolling the outer viewport affects the top controls. | 4609 // Test that scrolling the outer viewport affects the browser controls. |
| 4595 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsScrollOuterViewport) { | 4610 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4596 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4611 BrowserControlsScrollOuterViewport) { |
| 4612 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4597 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 4613 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 4598 DrawFrame(); | 4614 DrawFrame(); |
| 4599 | 4615 |
| 4600 EXPECT_EQ(top_controls_height_, | 4616 EXPECT_EQ(top_controls_height_, |
| 4601 host_impl_->top_controls_manager()->ContentTopOffset()); | 4617 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4602 | 4618 |
| 4603 // Send a gesture scroll that will scroll the outer viewport, make sure the | 4619 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 4604 // top controls get scrolled. | 4620 // browser controls get scrolled. |
| 4605 gfx::Vector2dF scroll_delta(0.f, 15.f); | 4621 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 4606 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4622 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4607 host_impl_ | 4623 host_impl_ |
| 4608 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4624 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4609 InputHandler::TOUCHSCREEN) | 4625 InputHandler::TOUCHSCREEN) |
| 4610 .thread); | 4626 .thread); |
| 4611 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4627 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4612 | 4628 |
| 4613 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 4629 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 4614 host_impl_->CurrentlyScrollingLayer()); | 4630 host_impl_->CurrentlyScrollingLayer()); |
| 4615 host_impl_->ScrollEnd(EndState().get()); | 4631 host_impl_->ScrollEnd(EndState().get()); |
| 4616 | 4632 |
| 4617 EXPECT_FLOAT_EQ(scroll_delta.y(), | 4633 EXPECT_FLOAT_EQ( |
| 4618 top_controls_height_ - | 4634 scroll_delta.y(), |
| 4619 host_impl_->top_controls_manager()->ContentTopOffset()); | 4635 top_controls_height_ - |
| 4636 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4620 | 4637 |
| 4621 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 4638 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 4622 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4639 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4623 host_impl_ | 4640 host_impl_ |
| 4624 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4641 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4625 InputHandler::TOUCHSCREEN) | 4642 InputHandler::TOUCHSCREEN) |
| 4626 .thread); | 4643 .thread); |
| 4627 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4644 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4628 | 4645 |
| 4629 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 4646 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4630 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 4647 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 4631 host_impl_->CurrentlyScrollingLayer()); | 4648 host_impl_->CurrentlyScrollingLayer()); |
| 4632 | 4649 |
| 4633 host_impl_->ScrollEnd(EndState().get()); | 4650 host_impl_->ScrollEnd(EndState().get()); |
| 4634 | 4651 |
| 4635 // Position the viewports such that the inner viewport will be scrolled. | 4652 // Position the viewports such that the inner viewport will be scrolled. |
| 4636 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 4653 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 4637 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), | 4654 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), |
| 4638 gfx::Vector2dF()); | 4655 gfx::Vector2dF()); |
| 4639 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), | 4656 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), |
| 4640 inner_viewport_offset); | 4657 inner_viewport_offset); |
| 4641 | 4658 |
| 4642 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 4659 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
| 4643 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4660 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4644 host_impl_ | 4661 host_impl_ |
| 4645 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4662 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4646 InputHandler::TOUCHSCREEN) | 4663 InputHandler::TOUCHSCREEN) |
| 4647 .thread); | 4664 .thread); |
| 4648 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4665 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4649 | 4666 |
| 4650 EXPECT_EQ(top_controls_height_, | 4667 EXPECT_EQ(top_controls_height_, |
| 4651 host_impl_->top_controls_manager()->ContentTopOffset()); | 4668 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4652 EXPECT_FLOAT_EQ( | 4669 EXPECT_FLOAT_EQ( |
| 4653 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), | 4670 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
| 4654 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); | 4671 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); |
| 4655 | 4672 |
| 4656 host_impl_->ScrollEnd(EndState().get()); | 4673 host_impl_->ScrollEnd(EndState().get()); |
| 4657 } | 4674 } |
| 4658 | 4675 |
| 4659 TEST_F(LayerTreeHostImplTopControlsTest, | 4676 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4660 ScrollNonScrollableRootWithTopControls) { | 4677 ScrollNonScrollableRootWithBrowserControls) { |
| 4661 settings_ = DefaultSettings(); | 4678 settings_ = DefaultSettings(); |
| 4662 CreateHostImpl(settings_, CreateCompositorFrameSink()); | 4679 CreateHostImpl(settings_, CreateCompositorFrameSink()); |
| 4663 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4680 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4664 layer_size_, layer_size_, layer_size_); | 4681 layer_size_, layer_size_, layer_size_); |
| 4665 DrawFrame(); | 4682 DrawFrame(); |
| 4666 | 4683 |
| 4667 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4684 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4668 host_impl_ | 4685 host_impl_ |
| 4669 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4686 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4670 InputHandler::TOUCHSCREEN) | 4687 InputHandler::TOUCHSCREEN) |
| 4671 .thread); | 4688 .thread); |
| 4672 | 4689 |
| 4673 host_impl_->top_controls_manager()->ScrollBegin(); | 4690 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4674 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 4691 host_impl_->browser_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
| 4675 host_impl_->top_controls_manager()->ScrollEnd(); | 4692 host_impl_->browser_controls_manager()->ScrollEnd(); |
| 4676 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4693 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4677 // Now that top controls have moved, expect the clip to resize. | 4694 // Now that browser controls have moved, expect the clip to resize. |
| 4678 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() | 4695 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4679 ->test_properties() | 4696 ->test_properties() |
| 4680 ->parent->test_properties() | 4697 ->parent->test_properties() |
| 4681 ->parent; | 4698 ->parent; |
| 4682 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4699 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4683 | 4700 |
| 4684 host_impl_->ScrollEnd(EndState().get()); | 4701 host_impl_->ScrollEnd(EndState().get()); |
| 4685 | 4702 |
| 4686 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4703 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4687 host_impl_ | 4704 host_impl_ |
| 4688 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4705 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4689 InputHandler::TOUCHSCREEN) | 4706 InputHandler::TOUCHSCREEN) |
| 4690 .thread); | 4707 .thread); |
| 4691 | 4708 |
| 4692 float scroll_increment_y = -25.f; | 4709 float scroll_increment_y = -25.f; |
| 4693 host_impl_->top_controls_manager()->ScrollBegin(); | 4710 host_impl_->browser_controls_manager()->ScrollBegin(); |
| 4694 host_impl_->top_controls_manager()->ScrollBy( | 4711 host_impl_->browser_controls_manager()->ScrollBy( |
| 4695 gfx::Vector2dF(0.f, scroll_increment_y)); | 4712 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 4696 EXPECT_FLOAT_EQ(-scroll_increment_y, | 4713 EXPECT_FLOAT_EQ(-scroll_increment_y, |
| 4697 host_impl_->top_controls_manager()->ContentTopOffset()); | 4714 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4698 // Now that top controls have moved, expect the clip to resize. | 4715 // Now that browser controls have moved, expect the clip to resize. |
| 4699 EXPECT_EQ(gfx::Size(viewport_size_.width(), | 4716 EXPECT_EQ(gfx::Size(viewport_size_.width(), |
| 4700 viewport_size_.height() + scroll_increment_y), | 4717 viewport_size_.height() + scroll_increment_y), |
| 4701 inner_clip_ptr->bounds()); | 4718 inner_clip_ptr->bounds()); |
| 4702 | 4719 |
| 4703 host_impl_->top_controls_manager()->ScrollBy( | 4720 host_impl_->browser_controls_manager()->ScrollBy( |
| 4704 gfx::Vector2dF(0.f, scroll_increment_y)); | 4721 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 4705 host_impl_->top_controls_manager()->ScrollEnd(); | 4722 host_impl_->browser_controls_manager()->ScrollEnd(); |
| 4706 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, | 4723 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, |
| 4707 host_impl_->top_controls_manager()->ContentTopOffset()); | 4724 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4708 // Now that top controls have moved, expect the clip to resize. | 4725 // Now that browser controls have moved, expect the clip to resize. |
| 4709 EXPECT_EQ(clip_size_, inner_clip_ptr->bounds()); | 4726 EXPECT_EQ(clip_size_, inner_clip_ptr->bounds()); |
| 4710 | 4727 |
| 4711 host_impl_->ScrollEnd(EndState().get()); | 4728 host_impl_->ScrollEnd(EndState().get()); |
| 4712 | 4729 |
| 4713 // Verify the layer is once-again non-scrollable. | 4730 // Verify the layer is once-again non-scrollable. |
| 4714 EXPECT_EQ( | 4731 EXPECT_EQ( |
| 4715 gfx::ScrollOffset(), | 4732 gfx::ScrollOffset(), |
| 4716 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); | 4733 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); |
| 4717 | 4734 |
| 4718 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4735 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4719 host_impl_ | 4736 host_impl_ |
| 4720 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4737 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4721 InputHandler::TOUCHSCREEN) | 4738 InputHandler::TOUCHSCREEN) |
| 4722 .thread); | 4739 .thread); |
| 4723 } | 4740 } |
| 4724 | 4741 |
| 4725 // Tests that activating a pending tree while there's a bounds_delta on the | 4742 // Tests that activating a pending tree while there's a bounds_delta on the |
| 4726 // viewport layers from top controls doesn't cause a scroll jump. This bug was | 4743 // viewport layers from browser controls doesn't cause a scroll jump. This bug |
| 4727 // occurring because the UpdateViewportContainerSizes was being called before | 4744 // was occurring because the UpdateViewportContainerSizes was being called |
| 4728 // the property trees were updated with the bounds_delta. crbug.com/597266. | 4745 // before the property trees were updated with the bounds_delta. |
| 4729 TEST_F(LayerTreeHostImplTopControlsTest, ViewportBoundsDeltaOnTreeActivation) { | 4746 // crbug.com/597266. |
| 4747 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 4748 ViewportBoundsDeltaOnTreeActivation) { |
| 4730 const gfx::Size inner_viewport_size(1000, 1000); | 4749 const gfx::Size inner_viewport_size(1000, 1000); |
| 4731 const gfx::Size outer_viewport_size(1000, 1000); | 4750 const gfx::Size outer_viewport_size(1000, 1000); |
| 4732 const gfx::Size content_size(2000, 2000); | 4751 const gfx::Size content_size(2000, 2000); |
| 4733 | 4752 |
| 4734 // Initialization | 4753 // Initialization |
| 4735 { | 4754 { |
| 4736 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4755 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4737 inner_viewport_size, outer_viewport_size, content_size); | 4756 inner_viewport_size, outer_viewport_size, content_size); |
| 4738 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 4757 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 4739 | 4758 |
| 4740 // Start off with the top controls hidden on both main and impl. | 4759 // Start off with the browser controls hidden on both main and impl. |
| 4741 host_impl_->active_tree()->set_top_controls_shrink_blink_size(false); | 4760 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(false); |
| 4742 host_impl_->active_tree()->PushTopControlsFromMainThread(0); | 4761 host_impl_->active_tree()->PushBrowserControlsFromMainThread(0); |
| 4743 | 4762 |
| 4744 host_impl_->CreatePendingTree(); | 4763 host_impl_->CreatePendingTree(); |
| 4745 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4764 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 4746 host_impl_->pending_tree(), inner_viewport_size, outer_viewport_size, | 4765 host_impl_->pending_tree(), inner_viewport_size, outer_viewport_size, |
| 4747 content_size); | 4766 content_size); |
| 4748 host_impl_->pending_tree()->set_top_controls_shrink_blink_size(false); | 4767 host_impl_->pending_tree()->set_browser_controls_shrink_blink_size(false); |
| 4749 | 4768 |
| 4750 // Fully scroll the viewport. | 4769 // Fully scroll the viewport. |
| 4751 host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), | 4770 host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), |
| 4752 InputHandler::TOUCHSCREEN); | 4771 InputHandler::TOUCHSCREEN); |
| 4753 host_impl_->ScrollBy( | 4772 host_impl_->ScrollBy( |
| 4754 UpdateState(gfx::Point(), gfx::Vector2d(0, 2000)).get()); | 4773 UpdateState(gfx::Point(), gfx::Vector2d(0, 2000)).get()); |
| 4755 host_impl_->ScrollEnd(EndState().get()); | 4774 host_impl_->ScrollEnd(EndState().get()); |
| 4756 } | 4775 } |
| 4757 | 4776 |
| 4758 LayerImpl* outer_scroll = | 4777 LayerImpl* outer_scroll = |
| 4759 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4778 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4760 | 4779 |
| 4761 ASSERT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 4780 ASSERT_FLOAT_EQ(0, |
| 4781 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4762 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); | 4782 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); |
| 4763 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); | 4783 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); |
| 4764 | 4784 |
| 4765 // Kick off an animation to show the top controls. | 4785 // Kick off an animation to show the browser controls. |
| 4766 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, true); | 4786 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 4787 BOTH, SHOWN, true); |
| 4767 base::TimeTicks start_time = base::TimeTicks::Now(); | 4788 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 4768 BeginFrameArgs begin_frame_args = | 4789 BeginFrameArgs begin_frame_args = |
| 4769 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 4790 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 4770 | 4791 |
| 4771 // Pump an animation frame to put some delta in the top controls. | 4792 // Pump an animation frame to put some delta in the browser controls. |
| 4772 { | 4793 { |
| 4773 begin_frame_args.frame_time = | 4794 begin_frame_args.frame_time = |
| 4774 start_time + base::TimeDelta::FromMilliseconds(50); | 4795 start_time + base::TimeDelta::FromMilliseconds(50); |
| 4775 host_impl_->WillBeginImplFrame(begin_frame_args); | 4796 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 4776 host_impl_->Animate(); | 4797 host_impl_->Animate(); |
| 4777 host_impl_->UpdateAnimationState(true); | 4798 host_impl_->UpdateAnimationState(true); |
| 4778 host_impl_->DidFinishImplFrame(); | 4799 host_impl_->DidFinishImplFrame(); |
| 4779 } | 4800 } |
| 4780 | 4801 |
| 4781 // Pull the top controls delta and get it back to the pending tree so that | 4802 // Pull the browser controls delta and get it back to the pending tree so that |
| 4782 // when we go to activate the pending tree we cause a change to top controls. | 4803 // when we go to activate the pending tree we cause a change to browser |
| 4804 // controls. |
| 4783 { | 4805 { |
| 4784 float delta = | 4806 float delta = |
| 4785 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); | 4807 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); |
| 4786 ASSERT_GT(delta, 0); | 4808 ASSERT_GT(delta, 0); |
| 4787 ASSERT_LT(delta, 1); | 4809 ASSERT_LT(delta, 1); |
| 4788 host_impl_->active_tree() | 4810 host_impl_->active_tree() |
| 4789 ->top_controls_shown_ratio() | 4811 ->top_controls_shown_ratio() |
| 4790 ->PullDeltaForMainThread(); | 4812 ->PullDeltaForMainThread(); |
| 4791 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4813 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4792 delta); | 4814 delta); |
| 4793 } | 4815 } |
| 4794 | 4816 |
| 4795 // 200 is the kShowHideMaxDurationMs value from top_controls_manager.cc so the | 4817 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so |
| 4796 // top controls should be fully animated in this frame. | 4818 // the browser controls should be fully animated in this frame. |
| 4797 { | 4819 { |
| 4798 begin_frame_args.frame_time = | 4820 begin_frame_args.frame_time = |
| 4799 start_time + base::TimeDelta::FromMilliseconds(200); | 4821 start_time + base::TimeDelta::FromMilliseconds(200); |
| 4800 host_impl_->WillBeginImplFrame(begin_frame_args); | 4822 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 4801 host_impl_->Animate(); | 4823 host_impl_->Animate(); |
| 4802 host_impl_->UpdateAnimationState(true); | 4824 host_impl_->UpdateAnimationState(true); |
| 4803 host_impl_->DidFinishImplFrame(); | 4825 host_impl_->DidFinishImplFrame(); |
| 4804 | 4826 |
| 4805 ASSERT_EQ(50, host_impl_->top_controls_manager()->ContentTopOffset()); | 4827 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4806 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); | 4828 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); |
| 4807 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we | 4829 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we |
| 4808 // lose some precision in the intermediate animation steps. | 4830 // lose some precision in the intermediate animation steps. |
| 4809 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); | 4831 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); |
| 4810 } | 4832 } |
| 4811 | 4833 |
| 4812 // Activate the pending tree which should have the same scroll value as the | 4834 // Activate the pending tree which should have the same scroll value as the |
| 4813 // active tree. | 4835 // active tree. |
| 4814 { | 4836 { |
| 4815 host_impl_->pending_tree() | 4837 host_impl_->pending_tree() |
| (...skipping 4064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8880 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8902 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
| 8881 .did_scroll); | 8903 .did_scroll); |
| 8882 host_impl_->ScrollEnd(EndState().get()); | 8904 host_impl_->ScrollEnd(EndState().get()); |
| 8883 | 8905 |
| 8884 EXPECT_EQ(0, set_needs_commit_count); | 8906 EXPECT_EQ(0, set_needs_commit_count); |
| 8885 EXPECT_EQ(2, set_needs_redraw_count); | 8907 EXPECT_EQ(2, set_needs_redraw_count); |
| 8886 EXPECT_EQ(1, forward_to_main_count); | 8908 EXPECT_EQ(1, forward_to_main_count); |
| 8887 } | 8909 } |
| 8888 } | 8910 } |
| 8889 | 8911 |
| 8890 class LayerTreeHostImplWithTopControlsTest : public LayerTreeHostImplTest { | 8912 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest { |
| 8891 public: | 8913 public: |
| 8892 void SetUp() override { | 8914 void SetUp() override { |
| 8893 LayerTreeSettings settings = DefaultSettings(); | 8915 LayerTreeSettings settings = DefaultSettings(); |
| 8894 CreateHostImpl(settings, CreateCompositorFrameSink()); | 8916 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 8895 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); | 8917 host_impl_->active_tree()->set_top_controls_height(top_controls_height_); |
| 8896 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); | 8918 host_impl_->sync_tree()->set_top_controls_height(top_controls_height_); |
| 8897 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 8919 host_impl_->active_tree()->SetCurrentBrowserControlsShownRatio(1.f); |
| 8898 } | 8920 } |
| 8899 | 8921 |
| 8900 protected: | 8922 protected: |
| 8901 static const int top_controls_height_; | 8923 static const int top_controls_height_; |
| 8902 }; | 8924 }; |
| 8903 | 8925 |
| 8904 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 8926 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; |
| 8905 | 8927 |
| 8906 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { | 8928 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { |
| 8907 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8929 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8908 scroll_layer->layer_tree_impl() | 8930 scroll_layer->layer_tree_impl() |
| 8909 ->property_trees() | 8931 ->property_trees() |
| 8910 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 8932 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 8911 gfx::ScrollOffset(0, 10)); | 8933 gfx::ScrollOffset(0, 10)); |
| 8912 BeginFrameArgs begin_frame_args = | 8934 BeginFrameArgs begin_frame_args = |
| 8913 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 8935 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); |
| 8914 host_impl_->WillBeginImplFrame(begin_frame_args); | 8936 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 8915 host_impl_->Animate(); | 8937 host_impl_->Animate(); |
| 8916 EXPECT_FALSE(did_request_redraw_); | 8938 EXPECT_FALSE(did_request_redraw_); |
| 8917 host_impl_->DidFinishImplFrame(); | 8939 host_impl_->DidFinishImplFrame(); |
| 8918 } | 8940 } |
| 8919 | 8941 |
| 8920 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { | 8942 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 8943 BrowserControlsHeightIsCommitted) { |
| 8921 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8944 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8922 EXPECT_FALSE(did_request_redraw_); | 8945 EXPECT_FALSE(did_request_redraw_); |
| 8923 host_impl_->CreatePendingTree(); | 8946 host_impl_->CreatePendingTree(); |
| 8924 host_impl_->sync_tree()->set_top_controls_height(100); | 8947 host_impl_->sync_tree()->set_top_controls_height(100); |
| 8925 host_impl_->ActivateSyncTree(); | 8948 host_impl_->ActivateSyncTree(); |
| 8926 EXPECT_EQ(100, host_impl_->top_controls_manager()->TopControlsHeight()); | 8949 EXPECT_EQ(100, host_impl_->browser_controls_manager()->TopControlsHeight()); |
| 8927 } | 8950 } |
| 8928 | 8951 |
| 8929 TEST_F(LayerTreeHostImplWithTopControlsTest, | 8952 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 8930 TopControlsStayFullyVisibleOnHeightChange) { | 8953 BrowserControlsStayFullyVisibleOnHeightChange) { |
| 8931 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8954 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8932 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8955 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 8933 | 8956 |
| 8934 host_impl_->CreatePendingTree(); | 8957 host_impl_->CreatePendingTree(); |
| 8935 host_impl_->sync_tree()->set_top_controls_height(0); | 8958 host_impl_->sync_tree()->set_top_controls_height(0); |
| 8936 host_impl_->ActivateSyncTree(); | 8959 host_impl_->ActivateSyncTree(); |
| 8937 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8960 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 8938 | 8961 |
| 8939 host_impl_->CreatePendingTree(); | 8962 host_impl_->CreatePendingTree(); |
| 8940 host_impl_->sync_tree()->set_top_controls_height(50); | 8963 host_impl_->sync_tree()->set_top_controls_height(50); |
| 8941 host_impl_->ActivateSyncTree(); | 8964 host_impl_->ActivateSyncTree(); |
| 8942 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8965 EXPECT_EQ(0.f, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 8943 } | 8966 } |
| 8944 | 8967 |
| 8945 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { | 8968 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 8969 BrowserControlsAnimationScheduling) { |
| 8946 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8970 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8947 scroll_layer->layer_tree_impl() | 8971 scroll_layer->layer_tree_impl() |
| 8948 ->property_trees() | 8972 ->property_trees() |
| 8949 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 8973 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 8950 gfx::ScrollOffset(0, 10)); | 8974 gfx::ScrollOffset(0, 10)); |
| 8951 host_impl_->DidChangeTopControlsPosition(); | 8975 host_impl_->DidChangeBrowserControlsPosition(); |
| 8952 EXPECT_TRUE(did_request_next_frame_); | 8976 EXPECT_TRUE(did_request_next_frame_); |
| 8953 EXPECT_TRUE(did_request_redraw_); | 8977 EXPECT_TRUE(did_request_redraw_); |
| 8954 } | 8978 } |
| 8955 | 8979 |
| 8956 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 8980 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 8981 ScrollHandledByBrowserControls) { |
| 8957 InputHandlerScrollResult result; | 8982 InputHandlerScrollResult result; |
| 8958 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 8983 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 8959 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8984 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8960 | 8985 |
| 8961 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 8986 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 8962 host_impl_->top_controls_manager()->UpdateTopControlsState( | 8987 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 8963 BOTH, SHOWN, false); | 8988 BOTH, SHOWN, false); |
| 8964 DrawFrame(); | 8989 DrawFrame(); |
| 8965 | 8990 |
| 8966 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8991 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8967 host_impl_ | 8992 host_impl_ |
| 8968 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8993 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8969 InputHandler::TOUCHSCREEN) | 8994 InputHandler::TOUCHSCREEN) |
| 8970 .thread); | 8995 .thread); |
| 8971 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 8996 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 8972 EXPECT_EQ(gfx::Vector2dF().ToString(), | 8997 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 8973 scroll_layer->CurrentScrollOffset().ToString()); | 8998 scroll_layer->CurrentScrollOffset().ToString()); |
| 8974 | 8999 |
| 8975 // Scroll just the top controls and verify that the scroll succeeds. | 9000 // Scroll just the browser controls and verify that the scroll succeeds. |
| 8976 const float residue = 10; | 9001 const float residue = 10; |
| 8977 float offset = top_controls_height_ - residue; | 9002 float offset = top_controls_height_ - residue; |
| 8978 result = host_impl_->ScrollBy( | 9003 result = host_impl_->ScrollBy( |
| 8979 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); | 9004 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); |
| 8980 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); | 9005 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); |
| 8981 EXPECT_TRUE(result.did_scroll); | 9006 EXPECT_TRUE(result.did_scroll); |
| 8982 EXPECT_FLOAT_EQ(-offset, | 9007 EXPECT_FLOAT_EQ(-offset, |
| 8983 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9008 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 8984 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9009 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 8985 scroll_layer->CurrentScrollOffset().ToString()); | 9010 scroll_layer->CurrentScrollOffset().ToString()); |
| 8986 | 9011 |
| 8987 // Scroll across the boundary | 9012 // Scroll across the boundary |
| 8988 const float content_scroll = 20; | 9013 const float content_scroll = 20; |
| 8989 offset = residue + content_scroll; | 9014 offset = residue + content_scroll; |
| 8990 result = host_impl_->ScrollBy( | 9015 result = host_impl_->ScrollBy( |
| 8991 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); | 9016 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); |
| 8992 EXPECT_TRUE(result.did_scroll); | 9017 EXPECT_TRUE(result.did_scroll); |
| 8993 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); | 9018 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); |
| 8994 EXPECT_EQ(-top_controls_height_, | 9019 EXPECT_EQ(-top_controls_height_, |
| 8995 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9020 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 8996 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), | 9021 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), |
| 8997 scroll_layer->CurrentScrollOffset().ToString()); | 9022 scroll_layer->CurrentScrollOffset().ToString()); |
| 8998 | 9023 |
| 8999 // Now scroll back to the top of the content | 9024 // Now scroll back to the top of the content |
| 9000 offset = -content_scroll; | 9025 offset = -content_scroll; |
| 9001 result = host_impl_->ScrollBy( | 9026 result = host_impl_->ScrollBy( |
| 9002 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); | 9027 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); |
| 9003 EXPECT_TRUE(result.did_scroll); | 9028 EXPECT_TRUE(result.did_scroll); |
| 9004 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); | 9029 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); |
| 9005 EXPECT_EQ(-top_controls_height_, | 9030 EXPECT_EQ(-top_controls_height_, |
| 9006 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9031 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9007 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9032 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9008 scroll_layer->CurrentScrollOffset().ToString()); | 9033 scroll_layer->CurrentScrollOffset().ToString()); |
| 9009 | 9034 |
| 9010 // And scroll the top controls completely into view | 9035 // And scroll the browser controls completely into view |
| 9011 offset = -top_controls_height_; | 9036 offset = -top_controls_height_; |
| 9012 result = host_impl_->ScrollBy( | 9037 result = host_impl_->ScrollBy( |
| 9013 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); | 9038 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); |
| 9014 EXPECT_TRUE(result.did_scroll); | 9039 EXPECT_TRUE(result.did_scroll); |
| 9015 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); | 9040 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, 0)); |
| 9016 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9041 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9017 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9042 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9018 scroll_layer->CurrentScrollOffset().ToString()); | 9043 scroll_layer->CurrentScrollOffset().ToString()); |
| 9019 | 9044 |
| 9020 // And attempt to scroll past the end | 9045 // And attempt to scroll past the end |
| 9021 result = host_impl_->ScrollBy( | 9046 result = host_impl_->ScrollBy( |
| 9022 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); | 9047 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()); |
| 9023 EXPECT_FALSE(result.did_scroll); | 9048 EXPECT_FALSE(result.did_scroll); |
| 9024 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, -50)); | 9049 EXPECT_EQ(result.unused_scroll_delta, gfx::Vector2d(0, -50)); |
| 9025 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9050 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9026 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9051 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9027 scroll_layer->CurrentScrollOffset().ToString()); | 9052 scroll_layer->CurrentScrollOffset().ToString()); |
| 9028 | 9053 |
| 9029 host_impl_->ScrollEnd(EndState().get()); | 9054 host_impl_->ScrollEnd(EndState().get()); |
| 9030 } | 9055 } |
| 9031 | 9056 |
| 9032 TEST_F(LayerTreeHostImplWithTopControlsTest, WheelUnhandledByTopControls) { | 9057 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 9058 WheelUnhandledByBrowserControls) { |
| 9033 SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9059 SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9034 host_impl_->SetViewportSize(gfx::Size(50, 100)); | 9060 host_impl_->SetViewportSize(gfx::Size(50, 100)); |
| 9035 host_impl_->active_tree()->set_top_controls_shrink_blink_size(true); | 9061 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true); |
| 9036 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 9062 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 9037 false); | 9063 BOTH, SHOWN, false); |
| 9038 DrawFrame(); | 9064 DrawFrame(); |
| 9039 | 9065 |
| 9040 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); | 9066 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); |
| 9041 | 9067 |
| 9042 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9068 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9043 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 9069 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9044 InputHandler::WHEEL) | 9070 InputHandler::WHEEL) |
| 9045 .thread); | 9071 .thread); |
| 9046 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9072 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9047 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); | 9073 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); |
| 9048 | 9074 |
| 9049 // Wheel scrolls should not affect the top controls, and should pass | 9075 // Wheel scrolls should not affect the browser controls, and should pass |
| 9050 // directly through to the viewport. | 9076 // directly through to the viewport. |
| 9051 const float delta = top_controls_height_; | 9077 const float delta = top_controls_height_; |
| 9052 EXPECT_TRUE( | 9078 EXPECT_TRUE( |
| 9053 host_impl_->ScrollBy( | 9079 host_impl_->ScrollBy( |
| 9054 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 9080 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
| 9055 .did_scroll); | 9081 .did_scroll); |
| 9056 EXPECT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9082 EXPECT_FLOAT_EQ(0, |
| 9083 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9057 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), | 9084 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), |
| 9058 viewport_layer->CurrentScrollOffset()); | 9085 viewport_layer->CurrentScrollOffset()); |
| 9059 | 9086 |
| 9060 EXPECT_TRUE( | 9087 EXPECT_TRUE( |
| 9061 host_impl_->ScrollBy( | 9088 host_impl_->ScrollBy( |
| 9062 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 9089 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
| 9063 .did_scroll); | 9090 .did_scroll); |
| 9064 EXPECT_FLOAT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9091 EXPECT_FLOAT_EQ(0, |
| 9092 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9065 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), | 9093 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), |
| 9066 viewport_layer->CurrentScrollOffset()); | 9094 viewport_layer->CurrentScrollOffset()); |
| 9067 } | 9095 } |
| 9068 | 9096 |
| 9069 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 9097 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 9098 BrowserControlsAnimationAtOrigin) { |
| 9070 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9099 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9071 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9100 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9072 | 9101 |
| 9073 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 9102 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
| 9074 host_impl_->top_controls_manager()->UpdateTopControlsState( | 9103 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 9075 BOTH, SHOWN, false); | 9104 BOTH, SHOWN, false); |
| 9076 DrawFrame(); | 9105 DrawFrame(); |
| 9077 | 9106 |
| 9078 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9107 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9079 host_impl_ | 9108 host_impl_ |
| 9080 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9109 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9081 InputHandler::TOUCHSCREEN) | 9110 InputHandler::TOUCHSCREEN) |
| 9082 .thread); | 9111 .thread); |
| 9083 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9112 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9084 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9113 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9085 scroll_layer->CurrentScrollOffset().ToString()); | 9114 scroll_layer->CurrentScrollOffset().ToString()); |
| 9086 | 9115 |
| 9087 // Scroll the top controls partially. | 9116 // Scroll the browser controls partially. |
| 9088 const float residue = 35; | 9117 const float residue = 35; |
| 9089 float offset = top_controls_height_ - residue; | 9118 float offset = top_controls_height_ - residue; |
| 9090 EXPECT_TRUE( | 9119 EXPECT_TRUE( |
| 9091 host_impl_->ScrollBy( | 9120 host_impl_->ScrollBy( |
| 9092 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9121 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9093 .did_scroll); | 9122 .did_scroll); |
| 9094 EXPECT_FLOAT_EQ(-offset, | 9123 EXPECT_FLOAT_EQ(-offset, |
| 9095 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9124 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9096 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9125 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9097 scroll_layer->CurrentScrollOffset().ToString()); | 9126 scroll_layer->CurrentScrollOffset().ToString()); |
| 9098 | 9127 |
| 9099 did_request_redraw_ = false; | 9128 did_request_redraw_ = false; |
| 9100 did_request_next_frame_ = false; | 9129 did_request_next_frame_ = false; |
| 9101 did_request_commit_ = false; | 9130 did_request_commit_ = false; |
| 9102 | 9131 |
| 9103 // End the scroll while the controls are still offset from their limit. | 9132 // End the scroll while the controls are still offset from their limit. |
| 9104 host_impl_->ScrollEnd(EndState().get()); | 9133 host_impl_->ScrollEnd(EndState().get()); |
| 9105 ASSERT_TRUE(host_impl_->top_controls_manager()->has_animation()); | 9134 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9106 EXPECT_TRUE(did_request_next_frame_); | 9135 EXPECT_TRUE(did_request_next_frame_); |
| 9107 EXPECT_TRUE(did_request_redraw_); | 9136 EXPECT_TRUE(did_request_redraw_); |
| 9108 EXPECT_FALSE(did_request_commit_); | 9137 EXPECT_FALSE(did_request_commit_); |
| 9109 | 9138 |
| 9110 // The top controls should properly animate until finished, despite the scroll | 9139 // The browser controls should properly animate until finished, despite the |
| 9111 // offset being at the origin. | 9140 // scroll offset being at the origin. |
| 9112 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9141 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
| 9113 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9142 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); |
| 9114 while (did_request_next_frame_) { | 9143 while (did_request_next_frame_) { |
| 9115 did_request_redraw_ = false; | 9144 did_request_redraw_ = false; |
| 9116 did_request_next_frame_ = false; | 9145 did_request_next_frame_ = false; |
| 9117 did_request_commit_ = false; | 9146 did_request_commit_ = false; |
| 9118 | 9147 |
| 9119 float old_offset = | 9148 float old_offset = |
| 9120 host_impl_->top_controls_manager()->ControlsTopOffset(); | 9149 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9121 | 9150 |
| 9122 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9151 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9123 host_impl_->WillBeginImplFrame(begin_frame_args); | 9152 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9124 host_impl_->Animate(); | 9153 host_impl_->Animate(); |
| 9125 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9154 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9126 scroll_layer->CurrentScrollOffset().ToString()); | 9155 scroll_layer->CurrentScrollOffset().ToString()); |
| 9127 | 9156 |
| 9128 float new_offset = | 9157 float new_offset = |
| 9129 host_impl_->top_controls_manager()->ControlsTopOffset(); | 9158 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9130 | 9159 |
| 9131 // No commit is needed as the controls are animating the content offset, | 9160 // No commit is needed as the controls are animating the content offset, |
| 9132 // not the scroll offset. | 9161 // not the scroll offset. |
| 9133 EXPECT_FALSE(did_request_commit_); | 9162 EXPECT_FALSE(did_request_commit_); |
| 9134 | 9163 |
| 9135 if (new_offset != old_offset) | 9164 if (new_offset != old_offset) |
| 9136 EXPECT_TRUE(did_request_redraw_); | 9165 EXPECT_TRUE(did_request_redraw_); |
| 9137 | 9166 |
| 9138 if (new_offset != 0) { | 9167 if (new_offset != 0) { |
| 9139 EXPECT_TRUE(host_impl_->top_controls_manager()->has_animation()); | 9168 EXPECT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9140 EXPECT_TRUE(did_request_next_frame_); | 9169 EXPECT_TRUE(did_request_next_frame_); |
| 9141 } | 9170 } |
| 9142 host_impl_->DidFinishImplFrame(); | 9171 host_impl_->DidFinishImplFrame(); |
| 9143 } | 9172 } |
| 9144 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 9173 EXPECT_FALSE(host_impl_->browser_controls_manager()->has_animation()); |
| 9145 } | 9174 } |
| 9146 | 9175 |
| 9147 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { | 9176 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 9177 BrowserControlsAnimationAfterScroll) { |
| 9148 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9178 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9149 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9179 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9150 | 9180 |
| 9151 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 9181 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 9152 host_impl_->top_controls_manager()->UpdateTopControlsState( | 9182 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 9153 BOTH, SHOWN, false); | 9183 BOTH, SHOWN, false); |
| 9154 float initial_scroll_offset = 50; | 9184 float initial_scroll_offset = 50; |
| 9155 scroll_layer->layer_tree_impl() | 9185 scroll_layer->layer_tree_impl() |
| 9156 ->property_trees() | 9186 ->property_trees() |
| 9157 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 9187 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 9158 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); | 9188 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); |
| 9159 DrawFrame(); | 9189 DrawFrame(); |
| 9160 | 9190 |
| 9161 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9191 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9162 host_impl_ | 9192 host_impl_ |
| 9163 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9193 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9164 InputHandler::TOUCHSCREEN) | 9194 InputHandler::TOUCHSCREEN) |
| 9165 .thread); | 9195 .thread); |
| 9166 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9196 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9167 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9197 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9168 scroll_layer->CurrentScrollOffset().ToString()); | 9198 scroll_layer->CurrentScrollOffset().ToString()); |
| 9169 | 9199 |
| 9170 // Scroll the top controls partially. | 9200 // Scroll the browser controls partially. |
| 9171 const float residue = 15; | 9201 const float residue = 15; |
| 9172 float offset = top_controls_height_ - residue; | 9202 float offset = top_controls_height_ - residue; |
| 9173 EXPECT_TRUE( | 9203 EXPECT_TRUE( |
| 9174 host_impl_->ScrollBy( | 9204 host_impl_->ScrollBy( |
| 9175 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9205 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9176 .did_scroll); | 9206 .did_scroll); |
| 9177 EXPECT_FLOAT_EQ(-offset, | 9207 EXPECT_FLOAT_EQ(-offset, |
| 9178 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9208 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9179 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9209 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9180 scroll_layer->CurrentScrollOffset().ToString()); | 9210 scroll_layer->CurrentScrollOffset().ToString()); |
| 9181 | 9211 |
| 9182 did_request_redraw_ = false; | 9212 did_request_redraw_ = false; |
| 9183 did_request_next_frame_ = false; | 9213 did_request_next_frame_ = false; |
| 9184 did_request_commit_ = false; | 9214 did_request_commit_ = false; |
| 9185 | 9215 |
| 9186 // End the scroll while the controls are still offset from the limit. | 9216 // End the scroll while the controls are still offset from the limit. |
| 9187 host_impl_->ScrollEnd(EndState().get()); | 9217 host_impl_->ScrollEnd(EndState().get()); |
| 9188 ASSERT_TRUE(host_impl_->top_controls_manager()->has_animation()); | 9218 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9189 EXPECT_TRUE(did_request_next_frame_); | 9219 EXPECT_TRUE(did_request_next_frame_); |
| 9190 EXPECT_TRUE(did_request_redraw_); | 9220 EXPECT_TRUE(did_request_redraw_); |
| 9191 EXPECT_FALSE(did_request_commit_); | 9221 EXPECT_FALSE(did_request_commit_); |
| 9192 | 9222 |
| 9193 // Animate the top controls to the limit. | 9223 // Animate the browser controls to the limit. |
| 9194 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9224 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
| 9195 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9225 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); |
| 9196 while (did_request_next_frame_) { | 9226 while (did_request_next_frame_) { |
| 9197 did_request_redraw_ = false; | 9227 did_request_redraw_ = false; |
| 9198 did_request_next_frame_ = false; | 9228 did_request_next_frame_ = false; |
| 9199 did_request_commit_ = false; | 9229 did_request_commit_ = false; |
| 9200 | 9230 |
| 9201 float old_offset = | 9231 float old_offset = |
| 9202 host_impl_->top_controls_manager()->ControlsTopOffset(); | 9232 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9203 | 9233 |
| 9204 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9234 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9205 host_impl_->WillBeginImplFrame(begin_frame_args); | 9235 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9206 host_impl_->Animate(); | 9236 host_impl_->Animate(); |
| 9207 | 9237 |
| 9208 float new_offset = | 9238 float new_offset = |
| 9209 host_impl_->top_controls_manager()->ControlsTopOffset(); | 9239 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9210 | 9240 |
| 9211 if (new_offset != old_offset) { | 9241 if (new_offset != old_offset) { |
| 9212 EXPECT_TRUE(did_request_redraw_); | 9242 EXPECT_TRUE(did_request_redraw_); |
| 9213 EXPECT_TRUE(did_request_commit_); | 9243 EXPECT_TRUE(did_request_commit_); |
| 9214 } | 9244 } |
| 9215 host_impl_->DidFinishImplFrame(); | 9245 host_impl_->DidFinishImplFrame(); |
| 9216 } | 9246 } |
| 9217 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 9247 EXPECT_FALSE(host_impl_->browser_controls_manager()->has_animation()); |
| 9218 EXPECT_EQ(-top_controls_height_, | 9248 EXPECT_EQ(-top_controls_height_, |
| 9219 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9249 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9220 } | 9250 } |
| 9221 | 9251 |
| 9222 TEST_F(LayerTreeHostImplWithTopControlsTest, | 9252 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 9223 TopControlsAnimationAfterMainThreadFlingStopped) { | 9253 BrowserControlsAnimationAfterMainThreadFlingStopped) { |
| 9224 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9254 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9225 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9255 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9226 | 9256 |
| 9227 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 9257 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 9228 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 9258 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 9229 false); | 9259 BOTH, SHOWN, false); |
| 9230 float initial_scroll_offset = 50; | 9260 float initial_scroll_offset = 50; |
| 9231 scroll_layer->layer_tree_impl() | 9261 scroll_layer->layer_tree_impl() |
| 9232 ->property_trees() | 9262 ->property_trees() |
| 9233 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 9263 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 9234 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); | 9264 scroll_layer->id(), gfx::ScrollOffset(0, initial_scroll_offset)); |
| 9235 DrawFrame(); | 9265 DrawFrame(); |
| 9236 | 9266 |
| 9237 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9267 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9238 host_impl_ | 9268 host_impl_ |
| 9239 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9269 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9240 InputHandler::TOUCHSCREEN) | 9270 InputHandler::TOUCHSCREEN) |
| 9241 .thread); | 9271 .thread); |
| 9242 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9272 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9243 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9273 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9244 scroll_layer->CurrentScrollOffset().ToString()); | 9274 scroll_layer->CurrentScrollOffset().ToString()); |
| 9245 | 9275 |
| 9246 // Scroll the top controls partially. | 9276 // Scroll the browser controls partially. |
| 9247 const float residue = 15; | 9277 const float residue = 15; |
| 9248 float offset = top_controls_height_ - residue; | 9278 float offset = top_controls_height_ - residue; |
| 9249 EXPECT_TRUE( | 9279 EXPECT_TRUE( |
| 9250 host_impl_->ScrollBy( | 9280 host_impl_->ScrollBy( |
| 9251 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9281 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9252 .did_scroll); | 9282 .did_scroll); |
| 9253 EXPECT_FLOAT_EQ(-offset, | 9283 EXPECT_FLOAT_EQ(-offset, |
| 9254 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9284 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9255 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9285 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9256 scroll_layer->CurrentScrollOffset().ToString()); | 9286 scroll_layer->CurrentScrollOffset().ToString()); |
| 9257 | 9287 |
| 9258 did_request_redraw_ = false; | 9288 did_request_redraw_ = false; |
| 9259 did_request_next_frame_ = false; | 9289 did_request_next_frame_ = false; |
| 9260 did_request_commit_ = false; | 9290 did_request_commit_ = false; |
| 9261 | 9291 |
| 9262 // End the fling while the controls are still offset from the limit. | 9292 // End the fling while the controls are still offset from the limit. |
| 9263 host_impl_->MainThreadHasStoppedFlinging(); | 9293 host_impl_->MainThreadHasStoppedFlinging(); |
| 9264 ASSERT_TRUE(host_impl_->top_controls_manager()->has_animation()); | 9294 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9265 EXPECT_TRUE(did_request_next_frame_); | 9295 EXPECT_TRUE(did_request_next_frame_); |
| 9266 EXPECT_TRUE(did_request_redraw_); | 9296 EXPECT_TRUE(did_request_redraw_); |
| 9267 EXPECT_FALSE(did_request_commit_); | 9297 EXPECT_FALSE(did_request_commit_); |
| 9268 | 9298 |
| 9269 // Animate the top controls to the limit. | 9299 // Animate the browser controls to the limit. |
| 9270 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9300 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
| 9271 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9301 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); |
| 9272 while (did_request_next_frame_) { | 9302 while (did_request_next_frame_) { |
| 9273 did_request_redraw_ = false; | 9303 did_request_redraw_ = false; |
| 9274 did_request_next_frame_ = false; | 9304 did_request_next_frame_ = false; |
| 9275 did_request_commit_ = false; | 9305 did_request_commit_ = false; |
| 9276 | 9306 |
| 9277 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); | 9307 float old_offset = |
| 9308 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9278 | 9309 |
| 9279 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9310 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9280 host_impl_->WillBeginImplFrame(begin_frame_args); | 9311 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9281 host_impl_->Animate(); | 9312 host_impl_->Animate(); |
| 9282 | 9313 |
| 9283 float new_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); | 9314 float new_offset = |
| 9315 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9284 | 9316 |
| 9285 if (new_offset != old_offset) { | 9317 if (new_offset != old_offset) { |
| 9286 EXPECT_TRUE(did_request_redraw_); | 9318 EXPECT_TRUE(did_request_redraw_); |
| 9287 EXPECT_TRUE(did_request_commit_); | 9319 EXPECT_TRUE(did_request_commit_); |
| 9288 } | 9320 } |
| 9289 host_impl_->DidFinishImplFrame(); | 9321 host_impl_->DidFinishImplFrame(); |
| 9290 } | 9322 } |
| 9291 EXPECT_FALSE(host_impl_->top_controls_manager()->has_animation()); | 9323 EXPECT_FALSE(host_impl_->browser_controls_manager()->has_animation()); |
| 9292 EXPECT_EQ(-top_controls_height_, | 9324 EXPECT_EQ(-top_controls_height_, |
| 9293 host_impl_->top_controls_manager()->ControlsTopOffset()); | 9325 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9294 } | 9326 } |
| 9295 | 9327 |
| 9296 TEST_F(LayerTreeHostImplWithTopControlsTest, | 9328 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 9297 TopControlsScrollDeltaInOverScroll) { | 9329 BrowserControlsScrollDeltaInOverScroll) { |
| 9298 // Verifies that the overscroll delta should not have accumulated in | 9330 // Verifies that the overscroll delta should not have accumulated in |
| 9299 // the top controls if we do a hide and show without releasing finger. | 9331 // the browser controls if we do a hide and show without releasing finger. |
| 9300 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9332 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9301 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9333 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9302 | 9334 |
| 9303 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 9335 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 9304 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 9336 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 9305 false); | 9337 BOTH, SHOWN, false); |
| 9306 DrawFrame(); | 9338 DrawFrame(); |
| 9307 | 9339 |
| 9308 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9340 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9309 host_impl_ | 9341 host_impl_ |
| 9310 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9342 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9311 InputHandler::TOUCHSCREEN) | 9343 InputHandler::TOUCHSCREEN) |
| 9312 .thread); | 9344 .thread); |
| 9313 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9345 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9314 | 9346 |
| 9315 float offset = 50; | 9347 float offset = 50; |
| 9316 EXPECT_TRUE( | 9348 EXPECT_TRUE( |
| 9317 host_impl_->ScrollBy( | 9349 host_impl_->ScrollBy( |
| 9318 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9350 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9319 .did_scroll); | 9351 .did_scroll); |
| 9320 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9352 EXPECT_EQ(-offset, |
| 9353 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9321 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9354 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9322 scroll_layer->CurrentScrollOffset().ToString()); | 9355 scroll_layer->CurrentScrollOffset().ToString()); |
| 9323 | 9356 |
| 9324 EXPECT_TRUE( | 9357 EXPECT_TRUE( |
| 9325 host_impl_->ScrollBy( | 9358 host_impl_->ScrollBy( |
| 9326 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9359 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9327 .did_scroll); | 9360 .did_scroll); |
| 9328 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | 9361 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
| 9329 scroll_layer->CurrentScrollOffset().ToString()); | 9362 scroll_layer->CurrentScrollOffset().ToString()); |
| 9330 | 9363 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9349 scroll_layer->CurrentScrollOffset().ToString()); | 9382 scroll_layer->CurrentScrollOffset().ToString()); |
| 9350 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | 9383 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
| 9351 host_impl_->accumulated_root_overscroll().ToString()); | 9384 host_impl_->accumulated_root_overscroll().ToString()); |
| 9352 | 9385 |
| 9353 EXPECT_TRUE(host_impl_->ScrollBy(UpdateState(gfx::Point(), | 9386 EXPECT_TRUE(host_impl_->ScrollBy(UpdateState(gfx::Point(), |
| 9354 gfx::Vector2d(0, -2 * offset)) | 9387 gfx::Vector2d(0, -2 * offset)) |
| 9355 .get()) | 9388 .get()) |
| 9356 .did_scroll); | 9389 .did_scroll); |
| 9357 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 9390 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
| 9358 scroll_layer->CurrentScrollOffset().ToString()); | 9391 scroll_layer->CurrentScrollOffset().ToString()); |
| 9359 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9392 EXPECT_EQ(-offset, |
| 9393 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9360 | 9394 |
| 9361 EXPECT_TRUE( | 9395 EXPECT_TRUE( |
| 9362 host_impl_->ScrollBy( | 9396 host_impl_->ScrollBy( |
| 9363 UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) | 9397 UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) |
| 9364 .did_scroll); | 9398 .did_scroll); |
| 9365 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 9399 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
| 9366 scroll_layer->CurrentScrollOffset().ToString()); | 9400 scroll_layer->CurrentScrollOffset().ToString()); |
| 9367 | 9401 |
| 9368 // Top controls should be fully visible | 9402 // Browser controls should be fully visible |
| 9369 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 9403 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9370 | 9404 |
| 9371 host_impl_->ScrollEnd(EndState().get()); | 9405 host_impl_->ScrollEnd(EndState().get()); |
| 9372 } | 9406 } |
| 9373 | 9407 |
| 9374 // Tests that when we set a child scroller (e.g. a scrolling div) as the outer | 9408 // Tests that when we set a child scroller (e.g. a scrolling div) as the outer |
| 9375 // viewport, scrolling it controls the top controls. | 9409 // viewport, scrolling it controls the browser controls. |
| 9376 TEST_F(LayerTreeHostImplTopControlsTest, | 9410 TEST_F(LayerTreeHostImplBrowserControlsTest, |
| 9377 ReplacedOuterViewportScrollsTopControls) { | 9411 ReplacedOuterViewportScrollsBrowserControls) { |
| 9378 const gfx::Size scroll_content_size(400, 400); | 9412 const gfx::Size scroll_content_size(400, 400); |
| 9379 const gfx::Size root_layer_size(200, 200); | 9413 const gfx::Size root_layer_size(200, 200); |
| 9380 const gfx::Size viewport_size(100, 100); | 9414 const gfx::Size viewport_size(100, 100); |
| 9381 | 9415 |
| 9382 SetupTopControlsAndScrollLayerWithVirtualViewport( | 9416 SetupBrowserControlsAndScrollLayerWithVirtualViewport( |
| 9383 viewport_size, viewport_size, root_layer_size); | 9417 viewport_size, viewport_size, root_layer_size); |
| 9384 | 9418 |
| 9385 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9419 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9386 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9420 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9387 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 9421 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 9388 LayerImpl* scroll_layer = nullptr; | 9422 LayerImpl* scroll_layer = nullptr; |
| 9389 | 9423 |
| 9390 // Initialization: Add a child scrolling layer to the outer scroll layer and | 9424 // Initialization: Add a child scrolling layer to the outer scroll layer and |
| 9391 // set its scroll layer as the outer viewport. This simulates setting a | 9425 // set its scroll layer as the outer viewport. This simulates setting a |
| 9392 // scrolling element as the root scroller on the page. | 9426 // scrolling element as the root scroller on the page. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 9404 | 9438 |
| 9405 clip->test_properties()->AddChild(std::move(scroll)); | 9439 clip->test_properties()->AddChild(std::move(scroll)); |
| 9406 outer_scroll->test_properties()->AddChild(std::move(clip)); | 9440 outer_scroll->test_properties()->AddChild(std::move(clip)); |
| 9407 layer_tree_impl->SetViewportLayersFromIds( | 9441 layer_tree_impl->SetViewportLayersFromIds( |
| 9408 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), | 9442 Layer::INVALID_ID, layer_tree_impl->PageScaleLayer()->id(), |
| 9409 inner_scroll->id(), scroll_layer->id()); | 9443 inner_scroll->id(), scroll_layer->id()); |
| 9410 layer_tree_impl->BuildPropertyTreesForTesting(); | 9444 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 9411 DrawFrame(); | 9445 DrawFrame(); |
| 9412 } | 9446 } |
| 9413 | 9447 |
| 9414 ASSERT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 9448 ASSERT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 9415 | 9449 |
| 9416 // Scrolling should scroll the child content and the top controls. The | 9450 // Scrolling should scroll the child content and the browser controls. The |
| 9417 // original outer viewport should get no scroll. | 9451 // original outer viewport should get no scroll. |
| 9418 { | 9452 { |
| 9419 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 9453 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 9420 InputHandler::TOUCHSCREEN); | 9454 InputHandler::TOUCHSCREEN); |
| 9421 host_impl_->ScrollBy( | 9455 host_impl_->ScrollBy( |
| 9422 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); | 9456 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); |
| 9423 host_impl_->ScrollEnd(EndState().get()); | 9457 host_impl_->ScrollEnd(EndState().get()); |
| 9424 | 9458 |
| 9425 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll->CurrentScrollOffset()); | 9459 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll->CurrentScrollOffset()); |
| 9426 EXPECT_VECTOR_EQ(gfx::Vector2dF(100.f, 50.f), | 9460 EXPECT_VECTOR_EQ(gfx::Vector2dF(100.f, 50.f), |
| 9427 scroll_layer->CurrentScrollOffset()); | 9461 scroll_layer->CurrentScrollOffset()); |
| 9428 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 9462 EXPECT_EQ(0.f, |
| 9463 host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 9429 } | 9464 } |
| 9430 } | 9465 } |
| 9431 | 9466 |
| 9432 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { | 9467 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
| 9433 public: | 9468 public: |
| 9434 void SetupVirtualViewportLayers(const gfx::Size& content_size, | 9469 void SetupVirtualViewportLayers(const gfx::Size& content_size, |
| 9435 const gfx::Size& outer_viewport, | 9470 const gfx::Size& outer_viewport, |
| 9436 const gfx::Size& inner_viewport) { | 9471 const gfx::Size& inner_viewport) { |
| 9437 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 9472 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 9438 const int kOuterViewportClipLayerId = 6; | 9473 const int kOuterViewportClipLayerId = 6; |
| (...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11473 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11508 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
| 11474 | 11509 |
| 11475 // Re-initialize with a software output surface. | 11510 // Re-initialize with a software output surface. |
| 11476 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11511 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
| 11477 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11512 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 11478 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11513 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 11479 } | 11514 } |
| 11480 | 11515 |
| 11481 } // namespace | 11516 } // namespace |
| 11482 } // namespace cc | 11517 } // namespace cc |
| OLD | NEW |