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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 LayerImpl::Create(layer_tree_impl, 1); | 226 LayerImpl::Create(layer_tree_impl, 1); |
227 root->SetBounds(content_size); | 227 root->SetBounds(content_size); |
228 root->SetContentBounds(content_size); | 228 root->SetContentBounds(content_size); |
229 root->SetPosition(gfx::PointF()); | 229 root->SetPosition(gfx::PointF()); |
230 root->SetHasRenderSurface(true); | 230 root->SetHasRenderSurface(true); |
231 | 231 |
232 scoped_ptr<LayerImpl> scroll = | 232 scoped_ptr<LayerImpl> scroll = |
233 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 233 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
234 LayerImpl* scroll_layer = scroll.get(); | 234 LayerImpl* scroll_layer = scroll.get(); |
235 scroll->SetIsContainerForFixedPositionLayers(true); | 235 scroll->SetIsContainerForFixedPositionLayers(true); |
236 scroll->SetScrollOffset(gfx::ScrollOffset()); | 236 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
237 | 237 |
238 scoped_ptr<LayerImpl> clip = | 238 scoped_ptr<LayerImpl> clip = |
239 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 239 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
240 clip->SetBounds( | 240 clip->SetBounds( |
241 gfx::Size(content_size.width() / 2, content_size.height() / 2)); | 241 gfx::Size(content_size.width() / 2, content_size.height() / 2)); |
242 | 242 |
243 scoped_ptr<LayerImpl> page_scale = | 243 scoped_ptr<LayerImpl> page_scale = |
244 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 244 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
245 | 245 |
246 scroll->SetScrollClipLayer(clip->id()); | 246 scroll->SetScrollClipLayer(clip->id()); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 { | 461 { |
462 scoped_ptr<LayerImpl> root_clip = | 462 scoped_ptr<LayerImpl> root_clip = |
463 LayerImpl::Create(host_impl_->active_tree(), 2); | 463 LayerImpl::Create(host_impl_->active_tree(), 2); |
464 scoped_ptr<LayerImpl> root = | 464 scoped_ptr<LayerImpl> root = |
465 LayerImpl::Create(host_impl_->active_tree(), 1); | 465 LayerImpl::Create(host_impl_->active_tree(), 1); |
466 root_clip->SetBounds(gfx::Size(10, 10)); | 466 root_clip->SetBounds(gfx::Size(10, 10)); |
467 LayerImpl* root_layer = root.get(); | 467 LayerImpl* root_layer = root.get(); |
468 root_clip->AddChild(root.Pass()); | 468 root_clip->AddChild(root.Pass()); |
469 root_layer->SetBounds(gfx::Size(110, 110)); | 469 root_layer->SetBounds(gfx::Size(110, 110)); |
470 root_layer->SetScrollClipLayer(root_clip->id()); | 470 root_layer->SetScrollClipLayer(root_clip->id()); |
471 root_layer->SetScrollOffset(scroll_offset); | 471 root_layer->PushScrollOffsetFromMainThread(scroll_offset); |
472 root_layer->ScrollBy(scroll_delta); | 472 root_layer->ScrollBy(scroll_delta); |
473 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 473 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
474 } | 474 } |
475 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; | 475 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; |
476 | 476 |
477 scoped_ptr<ScrollAndScaleSet> scroll_info; | 477 scoped_ptr<ScrollAndScaleSet> scroll_info; |
478 | 478 |
479 scroll_info = host_impl_->ProcessScrollDeltas(); | 479 scroll_info = host_impl_->ProcessScrollDeltas(); |
480 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 480 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
481 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), scroll_delta); | |
482 ExpectContains(*scroll_info, root->id(), scroll_delta); | 481 ExpectContains(*scroll_info, root->id(), scroll_delta); |
483 | 482 |
484 gfx::Vector2d scroll_delta2(-5, 27); | 483 gfx::Vector2d scroll_delta2(-5, 27); |
485 root->ScrollBy(scroll_delta2); | 484 root->ScrollBy(scroll_delta2); |
486 scroll_info = host_impl_->ProcessScrollDeltas(); | 485 scroll_info = host_impl_->ProcessScrollDeltas(); |
487 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 486 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
488 EXPECT_VECTOR_EQ(root->sent_scroll_delta(), scroll_delta + scroll_delta2); | |
489 ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2); | 487 ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2); |
490 | 488 |
491 root->ScrollBy(gfx::Vector2d()); | 489 root->ScrollBy(gfx::Vector2d()); |
492 scroll_info = host_impl_->ProcessScrollDeltas(); | 490 scroll_info = host_impl_->ProcessScrollDeltas(); |
493 EXPECT_EQ(root->sent_scroll_delta(), scroll_delta + scroll_delta2); | 491 ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2); |
494 } | 492 } |
495 | 493 |
496 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { | 494 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { |
497 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 495 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
498 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 496 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
499 DrawFrame(); | 497 DrawFrame(); |
500 | 498 |
501 EXPECT_EQ(InputHandler::ScrollStarted, | 499 EXPECT_EQ(InputHandler::ScrollStarted, |
502 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 500 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
503 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 501 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 834 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
837 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 835 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
838 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 836 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
839 | 837 |
840 gfx::Size overflow_size(400, 400); | 838 gfx::Size overflow_size(400, 400); |
841 ASSERT_EQ(1u, scroll_layer->children().size()); | 839 ASSERT_EQ(1u, scroll_layer->children().size()); |
842 LayerImpl* overflow = scroll_layer->children()[0]; | 840 LayerImpl* overflow = scroll_layer->children()[0]; |
843 overflow->SetBounds(overflow_size); | 841 overflow->SetBounds(overflow_size); |
844 overflow->SetContentBounds(overflow_size); | 842 overflow->SetContentBounds(overflow_size); |
845 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); | 843 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); |
846 overflow->SetScrollOffset(gfx::ScrollOffset()); | 844 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
847 overflow->SetPosition(gfx::PointF()); | 845 overflow->SetPosition(gfx::PointF()); |
848 | 846 |
849 DrawFrame(); | 847 DrawFrame(); |
850 gfx::Point scroll_position(10, 10); | 848 gfx::Point scroll_position(10, 10); |
851 | 849 |
852 EXPECT_EQ(InputHandler::ScrollStarted, | 850 EXPECT_EQ(InputHandler::ScrollStarted, |
853 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 851 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
854 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 852 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
855 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset()); | 853 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
856 | 854 |
857 gfx::Vector2dF scroll_delta(10, 10); | 855 gfx::Vector2dF scroll_delta(10, 10); |
858 host_impl_->ScrollBy(scroll_position, scroll_delta); | 856 host_impl_->ScrollBy(scroll_position, scroll_delta); |
859 host_impl_->ScrollEnd(); | 857 host_impl_->ScrollEnd(); |
860 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 858 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
861 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset()); | 859 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
862 | 860 |
863 overflow->set_user_scrollable_horizontal(false); | 861 overflow->set_user_scrollable_horizontal(false); |
864 | 862 |
865 EXPECT_EQ(InputHandler::ScrollStarted, | 863 EXPECT_EQ(InputHandler::ScrollStarted, |
866 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 864 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
867 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 865 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
868 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->TotalScrollOffset()); | 866 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
869 | 867 |
870 host_impl_->ScrollBy(scroll_position, scroll_delta); | 868 host_impl_->ScrollBy(scroll_position, scroll_delta); |
871 host_impl_->ScrollEnd(); | 869 host_impl_->ScrollEnd(); |
872 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 870 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
873 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 871 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
874 | 872 |
875 overflow->set_user_scrollable_vertical(false); | 873 overflow->set_user_scrollable_vertical(false); |
876 | 874 |
877 EXPECT_EQ(InputHandler::ScrollStarted, | 875 EXPECT_EQ(InputHandler::ScrollStarted, |
878 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); | 876 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
879 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->TotalScrollOffset()); | 877 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
880 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 878 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
881 | 879 |
882 host_impl_->ScrollBy(scroll_position, scroll_delta); | 880 host_impl_->ScrollBy(scroll_position, scroll_delta); |
883 host_impl_->ScrollEnd(); | 881 host_impl_->ScrollEnd(); |
884 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->TotalScrollOffset()); | 882 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); |
885 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->TotalScrollOffset()); | 883 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
886 } | 884 } |
887 | 885 |
888 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 886 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
889 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 887 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
890 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 888 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
891 DrawFrame(); | 889 DrawFrame(); |
892 | 890 |
893 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); | 891 EXPECT_EQ(scroll_layer, host_impl_->InnerViewportScrollLayer()); |
894 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); | 892 LayerImpl* container_layer = scroll_layer->scroll_clip_layer(); |
895 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 893 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1017 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1020 host_impl_->ProcessScrollDeltas(); | 1018 host_impl_->ProcessScrollDeltas(); |
1021 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); | 1019 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); |
1022 } | 1020 } |
1023 | 1021 |
1024 // Zoom-out clamping | 1022 // Zoom-out clamping |
1025 { | 1023 { |
1026 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1024 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1027 max_page_scale); | 1025 max_page_scale); |
1028 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1026 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1029 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1027 scroll_layer->PullDeltaForMainThread(); |
| 1028 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
1030 | 1029 |
1031 float page_scale_delta = 0.1f; | 1030 float page_scale_delta = 0.1f; |
1032 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 1031 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
1033 host_impl_->PinchGestureBegin(); | 1032 host_impl_->PinchGestureBegin(); |
1034 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1033 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
1035 host_impl_->PinchGestureEnd(); | 1034 host_impl_->PinchGestureEnd(); |
1036 host_impl_->ScrollEnd(); | 1035 host_impl_->ScrollEnd(); |
1037 | 1036 |
1038 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1037 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1039 host_impl_->ProcessScrollDeltas(); | 1038 host_impl_->ProcessScrollDeltas(); |
1040 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 1039 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
1041 | 1040 |
1042 EXPECT_TRUE(scroll_info->scrolls.empty()); | 1041 EXPECT_TRUE(scroll_info->scrolls.empty()); |
1043 } | 1042 } |
1044 | 1043 |
1045 // Two-finger panning should not happen based on pinch events only | 1044 // Two-finger panning should not happen based on pinch events only |
1046 { | 1045 { |
1047 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1046 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1048 max_page_scale); | 1047 max_page_scale); |
1049 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1048 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1050 scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20)); | 1049 scroll_layer->PullDeltaForMainThread(); |
| 1050 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
1051 | 1051 |
1052 float page_scale_delta = 1.f; | 1052 float page_scale_delta = 1.f; |
1053 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); | 1053 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); |
1054 host_impl_->PinchGestureBegin(); | 1054 host_impl_->PinchGestureBegin(); |
1055 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1055 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
1056 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1056 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
1057 host_impl_->PinchGestureEnd(); | 1057 host_impl_->PinchGestureEnd(); |
1058 host_impl_->ScrollEnd(); | 1058 host_impl_->ScrollEnd(); |
1059 | 1059 |
1060 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1060 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1061 host_impl_->ProcessScrollDeltas(); | 1061 host_impl_->ProcessScrollDeltas(); |
1062 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1062 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
1063 EXPECT_TRUE(scroll_info->scrolls.empty()); | 1063 EXPECT_TRUE(scroll_info->scrolls.empty()); |
1064 } | 1064 } |
1065 | 1065 |
1066 // Two-finger panning should work with interleaved scroll events | 1066 // Two-finger panning should work with interleaved scroll events |
1067 { | 1067 { |
1068 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1068 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1069 max_page_scale); | 1069 max_page_scale); |
1070 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1070 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1071 scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20)); | 1071 scroll_layer->PullDeltaForMainThread(); |
| 1072 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
1072 | 1073 |
1073 float page_scale_delta = 1.f; | 1074 float page_scale_delta = 1.f; |
1074 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); | 1075 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); |
1075 host_impl_->PinchGestureBegin(); | 1076 host_impl_->PinchGestureBegin(); |
1076 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1077 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
1077 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 1078 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
1078 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1079 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
1079 host_impl_->PinchGestureEnd(); | 1080 host_impl_->PinchGestureEnd(); |
1080 host_impl_->ScrollEnd(); | 1081 host_impl_->ScrollEnd(); |
1081 | 1082 |
1082 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1083 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1083 host_impl_->ProcessScrollDeltas(); | 1084 host_impl_->ProcessScrollDeltas(); |
1084 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1085 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
1085 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); | 1086 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); |
1086 } | 1087 } |
1087 | 1088 |
1088 // Two-finger panning should work when starting fully zoomed out. | 1089 // Two-finger panning should work when starting fully zoomed out. |
1089 { | 1090 { |
1090 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); | 1091 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); |
1091 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1092 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
1092 scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 1093 scroll_layer->PullDeltaForMainThread(); |
| 1094 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); |
1093 | 1095 |
1094 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); | 1096 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); |
1095 host_impl_->PinchGestureBegin(); | 1097 host_impl_->PinchGestureBegin(); |
1096 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1098 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
1097 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); | 1099 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); |
1098 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); | 1100 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); |
1099 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 1101 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
1100 host_impl_->PinchGestureEnd(); | 1102 host_impl_->PinchGestureEnd(); |
1101 host_impl_->ScrollEnd(); | 1103 host_impl_->ScrollEnd(); |
1102 | 1104 |
(...skipping 17 matching lines...) Expand all Loading... |
1120 base::TimeTicks start_time = base::TimeTicks() + | 1122 base::TimeTicks start_time = base::TimeTicks() + |
1121 base::TimeDelta::FromSeconds(1); | 1123 base::TimeDelta::FromSeconds(1); |
1122 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1124 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
1123 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1125 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1124 base::TimeTicks end_time = start_time + duration; | 1126 base::TimeTicks end_time = start_time + duration; |
1125 | 1127 |
1126 // Non-anchor zoom-in | 1128 // Non-anchor zoom-in |
1127 { | 1129 { |
1128 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1130 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1129 max_page_scale); | 1131 max_page_scale); |
1130 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1132 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
1131 | 1133 |
1132 did_request_redraw_ = false; | 1134 did_request_redraw_ = false; |
1133 did_request_animate_ = false; | 1135 did_request_animate_ = false; |
1134 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1136 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
1135 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1137 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
1136 gfx::Vector2d(), | 1138 gfx::Vector2d(), |
1137 false, | 1139 false, |
1138 2.f, | 1140 2.f, |
1139 duration))); | 1141 duration))); |
1140 host_impl_->ActivateSyncTree(); | 1142 host_impl_->ActivateSyncTree(); |
(...skipping 22 matching lines...) Expand all Loading... |
1163 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1165 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1164 host_impl_->ProcessScrollDeltas(); | 1166 host_impl_->ProcessScrollDeltas(); |
1165 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 1167 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
1166 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1168 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1167 } | 1169 } |
1168 | 1170 |
1169 // Anchor zoom-out | 1171 // Anchor zoom-out |
1170 { | 1172 { |
1171 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1173 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1172 max_page_scale); | 1174 max_page_scale); |
1173 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1175 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
1174 | 1176 |
1175 did_request_redraw_ = false; | 1177 did_request_redraw_ = false; |
1176 did_request_animate_ = false; | 1178 did_request_animate_ = false; |
1177 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1179 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
1178 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( | 1180 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( |
1179 gfx::Vector2d(25, 25), | 1181 gfx::Vector2d(25, 25), |
1180 true, | 1182 true, |
1181 min_page_scale, | 1183 min_page_scale, |
1182 duration))); | 1184 duration))); |
1183 host_impl_->ActivateSyncTree(); | 1185 host_impl_->ActivateSyncTree(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 base::TimeTicks start_time = base::TimeTicks() + | 1221 base::TimeTicks start_time = base::TimeTicks() + |
1220 base::TimeDelta::FromSeconds(1); | 1222 base::TimeDelta::FromSeconds(1); |
1221 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1223 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
1222 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1224 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1223 base::TimeTicks end_time = start_time + duration; | 1225 base::TimeTicks end_time = start_time + duration; |
1224 | 1226 |
1225 // Anchor zoom with unchanged page scale should not change scroll or scale. | 1227 // Anchor zoom with unchanged page scale should not change scroll or scale. |
1226 { | 1228 { |
1227 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1229 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
1228 max_page_scale); | 1230 max_page_scale); |
1229 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1231 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
1230 | 1232 |
1231 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1233 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
1232 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1234 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
1233 gfx::Vector2d(), | 1235 gfx::Vector2d(), |
1234 true, | 1236 true, |
1235 1.f, | 1237 1.f, |
1236 duration))); | 1238 duration))); |
1237 host_impl_->ActivateSyncTree(); | 1239 host_impl_->ActivateSyncTree(); |
1238 host_impl_->Animate(start_time); | 1240 host_impl_->Animate(start_time); |
1239 host_impl_->Animate(halfway_through_animation); | 1241 host_impl_->Animate(halfway_through_animation); |
(...skipping 26 matching lines...) Expand all Loading... |
1266 host_impl_->ActivateSyncTree(); | 1268 host_impl_->ActivateSyncTree(); |
1267 | 1269 |
1268 base::TimeTicks start_time = base::TimeTicks() + | 1270 base::TimeTicks start_time = base::TimeTicks() + |
1269 base::TimeDelta::FromSeconds(1); | 1271 base::TimeDelta::FromSeconds(1); |
1270 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1272 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
1271 base::TimeTicks third_through_animation = start_time + duration / 3; | 1273 base::TimeTicks third_through_animation = start_time + duration / 3; |
1272 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1274 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1273 base::TimeTicks end_time = start_time + duration; | 1275 base::TimeTicks end_time = start_time + duration; |
1274 float target_scale = 2.f; | 1276 float target_scale = 2.f; |
1275 | 1277 |
1276 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1278 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
1277 | 1279 |
1278 // Make sure TakePageScaleAnimation works properly. | 1280 // Make sure TakePageScaleAnimation works properly. |
1279 | 1281 |
1280 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 1282 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
1281 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1283 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
1282 gfx::Vector2d(), | 1284 gfx::Vector2d(), |
1283 false, | 1285 false, |
1284 target_scale, | 1286 target_scale, |
1285 duration))); | 1287 duration))); |
1286 scoped_ptr<PendingPageScaleAnimation> psa = | 1288 scoped_ptr<PendingPageScaleAnimation> psa = |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1356 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
1355 DCHECK(scroll_layer); | 1357 DCHECK(scroll_layer); |
1356 | 1358 |
1357 base::TimeTicks start_time = | 1359 base::TimeTicks start_time = |
1358 base::TimeTicks() + base::TimeDelta::FromSeconds(1); | 1360 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
1359 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 1361 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
1360 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1362 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1361 base::TimeTicks end_time = start_time + duration; | 1363 base::TimeTicks end_time = start_time + duration; |
1362 | 1364 |
1363 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 1365 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
1364 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50)); | 1366 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
1365 | 1367 |
1366 did_complete_page_scale_animation_ = false; | 1368 did_complete_page_scale_animation_ = false; |
1367 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 1369 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
1368 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 1370 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
1369 gfx::Vector2d(), false, 2.f, duration))); | 1371 gfx::Vector2d(), false, 2.f, duration))); |
1370 host_impl_->ActivateSyncTree(); | 1372 host_impl_->ActivateSyncTree(); |
1371 host_impl_->Animate(start_time); | 1373 host_impl_->Animate(start_time); |
1372 EXPECT_FALSE(did_complete_page_scale_animation_); | 1374 EXPECT_FALSE(did_complete_page_scale_animation_); |
1373 | 1375 |
1374 host_impl_->Animate(halfway_through_animation); | 1376 host_impl_->Animate(halfway_through_animation); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 host_impl_->InitializeRenderer(CreateOutputSurface()); \ | 1421 host_impl_->InitializeRenderer(CreateOutputSurface()); \ |
1420 host_impl_->SetViewportSize(viewport_size); \ | 1422 host_impl_->SetViewportSize(viewport_size); \ |
1421 \ | 1423 \ |
1422 scoped_ptr<LayerImpl> root = \ | 1424 scoped_ptr<LayerImpl> root = \ |
1423 LayerImpl::Create(host_impl_->active_tree(), 1); \ | 1425 LayerImpl::Create(host_impl_->active_tree(), 1); \ |
1424 root->SetBounds(viewport_size); \ | 1426 root->SetBounds(viewport_size); \ |
1425 \ | 1427 \ |
1426 scoped_ptr<LayerImpl> scroll = \ | 1428 scoped_ptr<LayerImpl> scroll = \ |
1427 LayerImpl::Create(host_impl_->active_tree(), 2); \ | 1429 LayerImpl::Create(host_impl_->active_tree(), 2); \ |
1428 scroll->SetScrollClipLayer(root->id()); \ | 1430 scroll->SetScrollClipLayer(root->id()); \ |
1429 scroll->SetScrollOffset(gfx::ScrollOffset()); \ | 1431 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); \ |
1430 root->SetBounds(viewport_size); \ | 1432 root->SetBounds(viewport_size); \ |
1431 scroll->SetBounds(content_size); \ | 1433 scroll->SetBounds(content_size); \ |
1432 scroll->SetContentBounds(content_size); \ | 1434 scroll->SetContentBounds(content_size); \ |
1433 scroll->SetIsContainerForFixedPositionLayers(true); \ | 1435 scroll->SetIsContainerForFixedPositionLayers(true); \ |
1434 \ | 1436 \ |
1435 scoped_ptr<LayerImpl> contents = \ | 1437 scoped_ptr<LayerImpl> contents = \ |
1436 LayerImpl::Create(host_impl_->active_tree(), 3); \ | 1438 LayerImpl::Create(host_impl_->active_tree(), 3); \ |
1437 contents->SetDrawsContent(true); \ | 1439 contents->SetDrawsContent(true); \ |
1438 contents->SetBounds(content_size); \ | 1440 contents->SetBounds(content_size); \ |
1439 contents->SetContentBounds(content_size); \ | 1441 contents->SetContentBounds(content_size); \ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 | 1493 |
1492 // After the fade begins, we should start getting redraws instead of a | 1494 // After the fade begins, we should start getting redraws instead of a |
1493 // scheduled animation. | 1495 // scheduled animation. |
1494 fake_now += base::TimeDelta::FromMilliseconds(25); | 1496 fake_now += base::TimeDelta::FromMilliseconds(25); |
1495 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1497 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1496 EXPECT_TRUE(did_request_animate_); | 1498 EXPECT_TRUE(did_request_animate_); |
1497 did_request_animate_ = false; | 1499 did_request_animate_ = false; |
1498 | 1500 |
1499 // Setting the scroll offset outside a scroll should also cause the scrollbar | 1501 // Setting the scroll offset outside a scroll should also cause the scrollbar |
1500 // to appear and to schedule a fade. | 1502 // to appear and to schedule a fade. |
1501 host_impl_->InnerViewportScrollLayer()->SetScrollOffset( | 1503 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( |
1502 gfx::ScrollOffset(5, 5)); | 1504 gfx::ScrollOffset(5, 5)); |
1503 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1505 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1504 requested_scrollbar_animation_delay_); | 1506 requested_scrollbar_animation_delay_); |
1505 EXPECT_FALSE(did_request_redraw_); | 1507 EXPECT_FALSE(did_request_redraw_); |
1506 EXPECT_FALSE(did_request_animate_); | 1508 EXPECT_FALSE(did_request_animate_); |
1507 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1509 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1508 | 1510 |
1509 // Unnecessarily Fade animation of solid color scrollbar is not triggered. | 1511 // Unnecessarily Fade animation of solid color scrollbar is not triggered. |
1510 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1512 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1511 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1513 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 host_impl_->SetViewportSize(device_viewport_size); | 1590 host_impl_->SetViewportSize(device_viewport_size); |
1589 | 1591 |
1590 scoped_ptr<LayerImpl> root = | 1592 scoped_ptr<LayerImpl> root = |
1591 LayerImpl::Create(host_impl_->active_tree(), 1); | 1593 LayerImpl::Create(host_impl_->active_tree(), 1); |
1592 root->SetBounds(viewport_size); | 1594 root->SetBounds(viewport_size); |
1593 root->SetHasRenderSurface(true); | 1595 root->SetHasRenderSurface(true); |
1594 | 1596 |
1595 scoped_ptr<LayerImpl> scroll = | 1597 scoped_ptr<LayerImpl> scroll = |
1596 LayerImpl::Create(host_impl_->active_tree(), 2); | 1598 LayerImpl::Create(host_impl_->active_tree(), 2); |
1597 scroll->SetScrollClipLayer(root->id()); | 1599 scroll->SetScrollClipLayer(root->id()); |
1598 scroll->SetScrollOffset(gfx::ScrollOffset()); | 1600 scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
1599 scroll->SetBounds(content_size); | 1601 scroll->SetBounds(content_size); |
1600 scroll->SetContentBounds(content_size); | 1602 scroll->SetContentBounds(content_size); |
1601 scroll->SetIsContainerForFixedPositionLayers(true); | 1603 scroll->SetIsContainerForFixedPositionLayers(true); |
1602 | 1604 |
1603 scoped_ptr<LayerImpl> contents = | 1605 scoped_ptr<LayerImpl> contents = |
1604 LayerImpl::Create(host_impl_->active_tree(), 3); | 1606 LayerImpl::Create(host_impl_->active_tree(), 3); |
1605 contents->SetDrawsContent(true); | 1607 contents->SetDrawsContent(true); |
1606 contents->SetBounds(content_size); | 1608 contents->SetBounds(content_size); |
1607 contents->SetContentBounds(content_size); | 1609 contents->SetContentBounds(content_size); |
1608 | 1610 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 2470 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
2469 | 2471 |
2470 EXPECT_EQ(InputHandler::ScrollStarted, | 2472 EXPECT_EQ(InputHandler::ScrollStarted, |
2471 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2473 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
2472 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); | 2474 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); |
2473 | 2475 |
2474 // The entire scroll delta should have been used to hide the top controls. | 2476 // The entire scroll delta should have been used to hide the top controls. |
2475 // The viewport layers should be resized back to their full sizes. | 2477 // The viewport layers should be resized back to their full sizes. |
2476 EXPECT_EQ(0.f, | 2478 EXPECT_EQ(0.f, |
2477 host_impl_->active_tree()->total_top_controls_content_offset()); | 2479 host_impl_->active_tree()->total_top_controls_content_offset()); |
2478 EXPECT_EQ(0.f, inner_scroll->TotalScrollOffset().y()); | 2480 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
2479 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 2481 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
2480 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 2482 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
2481 | 2483 |
2482 // The inner viewport should be scrollable by 50px * page_scale. | 2484 // The inner viewport should be scrollable by 50px * page_scale. |
2483 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); | 2485 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); |
2484 EXPECT_EQ(50.f, inner_scroll->TotalScrollOffset().y()); | 2486 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
2485 EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y()); | 2487 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
2486 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 2488 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
2487 | 2489 |
2488 host_impl_->ScrollEnd(); | 2490 host_impl_->ScrollEnd(); |
2489 | 2491 |
2490 EXPECT_EQ(InputHandler::ScrollStarted, | 2492 EXPECT_EQ(InputHandler::ScrollStarted, |
2491 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 2493 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
2492 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 2494 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
2493 | 2495 |
2494 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2496 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); |
2495 | 2497 |
2496 // The entire scroll delta should have been used to show the top controls. | 2498 // The entire scroll delta should have been used to show the top controls. |
2497 // The outer viewport should be resized to accomodate and scrolled to the | 2499 // The outer viewport should be resized to accomodate and scrolled to the |
2498 // bottom of the document to keep the viewport in place. | 2500 // bottom of the document to keep the viewport in place. |
2499 EXPECT_EQ(50.f, | 2501 EXPECT_EQ(50.f, |
2500 host_impl_->active_tree()->total_top_controls_content_offset()); | 2502 host_impl_->active_tree()->total_top_controls_content_offset()); |
2501 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 2503 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
2502 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 2504 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
2503 EXPECT_EQ(25.f, outer_scroll->TotalScrollOffset().y()); | 2505 EXPECT_EQ(25.f, outer_scroll->CurrentScrollOffset().y()); |
2504 EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y()); | 2506 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
2505 | 2507 |
2506 // Now when we continue scrolling, make sure the outer viewport gets scrolled | 2508 // Now when we continue scrolling, make sure the outer viewport gets scrolled |
2507 // since it wasn't scrollable when the scroll began. | 2509 // since it wasn't scrollable when the scroll began. |
2508 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); | 2510 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -20.f)); |
2509 EXPECT_EQ(15.f, outer_scroll->TotalScrollOffset().y()); | 2511 EXPECT_EQ(15.f, outer_scroll->CurrentScrollOffset().y()); |
2510 EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y()); | 2512 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
2511 | 2513 |
2512 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f)); | 2514 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -30.f)); |
2513 EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y()); | 2515 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
2514 EXPECT_EQ(25.f, inner_scroll->TotalScrollOffset().y()); | 2516 EXPECT_EQ(25.f, inner_scroll->CurrentScrollOffset().y()); |
2515 | 2517 |
2516 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2518 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); |
2517 host_impl_->ScrollEnd(); | 2519 host_impl_->ScrollEnd(); |
2518 | 2520 |
2519 EXPECT_EQ(0.f, outer_scroll->TotalScrollOffset().y()); | 2521 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
2520 EXPECT_EQ(0.f, inner_scroll->TotalScrollOffset().y()); | 2522 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
2521 } | 2523 } |
2522 | 2524 |
2523 // Test that the fixed position container delta is appropriately adjusted | 2525 // Test that the fixed position container delta is appropriately adjusted |
2524 // by the top controls showing/hiding and page scale doesn't affect it. | 2526 // by the top controls showing/hiding and page scale doesn't affect it. |
2525 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { | 2527 TEST_F(LayerTreeHostImplTopControlsTest, FixedContainerDelta) { |
2526 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2528 SetupTopControlsAndScrollLayerWithVirtualViewport( |
2527 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); | 2529 gfx::Size(100, 100), gfx::Size(100, 100), gfx::Size(100, 100)); |
2528 DrawFrame(); | 2530 DrawFrame(); |
2529 | 2531 |
2530 float page_scale = 1.5f; | 2532 float page_scale = 1.5f; |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 scoped_ptr<LayerImpl> child = | 3299 scoped_ptr<LayerImpl> child = |
3298 CreateScrollableLayer(2, content_size, root.get()); | 3300 CreateScrollableLayer(2, content_size, root.get()); |
3299 LayerImpl* grand_child_layer = grand_child.get(); | 3301 LayerImpl* grand_child_layer = grand_child.get(); |
3300 child->AddChild(grand_child.Pass()); | 3302 child->AddChild(grand_child.Pass()); |
3301 | 3303 |
3302 LayerImpl* child_layer = child.get(); | 3304 LayerImpl* child_layer = child.get(); |
3303 root->AddChild(child.Pass()); | 3305 root->AddChild(child.Pass()); |
3304 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3306 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3305 host_impl_->active_tree()->DidBecomeActive(); | 3307 host_impl_->active_tree()->DidBecomeActive(); |
3306 host_impl_->SetViewportSize(surface_size); | 3308 host_impl_->SetViewportSize(surface_size); |
3307 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 5)); | 3309 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); |
3308 child_layer->SetScrollOffset(gfx::ScrollOffset(3, 0)); | 3310 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); |
3309 | 3311 |
3310 DrawFrame(); | 3312 DrawFrame(); |
3311 { | 3313 { |
3312 gfx::Vector2d scroll_delta(-8, -7); | 3314 gfx::Vector2d scroll_delta(-8, -7); |
3313 EXPECT_EQ(InputHandler::ScrollStarted, | 3315 EXPECT_EQ(InputHandler::ScrollStarted, |
3314 host_impl_->ScrollBegin(gfx::Point(), | 3316 host_impl_->ScrollBegin(gfx::Point(), |
3315 InputHandler::Wheel)); | 3317 InputHandler::Wheel)); |
3316 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3318 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
3317 host_impl_->ScrollEnd(); | 3319 host_impl_->ScrollEnd(); |
3318 | 3320 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3351 LayerImpl* child_layer = child.get(); | 3353 LayerImpl* child_layer = child.get(); |
3352 root_scrolling->AddChild(child.Pass()); | 3354 root_scrolling->AddChild(child.Pass()); |
3353 root->AddChild(root_scrolling.Pass()); | 3355 root->AddChild(root_scrolling.Pass()); |
3354 EXPECT_EQ(viewport_size, root->bounds()); | 3356 EXPECT_EQ(viewport_size, root->bounds()); |
3355 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3357 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
3356 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 3358 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
3357 Layer::INVALID_ID); | 3359 Layer::INVALID_ID); |
3358 host_impl_->active_tree()->DidBecomeActive(); | 3360 host_impl_->active_tree()->DidBecomeActive(); |
3359 host_impl_->SetViewportSize(viewport_size); | 3361 host_impl_->SetViewportSize(viewport_size); |
3360 | 3362 |
3361 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 3363 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
3362 child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3)); | 3364 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
3363 | 3365 |
3364 DrawFrame(); | 3366 DrawFrame(); |
3365 { | 3367 { |
3366 gfx::Vector2d scroll_delta(0, -10); | 3368 gfx::Vector2d scroll_delta(0, -10); |
3367 EXPECT_EQ(InputHandler::ScrollStarted, | 3369 EXPECT_EQ(InputHandler::ScrollStarted, |
3368 host_impl_->ScrollBegin(gfx::Point(), | 3370 host_impl_->ScrollBegin(gfx::Point(), |
3369 InputHandler::NonBubblingGesture)); | 3371 InputHandler::NonBubblingGesture)); |
3370 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3372 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
3371 host_impl_->ScrollEnd(); | 3373 host_impl_->ScrollEnd(); |
3372 | 3374 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3729 float min_page_scale_factor, | 3731 float min_page_scale_factor, |
3730 float max_page_scale_factor) override { | 3732 float max_page_scale_factor) override { |
3731 DCHECK(total_scroll_offset.x() <= max_scroll_offset.x()); | 3733 DCHECK(total_scroll_offset.x() <= max_scroll_offset.x()); |
3732 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); | 3734 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); |
3733 last_set_scroll_offset_ = total_scroll_offset; | 3735 last_set_scroll_offset_ = total_scroll_offset; |
3734 max_scroll_offset_ = max_scroll_offset; | 3736 max_scroll_offset_ = max_scroll_offset; |
3735 scrollable_size_ = scrollable_size; | 3737 scrollable_size_ = scrollable_size; |
3736 page_scale_factor_ = page_scale_factor; | 3738 page_scale_factor_ = page_scale_factor; |
3737 min_page_scale_factor_ = min_page_scale_factor; | 3739 min_page_scale_factor_ = min_page_scale_factor; |
3738 max_page_scale_factor_ = max_page_scale_factor; | 3740 max_page_scale_factor_ = max_page_scale_factor; |
| 3741 |
| 3742 set_getter_return_value(last_set_scroll_offset_); |
3739 } | 3743 } |
3740 | 3744 |
3741 gfx::ScrollOffset last_set_scroll_offset() { | 3745 gfx::ScrollOffset last_set_scroll_offset() { |
3742 return last_set_scroll_offset_; | 3746 return last_set_scroll_offset_; |
3743 } | 3747 } |
3744 | 3748 |
3745 void set_getter_return_value(const gfx::ScrollOffset& value) { | 3749 void set_getter_return_value(const gfx::ScrollOffset& value) { |
3746 getter_return_value_ = value; | 3750 getter_return_value_ = value; |
3747 } | 3751 } |
3748 | 3752 |
(...skipping 29 matching lines...) Expand all Loading... |
3778 | 3782 |
3779 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 3783 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
3780 TestScrollOffsetDelegate scroll_delegate; | 3784 TestScrollOffsetDelegate scroll_delegate; |
3781 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 3785 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
3782 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 3786 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
3783 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 3787 LayerImpl* clip_layer = scroll_layer->parent()->parent(); |
3784 clip_layer->SetBounds(gfx::Size(10, 20)); | 3788 clip_layer->SetBounds(gfx::Size(10, 20)); |
3785 | 3789 |
3786 // Setting the delegate results in the current scroll offset being set. | 3790 // Setting the delegate results in the current scroll offset being set. |
3787 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 3791 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
3788 scroll_layer->SetScrollOffset(gfx::ScrollOffset()); | 3792 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
3789 scroll_layer->SetScrollDelta(initial_scroll_delta); | 3793 scroll_layer->SetScrollDelta(initial_scroll_delta); |
3790 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); | 3794 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); |
3791 EXPECT_EQ(initial_scroll_delta.ToString(), | 3795 EXPECT_EQ(initial_scroll_delta.ToString(), |
3792 scroll_delegate.last_set_scroll_offset().ToString()); | 3796 scroll_delegate.last_set_scroll_offset().ToString()); |
3793 | 3797 |
3794 // Setting the delegate results in the scrollable_size, max_scroll_offset, | 3798 // Setting the delegate results in the scrollable_size, max_scroll_offset, |
3795 // page_scale_factor and {min|max}_page_scale_factor being set. | 3799 // page_scale_factor and {min|max}_page_scale_factor being set. |
3796 EXPECT_EQ(gfx::SizeF(100, 100), scroll_delegate.scrollable_size()); | 3800 EXPECT_EQ(gfx::SizeF(100, 100), scroll_delegate.scrollable_size()); |
3797 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_delegate.max_scroll_offset()); | 3801 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_delegate.max_scroll_offset()); |
3798 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); | 3802 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3852 host_impl_->ActivateSyncTree(); | 3856 host_impl_->ActivateSyncTree(); |
3853 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); | 3857 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); |
3854 | 3858 |
3855 // Un-setting the delegate should propagate the delegate's current offset to | 3859 // Un-setting the delegate should propagate the delegate's current offset to |
3856 // the root scrollable layer. | 3860 // the root scrollable layer. |
3857 current_offset = gfx::ScrollOffset(13.f, 12.f); | 3861 current_offset = gfx::ScrollOffset(13.f, 12.f); |
3858 scroll_delegate.set_getter_return_value(current_offset); | 3862 scroll_delegate.set_getter_return_value(current_offset); |
3859 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); | 3863 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); |
3860 | 3864 |
3861 EXPECT_EQ(current_offset.ToString(), | 3865 EXPECT_EQ(current_offset.ToString(), |
3862 scroll_layer->TotalScrollOffset().ToString()); | 3866 scroll_layer->CurrentScrollOffset().ToString()); |
3863 } | 3867 } |
3864 | 3868 |
3865 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { | 3869 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { |
3866 const gfx::Transform target_space_transform = | 3870 const gfx::Transform target_space_transform = |
3867 layer->draw_properties().target_space_transform; | 3871 layer->draw_properties().target_space_transform; |
3868 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); | 3872 EXPECT_TRUE(target_space_transform.IsScaleOrTranslation()); |
3869 gfx::Point translated_point; | 3873 gfx::Point translated_point; |
3870 target_space_transform.TransformPoint(&translated_point); | 3874 target_space_transform.TransformPoint(&translated_point); |
3871 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); | 3875 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); |
3872 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); | 3876 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 CreateScrollableLayer(3, surface_size, root_clip.get()); | 4035 CreateScrollableLayer(3, surface_size, root_clip.get()); |
4032 | 4036 |
4033 scoped_ptr<LayerImpl> child = | 4037 scoped_ptr<LayerImpl> child = |
4034 CreateScrollableLayer(2, surface_size, root_clip.get()); | 4038 CreateScrollableLayer(2, surface_size, root_clip.get()); |
4035 LayerImpl* grand_child_layer = grand_child.get(); | 4039 LayerImpl* grand_child_layer = grand_child.get(); |
4036 child->AddChild(grand_child.Pass()); | 4040 child->AddChild(grand_child.Pass()); |
4037 | 4041 |
4038 LayerImpl* child_layer = child.get(); | 4042 LayerImpl* child_layer = child.get(); |
4039 root->AddChild(child.Pass()); | 4043 root->AddChild(child.Pass()); |
4040 root_clip->AddChild(root.Pass()); | 4044 root_clip->AddChild(root.Pass()); |
4041 child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3)); | 4045 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
4042 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 4046 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
4043 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4047 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
4044 host_impl_->active_tree()->DidBecomeActive(); | 4048 host_impl_->active_tree()->DidBecomeActive(); |
4045 host_impl_->SetViewportSize(surface_size); | 4049 host_impl_->SetViewportSize(surface_size); |
4046 DrawFrame(); | 4050 DrawFrame(); |
4047 { | 4051 { |
4048 gfx::Vector2d scroll_delta(0, -10); | 4052 gfx::Vector2d scroll_delta(0, -10); |
4049 EXPECT_EQ(InputHandler::ScrollStarted, | 4053 EXPECT_EQ(InputHandler::ScrollStarted, |
4050 host_impl_->ScrollBegin(gfx::Point(), | 4054 host_impl_->ScrollBegin(gfx::Point(), |
4051 InputHandler::NonBubblingGesture)); | 4055 InputHandler::NonBubblingGesture)); |
4052 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4056 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6244 3, pile); | 6248 3, pile); |
6245 LayerImpl* content_layer = scoped_content_layer.get(); | 6249 LayerImpl* content_layer = scoped_content_layer.get(); |
6246 scrolling_layer->AddChild(scoped_content_layer.Pass()); | 6250 scrolling_layer->AddChild(scoped_content_layer.Pass()); |
6247 content_layer->SetBounds(content_layer_bounds); | 6251 content_layer->SetBounds(content_layer_bounds); |
6248 content_layer->SetDrawsContent(true); | 6252 content_layer->SetDrawsContent(true); |
6249 | 6253 |
6250 root->SetBounds(root_size); | 6254 root->SetBounds(root_size); |
6251 | 6255 |
6252 gfx::ScrollOffset scroll_offset(100000, 0); | 6256 gfx::ScrollOffset scroll_offset(100000, 0); |
6253 scrolling_layer->SetScrollClipLayer(root->id()); | 6257 scrolling_layer->SetScrollClipLayer(root->id()); |
6254 scrolling_layer->SetScrollOffset(scroll_offset); | 6258 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); |
6255 | 6259 |
6256 host_impl_->ActivateSyncTree(); | 6260 host_impl_->ActivateSyncTree(); |
6257 | 6261 |
6258 host_impl_->active_tree()->UpdateDrawProperties(); | 6262 host_impl_->active_tree()->UpdateDrawProperties(); |
6259 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 6263 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
6260 | 6264 |
6261 LayerTreeHostImpl::FrameData frame; | 6265 LayerTreeHostImpl::FrameData frame; |
6262 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6266 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
6263 | 6267 |
6264 ASSERT_EQ(1u, frame.render_passes.size()); | 6268 ASSERT_EQ(1u, frame.render_passes.size()); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6762 // Scroll a child layer beyond its maximum scroll range and make sure the | 6766 // Scroll a child layer beyond its maximum scroll range and make sure the |
6763 // the scroll doesn't bubble up to the parent layer. | 6767 // the scroll doesn't bubble up to the parent layer. |
6764 gfx::Size surface_size(10, 10); | 6768 gfx::Size surface_size(10, 10); |
6765 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 6769 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
6766 root->SetHasRenderSurface(true); | 6770 root->SetHasRenderSurface(true); |
6767 scoped_ptr<LayerImpl> root_scrolling = | 6771 scoped_ptr<LayerImpl> root_scrolling = |
6768 CreateScrollableLayer(2, surface_size, root.get()); | 6772 CreateScrollableLayer(2, surface_size, root.get()); |
6769 | 6773 |
6770 scoped_ptr<LayerImpl> grand_child = | 6774 scoped_ptr<LayerImpl> grand_child = |
6771 CreateScrollableLayer(4, surface_size, root.get()); | 6775 CreateScrollableLayer(4, surface_size, root.get()); |
6772 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2)); | 6776 grand_child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
6773 | 6777 |
6774 scoped_ptr<LayerImpl> child = | 6778 scoped_ptr<LayerImpl> child = |
6775 CreateScrollableLayer(3, surface_size, root.get()); | 6779 CreateScrollableLayer(3, surface_size, root.get()); |
6776 child->SetScrollOffset(gfx::ScrollOffset(0, 4)); | 6780 child->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 4)); |
6777 child->AddChild(grand_child.Pass()); | 6781 child->AddChild(grand_child.Pass()); |
6778 | 6782 |
6779 root_scrolling->AddChild(child.Pass()); | 6783 root_scrolling->AddChild(child.Pass()); |
6780 root->AddChild(root_scrolling.Pass()); | 6784 root->AddChild(root_scrolling.Pass()); |
6781 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 6785 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
6782 host_impl_->active_tree()->DidBecomeActive(); | 6786 host_impl_->active_tree()->DidBecomeActive(); |
6783 host_impl_->SetViewportSize(surface_size); | 6787 host_impl_->SetViewportSize(surface_size); |
6784 DrawFrame(); | 6788 DrawFrame(); |
6785 { | 6789 { |
6786 scoped_ptr<ScrollAndScaleSet> scroll_info; | 6790 scoped_ptr<ScrollAndScaleSet> scroll_info; |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7258 } | 7262 } |
7259 | 7263 |
7260 protected: | 7264 protected: |
7261 static const int top_controls_height_; | 7265 static const int top_controls_height_; |
7262 }; | 7266 }; |
7263 | 7267 |
7264 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; | 7268 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; |
7265 | 7269 |
7266 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { | 7270 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { |
7267 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7271 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
7268 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); | 7272 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); |
7269 host_impl_->Animate(base::TimeTicks()); | 7273 host_impl_->Animate(base::TimeTicks()); |
7270 EXPECT_FALSE(did_request_redraw_); | 7274 EXPECT_FALSE(did_request_redraw_); |
7271 } | 7275 } |
7272 | 7276 |
7273 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { | 7277 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { |
7274 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7278 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
7275 EXPECT_FALSE(did_request_redraw_); | 7279 EXPECT_FALSE(did_request_redraw_); |
7276 host_impl_->CreatePendingTree(); | 7280 host_impl_->CreatePendingTree(); |
7277 host_impl_->sync_tree()->set_top_controls_height(100); | 7281 host_impl_->sync_tree()->set_top_controls_height(100); |
7278 host_impl_->ActivateSyncTree(); | 7282 host_impl_->ActivateSyncTree(); |
(...skipping 11 matching lines...) Expand all Loading... |
7290 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7294 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
7291 | 7295 |
7292 host_impl_->CreatePendingTree(); | 7296 host_impl_->CreatePendingTree(); |
7293 host_impl_->sync_tree()->set_top_controls_height(50); | 7297 host_impl_->sync_tree()->set_top_controls_height(50); |
7294 host_impl_->ActivateSyncTree(); | 7298 host_impl_->ActivateSyncTree(); |
7295 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); | 7299 EXPECT_EQ(0.f, host_impl_->ControlsTopOffset()); |
7296 } | 7300 } |
7297 | 7301 |
7298 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { | 7302 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { |
7299 SetupScrollAndContentsLayers(gfx::Size(100, 100)) | 7303 SetupScrollAndContentsLayers(gfx::Size(100, 100)) |
7300 ->SetScrollOffset(gfx::ScrollOffset(0, 10)); | 7304 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); |
7301 host_impl_->DidChangeTopControlsPosition(); | 7305 host_impl_->DidChangeTopControlsPosition(); |
7302 EXPECT_TRUE(did_request_animate_); | 7306 EXPECT_TRUE(did_request_animate_); |
7303 EXPECT_TRUE(did_request_redraw_); | 7307 EXPECT_TRUE(did_request_redraw_); |
7304 } | 7308 } |
7305 | 7309 |
7306 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 7310 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
7307 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7311 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
7308 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7312 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
7309 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7313 host_impl_->top_controls_manager()->UpdateTopControlsState( |
7310 BOTH, SHOWN, false); | 7314 BOTH, SHOWN, false); |
7311 DrawFrame(); | 7315 DrawFrame(); |
7312 | 7316 |
7313 EXPECT_EQ(InputHandler::ScrollStarted, | 7317 EXPECT_EQ(InputHandler::ScrollStarted, |
7314 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7318 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7315 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7319 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7316 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7320 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7317 scroll_layer->TotalScrollOffset().ToString()); | 7321 scroll_layer->CurrentScrollOffset().ToString()); |
7318 | 7322 |
7319 // Scroll just the top controls and verify that the scroll succeeds. | 7323 // Scroll just the top controls and verify that the scroll succeeds. |
7320 const float residue = 10; | 7324 const float residue = 10; |
7321 float offset = top_controls_height_ - residue; | 7325 float offset = top_controls_height_ - residue; |
7322 EXPECT_TRUE( | 7326 EXPECT_TRUE( |
7323 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7327 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7324 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7328 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7325 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7329 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7326 scroll_layer->TotalScrollOffset().ToString()); | 7330 scroll_layer->CurrentScrollOffset().ToString()); |
7327 | 7331 |
7328 // Scroll across the boundary | 7332 // Scroll across the boundary |
7329 const float content_scroll = 20; | 7333 const float content_scroll = 20; |
7330 offset = residue + content_scroll; | 7334 offset = residue + content_scroll; |
7331 EXPECT_TRUE( | 7335 EXPECT_TRUE( |
7332 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7336 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7333 EXPECT_EQ(-top_controls_height_, | 7337 EXPECT_EQ(-top_controls_height_, |
7334 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7338 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7335 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), | 7339 EXPECT_EQ(gfx::Vector2dF(0, content_scroll).ToString(), |
7336 scroll_layer->TotalScrollOffset().ToString()); | 7340 scroll_layer->CurrentScrollOffset().ToString()); |
7337 | 7341 |
7338 // Now scroll back to the top of the content | 7342 // Now scroll back to the top of the content |
7339 offset = -content_scroll; | 7343 offset = -content_scroll; |
7340 EXPECT_TRUE( | 7344 EXPECT_TRUE( |
7341 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7345 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7342 EXPECT_EQ(-top_controls_height_, | 7346 EXPECT_EQ(-top_controls_height_, |
7343 host_impl_->top_controls_manager()->ControlsTopOffset()); | 7347 host_impl_->top_controls_manager()->ControlsTopOffset()); |
7344 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7348 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7345 scroll_layer->TotalScrollOffset().ToString()); | 7349 scroll_layer->CurrentScrollOffset().ToString()); |
7346 | 7350 |
7347 // And scroll the top controls completely into view | 7351 // And scroll the top controls completely into view |
7348 offset = -top_controls_height_; | 7352 offset = -top_controls_height_; |
7349 EXPECT_TRUE( | 7353 EXPECT_TRUE( |
7350 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7354 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7351 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7355 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7352 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7356 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7353 scroll_layer->TotalScrollOffset().ToString()); | 7357 scroll_layer->CurrentScrollOffset().ToString()); |
7354 | 7358 |
7355 // And attempt to scroll past the end | 7359 // And attempt to scroll past the end |
7356 EXPECT_FALSE( | 7360 EXPECT_FALSE( |
7357 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7361 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7358 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7362 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7359 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7363 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7360 scroll_layer->TotalScrollOffset().ToString()); | 7364 scroll_layer->CurrentScrollOffset().ToString()); |
7361 | 7365 |
7362 host_impl_->ScrollEnd(); | 7366 host_impl_->ScrollEnd(); |
7363 } | 7367 } |
7364 | 7368 |
7365 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 7369 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
7366 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7370 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
7367 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 7371 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
7368 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7372 host_impl_->top_controls_manager()->UpdateTopControlsState( |
7369 BOTH, SHOWN, false); | 7373 BOTH, SHOWN, false); |
7370 DrawFrame(); | 7374 DrawFrame(); |
7371 | 7375 |
7372 EXPECT_EQ(InputHandler::ScrollStarted, | 7376 EXPECT_EQ(InputHandler::ScrollStarted, |
7373 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7377 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7374 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7378 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7375 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7379 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7376 scroll_layer->TotalScrollOffset().ToString()); | 7380 scroll_layer->CurrentScrollOffset().ToString()); |
7377 | 7381 |
7378 // Scroll the top controls partially. | 7382 // Scroll the top controls partially. |
7379 const float residue = 35; | 7383 const float residue = 35; |
7380 float offset = top_controls_height_ - residue; | 7384 float offset = top_controls_height_ - residue; |
7381 EXPECT_TRUE( | 7385 EXPECT_TRUE( |
7382 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7386 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7383 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7387 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7384 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7388 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7385 scroll_layer->TotalScrollOffset().ToString()); | 7389 scroll_layer->CurrentScrollOffset().ToString()); |
7386 | 7390 |
7387 did_request_redraw_ = false; | 7391 did_request_redraw_ = false; |
7388 did_request_animate_ = false; | 7392 did_request_animate_ = false; |
7389 did_request_commit_ = false; | 7393 did_request_commit_ = false; |
7390 | 7394 |
7391 // End the scroll while the controls are still offset from their limit. | 7395 // End the scroll while the controls are still offset from their limit. |
7392 host_impl_->ScrollEnd(); | 7396 host_impl_->ScrollEnd(); |
7393 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 7397 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
7394 EXPECT_TRUE(did_request_animate_); | 7398 EXPECT_TRUE(did_request_animate_); |
7395 EXPECT_TRUE(did_request_redraw_); | 7399 EXPECT_TRUE(did_request_redraw_); |
7396 EXPECT_FALSE(did_request_commit_); | 7400 EXPECT_FALSE(did_request_commit_); |
7397 | 7401 |
7398 // The top controls should properly animate until finished, despite the scroll | 7402 // The top controls should properly animate until finished, despite the scroll |
7399 // offset being at the origin. | 7403 // offset being at the origin. |
7400 base::TimeTicks animation_time = gfx::FrameTime::Now(); | 7404 base::TimeTicks animation_time = gfx::FrameTime::Now(); |
7401 while (did_request_animate_) { | 7405 while (did_request_animate_) { |
7402 did_request_redraw_ = false; | 7406 did_request_redraw_ = false; |
7403 did_request_animate_ = false; | 7407 did_request_animate_ = false; |
7404 did_request_commit_ = false; | 7408 did_request_commit_ = false; |
7405 | 7409 |
7406 float old_offset = | 7410 float old_offset = |
7407 host_impl_->top_controls_manager()->ControlsTopOffset(); | 7411 host_impl_->top_controls_manager()->ControlsTopOffset(); |
7408 | 7412 |
7409 animation_time += base::TimeDelta::FromMilliseconds(5); | 7413 animation_time += base::TimeDelta::FromMilliseconds(5); |
7410 host_impl_->Animate(animation_time); | 7414 host_impl_->Animate(animation_time); |
7411 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7415 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7412 scroll_layer->TotalScrollOffset().ToString()); | 7416 scroll_layer->CurrentScrollOffset().ToString()); |
7413 | 7417 |
7414 float new_offset = | 7418 float new_offset = |
7415 host_impl_->top_controls_manager()->ControlsTopOffset(); | 7419 host_impl_->top_controls_manager()->ControlsTopOffset(); |
7416 | 7420 |
7417 // No commit is needed as the controls are animating the content offset, | 7421 // No commit is needed as the controls are animating the content offset, |
7418 // not the scroll offset. | 7422 // not the scroll offset. |
7419 EXPECT_FALSE(did_request_commit_); | 7423 EXPECT_FALSE(did_request_commit_); |
7420 | 7424 |
7421 if (new_offset != old_offset) | 7425 if (new_offset != old_offset) |
7422 EXPECT_TRUE(did_request_redraw_); | 7426 EXPECT_TRUE(did_request_redraw_); |
7423 | 7427 |
7424 if (new_offset != 0) { | 7428 if (new_offset != 0) { |
7425 EXPECT_TRUE(host_impl_->top_controls_manager()->animation()); | 7429 EXPECT_TRUE(host_impl_->top_controls_manager()->animation()); |
7426 EXPECT_TRUE(did_request_animate_); | 7430 EXPECT_TRUE(did_request_animate_); |
7427 } | 7431 } |
7428 } | 7432 } |
7429 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); | 7433 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); |
7430 } | 7434 } |
7431 | 7435 |
7432 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { | 7436 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
7433 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7437 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
7434 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7438 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
7435 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7439 host_impl_->top_controls_manager()->UpdateTopControlsState( |
7436 BOTH, SHOWN, false); | 7440 BOTH, SHOWN, false); |
7437 float initial_scroll_offset = 50; | 7441 float initial_scroll_offset = 50; |
7438 scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, initial_scroll_offset)); | 7442 scroll_layer->PushScrollOffsetFromMainThread( |
| 7443 gfx::ScrollOffset(0, initial_scroll_offset)); |
7439 DrawFrame(); | 7444 DrawFrame(); |
7440 | 7445 |
7441 EXPECT_EQ(InputHandler::ScrollStarted, | 7446 EXPECT_EQ(InputHandler::ScrollStarted, |
7442 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7447 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7443 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7448 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7444 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7449 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
7445 scroll_layer->TotalScrollOffset().ToString()); | 7450 scroll_layer->CurrentScrollOffset().ToString()); |
7446 | 7451 |
7447 // Scroll the top controls partially. | 7452 // Scroll the top controls partially. |
7448 const float residue = 15; | 7453 const float residue = 15; |
7449 float offset = top_controls_height_ - residue; | 7454 float offset = top_controls_height_ - residue; |
7450 EXPECT_TRUE( | 7455 EXPECT_TRUE( |
7451 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7456 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7452 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7457 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7453 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7458 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
7454 scroll_layer->TotalScrollOffset().ToString()); | 7459 scroll_layer->CurrentScrollOffset().ToString()); |
7455 | 7460 |
7456 did_request_redraw_ = false; | 7461 did_request_redraw_ = false; |
7457 did_request_animate_ = false; | 7462 did_request_animate_ = false; |
7458 did_request_commit_ = false; | 7463 did_request_commit_ = false; |
7459 | 7464 |
7460 // End the scroll while the controls are still offset from the limit. | 7465 // End the scroll while the controls are still offset from the limit. |
7461 host_impl_->ScrollEnd(); | 7466 host_impl_->ScrollEnd(); |
7462 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); | 7467 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); |
7463 EXPECT_TRUE(did_request_animate_); | 7468 EXPECT_TRUE(did_request_animate_); |
7464 EXPECT_TRUE(did_request_redraw_); | 7469 EXPECT_TRUE(did_request_redraw_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7501 | 7506 |
7502 EXPECT_EQ(InputHandler::ScrollStarted, | 7507 EXPECT_EQ(InputHandler::ScrollStarted, |
7503 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7508 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7504 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7509 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7505 | 7510 |
7506 float offset = 50; | 7511 float offset = 50; |
7507 EXPECT_TRUE( | 7512 EXPECT_TRUE( |
7508 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7513 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7509 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7514 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7510 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7515 EXPECT_EQ(gfx::Vector2dF().ToString(), |
7511 scroll_layer->TotalScrollOffset().ToString()); | 7516 scroll_layer->CurrentScrollOffset().ToString()); |
7512 | 7517 |
7513 EXPECT_TRUE( | 7518 EXPECT_TRUE( |
7514 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7519 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7515 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | 7520 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
7516 scroll_layer->TotalScrollOffset().ToString()); | 7521 scroll_layer->CurrentScrollOffset().ToString()); |
7517 | 7522 |
7518 EXPECT_TRUE( | 7523 EXPECT_TRUE( |
7519 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7524 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
7520 | 7525 |
7521 // Should have fully scrolled | 7526 // Should have fully scrolled |
7522 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), | 7527 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), |
7523 scroll_layer->TotalScrollOffset().ToString()); | 7528 scroll_layer->CurrentScrollOffset().ToString()); |
7524 | 7529 |
7525 float overscrollamount = 10; | 7530 float overscrollamount = 10; |
7526 | 7531 |
7527 // Overscroll the content | 7532 // Overscroll the content |
7528 EXPECT_FALSE( | 7533 EXPECT_FALSE( |
7529 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) | 7534 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, overscrollamount)) |
7530 .did_scroll); | 7535 .did_scroll); |
7531 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), | 7536 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), |
7532 scroll_layer->TotalScrollOffset().ToString()); | 7537 scroll_layer->CurrentScrollOffset().ToString()); |
7533 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | 7538 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
7534 host_impl_->accumulated_root_overscroll().ToString()); | 7539 host_impl_->accumulated_root_overscroll().ToString()); |
7535 | 7540 |
7536 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) | 7541 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -2 * offset)) |
7537 .did_scroll); | 7542 .did_scroll); |
7538 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 7543 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
7539 scroll_layer->TotalScrollOffset().ToString()); | 7544 scroll_layer->CurrentScrollOffset().ToString()); |
7540 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7545 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7541 | 7546 |
7542 EXPECT_TRUE( | 7547 EXPECT_TRUE( |
7543 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); | 7548 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -offset)).did_scroll); |
7544 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 7549 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
7545 scroll_layer->TotalScrollOffset().ToString()); | 7550 scroll_layer->CurrentScrollOffset().ToString()); |
7546 | 7551 |
7547 // Top controls should be fully visible | 7552 // Top controls should be fully visible |
7548 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7553 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
7549 | 7554 |
7550 host_impl_->ScrollEnd(); | 7555 host_impl_->ScrollEnd(); |
7551 } | 7556 } |
7552 | 7557 |
7553 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { | 7558 class LayerTreeHostImplVirtualViewportTest : public LayerTreeHostImplTest { |
7554 public: | 7559 public: |
7555 void SetupVirtualViewportLayers(const gfx::Size& content_size, | 7560 void SetupVirtualViewportLayers(const gfx::Size& content_size, |
7556 const gfx::Size& outer_viewport, | 7561 const gfx::Size& outer_viewport, |
7557 const gfx::Size& inner_viewport) { | 7562 const gfx::Size& inner_viewport) { |
7558 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); | 7563 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); |
7559 const int kOuterViewportClipLayerId = 6; | 7564 const int kOuterViewportClipLayerId = 6; |
7560 const int kOuterViewportScrollLayerId = 7; | 7565 const int kOuterViewportScrollLayerId = 7; |
7561 const int kInnerViewportScrollLayerId = 2; | 7566 const int kInnerViewportScrollLayerId = 2; |
7562 const int kInnerViewportClipLayerId = 4; | 7567 const int kInnerViewportClipLayerId = 4; |
7563 const int kPageScaleLayerId = 5; | 7568 const int kPageScaleLayerId = 5; |
7564 | 7569 |
7565 scoped_ptr<LayerImpl> inner_scroll = | 7570 scoped_ptr<LayerImpl> inner_scroll = |
7566 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); | 7571 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); |
7567 inner_scroll->SetIsContainerForFixedPositionLayers(true); | 7572 inner_scroll->SetIsContainerForFixedPositionLayers(true); |
7568 inner_scroll->SetScrollOffset(gfx::ScrollOffset()); | 7573 inner_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
7569 | 7574 |
7570 scoped_ptr<LayerImpl> inner_clip = | 7575 scoped_ptr<LayerImpl> inner_clip = |
7571 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); | 7576 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); |
7572 inner_clip->SetBounds(inner_viewport); | 7577 inner_clip->SetBounds(inner_viewport); |
7573 | 7578 |
7574 scoped_ptr<LayerImpl> page_scale = | 7579 scoped_ptr<LayerImpl> page_scale = |
7575 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); | 7580 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); |
7576 | 7581 |
7577 inner_scroll->SetScrollClipLayer(inner_clip->id()); | 7582 inner_scroll->SetScrollClipLayer(inner_clip->id()); |
7578 inner_scroll->SetBounds(outer_viewport); | 7583 inner_scroll->SetBounds(outer_viewport); |
7579 inner_scroll->SetContentBounds(outer_viewport); | 7584 inner_scroll->SetContentBounds(outer_viewport); |
7580 inner_scroll->SetPosition(gfx::PointF()); | 7585 inner_scroll->SetPosition(gfx::PointF()); |
7581 | 7586 |
7582 scoped_ptr<LayerImpl> outer_clip = | 7587 scoped_ptr<LayerImpl> outer_clip = |
7583 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); | 7588 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); |
7584 outer_clip->SetBounds(outer_viewport); | 7589 outer_clip->SetBounds(outer_viewport); |
7585 outer_clip->SetIsContainerForFixedPositionLayers(true); | 7590 outer_clip->SetIsContainerForFixedPositionLayers(true); |
7586 | 7591 |
7587 scoped_ptr<LayerImpl> outer_scroll = | 7592 scoped_ptr<LayerImpl> outer_scroll = |
7588 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); | 7593 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); |
7589 outer_scroll->SetScrollClipLayer(outer_clip->id()); | 7594 outer_scroll->SetScrollClipLayer(outer_clip->id()); |
7590 outer_scroll->SetScrollOffset(gfx::ScrollOffset()); | 7595 outer_scroll->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
7591 outer_scroll->SetBounds(content_size); | 7596 outer_scroll->SetBounds(content_size); |
7592 outer_scroll->SetContentBounds(content_size); | 7597 outer_scroll->SetContentBounds(content_size); |
7593 outer_scroll->SetPosition(gfx::PointF()); | 7598 outer_scroll->SetPosition(gfx::PointF()); |
7594 | 7599 |
7595 scoped_ptr<LayerImpl> contents = | 7600 scoped_ptr<LayerImpl> contents = |
7596 LayerImpl::Create(layer_tree_impl, 8); | 7601 LayerImpl::Create(layer_tree_impl, 8); |
7597 contents->SetDrawsContent(true); | 7602 contents->SetDrawsContent(true); |
7598 contents->SetBounds(content_size); | 7603 contents->SetBounds(content_size); |
7599 contents->SetContentBounds(content_size); | 7604 contents->SetContentBounds(content_size); |
7600 contents->SetPosition(gfx::PointF()); | 7605 contents->SetPosition(gfx::PointF()); |
(...skipping 20 matching lines...) Expand all Loading... |
7621 gfx::Size inner_viewport = gfx::Size(25, 40); | 7626 gfx::Size inner_viewport = gfx::Size(25, 40); |
7622 | 7627 |
7623 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7628 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
7624 | 7629 |
7625 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7630 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
7626 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7631 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
7627 DrawFrame(); | 7632 DrawFrame(); |
7628 { | 7633 { |
7629 gfx::Vector2dF inner_expected; | 7634 gfx::Vector2dF inner_expected; |
7630 gfx::Vector2dF outer_expected; | 7635 gfx::Vector2dF outer_expected; |
7631 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7636 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7632 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7637 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7633 | 7638 |
7634 // Make sure the fling goes to the outer viewport first | 7639 // Make sure the fling goes to the outer viewport first |
7635 EXPECT_EQ(InputHandler::ScrollStarted, | 7640 EXPECT_EQ(InputHandler::ScrollStarted, |
7636 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7641 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7637 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 7642 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
7638 | 7643 |
7639 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7644 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
7640 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7645 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7641 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7646 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7642 | 7647 |
7643 host_impl_->ScrollEnd(); | 7648 host_impl_->ScrollEnd(); |
7644 | 7649 |
7645 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7650 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7646 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7651 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7647 | 7652 |
7648 // Fling past the outer viewport boundry, make sure inner viewport scrolls. | 7653 // Fling past the outer viewport boundry, make sure inner viewport scrolls. |
7649 EXPECT_EQ(InputHandler::ScrollStarted, | 7654 EXPECT_EQ(InputHandler::ScrollStarted, |
7650 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7655 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7651 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 7656 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
7652 | 7657 |
7653 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7658 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7654 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7659 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7655 | 7660 |
7656 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7661 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7657 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7662 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
7658 | 7663 |
7659 host_impl_->ScrollEnd(); | 7664 host_impl_->ScrollEnd(); |
7660 | 7665 |
7661 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7666 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7662 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7667 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7663 } | 7668 } |
7664 } | 7669 } |
7665 | 7670 |
7666 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7671 TEST_F(LayerTreeHostImplVirtualViewportTest, |
7667 DiagonalScrollBubblesPerfectlyToInner) { | 7672 DiagonalScrollBubblesPerfectlyToInner) { |
7668 gfx::Size content_size = gfx::Size(100, 160); | 7673 gfx::Size content_size = gfx::Size(100, 160); |
7669 gfx::Size outer_viewport = gfx::Size(50, 80); | 7674 gfx::Size outer_viewport = gfx::Size(50, 80); |
7670 gfx::Size inner_viewport = gfx::Size(25, 40); | 7675 gfx::Size inner_viewport = gfx::Size(25, 40); |
7671 | 7676 |
7672 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7677 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
7673 | 7678 |
7674 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7679 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
7675 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7680 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
7676 DrawFrame(); | 7681 DrawFrame(); |
7677 { | 7682 { |
7678 gfx::Vector2dF inner_expected; | 7683 gfx::Vector2dF inner_expected; |
7679 gfx::Vector2dF outer_expected; | 7684 gfx::Vector2dF outer_expected; |
7680 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7685 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7681 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7686 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7682 | 7687 |
7683 // Make sure the scroll goes to the outer viewport first. | 7688 // Make sure the scroll goes to the outer viewport first. |
7684 EXPECT_EQ(InputHandler::ScrollStarted, | 7689 EXPECT_EQ(InputHandler::ScrollStarted, |
7685 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 7690 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
7686 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | 7691 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
7687 | 7692 |
7688 // Scroll near the edge of the outer viewport. | 7693 // Scroll near the edge of the outer viewport. |
7689 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7694 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
7690 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7695 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
7691 outer_expected += scroll_delta; | 7696 outer_expected += scroll_delta; |
7692 | 7697 |
7693 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7698 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7694 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7699 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7695 | 7700 |
7696 // Now diagonal scroll across the outer viewport boundary in a single event. | 7701 // Now diagonal scroll across the outer viewport boundary in a single event. |
7697 // The entirety of the scroll should be consumed, as bubbling between inner | 7702 // The entirety of the scroll should be consumed, as bubbling between inner |
7698 // and outer viewport layers is perfect. | 7703 // and outer viewport layers is perfect. |
7699 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); | 7704 host_impl_->ScrollBy(gfx::Point(), gfx::ScaleVector2d(scroll_delta, 2)); |
7700 outer_expected += scroll_delta; | 7705 outer_expected += scroll_delta; |
7701 inner_expected += scroll_delta; | 7706 inner_expected += scroll_delta; |
7702 host_impl_->ScrollEnd(); | 7707 host_impl_->ScrollEnd(); |
7703 | 7708 |
7704 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->TotalScrollOffset()); | 7709 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
7705 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->TotalScrollOffset()); | 7710 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
7706 } | 7711 } |
7707 } | 7712 } |
7708 | 7713 |
7709 TEST_F(LayerTreeHostImplVirtualViewportTest, | 7714 TEST_F(LayerTreeHostImplVirtualViewportTest, |
7710 TouchFlingCanLockToViewportLayerAfterBubbling) { | 7715 TouchFlingCanLockToViewportLayerAfterBubbling) { |
7711 gfx::Size content_size = gfx::Size(100, 160); | 7716 gfx::Size content_size = gfx::Size(100, 160); |
7712 gfx::Size outer_viewport = gfx::Size(50, 80); | 7717 gfx::Size outer_viewport = gfx::Size(50, 80); |
7713 gfx::Size inner_viewport = gfx::Size(25, 40); | 7718 gfx::Size inner_viewport = gfx::Size(25, 40); |
7714 | 7719 |
7715 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 7720 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7816 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 7821 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
7817 | 7822 |
7818 EXPECT_EQ(InputHandler::ScrollStarted, | 7823 EXPECT_EQ(InputHandler::ScrollStarted, |
7819 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 7824 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
7820 | 7825 |
7821 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 7826 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
7822 | 7827 |
7823 host_impl_->Animate(start_time); | 7828 host_impl_->Animate(start_time); |
7824 host_impl_->UpdateAnimationState(true); | 7829 host_impl_->UpdateAnimationState(true); |
7825 | 7830 |
7826 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->TotalScrollOffset()); | 7831 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
7827 | 7832 |
7828 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); | 7833 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); |
7829 host_impl_->UpdateAnimationState(true); | 7834 host_impl_->UpdateAnimationState(true); |
7830 | 7835 |
7831 float y = scrolling_layer->TotalScrollOffset().y(); | 7836 float y = scrolling_layer->CurrentScrollOffset().y(); |
7832 EXPECT_TRUE(y > 1 && y < 49); | 7837 EXPECT_TRUE(y > 1 && y < 49); |
7833 | 7838 |
7834 // Update target. | 7839 // Update target. |
7835 EXPECT_EQ(InputHandler::ScrollStarted, | 7840 EXPECT_EQ(InputHandler::ScrollStarted, |
7836 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 7841 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
7837 | 7842 |
7838 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); | 7843 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); |
7839 host_impl_->UpdateAnimationState(true); | 7844 host_impl_->UpdateAnimationState(true); |
7840 | 7845 |
7841 y = scrolling_layer->TotalScrollOffset().y(); | 7846 y = scrolling_layer->CurrentScrollOffset().y(); |
7842 EXPECT_TRUE(y > 50 && y < 100); | 7847 EXPECT_TRUE(y > 50 && y < 100); |
7843 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 7848 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
7844 | 7849 |
7845 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 7850 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
7846 host_impl_->UpdateAnimationState(true); | 7851 host_impl_->UpdateAnimationState(true); |
7847 | 7852 |
7848 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 7853 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
7849 scrolling_layer->TotalScrollOffset()); | 7854 scrolling_layer->CurrentScrollOffset()); |
7850 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 7855 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
7851 } | 7856 } |
7852 | 7857 |
7853 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 7858 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
7854 host_impl_->CreatePendingTree(); | 7859 host_impl_->CreatePendingTree(); |
7855 | 7860 |
7856 scoped_ptr<PictureLayerImpl> layer = | 7861 scoped_ptr<PictureLayerImpl> layer = |
7857 PictureLayerImpl::Create(host_impl_->pending_tree(), 10, false); | 7862 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 10); |
7858 layer->SetBounds(gfx::Size(10, 10)); | 7863 layer->SetBounds(gfx::Size(10, 10)); |
7859 | 7864 |
7860 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( | 7865 scoped_refptr<RasterSource> pile(FakePicturePileImpl::CreateEmptyPile( |
7861 gfx::Size(10, 10), gfx::Size(10, 10))); | 7866 gfx::Size(10, 10), gfx::Size(10, 10))); |
7862 Region empty_invalidation; | 7867 Region empty_invalidation; |
7863 const PictureLayerTilingSet* null_tiling_set = nullptr; | 7868 const PictureLayerTilingSet* null_tiling_set = nullptr; |
7864 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); | 7869 layer->UpdateRasterSource(pile, &empty_invalidation, null_tiling_set); |
7865 | 7870 |
7866 host_impl_->pending_tree()->SetRootLayer(layer.Pass()); | 7871 host_impl_->pending_tree()->SetRootLayer(layer.Pass()); |
7867 | 7872 |
(...skipping 29 matching lines...) Expand all Loading... |
7897 layer_pairs.clear(); | 7902 layer_pairs.clear(); |
7898 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); | 7903 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
7899 EXPECT_EQ(1u, layer_pairs.size()); | 7904 EXPECT_EQ(1u, layer_pairs.size()); |
7900 EXPECT_EQ(active_layer, layer_pairs[0].active); | 7905 EXPECT_EQ(active_layer, layer_pairs[0].active); |
7901 EXPECT_EQ(nullptr, layer_pairs[0].pending); | 7906 EXPECT_EQ(nullptr, layer_pairs[0].pending); |
7902 | 7907 |
7903 // Create another layer in the pending tree that's not in the active tree. We | 7908 // Create another layer in the pending tree that's not in the active tree. We |
7904 // should get two pairs. | 7909 // should get two pairs. |
7905 host_impl_->CreatePendingTree(); | 7910 host_impl_->CreatePendingTree(); |
7906 host_impl_->pending_tree()->root_layer()->AddChild( | 7911 host_impl_->pending_tree()->root_layer()->AddChild( |
7907 PictureLayerImpl::Create(host_impl_->pending_tree(), 11, false)); | 7912 FakePictureLayerImpl::Create(host_impl_->pending_tree(), 11)); |
7908 | 7913 |
7909 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; | 7914 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0]; |
7910 | 7915 |
7911 layer_pairs.clear(); | 7916 layer_pairs.clear(); |
7912 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); | 7917 host_impl_->GetPictureLayerImplPairs(&layer_pairs, true); |
7913 EXPECT_EQ(2u, layer_pairs.size()); | 7918 EXPECT_EQ(2u, layer_pairs.size()); |
7914 | 7919 |
7915 // The pair ordering is flaky, so make it consistent. | 7920 // The pair ordering is flaky, so make it consistent. |
7916 if (layer_pairs[0].active != active_layer) | 7921 if (layer_pairs[0].active != active_layer) |
7917 std::swap(layer_pairs[0], layer_pairs[1]); | 7922 std::swap(layer_pairs[0], layer_pairs[1]); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7990 float page_scale_delta = 2.f; | 7995 float page_scale_delta = 2.f; |
7991 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); | 7996 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
7992 host_impl_->PinchGestureBegin(); | 7997 host_impl_->PinchGestureBegin(); |
7993 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 7998 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
7994 host_impl_->PinchGestureEnd(); | 7999 host_impl_->PinchGestureEnd(); |
7995 host_impl_->ScrollEnd(); | 8000 host_impl_->ScrollEnd(); |
7996 | 8001 |
7997 gfx::Vector2dF scroll_delta(0, 5); | 8002 gfx::Vector2dF scroll_delta(0, 5); |
7998 EXPECT_EQ(InputHandler::ScrollStarted, | 8003 EXPECT_EQ(InputHandler::ScrollStarted, |
7999 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 8004 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
8000 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); | 8005 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
8001 | 8006 |
8002 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8007 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
8003 host_impl_->ScrollEnd(); | 8008 host_impl_->ScrollEnd(); |
8004 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), scroll_layer->TotalScrollOffset()); | 8009 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
| 8010 scroll_layer->CurrentScrollOffset()); |
8005 } | 8011 } |
8006 } | 8012 } |
8007 | 8013 |
8008 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 8014 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
8009 public: | 8015 public: |
8010 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} | 8016 LayerTreeHostImplCountingLostSurfaces() : num_lost_surfaces_(0) {} |
8011 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } | 8017 void DidLoseOutputSurfaceOnImplThread() override { num_lost_surfaces_++; } |
8012 | 8018 |
8013 protected: | 8019 protected: |
8014 int num_lost_surfaces_; | 8020 int num_lost_surfaces_; |
8015 }; | 8021 }; |
8016 | 8022 |
8017 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { | 8023 TEST_F(LayerTreeHostImplCountingLostSurfaces, TwiceLostSurface) { |
8018 // Really we just need at least one client notification each time | 8024 // Really we just need at least one client notification each time |
8019 // we go from having a valid output surface to not having a valid output | 8025 // we go from having a valid output surface to not having a valid output |
8020 // surface. | 8026 // surface. |
8021 EXPECT_EQ(0, num_lost_surfaces_); | 8027 EXPECT_EQ(0, num_lost_surfaces_); |
8022 host_impl_->DidLoseOutputSurface(); | 8028 host_impl_->DidLoseOutputSurface(); |
8023 EXPECT_EQ(1, num_lost_surfaces_); | 8029 EXPECT_EQ(1, num_lost_surfaces_); |
8024 host_impl_->DidLoseOutputSurface(); | 8030 host_impl_->DidLoseOutputSurface(); |
8025 EXPECT_LE(1, num_lost_surfaces_); | 8031 EXPECT_LE(1, num_lost_surfaces_); |
8026 } | 8032 } |
8027 | 8033 |
8028 } // namespace | 8034 } // namespace |
8029 } // namespace cc | 8035 } // namespace cc |
OLD | NEW |