| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 LayerImpl::Create(layer_tree_impl, 1); | 231 LayerImpl::Create(layer_tree_impl, 1); |
| 232 root->SetBounds(content_size); | 232 root->SetBounds(content_size); |
| 233 root->SetContentBounds(content_size); | 233 root->SetContentBounds(content_size); |
| 234 root->SetPosition(gfx::PointF()); | 234 root->SetPosition(gfx::PointF()); |
| 235 root->SetHasRenderSurface(true); | 235 root->SetHasRenderSurface(true); |
| 236 | 236 |
| 237 scoped_ptr<LayerImpl> scroll = | 237 scoped_ptr<LayerImpl> scroll = |
| 238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
| 239 LayerImpl* scroll_layer = scroll.get(); | 239 LayerImpl* scroll_layer = scroll.get(); |
| 240 scroll->SetIsContainerForFixedPositionLayers(true); | 240 scroll->SetIsContainerForFixedPositionLayers(true); |
| 241 scroll->SetScrollOffset(gfx::ScrollOffset()); | 241 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 242 | 242 |
| 243 scoped_ptr<LayerImpl> clip = | 243 scoped_ptr<LayerImpl> clip = |
| 244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
| 245 clip->SetBounds( | 245 clip->SetBounds( |
| 246 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 246 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
| 247 | 247 |
| 248 scoped_ptr<LayerImpl> page_scale = | 248 scoped_ptr<LayerImpl> page_scale = |
| 249 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 249 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
| 250 | 250 |
| 251 scroll->SetScrollClipLayer(clip->id()); | 251 scroll->SetScrollClipLayer(clip->id()); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 { | 466 { |
| 467 scoped_ptr<LayerImpl> root_clip = | 467 scoped_ptr<LayerImpl> root_clip = |
| 468 LayerImpl::Create(host_impl_->active_tree(), 2); | 468 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 469 scoped_ptr<LayerImpl> root = | 469 scoped_ptr<LayerImpl> root = |
| 470 LayerImpl::Create(host_impl_->active_tree(), 1); | 470 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 471 root_clip->SetBounds(gfx::Size(10, 10)); | 471 root_clip->SetBounds(gfx::Size(10, 10)); |
| 472 LayerImpl* root_layer = root.get(); | 472 LayerImpl* root_layer = root.get(); |
| 473 root_clip->AddChild(root.Pass()); | 473 root_clip->AddChild(root.Pass()); |
| 474 root_layer->SetBounds(gfx::Size(110, 110)); | 474 root_layer->SetBounds(gfx::Size(110, 110)); |
| 475 root_layer->SetScrollClipLayer(root_clip->id()); | 475 root_layer->SetScrollClipLayer(root_clip->id()); |
| 476 root_layer->SetScrollOffset(scroll_offset); | 476 root_layer->PushScrollOffsetFromMainThread(scroll_offset); |
| 477 root_layer->ScrollBy(scroll_delta); | 477 root_layer->ScrollBy(scroll_delta); |
| 478 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 478 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 479 } | 479 } |
| 480 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; | 480 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; |
| 481 | 481 |
| 482 scoped_ptr<ScrollAndScaleSet> scroll_info; | 482 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 483 | 483 |
| 484 scroll_info = host_impl_->ProcessScrollDeltas(); | 484 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 485 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 485 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 486 ExpectContains(*scroll_info, root->id(), scroll_delta); | 486 ExpectContains(*scroll_info, root->id(), scroll_delta); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 839 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 840 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 840 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 841 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 841 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 842 | 842 |
| 843 gfx::Size overflow_size(400, 400); | 843 gfx::Size overflow_size(400, 400); |
| 844 ASSERT_EQ(1u, scroll_layer->children().size()); | 844 ASSERT_EQ(1u, scroll_layer->children().size()); |
| 845 LayerImpl* overflow = scroll_layer->children()[0]; | 845 LayerImpl* overflow = scroll_layer->children()[0]; |
| 846 overflow->SetBounds(overflow_size); | 846 overflow->SetBounds(overflow_size); |
| 847 overflow->SetContentBounds(overflow_size); | 847 overflow->SetContentBounds(overflow_size); |
| 848 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); | 848 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); |
| 849 overflow->SetScrollOffset(gfx::ScrollOffset()); | 849 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 850 overflow->SetPosition(gfx::PointF()); | 850 overflow->SetPosition(gfx::PointF()); |
| 851 | 851 |
| 852 DrawFrame(); | 852 DrawFrame(); |
| 853 gfx::Point scroll_position(10, 10); | 853 gfx::Point scroll_position(10, 10); |
| 854 | 854 |
| 855 EXPECT_EQ(InputHandler::ScrollStarted, | 855 EXPECT_EQ(InputHandler::ScrollStarted, |
| 856 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 856 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 857 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 857 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 858 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset()); | 858 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
| 859 | 859 |
| 860 gfx::Vector2dF scroll_delta(10, 10); | 860 gfx::Vector2dF scroll_delta(10, 10); |
| 861 host_impl_->ScrollBy(scroll_position, scroll_delta); | 861 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 862 host_impl_->ScrollEnd(); | 862 host_impl_->ScrollEnd(); |
| 863 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 863 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 864 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset()); | 864 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 865 | 865 |
| 866 overflow->set_user_scrollable_horizontal(false); | 866 overflow->set_user_scrollable_horizontal(false); |
| 867 | 867 |
| 868 EXPECT_EQ(InputHandler::ScrollStarted, | 868 EXPECT_EQ(InputHandler::ScrollStarted, |
| 869 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 869 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 870 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 870 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 871 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset()); | 871 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 872 | 872 |
| 873 host_impl_->ScrollBy(scroll_position, scroll_delta); | 873 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 874 host_impl_->ScrollEnd(); | 874 host_impl_->ScrollEnd(); |
| 875 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 875 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
| 876 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 876 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 877 | 877 |
| 878 overflow->set_user_scrollable_vertical(false); | 878 overflow->set_user_scrollable_vertical(false); |
| 879 | 879 |
| 880 EXPECT_EQ(InputHandler::ScrollStarted, | 880 EXPECT_EQ(InputHandler::ScrollStarted, |
| 881 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 881 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 882 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 882 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
| 883 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 883 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 884 | 884 |
| 885 host_impl_->ScrollBy(scroll_position, scroll_delta); | 885 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 886 host_impl_->ScrollEnd(); | 886 host_impl_->ScrollEnd(); |
| 887 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); | 887 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); |
| 888 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 888 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 889 } | 889 } |
| 890 | 890 |
| 891 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 891 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
| 892 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 892 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 893 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 893 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 894 DrawFrame(); | 894 DrawFrame(); |
| 895 | 895 |
| 896 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 896 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
| 897 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 897 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
| 898 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 898 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 host_impl_->ProcessScrollDeltas(); | 1023 host_impl_->ProcessScrollDeltas(); |
| 1024 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); | 1024 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 // Zoom-out clamping | 1027 // Zoom-out clamping |
| 1028 { | 1028 { |
| 1029 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1029 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1030 max_page_scale); | 1030 max_page_scale); |
| 1031 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1031 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1032 scroll_layer->PullDeltaForMainThread(); | 1032 scroll_layer->PullDeltaForMainThread(); |
| 1033 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1033 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1034 | 1034 |
| 1035 float page_scale_delta = 0.1f; | 1035 float page_scale_delta = 0.1f; |
| 1036 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 1036 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 1037 host_impl_->PinchGestureBegin(); | 1037 host_impl_->PinchGestureBegin(); |
| 1038 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1038 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 1039 host_impl_->PinchGestureEnd(); | 1039 host_impl_->PinchGestureEnd(); |
| 1040 host_impl_->ScrollEnd(); | 1040 host_impl_->ScrollEnd(); |
| 1041 | 1041 |
| 1042 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1042 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1043 host_impl_->ProcessScrollDeltas(); | 1043 host_impl_->ProcessScrollDeltas(); |
| 1044 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 1044 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
| 1045 | 1045 |
| 1046 EXPECT_TRUE(scroll_info->scrolls.empty()); | 1046 EXPECT_TRUE(scroll_info->scrolls.empty()); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 // Two-finger panning should not happen based on pinch events only | 1049 // Two-finger panning should not happen based on pinch events only |
| 1050 { | 1050 { |
| 1051 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1051 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1052 max_page_scale); | 1052 max_page_scale); |
| 1053 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1053 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1054 scroll_layer->PullDeltaForMainThread(); | 1054 scroll_layer->PullDeltaForMainThread(); |
| 1055 scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20)); | 1055 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
| 1056 | 1056 |
| 1057 float page_scale_delta = 1.f; | 1057 float page_scale_delta = 1.f; |
| 1058 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); | 1058 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); |
| 1059 host_impl_->PinchGestureBegin(); | 1059 host_impl_->PinchGestureBegin(); |
| 1060 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1060 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
| 1061 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1061 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
| 1062 host_impl_->PinchGestureEnd(); | 1062 host_impl_->PinchGestureEnd(); |
| 1063 host_impl_->ScrollEnd(); | 1063 host_impl_->ScrollEnd(); |
| 1064 | 1064 |
| 1065 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1065 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1066 host_impl_->ProcessScrollDeltas(); | 1066 host_impl_->ProcessScrollDeltas(); |
| 1067 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1067 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1068 EXPECT_TRUE(scroll_info->scrolls.empty()); | 1068 EXPECT_TRUE(scroll_info->scrolls.empty()); |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 // Two-finger panning should work with interleaved scroll events | 1071 // Two-finger panning should work with interleaved scroll events |
| 1072 { | 1072 { |
| 1073 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1073 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1074 max_page_scale); | 1074 max_page_scale); |
| 1075 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1075 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1076 scroll_layer->PullDeltaForMainThread(); | 1076 scroll_layer->PullDeltaForMainThread(); |
| 1077 scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20)); | 1077 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
| 1078 | 1078 |
| 1079 float page_scale_delta = 1.f; | 1079 float page_scale_delta = 1.f; |
| 1080 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); | 1080 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); |
| 1081 host_impl_->PinchGestureBegin(); | 1081 host_impl_->PinchGestureBegin(); |
| 1082 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1082 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
| 1083 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 1083 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
| 1084 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1084 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
| 1085 host_impl_->PinchGestureEnd(); | 1085 host_impl_->PinchGestureEnd(); |
| 1086 host_impl_->ScrollEnd(); | 1086 host_impl_->ScrollEnd(); |
| 1087 | 1087 |
| 1088 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1088 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1089 host_impl_->ProcessScrollDeltas(); | 1089 host_impl_->ProcessScrollDeltas(); |
| 1090 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1090 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1091 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); | 1091 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); |
| 1092 } | 1092 } |
| 1093 | 1093 |
| 1094 // Two-finger panning should work when starting fully zoomed out. | 1094 // Two-finger panning should work when starting fully zoomed out. |
| 1095 { | 1095 { |
| 1096 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); | 1096 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); |
| 1097 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1097 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1098 scroll_layer->PullDeltaForMainThread(); | 1098 scroll_layer->PullDeltaForMainThread(); |
| 1099 scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 1099 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); |
| 1100 | 1100 |
| 1101 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); | 1101 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); |
| 1102 host_impl_->PinchGestureBegin(); | 1102 host_impl_->PinchGestureBegin(); |
| 1103 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1103 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
| 1104 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); | 1104 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); |
| 1105 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); | 1105 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); |
| 1106 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 1106 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
| 1107 host_impl_->PinchGestureEnd(); | 1107 host_impl_->PinchGestureEnd(); |
| 1108 host_impl_->ScrollEnd(); | 1108 host_impl_->ScrollEnd(); |
| 1109 | 1109 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1127 base::TimeTicks start_time = base::TimeTicks() + | 1127 base::TimeTicks start_time = base::TimeTicks() + |
| 1128 base::TimeDelta::FromSeconds(1); | 1128 base::TimeDelta::FromSeconds(1); |
| 1129 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1129 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 1130 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1130 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 1131 base::TimeTicks end_time = start_time + duration; | 1131 base::TimeTicks end_time = start_time + duration; |
| 1132 | 1132 |
| 1133 // Non-anchor zoom-in | 1133 // Non-anchor zoom-in |
| 1134 { | 1134 { |
| 1135 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1135 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1136 max_page_scale); | 1136 max_page_scale); |
| 1137 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1137 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1138 | 1138 |
| 1139 did_request_redraw_ = false; | 1139 did_request_redraw_ = false; |
| 1140 did_request_animate_ = false; | 1140 did_request_animate_ = false; |
| 1141 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1141 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 1142 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1142 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 1143 gfx::Vector2d(), | 1143 gfx::Vector2d(), |
| 1144 false, | 1144 false, |
| 1145 2.f, | 1145 2.f, |
| 1146 duration))); | 1146 duration))); |
| 1147 host_impl_->ActivateSyncTree(); | 1147 host_impl_->ActivateSyncTree(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1170 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1170 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1171 host_impl_->ProcessScrollDeltas(); | 1171 host_impl_->ProcessScrollDeltas(); |
| 1172 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 1172 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
| 1173 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1173 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
| 1174 } | 1174 } |
| 1175 | 1175 |
| 1176 // Anchor zoom-out | 1176 // Anchor zoom-out |
| 1177 { | 1177 { |
| 1178 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1178 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1179 max_page_scale); | 1179 max_page_scale); |
| 1180 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1180 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1181 | 1181 |
| 1182 did_request_redraw_ = false; | 1182 did_request_redraw_ = false; |
| 1183 did_request_animate_ = false; | 1183 did_request_animate_ = false; |
| 1184 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1184 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 1185 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( | 1185 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( |
| 1186 gfx::Vector2d(25, 25), | 1186 gfx::Vector2d(25, 25), |
| 1187 true, | 1187 true, |
| 1188 min_page_scale, | 1188 min_page_scale, |
| 1189 duration))); | 1189 duration))); |
| 1190 host_impl_->ActivateSyncTree(); | 1190 host_impl_->ActivateSyncTree(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 base::TimeTicks start_time = base::TimeTicks() + | 1226 base::TimeTicks start_time = base::TimeTicks() + |
| 1227 base::TimeDelta::FromSeconds(1); | 1227 base::TimeDelta::FromSeconds(1); |
| 1228 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1228 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 1229 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1229 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 1230 base::TimeTicks end_time = start_time + duration; | 1230 base::TimeTicks end_time = start_time + duration; |
| 1231 | 1231 |
| 1232 // Anchor zoom with unchanged page scale should not change scroll or scale. | 1232 // Anchor zoom with unchanged page scale should not change scroll or scale. |
| 1233 { | 1233 { |
| 1234 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1234 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1235 max_page_scale); | 1235 max_page_scale); |
| 1236 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1236 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1237 | 1237 |
| 1238 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1238 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 1239 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1239 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 1240 gfx::Vector2d(), | 1240 gfx::Vector2d(), |
| 1241 true, | 1241 true, |
| 1242 1.f, | 1242 1.f, |
| 1243 duration))); | 1243 duration))); |
| 1244 host_impl_->ActivateSyncTree(); | 1244 host_impl_->ActivateSyncTree(); |
| 1245 host_impl_->Animate(start_time); | 1245 host_impl_->Animate(start_time); |
| 1246 host_impl_->Animate(halfway_through_animation); | 1246 host_impl_->Animate(halfway_through_animation); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1273 host_impl_->ActivateSyncTree(); | 1273 host_impl_->ActivateSyncTree(); |
| 1274 | 1274 |
| 1275 base::TimeTicks start_time = base::TimeTicks() + | 1275 base::TimeTicks start_time = base::TimeTicks() + |
| 1276 base::TimeDelta::FromSeconds(1); | 1276 base::TimeDelta::FromSeconds(1); |
| 1277 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1277 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 1278 base::TimeTicks third_through_animation = start_time + duration / 3; | 1278 base::TimeTicks third_through_animation = start_time + duration / 3; |
| 1279 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1279 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 1280 base::TimeTicks end_time = start_time + duration; | 1280 base::TimeTicks end_time = start_time + duration; |
| 1281 float target_scale = 2.f; | 1281 float target_scale = 2.f; |
| 1282 | 1282 |
| 1283 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1283 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1284 | 1284 |
| 1285 // Make sure TakePageScaleAnimation works properly. | 1285 // Make sure TakePageScaleAnimation works properly. |
| 1286 | 1286 |
| 1287 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 1287 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
| 1288 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1288 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 1289 gfx::Vector2d(), | 1289 gfx::Vector2d(), |
| 1290 false, | 1290 false, |
| 1291 target_scale, | 1291 target_scale, |
| 1292 duration))); | 1292 duration))); |
| 1293 scoped_ptr<PendingPageScaleAnimation> psa = | 1293 scoped_ptr<PendingPageScaleAnimation> psa = |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1361 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1362 DCHECK(scroll_layer); | 1362 DCHECK(scroll_layer); |
| 1363 | 1363 |
| 1364 base::TimeTicks start_time = | 1364 base::TimeTicks start_time = |
| 1365 base::TimeTicks() + base::TimeDelta::FromSeconds(1); | 1365 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
| 1366 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1366 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 1367 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1367 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 1368 base::TimeTicks end_time = start_time + duration; | 1368 base::TimeTicks end_time = start_time + duration; |
| 1369 | 1369 |
| 1370 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 1370 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 1371 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1371 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1372 | 1372 |
| 1373 did_complete_page_scale_animation_ = false; | 1373 did_complete_page_scale_animation_ = false; |
| 1374 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1374 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 1375 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1375 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 1376 gfx::Vector2d(), false, 2.f, duration))); | 1376 gfx::Vector2d(), false, 2.f, duration))); |
| 1377 host_impl_->ActivateSyncTree(); | 1377 host_impl_->ActivateSyncTree(); |
| 1378 host_impl_->Animate(start_time); | 1378 host_impl_->Animate(start_time); |
| 1379 EXPECT_FALSE(did_complete_page_scale_animation_); | 1379 EXPECT_FALSE(did_complete_page_scale_animation_); |
| 1380 | 1380 |
| 1381 host_impl_->Animate(halfway_through_animation); | 1381 host_impl_->Animate(halfway_through_animation); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 host_impl_->InitializeRenderer(CreateOutputSurface()); \ | 1426 host_impl_->InitializeRenderer(CreateOutputSurface()); \ |
| 1427 host_impl_->SetViewportSize(viewport_size); \ | 1427 host_impl_->SetViewportSize(viewport_size); \ |
| 1428 \ | 1428 \ |
| 1429 scoped_ptr<LayerImpl> root = \ | 1429 scoped_ptr<LayerImpl> root = \ |
| 1430 LayerImpl::Create(host_impl_->active_tree(), 1); \ | 1430 LayerImpl::Create(host_impl_->active_tree(), 1); \ |
| 1431 root->SetBounds(viewport_size); \ | 1431 root->SetBounds(viewport_size); \ |
| 1432 \ | 1432 \ |
| 1433 scoped_ptr<LayerImpl> scroll = \ | 1433 scoped_ptr<LayerImpl> scroll = \ |
| 1434 LayerImpl::Create(host_impl_->active_tree(), 2); \ | 1434 LayerImpl::Create(host_impl_->active_tree(), 2); \ |
| 1435 scroll->SetScrollClipLayer(root->id()); \ | 1435 scroll->SetScrollClipLayer(root->id()); \ |
| 1436 scroll->SetScrollOffset(gfx::ScrollOffset()); \ | 1436 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); \ |
| 1437 root->SetBounds(viewport_size); \ | 1437 root->SetBounds(viewport_size); \ |
| 1438 scroll->SetBounds(content_size); \ | 1438 scroll->SetBounds(content_size); \ |
| 1439 scroll->SetContentBounds(content_size); \ | 1439 scroll->SetContentBounds(content_size); \ |
| 1440 scroll->SetIsContainerForFixedPositionLayers(true); \ | 1440 scroll->SetIsContainerForFixedPositionLayers(true); \ |
| 1441 \ | 1441 \ |
| 1442 scoped_ptr<LayerImpl> contents = \ | 1442 scoped_ptr<LayerImpl> contents = \ |
| 1443 LayerImpl::Create(host_impl_->active_tree(), 3); \ | 1443 LayerImpl::Create(host_impl_->active_tree(), 3); \ |
| 1444 contents->SetDrawsContent(true); \ | 1444 contents->SetDrawsContent(true); \ |
| 1445 contents->SetBounds(content_size); \ | 1445 contents->SetBounds(content_size); \ |
| 1446 contents->SetContentBounds(content_size); \ | 1446 contents->SetContentBounds(content_size); \ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 | 1498 |
| 1499 // After the fade begins, we should start getting redraws instead of a | 1499 // After the fade begins, we should start getting redraws instead of a |
| 1500 // scheduled animation. | 1500 // scheduled animation. |
| 1501 fake_now += base::TimeDelta::FromMilliseconds(25); | 1501 fake_now += base::TimeDelta::FromMilliseconds(25); |
| 1502 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1502 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1503 EXPECT_TRUE(did_request_animate_); | 1503 EXPECT_TRUE(did_request_animate_); |
| 1504 did_request_animate_ = false; | 1504 did_request_animate_ = false; |
| 1505 | 1505 |
| 1506 // Setting the scroll offset outside a scroll should also cause the scrollbar | 1506 // Setting the scroll offset outside a scroll should also cause the scrollbar |
| 1507 // to appear and to schedule a fade. | 1507 // to appear and to schedule a fade. |
| 1508 host_impl_->InnerViewportScrollLayer()->SetScrollOffset( | 1508 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( |
| 1509 gfx::ScrollOffset(5, 5)); | 1509 gfx::ScrollOffset(5, 5)); |
| 1510 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1510 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
| 1511 requested_scrollbar_animation_delay_); | 1511 requested_scrollbar_animation_delay_); |
| 1512 EXPECT_FALSE(did_request_redraw_); | 1512 EXPECT_FALSE(did_request_redraw_); |
| 1513 EXPECT_FALSE(did_request_animate_); | 1513 EXPECT_FALSE(did_request_animate_); |
| 1514 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1514 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
| 1515 | 1515 |
| 1516 // Unnecessarily Fade animation of solid color scrollbar is not triggered. | 1516 // Unnecessarily Fade animation of solid color scrollbar is not triggered. |
| 1517 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1517 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1518 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1518 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 host_impl_->SetViewportSize(device_viewport_size); | 1595 host_impl_->SetViewportSize(device_viewport_size); |
| 1596 | 1596 |
| 1597 scoped_ptr<LayerImpl> root = | 1597 scoped_ptr<LayerImpl> root = |
| 1598 LayerImpl::Create(host_impl_->active_tree(), 1); | 1598 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 1599 root->SetBounds(viewport_size); | 1599 root->SetBounds(viewport_size); |
| 1600 root->SetHasRenderSurface(true); | 1600 root->SetHasRenderSurface(true); |
| 1601 | 1601 |
| 1602 scoped_ptr<LayerImpl> scroll = | 1602 scoped_ptr<LayerImpl> scroll = |
| 1603 LayerImpl::Create(host_impl_->active_tree(), 2); | 1603 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 1604 scroll->SetScrollClipLayer(root->id()); | 1604 scroll->SetScrollClipLayer(root->id()); |
| 1605 scroll->SetScrollOffset(gfx::ScrollOffset()); | 1605 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 1606 scroll->SetBounds(content_size); | 1606 scroll->SetBounds(content_size); |
| 1607 scroll->SetContentBounds(content_size); | 1607 scroll->SetContentBounds(content_size); |
| 1608 scroll->SetIsContainerForFixedPositionLayers(true); | 1608 scroll->SetIsContainerForFixedPositionLayers(true); |
| 1609 | 1609 |
| 1610 scoped_ptr<LayerImpl> contents = | 1610 scoped_ptr<LayerImpl> contents = |
| 1611 LayerImpl::Create(host_impl_->active_tree(), 3); | 1611 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 1612 contents->SetDrawsContent(true); | 1612 contents->SetDrawsContent(true); |
| 1613 contents->SetBounds(content_size); | 1613 contents->SetBounds(content_size); |
| 1614 contents->SetContentBounds(content_size); | 1614 contents->SetContentBounds(content_size); |
| 1615 | 1615 |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2475 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 2475 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 2476 | 2476 |
| 2477 EXPECT_EQ(InputHandler::ScrollStarted, | 2477 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2478 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2478 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2479 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); | 2479 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); |
| 2480 | 2480 |
| 2481 // The entire scroll delta should have been used to hide the top controls. | 2481 // The entire scroll delta should have been used to hide the top controls. |
| 2482 // The viewport layers should be resized back to their full sizes. | 2482 // The viewport layers should be resized back to their full sizes. |
| 2483 EXPECT_EQ(0.f, | 2483 EXPECT_EQ(0.f, |
| 2484 host_impl_->active_tree()->total_top_controls_content_offset()); | 2484 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2485 EXPECT_EQ(0.f, inner_scroll->TotalScrollOffset().y()); | 2485 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 2486 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 2486 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
| 2487 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 2487 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
| 2488 | 2488 |
| 2489 // The inner viewport should be scrollable by 50px * page_scale. | 2489 // The inner viewport should be scrollable by 50px * page_scale. |
| 2490 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); | 2490 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); |
| 2491 EXPECT_EQ(50.f, inner_scroll->TotalScrollOffset().y()); | 2491 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
| 2492 EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y()); | 2492 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 2493 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 2493 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
| 2494 | 2494 |
| 2495 host_impl_->ScrollEnd(); | 2495 host_impl_->ScrollEnd(); |
| 2496 | 2496 |
| 2497 EXPECT_EQ(InputHandler::ScrollStarted, | 2497 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2498 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2498 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2499 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 2499 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 2500 | 2500 |
| 2501 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2501 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); |
| 2502 | 2502 |
| 2503 // The entire scroll delta should have been used to show the top controls. | 2503 // The entire scroll delta should have been used to show the top controls. |
| 2504 // The outer viewport should be resized to accomodate and scrolled to the | 2504 // The outer viewport should be resized to accomodate and scrolled to the |
| 2505 // bottom of the document to keep the viewport in place. | 2505 // bottom of the document to keep the viewport in place. |
| 2506 EXPECT_EQ(50.f, | 2506 EXPECT_EQ(50.f, |
| 2507 host_impl_->active_tree()->total_top_controls_content_offset()); | 2507 host_impl_->active_tree()->total_top_controls_content_offset()); |
| 2508 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 2508 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
| 2509 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 2509 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
| 2510 EXPECT_EQ(25.f, outer_scroll->TotalScrollOffset().y()); | 2510 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
| 2511 EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y()); | 2511 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
| 2512 | 2512 |
| 2513 // Now when we continue scrolling, make sure the outer viewport gets scrolled | 2513 // Now when we continue scrolling, make sure the outer viewport gets scrolled |
| 2514 // since it wasn't scrollable when the scroll began. | 2514 // since it wasn't scrollable when the scroll began. |
| 2515 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); | 2515 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); |
| 2516 EXPECT_EQ(15.f, outer_scroll->TotalScrollOffset().y()); | 2516 EXPECT_EQ(15.f, outer_scroll->CurrentScrollOffset().y()); |
| 2517 EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y()); | 2517 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
| 2518 | 2518 |
| 2519 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f)); | 2519 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f)); |
| 2520 EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y()); | 2520 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 2521 EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y()); | 2521 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
| 2522 | 2522 |
| 2523 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2523 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); |
| 2524 host_impl_->ScrollEnd(); | 2524 host_impl_->ScrollEnd(); |
| 2525 | 2525 |
| 2526 EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y()); | 2526 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 2527 EXPECT_EQ(0.f, inner_scroll->TotalScrollOffset().y()); | 2527 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 2528 } | 2528 } |
| 2529 | 2529 |
| 2530 // Test that the fixed position container delta is appropriately adjusted | 2530 // Test that the fixed position container delta is appropriately adjusted |
| 2531 // by the top controls showing/hiding and page scale doesn't affect it. | 2531 // by the top controls showing/hiding and page scale doesn't affect it. |
| 2532 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { | 2532 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { |
| 2533 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2533 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2534 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); | 2534 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); |
| 2535 DrawFrame(); | 2535 DrawFrame(); |
| 2536 | 2536 |
| 2537 float page_scale = 1.5f; | 2537 float page_scale = 1.5f; |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3304 scoped_ptr<LayerImpl> child = | 3304 scoped_ptr<LayerImpl> child = |
| 3305 CreateScrollableLayer(2, content_size, root.get()); | 3305 CreateScrollableLayer(2, content_size, root.get()); |
| 3306 LayerImpl* grand_child_layer = grand_child.get(); | 3306 LayerImpl* grand_child_layer = grand_child.get(); |
| 3307 child->AddChild(grand_child.Pass()); | 3307 child->AddChild(grand_child.Pass()); |
| 3308 | 3308 |
| 3309 LayerImpl* child_layer = child.get(); | 3309 LayerImpl* child_layer = child.get(); |
| 3310 root->AddChild(child.Pass()); | 3310 root->AddChild(child.Pass()); |
| 3311 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3311 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3312 host_impl_->active_tree()->DidBecomeActive(); | 3312 host_impl_->active_tree()->DidBecomeActive(); |
| 3313 host_impl_->SetViewportSize(surface_size); | 3313 host_impl_->SetViewportSize(surface_size); |
| 3314 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 5)); | 3314 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); |
| 3315 child_layer->SetScrollOffset(gfx::ScrollOffset(3, 0)); | 3315 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); |
| 3316 | 3316 |
| 3317 DrawFrame(); | 3317 DrawFrame(); |
| 3318 { | 3318 { |
| 3319 gfx::Vector2d scroll_delta(-8, -7); | 3319 gfx::Vector2d scroll_delta(-8, -7); |
| 3320 EXPECT_EQ(InputHandler::ScrollStarted, | 3320 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3321 host_impl_->ScrollBegin(gfx::Point(), | 3321 host_impl_->ScrollBegin(gfx::Point(), |
| 3322 InputHandler::Wheel)); | 3322 InputHandler::Wheel)); |
| 3323 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3323 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3324 host_impl_->ScrollEnd(); | 3324 host_impl_->ScrollEnd(); |
| 3325 | 3325 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3358 LayerImpl* child_layer = child.get(); | 3358 LayerImpl* child_layer = child.get(); |
| 3359 root_scrolling->AddChild(child.Pass()); | 3359 root_scrolling->AddChild(child.Pass()); |
| 3360 root->AddChild(root_scrolling.Pass()); | 3360 root->AddChild(root_scrolling.Pass()); |
| 3361 EXPECT_EQ(viewport_size, root->bounds()); | 3361 EXPECT_EQ(viewport_size, root->bounds()); |
| 3362 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3362 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3363 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 3363 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
| 3364 Layer::INVALID_ID); | 3364 Layer::INVALID_ID); |
| 3365 host_impl_->active_tree()->DidBecomeActive(); | 3365 host_impl_->active_tree()->DidBecomeActive(); |
| 3366 host_impl_->SetViewportSize(viewport_size); | 3366 host_impl_->SetViewportSize(viewport_size); |
| 3367 | 3367 |
| 3368 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 3368 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
| 3369 child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3)); | 3369 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
| 3370 | 3370 |
| 3371 DrawFrame(); | 3371 DrawFrame(); |
| 3372 { | 3372 { |
| 3373 gfx::Vector2d scroll_delta(0, -10); | 3373 gfx::Vector2d scroll_delta(0, -10); |
| 3374 EXPECT_EQ(InputHandler::ScrollStarted, | 3374 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3375 host_impl_->ScrollBegin(gfx::Point(), | 3375 host_impl_->ScrollBegin(gfx::Point(), |
| 3376 InputHandler::NonBubblingGesture)); | 3376 InputHandler::NonBubblingGesture)); |
| 3377 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3377 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3378 host_impl_->ScrollEnd(); | 3378 host_impl_->ScrollEnd(); |
| 3379 | 3379 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3787 | 3787 |
| 3788 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 3788 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
| 3789 TestScrollOffsetDelegate scroll_delegate; | 3789 TestScrollOffsetDelegate scroll_delegate; |
| 3790 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 3790 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
| 3791 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 3791 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 3792 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 3792 LayerImpl* clip_layer = scroll_layer->parent()->parent(); |
| 3793 clip_layer->SetBounds(gfx::Size(10, 20)); | 3793 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 3794 | 3794 |
| 3795 // Setting the delegate results in the current scroll offset being set. | 3795 // Setting the delegate results in the current scroll offset being set. |
| 3796 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 3796 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
| 3797 scroll_layer->SetScrollOffset(gfx::ScrollOffset()); | 3797 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 3798 scroll_layer->SetScrollDelta(initial_scroll_delta); | 3798 scroll_layer->SetScrollDelta(initial_scroll_delta); |
| 3799 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); | 3799 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); |
| 3800 EXPECT_EQ(initial_scroll_delta.ToString(), | 3800 EXPECT_EQ(initial_scroll_delta.ToString(), |
| 3801 scroll_delegate.last_set_scroll_offset().ToString()); | 3801 scroll_delegate.last_set_scroll_offset().ToString()); |
| 3802 | 3802 |
| 3803 // Setting the delegate results in the scrollable_size, max_scroll_offset, | 3803 // Setting the delegate results in the scrollable_size, max_scroll_offset, |
| 3804 // page_scale_factor and {min|max}_page_scale_factor being set. | 3804 // page_scale_factor and {min|max}_page_scale_factor being set. |
| 3805 EXPECT_EQ(gfx::SizeF(100, 100), scroll_delegate.scrollable_size()); | 3805 EXPECT_EQ(gfx::SizeF(100, 100), scroll_delegate.scrollable_size()); |
| 3806 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_delegate.max_scroll_offset()); | 3806 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_delegate.max_scroll_offset()); |
| 3807 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); | 3807 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3861 host_impl_->ActivateSyncTree(); | 3861 host_impl_->ActivateSyncTree(); |
| 3862 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); | 3862 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); |
| 3863 | 3863 |
| 3864 // Un-setting the delegate should propagate the delegate's current offset to | 3864 // Un-setting the delegate should propagate the delegate's current offset to |
| 3865 // the root scrollable layer. | 3865 // the root scrollable layer. |
| 3866 current_offset = gfx::ScrollOffset(13.f, 12.f); | 3866 current_offset = gfx::ScrollOffset(13.f, 12.f); |
| 3867 scroll_delegate.set_getter_return_value(current_offset); | 3867 scroll_delegate.set_getter_return_value(current_offset); |
| 3868 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); | 3868 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); |
| 3869 | 3869 |
| 3870 EXPECT_EQ(current_offset.ToString(), | 3870 EXPECT_EQ(current_offset.ToString(), |
| 3871 scroll_layer->TotalScrollOffset().ToString()); | 3871 scroll_layer->CurrentScrollOffset().ToString()); |
| 3872 } | 3872 } |
| 3873 | 3873 |
| 3874 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { | 3874 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { |
| 3875 const gfx::Transform target_space_transform = | 3875 const gfx::Transform target_space_transform = |
| 3876 layer->draw_properties().target_space_transform; | 3876 layer->draw_properties().target_space_transform; |
| 3877 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); | 3877 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); |
| 3878 gfx::Point translated_point; | 3878 gfx::Point translated_point; |
| 3879 target_space_transform.TransformPoint(&translated_point); | 3879 target_space_transform.TransformPoint(&translated_point); |
| 3880 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); | 3880 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); |
| 3881 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); | 3881 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4040 CreateScrollableLayer(3, surface_size, root_clip.get()); | 4040 CreateScrollableLayer(3, surface_size, root_clip.get()); |
| 4041 | 4041 |
| 4042 scoped_ptr<LayerImpl> child = | 4042 scoped_ptr<LayerImpl> child = |
| 4043 CreateScrollableLayer(2, surface_size, root_clip.get()); | 4043 CreateScrollableLayer(2, surface_size, root_clip.get()); |
| 4044 LayerImpl* grand_child_layer = grand_child.get(); | 4044 LayerImpl* grand_child_layer = grand_child.get(); |
| 4045 child->AddChild(grand_child.Pass()); | 4045 child->AddChild(grand_child.Pass()); |
| 4046 | 4046 |
| 4047 LayerImpl* child_layer = child.get(); | 4047 LayerImpl* child_layer = child.get(); |
| 4048 root->AddChild(child.Pass()); | 4048 root->AddChild(child.Pass()); |
| 4049 root_clip->AddChild(root.Pass()); | 4049 root_clip->AddChild(root.Pass()); |
| 4050 child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3)); | 4050 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
| 4051 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 4051 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
| 4052 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4052 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 4053 host_impl_->active_tree()->DidBecomeActive(); | 4053 host_impl_->active_tree()->DidBecomeActive(); |
| 4054 host_impl_->SetViewportSize(surface_size); | 4054 host_impl_->SetViewportSize(surface_size); |
| 4055 DrawFrame(); | 4055 DrawFrame(); |
| 4056 { | 4056 { |
| 4057 gfx::Vector2d scroll_delta(0, -10); | 4057 gfx::Vector2d scroll_delta(0, -10); |
| 4058 EXPECT_EQ(InputHandler::ScrollStarted, | 4058 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4059 host_impl_->ScrollBegin(gfx::Point(), | 4059 host_impl_->ScrollBegin(gfx::Point(), |
| 4060 InputHandler::NonBubblingGesture)); | 4060 InputHandler::NonBubblingGesture)); |
| 4061 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4061 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6265 3, pile); | 6265 3, pile); |
| 6266 LayerImpl* content_layer = scoped_content_layer.get(); | 6266 LayerImpl* content_layer = scoped_content_layer.get(); |
| 6267 scrolling_layer->AddChild(scoped_content_layer.Pass()); | 6267 scrolling_layer->AddChild(scoped_content_layer.Pass()); |
| 6268 content_layer->SetBounds(content_layer_bounds); | 6268 content_layer->SetBounds(content_layer_bounds); |
| 6269 content_layer->SetDrawsContent(true); | 6269 content_layer->SetDrawsContent(true); |
| 6270 | 6270 |
| 6271 root->SetBounds(root_size); | 6271 root->SetBounds(root_size); |
| 6272 | 6272 |
| 6273 gfx::ScrollOffset scroll_offset(100000, 0); | 6273 gfx::ScrollOffset scroll_offset(100000, 0); |
| 6274 scrolling_layer->SetScrollClipLayer(root->id()); | 6274 scrolling_layer->SetScrollClipLayer(root->id()); |
| 6275 scrolling_layer->SetScrollOffset(scroll_offset); | 6275 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); |
| 6276 | 6276 |
| 6277 host_impl_->ActivateSyncTree(); | 6277 host_impl_->ActivateSyncTree(); |
| 6278 | 6278 |
| 6279 host_impl_->active_tree()->UpdateDrawProperties(); | 6279 host_impl_->active_tree()->UpdateDrawProperties(); |
| 6280 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 6280 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
| 6281 | 6281 |
| 6282 LayerTreeHostImpl::FrameData frame; | 6282 LayerTreeHostImpl::FrameData frame; |
| 6283 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6283 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6284 | 6284 |
| 6285 ASSERT_EQ(1u, frame.render_passes.size()); | 6285 ASSERT_EQ(1u, frame.render_passes.size()); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6793 // Scroll a child layer beyond its maximum scroll range and make sure the | 6793 // Scroll a child layer beyond its maximum scroll range and make sure the |
| 6794 // the scroll doesn't bubble up to the parent layer. | 6794 // the scroll doesn't bubble up to the parent layer. |
| 6795 gfx::Size surface_size(10, 10); | 6795 gfx::Size surface_size(10, 10); |
| 6796 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6796 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 6797 root->SetHasRenderSurface(true); | 6797 root->SetHasRenderSurface(true); |
| 6798 scoped_ptr<LayerImpl> root_scrolling = | 6798 scoped_ptr<LayerImpl> root_scrolling = |
| 6799 CreateScrollableLayer(2, surface_size, root.get()); | 6799 CreateScrollableLayer(2, surface_size, root.get()); |
| 6800 | 6800 |
| 6801 scoped_ptr<LayerImpl> grand_child = | 6801 scoped_ptr<LayerImpl> grand_child = |
| 6802 CreateScrollableLayer(4, surface_size, root.get()); | 6802 CreateScrollableLayer(4, surface_size, root.get()); |
| 6803 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 6803 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
| 6804 | 6804 |
| 6805 scoped_ptr<LayerImpl> child = | 6805 scoped_ptr<LayerImpl> child = |
| 6806 CreateScrollableLayer(3, surface_size, root.get()); | 6806 CreateScrollableLayer(3, surface_size, root.get()); |
| 6807 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); | 6807 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); |
| 6808 child->AddChild(grand_child.Pass()); | 6808 child->AddChild(grand_child.Pass()); |
| 6809 | 6809 |
| 6810 root_scrolling->AddChild(child.Pass()); | 6810 root_scrolling->AddChild(child.Pass()); |
| 6811 root->AddChild(root_scrolling.Pass()); | 6811 root->AddChild(root_scrolling.Pass()); |
| 6812 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6812 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 6813 host_impl_->active_tree()->DidBecomeActive(); | 6813 host_impl_->active_tree()->DidBecomeActive(); |
| 6814 host_impl_->SetViewportSize(surface_size); | 6814 host_impl_->SetViewportSize(surface_size); |
| 6815 DrawFrame(); | 6815 DrawFrame(); |
| 6816 { | 6816 { |
| 6817 scoped_ptr<ScrollAndScaleSet> scroll_info; | 6817 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7289 } | 7289 } |
| 7290 | 7290 |
| 7291 protected: | 7291 protected: |
| 7292 static const int top_controls_height_; | 7292 static const int top_controls_height_; |
| 7293 }; | 7293 }; |
| 7294 | 7294 |
| 7295 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 7295 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; |
| 7296 | 7296 |
| 7297 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { | 7297 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { |
| 7298 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7298 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
| 7299 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); | 7299 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); |
| 7300 host_impl_->Animate(base::TimeTicks()); | 7300 host_impl_->Animate(base::TimeTicks()); |
| 7301 EXPECT_FALSE(did_request_redraw_); | 7301 EXPECT_FALSE(did_request_redraw_); |
| 7302 } | 7302 } |
| 7303 | 7303 |
| 7304 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { | 7304 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { |
| 7305 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7305 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 7306 EXPECT_FALSE(did_request_redraw_); | 7306 EXPECT_FALSE(did_request_redraw_); |
| 7307 host_impl_->CreatePendingTree(); | 7307 host_impl_->CreatePendingTree(); |
| 7308 host_impl_->sync_tree()->set_top_controls_height(100); | 7308 host_impl_->sync_tree()->set_top_controls_height(100); |
| 7309 host_impl_->ActivateSyncTree(); | 7309 host_impl_->ActivateSyncTree(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7321 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7321 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
| 7322 | 7322 |
| 7323 host_impl_->CreatePendingTree(); | 7323 host_impl_->CreatePendingTree(); |
| 7324 host_impl_->sync_tree()->set_top_controls_height(50); | 7324 host_impl_->sync_tree()->set_top_controls_height(50); |
| 7325 host_impl_->ActivateSyncTree(); | 7325 host_impl_->ActivateSyncTree(); |
| 7326 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7326 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
| 7327 } | 7327 } |
| 7328 | 7328 |
| 7329 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { | 7329 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { |
| 7330 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7330 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
| 7331 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); | 7331 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); |
| 7332 host_impl_->DidChangeTopControlsPosition(); | 7332 host_impl_->DidChangeTopControlsPosition(); |
| 7333 EXPECT_TRUE(did_request_animate_); | 7333 EXPECT_TRUE(did_request_animate_); |
| 7334 EXPECT_TRUE(did_request_redraw_); | 7334 EXPECT_TRUE(did_request_redraw_); |
| 7335 } | 7335 } |
| 7336 | 7336 |
| 7337 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 7337 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
| 7338 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7338 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7339 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7339 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 7340 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7340 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 7341 BOTH, SHOWN, false); | 7341 BOTH, SHOWN, false); |
| 7342 DrawFrame(); | 7342 DrawFrame(); |
| 7343 | 7343 |
| 7344 EXPECT_EQ(InputHandler::ScrollStarted, | 7344 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7345 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7345 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7346 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7346 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7347 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7347 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7348 scroll_layer->TotalScrollOffset().ToString()); | 7348 scroll_layer->CurrentScrollOffset().ToString()); |
| 7349 | 7349 |
| 7350 // Scroll just the top controls and verify that the scroll succeeds. | 7350 // Scroll just the top controls and verify that the scroll succeeds. |
| 7351 const float residue = 10; | 7351 const float residue = 10; |
| 7352 float offset = top_controls_height_ - residue; | 7352 float offset = top_controls_height_ - residue; |
| 7353 EXPECT_TRUE( | 7353 EXPECT_TRUE( |
| 7354 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7354 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7355 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7355 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7356 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7356 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7357 scroll_layer->TotalScrollOffset().ToString()); | 7357 scroll_layer->CurrentScrollOffset().ToString()); |
| 7358 | 7358 |
| 7359 // Scroll across the boundary | 7359 // Scroll across the boundary |
| 7360 const float content_scroll = 20; | 7360 const float content_scroll = 20; |
| 7361 offset = residue + content_scroll; | 7361 offset = residue + content_scroll; |
| 7362 EXPECT_TRUE( | 7362 EXPECT_TRUE( |
| 7363 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7363 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7364 EXPECT_EQ(-top_controls_height_, | 7364 EXPECT_EQ(-top_controls_height_, |
| 7365 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7365 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7366 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), | 7366 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), |
| 7367 scroll_layer->TotalScrollOffset().ToString()); | 7367 scroll_layer->CurrentScrollOffset().ToString()); |
| 7368 | 7368 |
| 7369 // Now scroll back to the top of the content | 7369 // Now scroll back to the top of the content |
| 7370 offset = -content_scroll; | 7370 offset = -content_scroll; |
| 7371 EXPECT_TRUE( | 7371 EXPECT_TRUE( |
| 7372 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7372 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7373 EXPECT_EQ(-top_controls_height_, | 7373 EXPECT_EQ(-top_controls_height_, |
| 7374 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7374 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7375 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7375 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7376 scroll_layer->TotalScrollOffset().ToString()); | 7376 scroll_layer->CurrentScrollOffset().ToString()); |
| 7377 | 7377 |
| 7378 // And scroll the top controls completely into view | 7378 // And scroll the top controls completely into view |
| 7379 offset = -top_controls_height_; | 7379 offset = -top_controls_height_; |
| 7380 EXPECT_TRUE( | 7380 EXPECT_TRUE( |
| 7381 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7381 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7382 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7382 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7383 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7383 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7384 scroll_layer->TotalScrollOffset().ToString()); | 7384 scroll_layer->CurrentScrollOffset().ToString()); |
| 7385 | 7385 |
| 7386 // And attempt to scroll past the end | 7386 // And attempt to scroll past the end |
| 7387 EXPECT_FALSE( | 7387 EXPECT_FALSE( |
| 7388 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7388 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7389 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7389 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7390 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7390 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7391 scroll_layer->TotalScrollOffset().ToString()); | 7391 scroll_layer->CurrentScrollOffset().ToString()); |
| 7392 | 7392 |
| 7393 host_impl_->ScrollEnd(); | 7393 host_impl_->ScrollEnd(); |
| 7394 } | 7394 } |
| 7395 | 7395 |
| 7396 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 7396 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
| 7397 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7397 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7398 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 7398 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
| 7399 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7399 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 7400 BOTH, SHOWN, false); | 7400 BOTH, SHOWN, false); |
| 7401 DrawFrame(); | 7401 DrawFrame(); |
| 7402 | 7402 |
| 7403 EXPECT_EQ(InputHandler::ScrollStarted, | 7403 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7404 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7404 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7405 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7405 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7406 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7406 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7407 scroll_layer->TotalScrollOffset().ToString()); | 7407 scroll_layer->CurrentScrollOffset().ToString()); |
| 7408 | 7408 |
| 7409 // Scroll the top controls partially. | 7409 // Scroll the top controls partially. |
| 7410 const float residue = 35; | 7410 const float residue = 35; |
| 7411 float offset = top_controls_height_ - residue; | 7411 float offset = top_controls_height_ - residue; |
| 7412 EXPECT_TRUE( | 7412 EXPECT_TRUE( |
| 7413 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7413 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7414 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7414 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7415 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7415 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7416 scroll_layer->TotalScrollOffset().ToString()); | 7416 scroll_layer->CurrentScrollOffset().ToString()); |
| 7417 | 7417 |
| 7418 did_request_redraw_ = false; | 7418 did_request_redraw_ = false; |
| 7419 did_request_animate_ = false; | 7419 did_request_animate_ = false; |
| 7420 did_request_commit_ = false; | 7420 did_request_commit_ = false; |
| 7421 | 7421 |
| 7422 // End the scroll while the controls are still offset from their limit. | 7422 // End the scroll while the controls are still offset from their limit. |
| 7423 host_impl_->ScrollEnd(); | 7423 host_impl_->ScrollEnd(); |
| 7424 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 7424 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 7425 EXPECT_TRUE(did_request_animate_); | 7425 EXPECT_TRUE(did_request_animate_); |
| 7426 EXPECT_TRUE(did_request_redraw_); | 7426 EXPECT_TRUE(did_request_redraw_); |
| 7427 EXPECT_FALSE(did_request_commit_); | 7427 EXPECT_FALSE(did_request_commit_); |
| 7428 | 7428 |
| 7429 // The top controls should properly animate until finished, despite the scroll | 7429 // The top controls should properly animate until finished, despite the scroll |
| 7430 // offset being at the origin. | 7430 // offset being at the origin. |
| 7431 base::TimeTicks animation_time = gfx::FrameTime::Now(); | 7431 base::TimeTicks animation_time = gfx::FrameTime::Now(); |
| 7432 while (did_request_animate_) { | 7432 while (did_request_animate_) { |
| 7433 did_request_redraw_ = false; | 7433 did_request_redraw_ = false; |
| 7434 did_request_animate_ = false; | 7434 did_request_animate_ = false; |
| 7435 did_request_commit_ = false; | 7435 did_request_commit_ = false; |
| 7436 | 7436 |
| 7437 float old_offset = | 7437 float old_offset = |
| 7438 host_impl_->top_controls_manager()->ControlsTopOffset(); | 7438 host_impl_->top_controls_manager()->ControlsTopOffset(); |
| 7439 | 7439 |
| 7440 animation_time += base::TimeDelta::FromMilliseconds(5); | 7440 animation_time += base::TimeDelta::FromMilliseconds(5); |
| 7441 host_impl_->Animate(animation_time); | 7441 host_impl_->Animate(animation_time); |
| 7442 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7442 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7443 scroll_layer->TotalScrollOffset().ToString()); | 7443 scroll_layer->CurrentScrollOffset().ToString()); |
| 7444 | 7444 |
| 7445 float new_offset = | 7445 float new_offset = |
| 7446 host_impl_->top_controls_manager()->ControlsTopOffset(); | 7446 host_impl_->top_controls_manager()->ControlsTopOffset(); |
| 7447 | 7447 |
| 7448 // No commit is needed as the controls are animating the content offset, | 7448 // No commit is needed as the controls are animating the content offset, |
| 7449 // not the scroll offset. | 7449 // not the scroll offset. |
| 7450 EXPECT_FALSE(did_request_commit_); | 7450 EXPECT_FALSE(did_request_commit_); |
| 7451 | 7451 |
| 7452 if (new_offset != old_offset) | 7452 if (new_offset != old_offset) |
| 7453 EXPECT_TRUE(did_request_redraw_); | 7453 EXPECT_TRUE(did_request_redraw_); |
| 7454 | 7454 |
| 7455 if (new_offset != 0) { | 7455 if (new_offset != 0) { |
| 7456 EXPECT_TRUE(host_impl_->top_controls_manager()->animation()); | 7456 EXPECT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 7457 EXPECT_TRUE(did_request_animate_); | 7457 EXPECT_TRUE(did_request_animate_); |
| 7458 } | 7458 } |
| 7459 } | 7459 } |
| 7460 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); | 7460 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); |
| 7461 } | 7461 } |
| 7462 | 7462 |
| 7463 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { | 7463 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
| 7464 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7464 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7465 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7465 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 7466 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7466 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 7467 BOTH, SHOWN, false); | 7467 BOTH, SHOWN, false); |
| 7468 float initial_scroll_offset = 50; | 7468 float initial_scroll_offset = 50; |
| 7469 scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, initial_scroll_offset)); | 7469 scroll_layer->PushScrollOffsetFromMainThread( |
| 7470 gfx::ScrollOffset(0, initial_scroll_offset)); |
| 7470 DrawFrame(); | 7471 DrawFrame(); |
| 7471 | 7472 |
| 7472 EXPECT_EQ(InputHandler::ScrollStarted, | 7473 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7473 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7474 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7474 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7475 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7475 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7476 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 7476 scroll_layer->TotalScrollOffset().ToString()); | 7477 scroll_layer->CurrentScrollOffset().ToString()); |
| 7477 | 7478 |
| 7478 // Scroll the top controls partially. | 7479 // Scroll the top controls partially. |
| 7479 const float residue = 15; | 7480 const float residue = 15; |
| 7480 float offset = top_controls_height_ - residue; | 7481 float offset = top_controls_height_ - residue; |
| 7481 EXPECT_TRUE( | 7482 EXPECT_TRUE( |
| 7482 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7483 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7483 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7484 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7484 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7485 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 7485 scroll_layer->TotalScrollOffset().ToString()); | 7486 scroll_layer->CurrentScrollOffset().ToString()); |
| 7486 | 7487 |
| 7487 did_request_redraw_ = false; | 7488 did_request_redraw_ = false; |
| 7488 did_request_animate_ = false; | 7489 did_request_animate_ = false; |
| 7489 did_request_commit_ = false; | 7490 did_request_commit_ = false; |
| 7490 | 7491 |
| 7491 // End the scroll while the controls are still offset from the limit. | 7492 // End the scroll while the controls are still offset from the limit. |
| 7492 host_impl_->ScrollEnd(); | 7493 host_impl_->ScrollEnd(); |
| 7493 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 7494 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
| 7494 EXPECT_TRUE(did_request_animate_); | 7495 EXPECT_TRUE(did_request_animate_); |
| 7495 EXPECT_TRUE(did_request_redraw_); | 7496 EXPECT_TRUE(did_request_redraw_); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7532 | 7533 |
| 7533 EXPECT_EQ(InputHandler::ScrollStarted, | 7534 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7534 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7535 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7535 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7536 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7536 | 7537 |
| 7537 float offset = 50; | 7538 float offset = 50; |
| 7538 EXPECT_TRUE( | 7539 EXPECT_TRUE( |
| 7539 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7540 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7540 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7541 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7541 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7542 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7542 scroll_layer->TotalScrollOffset().ToString()); | 7543 scroll_layer->CurrentScrollOffset().ToString()); |
| 7543 | 7544 |
| 7544 EXPECT_TRUE( | 7545 EXPECT_TRUE( |
| 7545 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7546 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7546 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | 7547 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
| 7547 scroll_layer->TotalScrollOffset().ToString()); | 7548 scroll_layer->CurrentScrollOffset().ToString()); |
| 7548 | 7549 |
| 7549 EXPECT_TRUE( | 7550 EXPECT_TRUE( |
| 7550 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7551 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7551 | 7552 |
| 7552 // Should have fully scrolled | 7553 // Should have fully scrolled |
| 7553 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), | 7554 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), |
| 7554 scroll_layer->TotalScrollOffset().ToString()); | 7555 scroll_layer->CurrentScrollOffset().ToString()); |
| 7555 | 7556 |
| 7556 float overscrollamount = 10; | 7557 float overscrollamount = 10; |
| 7557 | 7558 |
| 7558 // Overscroll the content | 7559 // Overscroll the content |
| 7559 EXPECT_FALSE( | 7560 EXPECT_FALSE( |
| 7560 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) | 7561 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) |
| 7561 .did_scroll); | 7562 .did_scroll); |
| 7562 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), | 7563 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), |
| 7563 scroll_layer->TotalScrollOffset().ToString()); | 7564 scroll_layer->CurrentScrollOffset().ToString()); |
| 7564 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | 7565 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
| 7565 host_impl_->accumulated_root_overscroll().ToString()); | 7566 host_impl_->accumulated_root_overscroll().ToString()); |
| 7566 | 7567 |
| 7567 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) | 7568 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) |
| 7568 .did_scroll); | 7569 .did_scroll); |
| 7569 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 7570 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
| 7570 scroll_layer->TotalScrollOffset().ToString()); | 7571 scroll_layer->CurrentScrollOffset().ToString()); |
| 7571 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7572 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7572 | 7573 |
| 7573 EXPECT_TRUE( | 7574 EXPECT_TRUE( |
| 7574 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); | 7575 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); |
| 7575 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 7576 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
| 7576 scroll_layer->TotalScrollOffset().ToString()); | 7577 scroll_layer->CurrentScrollOffset().ToString()); |
| 7577 | 7578 |
| 7578 // Top controls should be fully visible | 7579 // Top controls should be fully visible |
| 7579 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7580 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7580 | 7581 |
| 7581 host_impl_->ScrollEnd(); | 7582 host_impl_->ScrollEnd(); |
| 7582 } | 7583 } |
| 7583 | 7584 |
| 7584 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { | 7585 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
| 7585 public: | 7586 public: |
| 7586 void SetupVirtualViewportLayers(const gfx::Size& content_size, | 7587 void SetupVirtualViewportLayers(const gfx::Size& content_size, |
| 7587 const gfx::Size& outer_viewport, | 7588 const gfx::Size& outer_viewport, |
| 7588 const gfx::Size& inner_viewport) { | 7589 const gfx::Size& inner_viewport) { |
| 7589 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 7590 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
| 7590 const int kOuterViewportClipLayerId = 6; | 7591 const int kOuterViewportClipLayerId = 6; |
| 7591 const int kOuterViewportScrollLayerId = 7; | 7592 const int kOuterViewportScrollLayerId = 7; |
| 7592 const int kInnerViewportScrollLayerId = 2; | 7593 const int kInnerViewportScrollLayerId = 2; |
| 7593 const int kInnerViewportClipLayerId = 4; | 7594 const int kInnerViewportClipLayerId = 4; |
| 7594 const int kPageScaleLayerId = 5; | 7595 const int kPageScaleLayerId = 5; |
| 7595 | 7596 |
| 7596 scoped_ptr<LayerImpl> inner_scroll = | 7597 scoped_ptr<LayerImpl> inner_scroll = |
| 7597 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 7598 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
| 7598 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 7599 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
| 7599 inner_scroll->SetScrollOffset(gfx::ScrollOffset()); | 7600 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 7600 | 7601 |
| 7601 scoped_ptr<LayerImpl> inner_clip = | 7602 scoped_ptr<LayerImpl> inner_clip = |
| 7602 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 7603 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
| 7603 inner_clip->SetBounds(inner_viewport); | 7604 inner_clip->SetBounds(inner_viewport); |
| 7604 | 7605 |
| 7605 scoped_ptr<LayerImpl> page_scale = | 7606 scoped_ptr<LayerImpl> page_scale = |
| 7606 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 7607 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
| 7607 | 7608 |
| 7608 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 7609 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
| 7609 inner_scroll->SetBounds(outer_viewport); | 7610 inner_scroll->SetBounds(outer_viewport); |
| 7610 inner_scroll->SetContentBounds(outer_viewport); | 7611 inner_scroll->SetContentBounds(outer_viewport); |
| 7611 inner_scroll->SetPosition(gfx::PointF()); | 7612 inner_scroll->SetPosition(gfx::PointF()); |
| 7612 | 7613 |
| 7613 scoped_ptr<LayerImpl> outer_clip = | 7614 scoped_ptr<LayerImpl> outer_clip = |
| 7614 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 7615 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); |
| 7615 outer_clip->SetBounds(outer_viewport); | 7616 outer_clip->SetBounds(outer_viewport); |
| 7616 outer_clip->SetIsContainerForFixedPositionLayers(true); | 7617 outer_clip->SetIsContainerForFixedPositionLayers(true); |
| 7617 | 7618 |
| 7618 scoped_ptr<LayerImpl> outer_scroll = | 7619 scoped_ptr<LayerImpl> outer_scroll = |
| 7619 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 7620 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); |
| 7620 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 7621 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
| 7621 outer_scroll->SetScrollOffset(gfx::ScrollOffset()); | 7622 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 7622 outer_scroll->SetBounds(content_size); | 7623 outer_scroll->SetBounds(content_size); |
| 7623 outer_scroll->SetContentBounds(content_size); | 7624 outer_scroll->SetContentBounds(content_size); |
| 7624 outer_scroll->SetPosition(gfx::PointF()); | 7625 outer_scroll->SetPosition(gfx::PointF()); |
| 7625 | 7626 |
| 7626 scoped_ptr<LayerImpl> contents = | 7627 scoped_ptr<LayerImpl> contents = |
| 7627 LayerImpl::Create(layer_tree_impl, 8); | 7628 LayerImpl::Create(layer_tree_impl, 8); |
| 7628 contents->SetDrawsContent(true); | 7629 contents->SetDrawsContent(true); |
| 7629 contents->SetBounds(content_size); | 7630 contents->SetBounds(content_size); |
| 7630 contents->SetContentBounds(content_size); | 7631 contents->SetContentBounds(content_size); |
| 7631 contents->SetPosition(gfx::PointF()); | 7632 contents->SetPosition(gfx::PointF()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7652 gfx::Size inner_viewport = gfx::Size(25, 40); | 7653 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 7653 | 7654 |
| 7654 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7655 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 7655 | 7656 |
| 7656 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7657 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 7657 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7658 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 7658 DrawFrame(); | 7659 DrawFrame(); |
| 7659 { | 7660 { |
| 7660 gfx::Vector2dF inner_expected; | 7661 gfx::Vector2dF inner_expected; |
| 7661 gfx::Vector2dF outer_expected; | 7662 gfx::Vector2dF outer_expected; |
| 7662 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7663 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7663 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7664 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7664 | 7665 |
| 7665 // Make sure the fling goes to the outer viewport first | 7666 // Make sure the fling goes to the outer viewport first |
| 7666 EXPECT_EQ(InputHandler::ScrollStarted, | 7667 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7667 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7668 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7668 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 7669 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7669 | 7670 |
| 7670 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7671 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
| 7671 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7672 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7672 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7673 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7673 | 7674 |
| 7674 host_impl_->ScrollEnd(); | 7675 host_impl_->ScrollEnd(); |
| 7675 | 7676 |
| 7676 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7677 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7677 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7678 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7678 | 7679 |
| 7679 // Fling past the outer viewport boundry, make sure inner viewport scrolls. | 7680 // Fling past the outer viewport boundry, make sure inner viewport scrolls. |
| 7680 EXPECT_EQ(InputHandler::ScrollStarted, | 7681 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7681 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7682 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7682 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 7683 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7683 | 7684 |
| 7684 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7685 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7685 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7686 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7686 | 7687 |
| 7687 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7688 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7688 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7689 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7689 | 7690 |
| 7690 host_impl_->ScrollEnd(); | 7691 host_impl_->ScrollEnd(); |
| 7691 | 7692 |
| 7692 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7693 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7693 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7694 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7694 } | 7695 } |
| 7695 } | 7696 } |
| 7696 | 7697 |
| 7697 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7698 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 7698 DiagonalScrollBubblesPerfectlyToInner) { | 7699 DiagonalScrollBubblesPerfectlyToInner) { |
| 7699 gfx::Size content_size = gfx::Size(100, 160); | 7700 gfx::Size content_size = gfx::Size(100, 160); |
| 7700 gfx::Size outer_viewport = gfx::Size(50, 80); | 7701 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 7701 gfx::Size inner_viewport = gfx::Size(25, 40); | 7702 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 7702 | 7703 |
| 7703 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7704 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 7704 | 7705 |
| 7705 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7706 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 7706 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7707 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 7707 DrawFrame(); | 7708 DrawFrame(); |
| 7708 { | 7709 { |
| 7709 gfx::Vector2dF inner_expected; | 7710 gfx::Vector2dF inner_expected; |
| 7710 gfx::Vector2dF outer_expected; | 7711 gfx::Vector2dF outer_expected; |
| 7711 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7712 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7712 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7713 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7713 | 7714 |
| 7714 // Make sure the scroll goes to the outer viewport first. | 7715 // Make sure the scroll goes to the outer viewport first. |
| 7715 EXPECT_EQ(InputHandler::ScrollStarted, | 7716 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7716 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7717 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7717 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 7718 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7718 | 7719 |
| 7719 // Scroll near the edge of the outer viewport. | 7720 // Scroll near the edge of the outer viewport. |
| 7720 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7721 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
| 7721 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7722 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7722 outer_expected += scroll_delta; | 7723 outer_expected += scroll_delta; |
| 7723 | 7724 |
| 7724 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7725 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7725 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7726 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7726 | 7727 |
| 7727 // Now diagonal scroll across the outer viewport boundary in a single event. | 7728 // Now diagonal scroll across the outer viewport boundary in a single event. |
| 7728 // The entirety of the scroll should be consumed, as bubbling between inner | 7729 // The entirety of the scroll should be consumed, as bubbling between inner |
| 7729 // and outer viewport layers is perfect. | 7730 // and outer viewport layers is perfect. |
| 7730 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); | 7731 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); |
| 7731 outer_expected += scroll_delta; | 7732 outer_expected += scroll_delta; |
| 7732 inner_expected += scroll_delta; | 7733 inner_expected += scroll_delta; |
| 7733 host_impl_->ScrollEnd(); | 7734 host_impl_->ScrollEnd(); |
| 7734 | 7735 |
| 7735 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7736 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7736 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7737 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7737 } | 7738 } |
| 7738 } | 7739 } |
| 7739 | 7740 |
| 7740 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7741 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 7741 TouchFlingCanLockToViewportLayerAfterBubbling) { | 7742 TouchFlingCanLockToViewportLayerAfterBubbling) { |
| 7742 gfx::Size content_size = gfx::Size(100, 160); | 7743 gfx::Size content_size = gfx::Size(100, 160); |
| 7743 gfx::Size outer_viewport = gfx::Size(50, 80); | 7744 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 7744 gfx::Size inner_viewport = gfx::Size(25, 40); | 7745 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 7745 | 7746 |
| 7746 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7747 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7847 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 7848 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 7848 | 7849 |
| 7849 EXPECT_EQ(InputHandler::ScrollStarted, | 7850 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7850 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 7851 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
| 7851 | 7852 |
| 7852 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 7853 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 7853 | 7854 |
| 7854 host_impl_->Animate(start_time); | 7855 host_impl_->Animate(start_time); |
| 7855 host_impl_->UpdateAnimationState(true); | 7856 host_impl_->UpdateAnimationState(true); |
| 7856 | 7857 |
| 7857 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->TotalScrollOffset()); | 7858 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 7858 | 7859 |
| 7859 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); | 7860 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); |
| 7860 host_impl_->UpdateAnimationState(true); | 7861 host_impl_->UpdateAnimationState(true); |
| 7861 | 7862 |
| 7862 float y = scrolling_layer->TotalScrollOffset().y(); | 7863 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 7863 EXPECT_TRUE(y > 1 && y < 49); | 7864 EXPECT_TRUE(y > 1 && y < 49); |
| 7864 | 7865 |
| 7865 // Update target. | 7866 // Update target. |
| 7866 EXPECT_EQ(InputHandler::ScrollStarted, | 7867 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7867 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 7868 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
| 7868 | 7869 |
| 7869 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); | 7870 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); |
| 7870 host_impl_->UpdateAnimationState(true); | 7871 host_impl_->UpdateAnimationState(true); |
| 7871 | 7872 |
| 7872 y = scrolling_layer->TotalScrollOffset().y(); | 7873 y = scrolling_layer->CurrentScrollOffset().y(); |
| 7873 EXPECT_TRUE(y > 50 && y < 100); | 7874 EXPECT_TRUE(y > 50 && y < 100); |
| 7874 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 7875 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
| 7875 | 7876 |
| 7876 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 7877 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
| 7877 host_impl_->UpdateAnimationState(true); | 7878 host_impl_->UpdateAnimationState(true); |
| 7878 | 7879 |
| 7879 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 7880 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 7880 scrolling_layer->TotalScrollOffset()); | 7881 scrolling_layer->CurrentScrollOffset()); |
| 7881 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 7882 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 7882 } | 7883 } |
| 7883 | 7884 |
| 7884 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 7885 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
| 7885 host_impl_->CreatePendingTree(); | 7886 host_impl_->CreatePendingTree(); |
| 7886 | 7887 |
| 7887 scoped_ptr<PictureLayerImpl> layer = | 7888 scoped_ptr<PictureLayerImpl> layer = |
| 7888 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); | 7889 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); |
| 7889 layer->SetBounds(gfx::Size(10, 10)); | 7890 layer->SetBounds(gfx::Size(10, 10)); |
| 7890 | 7891 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8021 float page_scale_delta = 2.f; | 8022 float page_scale_delta = 2.f; |
| 8022 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 8023 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 8023 host_impl_->PinchGestureBegin(); | 8024 host_impl_->PinchGestureBegin(); |
| 8024 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 8025 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 8025 host_impl_->PinchGestureEnd(); | 8026 host_impl_->PinchGestureEnd(); |
| 8026 host_impl_->ScrollEnd(); | 8027 host_impl_->ScrollEnd(); |
| 8027 | 8028 |
| 8028 gfx::Vector2dF scroll_delta(0, 5); | 8029 gfx::Vector2dF scroll_delta(0, 5); |
| 8029 EXPECT_EQ(InputHandler::ScrollStarted, | 8030 EXPECT_EQ(InputHandler::ScrollStarted, |
| 8030 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 8031 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 8031 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 8032 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 8032 | 8033 |
| 8033 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8034 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 8034 host_impl_->ScrollEnd(); | 8035 host_impl_->ScrollEnd(); |
| 8035 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), scroll_layer->TotalScrollOffset()); | 8036 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
| 8037 scroll_layer->CurrentScrollOffset()); |
| 8036 } | 8038 } |
| 8037 } | 8039 } |
| 8038 | 8040 |
| 8039 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 8041 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
| 8040 public: | 8042 public: |
| 8041 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} | 8043 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} |
| 8042 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } | 8044 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } |
| 8043 | 8045 |
| 8044 protected: | 8046 protected: |
| 8045 int num_lost_surfaces_; | 8047 int num_lost_surfaces_; |
| 8046 }; | 8048 }; |
| 8047 | 8049 |
| 8048 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { | 8050 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { |
| 8049 // Really we just need at least one client notification each time | 8051 // Really we just need at least one client notification each time |
| 8050 // we go from having a valid output surface to not having a valid output | 8052 // we go from having a valid output surface to not having a valid output |
| 8051 // surface. | 8053 // surface. |
| 8052 EXPECT_EQ(0, num_lost_surfaces_); | 8054 EXPECT_EQ(0, num_lost_surfaces_); |
| 8053 host_impl_->DidLoseOutputSurface(); | 8055 host_impl_->DidLoseOutputSurface(); |
| 8054 EXPECT_EQ(1, num_lost_surfaces_); | 8056 EXPECT_EQ(1, num_lost_surfaces_); |
| 8055 host_impl_->DidLoseOutputSurface(); | 8057 host_impl_->DidLoseOutputSurface(); |
| 8056 EXPECT_LE(1, num_lost_surfaces_); | 8058 EXPECT_LE(1, num_lost_surfaces_); |
| 8057 } | 8059 } |
| 8058 | 8060 |
| 8059 } // namespace | 8061 } // namespace |
| 8060 } // namespace cc | 8062 } // namespace cc |
| OLD | NEW |