Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: blow up the patchset :( Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 scoped_ptr<LayerImpl> root = 231 scoped_ptr<LayerImpl> root =
232 LayerImpl::Create(layer_tree_impl, 1); 232 LayerImpl::Create(layer_tree_impl, 1);
233 root->SetBounds(content_size); 233 root->SetBounds(content_size);
234 root->SetContentBounds(content_size); 234 root->SetContentBounds(content_size);
235 root->SetPosition(gfx::PointF()); 235 root->SetPosition(gfx::PointF());
236 236
237 scoped_ptr<LayerImpl> scroll = 237 scoped_ptr<LayerImpl> scroll =
238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); 238 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
239 LayerImpl* scroll_layer = scroll.get(); 239 LayerImpl* scroll_layer = scroll.get();
240 scroll->SetIsContainerForFixedPositionLayers(true); 240 scroll->SetIsContainerForFixedPositionLayers(true);
241 scroll->SetScrollOffset(gfx::Vector2d()); 241 scroll->SetScrollOffset(gfx::ScrollOffset());
242 242
243 scoped_ptr<LayerImpl> clip = 243 scoped_ptr<LayerImpl> clip =
244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 244 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
245 clip->SetBounds( 245 clip->SetBounds(
246 gfx::Size(content_size.width() / 2, content_size.height() / 2)); 246 gfx::Size(content_size.width() / 2, content_size.height() / 2));
247 247
248 scoped_ptr<LayerImpl> page_scale = 248 scoped_ptr<LayerImpl> page_scale =
249 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); 249 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId);
250 250
251 scroll->SetScrollClipLayer(clip->id()); 251 scroll->SetScrollClipLayer(clip->id());
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 scroll_info = host_impl_->ProcessScrollDeltas(); 453 scroll_info = host_impl_->ProcessScrollDeltas();
454 ASSERT_EQ(scroll_info->scrolls.size(), 0u); 454 ASSERT_EQ(scroll_info->scrolls.size(), 0u);
455 ExpectClearedScrollDeltasRecursive(root); 455 ExpectClearedScrollDeltasRecursive(root);
456 456
457 scroll_info = host_impl_->ProcessScrollDeltas(); 457 scroll_info = host_impl_->ProcessScrollDeltas();
458 ASSERT_EQ(scroll_info->scrolls.size(), 0u); 458 ASSERT_EQ(scroll_info->scrolls.size(), 0u);
459 ExpectClearedScrollDeltasRecursive(root); 459 ExpectClearedScrollDeltasRecursive(root);
460 } 460 }
461 461
462 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) { 462 TEST_F(LayerTreeHostImplTest, ScrollDeltaRepeatedScrolls) {
463 gfx::Vector2d scroll_offset(20, 30); 463 gfx::ScrollOffset scroll_offset(20, 30);
464 gfx::Vector2d scroll_delta(11, -15); 464 gfx::Vector2d scroll_delta(11, -15);
465 { 465 {
466 scoped_ptr<LayerImpl> root_clip = 466 scoped_ptr<LayerImpl> root_clip =
467 LayerImpl::Create(host_impl_->active_tree(), 2); 467 LayerImpl::Create(host_impl_->active_tree(), 2);
468 scoped_ptr<LayerImpl> root = 468 scoped_ptr<LayerImpl> root =
469 LayerImpl::Create(host_impl_->active_tree(), 1); 469 LayerImpl::Create(host_impl_->active_tree(), 1);
470 root_clip->SetBounds(gfx::Size(10, 10)); 470 root_clip->SetBounds(gfx::Size(10, 10));
471 LayerImpl* root_layer = root.get(); 471 LayerImpl* root_layer = root.get();
472 root_clip->AddChild(root.Pass()); 472 root_clip->AddChild(root.Pass());
473 root_layer->SetBounds(gfx::Size(110, 110)); 473 root_layer->SetBounds(gfx::Size(110, 110));
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 TEST_F(LayerTreeHostImplTest, DISABLED_ScrollWithUserUnscrollableLayers) { 832 TEST_F(LayerTreeHostImplTest, DISABLED_ScrollWithUserUnscrollableLayers) {
833 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 833 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
834 host_impl_->SetViewportSize(gfx::Size(100, 100)); 834 host_impl_->SetViewportSize(gfx::Size(100, 100));
835 835
836 gfx::Size overflow_size(400, 400); 836 gfx::Size overflow_size(400, 400);
837 ASSERT_EQ(1u, scroll_layer->children().size()); 837 ASSERT_EQ(1u, scroll_layer->children().size());
838 LayerImpl* overflow = scroll_layer->children()[0]; 838 LayerImpl* overflow = scroll_layer->children()[0];
839 overflow->SetBounds(overflow_size); 839 overflow->SetBounds(overflow_size);
840 overflow->SetContentBounds(overflow_size); 840 overflow->SetContentBounds(overflow_size);
841 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); 841 overflow->SetScrollClipLayer(scroll_layer->parent()->id());
842 overflow->SetScrollOffset(gfx::Vector2d()); 842 overflow->SetScrollOffset(gfx::ScrollOffset());
843 overflow->SetPosition(gfx::PointF()); 843 overflow->SetPosition(gfx::PointF());
844 844
845 DrawFrame(); 845 DrawFrame();
846 gfx::Point scroll_position(10, 10); 846 gfx::Point scroll_position(10, 10);
847 847
848 EXPECT_EQ(InputHandler::ScrollStarted, 848 EXPECT_EQ(InputHandler::ScrollStarted,
849 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); 849 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel));
850 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset()); 850 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->TotalScrollOffset());
851 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset()); 851 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->TotalScrollOffset());
852 852
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 host_impl_->ScrollEnd(); 932 host_impl_->ScrollEnd();
933 EXPECT_FALSE(did_request_animate_); 933 EXPECT_FALSE(did_request_animate_);
934 EXPECT_TRUE(did_request_redraw_); 934 EXPECT_TRUE(did_request_redraw_);
935 EXPECT_TRUE(did_request_commit_); 935 EXPECT_TRUE(did_request_commit_);
936 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 936 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
937 937
938 scoped_ptr<ScrollAndScaleSet> scroll_info = 938 scoped_ptr<ScrollAndScaleSet> scroll_info =
939 host_impl_->ProcessScrollDeltas(); 939 host_impl_->ProcessScrollDeltas();
940 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 940 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
941 941
942 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(), 942 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(),
943 scroll_layer->MaxScrollOffset().ToString()); 943 scroll_layer->MaxScrollOffset().ToString());
944 } 944 }
945 945
946 // Scrolling after a pinch gesture should always be in local space. The 946 // Scrolling after a pinch gesture should always be in local space. The
947 // scroll deltas do not have the page scale factor applied. 947 // scroll deltas do not have the page scale factor applied.
948 { 948 {
949 host_impl_->active_tree()->SetPageScaleFactorAndLimits( 949 host_impl_->active_tree()->SetPageScaleFactorAndLimits(
950 page_scale_factor, min_page_scale, max_page_scale); 950 page_scale_factor, min_page_scale, max_page_scale);
951 host_impl_->active_tree()->SetPageScaleDelta(1.f); 951 host_impl_->active_tree()->SetPageScaleDelta(1.f);
952 scroll_layer->SetScrollDelta(gfx::Vector2d()); 952 scroll_layer->SetScrollDelta(gfx::Vector2d());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 host_impl_->ProcessScrollDeltas(); 1042 host_impl_->ProcessScrollDeltas();
1043 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); 1043 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale);
1044 } 1044 }
1045 1045
1046 // Zoom-out clamping 1046 // Zoom-out clamping
1047 { 1047 {
1048 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1048 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1049 min_page_scale, 1049 min_page_scale,
1050 max_page_scale); 1050 max_page_scale);
1051 scroll_layer->SetScrollDelta(gfx::Vector2d()); 1051 scroll_layer->SetScrollDelta(gfx::Vector2d());
1052 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); 1052 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1053 1053
1054 float page_scale_delta = 0.1f; 1054 float page_scale_delta = 0.1f;
1055 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); 1055 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
1056 host_impl_->PinchGestureBegin(); 1056 host_impl_->PinchGestureBegin();
1057 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 1057 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
1058 host_impl_->PinchGestureEnd(); 1058 host_impl_->PinchGestureEnd();
1059 host_impl_->ScrollEnd(); 1059 host_impl_->ScrollEnd();
1060 1060
1061 scoped_ptr<ScrollAndScaleSet> scroll_info = 1061 scoped_ptr<ScrollAndScaleSet> scroll_info =
1062 host_impl_->ProcessScrollDeltas(); 1062 host_impl_->ProcessScrollDeltas();
1063 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); 1063 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
1064 1064
1065 EXPECT_TRUE(scroll_info->scrolls.empty()); 1065 EXPECT_TRUE(scroll_info->scrolls.empty());
1066 } 1066 }
1067 1067
1068 // Two-finger panning should not happen based on pinch events only 1068 // Two-finger panning should not happen based on pinch events only
1069 { 1069 {
1070 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1070 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1071 min_page_scale, 1071 min_page_scale,
1072 max_page_scale); 1072 max_page_scale);
1073 scroll_layer->SetScrollDelta(gfx::Vector2d()); 1073 scroll_layer->SetScrollDelta(gfx::Vector2d());
1074 scroll_layer->SetScrollOffset(gfx::Vector2d(20, 20)); 1074 scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20));
1075 1075
1076 float page_scale_delta = 1.f; 1076 float page_scale_delta = 1.f;
1077 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); 1077 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture);
1078 host_impl_->PinchGestureBegin(); 1078 host_impl_->PinchGestureBegin();
1079 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 1079 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
1080 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 1080 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
1081 host_impl_->PinchGestureEnd(); 1081 host_impl_->PinchGestureEnd();
1082 host_impl_->ScrollEnd(); 1082 host_impl_->ScrollEnd();
1083 1083
1084 scoped_ptr<ScrollAndScaleSet> scroll_info = 1084 scoped_ptr<ScrollAndScaleSet> scroll_info =
1085 host_impl_->ProcessScrollDeltas(); 1085 host_impl_->ProcessScrollDeltas();
1086 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 1086 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
1087 EXPECT_TRUE(scroll_info->scrolls.empty()); 1087 EXPECT_TRUE(scroll_info->scrolls.empty());
1088 } 1088 }
1089 1089
1090 // Two-finger panning should work with interleaved scroll events 1090 // Two-finger panning should work with interleaved scroll events
1091 { 1091 {
1092 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1092 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1093 min_page_scale, 1093 min_page_scale,
1094 max_page_scale); 1094 max_page_scale);
1095 scroll_layer->SetScrollDelta(gfx::Vector2d()); 1095 scroll_layer->SetScrollDelta(gfx::Vector2d());
1096 scroll_layer->SetScrollOffset(gfx::Vector2d(20, 20)); 1096 scroll_layer->SetScrollOffset(gfx::ScrollOffset(20, 20));
1097 1097
1098 float page_scale_delta = 1.f; 1098 float page_scale_delta = 1.f;
1099 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); 1099 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture);
1100 host_impl_->PinchGestureBegin(); 1100 host_impl_->PinchGestureBegin();
1101 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 1101 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
1102 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); 1102 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10));
1103 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 1103 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
1104 host_impl_->PinchGestureEnd(); 1104 host_impl_->PinchGestureEnd();
1105 host_impl_->ScrollEnd(); 1105 host_impl_->ScrollEnd();
1106 1106
1107 scoped_ptr<ScrollAndScaleSet> scroll_info = 1107 scoped_ptr<ScrollAndScaleSet> scroll_info =
1108 host_impl_->ProcessScrollDeltas(); 1108 host_impl_->ProcessScrollDeltas();
1109 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 1109 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
1110 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); 1110 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10));
1111 } 1111 }
1112 1112
1113 // Two-finger panning should work when starting fully zoomed out. 1113 // Two-finger panning should work when starting fully zoomed out.
1114 { 1114 {
1115 host_impl_->active_tree()->SetPageScaleFactorAndLimits(0.5f, 1115 host_impl_->active_tree()->SetPageScaleFactorAndLimits(0.5f,
1116 0.5f, 1116 0.5f,
1117 4.f); 1117 4.f);
1118 scroll_layer->SetScrollDelta(gfx::Vector2d()); 1118 scroll_layer->SetScrollDelta(gfx::Vector2d());
1119 scroll_layer->SetScrollOffset(gfx::Vector2d(0, 0)); 1119 scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, 0));
1120 1120
1121 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); 1121 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture);
1122 host_impl_->PinchGestureBegin(); 1122 host_impl_->PinchGestureBegin();
1123 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); 1123 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0));
1124 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); 1124 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0));
1125 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); 1125 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10));
1126 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); 1126 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10));
1127 host_impl_->PinchGestureEnd(); 1127 host_impl_->PinchGestureEnd();
1128 host_impl_->ScrollEnd(); 1128 host_impl_->ScrollEnd();
1129 1129
(...skipping 18 matching lines...) Expand all
1148 base::TimeDelta::FromSeconds(1); 1148 base::TimeDelta::FromSeconds(1);
1149 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1149 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1150 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1150 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1151 base::TimeTicks end_time = start_time + duration; 1151 base::TimeTicks end_time = start_time + duration;
1152 1152
1153 // Non-anchor zoom-in 1153 // Non-anchor zoom-in
1154 { 1154 {
1155 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1155 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1156 min_page_scale, 1156 min_page_scale,
1157 max_page_scale); 1157 max_page_scale);
1158 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); 1158 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1159 1159
1160 did_request_redraw_ = false; 1160 did_request_redraw_ = false;
1161 did_request_animate_ = false; 1161 did_request_animate_ = false;
1162 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); 1162 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration);
1163 EXPECT_FALSE(did_request_redraw_); 1163 EXPECT_FALSE(did_request_redraw_);
1164 EXPECT_TRUE(did_request_animate_); 1164 EXPECT_TRUE(did_request_animate_);
1165 1165
1166 did_request_redraw_ = false; 1166 did_request_redraw_ = false;
1167 did_request_animate_ = false; 1167 did_request_animate_ = false;
1168 host_impl_->Animate(start_time); 1168 host_impl_->Animate(start_time);
(...skipping 17 matching lines...) Expand all
1186 host_impl_->ProcessScrollDeltas(); 1186 host_impl_->ProcessScrollDeltas();
1187 EXPECT_EQ(scroll_info->page_scale_delta, 2); 1187 EXPECT_EQ(scroll_info->page_scale_delta, 2);
1188 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); 1188 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
1189 } 1189 }
1190 1190
1191 // Anchor zoom-out 1191 // Anchor zoom-out
1192 { 1192 {
1193 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1193 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1194 min_page_scale, 1194 min_page_scale,
1195 max_page_scale); 1195 max_page_scale);
1196 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); 1196 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1197 1197
1198 did_request_redraw_ = false; 1198 did_request_redraw_ = false;
1199 did_request_animate_ = false; 1199 did_request_animate_ = false;
1200 host_impl_->StartPageScaleAnimation( 1200 host_impl_->StartPageScaleAnimation(
1201 gfx::Vector2d(25, 25), true, min_page_scale, duration); 1201 gfx::Vector2d(25, 25), true, min_page_scale, duration);
1202 EXPECT_FALSE(did_request_redraw_); 1202 EXPECT_FALSE(did_request_redraw_);
1203 EXPECT_TRUE(did_request_animate_); 1203 EXPECT_TRUE(did_request_animate_);
1204 1204
1205 did_request_redraw_ = false; 1205 did_request_redraw_ = false;
1206 did_request_animate_ = false; 1206 did_request_animate_ = false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 base::TimeDelta::FromSeconds(1); 1238 base::TimeDelta::FromSeconds(1);
1239 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1239 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1240 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1240 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1241 base::TimeTicks end_time = start_time + duration; 1241 base::TimeTicks end_time = start_time + duration;
1242 1242
1243 // Anchor zoom with unchanged page scale should not change scroll or scale. 1243 // Anchor zoom with unchanged page scale should not change scroll or scale.
1244 { 1244 {
1245 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1245 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1246 min_page_scale, 1246 min_page_scale,
1247 max_page_scale); 1247 max_page_scale);
1248 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); 1248 scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
1249 1249
1250 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), true, 1.f, duration); 1250 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), true, 1.f, duration);
1251 host_impl_->Animate(start_time); 1251 host_impl_->Animate(start_time);
1252 host_impl_->Animate(halfway_through_animation); 1252 host_impl_->Animate(halfway_through_animation);
1253 EXPECT_TRUE(did_request_redraw_); 1253 EXPECT_TRUE(did_request_redraw_);
1254 host_impl_->Animate(end_time); 1254 host_impl_->Animate(end_time);
1255 EXPECT_TRUE(did_request_commit_); 1255 EXPECT_TRUE(did_request_commit_);
1256 1256
1257 scoped_ptr<ScrollAndScaleSet> scroll_info = 1257 scoped_ptr<ScrollAndScaleSet> scroll_info =
1258 host_impl_->ProcessScrollDeltas(); 1258 host_impl_->ProcessScrollDeltas();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 host_impl_->InitializeRenderer(CreateOutputSurface()); \ 1302 host_impl_->InitializeRenderer(CreateOutputSurface()); \
1303 host_impl_->SetViewportSize(viewport_size); \ 1303 host_impl_->SetViewportSize(viewport_size); \
1304 \ 1304 \
1305 scoped_ptr<LayerImpl> root = \ 1305 scoped_ptr<LayerImpl> root = \
1306 LayerImpl::Create(host_impl_->active_tree(), 1); \ 1306 LayerImpl::Create(host_impl_->active_tree(), 1); \
1307 root->SetBounds(viewport_size); \ 1307 root->SetBounds(viewport_size); \
1308 \ 1308 \
1309 scoped_ptr<LayerImpl> scroll = \ 1309 scoped_ptr<LayerImpl> scroll = \
1310 LayerImpl::Create(host_impl_->active_tree(), 2); \ 1310 LayerImpl::Create(host_impl_->active_tree(), 2); \
1311 scroll->SetScrollClipLayer(root->id()); \ 1311 scroll->SetScrollClipLayer(root->id()); \
1312 scroll->SetScrollOffset(gfx::Vector2d()); \ 1312 scroll->SetScrollOffset(gfx::ScrollOffset()); \
1313 root->SetBounds(viewport_size); \ 1313 root->SetBounds(viewport_size); \
1314 scroll->SetBounds(content_size); \ 1314 scroll->SetBounds(content_size); \
1315 scroll->SetContentBounds(content_size); \ 1315 scroll->SetContentBounds(content_size); \
1316 scroll->SetIsContainerForFixedPositionLayers(true); \ 1316 scroll->SetIsContainerForFixedPositionLayers(true); \
1317 \ 1317 \
1318 scoped_ptr<LayerImpl> contents = \ 1318 scoped_ptr<LayerImpl> contents = \
1319 LayerImpl::Create(host_impl_->active_tree(), 3); \ 1319 LayerImpl::Create(host_impl_->active_tree(), 3); \
1320 contents->SetDrawsContent(true); \ 1320 contents->SetDrawsContent(true); \
1321 contents->SetBounds(content_size); \ 1321 contents->SetBounds(content_size); \
1322 contents->SetContentBounds(content_size); \ 1322 contents->SetContentBounds(content_size); \
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 1373
1374 // After the fade begins, we should start getting redraws instead of a 1374 // After the fade begins, we should start getting redraws instead of a
1375 // scheduled animation. 1375 // scheduled animation.
1376 fake_now += base::TimeDelta::FromMilliseconds(25); 1376 fake_now += base::TimeDelta::FromMilliseconds(25);
1377 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1377 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1378 EXPECT_TRUE(did_request_animate_); 1378 EXPECT_TRUE(did_request_animate_);
1379 did_request_animate_ = false; 1379 did_request_animate_ = false;
1380 1380
1381 // Setting the scroll offset outside a scroll should also cause the scrollbar 1381 // Setting the scroll offset outside a scroll should also cause the scrollbar
1382 // to appear and to schedule a fade. 1382 // to appear and to schedule a fade.
1383 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); 1383 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(
1384 gfx::ScrollOffset(5, 5));
1384 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), 1385 EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
1385 requested_scrollbar_animation_delay_); 1386 requested_scrollbar_animation_delay_);
1386 EXPECT_FALSE(did_request_redraw_); 1387 EXPECT_FALSE(did_request_redraw_);
1387 EXPECT_FALSE(did_request_animate_); 1388 EXPECT_FALSE(did_request_animate_);
1388 requested_scrollbar_animation_delay_ = base::TimeDelta(); 1389 requested_scrollbar_animation_delay_ = base::TimeDelta();
1389 1390
1390 // Unnecessarily Fade animation of solid color scrollbar is not triggered. 1391 // Unnecessarily Fade animation of solid color scrollbar is not triggered.
1391 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); 1392 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
1392 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); 1393 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
1393 host_impl_->ScrollEnd(); 1394 host_impl_->ScrollEnd();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 host_impl_->SetDeviceScaleFactor(device_scale_factor); 1469 host_impl_->SetDeviceScaleFactor(device_scale_factor);
1469 host_impl_->SetViewportSize(device_viewport_size); 1470 host_impl_->SetViewportSize(device_viewport_size);
1470 1471
1471 scoped_ptr<LayerImpl> root = 1472 scoped_ptr<LayerImpl> root =
1472 LayerImpl::Create(host_impl_->active_tree(), 1); 1473 LayerImpl::Create(host_impl_->active_tree(), 1);
1473 root->SetBounds(viewport_size); 1474 root->SetBounds(viewport_size);
1474 1475
1475 scoped_ptr<LayerImpl> scroll = 1476 scoped_ptr<LayerImpl> scroll =
1476 LayerImpl::Create(host_impl_->active_tree(), 2); 1477 LayerImpl::Create(host_impl_->active_tree(), 2);
1477 scroll->SetScrollClipLayer(root->id()); 1478 scroll->SetScrollClipLayer(root->id());
1478 scroll->SetScrollOffset(gfx::Vector2d()); 1479 scroll->SetScrollOffset(gfx::ScrollOffset());
1479 scroll->SetBounds(content_size); 1480 scroll->SetBounds(content_size);
1480 scroll->SetContentBounds(content_size); 1481 scroll->SetContentBounds(content_size);
1481 scroll->SetIsContainerForFixedPositionLayers(true); 1482 scroll->SetIsContainerForFixedPositionLayers(true);
1482 1483
1483 scoped_ptr<LayerImpl> contents = 1484 scoped_ptr<LayerImpl> contents =
1484 LayerImpl::Create(host_impl_->active_tree(), 3); 1485 LayerImpl::Create(host_impl_->active_tree(), 3);
1485 contents->SetDrawsContent(true); 1486 contents->SetDrawsContent(true);
1486 contents->SetBounds(content_size); 1487 contents->SetBounds(content_size);
1487 contents->SetContentBounds(content_size); 1488 contents->SetContentBounds(content_size);
1488 1489
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 host_impl_->top_controls_manager()->ScrollEnd(); 2410 host_impl_->top_controls_manager()->ScrollEnd();
2410 EXPECT_EQ(-2 * scroll_increment_y, 2411 EXPECT_EQ(-2 * scroll_increment_y,
2411 host_impl_->top_controls_manager()->ContentTopOffset()); 2412 host_impl_->top_controls_manager()->ContentTopOffset());
2412 // Now that top controls have moved, expect the clip to resize. 2413 // Now that top controls have moved, expect the clip to resize.
2413 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); 2414 EXPECT_EQ(clip_size_, root_clip_ptr->bounds());
2414 2415
2415 host_impl_->ScrollEnd(); 2416 host_impl_->ScrollEnd();
2416 2417
2417 // Verify the layer is once-again non-scrollable. 2418 // Verify the layer is once-again non-scrollable.
2418 EXPECT_EQ( 2419 EXPECT_EQ(
2419 gfx::Vector2d(), 2420 gfx::ScrollOffset(),
2420 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); 2421 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset());
2421 2422
2422 EXPECT_EQ(InputHandler::ScrollStarted, 2423 EXPECT_EQ(InputHandler::ScrollStarted,
2423 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); 2424 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
2424 } 2425 }
2425 2426
2426 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { 2427 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) {
2427 // Test the configuration where a non-composited root layer is embedded in a 2428 // Test the configuration where a non-composited root layer is embedded in a
2428 // scrollable outer layer. 2429 // scrollable outer layer.
2429 gfx::Size surface_size(10, 10); 2430 gfx::Size surface_size(10, 10);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 host_impl_->active_tree()->DidBecomeActive(); 2573 host_impl_->active_tree()->DidBecomeActive();
2573 host_impl_->SetViewportSize(viewport_size); 2574 host_impl_->SetViewportSize(viewport_size);
2574 DrawFrame(); 2575 DrawFrame();
2575 2576
2576 LayerImpl* root_scroll = 2577 LayerImpl* root_scroll =
2577 host_impl_->active_tree()->InnerViewportScrollLayer(); 2578 host_impl_->active_tree()->InnerViewportScrollLayer();
2578 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); 2579 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
2579 2580
2580 gfx::Vector2d scroll_delta(0, 10); 2581 gfx::Vector2d scroll_delta(0, 10);
2581 gfx::Vector2d expected_scroll_delta = scroll_delta; 2582 gfx::Vector2d expected_scroll_delta = scroll_delta;
2582 gfx::Vector2d expected_max_scroll = root_scroll->MaxScrollOffset(); 2583 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset();
2583 EXPECT_EQ(InputHandler::ScrollStarted, 2584 EXPECT_EQ(InputHandler::ScrollStarted,
2584 host_impl_->ScrollBegin(gfx::Point(5, 5), 2585 host_impl_->ScrollBegin(gfx::Point(5, 5),
2585 InputHandler::Wheel)); 2586 InputHandler::Wheel));
2586 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 2587 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
2587 host_impl_->ScrollEnd(); 2588 host_impl_->ScrollEnd();
2588 2589
2589 // Set new page scale from main thread. 2590 // Set new page scale from main thread.
2590 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, 2591 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale,
2591 page_scale, 2592 page_scale,
2592 page_scale); 2593 page_scale);
(...skipping 30 matching lines...) Expand all
2623 host_impl_->SetViewportSize(viewport_size); 2624 host_impl_->SetViewportSize(viewport_size);
2624 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale); 2625 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, page_scale);
2625 DrawFrame(); 2626 DrawFrame();
2626 2627
2627 LayerImpl* root_scroll = 2628 LayerImpl* root_scroll =
2628 host_impl_->active_tree()->InnerViewportScrollLayer(); 2629 host_impl_->active_tree()->InnerViewportScrollLayer();
2629 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); 2630 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds());
2630 2631
2631 gfx::Vector2d scroll_delta(0, 10); 2632 gfx::Vector2d scroll_delta(0, 10);
2632 gfx::Vector2d expected_scroll_delta = scroll_delta; 2633 gfx::Vector2d expected_scroll_delta = scroll_delta;
2633 gfx::Vector2d expected_max_scroll = root_scroll->MaxScrollOffset(); 2634 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset();
2634 EXPECT_EQ(InputHandler::ScrollStarted, 2635 EXPECT_EQ(InputHandler::ScrollStarted,
2635 host_impl_->ScrollBegin(gfx::Point(5, 5), 2636 host_impl_->ScrollBegin(gfx::Point(5, 5),
2636 InputHandler::Wheel)); 2637 InputHandler::Wheel));
2637 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 2638 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
2638 host_impl_->ScrollEnd(); 2639 host_impl_->ScrollEnd();
2639 2640
2640 // Set new page scale on impl thread by pinching. 2641 // Set new page scale on impl thread by pinching.
2641 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); 2642 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
2642 host_impl_->PinchGestureBegin(); 2643 host_impl_->PinchGestureBegin();
2643 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); 2644 host_impl_->PinchGestureUpdate(page_scale, gfx::Point());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2733 LayerImpl* child = child_scrolling.get(); 2734 LayerImpl* child = child_scrolling.get();
2734 root_scrolling_ptr->AddChild(child_scrolling.Pass()); 2735 root_scrolling_ptr->AddChild(child_scrolling.Pass());
2735 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2736 host_impl_->active_tree()->SetRootLayer(root.Pass());
2736 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); 2737 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
2737 host_impl_->active_tree()->DidBecomeActive(); 2738 host_impl_->active_tree()->DidBecomeActive();
2738 host_impl_->SetViewportSize(surface_size); 2739 host_impl_->SetViewportSize(surface_size);
2739 DrawFrame(); 2740 DrawFrame();
2740 2741
2741 gfx::Vector2d scroll_delta(0, 10); 2742 gfx::Vector2d scroll_delta(0, 10);
2742 gfx::Vector2d expected_scroll_delta(scroll_delta); 2743 gfx::Vector2d expected_scroll_delta(scroll_delta);
2743 gfx::Vector2d expected_max_scroll(child->MaxScrollOffset()); 2744 gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset());
2744 EXPECT_EQ(InputHandler::ScrollStarted, 2745 EXPECT_EQ(InputHandler::ScrollStarted,
2745 host_impl_->ScrollBegin(gfx::Point(5, 5), 2746 host_impl_->ScrollBegin(gfx::Point(5, 5),
2746 InputHandler::Wheel)); 2747 InputHandler::Wheel));
2747 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 2748 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
2748 host_impl_->ScrollEnd(); 2749 host_impl_->ScrollEnd();
2749 2750
2750 float page_scale = 2.f; 2751 float page_scale = 2.f;
2751 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale, 2752 host_impl_->active_tree()->SetPageScaleFactorAndLimits(page_scale,
2752 1.f, 2753 1.f,
2753 page_scale); 2754 page_scale);
(...skipping 27 matching lines...) Expand all
2781 scoped_ptr<LayerImpl> child = 2782 scoped_ptr<LayerImpl> child =
2782 CreateScrollableLayer(2, content_size, root.get()); 2783 CreateScrollableLayer(2, content_size, root.get());
2783 LayerImpl* grand_child_layer = grand_child.get(); 2784 LayerImpl* grand_child_layer = grand_child.get();
2784 child->AddChild(grand_child.Pass()); 2785 child->AddChild(grand_child.Pass());
2785 2786
2786 LayerImpl* child_layer = child.get(); 2787 LayerImpl* child_layer = child.get();
2787 root->AddChild(child.Pass()); 2788 root->AddChild(child.Pass());
2788 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2789 host_impl_->active_tree()->SetRootLayer(root.Pass());
2789 host_impl_->active_tree()->DidBecomeActive(); 2790 host_impl_->active_tree()->DidBecomeActive();
2790 host_impl_->SetViewportSize(surface_size); 2791 host_impl_->SetViewportSize(surface_size);
2791 grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 5)); 2792 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 5));
2792 child_layer->SetScrollOffset(gfx::Vector2d(3, 0)); 2793 child_layer->SetScrollOffset(gfx::ScrollOffset(3, 0));
2793 2794
2794 DrawFrame(); 2795 DrawFrame();
2795 { 2796 {
2796 gfx::Vector2d scroll_delta(-8, -7); 2797 gfx::Vector2d scroll_delta(-8, -7);
2797 EXPECT_EQ(InputHandler::ScrollStarted, 2798 EXPECT_EQ(InputHandler::ScrollStarted,
2798 host_impl_->ScrollBegin(gfx::Point(), 2799 host_impl_->ScrollBegin(gfx::Point(),
2799 InputHandler::Wheel)); 2800 InputHandler::Wheel));
2800 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 2801 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
2801 host_impl_->ScrollEnd(); 2802 host_impl_->ScrollEnd();
2802 2803
(...skipping 30 matching lines...) Expand all
2833 2834
2834 LayerImpl* child_layer = child.get(); 2835 LayerImpl* child_layer = child.get();
2835 root_scrolling->AddChild(child.Pass()); 2836 root_scrolling->AddChild(child.Pass());
2836 root->AddChild(root_scrolling.Pass()); 2837 root->AddChild(root_scrolling.Pass());
2837 EXPECT_EQ(viewport_size, root->bounds()); 2838 EXPECT_EQ(viewport_size, root->bounds());
2838 host_impl_->active_tree()->SetRootLayer(root.Pass()); 2839 host_impl_->active_tree()->SetRootLayer(root.Pass());
2839 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID); 2840 host_impl_->active_tree()->SetViewportLayersFromIds(1, 2, Layer::INVALID_ID);
2840 host_impl_->active_tree()->DidBecomeActive(); 2841 host_impl_->active_tree()->DidBecomeActive();
2841 host_impl_->SetViewportSize(viewport_size); 2842 host_impl_->SetViewportSize(viewport_size);
2842 2843
2843 grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 2)); 2844 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2));
2844 child_layer->SetScrollOffset(gfx::Vector2d(0, 3)); 2845 child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3));
2845 2846
2846 DrawFrame(); 2847 DrawFrame();
2847 { 2848 {
2848 gfx::Vector2d scroll_delta(0, -10); 2849 gfx::Vector2d scroll_delta(0, -10);
2849 EXPECT_EQ(InputHandler::ScrollStarted, 2850 EXPECT_EQ(InputHandler::ScrollStarted,
2850 host_impl_->ScrollBegin(gfx::Point(), 2851 host_impl_->ScrollBegin(gfx::Point(),
2851 InputHandler::NonBubblingGesture)); 2852 InputHandler::NonBubblingGesture));
2852 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 2853 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
2853 host_impl_->ScrollEnd(); 2854 host_impl_->ScrollEnd();
2854 2855
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
3172 int height = 20; 3173 int height = 20;
3173 int scale = 3; 3174 int scale = 3;
3174 SetupScrollAndContentsLayers(gfx::Size(width, height)); 3175 SetupScrollAndContentsLayers(gfx::Size(width, height));
3175 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds( 3176 host_impl_->active_tree()->InnerViewportContainerLayer()->SetBounds(
3176 gfx::Size(width * scale - 1, height * scale)); 3177 gfx::Size(width * scale - 1, height * scale));
3177 host_impl_->SetDeviceScaleFactor(scale); 3178 host_impl_->SetDeviceScaleFactor(scale);
3178 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); 3179 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
3179 3180
3180 LayerImpl* inner_viewport_scroll_layer = 3181 LayerImpl* inner_viewport_scroll_layer =
3181 host_impl_->active_tree()->InnerViewportScrollLayer(); 3182 host_impl_->active_tree()->InnerViewportScrollLayer();
3182 EXPECT_EQ(gfx::Vector2d(0, 0), 3183 EXPECT_EQ(gfx::ScrollOffset(0, 0),
3183 inner_viewport_scroll_layer->MaxScrollOffset()); 3184 inner_viewport_scroll_layer->MaxScrollOffset());
3184 } 3185 }
3185 3186
3186 class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate { 3187 class TestScrollOffsetDelegate : public LayerScrollOffsetDelegate {
3187 public: 3188 public:
3188 TestScrollOffsetDelegate() 3189 TestScrollOffsetDelegate()
3189 : page_scale_factor_(0.f), 3190 : page_scale_factor_(0.f),
3190 min_page_scale_factor_(-1.f), 3191 min_page_scale_factor_(-1.f),
3191 max_page_scale_factor_(-1.f) {} 3192 max_page_scale_factor_(-1.f) {}
3192 3193
3193 virtual ~TestScrollOffsetDelegate() {} 3194 virtual ~TestScrollOffsetDelegate() {}
3194 3195
3195 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { 3196 virtual gfx::ScrollOffset GetTotalScrollOffset() OVERRIDE {
3196 return getter_return_value_; 3197 return getter_return_value_;
3197 } 3198 }
3198 3199
3199 virtual bool IsExternalFlingActive() const OVERRIDE { return false; } 3200 virtual bool IsExternalFlingActive() const OVERRIDE { return false; }
3200 3201
3201 virtual void UpdateRootLayerState(const gfx::Vector2dF& total_scroll_offset, 3202 virtual void UpdateRootLayerState(
3202 const gfx::Vector2dF& max_scroll_offset, 3203 const gfx::ScrollOffset& total_scroll_offset,
3203 const gfx::SizeF& scrollable_size, 3204 const gfx::ScrollOffset& max_scroll_offset,
3204 float page_scale_factor, 3205 const gfx::SizeF& scrollable_size,
3205 float min_page_scale_factor, 3206 float page_scale_factor,
3206 float max_page_scale_factor) OVERRIDE { 3207 float min_page_scale_factor,
3208 float max_page_scale_factor) OVERRIDE {
3207 DCHECK(total_scroll_offset.x() <= max_scroll_offset.x()); 3209 DCHECK(total_scroll_offset.x() <= max_scroll_offset.x());
3208 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); 3210 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y());
3209 last_set_scroll_offset_ = total_scroll_offset; 3211 last_set_scroll_offset_ = total_scroll_offset;
3210 max_scroll_offset_ = max_scroll_offset; 3212 max_scroll_offset_ = max_scroll_offset;
3211 scrollable_size_ = scrollable_size; 3213 scrollable_size_ = scrollable_size;
3212 page_scale_factor_ = page_scale_factor; 3214 page_scale_factor_ = page_scale_factor;
3213 min_page_scale_factor_ = min_page_scale_factor; 3215 min_page_scale_factor_ = min_page_scale_factor;
3214 max_page_scale_factor_ = max_page_scale_factor; 3216 max_page_scale_factor_ = max_page_scale_factor;
3215 } 3217 }
3216 3218
3217 gfx::Vector2dF last_set_scroll_offset() { 3219 gfx::ScrollOffset last_set_scroll_offset() {
3218 return last_set_scroll_offset_; 3220 return last_set_scroll_offset_;
3219 } 3221 }
3220 3222
3221 void set_getter_return_value(const gfx::Vector2dF& value) { 3223 void set_getter_return_value(const gfx::ScrollOffset& value) {
3222 getter_return_value_ = value; 3224 getter_return_value_ = value;
3223 } 3225 }
3224 3226
3225 gfx::Vector2dF max_scroll_offset() const { 3227 gfx::ScrollOffset max_scroll_offset() const {
3226 return max_scroll_offset_; 3228 return max_scroll_offset_;
3227 } 3229 }
3228 3230
3229 gfx::SizeF scrollable_size() const { 3231 gfx::SizeF scrollable_size() const {
3230 return scrollable_size_; 3232 return scrollable_size_;
3231 } 3233 }
3232 3234
3233 float page_scale_factor() const { 3235 float page_scale_factor() const {
3234 return page_scale_factor_; 3236 return page_scale_factor_;
3235 } 3237 }
3236 3238
3237 float min_page_scale_factor() const { 3239 float min_page_scale_factor() const {
3238 return min_page_scale_factor_; 3240 return min_page_scale_factor_;
3239 } 3241 }
3240 3242
3241 float max_page_scale_factor() const { 3243 float max_page_scale_factor() const {
3242 return max_page_scale_factor_; 3244 return max_page_scale_factor_;
3243 } 3245 }
3244 3246
3245 private: 3247 private:
3246 gfx::Vector2dF last_set_scroll_offset_; 3248 gfx::ScrollOffset last_set_scroll_offset_;
3247 gfx::Vector2dF getter_return_value_; 3249 gfx::ScrollOffset getter_return_value_;
3248 gfx::Vector2dF max_scroll_offset_; 3250 gfx::ScrollOffset max_scroll_offset_;
3249 gfx::SizeF scrollable_size_; 3251 gfx::SizeF scrollable_size_;
3250 float page_scale_factor_; 3252 float page_scale_factor_;
3251 float min_page_scale_factor_; 3253 float min_page_scale_factor_;
3252 float max_page_scale_factor_; 3254 float max_page_scale_factor_;
3253 }; 3255 };
3254 3256
3255 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { 3257 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) {
3256 TestScrollOffsetDelegate scroll_delegate; 3258 TestScrollOffsetDelegate scroll_delegate;
3257 host_impl_->SetViewportSize(gfx::Size(10, 20)); 3259 host_impl_->SetViewportSize(gfx::Size(10, 20));
3258 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 3260 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
3259 LayerImpl* clip_layer = scroll_layer->parent()->parent(); 3261 LayerImpl* clip_layer = scroll_layer->parent()->parent();
3260 clip_layer->SetBounds(gfx::Size(10, 20)); 3262 clip_layer->SetBounds(gfx::Size(10, 20));
3261 3263
3262 // Setting the delegate results in the current scroll offset being set. 3264 // Setting the delegate results in the current scroll offset being set.
3263 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); 3265 gfx::Vector2dF initial_scroll_delta(10.f, 10.f);
3264 scroll_layer->SetScrollOffset(gfx::Vector2d()); 3266 scroll_layer->SetScrollOffset(gfx::ScrollOffset());
3265 scroll_layer->SetScrollDelta(initial_scroll_delta); 3267 scroll_layer->SetScrollDelta(initial_scroll_delta);
3266 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); 3268 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate);
3267 EXPECT_EQ(initial_scroll_delta.ToString(), 3269 EXPECT_EQ(initial_scroll_delta.ToString(),
3268 scroll_delegate.last_set_scroll_offset().ToString()); 3270 scroll_delegate.last_set_scroll_offset().ToString());
3269 3271
3270 // Setting the delegate results in the scrollable_size, max_scroll_offset, 3272 // Setting the delegate results in the scrollable_size, max_scroll_offset,
3271 // page_scale_factor and {min|max}_page_scale_factor being set. 3273 // page_scale_factor and {min|max}_page_scale_factor being set.
3272 EXPECT_EQ(gfx::SizeF(100, 100), scroll_delegate.scrollable_size()); 3274 EXPECT_EQ(gfx::SizeF(100, 100), scroll_delegate.scrollable_size());
3273 EXPECT_EQ(gfx::Vector2dF(90, 80), scroll_delegate.max_scroll_offset()); 3275 EXPECT_EQ(gfx::ScrollOffset(90, 80), scroll_delegate.max_scroll_offset());
3274 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); 3276 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor());
3275 EXPECT_EQ(0.f, scroll_delegate.min_page_scale_factor()); 3277 EXPECT_EQ(0.f, scroll_delegate.min_page_scale_factor());
3276 EXPECT_EQ(0.f, scroll_delegate.max_page_scale_factor()); 3278 EXPECT_EQ(0.f, scroll_delegate.max_page_scale_factor());
3277 3279
3278 // Updating page scale immediately updates the delegate. 3280 // Updating page scale immediately updates the delegate.
3279 host_impl_->active_tree()->SetPageScaleFactorAndLimits(2.f, 0.5f, 4.f); 3281 host_impl_->active_tree()->SetPageScaleFactorAndLimits(2.f, 0.5f, 4.f);
3280 EXPECT_EQ(2.f, scroll_delegate.page_scale_factor()); 3282 EXPECT_EQ(2.f, scroll_delegate.page_scale_factor());
3281 EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor()); 3283 EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor());
3282 EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor()); 3284 EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor());
3283 host_impl_->active_tree()->SetPageScaleDelta(1.5f); 3285 host_impl_->active_tree()->SetPageScaleDelta(1.5f);
(...skipping 11 matching lines...) Expand all
3295 // delegate). 3297 // delegate).
3296 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); 3298 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture);
3297 host_impl_->PinchGestureBegin(); 3299 host_impl_->PinchGestureBegin();
3298 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); 3300 host_impl_->PinchGestureUpdate(2.f, gfx::Point());
3299 host_impl_->PinchGestureUpdate(.5f, gfx::Point()); 3301 host_impl_->PinchGestureUpdate(.5f, gfx::Point());
3300 host_impl_->PinchGestureEnd(); 3302 host_impl_->PinchGestureEnd();
3301 host_impl_->ScrollEnd(); 3303 host_impl_->ScrollEnd();
3302 3304
3303 // Scrolling should be relative to the offset as returned by the delegate. 3305 // Scrolling should be relative to the offset as returned by the delegate.
3304 gfx::Vector2dF scroll_delta(0.f, 10.f); 3306 gfx::Vector2dF scroll_delta(0.f, 10.f);
3305 gfx::Vector2dF current_offset(7.f, 8.f); 3307 gfx::ScrollOffset current_offset(7.f, 8.f);
3306 3308
3307 scroll_delegate.set_getter_return_value(current_offset); 3309 scroll_delegate.set_getter_return_value(current_offset);
3308 EXPECT_EQ(InputHandler::ScrollStarted, 3310 EXPECT_EQ(InputHandler::ScrollStarted,
3309 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); 3311 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
3310 3312
3311 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 3313 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
3312 EXPECT_EQ(current_offset + scroll_delta, 3314 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta),
3313 scroll_delegate.last_set_scroll_offset()); 3315 scroll_delegate.last_set_scroll_offset());
3314 3316
3315 current_offset = gfx::Vector2dF(42.f, 41.f); 3317 current_offset = gfx::ScrollOffset(42.f, 41.f);
3316 scroll_delegate.set_getter_return_value(current_offset); 3318 scroll_delegate.set_getter_return_value(current_offset);
3317 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 3319 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
3318 EXPECT_EQ(current_offset + scroll_delta, 3320 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta),
3319 scroll_delegate.last_set_scroll_offset()); 3321 scroll_delegate.last_set_scroll_offset());
3320 host_impl_->ScrollEnd(); 3322 host_impl_->ScrollEnd();
3321 scroll_delegate.set_getter_return_value(gfx::Vector2dF()); 3323 scroll_delegate.set_getter_return_value(gfx::ScrollOffset());
3322 3324
3323 // Forces a full tree synchronization and ensures that the scroll delegate 3325 // Forces a full tree synchronization and ensures that the scroll delegate
3324 // sees the correct size of the new tree. 3326 // sees the correct size of the new tree.
3325 gfx::Size new_size(42, 24); 3327 gfx::Size new_size(42, 24);
3326 host_impl_->CreatePendingTree(); 3328 host_impl_->CreatePendingTree();
3327 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size); 3329 CreateScrollAndContentsLayers(host_impl_->pending_tree(), new_size);
3328 host_impl_->ActivateSyncTree(); 3330 host_impl_->ActivateSyncTree();
3329 EXPECT_EQ(new_size, scroll_delegate.scrollable_size()); 3331 EXPECT_EQ(new_size, scroll_delegate.scrollable_size());
3330 3332
3331 // Un-setting the delegate should propagate the delegate's current offset to 3333 // Un-setting the delegate should propagate the delegate's current offset to
3332 // the root scrollable layer. 3334 // the root scrollable layer.
3333 current_offset = gfx::Vector2dF(13.f, 12.f); 3335 current_offset = gfx::ScrollOffset(13.f, 12.f);
3334 scroll_delegate.set_getter_return_value(current_offset); 3336 scroll_delegate.set_getter_return_value(current_offset);
3335 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); 3337 host_impl_->SetRootLayerScrollOffsetDelegate(NULL);
3336 3338
3337 EXPECT_EQ(current_offset.ToString(), 3339 EXPECT_EQ(current_offset.ToString(),
3338 scroll_layer->TotalScrollOffset().ToString()); 3340 scroll_layer->TotalScrollOffset().ToString());
3339 } 3341 }
3340 3342
3341 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) { 3343 void CheckLayerScrollDelta(LayerImpl* layer, gfx::Vector2dF scroll_delta) {
3342 const gfx::Transform target_space_transform = 3344 const gfx::Transform target_space_transform =
3343 layer->draw_properties().target_space_transform; 3345 layer->draw_properties().target_space_transform;
(...skipping 12 matching lines...) Expand all
3356 LayerImpl* clip_layer = scroll_layer->parent()->parent(); 3358 LayerImpl* clip_layer = scroll_layer->parent()->parent();
3357 clip_layer->SetBounds(gfx::Size(10, 20)); 3359 clip_layer->SetBounds(gfx::Size(10, 20));
3358 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate); 3360 host_impl_->SetRootLayerScrollOffsetDelegate(&scroll_delegate);
3359 3361
3360 // Draw first frame to clear any pending draws and check scroll. 3362 // Draw first frame to clear any pending draws and check scroll.
3361 DrawFrame(); 3363 DrawFrame();
3362 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); 3364 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f));
3363 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); 3365 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties());
3364 3366
3365 // Set external scroll delta on delegate and notify LayerTreeHost. 3367 // Set external scroll delta on delegate and notify LayerTreeHost.
3366 gfx::Vector2dF scroll_delta(10.f, 10.f); 3368 gfx::ScrollOffset scroll_delta(10.f, 10.f);
3367 scroll_delegate.set_getter_return_value(scroll_delta); 3369 scroll_delegate.set_getter_return_value(scroll_delta);
3368 host_impl_->OnRootLayerDelegatedScrollOffsetChanged(); 3370 host_impl_->OnRootLayerDelegatedScrollOffsetChanged();
3369 3371
3370 // Check scroll delta reflected in layer. 3372 // Check scroll delta reflected in layer.
3371 DrawFrame(); 3373 DrawFrame();
3372 CheckLayerScrollDelta(scroll_layer, scroll_delta); 3374 CheckLayerScrollDelta(scroll_layer, ScrollOffsetToVector2dF(scroll_delta));
3373 3375
3374 host_impl_->SetRootLayerScrollOffsetDelegate(NULL); 3376 host_impl_->SetRootLayerScrollOffsetDelegate(NULL);
3375 } 3377 }
3376 3378
3377 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { 3379 TEST_F(LayerTreeHostImplTest, OverscrollRoot) {
3378 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 3380 SetupScrollAndContentsLayers(gfx::Size(100, 100));
3379 host_impl_->SetViewportSize(gfx::Size(50, 50)); 3381 host_impl_->SetViewportSize(gfx::Size(50, 50));
3380 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f); 3382 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 0.5f, 4.f);
3381 DrawFrame(); 3383 DrawFrame();
3382 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); 3384 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3433 CreateScrollableLayer(3, surface_size, root_clip.get()); 3435 CreateScrollableLayer(3, surface_size, root_clip.get());
3434 3436
3435 scoped_ptr<LayerImpl> child = 3437 scoped_ptr<LayerImpl> child =
3436 CreateScrollableLayer(2, surface_size, root_clip.get()); 3438 CreateScrollableLayer(2, surface_size, root_clip.get());
3437 LayerImpl* grand_child_layer = grand_child.get(); 3439 LayerImpl* grand_child_layer = grand_child.get();
3438 child->AddChild(grand_child.Pass()); 3440 child->AddChild(grand_child.Pass());
3439 3441
3440 LayerImpl* child_layer = child.get(); 3442 LayerImpl* child_layer = child.get();
3441 root->AddChild(child.Pass()); 3443 root->AddChild(child.Pass());
3442 root_clip->AddChild(root.Pass()); 3444 root_clip->AddChild(root.Pass());
3443 child_layer->SetScrollOffset(gfx::Vector2d(0, 3)); 3445 child_layer->SetScrollOffset(gfx::ScrollOffset(0, 3));
3444 grand_child_layer->SetScrollOffset(gfx::Vector2d(0, 2)); 3446 grand_child_layer->SetScrollOffset(gfx::ScrollOffset(0, 2));
3445 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); 3447 host_impl_->active_tree()->SetRootLayer(root_clip.Pass());
3446 host_impl_->active_tree()->DidBecomeActive(); 3448 host_impl_->active_tree()->DidBecomeActive();
3447 host_impl_->SetViewportSize(surface_size); 3449 host_impl_->SetViewportSize(surface_size);
3448 DrawFrame(); 3450 DrawFrame();
3449 { 3451 {
3450 gfx::Vector2d scroll_delta(0, -10); 3452 gfx::Vector2d scroll_delta(0, -10);
3451 EXPECT_EQ(InputHandler::ScrollStarted, 3453 EXPECT_EQ(InputHandler::ScrollStarted,
3452 host_impl_->ScrollBegin(gfx::Point(), 3454 host_impl_->ScrollBegin(gfx::Point(),
3453 InputHandler::NonBubblingGesture)); 3455 InputHandler::NonBubblingGesture));
3454 host_impl_->ScrollBy(gfx::Point(), scroll_delta); 3456 host_impl_->ScrollBy(gfx::Point(), scroll_delta);
(...skipping 2179 matching lines...) Expand 10 before | Expand all | Expand 10 after
5634 5636
5635 scoped_ptr<FakePictureLayerImpl> scoped_content_layer = 5637 scoped_ptr<FakePictureLayerImpl> scoped_content_layer =
5636 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile); 5638 FakePictureLayerImpl::CreateWithPile(host_impl_->pending_tree(), 3, pile);
5637 LayerImpl* content_layer = scoped_content_layer.get(); 5639 LayerImpl* content_layer = scoped_content_layer.get();
5638 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>()); 5640 scrolling_layer->AddChild(scoped_content_layer.PassAs<LayerImpl>());
5639 content_layer->SetBounds(content_layer_bounds); 5641 content_layer->SetBounds(content_layer_bounds);
5640 content_layer->SetDrawsContent(true); 5642 content_layer->SetDrawsContent(true);
5641 5643
5642 root->SetBounds(root_size); 5644 root->SetBounds(root_size);
5643 5645
5644 gfx::Vector2d scroll_offset(100000, 0); 5646 gfx::ScrollOffset scroll_offset(100000, 0);
5645 scrolling_layer->SetScrollClipLayer(root->id()); 5647 scrolling_layer->SetScrollClipLayer(root->id());
5646 scrolling_layer->SetScrollOffset(scroll_offset); 5648 scrolling_layer->SetScrollOffset(scroll_offset);
5647 5649
5648 host_impl_->ActivateSyncTree(); 5650 host_impl_->ActivateSyncTree();
5649 5651
5650 host_impl_->active_tree()->UpdateDrawProperties(); 5652 host_impl_->active_tree()->UpdateDrawProperties();
5651 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); 5653 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size());
5652 5654
5653 LayerTreeHostImpl::FrameData frame; 5655 LayerTreeHostImpl::FrameData frame;
5654 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 5656 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
6164 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) { 6166 TEST_F(LayerTreeHostImplTest, TouchFlingShouldLockToFirstScrolledLayer) {
6165 // Scroll a child layer beyond its maximum scroll range and make sure the 6167 // Scroll a child layer beyond its maximum scroll range and make sure the
6166 // the scroll doesn't bubble up to the parent layer. 6168 // the scroll doesn't bubble up to the parent layer.
6167 gfx::Size surface_size(10, 10); 6169 gfx::Size surface_size(10, 10);
6168 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 6170 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
6169 scoped_ptr<LayerImpl> root_scrolling = 6171 scoped_ptr<LayerImpl> root_scrolling =
6170 CreateScrollableLayer(2, surface_size, root.get()); 6172 CreateScrollableLayer(2, surface_size, root.get());
6171 6173
6172 scoped_ptr<LayerImpl> grand_child = 6174 scoped_ptr<LayerImpl> grand_child =
6173 CreateScrollableLayer(4, surface_size, root.get()); 6175 CreateScrollableLayer(4, surface_size, root.get());
6174 grand_child->SetScrollOffset(gfx::Vector2d(0, 2)); 6176 grand_child->SetScrollOffset(gfx::ScrollOffset(0, 2));
6175 6177
6176 scoped_ptr<LayerImpl> child = 6178 scoped_ptr<LayerImpl> child =
6177 CreateScrollableLayer(3, surface_size, root.get()); 6179 CreateScrollableLayer(3, surface_size, root.get());
6178 child->SetScrollOffset(gfx::Vector2d(0, 4)); 6180 child->SetScrollOffset(gfx::ScrollOffset(0, 4));
6179 child->AddChild(grand_child.Pass()); 6181 child->AddChild(grand_child.Pass());
6180 6182
6181 root_scrolling->AddChild(child.Pass()); 6183 root_scrolling->AddChild(child.Pass());
6182 root->AddChild(root_scrolling.Pass()); 6184 root->AddChild(root_scrolling.Pass());
6183 host_impl_->active_tree()->SetRootLayer(root.Pass()); 6185 host_impl_->active_tree()->SetRootLayer(root.Pass());
6184 host_impl_->active_tree()->DidBecomeActive(); 6186 host_impl_->active_tree()->DidBecomeActive();
6185 host_impl_->SetViewportSize(surface_size); 6187 host_impl_->SetViewportSize(surface_size);
6186 DrawFrame(); 6188 DrawFrame();
6187 { 6189 {
6188 scoped_ptr<ScrollAndScaleSet> scroll_info; 6190 scoped_ptr<ScrollAndScaleSet> scroll_info;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
6656 } 6658 }
6657 6659
6658 protected: 6660 protected:
6659 static const int top_controls_height_; 6661 static const int top_controls_height_;
6660 }; 6662 };
6661 6663
6662 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; 6664 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50;
6663 6665
6664 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { 6666 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
6665 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 6667 SetupScrollAndContentsLayers(gfx::Size(100, 100))
6666 ->SetScrollOffset(gfx::Vector2d(0, 10)); 6668 ->SetScrollOffset(gfx::ScrollOffset(0, 10));
6667 host_impl_->Animate(base::TimeTicks()); 6669 host_impl_->Animate(base::TimeTicks());
6668 EXPECT_FALSE(did_request_redraw_); 6670 EXPECT_FALSE(did_request_redraw_);
6669 } 6671 }
6670 6672
6671 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) { 6673 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) {
6672 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 6674 SetupScrollAndContentsLayers(gfx::Size(100, 100))
6673 ->SetScrollOffset(gfx::Vector2d(0, 10)); 6675 ->SetScrollOffset(gfx::ScrollOffset(0, 10));
6674 host_impl_->DidChangeTopControlsPosition(); 6676 host_impl_->DidChangeTopControlsPosition();
6675 EXPECT_TRUE(did_request_animate_); 6677 EXPECT_TRUE(did_request_animate_);
6676 EXPECT_TRUE(did_request_redraw_); 6678 EXPECT_TRUE(did_request_redraw_);
6677 } 6679 }
6678 6680
6679 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { 6681 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
6680 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 6682 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
6681 host_impl_->SetViewportSize(gfx::Size(100, 100)); 6683 host_impl_->SetViewportSize(gfx::Size(100, 100));
6682 host_impl_->top_controls_manager()->UpdateTopControlsState( 6684 host_impl_->top_controls_manager()->UpdateTopControlsState(
6683 BOTH, SHOWN, false); 6685 BOTH, SHOWN, false);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
6795 } 6797 }
6796 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); 6798 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
6797 } 6799 }
6798 6800
6799 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { 6801 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
6800 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 6802 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
6801 host_impl_->SetViewportSize(gfx::Size(100, 100)); 6803 host_impl_->SetViewportSize(gfx::Size(100, 100));
6802 host_impl_->top_controls_manager()->UpdateTopControlsState( 6804 host_impl_->top_controls_manager()->UpdateTopControlsState(
6803 BOTH, SHOWN, false); 6805 BOTH, SHOWN, false);
6804 float initial_scroll_offset = 50; 6806 float initial_scroll_offset = 50;
6805 scroll_layer->SetScrollOffset(gfx::Vector2d(0, initial_scroll_offset)); 6807 scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, initial_scroll_offset));
6806 DrawFrame(); 6808 DrawFrame();
6807 6809
6808 EXPECT_EQ(InputHandler::ScrollStarted, 6810 EXPECT_EQ(InputHandler::ScrollStarted,
6809 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); 6811 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
6810 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); 6812 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset());
6811 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), 6813 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(),
6812 scroll_layer->TotalScrollOffset().ToString()); 6814 scroll_layer->TotalScrollOffset().ToString());
6813 6815
6814 // Scroll the top controls partially. 6816 // Scroll the top controls partially.
6815 const float residue = 15; 6817 const float residue = 15;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6862 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree(); 6864 LayerTreeImpl* layer_tree_impl = host_impl_->active_tree();
6863 const int kOuterViewportClipLayerId = 6; 6865 const int kOuterViewportClipLayerId = 6;
6864 const int kOuterViewportScrollLayerId = 7; 6866 const int kOuterViewportScrollLayerId = 7;
6865 const int kInnerViewportScrollLayerId = 2; 6867 const int kInnerViewportScrollLayerId = 2;
6866 const int kInnerViewportClipLayerId = 4; 6868 const int kInnerViewportClipLayerId = 4;
6867 const int kPageScaleLayerId = 5; 6869 const int kPageScaleLayerId = 5;
6868 6870
6869 scoped_ptr<LayerImpl> inner_scroll = 6871 scoped_ptr<LayerImpl> inner_scroll =
6870 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId); 6872 LayerImpl::Create(layer_tree_impl, kInnerViewportScrollLayerId);
6871 inner_scroll->SetIsContainerForFixedPositionLayers(true); 6873 inner_scroll->SetIsContainerForFixedPositionLayers(true);
6872 inner_scroll->SetScrollOffset(gfx::Vector2d()); 6874 inner_scroll->SetScrollOffset(gfx::ScrollOffset());
6873 6875
6874 scoped_ptr<LayerImpl> inner_clip = 6876 scoped_ptr<LayerImpl> inner_clip =
6875 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId); 6877 LayerImpl::Create(layer_tree_impl, kInnerViewportClipLayerId);
6876 inner_clip->SetBounds(inner_viewport); 6878 inner_clip->SetBounds(inner_viewport);
6877 6879
6878 scoped_ptr<LayerImpl> page_scale = 6880 scoped_ptr<LayerImpl> page_scale =
6879 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId); 6881 LayerImpl::Create(layer_tree_impl, kPageScaleLayerId);
6880 6882
6881 inner_scroll->SetScrollClipLayer(inner_clip->id()); 6883 inner_scroll->SetScrollClipLayer(inner_clip->id());
6882 inner_scroll->SetBounds(outer_viewport); 6884 inner_scroll->SetBounds(outer_viewport);
6883 inner_scroll->SetContentBounds(outer_viewport); 6885 inner_scroll->SetContentBounds(outer_viewport);
6884 inner_scroll->SetPosition(gfx::PointF()); 6886 inner_scroll->SetPosition(gfx::PointF());
6885 6887
6886 scoped_ptr<LayerImpl> outer_clip = 6888 scoped_ptr<LayerImpl> outer_clip =
6887 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId); 6889 LayerImpl::Create(layer_tree_impl, kOuterViewportClipLayerId);
6888 outer_clip->SetBounds(outer_viewport); 6890 outer_clip->SetBounds(outer_viewport);
6889 outer_clip->SetIsContainerForFixedPositionLayers(true); 6891 outer_clip->SetIsContainerForFixedPositionLayers(true);
6890 6892
6891 scoped_ptr<LayerImpl> outer_scroll = 6893 scoped_ptr<LayerImpl> outer_scroll =
6892 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId); 6894 LayerImpl::Create(layer_tree_impl, kOuterViewportScrollLayerId);
6893 outer_scroll->SetScrollClipLayer(outer_clip->id()); 6895 outer_scroll->SetScrollClipLayer(outer_clip->id());
6894 outer_scroll->SetScrollOffset(gfx::Vector2d()); 6896 outer_scroll->SetScrollOffset(gfx::ScrollOffset());
6895 outer_scroll->SetBounds(content_size); 6897 outer_scroll->SetBounds(content_size);
6896 outer_scroll->SetContentBounds(content_size); 6898 outer_scroll->SetContentBounds(content_size);
6897 outer_scroll->SetPosition(gfx::PointF()); 6899 outer_scroll->SetPosition(gfx::PointF());
6898 6900
6899 scoped_ptr<LayerImpl> contents = 6901 scoped_ptr<LayerImpl> contents =
6900 LayerImpl::Create(layer_tree_impl, 8); 6902 LayerImpl::Create(layer_tree_impl, 8);
6901 contents->SetDrawsContent(true); 6903 contents->SetDrawsContent(true);
6902 contents->SetBounds(content_size); 6904 contents->SetBounds(content_size);
6903 contents->SetContentBounds(content_size); 6905 contents->SetContentBounds(content_size);
6904 contents->SetPosition(gfx::PointF()); 6906 contents->SetPosition(gfx::PointF());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
7025 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); 7027 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
7026 7028
7027 EXPECT_EQ(InputHandler::ScrollStarted, 7029 EXPECT_EQ(InputHandler::ScrollStarted,
7028 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 7030 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
7029 7031
7030 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 7032 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
7031 7033
7032 host_impl_->Animate(start_time); 7034 host_impl_->Animate(start_time);
7033 host_impl_->UpdateAnimationState(true); 7035 host_impl_->UpdateAnimationState(true);
7034 7036
7035 EXPECT_EQ(gfx::Vector2dF(), scrolling_layer->TotalScrollOffset()); 7037 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->TotalScrollOffset());
7036 7038
7037 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); 7039 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
7038 host_impl_->UpdateAnimationState(true); 7040 host_impl_->UpdateAnimationState(true);
7039 7041
7040 float y = scrolling_layer->TotalScrollOffset().y(); 7042 float y = scrolling_layer->TotalScrollOffset().y();
7041 EXPECT_TRUE(y > 1 && y < 49); 7043 EXPECT_TRUE(y > 1 && y < 49);
7042 7044
7043 // Update target. 7045 // Update target.
7044 EXPECT_EQ(InputHandler::ScrollStarted, 7046 EXPECT_EQ(InputHandler::ScrollStarted,
7045 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 7047 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
7046 7048
7047 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); 7049 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
7048 host_impl_->UpdateAnimationState(true); 7050 host_impl_->UpdateAnimationState(true);
7049 7051
7050 y = scrolling_layer->TotalScrollOffset().y(); 7052 y = scrolling_layer->TotalScrollOffset().y();
7051 EXPECT_TRUE(y > 50 && y < 100); 7053 EXPECT_TRUE(y > 50 && y < 100);
7052 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); 7054 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
7053 7055
7054 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 7056 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
7055 host_impl_->UpdateAnimationState(true); 7057 host_impl_->UpdateAnimationState(true);
7056 7058
7057 EXPECT_EQ(gfx::Vector2dF(0, 100), scrolling_layer->TotalScrollOffset()); 7059 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
7060 scrolling_layer->TotalScrollOffset());
7058 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 7061 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
7059 } 7062 }
7060 7063
7061 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { 7064 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
7062 host_impl_->CreatePendingTree(); 7065 host_impl_->CreatePendingTree();
7063 host_impl_->ActivateSyncTree(); 7066 host_impl_->ActivateSyncTree();
7064 host_impl_->CreatePendingTree(); 7067 host_impl_->CreatePendingTree();
7065 7068
7066 LayerTreeImpl* active_tree = host_impl_->active_tree(); 7069 LayerTreeImpl* active_tree = host_impl_->active_tree();
7067 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7070 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
7171 // surface. 7174 // surface.
7172 EXPECT_EQ(0, num_lost_surfaces_); 7175 EXPECT_EQ(0, num_lost_surfaces_);
7173 host_impl_->DidLoseOutputSurface(); 7176 host_impl_->DidLoseOutputSurface();
7174 EXPECT_EQ(1, num_lost_surfaces_); 7177 EXPECT_EQ(1, num_lost_surfaces_);
7175 host_impl_->DidLoseOutputSurface(); 7178 host_impl_->DidLoseOutputSurface();
7176 EXPECT_LE(1, num_lost_surfaces_); 7179 EXPECT_LE(1, num_lost_surfaces_);
7177 } 7180 }
7178 7181
7179 } // namespace 7182 } // namespace
7180 } // namespace cc 7183 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698