| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 settings, this, task_runner_provider, &stats_instrumentation_, | 200 settings, this, task_runner_provider, &stats_instrumentation_, |
| 201 &task_graph_runner_, | 201 &task_graph_runner_, |
| 202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 202 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 203 compositor_frame_sink_ = std::move(compositor_frame_sink); | 203 compositor_frame_sink_ = std::move(compositor_frame_sink); |
| 204 host_impl_->SetVisible(true); | 204 host_impl_->SetVisible(true); |
| 205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 205 bool init = host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
| 206 host_impl_->SetViewportSize(gfx::Size(10, 10)); | 206 host_impl_->SetViewportSize(gfx::Size(10, 10)); |
| 207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 207 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 208 // Set the BeginFrameArgs so that methods which use it are able to. | 208 // Set the BeginFrameArgs so that methods which use it are able to. |
| 209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( | 209 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting( |
| 210 BEGINFRAME_FROM_HERE, | 210 BEGINFRAME_FROM_HERE, 0, 1, |
| 211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); | 211 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1))); |
| 212 host_impl_->DidFinishImplFrame(); | 212 host_impl_->DidFinishImplFrame(); |
| 213 | 213 |
| 214 timeline_ = | 214 timeline_ = |
| 215 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 215 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
| 216 GetImplAnimationHost()->AddAnimationTimeline(timeline_); | 216 GetImplAnimationHost()->AddAnimationTimeline(timeline_); |
| 217 | 217 |
| 218 return init; | 218 return init; |
| 219 } | 219 } |
| 220 | 220 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 layer_tree_impl->BuildPropertyTreesForTesting(); | 355 layer_tree_impl->BuildPropertyTreesForTesting(); |
| 356 layer_tree_impl->SetViewportLayersFromIds( | 356 layer_tree_impl->SetViewportLayersFromIds( |
| 357 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, | 357 Layer::INVALID_ID, kPageScaleLayerId, kInnerViewportScrollLayerId, |
| 358 kOuterViewportScrollLayerId); | 358 kOuterViewportScrollLayerId); |
| 359 | 359 |
| 360 layer_tree_impl->DidBecomeActive(); | 360 layer_tree_impl->DidBecomeActive(); |
| 361 return layer_tree_impl->InnerViewportScrollLayer(); | 361 return layer_tree_impl->InnerViewportScrollLayer(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { | 364 LayerImpl* SetupScrollAndContentsLayers(const gfx::Size& content_size) { |
| 365 LayerImpl* scroll_layer = CreateScrollAndContentsLayers( | 365 LayerImpl* scroll_layer = |
| 366 host_impl_->active_tree(), content_size); | 366 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
| 367 host_impl_->active_tree()->DidBecomeActive(); | 367 host_impl_->active_tree()->DidBecomeActive(); |
| 368 return scroll_layer; | 368 return scroll_layer; |
| 369 } | 369 } |
| 370 | 370 |
| 371 // Sets up a typical virtual viewport setup with one child content layer. | 371 // Sets up a typical virtual viewport setup with one child content layer. |
| 372 // Returns a pointer to the content layer. | 372 // Returns a pointer to the content layer. |
| 373 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, | 373 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, |
| 374 const gfx::Size& content_size) { | 374 const gfx::Size& content_size) { |
| 375 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and | 375 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and |
| 376 // the inner a different size from the outer. We'll reuse its layer | 376 // the inner a different size from the outer. We'll reuse its layer |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 741 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 742 status.main_thread_scrolling_reasons); | 742 status.main_thread_scrolling_reasons); |
| 743 } | 743 } |
| 744 | 744 |
| 745 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 745 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
| 746 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 746 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 747 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 747 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 748 DrawFrame(); | 748 DrawFrame(); |
| 749 | 749 |
| 750 // We should not crash if the tree is replaced while we are scrolling. | 750 // We should not crash if the tree is replaced while we are scrolling. |
| 751 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 751 EXPECT_EQ( |
| 752 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 752 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 753 InputHandler::WHEEL) | 753 host_impl_ |
| 754 .thread); | 754 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 755 .thread); |
| 755 host_impl_->active_tree()->DetachLayers(); | 756 host_impl_->active_tree()->DetachLayers(); |
| 756 | 757 |
| 757 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 758 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 758 | 759 |
| 759 // We should still be scrolling, because the scrolled layer also exists in the | 760 // We should still be scrolling, because the scrolled layer also exists in the |
| 760 // new tree. | 761 // new tree. |
| 761 gfx::Vector2d scroll_delta(0, 10); | 762 gfx::Vector2d scroll_delta(0, 10); |
| 762 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 763 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 763 host_impl_->ScrollEnd(EndState().get()); | 764 host_impl_->ScrollEnd(EndState().get()); |
| 764 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 765 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 765 host_impl_->ProcessScrollDeltas(); | 766 host_impl_->ProcessScrollDeltas(); |
| 766 EXPECT_TRUE( | 767 EXPECT_TRUE( |
| 767 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); | 768 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); |
| 768 } | 769 } |
| 769 | 770 |
| 770 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 771 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
| 771 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 772 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 772 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 773 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 773 DrawFrame(); | 774 DrawFrame(); |
| 774 | 775 |
| 775 // Wheel handlers determine whether mouse events block scroll. | 776 // Wheel handlers determine whether mouse events block scroll. |
| 776 host_impl_->active_tree()->set_event_listener_properties( | 777 host_impl_->active_tree()->set_event_listener_properties( |
| 777 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); | 778 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); |
| 778 EXPECT_EQ( | 779 EXPECT_EQ( |
| 779 EventListenerProperties::kBlocking, | 780 EventListenerProperties::kBlocking, |
| 780 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel)); | 781 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel)); |
| 781 | 782 |
| 782 // But they don't influence the actual handling of the scroll gestures. | 783 // But they don't influence the actual handling of the scroll gestures. |
| 783 InputHandler::ScrollStatus status = | 784 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 784 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 785 BeginState(gfx::Point()).get(), InputHandler::WHEEL); |
| 785 InputHandler::WHEEL); | |
| 786 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 786 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 787 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 787 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 788 status.main_thread_scrolling_reasons); | 788 status.main_thread_scrolling_reasons); |
| 789 host_impl_->ScrollEnd(EndState().get()); | 789 host_impl_->ScrollEnd(EndState().get()); |
| 790 } | 790 } |
| 791 | 791 |
| 792 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 792 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
| 793 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 793 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 794 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 794 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 795 DrawFrame(); | 795 DrawFrame(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 DrawFrame(); | 1123 DrawFrame(); |
| 1124 | 1124 |
| 1125 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( | 1125 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( |
| 1126 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); | 1126 BeginState(gfx::Point()).get(), InputHandler::TOUCHSCREEN); |
| 1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 1128 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 1128 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 1129 status.main_thread_scrolling_reasons); | 1129 status.main_thread_scrolling_reasons); |
| 1130 | 1130 |
| 1131 // Trying to scroll to the left/top will not succeed. | 1131 // Trying to scroll to the left/top will not succeed. |
| 1132 EXPECT_FALSE( | 1132 EXPECT_FALSE( |
| 1133 host_impl_->ScrollBy( | 1133 host_impl_ |
| 1134 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1134 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
| 1135 .did_scroll); | 1135 .did_scroll); |
| 1136 EXPECT_FALSE( | 1136 EXPECT_FALSE( |
| 1137 host_impl_->ScrollBy( | 1137 host_impl_ |
| 1138 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) | 1138 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) |
| 1139 .did_scroll); | 1139 .did_scroll); |
| 1140 EXPECT_FALSE( | 1140 EXPECT_FALSE( |
| 1141 host_impl_->ScrollBy( | 1141 host_impl_ |
| 1142 UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) | 1142 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) |
| 1143 .did_scroll); | 1143 .did_scroll); |
| 1144 | 1144 |
| 1145 // Scrolling to the right/bottom will succeed. | 1145 // Scrolling to the right/bottom will succeed. |
| 1146 EXPECT_TRUE( | 1146 EXPECT_TRUE( |
| 1147 host_impl_->ScrollBy( | 1147 host_impl_ |
| 1148 UpdateState(gfx::Point(), gfx::Vector2d(10, 0)).get()) | 1148 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, 0)).get()) |
| 1149 .did_scroll); | 1149 .did_scroll); |
| 1150 EXPECT_TRUE( | 1150 EXPECT_TRUE( |
| 1151 host_impl_->ScrollBy( | 1151 host_impl_ |
| 1152 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 1152 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
| 1153 .did_scroll); | 1153 .did_scroll); |
| 1154 EXPECT_TRUE( | 1154 EXPECT_TRUE( |
| 1155 host_impl_->ScrollBy( | 1155 host_impl_ |
| 1156 UpdateState(gfx::Point(), gfx::Vector2d(10, 10)).get()) | 1156 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, 10)).get()) |
| 1157 .did_scroll); | 1157 .did_scroll); |
| 1158 | 1158 |
| 1159 // Scrolling to left/top will now succeed. | 1159 // Scrolling to left/top will now succeed. |
| 1160 EXPECT_TRUE( | 1160 EXPECT_TRUE( |
| 1161 host_impl_->ScrollBy( | 1161 host_impl_ |
| 1162 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1162 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
| 1163 .did_scroll); | 1163 .did_scroll); |
| 1164 EXPECT_TRUE( | 1164 EXPECT_TRUE( |
| 1165 host_impl_->ScrollBy( | 1165 host_impl_ |
| 1166 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) | 1166 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) |
| 1167 .did_scroll); | 1167 .did_scroll); |
| 1168 EXPECT_TRUE( | 1168 EXPECT_TRUE( |
| 1169 host_impl_->ScrollBy( | 1169 host_impl_ |
| 1170 UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) | 1170 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, -10)).get()) |
| 1171 .did_scroll); | 1171 .did_scroll); |
| 1172 | 1172 |
| 1173 // Scrolling diagonally against an edge will succeed. | 1173 // Scrolling diagonally against an edge will succeed. |
| 1174 EXPECT_TRUE( | 1174 EXPECT_TRUE( |
| 1175 host_impl_->ScrollBy( | 1175 host_impl_ |
| 1176 UpdateState(gfx::Point(), gfx::Vector2d(10, -10)).get()) | 1176 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(10, -10)).get()) |
| 1177 .did_scroll); | 1177 .did_scroll); |
| 1178 EXPECT_TRUE( | 1178 EXPECT_TRUE( |
| 1179 host_impl_->ScrollBy( | 1179 host_impl_ |
| 1180 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) | 1180 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) |
| 1181 .did_scroll); | 1181 .did_scroll); |
| 1182 EXPECT_TRUE( | 1182 EXPECT_TRUE( |
| 1183 host_impl_->ScrollBy( | 1183 host_impl_ |
| 1184 UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) | 1184 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(-10, 10)).get()) |
| 1185 .did_scroll); | 1185 .did_scroll); |
| 1186 | 1186 |
| 1187 // Trying to scroll more than the available space will also succeed. | 1187 // Trying to scroll more than the available space will also succeed. |
| 1188 EXPECT_TRUE( | 1188 EXPECT_TRUE( |
| 1189 host_impl_->ScrollBy( | 1189 host_impl_ |
| 1190 UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) | 1190 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(5000, 5000)).get()) |
| 1191 .did_scroll); | 1191 .did_scroll); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1194 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 1195 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1195 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1196 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1196 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1197 | 1197 |
| 1198 gfx::Size overflow_size(400, 400); | 1198 gfx::Size overflow_size(400, 400); |
| 1199 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1199 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
| 1200 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1200 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
| 1201 overflow->SetBounds(overflow_size); | 1201 overflow->SetBounds(overflow_size); |
| 1202 overflow->SetScrollClipLayer( | 1202 overflow->SetScrollClipLayer( |
| 1203 scroll_layer->test_properties()->parent->test_properties()->parent->id()); | 1203 scroll_layer->test_properties()->parent->test_properties()->parent->id()); |
| 1204 overflow->layer_tree_impl() | 1204 overflow->layer_tree_impl() |
| 1205 ->property_trees() | 1205 ->property_trees() |
| 1206 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), | 1206 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), |
| 1207 gfx::ScrollOffset()); | 1207 gfx::ScrollOffset()); |
| 1208 overflow->SetPosition(gfx::PointF()); | 1208 overflow->SetPosition(gfx::PointF()); |
| 1209 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1209 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1210 | 1210 |
| 1211 DrawFrame(); | 1211 DrawFrame(); |
| 1212 gfx::Point scroll_position(10, 10); | 1212 gfx::Point scroll_position(10, 10); |
| 1213 | 1213 |
| 1214 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1214 EXPECT_EQ( |
| 1215 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1215 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1216 InputHandler::WHEEL) | 1216 host_impl_ |
| 1217 .thread); | 1217 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1218 .thread); |
| 1218 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1219 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1219 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); | 1220 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
| 1220 | 1221 |
| 1221 gfx::Vector2dF scroll_delta(10, 10); | 1222 gfx::Vector2dF scroll_delta(10, 10); |
| 1222 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1223 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
| 1223 host_impl_->ScrollEnd(EndState().get()); | 1224 host_impl_->ScrollEnd(EndState().get()); |
| 1224 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1225 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1225 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1226 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1226 | 1227 |
| 1227 overflow->set_user_scrollable_horizontal(false); | 1228 overflow->set_user_scrollable_horizontal(false); |
| 1228 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1229 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1229 | 1230 |
| 1230 DrawFrame(); | 1231 DrawFrame(); |
| 1231 | 1232 |
| 1232 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1233 EXPECT_EQ( |
| 1233 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1234 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1234 InputHandler::WHEEL) | 1235 host_impl_ |
| 1235 .thread); | 1236 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1237 .thread); |
| 1236 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1238 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1237 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1239 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1238 | 1240 |
| 1239 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1241 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
| 1240 host_impl_->ScrollEnd(EndState().get()); | 1242 host_impl_->ScrollEnd(EndState().get()); |
| 1241 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); | 1243 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1242 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1244 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1243 | 1245 |
| 1244 overflow->set_user_scrollable_vertical(false); | 1246 overflow->set_user_scrollable_vertical(false); |
| 1245 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1247 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1246 DrawFrame(); | 1248 DrawFrame(); |
| 1247 | 1249 |
| 1248 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1250 EXPECT_EQ( |
| 1249 host_impl_->ScrollBegin(BeginState(scroll_position).get(), | 1251 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1250 InputHandler::WHEEL) | 1252 host_impl_ |
| 1251 .thread); | 1253 ->ScrollBegin(BeginState(scroll_position).get(), InputHandler::WHEEL) |
| 1254 .thread); |
| 1252 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); | 1255 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), scroll_layer->CurrentScrollOffset()); |
| 1253 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1256 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1254 | 1257 |
| 1255 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); | 1258 host_impl_->ScrollBy(UpdateState(scroll_position, scroll_delta).get()); |
| 1256 host_impl_->ScrollEnd(EndState().get()); | 1259 host_impl_->ScrollEnd(EndState().get()); |
| 1257 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); | 1260 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), scroll_layer->CurrentScrollOffset()); |
| 1258 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1261 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1259 } | 1262 } |
| 1260 | 1263 |
| 1261 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { | 1264 TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 TransformOperations start; | 1341 TransformOperations start; |
| 1339 start.AppendTranslate(6.f, 7.f, 0.f); | 1342 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1340 TransformOperations end; | 1343 TransformOperations end; |
| 1341 end.AppendTranslate(8.f, 9.f, 0.f); | 1344 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1342 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1345 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
| 1343 start, end); | 1346 start, end); |
| 1344 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1347 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1345 | 1348 |
| 1346 base::TimeTicks now = base::TimeTicks::Now(); | 1349 base::TimeTicks now = base::TimeTicks::Now(); |
| 1347 host_impl_->WillBeginImplFrame( | 1350 host_impl_->WillBeginImplFrame( |
| 1348 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1351 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
| 1349 | 1352 |
| 1350 // TODO(crbug.com/551134): We always request a new frame and a draw for | 1353 // TODO(crbug.com/551134): We always request a new frame and a draw for |
| 1351 // animations that are on the pending tree, but we don't need to do that | 1354 // animations that are on the pending tree, but we don't need to do that |
| 1352 // unless they are waiting for some future time to start. | 1355 // unless they are waiting for some future time to start. |
| 1353 EXPECT_TRUE(did_request_next_frame_); | 1356 EXPECT_TRUE(did_request_next_frame_); |
| 1354 EXPECT_TRUE(did_request_redraw_); | 1357 EXPECT_TRUE(did_request_redraw_); |
| 1355 EXPECT_FALSE(did_request_commit_); | 1358 EXPECT_FALSE(did_request_commit_); |
| 1356 did_request_next_frame_ = false; | 1359 did_request_next_frame_ = false; |
| 1357 did_request_redraw_ = false; | 1360 did_request_redraw_ = false; |
| 1358 did_request_commit_ = false; | 1361 did_request_commit_ = false; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 TransformOperations start; | 1453 TransformOperations start; |
| 1451 start.AppendTranslate(6.f, 7.f, 0.f); | 1454 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1452 TransformOperations end; | 1455 TransformOperations end; |
| 1453 end.AppendTranslate(8.f, 9.f, 0.f); | 1456 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1454 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, | 1457 AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0, |
| 1455 start, end); | 1458 start, end); |
| 1456 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1459 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1457 | 1460 |
| 1458 base::TimeTicks now = base::TimeTicks::Now(); | 1461 base::TimeTicks now = base::TimeTicks::Now(); |
| 1459 host_impl_->WillBeginImplFrame( | 1462 host_impl_->WillBeginImplFrame( |
| 1460 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1463 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
| 1461 EXPECT_TRUE(did_request_next_frame_); | 1464 EXPECT_TRUE(did_request_next_frame_); |
| 1462 did_request_next_frame_ = false; | 1465 did_request_next_frame_ = false; |
| 1463 | 1466 |
| 1464 host_impl_->ActivateAnimations(); | 1467 host_impl_->ActivateAnimations(); |
| 1465 // On activating an animation, we should request another frame so that we'll | 1468 // On activating an animation, we should request another frame so that we'll |
| 1466 // continue ticking the animation. | 1469 // continue ticking the animation. |
| 1467 EXPECT_TRUE(did_request_next_frame_); | 1470 EXPECT_TRUE(did_request_next_frame_); |
| 1468 did_request_next_frame_ = false; | 1471 did_request_next_frame_ = false; |
| 1469 | 1472 |
| 1470 // The next frame after activating, we'll tick the animation again. | 1473 // The next frame after activating, we'll tick the animation again. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 TransformOperations start; | 1533 TransformOperations start; |
| 1531 start.AppendTranslate(6.f, 7.f, 0.f); | 1534 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1532 TransformOperations end; | 1535 TransformOperations end; |
| 1533 end.AppendTranslate(8.f, 9.f, 0.f); | 1536 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1534 int animation_id = AddAnimatedTransformToElementWithPlayer( | 1537 int animation_id = AddAnimatedTransformToElementWithPlayer( |
| 1535 child->element_id(), timeline(), 4.0, start, end); | 1538 child->element_id(), timeline(), 4.0, start, end); |
| 1536 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1539 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1537 | 1540 |
| 1538 base::TimeTicks now = base::TimeTicks::Now(); | 1541 base::TimeTicks now = base::TimeTicks::Now(); |
| 1539 host_impl_->WillBeginImplFrame( | 1542 host_impl_->WillBeginImplFrame( |
| 1540 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now)); | 1543 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, now)); |
| 1541 | 1544 |
| 1542 host_impl_->ActivateAnimations(); | 1545 host_impl_->ActivateAnimations(); |
| 1543 host_impl_->Animate(); | 1546 host_impl_->Animate(); |
| 1544 | 1547 |
| 1545 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); | 1548 EXPECT_FALSE(child->was_ever_ready_since_last_transform_animation()); |
| 1546 | 1549 |
| 1547 host_impl_->ResetRequiresHighResToDraw(); | 1550 host_impl_->ResetRequiresHighResToDraw(); |
| 1548 | 1551 |
| 1549 // Child layer has an animating transform but missing tiles. | 1552 // Child layer has an animating transform but missing tiles. |
| 1550 FakeLayerTreeHostImpl::FrameData frame; | 1553 FakeLayerTreeHostImpl::FrameData frame; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 float page_scale_delta = 2.f; | 1647 float page_scale_delta = 2.f; |
| 1645 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 1648 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 1646 InputHandler::TOUCHSCREEN); | 1649 InputHandler::TOUCHSCREEN); |
| 1647 host_impl_->PinchGestureBegin(); | 1650 host_impl_->PinchGestureBegin(); |
| 1648 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1651 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 1649 host_impl_->PinchGestureEnd(); | 1652 host_impl_->PinchGestureEnd(); |
| 1650 host_impl_->ScrollEnd(EndState().get()); | 1653 host_impl_->ScrollEnd(EndState().get()); |
| 1651 | 1654 |
| 1652 gfx::Vector2d scroll_delta(0, 10); | 1655 gfx::Vector2d scroll_delta(0, 10); |
| 1653 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 1656 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 1654 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 1657 host_impl_ |
| 1655 InputHandler::WHEEL) | 1658 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 1659 InputHandler::WHEEL) |
| 1656 .thread); | 1660 .thread); |
| 1657 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 1661 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 1658 host_impl_->ScrollEnd(EndState().get()); | 1662 host_impl_->ScrollEnd(EndState().get()); |
| 1659 | 1663 |
| 1660 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 1664 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 1661 host_impl_->ProcessScrollDeltas(); | 1665 host_impl_->ProcessScrollDeltas(); |
| 1662 EXPECT_TRUE(ScrollInfoContains( | 1666 EXPECT_TRUE(ScrollInfoContains( |
| 1663 *scroll_info.get(), scroll_layer->id(), | 1667 *scroll_info.get(), scroll_layer->id(), |
| 1664 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); | 1668 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta))); |
| 1665 } | 1669 } |
| 1666 } | 1670 } |
| 1667 | 1671 |
| 1668 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { | 1672 TEST_F(LayerTreeHostImplTest, ViewportScrollOrder) { |
| 1669 LayerTreeSettings settings = DefaultSettings(); | 1673 LayerTreeSettings settings = DefaultSettings(); |
| 1670 CreateHostImpl(settings, CreateCompositorFrameSink()); | 1674 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1671 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); | 1675 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.25f, 4.f); |
| 1672 | 1676 |
| 1673 const gfx::Size content_size(1000, 1000); | 1677 const gfx::Size content_size(1000, 1000); |
| 1674 const gfx::Size viewport_size(500, 500); | 1678 const gfx::Size viewport_size(500, 500); |
| 1675 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1679 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1676 | 1680 |
| 1677 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1681 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1678 outer_scroll_layer->SetDrawsContent(true); | 1682 outer_scroll_layer->SetDrawsContent(true); |
| 1679 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1683 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1680 inner_scroll_layer->SetDrawsContent(true); | 1684 inner_scroll_layer->SetDrawsContent(true); |
| 1681 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1685 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1682 | 1686 |
| 1683 EXPECT_VECTOR_EQ( | 1687 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500), |
| 1684 gfx::Vector2dF(500, 500), | 1688 outer_scroll_layer->MaxScrollOffset()); |
| 1685 outer_scroll_layer->MaxScrollOffset()); | |
| 1686 | 1689 |
| 1687 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1690 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1688 InputHandler::TOUCHSCREEN); | 1691 InputHandler::TOUCHSCREEN); |
| 1689 host_impl_->PinchGestureBegin(); | 1692 host_impl_->PinchGestureBegin(); |
| 1690 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1693 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
| 1691 host_impl_->PinchGestureEnd(); | 1694 host_impl_->PinchGestureEnd(); |
| 1692 host_impl_->ScrollEnd(EndState().get()); | 1695 host_impl_->ScrollEnd(EndState().get()); |
| 1693 | 1696 |
| 1694 // Sanity check - we're zoomed in, starting from the origin. | 1697 // Sanity check - we're zoomed in, starting from the origin. |
| 1695 EXPECT_VECTOR_EQ( | 1698 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 1696 gfx::Vector2dF(0, 0), | 1699 outer_scroll_layer->CurrentScrollOffset()); |
| 1697 outer_scroll_layer->CurrentScrollOffset()); | 1700 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 1698 EXPECT_VECTOR_EQ( | 1701 inner_scroll_layer->CurrentScrollOffset()); |
| 1699 gfx::Vector2dF(0, 0), | |
| 1700 inner_scroll_layer->CurrentScrollOffset()); | |
| 1701 | 1702 |
| 1702 // Scroll down - only the inner viewport should scroll. | 1703 // Scroll down - only the inner viewport should scroll. |
| 1703 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1704 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1704 InputHandler::TOUCHSCREEN); | 1705 InputHandler::TOUCHSCREEN); |
| 1705 host_impl_->ScrollBy( | 1706 host_impl_->ScrollBy( |
| 1706 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); | 1707 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); |
| 1707 host_impl_->ScrollEnd(EndState().get()); | 1708 host_impl_->ScrollEnd(EndState().get()); |
| 1708 | 1709 |
| 1709 EXPECT_VECTOR_EQ( | 1710 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 1710 gfx::Vector2dF(50, 50), | 1711 inner_scroll_layer->CurrentScrollOffset()); |
| 1711 inner_scroll_layer->CurrentScrollOffset()); | 1712 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 1712 EXPECT_VECTOR_EQ( | 1713 outer_scroll_layer->CurrentScrollOffset()); |
| 1713 gfx::Vector2dF(0, 0), | |
| 1714 outer_scroll_layer->CurrentScrollOffset()); | |
| 1715 | 1714 |
| 1716 // Scroll down - outer viewport should start scrolling after the inner is at | 1715 // Scroll down - outer viewport should start scrolling after the inner is at |
| 1717 // its maximum. | 1716 // its maximum. |
| 1718 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1717 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1719 InputHandler::TOUCHSCREEN); | 1718 InputHandler::TOUCHSCREEN); |
| 1720 host_impl_->ScrollBy( | 1719 host_impl_->ScrollBy( |
| 1721 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); | 1720 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(1000.f, 1000.f)).get()); |
| 1722 host_impl_->ScrollEnd(EndState().get()); | 1721 host_impl_->ScrollEnd(EndState().get()); |
| 1723 | 1722 |
| 1724 EXPECT_VECTOR_EQ( | 1723 EXPECT_VECTOR_EQ(gfx::Vector2dF(250, 250), |
| 1725 gfx::Vector2dF(250, 250), | 1724 inner_scroll_layer->CurrentScrollOffset()); |
| 1726 inner_scroll_layer->CurrentScrollOffset()); | 1725 EXPECT_VECTOR_EQ(gfx::Vector2dF(300, 300), |
| 1727 EXPECT_VECTOR_EQ( | 1726 outer_scroll_layer->CurrentScrollOffset()); |
| 1728 gfx::Vector2dF(300, 300), | |
| 1729 outer_scroll_layer->CurrentScrollOffset()); | |
| 1730 } | 1727 } |
| 1731 | 1728 |
| 1732 // Make sure scrolls smaller than a unit applied to the viewport don't get | 1729 // Make sure scrolls smaller than a unit applied to the viewport don't get |
| 1733 // dropped. crbug.com/539334. | 1730 // dropped. crbug.com/539334. |
| 1734 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { | 1731 TEST_F(LayerTreeHostImplTest, ScrollViewportWithFractionalAmounts) { |
| 1735 LayerTreeSettings settings = DefaultSettings(); | 1732 LayerTreeSettings settings = DefaultSettings(); |
| 1736 CreateHostImpl(settings, CreateCompositorFrameSink()); | 1733 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1737 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1734 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1738 | 1735 |
| 1739 const gfx::Size content_size(1000, 1000); | 1736 const gfx::Size content_size(1000, 1000); |
| 1740 const gfx::Size viewport_size(500, 500); | 1737 const gfx::Size viewport_size(500, 500); |
| 1741 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1738 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1742 | 1739 |
| 1743 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1740 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1744 outer_scroll_layer->SetDrawsContent(true); | 1741 outer_scroll_layer->SetDrawsContent(true); |
| 1745 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1742 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1746 inner_scroll_layer->SetDrawsContent(true); | 1743 inner_scroll_layer->SetDrawsContent(true); |
| 1747 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1744 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1748 | 1745 |
| 1749 // Sanity checks. | 1746 // Sanity checks. |
| 1750 EXPECT_VECTOR_EQ( | 1747 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500), |
| 1751 gfx::Vector2dF(500, 500), | 1748 outer_scroll_layer->MaxScrollOffset()); |
| 1752 outer_scroll_layer->MaxScrollOffset()); | |
| 1753 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 1749 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 1754 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); | 1750 EXPECT_VECTOR_EQ(gfx::Vector2dF(), inner_scroll_layer->CurrentScrollOffset()); |
| 1755 | 1751 |
| 1756 // Scroll only the layout viewport. | 1752 // Scroll only the layout viewport. |
| 1757 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1753 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1758 InputHandler::TOUCHSCREEN); | 1754 InputHandler::TOUCHSCREEN); |
| 1759 host_impl_->ScrollBy( | 1755 host_impl_->ScrollBy( |
| 1760 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); | 1756 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.125f, 0.125f)).get()); |
| 1761 EXPECT_VECTOR2DF_EQ( | 1757 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.125f, 0.125f), |
| 1762 gfx::Vector2dF(0.125f, 0.125f), | 1758 outer_scroll_layer->CurrentScrollOffset()); |
| 1763 outer_scroll_layer->CurrentScrollOffset()); | 1759 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0, 0), |
| 1764 EXPECT_VECTOR2DF_EQ( | 1760 inner_scroll_layer->CurrentScrollOffset()); |
| 1765 gfx::Vector2dF(0, 0), | |
| 1766 inner_scroll_layer->CurrentScrollOffset()); | |
| 1767 host_impl_->ScrollEnd(EndState().get()); | 1761 host_impl_->ScrollEnd(EndState().get()); |
| 1768 | 1762 |
| 1769 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 1763 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 1770 | 1764 |
| 1771 // Now that we zoomed in, the scroll should be applied to the inner viewport. | 1765 // Now that we zoomed in, the scroll should be applied to the inner viewport. |
| 1772 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1766 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1773 InputHandler::TOUCHSCREEN); | 1767 InputHandler::TOUCHSCREEN); |
| 1774 host_impl_->ScrollBy( | 1768 host_impl_->ScrollBy( |
| 1775 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); | 1769 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(0.5f, 0.5f)).get()); |
| 1776 EXPECT_VECTOR2DF_EQ( | 1770 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.125f, 0.125f), |
| 1777 gfx::Vector2dF(0.125f, 0.125f), | 1771 outer_scroll_layer->CurrentScrollOffset()); |
| 1778 outer_scroll_layer->CurrentScrollOffset()); | 1772 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.25f, 0.25f), |
| 1779 EXPECT_VECTOR2DF_EQ( | 1773 inner_scroll_layer->CurrentScrollOffset()); |
| 1780 gfx::Vector2dF(0.25f, 0.25f), | |
| 1781 inner_scroll_layer->CurrentScrollOffset()); | |
| 1782 host_impl_->ScrollEnd(EndState().get()); | 1774 host_impl_->ScrollEnd(EndState().get()); |
| 1783 } | 1775 } |
| 1784 | 1776 |
| 1785 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work | 1777 // Tests that scrolls during a pinch gesture (i.e. "two-finger" scrolls) work |
| 1786 // as expected. That is, scrolling during a pinch should bubble from the inner | 1778 // as expected. That is, scrolling during a pinch should bubble from the inner |
| 1787 // to the outer viewport. | 1779 // to the outer viewport. |
| 1788 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { | 1780 TEST_F(LayerTreeHostImplTest, ScrollDuringPinchGesture) { |
| 1789 LayerTreeSettings settings = DefaultSettings(); | 1781 LayerTreeSettings settings = DefaultSettings(); |
| 1790 CreateHostImpl(settings, CreateCompositorFrameSink()); | 1782 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 1791 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 1783 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 1792 | 1784 |
| 1793 const gfx::Size content_size(1000, 1000); | 1785 const gfx::Size content_size(1000, 1000); |
| 1794 const gfx::Size viewport_size(500, 500); | 1786 const gfx::Size viewport_size(500, 500); |
| 1795 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 1787 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 1796 | 1788 |
| 1797 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 1789 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 1798 outer_scroll_layer->SetDrawsContent(true); | 1790 outer_scroll_layer->SetDrawsContent(true); |
| 1799 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1791 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1800 inner_scroll_layer->SetDrawsContent(true); | 1792 inner_scroll_layer->SetDrawsContent(true); |
| 1801 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 1793 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 1802 | 1794 |
| 1803 EXPECT_VECTOR_EQ( | 1795 EXPECT_VECTOR_EQ(gfx::Vector2dF(500, 500), |
| 1804 gfx::Vector2dF(500, 500), | 1796 outer_scroll_layer->MaxScrollOffset()); |
| 1805 outer_scroll_layer->MaxScrollOffset()); | |
| 1806 | 1797 |
| 1807 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), | 1798 host_impl_->ScrollBegin(BeginState(gfx::Point(250, 250)).get(), |
| 1808 InputHandler::TOUCHSCREEN); | 1799 InputHandler::TOUCHSCREEN); |
| 1809 host_impl_->PinchGestureBegin(); | 1800 host_impl_->PinchGestureBegin(); |
| 1810 | 1801 |
| 1811 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); | 1802 host_impl_->PinchGestureUpdate(2, gfx::Point(250, 250)); |
| 1812 EXPECT_VECTOR_EQ( | 1803 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 1813 gfx::Vector2dF(0, 0), | 1804 outer_scroll_layer->CurrentScrollOffset()); |
| 1814 outer_scroll_layer->CurrentScrollOffset()); | 1805 EXPECT_VECTOR_EQ(gfx::Vector2dF(125, 125), |
| 1815 EXPECT_VECTOR_EQ( | 1806 inner_scroll_layer->CurrentScrollOffset()); |
| 1816 gfx::Vector2dF(125, 125), | |
| 1817 inner_scroll_layer->CurrentScrollOffset()); | |
| 1818 | 1807 |
| 1819 // Needed so that the pinch is accounted for in draw properties. | 1808 // Needed so that the pinch is accounted for in draw properties. |
| 1820 DrawFrame(); | 1809 DrawFrame(); |
| 1821 | 1810 |
| 1822 host_impl_->ScrollBy( | 1811 host_impl_->ScrollBy( |
| 1823 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)).get()); | 1812 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(10.f, 10.f)).get()); |
| 1824 EXPECT_VECTOR_EQ( | 1813 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 1825 gfx::Vector2dF(0, 0), | 1814 outer_scroll_layer->CurrentScrollOffset()); |
| 1826 outer_scroll_layer->CurrentScrollOffset()); | 1815 EXPECT_VECTOR_EQ(gfx::Vector2dF(130, 130), |
| 1827 EXPECT_VECTOR_EQ( | 1816 inner_scroll_layer->CurrentScrollOffset()); |
| 1828 gfx::Vector2dF(130, 130), | |
| 1829 inner_scroll_layer->CurrentScrollOffset()); | |
| 1830 | 1817 |
| 1831 DrawFrame(); | 1818 DrawFrame(); |
| 1832 | 1819 |
| 1833 host_impl_->ScrollBy( | 1820 host_impl_->ScrollBy( |
| 1834 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)).get()); | 1821 UpdateState(gfx::Point(250, 250), gfx::Vector2dF(400.f, 400.f)).get()); |
| 1835 EXPECT_VECTOR_EQ( | 1822 EXPECT_VECTOR_EQ(gfx::Vector2dF(80, 80), |
| 1836 gfx::Vector2dF(80, 80), | 1823 outer_scroll_layer->CurrentScrollOffset()); |
| 1837 outer_scroll_layer->CurrentScrollOffset()); | 1824 EXPECT_VECTOR_EQ(gfx::Vector2dF(250, 250), |
| 1838 EXPECT_VECTOR_EQ( | 1825 inner_scroll_layer->CurrentScrollOffset()); |
| 1839 gfx::Vector2dF(250, 250), | |
| 1840 inner_scroll_layer->CurrentScrollOffset()); | |
| 1841 | 1826 |
| 1842 host_impl_->PinchGestureEnd(); | 1827 host_impl_->PinchGestureEnd(); |
| 1843 host_impl_->ScrollEnd(EndState().get()); | 1828 host_impl_->ScrollEnd(EndState().get()); |
| 1844 } | 1829 } |
| 1845 | 1830 |
| 1846 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when | 1831 // Tests the "snapping" of pinch-zoom gestures to the screen edge. That is, when |
| 1847 // a pinch zoom is anchored within a certain margin of the screen edge, we | 1832 // a pinch zoom is anchored within a certain margin of the screen edge, we |
| 1848 // should assume the user means to scroll into the edge of the screen. | 1833 // should assume the user means to scroll into the edge of the screen. |
| 1849 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { | 1834 TEST_F(LayerTreeHostImplTest, PinchZoomSnapsToScreenEdge) { |
| 1850 LayerTreeSettings settings = DefaultSettings(); | 1835 LayerTreeSettings settings = DefaultSettings(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1943 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 1928 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 1944 | 1929 |
| 1945 // Scroll by a small amount, there should be no bubbling to the outer | 1930 // Scroll by a small amount, there should be no bubbling to the outer |
| 1946 // viewport. | 1931 // viewport. |
| 1947 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1932 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1948 InputHandler::WHEEL); | 1933 InputHandler::WHEEL); |
| 1949 host_impl_->ScrollBy( | 1934 host_impl_->ScrollBy( |
| 1950 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); | 1935 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(10.f, 20.f)).get()); |
| 1951 host_impl_->ScrollEnd(EndState().get()); | 1936 host_impl_->ScrollEnd(EndState().get()); |
| 1952 | 1937 |
| 1953 EXPECT_VECTOR_EQ( | 1938 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
| 1954 gfx::Vector2dF(5, 10), | 1939 inner_scroll_layer->CurrentScrollOffset()); |
| 1955 inner_scroll_layer->CurrentScrollOffset()); | 1940 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 1956 EXPECT_VECTOR_EQ( | |
| 1957 gfx::Vector2dF(), | |
| 1958 outer_scroll_layer->CurrentScrollOffset()); | |
| 1959 | 1941 |
| 1960 // Scroll by the inner viewport's max scroll extent, the remainder | 1942 // Scroll by the inner viewport's max scroll extent, the remainder |
| 1961 // should bubble up to the outer viewport. | 1943 // should bubble up to the outer viewport. |
| 1962 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1944 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1963 InputHandler::WHEEL); | 1945 InputHandler::WHEEL); |
| 1964 host_impl_->ScrollBy( | 1946 host_impl_->ScrollBy( |
| 1965 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); | 1947 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(100.f, 100.f)).get()); |
| 1966 host_impl_->ScrollEnd(EndState().get()); | 1948 host_impl_->ScrollEnd(EndState().get()); |
| 1967 | 1949 |
| 1968 EXPECT_VECTOR_EQ( | 1950 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 1969 gfx::Vector2dF(50, 50), | 1951 inner_scroll_layer->CurrentScrollOffset()); |
| 1970 inner_scroll_layer->CurrentScrollOffset()); | 1952 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
| 1971 EXPECT_VECTOR_EQ( | 1953 outer_scroll_layer->CurrentScrollOffset()); |
| 1972 gfx::Vector2dF(5, 10), | |
| 1973 outer_scroll_layer->CurrentScrollOffset()); | |
| 1974 | 1954 |
| 1975 // Scroll by the outer viewport's max scroll extent, it should all go to the | 1955 // Scroll by the outer viewport's max scroll extent, it should all go to the |
| 1976 // outer viewport. | 1956 // outer viewport. |
| 1977 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 1957 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 1978 InputHandler::WHEEL); | 1958 InputHandler::WHEEL); |
| 1979 host_impl_->ScrollBy( | 1959 host_impl_->ScrollBy( |
| 1980 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(190.f, 180.f)).get()); | 1960 UpdateState(gfx::Point(0, 0), gfx::Vector2dF(190.f, 180.f)).get()); |
| 1981 host_impl_->ScrollEnd(EndState().get()); | 1961 host_impl_->ScrollEnd(EndState().get()); |
| 1982 | 1962 |
| 1983 EXPECT_VECTOR_EQ( | 1963 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100), |
| 1984 gfx::Vector2dF(100, 100), | 1964 outer_scroll_layer->CurrentScrollOffset()); |
| 1985 outer_scroll_layer->CurrentScrollOffset()); | 1965 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 1986 EXPECT_VECTOR_EQ( | 1966 inner_scroll_layer->CurrentScrollOffset()); |
| 1987 gfx::Vector2dF(50, 50), | |
| 1988 inner_scroll_layer->CurrentScrollOffset()); | |
| 1989 } | 1967 } |
| 1990 | 1968 |
| 1991 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1969 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
| 1992 ui::LatencyInfo latency_info; | 1970 ui::LatencyInfo latency_info; |
| 1993 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, | 1971 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
| 1994 1234); | 1972 1234); |
| 1995 std::unique_ptr<SwapPromise> swap_promise( | 1973 std::unique_ptr<SwapPromise> swap_promise( |
| 1996 new LatencyInfoSwapPromise(latency_info)); | 1974 new LatencyInfoSwapPromise(latency_info)); |
| 1997 | 1975 |
| 1998 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1976 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2014 | 1992 |
| 2015 // Test that scrolls targeting a layer with a non-null scroll_parent() don't | 1993 // Test that scrolls targeting a layer with a non-null scroll_parent() don't |
| 2016 // bubble up. | 1994 // bubble up. |
| 2017 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { | 1995 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { |
| 2018 LayerImpl* viewport_scroll = | 1996 LayerImpl* viewport_scroll = |
| 2019 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1997 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2020 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1998 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2021 | 1999 |
| 2022 // Set up two scrolling children of the root, one of which is a scroll parent | 2000 // Set up two scrolling children of the root, one of which is a scroll parent |
| 2023 // to the other. Scrolls shouldn't bubbling from the child. | 2001 // to the other. Scrolls shouldn't bubbling from the child. |
| 2024 LayerImpl *parent; | 2002 LayerImpl* parent; |
| 2025 LayerImpl *child; | 2003 LayerImpl* child; |
| 2026 LayerImpl *child_clip; | 2004 LayerImpl* child_clip; |
| 2027 | 2005 |
| 2028 std::unique_ptr<LayerImpl> scroll_parent_clip = | 2006 std::unique_ptr<LayerImpl> scroll_parent_clip = |
| 2029 LayerImpl::Create(host_impl_->active_tree(), 6); | 2007 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 2030 std::unique_ptr<LayerImpl> scroll_parent = | 2008 std::unique_ptr<LayerImpl> scroll_parent = |
| 2031 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); | 2009 CreateScrollableLayer(7, gfx::Size(10, 10), scroll_parent_clip.get()); |
| 2032 parent = scroll_parent.get(); | 2010 parent = scroll_parent.get(); |
| 2033 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent)); | 2011 scroll_parent_clip->test_properties()->AddChild(std::move(scroll_parent)); |
| 2034 | 2012 |
| 2035 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip)); | 2013 viewport_scroll->test_properties()->AddChild(std::move(scroll_parent_clip)); |
| 2036 | 2014 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 // The viewport shouldn't receive any scroll delta. | 2075 // The viewport shouldn't receive any scroll delta. |
| 2098 EXPECT_VECTOR_EQ( | 2076 EXPECT_VECTOR_EQ( |
| 2099 gfx::Vector2dF(0, 0), | 2077 gfx::Vector2dF(0, 0), |
| 2100 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); | 2078 host_impl_->InnerViewportScrollLayer()->CurrentScrollOffset()); |
| 2101 EXPECT_VECTOR_EQ( | 2079 EXPECT_VECTOR_EQ( |
| 2102 gfx::Vector2dF(0, 0), | 2080 gfx::Vector2dF(0, 0), |
| 2103 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); | 2081 host_impl_->OuterViewportScrollLayer()->CurrentScrollOffset()); |
| 2104 } | 2082 } |
| 2105 } | 2083 } |
| 2106 | 2084 |
| 2107 | |
| 2108 TEST_F(LayerTreeHostImplTest, PinchGesture) { | 2085 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
| 2109 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2086 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2110 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2087 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2111 DrawFrame(); | 2088 DrawFrame(); |
| 2112 | 2089 |
| 2113 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2090 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 2114 DCHECK(scroll_layer); | 2091 DCHECK(scroll_layer); |
| 2115 | 2092 |
| 2116 float min_page_scale = 1.f; | 2093 float min_page_scale = 1.f; |
| 2117 float max_page_scale = 4.f; | 2094 float max_page_scale = 4.f; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2329 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { | 2306 TEST_F(LayerTreeHostImplTest, PageScaleAnimation) { |
| 2330 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2307 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2331 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2308 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2332 DrawFrame(); | 2309 DrawFrame(); |
| 2333 | 2310 |
| 2334 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2311 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 2335 DCHECK(scroll_layer); | 2312 DCHECK(scroll_layer); |
| 2336 | 2313 |
| 2337 float min_page_scale = 0.5f; | 2314 float min_page_scale = 0.5f; |
| 2338 float max_page_scale = 4.f; | 2315 float max_page_scale = 4.f; |
| 2339 base::TimeTicks start_time = base::TimeTicks() + | 2316 base::TimeTicks start_time = |
| 2340 base::TimeDelta::FromSeconds(1); | 2317 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
| 2341 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2318 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 2342 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2319 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 2343 base::TimeTicks end_time = start_time + duration; | 2320 base::TimeTicks end_time = start_time + duration; |
| 2344 | 2321 |
| 2345 BeginFrameArgs begin_frame_args = | 2322 BeginFrameArgs begin_frame_args = |
| 2346 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2323 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 2347 | 2324 |
| 2348 // Non-anchor zoom-in | 2325 // Non-anchor zoom-in |
| 2349 { | 2326 { |
| 2350 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2327 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2351 max_page_scale); | 2328 max_page_scale); |
| 2352 scroll_layer->layer_tree_impl() | 2329 scroll_layer->layer_tree_impl() |
| 2353 ->property_trees() | 2330 ->property_trees() |
| 2354 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2331 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 2355 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2332 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
| 2356 | 2333 |
| 2357 did_request_redraw_ = false; | 2334 did_request_redraw_ = false; |
| 2358 did_request_next_frame_ = false; | 2335 did_request_next_frame_ = false; |
| 2359 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2336 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 2360 std::unique_ptr<PendingPageScaleAnimation>( | 2337 std::unique_ptr<PendingPageScaleAnimation>( |
| 2361 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, | 2338 new PendingPageScaleAnimation(gfx::Vector2d(), false, 2.f, |
| 2362 duration))); | 2339 duration))); |
| 2363 host_impl_->ActivateSyncTree(); | 2340 host_impl_->ActivateSyncTree(); |
| 2364 EXPECT_FALSE(did_request_redraw_); | 2341 EXPECT_FALSE(did_request_redraw_); |
| 2365 EXPECT_TRUE(did_request_next_frame_); | 2342 EXPECT_TRUE(did_request_next_frame_); |
| 2366 | 2343 |
| 2367 did_request_redraw_ = false; | 2344 did_request_redraw_ = false; |
| 2368 did_request_next_frame_ = false; | 2345 did_request_next_frame_ = false; |
| 2369 begin_frame_args.frame_time = start_time; | 2346 begin_frame_args.frame_time = start_time; |
| 2347 begin_frame_args.sequence_number++; |
| 2370 host_impl_->WillBeginImplFrame(begin_frame_args); | 2348 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2371 host_impl_->Animate(); | 2349 host_impl_->Animate(); |
| 2372 EXPECT_TRUE(did_request_redraw_); | 2350 EXPECT_TRUE(did_request_redraw_); |
| 2373 EXPECT_TRUE(did_request_next_frame_); | 2351 EXPECT_TRUE(did_request_next_frame_); |
| 2374 host_impl_->DidFinishImplFrame(); | 2352 host_impl_->DidFinishImplFrame(); |
| 2375 | 2353 |
| 2376 did_request_redraw_ = false; | 2354 did_request_redraw_ = false; |
| 2377 did_request_next_frame_ = false; | 2355 did_request_next_frame_ = false; |
| 2378 begin_frame_args.frame_time = halfway_through_animation; | 2356 begin_frame_args.frame_time = halfway_through_animation; |
| 2357 begin_frame_args.sequence_number++; |
| 2379 host_impl_->WillBeginImplFrame(begin_frame_args); | 2358 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2380 host_impl_->Animate(); | 2359 host_impl_->Animate(); |
| 2381 EXPECT_TRUE(did_request_redraw_); | 2360 EXPECT_TRUE(did_request_redraw_); |
| 2382 EXPECT_TRUE(did_request_next_frame_); | 2361 EXPECT_TRUE(did_request_next_frame_); |
| 2383 host_impl_->DidFinishImplFrame(); | 2362 host_impl_->DidFinishImplFrame(); |
| 2384 | 2363 |
| 2385 did_request_redraw_ = false; | 2364 did_request_redraw_ = false; |
| 2386 did_request_next_frame_ = false; | 2365 did_request_next_frame_ = false; |
| 2387 did_request_commit_ = false; | 2366 did_request_commit_ = false; |
| 2388 begin_frame_args.frame_time = end_time; | 2367 begin_frame_args.frame_time = end_time; |
| 2368 begin_frame_args.sequence_number++; |
| 2389 host_impl_->WillBeginImplFrame(begin_frame_args); | 2369 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2390 host_impl_->Animate(); | 2370 host_impl_->Animate(); |
| 2391 EXPECT_TRUE(did_request_commit_); | 2371 EXPECT_TRUE(did_request_commit_); |
| 2392 EXPECT_FALSE(did_request_next_frame_); | 2372 EXPECT_FALSE(did_request_next_frame_); |
| 2393 host_impl_->DidFinishImplFrame(); | 2373 host_impl_->DidFinishImplFrame(); |
| 2394 | 2374 |
| 2395 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2375 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 2396 host_impl_->ProcessScrollDeltas(); | 2376 host_impl_->ProcessScrollDeltas(); |
| 2397 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 2377 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
| 2398 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2378 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2418 std::unique_ptr<PendingPageScaleAnimation>( | 2398 std::unique_ptr<PendingPageScaleAnimation>( |
| 2419 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, | 2399 new PendingPageScaleAnimation(gfx::Vector2d(25, 25), true, |
| 2420 min_page_scale, duration))); | 2400 min_page_scale, duration))); |
| 2421 host_impl_->ActivateSyncTree(); | 2401 host_impl_->ActivateSyncTree(); |
| 2422 EXPECT_FALSE(did_request_redraw_); | 2402 EXPECT_FALSE(did_request_redraw_); |
| 2423 EXPECT_TRUE(did_request_next_frame_); | 2403 EXPECT_TRUE(did_request_next_frame_); |
| 2424 | 2404 |
| 2425 did_request_redraw_ = false; | 2405 did_request_redraw_ = false; |
| 2426 did_request_next_frame_ = false; | 2406 did_request_next_frame_ = false; |
| 2427 begin_frame_args.frame_time = start_time; | 2407 begin_frame_args.frame_time = start_time; |
| 2408 begin_frame_args.sequence_number++; |
| 2428 host_impl_->WillBeginImplFrame(begin_frame_args); | 2409 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2429 host_impl_->Animate(); | 2410 host_impl_->Animate(); |
| 2430 EXPECT_TRUE(did_request_redraw_); | 2411 EXPECT_TRUE(did_request_redraw_); |
| 2431 EXPECT_TRUE(did_request_next_frame_); | 2412 EXPECT_TRUE(did_request_next_frame_); |
| 2432 host_impl_->DidFinishImplFrame(); | 2413 host_impl_->DidFinishImplFrame(); |
| 2433 | 2414 |
| 2434 did_request_redraw_ = false; | 2415 did_request_redraw_ = false; |
| 2435 did_request_commit_ = false; | 2416 did_request_commit_ = false; |
| 2436 did_request_next_frame_ = false; | 2417 did_request_next_frame_ = false; |
| 2437 begin_frame_args.frame_time = end_time; | 2418 begin_frame_args.frame_time = end_time; |
| 2419 begin_frame_args.sequence_number++; |
| 2438 host_impl_->WillBeginImplFrame(begin_frame_args); | 2420 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2439 host_impl_->Animate(); | 2421 host_impl_->Animate(); |
| 2440 EXPECT_TRUE(did_request_redraw_); | 2422 EXPECT_TRUE(did_request_redraw_); |
| 2441 EXPECT_FALSE(did_request_next_frame_); | 2423 EXPECT_FALSE(did_request_next_frame_); |
| 2442 EXPECT_TRUE(did_request_commit_); | 2424 EXPECT_TRUE(did_request_commit_); |
| 2443 host_impl_->DidFinishImplFrame(); | 2425 host_impl_->DidFinishImplFrame(); |
| 2444 | 2426 |
| 2445 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2427 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 2446 host_impl_->ProcessScrollDeltas(); | 2428 host_impl_->ProcessScrollDeltas(); |
| 2447 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 2429 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
| 2448 // Pushed to (0,0) via clamping against contents layer size. | 2430 // Pushed to (0,0) via clamping against contents layer size. |
| 2449 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2431 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
| 2450 gfx::Vector2d(-50, -50))); | 2432 gfx::Vector2d(-50, -50))); |
| 2451 } | 2433 } |
| 2452 } | 2434 } |
| 2453 | 2435 |
| 2454 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { | 2436 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { |
| 2455 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2437 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2456 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2438 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2457 DrawFrame(); | 2439 DrawFrame(); |
| 2458 | 2440 |
| 2459 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2441 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 2460 DCHECK(scroll_layer); | 2442 DCHECK(scroll_layer); |
| 2461 | 2443 |
| 2462 float min_page_scale = 0.5f; | 2444 float min_page_scale = 0.5f; |
| 2463 float max_page_scale = 4.f; | 2445 float max_page_scale = 4.f; |
| 2464 base::TimeTicks start_time = base::TimeTicks() + | 2446 base::TimeTicks start_time = |
| 2465 base::TimeDelta::FromSeconds(1); | 2447 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
| 2466 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2448 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 2467 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2449 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 2468 base::TimeTicks end_time = start_time + duration; | 2450 base::TimeTicks end_time = start_time + duration; |
| 2469 | 2451 |
| 2470 BeginFrameArgs begin_frame_args = | 2452 BeginFrameArgs begin_frame_args = |
| 2471 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2453 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 2472 | 2454 |
| 2473 // Anchor zoom with unchanged page scale should not change scroll or scale. | 2455 // Anchor zoom with unchanged page scale should not change scroll or scale. |
| 2474 { | 2456 { |
| 2475 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2457 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2476 max_page_scale); | 2458 max_page_scale); |
| 2477 scroll_layer->layer_tree_impl() | 2459 scroll_layer->layer_tree_impl() |
| 2478 ->property_trees() | 2460 ->property_trees() |
| 2479 ->scroll_tree.UpdateScrollOffsetBaseForTesting( | 2461 ->scroll_tree.UpdateScrollOffsetBaseForTesting( |
| 2480 scroll_layer->id(), gfx::ScrollOffset(50, 50)); | 2462 scroll_layer->id(), gfx::ScrollOffset(50, 50)); |
| 2481 | 2463 |
| 2482 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2464 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 2483 std::unique_ptr<PendingPageScaleAnimation>( | 2465 std::unique_ptr<PendingPageScaleAnimation>( |
| 2484 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, | 2466 new PendingPageScaleAnimation(gfx::Vector2d(), true, 1.f, |
| 2485 duration))); | 2467 duration))); |
| 2486 host_impl_->ActivateSyncTree(); | 2468 host_impl_->ActivateSyncTree(); |
| 2487 begin_frame_args.frame_time = start_time; | 2469 begin_frame_args.frame_time = start_time; |
| 2470 begin_frame_args.sequence_number++; |
| 2488 host_impl_->WillBeginImplFrame(begin_frame_args); | 2471 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2489 host_impl_->Animate(); | 2472 host_impl_->Animate(); |
| 2490 host_impl_->DidFinishImplFrame(); | 2473 host_impl_->DidFinishImplFrame(); |
| 2491 | 2474 |
| 2492 begin_frame_args.frame_time = halfway_through_animation; | 2475 begin_frame_args.frame_time = halfway_through_animation; |
| 2476 begin_frame_args.sequence_number++; |
| 2493 host_impl_->WillBeginImplFrame(begin_frame_args); | 2477 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2494 host_impl_->Animate(); | 2478 host_impl_->Animate(); |
| 2495 EXPECT_TRUE(did_request_redraw_); | 2479 EXPECT_TRUE(did_request_redraw_); |
| 2496 host_impl_->DidFinishImplFrame(); | 2480 host_impl_->DidFinishImplFrame(); |
| 2497 | 2481 |
| 2498 begin_frame_args.frame_time = end_time; | 2482 begin_frame_args.frame_time = end_time; |
| 2483 begin_frame_args.sequence_number++; |
| 2499 host_impl_->WillBeginImplFrame(begin_frame_args); | 2484 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2500 host_impl_->Animate(); | 2485 host_impl_->Animate(); |
| 2501 EXPECT_TRUE(did_request_commit_); | 2486 EXPECT_TRUE(did_request_commit_); |
| 2502 host_impl_->DidFinishImplFrame(); | 2487 host_impl_->DidFinishImplFrame(); |
| 2503 | 2488 |
| 2504 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2489 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 2505 host_impl_->ProcessScrollDeltas(); | 2490 host_impl_->ProcessScrollDeltas(); |
| 2506 EXPECT_EQ(scroll_info->page_scale_delta, 1); | 2491 EXPECT_EQ(scroll_info->page_scale_delta, 1); |
| 2507 ExpectNone(*scroll_info, scroll_layer->id()); | 2492 ExpectNone(*scroll_info, scroll_layer->id()); |
| 2508 } | 2493 } |
| 2509 } | 2494 } |
| 2510 | 2495 |
| 2511 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { | 2496 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { |
| 2512 host_impl_->CreatePendingTree(); | 2497 host_impl_->CreatePendingTree(); |
| 2513 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 2498 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 2514 CreateScrollAndContentsLayers( | 2499 CreateScrollAndContentsLayers(host_impl_->pending_tree(), |
| 2515 host_impl_->pending_tree(), | 2500 gfx::Size(100, 100)); |
| 2516 gfx::Size(100, 100)); | |
| 2517 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 2501 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 2518 host_impl_->ActivateSyncTree(); | 2502 host_impl_->ActivateSyncTree(); |
| 2519 DrawFrame(); | 2503 DrawFrame(); |
| 2520 | 2504 |
| 2521 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2505 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 2522 DCHECK(scroll_layer); | 2506 DCHECK(scroll_layer); |
| 2523 | 2507 |
| 2524 float min_page_scale = 0.5f; | 2508 float min_page_scale = 0.5f; |
| 2525 float max_page_scale = 4.f; | 2509 float max_page_scale = 4.f; |
| 2526 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 2510 host_impl_->sync_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 2527 max_page_scale); | 2511 max_page_scale); |
| 2528 host_impl_->ActivateSyncTree(); | 2512 host_impl_->ActivateSyncTree(); |
| 2529 | 2513 |
| 2530 base::TimeTicks start_time = base::TimeTicks() + | 2514 base::TimeTicks start_time = |
| 2531 base::TimeDelta::FromSeconds(1); | 2515 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
| 2532 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2516 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 2533 base::TimeTicks third_through_animation = start_time + duration / 3; | 2517 base::TimeTicks third_through_animation = start_time + duration / 3; |
| 2534 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2518 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 2535 base::TimeTicks end_time = start_time + duration; | 2519 base::TimeTicks end_time = start_time + duration; |
| 2536 float target_scale = 2.f; | 2520 float target_scale = 2.f; |
| 2537 | 2521 |
| 2538 BeginFrameArgs begin_frame_args = | 2522 BeginFrameArgs begin_frame_args = |
| 2539 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2523 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 2540 | 2524 |
| 2541 scroll_layer->layer_tree_impl() | 2525 scroll_layer->layer_tree_impl() |
| 2542 ->property_trees() | 2526 ->property_trees() |
| 2543 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2527 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 2544 gfx::ScrollOffset(50, 50)); | 2528 gfx::ScrollOffset(50, 50)); |
| 2545 | 2529 |
| 2546 // Make sure TakePageScaleAnimation works properly. | 2530 // Make sure TakePageScaleAnimation works properly. |
| 2547 | 2531 |
| 2548 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2532 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
| 2549 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2533 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 2550 gfx::Vector2d(), false, target_scale, duration))); | 2534 gfx::Vector2d(), false, target_scale, duration))); |
| 2551 std::unique_ptr<PendingPageScaleAnimation> psa = | 2535 std::unique_ptr<PendingPageScaleAnimation> psa = |
| 2552 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); | 2536 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); |
| 2553 EXPECT_EQ(target_scale, psa->scale); | 2537 EXPECT_EQ(target_scale, psa->scale); |
| 2554 EXPECT_EQ(duration, psa->duration); | 2538 EXPECT_EQ(duration, psa->duration); |
| 2555 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); | 2539 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); |
| 2556 | 2540 |
| 2557 // Recreate the PSA. Nothing should happen here since the tree containing the | 2541 // Recreate the PSA. Nothing should happen here since the tree containing the |
| 2558 // PSA hasn't been activated yet. | 2542 // PSA hasn't been activated yet. |
| 2559 did_request_redraw_ = false; | 2543 did_request_redraw_ = false; |
| 2560 did_request_next_frame_ = false; | 2544 did_request_next_frame_ = false; |
| 2561 host_impl_->sync_tree()->SetPendingPageScaleAnimation( | 2545 host_impl_->sync_tree()->SetPendingPageScaleAnimation( |
| 2562 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2546 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 2563 gfx::Vector2d(), false, target_scale, duration))); | 2547 gfx::Vector2d(), false, target_scale, duration))); |
| 2564 begin_frame_args.frame_time = halfway_through_animation; | 2548 begin_frame_args.frame_time = halfway_through_animation; |
| 2549 begin_frame_args.sequence_number++; |
| 2565 host_impl_->WillBeginImplFrame(begin_frame_args); | 2550 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2566 host_impl_->Animate(); | 2551 host_impl_->Animate(); |
| 2567 EXPECT_FALSE(did_request_next_frame_); | 2552 EXPECT_FALSE(did_request_next_frame_); |
| 2568 EXPECT_FALSE(did_request_redraw_); | 2553 EXPECT_FALSE(did_request_redraw_); |
| 2569 host_impl_->DidFinishImplFrame(); | 2554 host_impl_->DidFinishImplFrame(); |
| 2570 | 2555 |
| 2571 // Activate the sync tree. This should cause the animation to become enabled. | 2556 // Activate the sync tree. This should cause the animation to become enabled. |
| 2572 // It should also clear the pointer on the sync tree. | 2557 // It should also clear the pointer on the sync tree. |
| 2573 host_impl_->ActivateSyncTree(); | 2558 host_impl_->ActivateSyncTree(); |
| 2574 EXPECT_EQ(nullptr, | 2559 EXPECT_EQ(nullptr, |
| 2575 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); | 2560 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); |
| 2576 EXPECT_FALSE(did_request_redraw_); | 2561 EXPECT_FALSE(did_request_redraw_); |
| 2577 EXPECT_TRUE(did_request_next_frame_); | 2562 EXPECT_TRUE(did_request_next_frame_); |
| 2578 | 2563 |
| 2579 start_time += base::TimeDelta::FromSeconds(10); | 2564 start_time += base::TimeDelta::FromSeconds(10); |
| 2580 third_through_animation += base::TimeDelta::FromSeconds(10); | 2565 third_through_animation += base::TimeDelta::FromSeconds(10); |
| 2581 halfway_through_animation += base::TimeDelta::FromSeconds(10); | 2566 halfway_through_animation += base::TimeDelta::FromSeconds(10); |
| 2582 end_time += base::TimeDelta::FromSeconds(10); | 2567 end_time += base::TimeDelta::FromSeconds(10); |
| 2583 | 2568 |
| 2584 // From here on, make sure the animation runs as normal. | 2569 // From here on, make sure the animation runs as normal. |
| 2585 did_request_redraw_ = false; | 2570 did_request_redraw_ = false; |
| 2586 did_request_next_frame_ = false; | 2571 did_request_next_frame_ = false; |
| 2587 begin_frame_args.frame_time = start_time; | 2572 begin_frame_args.frame_time = start_time; |
| 2573 begin_frame_args.sequence_number++; |
| 2588 host_impl_->WillBeginImplFrame(begin_frame_args); | 2574 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2589 host_impl_->Animate(); | 2575 host_impl_->Animate(); |
| 2590 EXPECT_TRUE(did_request_redraw_); | 2576 EXPECT_TRUE(did_request_redraw_); |
| 2591 EXPECT_TRUE(did_request_next_frame_); | 2577 EXPECT_TRUE(did_request_next_frame_); |
| 2592 host_impl_->DidFinishImplFrame(); | 2578 host_impl_->DidFinishImplFrame(); |
| 2593 | 2579 |
| 2594 did_request_redraw_ = false; | 2580 did_request_redraw_ = false; |
| 2595 did_request_next_frame_ = false; | 2581 did_request_next_frame_ = false; |
| 2596 begin_frame_args.frame_time = third_through_animation; | 2582 begin_frame_args.frame_time = third_through_animation; |
| 2583 begin_frame_args.sequence_number++; |
| 2597 host_impl_->WillBeginImplFrame(begin_frame_args); | 2584 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2598 host_impl_->Animate(); | 2585 host_impl_->Animate(); |
| 2599 EXPECT_TRUE(did_request_redraw_); | 2586 EXPECT_TRUE(did_request_redraw_); |
| 2600 EXPECT_TRUE(did_request_next_frame_); | 2587 EXPECT_TRUE(did_request_next_frame_); |
| 2601 host_impl_->DidFinishImplFrame(); | 2588 host_impl_->DidFinishImplFrame(); |
| 2602 | 2589 |
| 2603 // Another activation shouldn't have any effect on the animation. | 2590 // Another activation shouldn't have any effect on the animation. |
| 2604 host_impl_->ActivateSyncTree(); | 2591 host_impl_->ActivateSyncTree(); |
| 2605 | 2592 |
| 2606 did_request_redraw_ = false; | 2593 did_request_redraw_ = false; |
| 2607 did_request_next_frame_ = false; | 2594 did_request_next_frame_ = false; |
| 2608 begin_frame_args.frame_time = halfway_through_animation; | 2595 begin_frame_args.frame_time = halfway_through_animation; |
| 2596 begin_frame_args.sequence_number++; |
| 2609 host_impl_->WillBeginImplFrame(begin_frame_args); | 2597 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2610 host_impl_->Animate(); | 2598 host_impl_->Animate(); |
| 2611 EXPECT_TRUE(did_request_redraw_); | 2599 EXPECT_TRUE(did_request_redraw_); |
| 2612 EXPECT_TRUE(did_request_next_frame_); | 2600 EXPECT_TRUE(did_request_next_frame_); |
| 2613 host_impl_->DidFinishImplFrame(); | 2601 host_impl_->DidFinishImplFrame(); |
| 2614 | 2602 |
| 2615 did_request_redraw_ = false; | 2603 did_request_redraw_ = false; |
| 2616 did_request_next_frame_ = false; | 2604 did_request_next_frame_ = false; |
| 2617 did_request_commit_ = false; | 2605 did_request_commit_ = false; |
| 2618 begin_frame_args.frame_time = end_time; | 2606 begin_frame_args.frame_time = end_time; |
| 2607 begin_frame_args.sequence_number++; |
| 2619 host_impl_->WillBeginImplFrame(begin_frame_args); | 2608 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2620 host_impl_->Animate(); | 2609 host_impl_->Animate(); |
| 2621 EXPECT_TRUE(did_request_commit_); | 2610 EXPECT_TRUE(did_request_commit_); |
| 2622 EXPECT_FALSE(did_request_next_frame_); | 2611 EXPECT_FALSE(did_request_next_frame_); |
| 2623 host_impl_->DidFinishImplFrame(); | 2612 host_impl_->DidFinishImplFrame(); |
| 2624 | 2613 |
| 2625 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2614 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 2626 host_impl_->ProcessScrollDeltas(); | 2615 host_impl_->ProcessScrollDeltas(); |
| 2627 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); | 2616 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); |
| 2628 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), | 2617 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), |
| 2629 gfx::Vector2d(-50, -50))); | 2618 gfx::Vector2d(-50, -50))); |
| 2630 } | 2619 } |
| 2631 | 2620 |
| 2632 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { | 2621 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { |
| 2633 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2622 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2634 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2623 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2635 DrawFrame(); | 2624 DrawFrame(); |
| 2636 | 2625 |
| 2637 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 2626 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 2638 DCHECK(scroll_layer); | 2627 DCHECK(scroll_layer); |
| 2639 | 2628 |
| 2640 base::TimeTicks start_time = | 2629 base::TimeTicks start_time = |
| 2641 base::TimeTicks() + base::TimeDelta::FromSeconds(1); | 2630 base::TimeTicks() + base::TimeDelta::FromSeconds(1); |
| 2642 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 2631 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 2643 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 2632 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
| 2644 base::TimeTicks end_time = start_time + duration; | 2633 base::TimeTicks end_time = start_time + duration; |
| 2645 | 2634 |
| 2646 BeginFrameArgs begin_frame_args = | 2635 BeginFrameArgs begin_frame_args = |
| 2647 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 2636 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 2648 | 2637 |
| 2649 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2638 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 2650 scroll_layer->layer_tree_impl() | 2639 scroll_layer->layer_tree_impl() |
| 2651 ->property_trees() | 2640 ->property_trees() |
| 2652 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 2641 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 2653 gfx::ScrollOffset(50, 50)); | 2642 gfx::ScrollOffset(50, 50)); |
| 2654 | 2643 |
| 2655 did_complete_page_scale_animation_ = false; | 2644 did_complete_page_scale_animation_ = false; |
| 2656 host_impl_->active_tree()->SetPendingPageScaleAnimation( | 2645 host_impl_->active_tree()->SetPendingPageScaleAnimation( |
| 2657 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( | 2646 std::unique_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( |
| 2658 gfx::Vector2d(), false, 2.f, duration))); | 2647 gfx::Vector2d(), false, 2.f, duration))); |
| 2659 host_impl_->ActivateSyncTree(); | 2648 host_impl_->ActivateSyncTree(); |
| 2660 begin_frame_args.frame_time = start_time; | 2649 begin_frame_args.frame_time = start_time; |
| 2650 begin_frame_args.sequence_number++; |
| 2661 host_impl_->WillBeginImplFrame(begin_frame_args); | 2651 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2662 host_impl_->Animate(); | 2652 host_impl_->Animate(); |
| 2663 EXPECT_FALSE(did_complete_page_scale_animation_); | 2653 EXPECT_FALSE(did_complete_page_scale_animation_); |
| 2664 host_impl_->DidFinishImplFrame(); | 2654 host_impl_->DidFinishImplFrame(); |
| 2665 | 2655 |
| 2666 begin_frame_args.frame_time = halfway_through_animation; | 2656 begin_frame_args.frame_time = halfway_through_animation; |
| 2657 begin_frame_args.sequence_number++; |
| 2667 host_impl_->WillBeginImplFrame(begin_frame_args); | 2658 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2668 host_impl_->Animate(); | 2659 host_impl_->Animate(); |
| 2669 EXPECT_FALSE(did_complete_page_scale_animation_); | 2660 EXPECT_FALSE(did_complete_page_scale_animation_); |
| 2670 host_impl_->DidFinishImplFrame(); | 2661 host_impl_->DidFinishImplFrame(); |
| 2671 | 2662 |
| 2672 begin_frame_args.frame_time = end_time; | 2663 begin_frame_args.frame_time = end_time; |
| 2664 begin_frame_args.sequence_number++; |
| 2673 host_impl_->WillBeginImplFrame(begin_frame_args); | 2665 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2674 host_impl_->Animate(); | 2666 host_impl_->Animate(); |
| 2675 EXPECT_TRUE(did_complete_page_scale_animation_); | 2667 EXPECT_TRUE(did_complete_page_scale_animation_); |
| 2676 host_impl_->DidFinishImplFrame(); | 2668 host_impl_->DidFinishImplFrame(); |
| 2677 } | 2669 } |
| 2678 | 2670 |
| 2679 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { | 2671 TEST_F(LayerTreeHostImplTest, MaxScrollOffsetAffectedByBoundsDelta) { |
| 2680 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2672 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2681 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2673 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2682 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 2674 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2713 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 2705 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 2714 : LayerTreeHostImpl(settings, | 2706 : LayerTreeHostImpl(settings, |
| 2715 client, | 2707 client, |
| 2716 task_runner_provider, | 2708 task_runner_provider, |
| 2717 rendering_stats_instrumentation, | 2709 rendering_stats_instrumentation, |
| 2718 task_graph_runner, | 2710 task_graph_runner, |
| 2719 AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 2711 AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
| 2720 0) {} | 2712 0) {} |
| 2721 | 2713 |
| 2722 BeginFrameArgs CurrentBeginFrameArgs() const override { | 2714 BeginFrameArgs CurrentBeginFrameArgs() const override { |
| 2723 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, | 2715 return CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1, |
| 2724 fake_current_physical_time_); | 2716 fake_current_physical_time_); |
| 2725 } | 2717 } |
| 2726 | 2718 |
| 2727 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { | 2719 void SetCurrentPhysicalTimeTicksForTest(base::TimeTicks fake_now) { |
| 2728 fake_current_physical_time_ = fake_now; | 2720 fake_current_physical_time_ = fake_now; |
| 2729 } | 2721 } |
| 2730 | 2722 |
| 2731 private: | 2723 private: |
| 2732 base::TimeTicks fake_current_physical_time_; | 2724 base::TimeTicks fake_current_physical_time_; |
| 2733 }; | 2725 }; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2792 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2801 InputHandler::WHEEL); | 2793 InputHandler::WHEEL); |
| 2802 host_impl_->ScrollEnd(EndState().get()); | 2794 host_impl_->ScrollEnd(EndState().get()); |
| 2803 EXPECT_FALSE(did_request_next_frame_); | 2795 EXPECT_FALSE(did_request_next_frame_); |
| 2804 EXPECT_FALSE(did_request_redraw_); | 2796 EXPECT_FALSE(did_request_redraw_); |
| 2805 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2797 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2806 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2798 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2807 | 2799 |
| 2808 // Before the scrollbar animation exists, we should not get redraws. | 2800 // Before the scrollbar animation exists, we should not get redraws. |
| 2809 BeginFrameArgs begin_frame_args = | 2801 BeginFrameArgs begin_frame_args = |
| 2810 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2802 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); |
| 2811 host_impl_->WillBeginImplFrame(begin_frame_args); | 2803 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2812 host_impl_->Animate(); | 2804 host_impl_->Animate(); |
| 2813 EXPECT_FALSE(did_request_next_frame_); | 2805 EXPECT_FALSE(did_request_next_frame_); |
| 2814 did_request_next_frame_ = false; | 2806 did_request_next_frame_ = false; |
| 2815 EXPECT_FALSE(did_request_redraw_); | 2807 EXPECT_FALSE(did_request_redraw_); |
| 2816 did_request_redraw_ = false; | 2808 did_request_redraw_ = false; |
| 2817 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2809 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2818 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2810 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2819 host_impl_->DidFinishImplFrame(); | 2811 host_impl_->DidFinishImplFrame(); |
| 2820 | 2812 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2837 requested_animation_delay_); | 2829 requested_animation_delay_); |
| 2838 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2830 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2839 } else { | 2831 } else { |
| 2840 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2832 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2841 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2833 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2842 } | 2834 } |
| 2843 | 2835 |
| 2844 if (expecting_animations) { | 2836 if (expecting_animations) { |
| 2845 // Before the scrollbar animation begins, we should not get redraws. | 2837 // Before the scrollbar animation begins, we should not get redraws. |
| 2846 begin_frame_args = | 2838 begin_frame_args = |
| 2847 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2839 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3, fake_now); |
| 2848 host_impl_->WillBeginImplFrame(begin_frame_args); | 2840 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2849 host_impl_->Animate(); | 2841 host_impl_->Animate(); |
| 2850 EXPECT_FALSE(did_request_next_frame_); | 2842 EXPECT_FALSE(did_request_next_frame_); |
| 2851 did_request_next_frame_ = false; | 2843 did_request_next_frame_ = false; |
| 2852 EXPECT_FALSE(did_request_redraw_); | 2844 EXPECT_FALSE(did_request_redraw_); |
| 2853 did_request_redraw_ = false; | 2845 did_request_redraw_ = false; |
| 2854 host_impl_->DidFinishImplFrame(); | 2846 host_impl_->DidFinishImplFrame(); |
| 2855 | 2847 |
| 2856 // Start the scrollbar animation. | 2848 // Start the scrollbar animation. |
| 2857 fake_now += requested_animation_delay_; | 2849 fake_now += requested_animation_delay_; |
| 2858 requested_animation_delay_ = base::TimeDelta(); | 2850 requested_animation_delay_ = base::TimeDelta(); |
| 2859 animation_task_.Run(); | 2851 animation_task_.Run(); |
| 2860 animation_task_ = base::Closure(); | 2852 animation_task_ = base::Closure(); |
| 2861 EXPECT_TRUE(did_request_next_frame_); | 2853 EXPECT_TRUE(did_request_next_frame_); |
| 2862 did_request_next_frame_ = false; | 2854 did_request_next_frame_ = false; |
| 2863 EXPECT_FALSE(did_request_redraw_); | 2855 EXPECT_FALSE(did_request_redraw_); |
| 2864 | 2856 |
| 2865 // After the scrollbar animation begins, we should start getting redraws. | 2857 // After the scrollbar animation begins, we should start getting redraws. |
| 2866 begin_frame_args = | 2858 begin_frame_args = |
| 2867 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2859 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 4, fake_now); |
| 2868 host_impl_->WillBeginImplFrame(begin_frame_args); | 2860 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2869 host_impl_->Animate(); | 2861 host_impl_->Animate(); |
| 2870 EXPECT_TRUE(did_request_next_frame_); | 2862 EXPECT_TRUE(did_request_next_frame_); |
| 2871 did_request_next_frame_ = false; | 2863 did_request_next_frame_ = false; |
| 2872 EXPECT_TRUE(did_request_redraw_); | 2864 EXPECT_TRUE(did_request_redraw_); |
| 2873 did_request_redraw_ = false; | 2865 did_request_redraw_ = false; |
| 2874 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2866 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2875 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2867 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2876 host_impl_->DidFinishImplFrame(); | 2868 host_impl_->DidFinishImplFrame(); |
| 2877 } | 2869 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2895 animation_task_ = base::Closure(); | 2887 animation_task_ = base::Closure(); |
| 2896 } else { | 2888 } else { |
| 2897 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2889 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2898 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2890 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2899 } | 2891 } |
| 2900 | 2892 |
| 2901 if (expecting_animations) { | 2893 if (expecting_animations) { |
| 2902 // Scrolling should have stopped the animation, so we should not be | 2894 // Scrolling should have stopped the animation, so we should not be |
| 2903 // getting redraws. | 2895 // getting redraws. |
| 2904 begin_frame_args = | 2896 begin_frame_args = |
| 2905 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now); | 2897 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 5, fake_now); |
| 2906 host_impl_->WillBeginImplFrame(begin_frame_args); | 2898 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2907 host_impl_->Animate(); | 2899 host_impl_->Animate(); |
| 2908 EXPECT_FALSE(did_request_next_frame_); | 2900 EXPECT_FALSE(did_request_next_frame_); |
| 2909 did_request_next_frame_ = false; | 2901 did_request_next_frame_ = false; |
| 2910 EXPECT_FALSE(did_request_redraw_); | 2902 EXPECT_FALSE(did_request_redraw_); |
| 2911 did_request_redraw_ = false; | 2903 did_request_redraw_ = false; |
| 2912 host_impl_->DidFinishImplFrame(); | 2904 host_impl_->DidFinishImplFrame(); |
| 2913 } | 2905 } |
| 2914 | 2906 |
| 2915 // Scrollbar animation is not triggered unnecessarily. | 2907 // Scrollbar animation is not triggered unnecessarily. |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3299 EXPECT_EQ(1.f, metadata.page_scale_factor); | 3291 EXPECT_EQ(1.f, metadata.page_scale_factor); |
| 3300 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); | 3292 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); |
| 3301 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 3293 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
| 3302 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 3294 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 3303 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 3295 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
| 3304 EXPECT_FALSE(metadata.root_overflow_x_hidden); | 3296 EXPECT_FALSE(metadata.root_overflow_x_hidden); |
| 3305 EXPECT_FALSE(metadata.root_overflow_y_hidden); | 3297 EXPECT_FALSE(metadata.root_overflow_y_hidden); |
| 3306 } | 3298 } |
| 3307 | 3299 |
| 3308 // Scrolling should update metadata immediately. | 3300 // Scrolling should update metadata immediately. |
| 3309 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 3301 EXPECT_EQ( |
| 3310 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 3302 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 3311 InputHandler::WHEEL) | 3303 host_impl_ |
| 3312 .thread); | 3304 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 3305 .thread); |
| 3313 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 3306 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 3314 { | 3307 { |
| 3315 CompositorFrameMetadata metadata = | 3308 CompositorFrameMetadata metadata = |
| 3316 host_impl_->MakeCompositorFrameMetadata(); | 3309 host_impl_->MakeCompositorFrameMetadata(); |
| 3317 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 3310 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| 3318 } | 3311 } |
| 3319 host_impl_->ScrollEnd(EndState().get()); | 3312 host_impl_->ScrollEnd(EndState().get()); |
| 3320 { | 3313 { |
| 3321 CompositorFrameMetadata metadata = | 3314 CompositorFrameMetadata metadata = |
| 3322 host_impl_->MakeCompositorFrameMetadata(); | 3315 host_impl_->MakeCompositorFrameMetadata(); |
| (...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4584 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 4577 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
| 4585 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4578 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4586 host_impl_ | 4579 host_impl_ |
| 4587 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4580 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4588 InputHandler::TOUCHSCREEN) | 4581 InputHandler::TOUCHSCREEN) |
| 4589 .thread); | 4582 .thread); |
| 4590 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4583 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4591 host_impl_->ScrollEnd(EndState().get()); | 4584 host_impl_->ScrollEnd(EndState().get()); |
| 4592 | 4585 |
| 4593 // The viewport offset shouldn't have changed. | 4586 // The viewport offset shouldn't have changed. |
| 4594 EXPECT_EQ(viewport_offset, | 4587 EXPECT_EQ(viewport_offset, host_impl_->active_tree()->TotalScrollOffset()); |
| 4595 host_impl_->active_tree()->TotalScrollOffset()); | |
| 4596 | 4588 |
| 4597 // Scroll the viewports to max scroll offset. | 4589 // Scroll the viewports to max scroll offset. |
| 4598 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); | 4590 SetScrollOffsetDelta(outer_scroll, gfx::Vector2dF(0, 200.f)); |
| 4599 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); | 4591 SetScrollOffsetDelta(inner_scroll, gfx::Vector2dF(100, 100.f)); |
| 4600 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 4592 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 4601 host_impl_->active_tree()->TotalScrollOffset()); | 4593 host_impl_->active_tree()->TotalScrollOffset()); |
| 4602 } | 4594 } |
| 4603 | 4595 |
| 4604 // Test that the browser controls coming in and out maintains the same aspect | 4596 // Test that the browser controls coming in and out maintains the same aspect |
| 4605 // ratio between the inner and outer viewports. | 4597 // ratio between the inner and outer viewports. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4622 host_impl_->ScrollEnd(EndState().get()); | 4614 host_impl_->ScrollEnd(EndState().get()); |
| 4623 | 4615 |
| 4624 EXPECT_FLOAT_EQ( | 4616 EXPECT_FLOAT_EQ( |
| 4625 scroll_delta.y(), | 4617 scroll_delta.y(), |
| 4626 top_controls_height_ - | 4618 top_controls_height_ - |
| 4627 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4619 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4628 | 4620 |
| 4629 // Browser controls were hidden by 25px so the inner viewport should have | 4621 // Browser controls were hidden by 25px so the inner viewport should have |
| 4630 // expanded by that much. | 4622 // expanded by that much. |
| 4631 LayerImpl* outer_container = | 4623 LayerImpl* outer_container = |
| 4632 host_impl_->active_tree()->OuterViewportContainerLayer(); | 4624 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 4633 LayerImpl* inner_container = | 4625 LayerImpl* inner_container = |
| 4634 host_impl_->active_tree()->InnerViewportContainerLayer(); | 4626 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 4635 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), | 4627 EXPECT_EQ(gfx::SizeF(100.f, 100.f + 25.f), |
| 4636 inner_container->BoundsForScrolling()); | 4628 inner_container->BoundsForScrolling()); |
| 4637 | 4629 |
| 4638 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. | 4630 // Outer viewport should match inner's aspect ratio. The bounds are ceiled. |
| 4639 float aspect_ratio = inner_container->BoundsForScrolling().width() / | 4631 float aspect_ratio = inner_container->BoundsForScrolling().width() / |
| 4640 inner_container->BoundsForScrolling().height(); | 4632 inner_container->BoundsForScrolling().height(); |
| 4641 gfx::SizeF expected = | 4633 gfx::SizeF expected = |
| 4642 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); | 4634 gfx::SizeF(gfx::ToCeiledSize(gfx::SizeF(200, 200 / aspect_ratio))); |
| 4643 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); | 4635 EXPECT_EQ(expected, outer_container->BoundsForScrolling()); |
| 4644 EXPECT_EQ(expected, | 4636 EXPECT_EQ(expected, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4819 ASSERT_FLOAT_EQ(0, | 4811 ASSERT_FLOAT_EQ(0, |
| 4820 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4812 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4821 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); | 4813 ASSERT_EQ(1000, outer_scroll->MaxScrollOffset().y()); |
| 4822 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); | 4814 ASSERT_EQ(1000, outer_scroll->CurrentScrollOffset().y()); |
| 4823 | 4815 |
| 4824 // Kick off an animation to show the browser controls. | 4816 // Kick off an animation to show the browser controls. |
| 4825 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( | 4817 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 4826 BOTH, SHOWN, true); | 4818 BOTH, SHOWN, true); |
| 4827 base::TimeTicks start_time = base::TimeTicks::Now(); | 4819 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 4828 BeginFrameArgs begin_frame_args = | 4820 BeginFrameArgs begin_frame_args = |
| 4829 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 4821 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 4830 | 4822 |
| 4831 // Pump an animation frame to put some delta in the browser controls. | 4823 // Pump an animation frame to put some delta in the browser controls. |
| 4832 { | 4824 { |
| 4833 begin_frame_args.frame_time = | 4825 begin_frame_args.frame_time = |
| 4834 start_time + base::TimeDelta::FromMilliseconds(50); | 4826 start_time + base::TimeDelta::FromMilliseconds(50); |
| 4827 begin_frame_args.sequence_number++; |
| 4835 host_impl_->WillBeginImplFrame(begin_frame_args); | 4828 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 4836 host_impl_->Animate(); | 4829 host_impl_->Animate(); |
| 4837 host_impl_->UpdateAnimationState(true); | 4830 host_impl_->UpdateAnimationState(true); |
| 4838 host_impl_->DidFinishImplFrame(); | 4831 host_impl_->DidFinishImplFrame(); |
| 4839 } | 4832 } |
| 4840 | 4833 |
| 4841 // Pull the browser controls delta and get it back to the pending tree so that | 4834 // Pull the browser controls delta and get it back to the pending tree so that |
| 4842 // when we go to activate the pending tree we cause a change to browser | 4835 // when we go to activate the pending tree we cause a change to browser |
| 4843 // controls. | 4836 // controls. |
| 4844 { | 4837 { |
| 4845 float delta = | 4838 float delta = |
| 4846 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); | 4839 host_impl_->active_tree()->top_controls_shown_ratio()->Delta(); |
| 4847 ASSERT_GT(delta, 0); | 4840 ASSERT_GT(delta, 0); |
| 4848 ASSERT_LT(delta, 1); | 4841 ASSERT_LT(delta, 1); |
| 4849 host_impl_->active_tree() | 4842 host_impl_->active_tree() |
| 4850 ->top_controls_shown_ratio() | 4843 ->top_controls_shown_ratio() |
| 4851 ->PullDeltaForMainThread(); | 4844 ->PullDeltaForMainThread(); |
| 4852 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4845 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4853 delta); | 4846 delta); |
| 4854 } | 4847 } |
| 4855 | 4848 |
| 4856 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so | 4849 // 200 is the kShowHideMaxDurationMs value from browser_controls_manager.cc so |
| 4857 // the browser controls should be fully animated in this frame. | 4850 // the browser controls should be fully animated in this frame. |
| 4858 { | 4851 { |
| 4859 begin_frame_args.frame_time = | 4852 begin_frame_args.frame_time = |
| 4860 start_time + base::TimeDelta::FromMilliseconds(200); | 4853 start_time + base::TimeDelta::FromMilliseconds(200); |
| 4854 begin_frame_args.sequence_number++; |
| 4861 host_impl_->WillBeginImplFrame(begin_frame_args); | 4855 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 4862 host_impl_->Animate(); | 4856 host_impl_->Animate(); |
| 4863 host_impl_->UpdateAnimationState(true); | 4857 host_impl_->UpdateAnimationState(true); |
| 4864 host_impl_->DidFinishImplFrame(); | 4858 host_impl_->DidFinishImplFrame(); |
| 4865 | 4859 |
| 4866 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); | 4860 ASSERT_EQ(50, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4867 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); | 4861 ASSERT_EQ(1050, outer_scroll->MaxScrollOffset().y()); |
| 4868 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we | 4862 // NEAR because clip layer bounds are truncated in MaxScrollOffset so we |
| 4869 // lose some precision in the intermediate animation steps. | 4863 // lose some precision in the intermediate animation steps. |
| 4870 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); | 4864 ASSERT_NEAR(1050, outer_scroll->CurrentScrollOffset().y(), 1.f); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4907 scroll_layer->SetPosition(gfx::PointF()); | 4901 scroll_layer->SetPosition(gfx::PointF()); |
| 4908 scroll_layer->test_properties()->AddChild(std::move(content_layer)); | 4902 scroll_layer->test_properties()->AddChild(std::move(content_layer)); |
| 4909 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); | 4903 scroll_clip_layer->test_properties()->AddChild(std::move(scroll_layer)); |
| 4910 | 4904 |
| 4911 scroll_clip_layer->test_properties()->force_render_surface = true; | 4905 scroll_clip_layer->test_properties()->force_render_surface = true; |
| 4912 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4906 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4913 | 4907 |
| 4914 host_impl_->SetViewportSize(surface_size); | 4908 host_impl_->SetViewportSize(surface_size); |
| 4915 DrawFrame(); | 4909 DrawFrame(); |
| 4916 | 4910 |
| 4917 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4911 EXPECT_EQ( |
| 4918 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4912 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4919 InputHandler::WHEEL) | 4913 host_impl_ |
| 4920 .thread); | 4914 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 4915 .thread); |
| 4921 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4916 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 4922 host_impl_->ScrollEnd(EndState().get()); | 4917 host_impl_->ScrollEnd(EndState().get()); |
| 4923 EXPECT_TRUE(did_request_redraw_); | 4918 EXPECT_TRUE(did_request_redraw_); |
| 4924 EXPECT_TRUE(did_request_commit_); | 4919 EXPECT_TRUE(did_request_commit_); |
| 4925 } | 4920 } |
| 4926 | 4921 |
| 4927 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 4922 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 4928 gfx::Size surface_size(10, 10); | 4923 gfx::Size surface_size(10, 10); |
| 4929 gfx::Size contents_size(20, 20); | 4924 gfx::Size contents_size(20, 20); |
| 4930 | 4925 |
| 4931 LayerImpl* root = | 4926 LayerImpl* root = |
| 4932 CreateBasicVirtualViewportLayers(surface_size, surface_size); | 4927 CreateBasicVirtualViewportLayers(surface_size, surface_size); |
| 4933 | 4928 |
| 4934 root->test_properties()->AddChild( | 4929 root->test_properties()->AddChild( |
| 4935 CreateScrollableLayer(12, contents_size, root)); | 4930 CreateScrollableLayer(12, contents_size, root)); |
| 4936 root->test_properties()->force_render_surface = true; | 4931 root->test_properties()->force_render_surface = true; |
| 4937 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 4932 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 4938 | 4933 |
| 4939 host_impl_->SetViewportSize(surface_size); | 4934 host_impl_->SetViewportSize(surface_size); |
| 4940 DrawFrame(); | 4935 DrawFrame(); |
| 4941 | 4936 |
| 4942 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4937 EXPECT_EQ( |
| 4943 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 4938 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4944 InputHandler::WHEEL) | 4939 host_impl_ |
| 4945 .thread); | 4940 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 4941 .thread); |
| 4946 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 4942 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 4947 host_impl_->ScrollEnd(EndState().get()); | 4943 host_impl_->ScrollEnd(EndState().get()); |
| 4948 EXPECT_TRUE(did_request_redraw_); | 4944 EXPECT_TRUE(did_request_redraw_); |
| 4949 EXPECT_TRUE(did_request_commit_); | 4945 EXPECT_TRUE(did_request_commit_); |
| 4950 } | 4946 } |
| 4951 | 4947 |
| 4952 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 4948 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 4953 gfx::Size surface_size(10, 10); | 4949 gfx::Size surface_size(10, 10); |
| 4954 std::unique_ptr<LayerImpl> root = | 4950 std::unique_ptr<LayerImpl> root = |
| 4955 LayerImpl::Create(host_impl_->active_tree(), 1); | 4951 LayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5057 | 5053 |
| 5058 LayerImpl* root_scroll = | 5054 LayerImpl* root_scroll = |
| 5059 host_impl_->active_tree()->OuterViewportScrollLayer(); | 5055 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 5060 LayerImpl* inner_scroll = | 5056 LayerImpl* inner_scroll = |
| 5061 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5057 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 5062 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 5058 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| 5063 | 5059 |
| 5064 gfx::Vector2d scroll_delta(0, 10); | 5060 gfx::Vector2d scroll_delta(0, 10); |
| 5065 gfx::Vector2d expected_scroll_delta = scroll_delta; | 5061 gfx::Vector2d expected_scroll_delta = scroll_delta; |
| 5066 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 5062 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
| 5067 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5063 EXPECT_EQ( |
| 5068 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5064 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5069 InputHandler::WHEEL) | 5065 host_impl_ |
| 5070 .thread); | 5066 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 5067 .thread); |
| 5071 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5068 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5072 host_impl_->ScrollEnd(EndState().get()); | 5069 host_impl_->ScrollEnd(EndState().get()); |
| 5073 | 5070 |
| 5074 // Set new page scale from main thread. | 5071 // Set new page scale from main thread. |
| 5075 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 5072 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
| 5076 | 5073 |
| 5077 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5074 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5078 host_impl_->ProcessScrollDeltas(); | 5075 host_impl_->ProcessScrollDeltas(); |
| 5079 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), | 5076 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), inner_scroll->id(), |
| 5080 expected_scroll_delta)); | 5077 expected_scroll_delta)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5107 | 5104 |
| 5108 LayerImpl* root_scroll = | 5105 LayerImpl* root_scroll = |
| 5109 host_impl_->active_tree()->OuterViewportScrollLayer(); | 5106 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 5110 LayerImpl* inner_scroll = | 5107 LayerImpl* inner_scroll = |
| 5111 host_impl_->active_tree()->InnerViewportScrollLayer(); | 5108 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 5112 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 5109 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| 5113 | 5110 |
| 5114 gfx::Vector2d scroll_delta(0, 10); | 5111 gfx::Vector2d scroll_delta(0, 10); |
| 5115 gfx::Vector2d expected_scroll_delta = scroll_delta; | 5112 gfx::Vector2d expected_scroll_delta = scroll_delta; |
| 5116 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 5113 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
| 5117 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5114 EXPECT_EQ( |
| 5118 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5115 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5119 InputHandler::WHEEL) | 5116 host_impl_ |
| 5120 .thread); | 5117 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 5118 .thread); |
| 5121 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5119 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5122 host_impl_->ScrollEnd(EndState().get()); | 5120 host_impl_->ScrollEnd(EndState().get()); |
| 5123 | 5121 |
| 5124 // Set new page scale on impl thread by pinching. | 5122 // Set new page scale on impl thread by pinching. |
| 5125 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5123 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5126 InputHandler::TOUCHSCREEN); | 5124 InputHandler::TOUCHSCREEN); |
| 5127 host_impl_->PinchGestureBegin(); | 5125 host_impl_->PinchGestureBegin(); |
| 5128 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 5126 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
| 5129 host_impl_->PinchGestureEnd(); | 5127 host_impl_->PinchGestureEnd(); |
| 5130 host_impl_->ScrollEnd(EndState().get()); | 5128 host_impl_->ScrollEnd(EndState().get()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5209 | 5207 |
| 5210 // Make the outer scroll layer scrollable. | 5208 // Make the outer scroll layer scrollable. |
| 5211 outer_scroll->SetBounds(gfx::Size(50, 50)); | 5209 outer_scroll->SetBounds(gfx::Size(50, 50)); |
| 5212 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5210 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5213 | 5211 |
| 5214 DrawFrame(); | 5212 DrawFrame(); |
| 5215 | 5213 |
| 5216 gfx::Vector2d scroll_delta(0, 10); | 5214 gfx::Vector2d scroll_delta(0, 10); |
| 5217 gfx::Vector2d expected_scroll_delta(scroll_delta); | 5215 gfx::Vector2d expected_scroll_delta(scroll_delta); |
| 5218 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); | 5216 gfx::ScrollOffset expected_max_scroll(outer_scroll->MaxScrollOffset()); |
| 5219 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5217 EXPECT_EQ( |
| 5220 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5218 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5221 InputHandler::WHEEL) | 5219 host_impl_ |
| 5222 .thread); | 5220 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 5221 .thread); |
| 5223 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5222 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5224 host_impl_->ScrollEnd(EndState().get()); | 5223 host_impl_->ScrollEnd(EndState().get()); |
| 5225 | 5224 |
| 5226 float page_scale = 2.f; | 5225 float page_scale = 2.f; |
| 5227 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 5226 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
| 5228 page_scale); | 5227 page_scale); |
| 5229 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5228 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5230 | 5229 |
| 5231 DrawOneFrame(); | 5230 DrawOneFrame(); |
| 5232 | 5231 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5272 gfx::ScrollOffset(0, 5)); | 5271 gfx::ScrollOffset(0, 5)); |
| 5273 child_layer->layer_tree_impl() | 5272 child_layer->layer_tree_impl() |
| 5274 ->property_trees() | 5273 ->property_trees() |
| 5275 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5274 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| 5276 gfx::ScrollOffset(3, 0)); | 5275 gfx::ScrollOffset(3, 0)); |
| 5277 | 5276 |
| 5278 host_impl_->SetViewportSize(surface_size); | 5277 host_impl_->SetViewportSize(surface_size); |
| 5279 DrawFrame(); | 5278 DrawFrame(); |
| 5280 { | 5279 { |
| 5281 gfx::Vector2d scroll_delta(-8, -7); | 5280 gfx::Vector2d scroll_delta(-8, -7); |
| 5282 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5281 EXPECT_EQ( |
| 5283 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5282 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5284 InputHandler::WHEEL) | 5283 host_impl_ |
| 5285 .thread); | 5284 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 5285 .thread); |
| 5286 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5286 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5287 host_impl_->ScrollEnd(EndState().get()); | 5287 host_impl_->ScrollEnd(EndState().get()); |
| 5288 | 5288 |
| 5289 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5289 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5290 host_impl_->ProcessScrollDeltas(); | 5290 host_impl_->ProcessScrollDeltas(); |
| 5291 | 5291 |
| 5292 // The grand child should have scrolled up to its limit. | 5292 // The grand child should have scrolled up to its limit. |
| 5293 LayerImpl* child = host_impl_->active_tree() | 5293 LayerImpl* child = host_impl_->active_tree() |
| 5294 ->root_layer_for_testing() | 5294 ->root_layer_for_testing() |
| 5295 ->test_properties() | 5295 ->test_properties() |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5343 gfx::ScrollOffset(0, 2)); | 5343 gfx::ScrollOffset(0, 2)); |
| 5344 child_layer->layer_tree_impl() | 5344 child_layer->layer_tree_impl() |
| 5345 ->property_trees() | 5345 ->property_trees() |
| 5346 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), | 5346 ->scroll_tree.UpdateScrollOffsetBaseForTesting(child_layer->id(), |
| 5347 gfx::ScrollOffset(0, 3)); | 5347 gfx::ScrollOffset(0, 3)); |
| 5348 | 5348 |
| 5349 DrawFrame(); | 5349 DrawFrame(); |
| 5350 { | 5350 { |
| 5351 gfx::Vector2d scroll_delta(0, -10); | 5351 gfx::Vector2d scroll_delta(0, -10); |
| 5352 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5352 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5353 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5353 host_impl_ |
| 5354 InputHandler::NON_BUBBLING_GESTURE) | 5354 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5355 InputHandler::NON_BUBBLING_GESTURE) |
| 5355 .thread); | 5356 .thread); |
| 5356 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5357 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5357 host_impl_->ScrollEnd(EndState().get()); | 5358 host_impl_->ScrollEnd(EndState().get()); |
| 5358 | 5359 |
| 5359 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5360 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5360 host_impl_->ProcessScrollDeltas(); | 5361 host_impl_->ProcessScrollDeltas(); |
| 5361 | 5362 |
| 5362 // The grand child should have scrolled up to its limit. | 5363 // The grand child should have scrolled up to its limit. |
| 5363 LayerImpl* child = host_impl_->active_tree() | 5364 LayerImpl* child = host_impl_->active_tree() |
| 5364 ->root_layer_for_testing() | 5365 ->root_layer_for_testing() |
| 5365 ->test_properties() | 5366 ->test_properties() |
| 5366 ->children[0] | 5367 ->children[0] |
| 5367 ->test_properties() | 5368 ->test_properties() |
| 5368 ->children[0] | 5369 ->children[0] |
| 5369 ->test_properties() | 5370 ->test_properties() |
| 5370 ->children[0]; | 5371 ->children[0]; |
| 5371 LayerImpl* grand_child = child->test_properties()->children[0]; | 5372 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 5372 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5373 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5373 gfx::Vector2d(0, -2))); | 5374 gfx::Vector2d(0, -2))); |
| 5374 | 5375 |
| 5375 // The child should not have scrolled. | 5376 // The child should not have scrolled. |
| 5376 ExpectNone(*scroll_info.get(), child->id()); | 5377 ExpectNone(*scroll_info.get(), child->id()); |
| 5377 | 5378 |
| 5378 // The next time we scroll we should only scroll the parent. | 5379 // The next time we scroll we should only scroll the parent. |
| 5379 scroll_delta = gfx::Vector2d(0, -3); | 5380 scroll_delta = gfx::Vector2d(0, -3); |
| 5380 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5381 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5381 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5382 host_impl_ |
| 5382 InputHandler::NON_BUBBLING_GESTURE) | 5383 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5384 InputHandler::NON_BUBBLING_GESTURE) |
| 5383 .thread); | 5385 .thread); |
| 5384 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5386 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 5385 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5387 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5386 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 5388 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
| 5387 host_impl_->ScrollEnd(EndState().get()); | 5389 host_impl_->ScrollEnd(EndState().get()); |
| 5388 | 5390 |
| 5389 scroll_info = host_impl_->ProcessScrollDeltas(); | 5391 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5390 | 5392 |
| 5391 // The child should have scrolled up to its limit. | 5393 // The child should have scrolled up to its limit. |
| 5392 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 5394 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), |
| 5393 gfx::Vector2d(0, -3))); | 5395 gfx::Vector2d(0, -3))); |
| 5394 | 5396 |
| 5395 // The grand child should not have scrolled. | 5397 // The grand child should not have scrolled. |
| 5396 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5398 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5397 gfx::Vector2d(0, -2))); | 5399 gfx::Vector2d(0, -2))); |
| 5398 | 5400 |
| 5399 // After scrolling the parent, another scroll on the opposite direction | 5401 // After scrolling the parent, another scroll on the opposite direction |
| 5400 // should still scroll the child. | 5402 // should still scroll the child. |
| 5401 scroll_delta = gfx::Vector2d(0, 7); | 5403 scroll_delta = gfx::Vector2d(0, 7); |
| 5402 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5404 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5403 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5405 host_impl_ |
| 5404 InputHandler::NON_BUBBLING_GESTURE) | 5406 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5407 InputHandler::NON_BUBBLING_GESTURE) |
| 5405 .thread); | 5408 .thread); |
| 5406 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5409 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 5407 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5410 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5408 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5411 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 5409 host_impl_->ScrollEnd(EndState().get()); | 5412 host_impl_->ScrollEnd(EndState().get()); |
| 5410 | 5413 |
| 5411 scroll_info = host_impl_->ProcessScrollDeltas(); | 5414 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5412 | 5415 |
| 5413 // The grand child should have scrolled. | 5416 // The grand child should have scrolled. |
| 5414 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5417 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5415 gfx::Vector2d(0, 5))); | 5418 gfx::Vector2d(0, 5))); |
| 5416 | 5419 |
| 5417 // The child should not have scrolled. | 5420 // The child should not have scrolled. |
| 5418 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 5421 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), |
| 5419 gfx::Vector2d(0, -3))); | 5422 gfx::Vector2d(0, -3))); |
| 5420 | 5423 |
| 5421 // Scrolling should be adjusted from viewport space. | 5424 // Scrolling should be adjusted from viewport space. |
| 5422 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); | 5425 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); |
| 5423 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 5426 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 5424 | 5427 |
| 5425 scroll_delta = gfx::Vector2d(0, -2); | 5428 scroll_delta = gfx::Vector2d(0, -2); |
| 5426 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5429 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5427 host_impl_->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5430 host_impl_ |
| 5428 InputHandler::NON_BUBBLING_GESTURE) | 5431 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
| 5432 InputHandler::NON_BUBBLING_GESTURE) |
| 5429 .thread); | 5433 .thread); |
| 5430 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); | 5434 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); |
| 5431 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5435 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5432 host_impl_->ScrollEnd(EndState().get()); | 5436 host_impl_->ScrollEnd(EndState().get()); |
| 5433 | 5437 |
| 5434 scroll_info = host_impl_->ProcessScrollDeltas(); | 5438 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5435 | 5439 |
| 5436 // Should have scrolled by half the amount in layer space (5 - 2/2) | 5440 // Should have scrolled by half the amount in layer space (5 - 2/2) |
| 5437 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5441 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5438 gfx::Vector2d(0, 4))); | 5442 gfx::Vector2d(0, 4))); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5466 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, | 5470 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 2, |
| 5467 Layer::INVALID_ID); | 5471 Layer::INVALID_ID); |
| 5468 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5472 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5469 host_impl_->active_tree()->DidBecomeActive(); | 5473 host_impl_->active_tree()->DidBecomeActive(); |
| 5470 | 5474 |
| 5471 host_impl_->SetViewportSize(surface_size); | 5475 host_impl_->SetViewportSize(surface_size); |
| 5472 DrawFrame(); | 5476 DrawFrame(); |
| 5473 { | 5477 { |
| 5474 gfx::Vector2d scroll_delta(0, 4); | 5478 gfx::Vector2d scroll_delta(0, 4); |
| 5475 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5479 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5476 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5480 host_impl_ |
| 5477 InputHandler::WHEEL) | 5481 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5482 InputHandler::WHEEL) |
| 5478 .thread); | 5483 .thread); |
| 5479 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5484 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5480 host_impl_->ScrollEnd(EndState().get()); | 5485 host_impl_->ScrollEnd(EndState().get()); |
| 5481 | 5486 |
| 5482 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5487 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5483 host_impl_->ProcessScrollDeltas(); | 5488 host_impl_->ProcessScrollDeltas(); |
| 5484 | 5489 |
| 5485 // Only the root scroll should have scrolled. | 5490 // Only the root scroll should have scrolled. |
| 5486 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 5491 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 5487 EXPECT_TRUE( | 5492 EXPECT_TRUE( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5542 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); | 5547 inner_clip2->test_properties()->AddChild(std::move(inner_scroll2)); |
| 5543 inner_clip2->test_properties()->force_render_surface = true; | 5548 inner_clip2->test_properties()->force_render_surface = true; |
| 5544 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); | 5549 root_ptr2->test_properties()->AddChild(std::move(inner_clip2)); |
| 5545 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); | 5550 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_ptr2)); |
| 5546 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5551 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5547 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, | 5552 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 4, 6, |
| 5548 10); | 5553 10); |
| 5549 host_impl_->active_tree()->DidBecomeActive(); | 5554 host_impl_->active_tree()->DidBecomeActive(); |
| 5550 | 5555 |
| 5551 // Scrolling should still work even though we did not draw yet. | 5556 // Scrolling should still work even though we did not draw yet. |
| 5552 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5557 EXPECT_EQ( |
| 5553 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5558 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5554 InputHandler::WHEEL) | 5559 host_impl_ |
| 5555 .thread); | 5560 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL) |
| 5561 .thread); |
| 5556 } | 5562 } |
| 5557 | 5563 |
| 5558 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 5564 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
| 5559 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5565 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5560 scroll_layer->SetDrawsContent(true); | 5566 scroll_layer->SetDrawsContent(true); |
| 5561 | 5567 |
| 5562 // Rotate the root layer 90 degrees counter-clockwise about its center. | 5568 // Rotate the root layer 90 degrees counter-clockwise about its center. |
| 5563 gfx::Transform rotate_transform; | 5569 gfx::Transform rotate_transform; |
| 5564 rotate_transform.Rotate(-90.0); | 5570 rotate_transform.Rotate(-90.0); |
| 5565 host_impl_->active_tree() | 5571 host_impl_->active_tree() |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5584 | 5590 |
| 5585 // The layer should have scrolled down in its local coordinates. | 5591 // The layer should have scrolled down in its local coordinates. |
| 5586 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5592 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5587 host_impl_->ProcessScrollDeltas(); | 5593 host_impl_->ProcessScrollDeltas(); |
| 5588 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5594 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
| 5589 gfx::Vector2d(0, gesture_scroll_delta.x()))); | 5595 gfx::Vector2d(0, gesture_scroll_delta.x()))); |
| 5590 | 5596 |
| 5591 // Reset and scroll down with the wheel. | 5597 // Reset and scroll down with the wheel. |
| 5592 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 5598 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
| 5593 gfx::Vector2d wheel_scroll_delta(0, 10); | 5599 gfx::Vector2d wheel_scroll_delta(0, 10); |
| 5594 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5600 EXPECT_EQ( |
| 5595 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5601 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5596 InputHandler::WHEEL) | 5602 host_impl_ |
| 5597 .thread); | 5603 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 5604 .thread); |
| 5598 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); | 5605 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); |
| 5599 host_impl_->ScrollEnd(EndState().get()); | 5606 host_impl_->ScrollEnd(EndState().get()); |
| 5600 | 5607 |
| 5601 // The layer should have scrolled down in its local coordinates. | 5608 // The layer should have scrolled down in its local coordinates. |
| 5602 scroll_info = host_impl_->ProcessScrollDeltas(); | 5609 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5603 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5610 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
| 5604 wheel_scroll_delta)); | 5611 wheel_scroll_delta)); |
| 5605 } | 5612 } |
| 5606 | 5613 |
| 5607 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { | 5614 TEST_F(LayerTreeHostImplTest, ScrollNonAxisAlignedRotatedLayer) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5762 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, | 5769 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child_layer_id, |
| 5763 expected_scroll_deltas[i])); | 5770 expected_scroll_deltas[i])); |
| 5764 | 5771 |
| 5765 // The root scroll layer should not have scrolled, because the input delta | 5772 // The root scroll layer should not have scrolled, because the input delta |
| 5766 // was close to the layer's axis of movement. | 5773 // was close to the layer's axis of movement. |
| 5767 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 5774 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
| 5768 } | 5775 } |
| 5769 } | 5776 } |
| 5770 | 5777 |
| 5771 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5778 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
| 5772 LayerImpl* scroll_layer = | 5779 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5773 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | |
| 5774 | 5780 |
| 5775 // Scale the layer to twice its normal size. | 5781 // Scale the layer to twice its normal size. |
| 5776 int scale = 2; | 5782 int scale = 2; |
| 5777 gfx::Transform scale_transform; | 5783 gfx::Transform scale_transform; |
| 5778 scale_transform.Scale(scale, scale); | 5784 scale_transform.Scale(scale, scale); |
| 5779 scroll_layer->test_properties()->parent->test_properties()->transform = | 5785 scroll_layer->test_properties()->parent->test_properties()->transform = |
| 5780 scale_transform; | 5786 scale_transform; |
| 5781 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 5787 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 5782 | 5788 |
| 5783 gfx::Size surface_size(50, 50); | 5789 gfx::Size surface_size(50, 50); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5797 // The layer should have scrolled down in its local coordinates, but half the | 5803 // The layer should have scrolled down in its local coordinates, but half the |
| 5798 // amount. | 5804 // amount. |
| 5799 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5805 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5800 host_impl_->ProcessScrollDeltas(); | 5806 host_impl_->ProcessScrollDeltas(); |
| 5801 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5807 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
| 5802 gfx::Vector2d(0, scroll_delta.y() / scale))); | 5808 gfx::Vector2d(0, scroll_delta.y() / scale))); |
| 5803 | 5809 |
| 5804 // Reset and scroll down with the wheel. | 5810 // Reset and scroll down with the wheel. |
| 5805 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | 5811 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); |
| 5806 gfx::Vector2d wheel_scroll_delta(0, 10); | 5812 gfx::Vector2d wheel_scroll_delta(0, 10); |
| 5807 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5813 EXPECT_EQ( |
| 5808 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5814 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5809 InputHandler::WHEEL) | 5815 host_impl_ |
| 5810 .thread); | 5816 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 5817 .thread); |
| 5811 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); | 5818 host_impl_->ScrollBy(UpdateState(gfx::Point(), wheel_scroll_delta).get()); |
| 5812 host_impl_->ScrollEnd(EndState().get()); | 5819 host_impl_->ScrollEnd(EndState().get()); |
| 5813 | 5820 |
| 5814 // It should apply the scale factor to the scroll delta for the wheel event. | 5821 // It should apply the scale factor to the scroll delta for the wheel event. |
| 5815 scroll_info = host_impl_->ProcessScrollDeltas(); | 5822 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5816 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), | 5823 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), scroll_layer->id(), |
| 5817 wheel_scroll_delta)); | 5824 wheel_scroll_delta)); |
| 5818 } | 5825 } |
| 5819 | 5826 |
| 5820 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { | 5827 TEST_F(LayerTreeHostImplTest, ScrollViewportRounding) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5859 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); | 5866 DCHECK(total_scroll_offset.y() <= max_scroll_offset.y()); |
| 5860 last_set_scroll_offset_ = total_scroll_offset; | 5867 last_set_scroll_offset_ = total_scroll_offset; |
| 5861 max_scroll_offset_ = max_scroll_offset; | 5868 max_scroll_offset_ = max_scroll_offset; |
| 5862 scrollable_size_ = scrollable_size; | 5869 scrollable_size_ = scrollable_size; |
| 5863 page_scale_factor_ = page_scale_factor; | 5870 page_scale_factor_ = page_scale_factor; |
| 5864 min_page_scale_factor_ = min_page_scale_factor; | 5871 min_page_scale_factor_ = min_page_scale_factor; |
| 5865 max_page_scale_factor_ = max_page_scale_factor; | 5872 max_page_scale_factor_ = max_page_scale_factor; |
| 5866 } | 5873 } |
| 5867 void DeliverInputForBeginFrame() override {} | 5874 void DeliverInputForBeginFrame() override {} |
| 5868 | 5875 |
| 5869 gfx::ScrollOffset last_set_scroll_offset() { | 5876 gfx::ScrollOffset last_set_scroll_offset() { return last_set_scroll_offset_; } |
| 5870 return last_set_scroll_offset_; | |
| 5871 } | |
| 5872 | 5877 |
| 5873 gfx::ScrollOffset max_scroll_offset() const { | 5878 gfx::ScrollOffset max_scroll_offset() const { return max_scroll_offset_; } |
| 5874 return max_scroll_offset_; | |
| 5875 } | |
| 5876 | 5879 |
| 5877 gfx::SizeF scrollable_size() const { | 5880 gfx::SizeF scrollable_size() const { return scrollable_size_; } |
| 5878 return scrollable_size_; | |
| 5879 } | |
| 5880 | 5881 |
| 5881 float page_scale_factor() const { | 5882 float page_scale_factor() const { return page_scale_factor_; } |
| 5882 return page_scale_factor_; | |
| 5883 } | |
| 5884 | 5883 |
| 5885 float min_page_scale_factor() const { | 5884 float min_page_scale_factor() const { return min_page_scale_factor_; } |
| 5886 return min_page_scale_factor_; | |
| 5887 } | |
| 5888 | 5885 |
| 5889 float max_page_scale_factor() const { | 5886 float max_page_scale_factor() const { return max_page_scale_factor_; } |
| 5890 return max_page_scale_factor_; | |
| 5891 } | |
| 5892 | 5887 |
| 5893 private: | 5888 private: |
| 5894 gfx::ScrollOffset last_set_scroll_offset_; | 5889 gfx::ScrollOffset last_set_scroll_offset_; |
| 5895 gfx::ScrollOffset max_scroll_offset_; | 5890 gfx::ScrollOffset max_scroll_offset_; |
| 5896 gfx::SizeF scrollable_size_; | 5891 gfx::SizeF scrollable_size_; |
| 5897 float page_scale_factor_; | 5892 float page_scale_factor_; |
| 5898 float min_page_scale_factor_; | 5893 float min_page_scale_factor_; |
| 5899 float max_page_scale_factor_; | 5894 float max_page_scale_factor_; |
| 5900 }; | 5895 }; |
| 5901 | 5896 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6043 InputHandlerScrollResult scroll_result; | 6038 InputHandlerScrollResult scroll_result; |
| 6044 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 6039 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 6045 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6040 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6046 | 6041 |
| 6047 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6042 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6048 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6043 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 6049 DrawFrame(); | 6044 DrawFrame(); |
| 6050 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6045 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6051 | 6046 |
| 6052 // In-bounds scrolling does not affect overscroll. | 6047 // In-bounds scrolling does not affect overscroll. |
| 6053 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6048 EXPECT_EQ( |
| 6054 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6049 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6055 InputHandler::WHEEL) | 6050 host_impl_ |
| 6056 .thread); | 6051 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 6052 .thread); |
| 6057 scroll_result = host_impl_->ScrollBy( | 6053 scroll_result = host_impl_->ScrollBy( |
| 6058 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 6054 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 6059 EXPECT_TRUE(scroll_result.did_scroll); | 6055 EXPECT_TRUE(scroll_result.did_scroll); |
| 6060 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6056 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6061 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); | 6057 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
| 6062 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6058 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6063 | 6059 |
| 6064 // Overscroll events are reflected immediately. | 6060 // Overscroll events are reflected immediately. |
| 6065 scroll_result = host_impl_->ScrollBy( | 6061 scroll_result = host_impl_->ScrollBy( |
| 6066 UpdateState(gfx::Point(), gfx::Vector2d(0, 50)).get()); | 6062 UpdateState(gfx::Point(), gfx::Vector2d(0, 50)).get()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6205 grand_child_layer->layer_tree_impl() | 6201 grand_child_layer->layer_tree_impl() |
| 6206 ->property_trees() | 6202 ->property_trees() |
| 6207 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), | 6203 ->scroll_tree.UpdateScrollOffsetBaseForTesting(grand_child_layer->id(), |
| 6208 gfx::ScrollOffset(0, 2)); | 6204 gfx::ScrollOffset(0, 2)); |
| 6209 | 6205 |
| 6210 host_impl_->SetViewportSize(surface_size); | 6206 host_impl_->SetViewportSize(surface_size); |
| 6211 DrawFrame(); | 6207 DrawFrame(); |
| 6212 { | 6208 { |
| 6213 gfx::Vector2d scroll_delta(0, -10); | 6209 gfx::Vector2d scroll_delta(0, -10); |
| 6214 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6210 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6215 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6211 host_impl_ |
| 6216 InputHandler::NON_BUBBLING_GESTURE) | 6212 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 6213 InputHandler::NON_BUBBLING_GESTURE) |
| 6217 .thread); | 6214 .thread); |
| 6218 scroll_result = | 6215 scroll_result = |
| 6219 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6216 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6220 EXPECT_TRUE(scroll_result.did_scroll); | 6217 EXPECT_TRUE(scroll_result.did_scroll); |
| 6221 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6218 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6222 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6219 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6223 host_impl_->ScrollEnd(EndState().get()); | 6220 host_impl_->ScrollEnd(EndState().get()); |
| 6224 | 6221 |
| 6225 // The next time we scroll we should only scroll the parent, but overscroll | 6222 // The next time we scroll we should only scroll the parent, but overscroll |
| 6226 // should still not reach the root layer. | 6223 // should still not reach the root layer. |
| 6227 scroll_delta = gfx::Vector2d(0, -30); | 6224 scroll_delta = gfx::Vector2d(0, -30); |
| 6228 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6225 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6229 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6226 host_impl_ |
| 6230 InputHandler::NON_BUBBLING_GESTURE) | 6227 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6228 InputHandler::NON_BUBBLING_GESTURE) |
| 6231 .thread); | 6229 .thread); |
| 6232 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6230 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
| 6233 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6231 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6234 host_impl_->ScrollEnd(EndState().get()); | 6232 host_impl_->ScrollEnd(EndState().get()); |
| 6235 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6233 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6236 host_impl_ | 6234 host_impl_ |
| 6237 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6235 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6238 InputHandler::NON_BUBBLING_GESTURE) | 6236 InputHandler::NON_BUBBLING_GESTURE) |
| 6239 .thread); | 6237 .thread); |
| 6240 scroll_result = | 6238 scroll_result = |
| 6241 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6239 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6242 EXPECT_TRUE(scroll_result.did_scroll); | 6240 EXPECT_TRUE(scroll_result.did_scroll); |
| 6243 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6241 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6244 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id()); | 6242 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id()); |
| 6245 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6243 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6246 host_impl_->ScrollEnd(EndState().get()); | 6244 host_impl_->ScrollEnd(EndState().get()); |
| 6247 | 6245 |
| 6248 // After scrolling the parent, another scroll on the opposite direction | 6246 // After scrolling the parent, another scroll on the opposite direction |
| 6249 // should scroll the child. | 6247 // should scroll the child. |
| 6250 scroll_delta = gfx::Vector2d(0, 70); | 6248 scroll_delta = gfx::Vector2d(0, 70); |
| 6251 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6249 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6252 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6250 host_impl_ |
| 6253 InputHandler::NON_BUBBLING_GESTURE) | 6251 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6252 InputHandler::NON_BUBBLING_GESTURE) |
| 6254 .thread); | 6253 .thread); |
| 6255 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6254 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
| 6256 scroll_result = | 6255 scroll_result = |
| 6257 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6256 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6258 EXPECT_TRUE(scroll_result.did_scroll); | 6257 EXPECT_TRUE(scroll_result.did_scroll); |
| 6259 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6258 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6260 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6259 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
| 6261 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6260 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6262 host_impl_->ScrollEnd(EndState().get()); | 6261 host_impl_->ScrollEnd(EndState().get()); |
| 6263 } | 6262 } |
| 6264 } | 6263 } |
| 6265 | 6264 |
| 6266 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 6265 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 6267 // When we try to scroll a non-scrollable child layer, the scroll delta | 6266 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 6268 // should be applied to one of its ancestors if possible. Overscroll should | 6267 // should be applied to one of its ancestors if possible. Overscroll should |
| 6269 // be reflected only when it has bubbled up to the root scrolling layer. | 6268 // be reflected only when it has bubbled up to the root scrolling layer. |
| 6270 InputHandlerScrollResult scroll_result; | 6269 InputHandlerScrollResult scroll_result; |
| 6271 SetupScrollAndContentsLayers(gfx::Size(20, 20)); | 6270 SetupScrollAndContentsLayers(gfx::Size(20, 20)); |
| 6272 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6271 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6273 | 6272 |
| 6274 DrawFrame(); | 6273 DrawFrame(); |
| 6275 { | 6274 { |
| 6276 gfx::Vector2d scroll_delta(0, 8); | 6275 gfx::Vector2d scroll_delta(0, 8); |
| 6277 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6276 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6278 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6277 host_impl_ |
| 6279 InputHandler::WHEEL) | 6278 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6279 InputHandler::WHEEL) |
| 6280 .thread); | 6280 .thread); |
| 6281 scroll_result = | 6281 scroll_result = |
| 6282 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6282 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6283 EXPECT_TRUE(scroll_result.did_scroll); | 6283 EXPECT_TRUE(scroll_result.did_scroll); |
| 6284 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6284 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6285 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6285 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6286 scroll_result = | 6286 scroll_result = |
| 6287 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6287 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6288 EXPECT_TRUE(scroll_result.did_scroll); | 6288 EXPECT_TRUE(scroll_result.did_scroll); |
| 6289 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6289 EXPECT_TRUE(scroll_result.did_overscroll_root); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6308 | 6308 |
| 6309 clip_layer->SetBounds(gfx::Size(50, 50)); | 6309 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 6310 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6310 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6311 | 6311 |
| 6312 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6312 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6313 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6313 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 6314 DrawFrame(); | 6314 DrawFrame(); |
| 6315 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6315 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6316 | 6316 |
| 6317 // Even though the layer can't scroll the overscroll still happens. | 6317 // Even though the layer can't scroll the overscroll still happens. |
| 6318 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6318 EXPECT_EQ( |
| 6319 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 6319 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6320 InputHandler::WHEEL) | 6320 host_impl_ |
| 6321 .thread); | 6321 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 6322 .thread); |
| 6322 scroll_result = host_impl_->ScrollBy( | 6323 scroll_result = host_impl_->ScrollBy( |
| 6323 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); | 6324 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); |
| 6324 EXPECT_FALSE(scroll_result.did_scroll); | 6325 EXPECT_FALSE(scroll_result.did_scroll); |
| 6325 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6326 EXPECT_TRUE(scroll_result.did_overscroll_root); |
| 6326 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 6327 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 6327 } | 6328 } |
| 6328 | 6329 |
| 6329 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 6330 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 6330 InputHandlerScrollResult scroll_result; | 6331 InputHandlerScrollResult scroll_result; |
| 6331 gfx::Size viewport_size(100, 100); | 6332 gfx::Size viewport_size(100, 100); |
| 6332 gfx::Size content_size(200, 200); | 6333 gfx::Size content_size(200, 200); |
| 6333 LayerImpl* root_scroll_layer = | 6334 LayerImpl* root_scroll_layer = |
| 6334 CreateBasicVirtualViewportLayers(viewport_size, viewport_size); | 6335 CreateBasicVirtualViewportLayers(viewport_size, viewport_size); |
| 6335 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 6336 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
| 6336 content_size); | 6337 content_size); |
| 6337 root_scroll_layer->SetBounds(content_size); | 6338 root_scroll_layer->SetBounds(content_size); |
| 6338 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 6339 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 6339 | 6340 |
| 6340 DrawFrame(); | 6341 DrawFrame(); |
| 6341 { | 6342 { |
| 6342 // Edge glow effect should be applicable only upon reaching Edges | 6343 // Edge glow effect should be applicable only upon reaching Edges |
| 6343 // of the content. unnecessary glow effect calls shouldn't be | 6344 // of the content. unnecessary glow effect calls shouldn't be |
| 6344 // called while scrolling up without reaching the edge of the content. | 6345 // called while scrolling up without reaching the edge of the content. |
| 6345 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6346 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6346 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6347 host_impl_ |
| 6347 InputHandler::WHEEL) | 6348 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 6349 InputHandler::WHEEL) |
| 6348 .thread); | 6350 .thread); |
| 6349 scroll_result = host_impl_->ScrollBy( | 6351 scroll_result = host_impl_->ScrollBy( |
| 6350 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); | 6352 UpdateState(gfx::Point(), gfx::Vector2dF(0, 100)).get()); |
| 6351 EXPECT_TRUE(scroll_result.did_scroll); | 6353 EXPECT_TRUE(scroll_result.did_scroll); |
| 6352 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6354 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6353 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6355 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 6354 host_impl_->accumulated_root_overscroll().ToString()); | 6356 host_impl_->accumulated_root_overscroll().ToString()); |
| 6355 scroll_result = host_impl_->ScrollBy( | 6357 scroll_result = host_impl_->ScrollBy( |
| 6356 UpdateState(gfx::Point(), gfx::Vector2dF(0, -2.30f)).get()); | 6358 UpdateState(gfx::Point(), gfx::Vector2dF(0, -2.30f)).get()); |
| 6357 EXPECT_TRUE(scroll_result.did_scroll); | 6359 EXPECT_TRUE(scroll_result.did_scroll); |
| 6358 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6360 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6359 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6361 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 6360 host_impl_->accumulated_root_overscroll().ToString()); | 6362 host_impl_->accumulated_root_overscroll().ToString()); |
| 6361 host_impl_->ScrollEnd(EndState().get()); | 6363 host_impl_->ScrollEnd(EndState().get()); |
| 6362 // unusedrootDelta should be subtracted from applied delta so that | 6364 // unusedrootDelta should be subtracted from applied delta so that |
| 6363 // unwanted glow effect calls are not called. | 6365 // unwanted glow effect calls are not called. |
| 6364 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6366 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6365 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6367 host_impl_ |
| 6366 InputHandler::NON_BUBBLING_GESTURE) | 6368 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 6369 InputHandler::NON_BUBBLING_GESTURE) |
| 6367 .thread); | 6370 .thread); |
| 6368 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6371 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6369 host_impl_->FlingScrollBegin().thread); | 6372 host_impl_->FlingScrollBegin().thread); |
| 6370 scroll_result = host_impl_->ScrollBy( | 6373 scroll_result = host_impl_->ScrollBy( |
| 6371 UpdateState(gfx::Point(), gfx::Vector2dF(0, 20)).get()); | 6374 UpdateState(gfx::Point(), gfx::Vector2dF(0, 20)).get()); |
| 6372 EXPECT_TRUE(scroll_result.did_scroll); | 6375 EXPECT_TRUE(scroll_result.did_scroll); |
| 6373 EXPECT_TRUE(scroll_result.did_overscroll_root); | 6376 EXPECT_TRUE(scroll_result.did_overscroll_root); |
| 6374 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), | 6377 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), |
| 6375 host_impl_->accumulated_root_overscroll()); | 6378 host_impl_->accumulated_root_overscroll()); |
| 6376 | 6379 |
| 6377 scroll_result = host_impl_->ScrollBy( | 6380 scroll_result = host_impl_->ScrollBy( |
| 6378 UpdateState(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)).get()); | 6381 UpdateState(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)).get()); |
| 6379 EXPECT_FALSE(scroll_result.did_scroll); | 6382 EXPECT_FALSE(scroll_result.did_scroll); |
| 6380 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6383 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6381 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), | 6384 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(0.000000f, 17.699997f), |
| 6382 host_impl_->accumulated_root_overscroll()); | 6385 host_impl_->accumulated_root_overscroll()); |
| 6383 host_impl_->ScrollEnd(EndState().get()); | 6386 host_impl_->ScrollEnd(EndState().get()); |
| 6384 // TestCase to check kEpsilon, which prevents minute values to trigger | 6387 // TestCase to check kEpsilon, which prevents minute values to trigger |
| 6385 // gloweffect without reaching edge. | 6388 // gloweffect without reaching edge. |
| 6386 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6389 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6387 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), | 6390 host_impl_ |
| 6388 InputHandler::WHEEL) | 6391 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), |
| 6392 InputHandler::WHEEL) |
| 6389 .thread); | 6393 .thread); |
| 6390 scroll_result = host_impl_->ScrollBy( | 6394 scroll_result = host_impl_->ScrollBy( |
| 6391 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); | 6395 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); |
| 6392 EXPECT_FALSE(scroll_result.did_scroll); | 6396 EXPECT_FALSE(scroll_result.did_scroll); |
| 6393 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6397 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6394 EXPECT_EQ(gfx::Vector2dF().ToString(), | 6398 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 6395 host_impl_->accumulated_root_overscroll().ToString()); | 6399 host_impl_->accumulated_root_overscroll().ToString()); |
| 6396 host_impl_->ScrollEnd(EndState().get()); | 6400 host_impl_->ScrollEnd(EndState().get()); |
| 6397 } | 6401 } |
| 6398 } | 6402 } |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6891 else | 6895 else |
| 6892 opaque_rect = opaque_content_rect_; | 6896 opaque_rect = opaque_content_rect_; |
| 6893 gfx::Rect visible_quad_rect = quad_rect_; | 6897 gfx::Rect visible_quad_rect = quad_rect_; |
| 6894 | 6898 |
| 6895 SharedQuadState* shared_quad_state = | 6899 SharedQuadState* shared_quad_state = |
| 6896 render_pass->CreateAndAppendSharedQuadState(); | 6900 render_pass->CreateAndAppendSharedQuadState(); |
| 6897 PopulateSharedQuadState(shared_quad_state); | 6901 PopulateSharedQuadState(shared_quad_state); |
| 6898 | 6902 |
| 6899 TileDrawQuad* test_blending_draw_quad = | 6903 TileDrawQuad* test_blending_draw_quad = |
| 6900 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 6904 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 6901 test_blending_draw_quad->SetNew(shared_quad_state, | 6905 test_blending_draw_quad->SetNew(shared_quad_state, quad_rect_, opaque_rect, |
| 6902 quad_rect_, | 6906 visible_quad_rect, resource_id_, |
| 6903 opaque_rect, | |
| 6904 visible_quad_rect, | |
| 6905 resource_id_, | |
| 6906 gfx::RectF(0.f, 0.f, 1.f, 1.f), | 6907 gfx::RectF(0.f, 0.f, 1.f, 1.f), |
| 6907 gfx::Size(1, 1), | 6908 gfx::Size(1, 1), false, false); |
| 6908 false, | |
| 6909 false); | |
| 6910 test_blending_draw_quad->visible_rect = quad_visible_rect_; | 6909 test_blending_draw_quad->visible_rect = quad_visible_rect_; |
| 6911 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); | 6910 EXPECT_EQ(blend_, test_blending_draw_quad->ShouldDrawWithBlending()); |
| 6912 EXPECT_EQ(has_render_surface_, !!render_surface()); | 6911 EXPECT_EQ(has_render_surface_, !!render_surface()); |
| 6913 } | 6912 } |
| 6914 | 6913 |
| 6915 void SetExpectation(bool blend, bool has_render_surface) { | 6914 void SetExpectation(bool blend, bool has_render_surface) { |
| 6916 blend_ = blend; | 6915 blend_ = blend; |
| 6917 has_render_surface_ = has_render_surface; | 6916 has_render_surface_ = has_render_surface; |
| 6918 quads_appended_ = false; | 6917 quads_appended_ = false; |
| 6919 } | 6918 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7247 video_layer->SetPosition(gfx::PointF(100.f, 100.f)); | 7246 video_layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 7248 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); | 7247 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 7249 | 7248 |
| 7250 video_layer->SetPosition(gfx::PointF(0.f, 0.f)); | 7249 video_layer->SetPosition(gfx::PointF(0.f, 0.f)); |
| 7251 video_layer->NoteLayerPropertyChanged(); | 7250 video_layer->NoteLayerPropertyChanged(); |
| 7252 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); | 7251 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get())); |
| 7253 } | 7252 } |
| 7254 | 7253 |
| 7255 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { | 7254 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { |
| 7256 protected: | 7255 protected: |
| 7257 LayerTreeHostImplViewportCoveredTest() : | 7256 LayerTreeHostImplViewportCoveredTest() |
| 7258 gutter_quad_material_(DrawQuad::SOLID_COLOR), | 7257 : gutter_quad_material_(DrawQuad::SOLID_COLOR), |
| 7259 child_(NULL), | 7258 child_(NULL), |
| 7260 did_activate_pending_tree_(false) {} | 7259 did_activate_pending_tree_(false) {} |
| 7261 | 7260 |
| 7262 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink( | 7261 std::unique_ptr<CompositorFrameSink> CreateFakeCompositorFrameSink( |
| 7263 bool software) { | 7262 bool software) { |
| 7264 if (software) | 7263 if (software) |
| 7265 return FakeCompositorFrameSink::CreateSoftware(); | 7264 return FakeCompositorFrameSink::CreateSoftware(); |
| 7266 return FakeCompositorFrameSink::Create3d(); | 7265 return FakeCompositorFrameSink::Create3d(); |
| 7267 } | 7266 } |
| 7268 | 7267 |
| 7269 void SetupActiveTreeLayers() { | 7268 void SetupActiveTreeLayers() { |
| 7270 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); | 7269 host_impl_->active_tree()->set_background_color(SK_ColorGRAY); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7541 host_impl_->CreatePendingTree(); | 7540 host_impl_->CreatePendingTree(); |
| 7542 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); | 7541 host_impl_->SetViewportSize(DipSizeToPixelSize(viewport_size_)); |
| 7543 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); | 7542 EXPECT_TRUE(host_impl_->active_tree()->ViewportSizeInvalid()); |
| 7544 | 7543 |
| 7545 SetupActiveTreeLayers(); | 7544 SetupActiveTreeLayers(); |
| 7546 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); | 7545 EXPECT_SCOPED(TestEmptyLayerWithOnDraw()); |
| 7547 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); | 7546 EXPECT_SCOPED(TestLayerInMiddleOfViewportWithOnDraw()); |
| 7548 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); | 7547 EXPECT_SCOPED(TestLayerIsLargerThanViewportWithOnDraw()); |
| 7549 } | 7548 } |
| 7550 | 7549 |
| 7551 class FakeDrawableLayerImpl: public LayerImpl { | 7550 class FakeDrawableLayerImpl : public LayerImpl { |
| 7552 public: | 7551 public: |
| 7553 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { | 7552 static std::unique_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, int id) { |
| 7554 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); | 7553 return base::WrapUnique(new FakeDrawableLayerImpl(tree_impl, id)); |
| 7555 } | 7554 } |
| 7555 |
| 7556 protected: | 7556 protected: |
| 7557 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) | 7557 FakeDrawableLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 7558 : LayerImpl(tree_impl, id) {} | 7558 : LayerImpl(tree_impl, id) {} |
| 7559 }; | 7559 }; |
| 7560 | 7560 |
| 7561 // Make sure damage tracking propagates all the way to the graphics context, | 7561 // Make sure damage tracking propagates all the way to the graphics context, |
| 7562 // where it should request to swap only the sub-buffer that is damaged. | 7562 // where it should request to swap only the sub-buffer that is damaged. |
| 7563 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { | 7563 TEST_F(LayerTreeHostImplTest, PartialSwapReceivesDamageRect) { |
| 7564 scoped_refptr<TestContextProvider> context_provider( | 7564 scoped_refptr<TestContextProvider> context_provider( |
| 7565 TestContextProvider::Create()); | 7565 TestContextProvider::Create()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7576 LayerTreeSettings settings = DefaultSettings(); | 7576 LayerTreeSettings settings = DefaultSettings(); |
| 7577 settings.renderer_settings.partial_swap_enabled = true; | 7577 settings.renderer_settings.partial_swap_enabled = true; |
| 7578 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = | 7578 std::unique_ptr<LayerTreeHostImpl> layer_tree_host_impl = |
| 7579 LayerTreeHostImpl::Create( | 7579 LayerTreeHostImpl::Create( |
| 7580 settings, this, &task_runner_provider_, &stats_instrumentation_, | 7580 settings, this, &task_runner_provider_, &stats_instrumentation_, |
| 7581 &task_graph_runner_, | 7581 &task_graph_runner_, |
| 7582 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); | 7582 AnimationHost::CreateForTesting(ThreadInstance::IMPL), 0); |
| 7583 layer_tree_host_impl->SetVisible(true); | 7583 layer_tree_host_impl->SetVisible(true); |
| 7584 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); | 7584 layer_tree_host_impl->InitializeRenderer(compositor_frame_sink.get()); |
| 7585 layer_tree_host_impl->WillBeginImplFrame( | 7585 layer_tree_host_impl->WillBeginImplFrame( |
| 7586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
| 7587 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); | 7587 layer_tree_host_impl->SetViewportSize(gfx::Size(500, 500)); |
| 7588 | 7588 |
| 7589 std::unique_ptr<LayerImpl> root = | 7589 std::unique_ptr<LayerImpl> root = |
| 7590 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); | 7590 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 1); |
| 7591 root->test_properties()->force_render_surface = true; | 7591 root->test_properties()->force_render_surface = true; |
| 7592 std::unique_ptr<LayerImpl> child = | 7592 std::unique_ptr<LayerImpl> child = |
| 7593 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); | 7593 FakeDrawableLayerImpl::Create(layer_tree_host_impl->active_tree(), 2); |
| 7594 child->SetPosition(gfx::PointF(12.f, 13.f)); | 7594 child->SetPosition(gfx::PointF(12.f, 13.f)); |
| 7595 child->SetBounds(gfx::Size(14, 15)); | 7595 child->SetBounds(gfx::Size(14, 15)); |
| 7596 child->SetDrawsContent(true); | 7596 child->SetDrawsContent(true); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7680 AppendQuadsData* append_quads_data) override { | 7680 AppendQuadsData* append_quads_data) override { |
| 7681 SharedQuadState* shared_quad_state = | 7681 SharedQuadState* shared_quad_state = |
| 7682 render_pass->CreateAndAppendSharedQuadState(); | 7682 render_pass->CreateAndAppendSharedQuadState(); |
| 7683 PopulateSharedQuadState(shared_quad_state); | 7683 PopulateSharedQuadState(shared_quad_state); |
| 7684 | 7684 |
| 7685 SkColor gray = SkColorSetRGB(100, 100, 100); | 7685 SkColor gray = SkColorSetRGB(100, 100, 100); |
| 7686 gfx::Rect quad_rect(bounds()); | 7686 gfx::Rect quad_rect(bounds()); |
| 7687 gfx::Rect visible_quad_rect(quad_rect); | 7687 gfx::Rect visible_quad_rect(quad_rect); |
| 7688 SolidColorDrawQuad* my_quad = | 7688 SolidColorDrawQuad* my_quad = |
| 7689 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 7689 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 7690 my_quad->SetNew( | 7690 my_quad->SetNew(shared_quad_state, quad_rect, visible_quad_rect, gray, |
| 7691 shared_quad_state, quad_rect, visible_quad_rect, gray, false); | 7691 false); |
| 7692 } | 7692 } |
| 7693 | 7693 |
| 7694 private: | 7694 private: |
| 7695 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) | 7695 FakeLayerWithQuads(LayerTreeImpl* tree_impl, int id) |
| 7696 : LayerImpl(tree_impl, id) {} | 7696 : LayerImpl(tree_impl, id) {} |
| 7697 }; | 7697 }; |
| 7698 | 7698 |
| 7699 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( | 7699 static std::unique_ptr<LayerTreeHostImpl> SetupLayersForOpacity( |
| 7700 LayerTreeSettings settings, | 7700 LayerTreeSettings settings, |
| 7701 bool partial_swap, | 7701 bool partial_swap, |
| 7702 LayerTreeHostImplClient* client, | 7702 LayerTreeHostImplClient* client, |
| 7703 TaskRunnerProvider* task_runner_provider, | 7703 TaskRunnerProvider* task_runner_provider, |
| 7704 TaskGraphRunner* task_graph_runner, | 7704 TaskGraphRunner* task_graph_runner, |
| 7705 RenderingStatsInstrumentation* stats_instrumentation, | 7705 RenderingStatsInstrumentation* stats_instrumentation, |
| 7706 CompositorFrameSink* compositor_frame_sink) { | 7706 CompositorFrameSink* compositor_frame_sink) { |
| 7707 settings.renderer_settings.partial_swap_enabled = partial_swap; | 7707 settings.renderer_settings.partial_swap_enabled = partial_swap; |
| 7708 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( | 7708 std::unique_ptr<LayerTreeHostImpl> my_host_impl = LayerTreeHostImpl::Create( |
| 7709 settings, client, task_runner_provider, stats_instrumentation, | 7709 settings, client, task_runner_provider, stats_instrumentation, |
| 7710 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), | 7710 task_graph_runner, AnimationHost::CreateForTesting(ThreadInstance::IMPL), |
| 7711 0); | 7711 0); |
| 7712 my_host_impl->SetVisible(true); | 7712 my_host_impl->SetVisible(true); |
| 7713 my_host_impl->InitializeRenderer(compositor_frame_sink); | 7713 my_host_impl->InitializeRenderer(compositor_frame_sink); |
| 7714 my_host_impl->WillBeginImplFrame( | 7714 my_host_impl->WillBeginImplFrame( |
| 7715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); | 7715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2)); |
| 7716 my_host_impl->SetViewportSize(gfx::Size(100, 100)); | 7716 my_host_impl->SetViewportSize(gfx::Size(100, 100)); |
| 7717 | 7717 |
| 7718 /* | 7718 /* |
| 7719 Layers are created as follows: | 7719 Layers are created as follows: |
| 7720 | 7720 |
| 7721 +--------------------+ | 7721 +--------------------+ |
| 7722 | 1 | | 7722 | 1 | |
| 7723 | +-----------+ | | 7723 | +-----------+ | |
| 7724 | | 2 | | | 7724 | | 2 | | |
| 7725 | | +-------------------+ | 7725 | | +-------------------+ |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7834 TestWebGraphicsContext3D* context3d = context.get(); | 7834 TestWebGraphicsContext3D* context3d = context.get(); |
| 7835 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( | 7835 std::unique_ptr<CompositorFrameSink> compositor_frame_sink( |
| 7836 FakeCompositorFrameSink::Create3d(std::move(context))); | 7836 FakeCompositorFrameSink::Create3d(std::move(context))); |
| 7837 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); | 7837 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
| 7838 | 7838 |
| 7839 std::unique_ptr<LayerImpl> root_layer = | 7839 std::unique_ptr<LayerImpl> root_layer = |
| 7840 LayerImpl::Create(host_impl_->active_tree(), 1); | 7840 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 7841 root_layer->SetBounds(gfx::Size(10, 10)); | 7841 root_layer->SetBounds(gfx::Size(10, 10)); |
| 7842 root_layer->test_properties()->force_render_surface = true; | 7842 root_layer->test_properties()->force_render_surface = true; |
| 7843 | 7843 |
| 7844 scoped_refptr<VideoFrame> softwareFrame = | 7844 scoped_refptr<VideoFrame> softwareFrame = media::VideoFrame::CreateColorFrame( |
| 7845 media::VideoFrame::CreateColorFrame( | 7845 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); |
| 7846 gfx::Size(4, 4), 0x80, 0x80, 0x80, base::TimeDelta()); | |
| 7847 FakeVideoFrameProvider provider; | 7846 FakeVideoFrameProvider provider; |
| 7848 provider.set_frame(softwareFrame); | 7847 provider.set_frame(softwareFrame); |
| 7849 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( | 7848 std::unique_ptr<VideoLayerImpl> video_layer = VideoLayerImpl::Create( |
| 7850 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); | 7849 host_impl_->active_tree(), 4, &provider, media::VIDEO_ROTATION_0); |
| 7851 video_layer->SetBounds(gfx::Size(10, 10)); | 7850 video_layer->SetBounds(gfx::Size(10, 10)); |
| 7852 video_layer->SetDrawsContent(true); | 7851 video_layer->SetDrawsContent(true); |
| 7853 root_layer->test_properties()->AddChild(std::move(video_layer)); | 7852 root_layer->test_properties()->AddChild(std::move(video_layer)); |
| 7854 | 7853 |
| 7855 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); | 7854 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root_layer)); |
| 7856 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7855 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7857 | 7856 |
| 7858 EXPECT_EQ(0u, context3d->NumTextures()); | 7857 EXPECT_EQ(0u, context3d->NumTextures()); |
| 7859 | 7858 |
| 7860 LayerTreeHostImpl::FrameData frame; | 7859 LayerTreeHostImpl::FrameData frame; |
| 7861 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 7860 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 7862 host_impl_->DrawLayers(&frame); | 7861 host_impl_->DrawLayers(&frame); |
| 7863 host_impl_->DidDrawAllLayers(frame); | 7862 host_impl_->DidDrawAllLayers(frame); |
| 7864 | 7863 |
| 7865 EXPECT_GT(context3d->NumTextures(), 0u); | 7864 EXPECT_GT(context3d->NumTextures(), 0u); |
| 7866 | 7865 |
| 7867 // Kill the layer tree. | 7866 // Kill the layer tree. |
| 7868 host_impl_->active_tree()->DetachLayers(); | 7867 host_impl_->active_tree()->DetachLayers(); |
| 7869 // There should be no textures left in use after. | 7868 // There should be no textures left in use after. |
| 7870 EXPECT_EQ(0u, context3d->NumTextures()); | 7869 EXPECT_EQ(0u, context3d->NumTextures()); |
| 7871 } | 7870 } |
| 7872 | 7871 |
| 7873 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { | 7872 class MockDrawQuadsToFillScreenContext : public TestWebGraphicsContext3D { |
| 7874 public: | 7873 public: |
| 7875 MOCK_METHOD1(useProgram, void(GLuint program)); | 7874 MOCK_METHOD1(useProgram, void(GLuint program)); |
| 7876 MOCK_METHOD4(drawElements, void(GLenum mode, | 7875 MOCK_METHOD4(drawElements, |
| 7877 GLsizei count, | 7876 void(GLenum mode, GLsizei count, GLenum type, GLintptr offset)); |
| 7878 GLenum type, | |
| 7879 GLintptr offset)); | |
| 7880 }; | 7877 }; |
| 7881 | 7878 |
| 7882 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { | 7879 TEST_F(LayerTreeHostImplTest, HasTransparentBackground) { |
| 7883 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 7880 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 7884 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 7881 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 7885 | 7882 |
| 7886 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); | 7883 host_impl_->active_tree()->set_background_color(SK_ColorWHITE); |
| 7887 | 7884 |
| 7888 // Verify one quad is drawn when transparent background set is not set. | 7885 // Verify one quad is drawn when transparent background set is not set. |
| 7889 host_impl_->active_tree()->set_has_transparent_background(false); | 7886 host_impl_->active_tree()->set_has_transparent_background(false); |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8605 | 8602 |
| 8606 root_scroll->test_properties()->AddChild(std::move(child)); | 8603 root_scroll->test_properties()->AddChild(std::move(child)); |
| 8607 root_clip->test_properties()->AddChild(std::move(root_scroll)); | 8604 root_clip->test_properties()->AddChild(std::move(root_scroll)); |
| 8608 | 8605 |
| 8609 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8606 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8610 host_impl_->active_tree()->DidBecomeActive(); | 8607 host_impl_->active_tree()->DidBecomeActive(); |
| 8611 | 8608 |
| 8612 host_impl_->SetViewportSize(surface_size); | 8609 host_impl_->SetViewportSize(surface_size); |
| 8613 DrawFrame(); | 8610 DrawFrame(); |
| 8614 { | 8611 { |
| 8615 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8612 EXPECT_EQ( |
| 8616 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8613 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8617 InputHandler::WHEEL) | 8614 host_impl_ |
| 8618 .thread); | 8615 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 8616 .thread); |
| 8619 | 8617 |
| 8620 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8618 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8621 host_impl_->FlingScrollBegin().thread); | 8619 host_impl_->FlingScrollBegin().thread); |
| 8622 | 8620 |
| 8623 gfx::Vector2d scroll_delta(0, 100); | 8621 gfx::Vector2d scroll_delta(0, 100); |
| 8624 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8622 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 8625 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 8623 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 8626 | 8624 |
| 8627 host_impl_->ScrollEnd(EndState().get()); | 8625 host_impl_->ScrollEnd(EndState().get()); |
| 8628 | 8626 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8728 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 8726 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
| 8729 child_scroll->SetDrawsContent(false); | 8727 child_scroll->SetDrawsContent(false); |
| 8730 | 8728 |
| 8731 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); | 8729 scroll_layer->test_properties()->AddChild(std::move(child_scroll)); |
| 8732 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8730 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8733 | 8731 |
| 8734 DrawFrame(); | 8732 DrawFrame(); |
| 8735 | 8733 |
| 8736 // We should have scrolled |child_scroll| even though it does not move | 8734 // We should have scrolled |child_scroll| even though it does not move |
| 8737 // any layer that is a drawn RSLL member. | 8735 // any layer that is a drawn RSLL member. |
| 8738 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8736 EXPECT_EQ( |
| 8739 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 8737 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8740 InputHandler::WHEEL) | 8738 host_impl_ |
| 8741 .thread); | 8739 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 8740 .thread); |
| 8742 | 8741 |
| 8743 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8742 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
| 8744 } | 8743 } |
| 8745 | 8744 |
| 8746 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8745 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 8747 // in CompositorFrameMetadata. | 8746 // in CompositorFrameMetadata. |
| 8748 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8747 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 8749 std::unique_ptr<SolidColorLayerImpl> root = | 8748 std::unique_ptr<SolidColorLayerImpl> root = |
| 8750 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8749 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 8751 root->SetPosition(gfx::PointF()); | 8750 root->SetPosition(gfx::PointF()); |
| 8752 root->SetBounds(gfx::Size(10, 10)); | 8751 root->SetBounds(gfx::Size(10, 10)); |
| 8753 root->SetDrawsContent(true); | 8752 root->SetDrawsContent(true); |
| 8754 root->test_properties()->force_render_surface = true; | 8753 root->test_properties()->force_render_surface = true; |
| 8755 | 8754 |
| 8756 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); | 8755 host_impl_->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 8757 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8756 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 8758 | 8757 |
| 8759 FakeCompositorFrameSink* fake_compositor_frame_sink = | 8758 FakeCompositorFrameSink* fake_compositor_frame_sink = |
| 8760 static_cast<FakeCompositorFrameSink*>( | 8759 static_cast<FakeCompositorFrameSink*>( |
| 8761 host_impl_->compositor_frame_sink()); | 8760 host_impl_->compositor_frame_sink()); |
| 8762 | 8761 |
| 8763 ui::LatencyInfo latency_info; | 8762 ui::LatencyInfo latency_info; |
| 8764 latency_info.AddLatencyNumber( | 8763 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, |
| 8765 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 0, 0); | 8764 0); |
| 8766 std::unique_ptr<SwapPromise> swap_promise( | 8765 std::unique_ptr<SwapPromise> swap_promise( |
| 8767 new LatencyInfoSwapPromise(latency_info)); | 8766 new LatencyInfoSwapPromise(latency_info)); |
| 8768 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); | 8767 host_impl_->active_tree()->QueuePinnedSwapPromise(std::move(swap_promise)); |
| 8769 | 8768 |
| 8770 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); | 8769 gfx::Rect full_frame_damage(host_impl_->DrawViewportSize()); |
| 8771 LayerTreeHostImpl::FrameData frame; | 8770 LayerTreeHostImpl::FrameData frame; |
| 8772 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 8771 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 8773 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); | 8772 EXPECT_TRUE(host_impl_->DrawLayers(&frame)); |
| 8774 host_impl_->DidDrawAllLayers(frame); | 8773 host_impl_->DidDrawAllLayers(frame); |
| 8775 | 8774 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8918 &set_needs_redraw_count, &forward_to_main_count)); | 8917 &set_needs_redraw_count, &forward_to_main_count)); |
| 8919 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8918 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8920 | 8919 |
| 8921 // Scrolling normally should not trigger any forwarding. | 8920 // Scrolling normally should not trigger any forwarding. |
| 8922 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8921 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8923 host_impl_ | 8922 host_impl_ |
| 8924 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8923 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8925 InputHandler::TOUCHSCREEN) | 8924 InputHandler::TOUCHSCREEN) |
| 8926 .thread); | 8925 .thread); |
| 8927 EXPECT_TRUE( | 8926 EXPECT_TRUE( |
| 8928 host_impl_->ScrollBy( | 8927 host_impl_ |
| 8929 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8928 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
| 8930 .did_scroll); | 8929 .did_scroll); |
| 8931 host_impl_->ScrollEnd(EndState().get()); | 8930 host_impl_->ScrollEnd(EndState().get()); |
| 8932 | 8931 |
| 8933 EXPECT_EQ(0, set_needs_commit_count); | 8932 EXPECT_EQ(0, set_needs_commit_count); |
| 8934 EXPECT_EQ(1, set_needs_redraw_count); | 8933 EXPECT_EQ(1, set_needs_redraw_count); |
| 8935 EXPECT_EQ(0, forward_to_main_count); | 8934 EXPECT_EQ(0, forward_to_main_count); |
| 8936 | 8935 |
| 8937 // Scrolling with a scroll handler should defer the swap to the main | 8936 // Scrolling with a scroll handler should defer the swap to the main |
| 8938 // thread. | 8937 // thread. |
| 8939 host_impl_->active_tree()->set_have_scroll_event_handlers(true); | 8938 host_impl_->active_tree()->set_have_scroll_event_handlers(true); |
| 8940 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8939 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8941 host_impl_ | 8940 host_impl_ |
| 8942 ->ScrollBegin(BeginState(gfx::Point()).get(), | 8941 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 8943 InputHandler::TOUCHSCREEN) | 8942 InputHandler::TOUCHSCREEN) |
| 8944 .thread); | 8943 .thread); |
| 8945 EXPECT_TRUE( | 8944 EXPECT_TRUE( |
| 8946 host_impl_->ScrollBy( | 8945 host_impl_ |
| 8947 UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) | 8946 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()) |
| 8948 .did_scroll); | 8947 .did_scroll); |
| 8949 host_impl_->ScrollEnd(EndState().get()); | 8948 host_impl_->ScrollEnd(EndState().get()); |
| 8950 | 8949 |
| 8951 EXPECT_EQ(0, set_needs_commit_count); | 8950 EXPECT_EQ(0, set_needs_commit_count); |
| 8952 EXPECT_EQ(2, set_needs_redraw_count); | 8951 EXPECT_EQ(2, set_needs_redraw_count); |
| 8953 EXPECT_EQ(1, forward_to_main_count); | 8952 EXPECT_EQ(1, forward_to_main_count); |
| 8954 } | 8953 } |
| 8955 } | 8954 } |
| 8956 | 8955 |
| 8957 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest { | 8956 class LayerTreeHostImplWithBrowserControlsTest : public LayerTreeHostImplTest { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 8970 | 8969 |
| 8971 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; | 8970 const int LayerTreeHostImplWithBrowserControlsTest::top_controls_height_ = 50; |
| 8972 | 8971 |
| 8973 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { | 8972 TEST_F(LayerTreeHostImplWithBrowserControlsTest, NoIdleAnimations) { |
| 8974 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8973 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8975 scroll_layer->layer_tree_impl() | 8974 scroll_layer->layer_tree_impl() |
| 8976 ->property_trees() | 8975 ->property_trees() |
| 8977 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 8976 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| 8978 gfx::ScrollOffset(0, 10)); | 8977 gfx::ScrollOffset(0, 10)); |
| 8979 BeginFrameArgs begin_frame_args = | 8978 BeginFrameArgs begin_frame_args = |
| 8980 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 8979 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
| 8981 host_impl_->WillBeginImplFrame(begin_frame_args); | 8980 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 8982 host_impl_->Animate(); | 8981 host_impl_->Animate(); |
| 8983 EXPECT_FALSE(did_request_redraw_); | 8982 EXPECT_FALSE(did_request_redraw_); |
| 8984 host_impl_->DidFinishImplFrame(); | 8983 host_impl_->DidFinishImplFrame(); |
| 8985 } | 8984 } |
| 8986 | 8985 |
| 8987 TEST_F(LayerTreeHostImplWithBrowserControlsTest, | 8986 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 8988 BrowserControlsHeightIsCommitted) { | 8987 BrowserControlsHeightIsCommitted) { |
| 8989 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 8988 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 8990 EXPECT_FALSE(did_request_redraw_); | 8989 EXPECT_FALSE(did_request_redraw_); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9103 WheelUnhandledByBrowserControls) { | 9102 WheelUnhandledByBrowserControls) { |
| 9104 SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9103 SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 9105 host_impl_->SetViewportSize(gfx::Size(50, 100)); | 9104 host_impl_->SetViewportSize(gfx::Size(50, 100)); |
| 9106 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true); | 9105 host_impl_->active_tree()->set_browser_controls_shrink_blink_size(true); |
| 9107 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( | 9106 host_impl_->browser_controls_manager()->UpdateBrowserControlsState( |
| 9108 BOTH, SHOWN, false); | 9107 BOTH, SHOWN, false); |
| 9109 DrawFrame(); | 9108 DrawFrame(); |
| 9110 | 9109 |
| 9111 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); | 9110 LayerImpl* viewport_layer = host_impl_->InnerViewportScrollLayer(); |
| 9112 | 9111 |
| 9113 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9112 EXPECT_EQ( |
| 9114 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 9113 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9115 InputHandler::WHEEL) | 9114 host_impl_ |
| 9116 .thread); | 9115 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 9116 .thread); |
| 9117 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9117 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9118 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); | 9118 EXPECT_VECTOR_EQ(gfx::Vector2dF(), viewport_layer->CurrentScrollOffset()); |
| 9119 | 9119 |
| 9120 // Wheel scrolls should not affect the browser controls, and should pass | 9120 // Wheel scrolls should not affect the browser controls, and should pass |
| 9121 // directly through to the viewport. | 9121 // directly through to the viewport. |
| 9122 const float delta = top_controls_height_; | 9122 const float delta = top_controls_height_; |
| 9123 EXPECT_TRUE( | 9123 EXPECT_TRUE( |
| 9124 host_impl_->ScrollBy( | 9124 host_impl_ |
| 9125 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 9125 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
| 9126 .did_scroll); | 9126 .did_scroll); |
| 9127 EXPECT_FLOAT_EQ(0, | 9127 EXPECT_FLOAT_EQ(0, |
| 9128 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9128 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9129 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), | 9129 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta), |
| 9130 viewport_layer->CurrentScrollOffset()); | 9130 viewport_layer->CurrentScrollOffset()); |
| 9131 | 9131 |
| 9132 EXPECT_TRUE( | 9132 EXPECT_TRUE( |
| 9133 host_impl_->ScrollBy( | 9133 host_impl_ |
| 9134 UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) | 9134 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, delta)).get()) |
| 9135 .did_scroll); | 9135 .did_scroll); |
| 9136 EXPECT_FLOAT_EQ(0, | 9136 EXPECT_FLOAT_EQ(0, |
| 9137 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9137 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9138 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), | 9138 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, delta * 2), |
| 9139 viewport_layer->CurrentScrollOffset()); | 9139 viewport_layer->CurrentScrollOffset()); |
| 9140 } | 9140 } |
| 9141 | 9141 |
| 9142 TEST_F(LayerTreeHostImplWithBrowserControlsTest, | 9142 TEST_F(LayerTreeHostImplWithBrowserControlsTest, |
| 9143 BrowserControlsAnimationAtOrigin) { | 9143 BrowserControlsAnimationAtOrigin) { |
| 9144 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 9144 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9155 InputHandler::TOUCHSCREEN) | 9155 InputHandler::TOUCHSCREEN) |
| 9156 .thread); | 9156 .thread); |
| 9157 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9157 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9158 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9158 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9159 scroll_layer->CurrentScrollOffset().ToString()); | 9159 scroll_layer->CurrentScrollOffset().ToString()); |
| 9160 | 9160 |
| 9161 // Scroll the browser controls partially. | 9161 // Scroll the browser controls partially. |
| 9162 const float residue = 35; | 9162 const float residue = 35; |
| 9163 float offset = top_controls_height_ - residue; | 9163 float offset = top_controls_height_ - residue; |
| 9164 EXPECT_TRUE( | 9164 EXPECT_TRUE( |
| 9165 host_impl_->ScrollBy( | 9165 host_impl_ |
| 9166 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9166 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9167 .did_scroll); | 9167 .did_scroll); |
| 9168 EXPECT_FLOAT_EQ(-offset, | 9168 EXPECT_FLOAT_EQ(-offset, |
| 9169 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9169 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9170 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9170 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9171 scroll_layer->CurrentScrollOffset().ToString()); | 9171 scroll_layer->CurrentScrollOffset().ToString()); |
| 9172 | 9172 |
| 9173 did_request_redraw_ = false; | 9173 did_request_redraw_ = false; |
| 9174 did_request_next_frame_ = false; | 9174 did_request_next_frame_ = false; |
| 9175 did_request_commit_ = false; | 9175 did_request_commit_ = false; |
| 9176 | 9176 |
| 9177 // End the scroll while the controls are still offset from their limit. | 9177 // End the scroll while the controls are still offset from their limit. |
| 9178 host_impl_->ScrollEnd(EndState().get()); | 9178 host_impl_->ScrollEnd(EndState().get()); |
| 9179 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9179 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9180 EXPECT_TRUE(did_request_next_frame_); | 9180 EXPECT_TRUE(did_request_next_frame_); |
| 9181 EXPECT_TRUE(did_request_redraw_); | 9181 EXPECT_TRUE(did_request_redraw_); |
| 9182 EXPECT_FALSE(did_request_commit_); | 9182 EXPECT_FALSE(did_request_commit_); |
| 9183 | 9183 |
| 9184 // The browser controls should properly animate until finished, despite the | 9184 // The browser controls should properly animate until finished, despite the |
| 9185 // scroll offset being at the origin. | 9185 // scroll offset being at the origin. |
| 9186 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9186 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
| 9187 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9187 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
| 9188 while (did_request_next_frame_) { | 9188 while (did_request_next_frame_) { |
| 9189 did_request_redraw_ = false; | 9189 did_request_redraw_ = false; |
| 9190 did_request_next_frame_ = false; | 9190 did_request_next_frame_ = false; |
| 9191 did_request_commit_ = false; | 9191 did_request_commit_ = false; |
| 9192 | 9192 |
| 9193 float old_offset = | 9193 float old_offset = |
| 9194 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9194 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9195 | 9195 |
| 9196 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9196 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9197 begin_frame_args.sequence_number++; |
| 9197 host_impl_->WillBeginImplFrame(begin_frame_args); | 9198 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9198 host_impl_->Animate(); | 9199 host_impl_->Animate(); |
| 9199 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9200 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9200 scroll_layer->CurrentScrollOffset().ToString()); | 9201 scroll_layer->CurrentScrollOffset().ToString()); |
| 9201 | 9202 |
| 9202 float new_offset = | 9203 float new_offset = |
| 9203 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9204 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9204 | 9205 |
| 9205 // No commit is needed as the controls are animating the content offset, | 9206 // No commit is needed as the controls are animating the content offset, |
| 9206 // not the scroll offset. | 9207 // not the scroll offset. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9239 InputHandler::TOUCHSCREEN) | 9240 InputHandler::TOUCHSCREEN) |
| 9240 .thread); | 9241 .thread); |
| 9241 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9242 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9242 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9243 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9243 scroll_layer->CurrentScrollOffset().ToString()); | 9244 scroll_layer->CurrentScrollOffset().ToString()); |
| 9244 | 9245 |
| 9245 // Scroll the browser controls partially. | 9246 // Scroll the browser controls partially. |
| 9246 const float residue = 15; | 9247 const float residue = 15; |
| 9247 float offset = top_controls_height_ - residue; | 9248 float offset = top_controls_height_ - residue; |
| 9248 EXPECT_TRUE( | 9249 EXPECT_TRUE( |
| 9249 host_impl_->ScrollBy( | 9250 host_impl_ |
| 9250 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9251 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9251 .did_scroll); | 9252 .did_scroll); |
| 9252 EXPECT_FLOAT_EQ(-offset, | 9253 EXPECT_FLOAT_EQ(-offset, |
| 9253 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9254 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9254 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9255 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9255 scroll_layer->CurrentScrollOffset().ToString()); | 9256 scroll_layer->CurrentScrollOffset().ToString()); |
| 9256 | 9257 |
| 9257 did_request_redraw_ = false; | 9258 did_request_redraw_ = false; |
| 9258 did_request_next_frame_ = false; | 9259 did_request_next_frame_ = false; |
| 9259 did_request_commit_ = false; | 9260 did_request_commit_ = false; |
| 9260 | 9261 |
| 9261 // End the scroll while the controls are still offset from the limit. | 9262 // End the scroll while the controls are still offset from the limit. |
| 9262 host_impl_->ScrollEnd(EndState().get()); | 9263 host_impl_->ScrollEnd(EndState().get()); |
| 9263 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9264 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9264 EXPECT_TRUE(did_request_next_frame_); | 9265 EXPECT_TRUE(did_request_next_frame_); |
| 9265 EXPECT_TRUE(did_request_redraw_); | 9266 EXPECT_TRUE(did_request_redraw_); |
| 9266 EXPECT_FALSE(did_request_commit_); | 9267 EXPECT_FALSE(did_request_commit_); |
| 9267 | 9268 |
| 9268 // Animate the browser controls to the limit. | 9269 // Animate the browser controls to the limit. |
| 9269 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9270 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
| 9270 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9271 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
| 9271 while (did_request_next_frame_) { | 9272 while (did_request_next_frame_) { |
| 9272 did_request_redraw_ = false; | 9273 did_request_redraw_ = false; |
| 9273 did_request_next_frame_ = false; | 9274 did_request_next_frame_ = false; |
| 9274 did_request_commit_ = false; | 9275 did_request_commit_ = false; |
| 9275 | 9276 |
| 9276 float old_offset = | 9277 float old_offset = |
| 9277 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9278 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9278 | 9279 |
| 9279 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9280 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9281 begin_frame_args.sequence_number++; |
| 9280 host_impl_->WillBeginImplFrame(begin_frame_args); | 9282 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9281 host_impl_->Animate(); | 9283 host_impl_->Animate(); |
| 9282 | 9284 |
| 9283 float new_offset = | 9285 float new_offset = |
| 9284 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9286 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9285 | 9287 |
| 9286 if (new_offset != old_offset) { | 9288 if (new_offset != old_offset) { |
| 9287 EXPECT_TRUE(did_request_redraw_); | 9289 EXPECT_TRUE(did_request_redraw_); |
| 9288 EXPECT_TRUE(did_request_commit_); | 9290 EXPECT_TRUE(did_request_commit_); |
| 9289 } | 9291 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 9315 InputHandler::TOUCHSCREEN) | 9317 InputHandler::TOUCHSCREEN) |
| 9316 .thread); | 9318 .thread); |
| 9317 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9319 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9318 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9320 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9319 scroll_layer->CurrentScrollOffset().ToString()); | 9321 scroll_layer->CurrentScrollOffset().ToString()); |
| 9320 | 9322 |
| 9321 // Scroll the browser controls partially. | 9323 // Scroll the browser controls partially. |
| 9322 const float residue = 15; | 9324 const float residue = 15; |
| 9323 float offset = top_controls_height_ - residue; | 9325 float offset = top_controls_height_ - residue; |
| 9324 EXPECT_TRUE( | 9326 EXPECT_TRUE( |
| 9325 host_impl_->ScrollBy( | 9327 host_impl_ |
| 9326 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9328 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9327 .did_scroll); | 9329 .did_scroll); |
| 9328 EXPECT_FLOAT_EQ(-offset, | 9330 EXPECT_FLOAT_EQ(-offset, |
| 9329 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9331 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9330 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 9332 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 9331 scroll_layer->CurrentScrollOffset().ToString()); | 9333 scroll_layer->CurrentScrollOffset().ToString()); |
| 9332 | 9334 |
| 9333 did_request_redraw_ = false; | 9335 did_request_redraw_ = false; |
| 9334 did_request_next_frame_ = false; | 9336 did_request_next_frame_ = false; |
| 9335 did_request_commit_ = false; | 9337 did_request_commit_ = false; |
| 9336 | 9338 |
| 9337 // End the fling while the controls are still offset from the limit. | 9339 // End the fling while the controls are still offset from the limit. |
| 9338 host_impl_->MainThreadHasStoppedFlinging(); | 9340 host_impl_->MainThreadHasStoppedFlinging(); |
| 9339 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); | 9341 ASSERT_TRUE(host_impl_->browser_controls_manager()->has_animation()); |
| 9340 EXPECT_TRUE(did_request_next_frame_); | 9342 EXPECT_TRUE(did_request_next_frame_); |
| 9341 EXPECT_TRUE(did_request_redraw_); | 9343 EXPECT_TRUE(did_request_redraw_); |
| 9342 EXPECT_FALSE(did_request_commit_); | 9344 EXPECT_FALSE(did_request_commit_); |
| 9343 | 9345 |
| 9344 // Animate the browser controls to the limit. | 9346 // Animate the browser controls to the limit. |
| 9345 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( | 9347 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting( |
| 9346 BEGINFRAME_FROM_HERE, base::TimeTicks::Now()); | 9348 BEGINFRAME_FROM_HERE, 0, 1, base::TimeTicks::Now()); |
| 9347 while (did_request_next_frame_) { | 9349 while (did_request_next_frame_) { |
| 9348 did_request_redraw_ = false; | 9350 did_request_redraw_ = false; |
| 9349 did_request_next_frame_ = false; | 9351 did_request_next_frame_ = false; |
| 9350 did_request_commit_ = false; | 9352 did_request_commit_ = false; |
| 9351 | 9353 |
| 9352 float old_offset = | 9354 float old_offset = |
| 9353 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9355 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9354 | 9356 |
| 9355 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); | 9357 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5); |
| 9358 begin_frame_args.sequence_number++; |
| 9356 host_impl_->WillBeginImplFrame(begin_frame_args); | 9359 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 9357 host_impl_->Animate(); | 9360 host_impl_->Animate(); |
| 9358 | 9361 |
| 9359 float new_offset = | 9362 float new_offset = |
| 9360 host_impl_->browser_controls_manager()->ControlsTopOffset(); | 9363 host_impl_->browser_controls_manager()->ControlsTopOffset(); |
| 9361 | 9364 |
| 9362 if (new_offset != old_offset) { | 9365 if (new_offset != old_offset) { |
| 9363 EXPECT_TRUE(did_request_redraw_); | 9366 EXPECT_TRUE(did_request_redraw_); |
| 9364 EXPECT_TRUE(did_request_commit_); | 9367 EXPECT_TRUE(did_request_commit_); |
| 9365 } | 9368 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9384 | 9387 |
| 9385 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9388 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9386 host_impl_ | 9389 host_impl_ |
| 9387 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9390 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9388 InputHandler::TOUCHSCREEN) | 9391 InputHandler::TOUCHSCREEN) |
| 9389 .thread); | 9392 .thread); |
| 9390 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9393 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9391 | 9394 |
| 9392 float offset = 50; | 9395 float offset = 50; |
| 9393 EXPECT_TRUE( | 9396 EXPECT_TRUE( |
| 9394 host_impl_->ScrollBy( | 9397 host_impl_ |
| 9395 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9398 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9396 .did_scroll); | 9399 .did_scroll); |
| 9397 EXPECT_EQ(-offset, | 9400 EXPECT_EQ(-offset, |
| 9398 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9401 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9399 EXPECT_EQ(gfx::Vector2dF().ToString(), | 9402 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 9400 scroll_layer->CurrentScrollOffset().ToString()); | 9403 scroll_layer->CurrentScrollOffset().ToString()); |
| 9401 | 9404 |
| 9402 EXPECT_TRUE( | 9405 EXPECT_TRUE( |
| 9403 host_impl_->ScrollBy( | 9406 host_impl_ |
| 9404 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9407 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9405 .did_scroll); | 9408 .did_scroll); |
| 9406 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), | 9409 EXPECT_EQ(gfx::Vector2dF(0, offset).ToString(), |
| 9407 scroll_layer->CurrentScrollOffset().ToString()); | 9410 scroll_layer->CurrentScrollOffset().ToString()); |
| 9408 | 9411 |
| 9409 EXPECT_TRUE( | 9412 EXPECT_TRUE( |
| 9410 host_impl_->ScrollBy( | 9413 host_impl_ |
| 9411 UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) | 9414 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, offset)).get()) |
| 9412 .did_scroll); | 9415 .did_scroll); |
| 9413 | 9416 |
| 9414 // Should have fully scrolled | 9417 // Should have fully scrolled |
| 9415 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), | 9418 EXPECT_EQ(gfx::Vector2dF(0, scroll_layer->MaxScrollOffset().y()).ToString(), |
| 9416 scroll_layer->CurrentScrollOffset().ToString()); | 9419 scroll_layer->CurrentScrollOffset().ToString()); |
| 9417 | 9420 |
| 9418 float overscrollamount = 10; | 9421 float overscrollamount = 10; |
| 9419 | 9422 |
| 9420 // Overscroll the content | 9423 // Overscroll the content |
| 9421 EXPECT_FALSE( | 9424 EXPECT_FALSE(host_impl_ |
| 9422 host_impl_->ScrollBy(UpdateState(gfx::Point(), | 9425 ->ScrollBy(UpdateState(gfx::Point(), |
| 9423 gfx::Vector2d(0, overscrollamount)) | 9426 gfx::Vector2d(0, overscrollamount)) |
| 9424 .get()) | 9427 .get()) |
| 9425 .did_scroll); | 9428 .did_scroll); |
| 9426 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), | 9429 EXPECT_EQ(gfx::Vector2dF(0, 2 * offset).ToString(), |
| 9427 scroll_layer->CurrentScrollOffset().ToString()); | 9430 scroll_layer->CurrentScrollOffset().ToString()); |
| 9428 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), | 9431 EXPECT_EQ(gfx::Vector2dF(0, overscrollamount).ToString(), |
| 9429 host_impl_->accumulated_root_overscroll().ToString()); | 9432 host_impl_->accumulated_root_overscroll().ToString()); |
| 9430 | 9433 |
| 9431 EXPECT_TRUE(host_impl_->ScrollBy(UpdateState(gfx::Point(), | 9434 EXPECT_TRUE( |
| 9432 gfx::Vector2d(0, -2 * offset)) | 9435 host_impl_ |
| 9433 .get()) | 9436 ->ScrollBy( |
| 9434 .did_scroll); | 9437 UpdateState(gfx::Point(), gfx::Vector2d(0, -2 * offset)).get()) |
| 9438 .did_scroll); |
| 9435 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 9439 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
| 9436 scroll_layer->CurrentScrollOffset().ToString()); | 9440 scroll_layer->CurrentScrollOffset().ToString()); |
| 9437 EXPECT_EQ(-offset, | 9441 EXPECT_EQ(-offset, |
| 9438 host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9442 host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9439 | 9443 |
| 9440 EXPECT_TRUE( | 9444 EXPECT_TRUE( |
| 9441 host_impl_->ScrollBy( | 9445 host_impl_ |
| 9442 UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) | 9446 ->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, -offset)).get()) |
| 9443 .did_scroll); | 9447 .did_scroll); |
| 9444 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), | 9448 EXPECT_EQ(gfx::Vector2dF(0, 0).ToString(), |
| 9445 scroll_layer->CurrentScrollOffset().ToString()); | 9449 scroll_layer->CurrentScrollOffset().ToString()); |
| 9446 | 9450 |
| 9447 // Browser controls should be fully visible | 9451 // Browser controls should be fully visible |
| 9448 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); | 9452 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ControlsTopOffset()); |
| 9449 | 9453 |
| 9450 host_impl_->ScrollEnd(EndState().get()); | 9454 host_impl_->ScrollEnd(EndState().get()); |
| 9451 } | 9455 } |
| 9452 | 9456 |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10283 const gfx::Size content_size(1000, 1000); | 10287 const gfx::Size content_size(1000, 1000); |
| 10284 const gfx::Size viewport_size(50, 100); | 10288 const gfx::Size viewport_size(50, 100); |
| 10285 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10289 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10286 | 10290 |
| 10287 DrawFrame(); | 10291 DrawFrame(); |
| 10288 | 10292 |
| 10289 base::TimeTicks start_time = | 10293 base::TimeTicks start_time = |
| 10290 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10294 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10291 | 10295 |
| 10292 BeginFrameArgs begin_frame_args = | 10296 BeginFrameArgs begin_frame_args = |
| 10293 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10297 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10294 | 10298 |
| 10295 EXPECT_EQ( | 10299 EXPECT_EQ( |
| 10296 InputHandler::SCROLL_ON_IMPL_THREAD, | 10300 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10297 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10301 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10298 | 10302 |
| 10299 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10303 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10300 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10304 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
| 10301 | 10305 |
| 10302 begin_frame_args.frame_time = start_time; | 10306 begin_frame_args.frame_time = start_time; |
| 10307 begin_frame_args.sequence_number++; |
| 10303 host_impl_->WillBeginImplFrame(begin_frame_args); | 10308 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10304 host_impl_->Animate(); | 10309 host_impl_->Animate(); |
| 10305 host_impl_->UpdateAnimationState(true); | 10310 host_impl_->UpdateAnimationState(true); |
| 10306 | 10311 |
| 10307 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10312 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10308 host_impl_->DidFinishImplFrame(); | 10313 host_impl_->DidFinishImplFrame(); |
| 10309 | 10314 |
| 10310 begin_frame_args.frame_time = | 10315 begin_frame_args.frame_time = |
| 10311 start_time + base::TimeDelta::FromMilliseconds(50); | 10316 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10317 begin_frame_args.sequence_number++; |
| 10312 host_impl_->WillBeginImplFrame(begin_frame_args); | 10318 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10313 host_impl_->Animate(); | 10319 host_impl_->Animate(); |
| 10314 host_impl_->UpdateAnimationState(true); | 10320 host_impl_->UpdateAnimationState(true); |
| 10315 | 10321 |
| 10316 float y = scrolling_layer->CurrentScrollOffset().y(); | 10322 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10317 EXPECT_TRUE(y > 1 && y < 49); | 10323 EXPECT_TRUE(y > 1 && y < 49); |
| 10318 | 10324 |
| 10319 // Update target. | 10325 // Update target. |
| 10320 EXPECT_EQ( | 10326 EXPECT_EQ( |
| 10321 InputHandler::SCROLL_ON_IMPL_THREAD, | 10327 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10322 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10328 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10323 host_impl_->DidFinishImplFrame(); | 10329 host_impl_->DidFinishImplFrame(); |
| 10324 | 10330 |
| 10325 begin_frame_args.frame_time = | 10331 begin_frame_args.frame_time = |
| 10326 start_time + base::TimeDelta::FromMilliseconds(200); | 10332 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10333 begin_frame_args.sequence_number++; |
| 10327 host_impl_->WillBeginImplFrame(begin_frame_args); | 10334 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10328 host_impl_->Animate(); | 10335 host_impl_->Animate(); |
| 10329 host_impl_->UpdateAnimationState(true); | 10336 host_impl_->UpdateAnimationState(true); |
| 10330 | 10337 |
| 10331 y = scrolling_layer->CurrentScrollOffset().y(); | 10338 y = scrolling_layer->CurrentScrollOffset().y(); |
| 10332 EXPECT_TRUE(y > 50 && y < 100); | 10339 EXPECT_TRUE(y > 50 && y < 100); |
| 10333 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10340 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10334 host_impl_->DidFinishImplFrame(); | 10341 host_impl_->DidFinishImplFrame(); |
| 10335 | 10342 |
| 10336 begin_frame_args.frame_time = | 10343 begin_frame_args.frame_time = |
| 10337 start_time + base::TimeDelta::FromMilliseconds(250); | 10344 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10345 begin_frame_args.sequence_number++; |
| 10338 host_impl_->WillBeginImplFrame(begin_frame_args); | 10346 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10339 host_impl_->Animate(); | 10347 host_impl_->Animate(); |
| 10340 host_impl_->UpdateAnimationState(true); | 10348 host_impl_->UpdateAnimationState(true); |
| 10341 | 10349 |
| 10342 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10350 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10343 scrolling_layer->CurrentScrollOffset()); | 10351 scrolling_layer->CurrentScrollOffset()); |
| 10344 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10352 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 10345 host_impl_->DidFinishImplFrame(); | 10353 host_impl_->DidFinishImplFrame(); |
| 10346 } | 10354 } |
| 10347 | 10355 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 10364 const gfx::Size content_size(1000, 1000); | 10372 const gfx::Size content_size(1000, 1000); |
| 10365 const gfx::Size viewport_size(50, 100); | 10373 const gfx::Size viewport_size(50, 100); |
| 10366 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10374 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10367 | 10375 |
| 10368 DrawFrame(); | 10376 DrawFrame(); |
| 10369 | 10377 |
| 10370 base::TimeTicks start_time = | 10378 base::TimeTicks start_time = |
| 10371 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200); | 10379 base::TimeTicks() + base::TimeDelta::FromMilliseconds(200); |
| 10372 | 10380 |
| 10373 BeginFrameArgs begin_frame_args = | 10381 BeginFrameArgs begin_frame_args = |
| 10374 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10382 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10375 begin_frame_args.frame_time = start_time; | 10383 begin_frame_args.frame_time = start_time; |
| 10384 begin_frame_args.sequence_number++; |
| 10376 host_impl_->WillBeginImplFrame(begin_frame_args); | 10385 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10377 host_impl_->UpdateAnimationState(true); | 10386 host_impl_->UpdateAnimationState(true); |
| 10378 host_impl_->DidFinishImplFrame(); | 10387 host_impl_->DidFinishImplFrame(); |
| 10379 | 10388 |
| 10380 EXPECT_EQ( | 10389 EXPECT_EQ( |
| 10381 InputHandler::SCROLL_ON_IMPL_THREAD, | 10390 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10382 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10391 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10383 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation | 10392 // This will call ScrollOffsetAnimationCurve::UpdateTarget while the animation |
| 10384 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and | 10393 // created above is in state ANIMATION::WAITING_FOR_TARGET_AVAILABILITY and |
| 10385 // doesn't have a start time. | 10394 // doesn't have a start time. |
| 10386 EXPECT_EQ( | 10395 EXPECT_EQ( |
| 10387 InputHandler::SCROLL_ON_IMPL_THREAD, | 10396 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10388 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 10397 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
| 10389 | 10398 |
| 10390 begin_frame_args.frame_time = | 10399 begin_frame_args.frame_time = |
| 10391 start_time + base::TimeDelta::FromMilliseconds(250); | 10400 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10401 begin_frame_args.sequence_number++; |
| 10392 // This is when the animation above gets promoted to STARTING. | 10402 // This is when the animation above gets promoted to STARTING. |
| 10393 host_impl_->WillBeginImplFrame(begin_frame_args); | 10403 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10394 host_impl_->UpdateAnimationState(true); | 10404 host_impl_->UpdateAnimationState(true); |
| 10395 host_impl_->DidFinishImplFrame(); | 10405 host_impl_->DidFinishImplFrame(); |
| 10396 | 10406 |
| 10397 begin_frame_args.frame_time = | 10407 begin_frame_args.frame_time = |
| 10398 start_time + base::TimeDelta::FromMilliseconds(300); | 10408 start_time + base::TimeDelta::FromMilliseconds(300); |
| 10409 begin_frame_args.sequence_number++; |
| 10399 // This is when the animation above gets ticked. | 10410 // This is when the animation above gets ticked. |
| 10400 host_impl_->WillBeginImplFrame(begin_frame_args); | 10411 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10401 host_impl_->UpdateAnimationState(true); | 10412 host_impl_->UpdateAnimationState(true); |
| 10402 host_impl_->DidFinishImplFrame(); | 10413 host_impl_->DidFinishImplFrame(); |
| 10403 | 10414 |
| 10404 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10415 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10405 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10416 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
| 10406 | 10417 |
| 10407 // Verify no jump. | 10418 // Verify no jump. |
| 10408 float y = scrolling_layer->CurrentScrollOffset().y(); | 10419 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10409 EXPECT_TRUE(y > 1 && y < 49); | 10420 EXPECT_TRUE(y > 1 && y < 49); |
| 10410 } | 10421 } |
| 10411 | 10422 |
| 10412 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { | 10423 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { |
| 10413 const gfx::Size content_size(1000, 1000); | 10424 const gfx::Size content_size(1000, 1000); |
| 10414 const gfx::Size viewport_size(50, 100); | 10425 const gfx::Size viewport_size(50, 100); |
| 10415 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10426 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10416 | 10427 |
| 10417 DrawFrame(); | 10428 DrawFrame(); |
| 10418 | 10429 |
| 10419 base::TimeTicks start_time = | 10430 base::TimeTicks start_time = |
| 10420 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10431 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10421 BeginFrameArgs begin_frame_args = | 10432 BeginFrameArgs begin_frame_args = |
| 10422 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10433 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10423 | 10434 |
| 10424 // Create animation with a 100ms delay. | 10435 // Create animation with a 100ms delay. |
| 10425 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10436 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10426 host_impl_ | 10437 host_impl_ |
| 10427 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10438 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
| 10428 base::TimeDelta::FromMilliseconds(100)) | 10439 base::TimeDelta::FromMilliseconds(100)) |
| 10429 .thread); | 10440 .thread); |
| 10430 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10441 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10431 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10442 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); |
| 10432 | 10443 |
| 10433 // First tick, animation is started. | 10444 // First tick, animation is started. |
| 10434 begin_frame_args.frame_time = start_time; | 10445 begin_frame_args.frame_time = start_time; |
| 10446 begin_frame_args.sequence_number++; |
| 10435 host_impl_->WillBeginImplFrame(begin_frame_args); | 10447 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10436 host_impl_->UpdateAnimationState(true); | 10448 host_impl_->UpdateAnimationState(true); |
| 10437 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10449 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10438 host_impl_->DidFinishImplFrame(); | 10450 host_impl_->DidFinishImplFrame(); |
| 10439 | 10451 |
| 10440 // Second tick after 50ms, animation should be half way done since | 10452 // Second tick after 50ms, animation should be half way done since |
| 10441 // the duration due to delay is 100ms. | 10453 // the duration due to delay is 100ms. |
| 10442 begin_frame_args.frame_time = | 10454 begin_frame_args.frame_time = |
| 10443 start_time + base::TimeDelta::FromMilliseconds(50); | 10455 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10456 begin_frame_args.sequence_number++; |
| 10444 host_impl_->WillBeginImplFrame(begin_frame_args); | 10457 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10445 host_impl_->UpdateAnimationState(true); | 10458 host_impl_->UpdateAnimationState(true); |
| 10446 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); | 10459 EXPECT_EQ(50, scrolling_layer->CurrentScrollOffset().y()); |
| 10447 host_impl_->DidFinishImplFrame(); | 10460 host_impl_->DidFinishImplFrame(); |
| 10448 | 10461 |
| 10449 // Update target. | 10462 // Update target. |
| 10450 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10463 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10451 host_impl_ | 10464 host_impl_ |
| 10452 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10465 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
| 10453 base::TimeDelta::FromMilliseconds(150)) | 10466 base::TimeDelta::FromMilliseconds(150)) |
| 10454 .thread); | 10467 .thread); |
| 10455 | 10468 |
| 10456 // Third tick after 100ms, should be at the target position since update | 10469 // Third tick after 100ms, should be at the target position since update |
| 10457 // target was called with a large value of jank. | 10470 // target was called with a large value of jank. |
| 10458 begin_frame_args.frame_time = | 10471 begin_frame_args.frame_time = |
| 10459 start_time + base::TimeDelta::FromMilliseconds(100); | 10472 start_time + base::TimeDelta::FromMilliseconds(100); |
| 10473 begin_frame_args.sequence_number++; |
| 10460 host_impl_->WillBeginImplFrame(begin_frame_args); | 10474 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10461 host_impl_->UpdateAnimationState(true); | 10475 host_impl_->UpdateAnimationState(true); |
| 10462 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); | 10476 EXPECT_LT(100, scrolling_layer->CurrentScrollOffset().y()); |
| 10463 } | 10477 } |
| 10464 | 10478 |
| 10465 // Test that a smooth scroll offset animation is aborted when followed by a | 10479 // Test that a smooth scroll offset animation is aborted when followed by a |
| 10466 // non-smooth scroll offset animation. | 10480 // non-smooth scroll offset animation. |
| 10467 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { | 10481 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) { |
| 10468 const gfx::Size content_size(1000, 1000); | 10482 const gfx::Size content_size(1000, 1000); |
| 10469 const gfx::Size viewport_size(500, 500); | 10483 const gfx::Size viewport_size(500, 500); |
| 10470 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10484 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10471 | 10485 |
| 10472 DrawFrame(); | 10486 DrawFrame(); |
| 10473 | 10487 |
| 10474 base::TimeTicks start_time = | 10488 base::TimeTicks start_time = |
| 10475 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10489 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10476 | 10490 |
| 10477 BeginFrameArgs begin_frame_args = | 10491 BeginFrameArgs begin_frame_args = |
| 10478 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10492 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10479 | 10493 |
| 10480 // Perform animated scroll. | 10494 // Perform animated scroll. |
| 10481 EXPECT_EQ( | 10495 EXPECT_EQ( |
| 10482 InputHandler::SCROLL_ON_IMPL_THREAD, | 10496 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10483 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10497 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10484 | 10498 |
| 10485 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10499 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10486 | 10500 |
| 10487 begin_frame_args.frame_time = start_time; | 10501 begin_frame_args.frame_time = start_time; |
| 10502 begin_frame_args.sequence_number++; |
| 10488 host_impl_->WillBeginImplFrame(begin_frame_args); | 10503 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10489 host_impl_->Animate(); | 10504 host_impl_->Animate(); |
| 10490 host_impl_->UpdateAnimationState(true); | 10505 host_impl_->UpdateAnimationState(true); |
| 10491 | 10506 |
| 10492 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10507 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
| 10493 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10508 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 10494 | 10509 |
| 10495 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10510 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10496 host_impl_->DidFinishImplFrame(); | 10511 host_impl_->DidFinishImplFrame(); |
| 10497 | 10512 |
| 10498 begin_frame_args.frame_time = | 10513 begin_frame_args.frame_time = |
| 10499 start_time + base::TimeDelta::FromMilliseconds(50); | 10514 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10515 begin_frame_args.sequence_number++; |
| 10500 host_impl_->WillBeginImplFrame(begin_frame_args); | 10516 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10501 host_impl_->Animate(); | 10517 host_impl_->Animate(); |
| 10502 host_impl_->UpdateAnimationState(true); | 10518 host_impl_->UpdateAnimationState(true); |
| 10503 | 10519 |
| 10504 float y = scrolling_layer->CurrentScrollOffset().y(); | 10520 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10505 EXPECT_TRUE(y > 1 && y < 49); | 10521 EXPECT_TRUE(y > 1 && y < 49); |
| 10506 | 10522 |
| 10507 // Perform instant scroll. | 10523 // Perform instant scroll. |
| 10508 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10524 EXPECT_EQ( |
| 10509 host_impl_->ScrollBegin(BeginState(gfx::Point(0, y)).get(), | 10525 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10510 InputHandler::WHEEL) | 10526 host_impl_ |
| 10511 .thread); | 10527 ->ScrollBegin(BeginState(gfx::Point(0, y)).get(), InputHandler::WHEEL) |
| 10528 .thread); |
| 10512 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), | 10529 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y), |
| 10513 InputHandler::WHEEL)); | 10530 InputHandler::WHEEL)); |
| 10514 host_impl_->ScrollBy( | 10531 host_impl_->ScrollBy( |
| 10515 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); | 10532 UpdateState(gfx::Point(0, y), gfx::Vector2d(0, 50)).get()); |
| 10516 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), | 10533 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, y + 50), |
| 10517 InputHandler::WHEEL)); | 10534 InputHandler::WHEEL)); |
| 10518 std::unique_ptr<ScrollState> scroll_state_end = EndState(); | 10535 std::unique_ptr<ScrollState> scroll_state_end = EndState(); |
| 10519 host_impl_->ScrollEnd(scroll_state_end.get()); | 10536 host_impl_->ScrollEnd(scroll_state_end.get()); |
| 10520 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 10537 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 10521 InputHandler::WHEEL)); | 10538 InputHandler::WHEEL)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 10539 const gfx::Size content_size(1000, 1000); | 10556 const gfx::Size content_size(1000, 1000); |
| 10540 const gfx::Size viewport_size(500, 500); | 10557 const gfx::Size viewport_size(500, 500); |
| 10541 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10558 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10542 | 10559 |
| 10543 DrawFrame(); | 10560 DrawFrame(); |
| 10544 | 10561 |
| 10545 base::TimeTicks start_time = | 10562 base::TimeTicks start_time = |
| 10546 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10563 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10547 | 10564 |
| 10548 BeginFrameArgs begin_frame_args = | 10565 BeginFrameArgs begin_frame_args = |
| 10549 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10566 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10550 | 10567 |
| 10551 // Perform animated scroll. | 10568 // Perform animated scroll. |
| 10552 EXPECT_EQ( | 10569 EXPECT_EQ( |
| 10553 InputHandler::SCROLL_ON_IMPL_THREAD, | 10570 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10554 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); | 10571 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100)).thread); |
| 10555 | 10572 |
| 10556 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10573 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10557 | 10574 |
| 10558 begin_frame_args.frame_time = start_time; | 10575 begin_frame_args.frame_time = start_time; |
| 10576 begin_frame_args.sequence_number++; |
| 10559 host_impl_->WillBeginImplFrame(begin_frame_args); | 10577 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10560 host_impl_->Animate(); | 10578 host_impl_->Animate(); |
| 10561 host_impl_->UpdateAnimationState(true); | 10579 host_impl_->UpdateAnimationState(true); |
| 10562 | 10580 |
| 10563 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10581 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
| 10564 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10582 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 10565 | 10583 |
| 10566 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10584 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10567 host_impl_->DidFinishImplFrame(); | 10585 host_impl_->DidFinishImplFrame(); |
| 10568 | 10586 |
| 10569 begin_frame_args.frame_time = | 10587 begin_frame_args.frame_time = |
| 10570 start_time + base::TimeDelta::FromMilliseconds(50); | 10588 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10589 begin_frame_args.sequence_number++; |
| 10571 host_impl_->WillBeginImplFrame(begin_frame_args); | 10590 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10572 host_impl_->Animate(); | 10591 host_impl_->Animate(); |
| 10573 host_impl_->UpdateAnimationState(true); | 10592 host_impl_->UpdateAnimationState(true); |
| 10574 | 10593 |
| 10575 float y = scrolling_layer->CurrentScrollOffset().y(); | 10594 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10576 EXPECT_TRUE(y > 1 && y < 49); | 10595 EXPECT_TRUE(y > 1 && y < 49); |
| 10577 | 10596 |
| 10578 // Abort animation. | 10597 // Abort animation. |
| 10579 GetImplAnimationHost()->ScrollAnimationAbort(true /*needs_completion*/); | 10598 GetImplAnimationHost()->ScrollAnimationAbort(true /*needs_completion*/); |
| 10580 host_impl_->UpdateAnimationState(true); | 10599 host_impl_->UpdateAnimationState(true); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10593 const gfx::Size content_size(1000, 1000); | 10612 const gfx::Size content_size(1000, 1000); |
| 10594 const gfx::Size viewport_size(500, 500); | 10613 const gfx::Size viewport_size(500, 500); |
| 10595 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10614 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10596 | 10615 |
| 10597 DrawFrame(); | 10616 DrawFrame(); |
| 10598 | 10617 |
| 10599 base::TimeTicks start_time = | 10618 base::TimeTicks start_time = |
| 10600 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10619 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10601 | 10620 |
| 10602 BeginFrameArgs begin_frame_args = | 10621 BeginFrameArgs begin_frame_args = |
| 10603 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10622 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10604 | 10623 |
| 10605 EXPECT_EQ( | 10624 EXPECT_EQ( |
| 10606 InputHandler::SCROLL_ON_IMPL_THREAD, | 10625 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10607 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10626 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10608 | 10627 |
| 10609 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10628 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10610 begin_frame_args.frame_time = start_time; | 10629 begin_frame_args.frame_time = start_time; |
| 10630 begin_frame_args.sequence_number++; |
| 10611 host_impl_->WillBeginImplFrame(begin_frame_args); | 10631 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10612 host_impl_->Animate(); | 10632 host_impl_->Animate(); |
| 10613 host_impl_->UpdateAnimationState(true); | 10633 host_impl_->UpdateAnimationState(true); |
| 10614 | 10634 |
| 10615 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10635 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10616 host_impl_->DidFinishImplFrame(); | 10636 host_impl_->DidFinishImplFrame(); |
| 10617 | 10637 |
| 10618 begin_frame_args.frame_time = | 10638 begin_frame_args.frame_time = |
| 10619 start_time + base::TimeDelta::FromMilliseconds(50); | 10639 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10640 begin_frame_args.sequence_number++; |
| 10620 host_impl_->WillBeginImplFrame(begin_frame_args); | 10641 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10621 host_impl_->Animate(); | 10642 host_impl_->Animate(); |
| 10622 host_impl_->UpdateAnimationState(true); | 10643 host_impl_->UpdateAnimationState(true); |
| 10623 | 10644 |
| 10624 float y = scrolling_layer->CurrentScrollOffset().y(); | 10645 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10625 EXPECT_TRUE(y > 1 && y < 49); | 10646 EXPECT_TRUE(y > 1 && y < 49); |
| 10626 | 10647 |
| 10627 // Update target. | 10648 // Update target. |
| 10628 EXPECT_EQ( | 10649 EXPECT_EQ( |
| 10629 InputHandler::SCROLL_ON_IMPL_THREAD, | 10650 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10630 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10651 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10631 host_impl_->DidFinishImplFrame(); | 10652 host_impl_->DidFinishImplFrame(); |
| 10632 | 10653 |
| 10633 begin_frame_args.frame_time = | 10654 begin_frame_args.frame_time = |
| 10634 start_time + base::TimeDelta::FromMilliseconds(200); | 10655 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10656 begin_frame_args.sequence_number++; |
| 10635 host_impl_->WillBeginImplFrame(begin_frame_args); | 10657 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10636 host_impl_->Animate(); | 10658 host_impl_->Animate(); |
| 10637 host_impl_->UpdateAnimationState(true); | 10659 host_impl_->UpdateAnimationState(true); |
| 10638 | 10660 |
| 10639 y = scrolling_layer->CurrentScrollOffset().y(); | 10661 y = scrolling_layer->CurrentScrollOffset().y(); |
| 10640 EXPECT_TRUE(y > 50 && y < 100); | 10662 EXPECT_TRUE(y > 50 && y < 100); |
| 10641 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10663 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10642 host_impl_->DidFinishImplFrame(); | 10664 host_impl_->DidFinishImplFrame(); |
| 10643 | 10665 |
| 10644 begin_frame_args.frame_time = | 10666 begin_frame_args.frame_time = |
| 10645 start_time + base::TimeDelta::FromMilliseconds(250); | 10667 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10668 begin_frame_args.sequence_number++; |
| 10646 host_impl_->WillBeginImplFrame(begin_frame_args); | 10669 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10647 host_impl_->Animate(); | 10670 host_impl_->Animate(); |
| 10648 host_impl_->UpdateAnimationState(true); | 10671 host_impl_->UpdateAnimationState(true); |
| 10649 | 10672 |
| 10650 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10673 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10651 scrolling_layer->CurrentScrollOffset()); | 10674 scrolling_layer->CurrentScrollOffset()); |
| 10652 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10675 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 10653 host_impl_->DidFinishImplFrame(); | 10676 host_impl_->DidFinishImplFrame(); |
| 10654 } | 10677 } |
| 10655 | 10678 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 10669 float page_scale_factor = 2.f; | 10692 float page_scale_factor = 2.f; |
| 10670 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10693 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 10671 page_scale_factor, min_page_scale, max_page_scale); | 10694 page_scale_factor, min_page_scale, max_page_scale); |
| 10672 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10695 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 10673 | 10696 |
| 10674 // Scroll by a small amount, there should be no bubbling to the outer | 10697 // Scroll by a small amount, there should be no bubbling to the outer |
| 10675 // viewport. | 10698 // viewport. |
| 10676 base::TimeTicks start_time = | 10699 base::TimeTicks start_time = |
| 10677 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 10700 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
| 10678 BeginFrameArgs begin_frame_args = | 10701 BeginFrameArgs begin_frame_args = |
| 10679 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10702 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10680 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10703 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10681 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 10704 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
| 10682 .thread); | 10705 .thread); |
| 10683 host_impl_->Animate(); | 10706 host_impl_->Animate(); |
| 10684 host_impl_->UpdateAnimationState(true); | 10707 host_impl_->UpdateAnimationState(true); |
| 10685 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10708 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10686 | 10709 |
| 10710 begin_frame_args.sequence_number++; |
| 10687 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10711 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
| 10688 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), | 10712 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
| 10689 inner_scroll_layer->CurrentScrollOffset()); | 10713 inner_scroll_layer->CurrentScrollOffset()); |
| 10690 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10714 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10691 outer_scroll_layer->CurrentScrollOffset()); | 10715 outer_scroll_layer->CurrentScrollOffset()); |
| 10692 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 10716 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 10693 | 10717 |
| 10694 // Scroll by the inner viewport's max scroll extent, the remainder | 10718 // Scroll by the inner viewport's max scroll extent, the remainder |
| 10695 // should bubble up to the outer viewport. | 10719 // should bubble up to the outer viewport. |
| 10696 EXPECT_EQ( | 10720 EXPECT_EQ( |
| 10697 InputHandler::SCROLL_ON_IMPL_THREAD, | 10721 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10698 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(100.f, 100.f)) | 10722 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(100.f, 100.f)) |
| 10699 .thread); | 10723 .thread); |
| 10700 host_impl_->Animate(); | 10724 host_impl_->Animate(); |
| 10701 host_impl_->UpdateAnimationState(true); | 10725 host_impl_->UpdateAnimationState(true); |
| 10702 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10726 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10703 | 10727 |
| 10728 begin_frame_args.sequence_number++; |
| 10704 BeginImplFrameAndAnimate(begin_frame_args, | 10729 BeginImplFrameAndAnimate(begin_frame_args, |
| 10705 start_time + base::TimeDelta::FromMilliseconds(350)); | 10730 start_time + base::TimeDelta::FromMilliseconds(350)); |
| 10706 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), | 10731 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 10707 inner_scroll_layer->CurrentScrollOffset()); | 10732 inner_scroll_layer->CurrentScrollOffset()); |
| 10708 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), | 10733 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
| 10709 outer_scroll_layer->CurrentScrollOffset()); | 10734 outer_scroll_layer->CurrentScrollOffset()); |
| 10710 | 10735 |
| 10711 // Scroll by the outer viewport's max scroll extent, it should all go to the | 10736 // Scroll by the outer viewport's max scroll extent, it should all go to the |
| 10712 // outer viewport. | 10737 // outer viewport. |
| 10713 EXPECT_EQ( | 10738 EXPECT_EQ( |
| 10714 InputHandler::SCROLL_ON_IMPL_THREAD, | 10739 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10715 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(190.f, 180.f)) | 10740 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(190.f, 180.f)) |
| 10716 .thread); | 10741 .thread); |
| 10717 host_impl_->Animate(); | 10742 host_impl_->Animate(); |
| 10718 host_impl_->UpdateAnimationState(true); | 10743 host_impl_->UpdateAnimationState(true); |
| 10719 EXPECT_EQ(outer_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10744 EXPECT_EQ(outer_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10720 | 10745 |
| 10746 begin_frame_args.sequence_number++; |
| 10721 BeginImplFrameAndAnimate(begin_frame_args, | 10747 BeginImplFrameAndAnimate(begin_frame_args, |
| 10722 start_time + base::TimeDelta::FromMilliseconds(850)); | 10748 start_time + base::TimeDelta::FromMilliseconds(850)); |
| 10723 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), | 10749 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 10724 inner_scroll_layer->CurrentScrollOffset()); | 10750 inner_scroll_layer->CurrentScrollOffset()); |
| 10725 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100), | 10751 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100), |
| 10726 outer_scroll_layer->CurrentScrollOffset()); | 10752 outer_scroll_layer->CurrentScrollOffset()); |
| 10727 | 10753 |
| 10728 // Scroll upwards by the max scroll extent. The inner viewport should animate | 10754 // Scroll upwards by the max scroll extent. The inner viewport should animate |
| 10729 // and the remainder should bubble to the outer viewport. | 10755 // and the remainder should bubble to the outer viewport. |
| 10730 EXPECT_EQ( | 10756 EXPECT_EQ( |
| 10731 InputHandler::SCROLL_ON_IMPL_THREAD, | 10757 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10732 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(-110.f, -120.f)) | 10758 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(-110.f, -120.f)) |
| 10733 .thread); | 10759 .thread); |
| 10734 host_impl_->Animate(); | 10760 host_impl_->Animate(); |
| 10735 host_impl_->UpdateAnimationState(true); | 10761 host_impl_->UpdateAnimationState(true); |
| 10736 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10762 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10737 | 10763 |
| 10764 begin_frame_args.sequence_number++; |
| 10738 BeginImplFrameAndAnimate( | 10765 BeginImplFrameAndAnimate( |
| 10739 begin_frame_args, start_time + base::TimeDelta::FromMilliseconds(1200)); | 10766 begin_frame_args, start_time + base::TimeDelta::FromMilliseconds(1200)); |
| 10740 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10767 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10741 inner_scroll_layer->CurrentScrollOffset()); | 10768 inner_scroll_layer->CurrentScrollOffset()); |
| 10742 EXPECT_VECTOR_EQ(gfx::Vector2dF(95, 90), | 10769 EXPECT_VECTOR_EQ(gfx::Vector2dF(95, 90), |
| 10743 outer_scroll_layer->CurrentScrollOffset()); | 10770 outer_scroll_layer->CurrentScrollOffset()); |
| 10744 } | 10771 } |
| 10745 | 10772 |
| 10746 // Test that the correct viewport scroll layer is updated when the target offset | 10773 // Test that the correct viewport scroll layer is updated when the target offset |
| 10747 // is updated. | 10774 // is updated. |
| 10748 TEST_F(LayerTreeHostImplTimelinesTest, ImplPinchZoomScrollAnimatedUpdate) { | 10775 TEST_F(LayerTreeHostImplTimelinesTest, ImplPinchZoomScrollAnimatedUpdate) { |
| 10749 const gfx::Size content_size(200, 200); | 10776 const gfx::Size content_size(200, 200); |
| 10750 const gfx::Size viewport_size(100, 100); | 10777 const gfx::Size viewport_size(100, 100); |
| 10751 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10778 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10752 | 10779 |
| 10753 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); | 10780 LayerImpl* outer_scroll_layer = host_impl_->OuterViewportScrollLayer(); |
| 10754 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); | 10781 LayerImpl* inner_scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 10755 | 10782 |
| 10756 // Zoom into the page by a 2X factor | 10783 // Zoom into the page by a 2X factor |
| 10757 float min_page_scale = 1.f, max_page_scale = 4.f; | 10784 float min_page_scale = 1.f, max_page_scale = 4.f; |
| 10758 float page_scale_factor = 2.f; | 10785 float page_scale_factor = 2.f; |
| 10759 host_impl_->active_tree()->PushPageScaleFromMainThread( | 10786 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 10760 page_scale_factor, min_page_scale, max_page_scale); | 10787 page_scale_factor, min_page_scale, max_page_scale); |
| 10761 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); | 10788 host_impl_->active_tree()->SetPageScaleOnActiveTree(page_scale_factor); |
| 10762 | 10789 |
| 10763 // Scroll the inner viewport. | 10790 // Scroll the inner viewport. |
| 10764 base::TimeTicks start_time = | 10791 base::TimeTicks start_time = |
| 10765 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); | 10792 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); |
| 10766 BeginFrameArgs begin_frame_args = | 10793 BeginFrameArgs begin_frame_args = |
| 10767 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10794 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10768 EXPECT_EQ( | 10795 EXPECT_EQ( |
| 10769 InputHandler::SCROLL_ON_IMPL_THREAD, | 10796 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10770 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); | 10797 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); |
| 10771 host_impl_->Animate(); | 10798 host_impl_->Animate(); |
| 10772 host_impl_->UpdateAnimationState(true); | 10799 host_impl_->UpdateAnimationState(true); |
| 10773 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10800 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10774 | 10801 |
| 10802 begin_frame_args.sequence_number++; |
| 10775 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10803 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
| 10776 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); | 10804 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); |
| 10777 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); | 10805 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); |
| 10778 EXPECT_TRUE(inner_x > 0 && inner_x < 45); | 10806 EXPECT_TRUE(inner_x > 0 && inner_x < 45); |
| 10779 EXPECT_TRUE(inner_y > 0 && inner_y < 45); | 10807 EXPECT_TRUE(inner_y > 0 && inner_y < 45); |
| 10780 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10808 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10781 outer_scroll_layer->CurrentScrollOffset()); | 10809 outer_scroll_layer->CurrentScrollOffset()); |
| 10782 | 10810 |
| 10783 // Update target. | 10811 // Update target. |
| 10784 EXPECT_EQ( | 10812 EXPECT_EQ( |
| 10785 InputHandler::SCROLL_ON_IMPL_THREAD, | 10813 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10786 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10814 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
| 10787 host_impl_->Animate(); | 10815 host_impl_->Animate(); |
| 10788 host_impl_->UpdateAnimationState(true); | 10816 host_impl_->UpdateAnimationState(true); |
| 10789 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10817 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10790 | 10818 |
| 10791 // Verify that all the delta is applied to the inner viewport and nothing is | 10819 // Verify that all the delta is applied to the inner viewport and nothing is |
| 10792 // carried forward. | 10820 // carried forward. |
| 10821 begin_frame_args.sequence_number++; |
| 10793 BeginImplFrameAndAnimate(begin_frame_args, | 10822 BeginImplFrameAndAnimate(begin_frame_args, |
| 10794 start_time + base::TimeDelta::FromMilliseconds(350)); | 10823 start_time + base::TimeDelta::FromMilliseconds(350)); |
| 10795 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), | 10824 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 10796 inner_scroll_layer->CurrentScrollOffset()); | 10825 inner_scroll_layer->CurrentScrollOffset()); |
| 10797 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10826 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10798 outer_scroll_layer->CurrentScrollOffset()); | 10827 outer_scroll_layer->CurrentScrollOffset()); |
| 10799 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 10828 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 10800 } | 10829 } |
| 10801 | 10830 |
| 10802 // Test that smooth scroll offset animation doesn't happen for non user | 10831 // Test that smooth scroll offset animation doesn't happen for non user |
| 10803 // scrollable layers. | 10832 // scrollable layers. |
| 10804 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) { | 10833 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedNotUserScrollable) { |
| 10805 const gfx::Size content_size(1000, 1000); | 10834 const gfx::Size content_size(1000, 1000); |
| 10806 const gfx::Size viewport_size(500, 500); | 10835 const gfx::Size viewport_size(500, 500); |
| 10807 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10836 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10808 | 10837 |
| 10809 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); | 10838 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_vertical(true); |
| 10810 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); | 10839 host_impl_->OuterViewportScrollLayer()->set_user_scrollable_horizontal(false); |
| 10811 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10840 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 10812 | 10841 |
| 10813 DrawFrame(); | 10842 DrawFrame(); |
| 10814 | 10843 |
| 10815 base::TimeTicks start_time = | 10844 base::TimeTicks start_time = |
| 10816 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10845 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10817 | 10846 |
| 10818 BeginFrameArgs begin_frame_args = | 10847 BeginFrameArgs begin_frame_args = |
| 10819 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10848 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10820 | 10849 |
| 10821 EXPECT_EQ( | 10850 EXPECT_EQ( |
| 10822 InputHandler::SCROLL_ON_IMPL_THREAD, | 10851 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10823 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10852 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
| 10824 | 10853 |
| 10825 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10854 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10826 begin_frame_args.frame_time = start_time; | 10855 begin_frame_args.frame_time = start_time; |
| 10856 begin_frame_args.sequence_number++; |
| 10827 host_impl_->WillBeginImplFrame(begin_frame_args); | 10857 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10828 host_impl_->Animate(); | 10858 host_impl_->Animate(); |
| 10829 host_impl_->UpdateAnimationState(true); | 10859 host_impl_->UpdateAnimationState(true); |
| 10830 | 10860 |
| 10831 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10861 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10832 host_impl_->DidFinishImplFrame(); | 10862 host_impl_->DidFinishImplFrame(); |
| 10833 | 10863 |
| 10834 begin_frame_args.frame_time = | 10864 begin_frame_args.frame_time = |
| 10835 start_time + base::TimeDelta::FromMilliseconds(50); | 10865 start_time + base::TimeDelta::FromMilliseconds(50); |
| 10866 begin_frame_args.sequence_number++; |
| 10836 host_impl_->WillBeginImplFrame(begin_frame_args); | 10867 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10837 host_impl_->Animate(); | 10868 host_impl_->Animate(); |
| 10838 host_impl_->UpdateAnimationState(true); | 10869 host_impl_->UpdateAnimationState(true); |
| 10839 | 10870 |
| 10840 // Should not have scrolled horizontally. | 10871 // Should not have scrolled horizontally. |
| 10841 EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x()); | 10872 EXPECT_EQ(0, scrolling_layer->CurrentScrollOffset().x()); |
| 10842 float y = scrolling_layer->CurrentScrollOffset().y(); | 10873 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10843 EXPECT_TRUE(y > 1 && y < 49); | 10874 EXPECT_TRUE(y > 1 && y < 49); |
| 10844 | 10875 |
| 10845 // Update target. | 10876 // Update target. |
| 10846 EXPECT_EQ( | 10877 EXPECT_EQ( |
| 10847 InputHandler::SCROLL_ON_IMPL_THREAD, | 10878 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10848 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10879 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
| 10849 host_impl_->DidFinishImplFrame(); | 10880 host_impl_->DidFinishImplFrame(); |
| 10850 | 10881 |
| 10851 begin_frame_args.frame_time = | 10882 begin_frame_args.frame_time = |
| 10852 start_time + base::TimeDelta::FromMilliseconds(200); | 10883 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10884 begin_frame_args.sequence_number++; |
| 10853 host_impl_->WillBeginImplFrame(begin_frame_args); | 10885 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10854 host_impl_->Animate(); | 10886 host_impl_->Animate(); |
| 10855 host_impl_->UpdateAnimationState(true); | 10887 host_impl_->UpdateAnimationState(true); |
| 10856 | 10888 |
| 10857 y = scrolling_layer->CurrentScrollOffset().y(); | 10889 y = scrolling_layer->CurrentScrollOffset().y(); |
| 10858 EXPECT_TRUE(y > 50 && y < 100); | 10890 EXPECT_TRUE(y > 50 && y < 100); |
| 10859 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10891 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
| 10860 host_impl_->DidFinishImplFrame(); | 10892 host_impl_->DidFinishImplFrame(); |
| 10861 | 10893 |
| 10862 begin_frame_args.frame_time = | 10894 begin_frame_args.frame_time = |
| 10863 start_time + base::TimeDelta::FromMilliseconds(250); | 10895 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10896 begin_frame_args.sequence_number++; |
| 10864 host_impl_->WillBeginImplFrame(begin_frame_args); | 10897 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10865 host_impl_->Animate(); | 10898 host_impl_->Animate(); |
| 10866 host_impl_->UpdateAnimationState(true); | 10899 host_impl_->UpdateAnimationState(true); |
| 10867 | 10900 |
| 10868 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10901 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10869 scrolling_layer->CurrentScrollOffset()); | 10902 scrolling_layer->CurrentScrollOffset()); |
| 10870 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10903 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 10871 host_impl_->DidFinishImplFrame(); | 10904 host_impl_->DidFinishImplFrame(); |
| 10872 } | 10905 } |
| 10873 | 10906 |
| 10874 // Test that smooth scrolls clamp correctly when bounds change mid-animation. | 10907 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
| 10875 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { | 10908 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
| 10876 const gfx::Size old_content_size(1000, 1000); | 10909 const gfx::Size old_content_size(1000, 1000); |
| 10877 const gfx::Size new_content_size(750, 750); | 10910 const gfx::Size new_content_size(750, 750); |
| 10878 const gfx::Size viewport_size(500, 500); | 10911 const gfx::Size viewport_size(500, 500); |
| 10879 | 10912 |
| 10880 LayerImpl* content_layer = | 10913 LayerImpl* content_layer = |
| 10881 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); | 10914 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
| 10882 | 10915 |
| 10883 DrawFrame(); | 10916 DrawFrame(); |
| 10884 | 10917 |
| 10885 base::TimeTicks start_time = | 10918 base::TimeTicks start_time = |
| 10886 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10919 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10887 BeginFrameArgs begin_frame_args = | 10920 BeginFrameArgs begin_frame_args = |
| 10888 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 10921 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10889 | 10922 |
| 10890 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); | 10923 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
| 10891 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10924 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 10892 | 10925 |
| 10893 begin_frame_args.frame_time = start_time; | 10926 begin_frame_args.frame_time = start_time; |
| 10927 begin_frame_args.sequence_number++; |
| 10894 host_impl_->WillBeginImplFrame(begin_frame_args); | 10928 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10895 host_impl_->Animate(); | 10929 host_impl_->Animate(); |
| 10896 host_impl_->UpdateAnimationState(true); | 10930 host_impl_->UpdateAnimationState(true); |
| 10897 host_impl_->DidFinishImplFrame(); | 10931 host_impl_->DidFinishImplFrame(); |
| 10898 | 10932 |
| 10899 content_layer->SetBounds(new_content_size); | 10933 content_layer->SetBounds(new_content_size); |
| 10900 scrolling_layer->SetBounds(new_content_size); | 10934 scrolling_layer->SetBounds(new_content_size); |
| 10901 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10935 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 10902 | 10936 |
| 10903 DrawFrame(); | 10937 DrawFrame(); |
| 10904 | 10938 |
| 10905 begin_frame_args.frame_time = | 10939 begin_frame_args.frame_time = |
| 10906 start_time + base::TimeDelta::FromMilliseconds(200); | 10940 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10941 begin_frame_args.sequence_number++; |
| 10907 host_impl_->WillBeginImplFrame(begin_frame_args); | 10942 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10908 host_impl_->Animate(); | 10943 host_impl_->Animate(); |
| 10909 host_impl_->UpdateAnimationState(true); | 10944 host_impl_->UpdateAnimationState(true); |
| 10910 host_impl_->DidFinishImplFrame(); | 10945 host_impl_->DidFinishImplFrame(); |
| 10911 | 10946 |
| 10912 EXPECT_EQ(gfx::ScrollOffset(250, 250), | 10947 EXPECT_EQ(gfx::ScrollOffset(250, 250), |
| 10913 scrolling_layer->CurrentScrollOffset()); | 10948 scrolling_layer->CurrentScrollOffset()); |
| 10914 } | 10949 } |
| 10915 | 10950 |
| 10916 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { | 10951 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11009 | 11044 |
| 11010 float page_scale_delta = 2.f; | 11045 float page_scale_delta = 2.f; |
| 11011 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 11046 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 11012 InputHandler::TOUCHSCREEN); | 11047 InputHandler::TOUCHSCREEN); |
| 11013 host_impl_->PinchGestureBegin(); | 11048 host_impl_->PinchGestureBegin(); |
| 11014 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 11049 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 11015 host_impl_->PinchGestureEnd(); | 11050 host_impl_->PinchGestureEnd(); |
| 11016 host_impl_->ScrollEnd(EndState().get()); | 11051 host_impl_->ScrollEnd(EndState().get()); |
| 11017 | 11052 |
| 11018 gfx::Vector2dF scroll_delta(0, 5); | 11053 gfx::Vector2dF scroll_delta(0, 5); |
| 11019 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 11054 EXPECT_EQ( |
| 11020 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 11055 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 11021 InputHandler::WHEEL) | 11056 host_impl_ |
| 11022 .thread); | 11057 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 11058 .thread); |
| 11023 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 11059 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 11024 | 11060 |
| 11025 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 11061 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 11026 host_impl_->ScrollEnd(EndState().get()); | 11062 host_impl_->ScrollEnd(EndState().get()); |
| 11027 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), | 11063 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
| 11028 scroll_layer->CurrentScrollOffset()); | 11064 scroll_layer->CurrentScrollOffset()); |
| 11029 } | 11065 } |
| 11030 } | 11066 } |
| 11031 | 11067 |
| 11032 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 11068 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11186 | 11222 |
| 11187 bool did_draw_frame() const { return did_draw_frame_; } | 11223 bool did_draw_frame() const { return did_draw_frame_; } |
| 11188 | 11224 |
| 11189 private: | 11225 private: |
| 11190 BeginFrameArgs begin_frame_args_; | 11226 BeginFrameArgs begin_frame_args_; |
| 11191 bool did_draw_frame_ = false; | 11227 bool did_draw_frame_ = false; |
| 11192 }; | 11228 }; |
| 11193 | 11229 |
| 11194 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { | 11230 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { |
| 11195 BeginFrameArgs begin_frame_args = | 11231 BeginFrameArgs begin_frame_args = |
| 11196 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11232 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
| 11197 FakeVideoFrameController controller; | 11233 FakeVideoFrameController controller; |
| 11198 | 11234 |
| 11199 host_impl_->WillBeginImplFrame(begin_frame_args); | 11235 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 11200 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11236 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
| 11201 host_impl_->AddVideoFrameController(&controller); | 11237 host_impl_->AddVideoFrameController(&controller); |
| 11202 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 11238 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
| 11203 host_impl_->DidFinishImplFrame(); | 11239 host_impl_->DidFinishImplFrame(); |
| 11204 | 11240 |
| 11205 EXPECT_FALSE(controller.did_draw_frame()); | 11241 EXPECT_FALSE(controller.did_draw_frame()); |
| 11206 LayerTreeHostImpl::FrameData frame; | 11242 LayerTreeHostImpl::FrameData frame; |
| 11207 host_impl_->DidDrawAllLayers(frame); | 11243 host_impl_->DidDrawAllLayers(frame); |
| 11208 EXPECT_TRUE(controller.did_draw_frame()); | 11244 EXPECT_TRUE(controller.did_draw_frame()); |
| 11209 | 11245 |
| 11210 controller.OnBeginFrame(begin_frame_args); | 11246 controller.OnBeginFrame(begin_frame_args); |
| 11211 EXPECT_FALSE(controller.did_draw_frame()); | 11247 EXPECT_FALSE(controller.did_draw_frame()); |
| 11212 host_impl_->RemoveVideoFrameController(&controller); | 11248 host_impl_->RemoveVideoFrameController(&controller); |
| 11213 host_impl_->DidDrawAllLayers(frame); | 11249 host_impl_->DidDrawAllLayers(frame); |
| 11214 EXPECT_FALSE(controller.did_draw_frame()); | 11250 EXPECT_FALSE(controller.did_draw_frame()); |
| 11215 } | 11251 } |
| 11216 | 11252 |
| 11217 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { | 11253 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { |
| 11218 BeginFrameArgs begin_frame_args = | 11254 BeginFrameArgs begin_frame_args = |
| 11219 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11255 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2); |
| 11220 FakeVideoFrameController controller; | 11256 FakeVideoFrameController controller; |
| 11221 | 11257 |
| 11222 host_impl_->WillBeginImplFrame(begin_frame_args); | 11258 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 11223 host_impl_->DidFinishImplFrame(); | 11259 host_impl_->DidFinishImplFrame(); |
| 11224 | 11260 |
| 11225 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11261 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
| 11226 host_impl_->AddVideoFrameController(&controller); | 11262 host_impl_->AddVideoFrameController(&controller); |
| 11227 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11263 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
| 11228 | 11264 |
| 11229 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); | 11265 begin_frame_args = CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 3); |
| 11230 EXPECT_FALSE(controller.begin_frame_args().IsValid()); | 11266 EXPECT_FALSE(controller.begin_frame_args().IsValid()); |
| 11231 host_impl_->WillBeginImplFrame(begin_frame_args); | 11267 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 11232 EXPECT_TRUE(controller.begin_frame_args().IsValid()); | 11268 EXPECT_TRUE(controller.begin_frame_args().IsValid()); |
| 11233 | 11269 |
| 11234 EXPECT_FALSE(controller.did_draw_frame()); | 11270 EXPECT_FALSE(controller.did_draw_frame()); |
| 11235 LayerTreeHostImpl::FrameData frame; | 11271 LayerTreeHostImpl::FrameData frame; |
| 11236 host_impl_->DidDrawAllLayers(frame); | 11272 host_impl_->DidDrawAllLayers(frame); |
| 11237 EXPECT_TRUE(controller.did_draw_frame()); | 11273 EXPECT_TRUE(controller.did_draw_frame()); |
| 11238 | 11274 |
| 11239 controller.OnBeginFrame(begin_frame_args); | 11275 controller.OnBeginFrame(begin_frame_args); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11731 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11767 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11732 host_impl_->MouseMoveAt(gfx::Point(10, 150)); | 11768 host_impl_->MouseMoveAt(gfx::Point(10, 150)); |
| 11733 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); | 11769 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_near_scrollbar()); |
| 11734 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); | 11770 EXPECT_TRUE(scrollbar_1_animation_controller->mouse_is_over_scrollbar()); |
| 11735 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); | 11771 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_near_scrollbar()); |
| 11736 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); | 11772 EXPECT_FALSE(scrollbar_2_animation_controller->mouse_is_over_scrollbar()); |
| 11737 } | 11773 } |
| 11738 | 11774 |
| 11739 } // namespace | 11775 } // namespace |
| 11740 } // namespace cc | 11776 } // namespace cc |
| OLD | NEW |