| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "cc/test/layer_test_common.h" | 59 #include "cc/test/layer_test_common.h" |
| 60 #include "cc/test/layer_tree_test.h" | 60 #include "cc/test/layer_tree_test.h" |
| 61 #include "cc/test/skia_common.h" | 61 #include "cc/test/skia_common.h" |
| 62 #include "cc/test/test_compositor_frame_sink.h" | 62 #include "cc/test/test_compositor_frame_sink.h" |
| 63 #include "cc/test/test_task_graph_runner.h" | 63 #include "cc/test/test_task_graph_runner.h" |
| 64 #include "cc/test/test_web_graphics_context_3d.h" | 64 #include "cc/test/test_web_graphics_context_3d.h" |
| 65 #include "cc/trees/effect_node.h" | 65 #include "cc/trees/effect_node.h" |
| 66 #include "cc/trees/layer_tree_host_common.h" | 66 #include "cc/trees/layer_tree_host_common.h" |
| 67 #include "cc/trees/layer_tree_impl.h" | 67 #include "cc/trees/layer_tree_impl.h" |
| 68 #include "cc/trees/mutator_host.h" | 68 #include "cc/trees/mutator_host.h" |
| 69 #include "cc/trees/scroll_node.h" |
| 69 #include "cc/trees/single_thread_proxy.h" | 70 #include "cc/trees/single_thread_proxy.h" |
| 70 #include "cc/trees/transform_node.h" | 71 #include "cc/trees/transform_node.h" |
| 71 #include "media/base/media.h" | 72 #include "media/base/media.h" |
| 72 #include "testing/gmock/include/gmock/gmock.h" | 73 #include "testing/gmock/include/gmock/gmock.h" |
| 73 #include "testing/gtest/include/gtest/gtest.h" | 74 #include "testing/gtest/include/gtest/gtest.h" |
| 74 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 75 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| 75 #include "ui/gfx/geometry/rect_conversions.h" | 76 #include "ui/gfx/geometry/rect_conversions.h" |
| 76 #include "ui/gfx/geometry/size_conversions.h" | 77 #include "ui/gfx/geometry/size_conversions.h" |
| 77 #include "ui/gfx/geometry/vector2d_conversions.h" | 78 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 78 | 79 |
| (...skipping 4142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4221 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 4222 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 4222 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 4223 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
| 4223 | 4224 |
| 4224 host_impl_->ScrollEnd(EndState().get()); | 4225 host_impl_->ScrollEnd(EndState().get()); |
| 4225 | 4226 |
| 4226 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4227 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4227 host_impl_ | 4228 host_impl_ |
| 4228 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4229 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4229 InputHandler::TOUCHSCREEN) | 4230 InputHandler::TOUCHSCREEN) |
| 4230 .thread); | 4231 .thread); |
| 4231 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), outer_scroll); | 4232 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 4233 outer_scroll->scroll_tree_index()); |
| 4232 | 4234 |
| 4233 host_impl_->ScrollBy( | 4235 host_impl_->ScrollBy( |
| 4234 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); | 4236 UpdateState(gfx::Point(), gfx::Vector2dF(0.f, -50.f)).get()); |
| 4235 | 4237 |
| 4236 // The entire scroll delta should have been used to show the browser controls. | 4238 // The entire scroll delta should have been used to show the browser controls. |
| 4237 // The outer viewport should be resized to accomodate and scrolled to the | 4239 // The outer viewport should be resized to accomodate and scrolled to the |
| 4238 // bottom of the document to keep the viewport in place. | 4240 // bottom of the document to keep the viewport in place. |
| 4239 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); | 4241 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentBrowserControlsShownRatio()); |
| 4240 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 4242 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
| 4241 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 4243 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4689 // Send a gesture scroll that will scroll the outer viewport, make sure the | 4691 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 4690 // browser controls get scrolled. | 4692 // browser controls get scrolled. |
| 4691 gfx::Vector2dF scroll_delta(0.f, 15.f); | 4693 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 4692 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4694 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4693 host_impl_ | 4695 host_impl_ |
| 4694 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4696 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4695 InputHandler::TOUCHSCREEN) | 4697 InputHandler::TOUCHSCREEN) |
| 4696 .thread); | 4698 .thread); |
| 4697 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4699 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4698 | 4700 |
| 4699 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 4701 EXPECT_EQ(host_impl_->OuterViewportScrollLayer()->scroll_tree_index(), |
| 4700 host_impl_->CurrentlyScrollingLayer()); | 4702 host_impl_->CurrentlyScrollingNode()->id); |
| 4701 host_impl_->ScrollEnd(EndState().get()); | 4703 host_impl_->ScrollEnd(EndState().get()); |
| 4702 | 4704 |
| 4703 EXPECT_FLOAT_EQ( | 4705 EXPECT_FLOAT_EQ( |
| 4704 scroll_delta.y(), | 4706 scroll_delta.y(), |
| 4705 top_controls_height_ - | 4707 top_controls_height_ - |
| 4706 host_impl_->browser_controls_manager()->ContentTopOffset()); | 4708 host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4707 | 4709 |
| 4708 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 4710 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 4709 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4711 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4710 host_impl_ | 4712 host_impl_ |
| 4711 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4713 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4712 InputHandler::TOUCHSCREEN) | 4714 InputHandler::TOUCHSCREEN) |
| 4713 .thread); | 4715 .thread); |
| 4714 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 4716 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 4715 | 4717 |
| 4716 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ContentTopOffset()); | 4718 EXPECT_EQ(0, host_impl_->browser_controls_manager()->ContentTopOffset()); |
| 4717 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 4719 EXPECT_EQ(host_impl_->OuterViewportScrollLayer()->scroll_tree_index(), |
| 4718 host_impl_->CurrentlyScrollingLayer()); | 4720 host_impl_->CurrentlyScrollingNode()->id); |
| 4719 | 4721 |
| 4720 host_impl_->ScrollEnd(EndState().get()); | 4722 host_impl_->ScrollEnd(EndState().get()); |
| 4721 | 4723 |
| 4722 // Position the viewports such that the inner viewport will be scrolled. | 4724 // Position the viewports such that the inner viewport will be scrolled. |
| 4723 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 4725 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 4724 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), | 4726 SetScrollOffsetDelta(host_impl_->OuterViewportScrollLayer(), |
| 4725 gfx::Vector2dF()); | 4727 gfx::Vector2dF()); |
| 4726 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), | 4728 SetScrollOffsetDelta(host_impl_->InnerViewportScrollLayer(), |
| 4727 inner_viewport_offset); | 4729 inner_viewport_offset); |
| 4728 | 4730 |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5415 // The child should not have scrolled. | 5417 // The child should not have scrolled. |
| 5416 ExpectNone(*scroll_info.get(), child->id()); | 5418 ExpectNone(*scroll_info.get(), child->id()); |
| 5417 | 5419 |
| 5418 // The next time we scroll we should only scroll the parent. | 5420 // The next time we scroll we should only scroll the parent. |
| 5419 scroll_delta = gfx::Vector2d(0, -3); | 5421 scroll_delta = gfx::Vector2d(0, -3); |
| 5420 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5422 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5421 host_impl_ | 5423 host_impl_ |
| 5422 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5424 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5423 InputHandler::NON_BUBBLING_GESTURE) | 5425 InputHandler::NON_BUBBLING_GESTURE) |
| 5424 .thread); | 5426 .thread); |
| 5425 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5427 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 5428 grand_child->scroll_tree_index()); |
| 5426 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5429 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5427 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 5430 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 5431 child->scroll_tree_index()); |
| 5428 host_impl_->ScrollEnd(EndState().get()); | 5432 host_impl_->ScrollEnd(EndState().get()); |
| 5429 | 5433 |
| 5430 scroll_info = host_impl_->ProcessScrollDeltas(); | 5434 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5431 | 5435 |
| 5432 // The child should have scrolled up to its limit. | 5436 // The child should have scrolled up to its limit. |
| 5433 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 5437 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), |
| 5434 gfx::Vector2d(0, -3))); | 5438 gfx::Vector2d(0, -3))); |
| 5435 | 5439 |
| 5436 // The grand child should not have scrolled. | 5440 // The grand child should not have scrolled. |
| 5437 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5441 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5438 gfx::Vector2d(0, -2))); | 5442 gfx::Vector2d(0, -2))); |
| 5439 | 5443 |
| 5440 // After scrolling the parent, another scroll on the opposite direction | 5444 // After scrolling the parent, another scroll on the opposite direction |
| 5441 // should still scroll the child. | 5445 // should still scroll the child. |
| 5442 scroll_delta = gfx::Vector2d(0, 7); | 5446 scroll_delta = gfx::Vector2d(0, 7); |
| 5443 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5447 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5444 host_impl_ | 5448 host_impl_ |
| 5445 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5449 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 5446 InputHandler::NON_BUBBLING_GESTURE) | 5450 InputHandler::NON_BUBBLING_GESTURE) |
| 5447 .thread); | 5451 .thread); |
| 5448 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5452 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 5453 grand_child->scroll_tree_index()); |
| 5449 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5454 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5450 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 5455 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 5456 grand_child->scroll_tree_index()); |
| 5451 host_impl_->ScrollEnd(EndState().get()); | 5457 host_impl_->ScrollEnd(EndState().get()); |
| 5452 | 5458 |
| 5453 scroll_info = host_impl_->ProcessScrollDeltas(); | 5459 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5454 | 5460 |
| 5455 // The grand child should have scrolled. | 5461 // The grand child should have scrolled. |
| 5456 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5462 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5457 gfx::Vector2d(0, 5))); | 5463 gfx::Vector2d(0, 5))); |
| 5458 | 5464 |
| 5459 // The child should not have scrolled. | 5465 // The child should not have scrolled. |
| 5460 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), | 5466 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), child->id(), |
| 5461 gfx::Vector2d(0, -3))); | 5467 gfx::Vector2d(0, -3))); |
| 5462 | 5468 |
| 5463 // Scrolling should be adjusted from viewport space. | 5469 // Scrolling should be adjusted from viewport space. |
| 5464 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); | 5470 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); |
| 5465 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); | 5471 host_impl_->active_tree()->SetPageScaleOnActiveTree(2.f); |
| 5466 | 5472 |
| 5467 scroll_delta = gfx::Vector2d(0, -2); | 5473 scroll_delta = gfx::Vector2d(0, -2); |
| 5468 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5474 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5469 host_impl_ | 5475 host_impl_ |
| 5470 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), | 5476 ->ScrollBegin(BeginState(gfx::Point(1, 1)).get(), |
| 5471 InputHandler::NON_BUBBLING_GESTURE) | 5477 InputHandler::NON_BUBBLING_GESTURE) |
| 5472 .thread); | 5478 .thread); |
| 5473 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); | 5479 EXPECT_EQ(grand_child->scroll_tree_index(), |
| 5480 host_impl_->CurrentlyScrollingNode()->id); |
| 5474 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5481 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5475 host_impl_->ScrollEnd(EndState().get()); | 5482 host_impl_->ScrollEnd(EndState().get()); |
| 5476 | 5483 |
| 5477 scroll_info = host_impl_->ProcessScrollDeltas(); | 5484 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 5478 | 5485 |
| 5479 // Should have scrolled by half the amount in layer space (5 - 2/2) | 5486 // Should have scrolled by half the amount in layer space (5 - 2/2) |
| 5480 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5487 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5481 gfx::Vector2d(0, 4))); | 5488 gfx::Vector2d(0, 4))); |
| 5482 } | 5489 } |
| 5483 } | 5490 } |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6259 host_impl_->ScrollEnd(EndState().get()); | 6266 host_impl_->ScrollEnd(EndState().get()); |
| 6260 | 6267 |
| 6261 // The next time we scroll we should only scroll the parent, but overscroll | 6268 // The next time we scroll we should only scroll the parent, but overscroll |
| 6262 // should still not reach the root layer. | 6269 // should still not reach the root layer. |
| 6263 scroll_delta = gfx::Vector2d(0, -30); | 6270 scroll_delta = gfx::Vector2d(0, -30); |
| 6264 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6271 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6265 host_impl_ | 6272 host_impl_ |
| 6266 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6273 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6267 InputHandler::NON_BUBBLING_GESTURE) | 6274 InputHandler::NON_BUBBLING_GESTURE) |
| 6268 .thread); | 6275 .thread); |
| 6269 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6276 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 6277 grand_child_layer->scroll_tree_index()); |
| 6270 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6278 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6271 host_impl_->ScrollEnd(EndState().get()); | 6279 host_impl_->ScrollEnd(EndState().get()); |
| 6272 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6280 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6273 host_impl_ | 6281 host_impl_ |
| 6274 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6282 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6275 InputHandler::NON_BUBBLING_GESTURE) | 6283 InputHandler::NON_BUBBLING_GESTURE) |
| 6276 .thread); | 6284 .thread); |
| 6277 scroll_result = | 6285 scroll_result = |
| 6278 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6286 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6279 EXPECT_TRUE(scroll_result.did_scroll); | 6287 EXPECT_TRUE(scroll_result.did_scroll); |
| 6280 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6288 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6281 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer()->id(), child_layer->id()); | 6289 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 6290 child_layer->scroll_tree_index()); |
| 6282 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6291 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6283 host_impl_->ScrollEnd(EndState().get()); | 6292 host_impl_->ScrollEnd(EndState().get()); |
| 6284 | 6293 |
| 6285 // After scrolling the parent, another scroll on the opposite direction | 6294 // After scrolling the parent, another scroll on the opposite direction |
| 6286 // should scroll the child. | 6295 // should scroll the child. |
| 6287 scroll_delta = gfx::Vector2d(0, 70); | 6296 scroll_delta = gfx::Vector2d(0, 70); |
| 6288 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6297 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 6289 host_impl_ | 6298 host_impl_ |
| 6290 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 6299 ->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 6291 InputHandler::NON_BUBBLING_GESTURE) | 6300 InputHandler::NON_BUBBLING_GESTURE) |
| 6292 .thread); | 6301 .thread); |
| 6293 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6302 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 6303 grand_child_layer->scroll_tree_index()); |
| 6294 scroll_result = | 6304 scroll_result = |
| 6295 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 6305 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 6296 EXPECT_TRUE(scroll_result.did_scroll); | 6306 EXPECT_TRUE(scroll_result.did_scroll); |
| 6297 EXPECT_FALSE(scroll_result.did_overscroll_root); | 6307 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 6298 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 6308 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 6309 grand_child_layer->scroll_tree_index()); |
| 6299 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6310 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6300 host_impl_->ScrollEnd(EndState().get()); | 6311 host_impl_->ScrollEnd(EndState().get()); |
| 6301 } | 6312 } |
| 6302 } | 6313 } |
| 6303 | 6314 |
| 6304 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 6315 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 6305 // When we try to scroll a non-scrollable child layer, the scroll delta | 6316 // When we try to scroll a non-scrollable child layer, the scroll delta |
| 6306 // should be applied to one of its ancestors if possible. Overscroll should | 6317 // should be applied to one of its ancestors if possible. Overscroll should |
| 6307 // be reflected only when it has bubbled up to the root scrolling layer. | 6318 // be reflected only when it has bubbled up to the root scrolling layer. |
| 6308 InputHandlerScrollResult scroll_result; | 6319 InputHandlerScrollResult scroll_result; |
| (...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8591 .thread); | 8602 .thread); |
| 8592 EXPECT_TRUE( | 8603 EXPECT_TRUE( |
| 8593 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8604 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8594 .did_scroll); | 8605 .did_scroll); |
| 8595 | 8606 |
| 8596 // The grand child should have scrolled up to its limit. | 8607 // The grand child should have scrolled up to its limit. |
| 8597 scroll_info = host_impl_->ProcessScrollDeltas(); | 8608 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 8598 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 8609 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 8599 EXPECT_TRUE( | 8610 EXPECT_TRUE( |
| 8600 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 8611 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| 8601 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 8612 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 8613 grand_child->scroll_tree_index()); |
| 8602 | 8614 |
| 8603 // The locked scrolling layer should remain set as the grand child. | 8615 // The locked scrolling layer should remain set as the grand child. |
| 8604 EXPECT_FALSE( | 8616 EXPECT_FALSE( |
| 8605 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8617 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8606 .did_scroll); | 8618 .did_scroll); |
| 8607 scroll_info = host_impl_->ProcessScrollDeltas(); | 8619 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 8608 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 8620 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 8609 EXPECT_TRUE( | 8621 EXPECT_TRUE( |
| 8610 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 8622 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| 8611 ExpectNone(*scroll_info, child->id()); | 8623 ExpectNone(*scroll_info, child->id()); |
| 8612 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 8624 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 8625 grand_child->scroll_tree_index()); |
| 8613 | 8626 |
| 8614 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 8627 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8615 host_impl_->FlingScrollBegin().thread); | 8628 host_impl_->FlingScrollBegin().thread); |
| 8616 EXPECT_FALSE( | 8629 EXPECT_FALSE( |
| 8617 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8630 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8618 .did_scroll); | 8631 .did_scroll); |
| 8619 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 8632 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 8633 grand_child->scroll_tree_index()); |
| 8620 | 8634 |
| 8621 // The child should not have scrolled. | 8635 // The child should not have scrolled. |
| 8622 scroll_info = host_impl_->ProcessScrollDeltas(); | 8636 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 8623 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 8637 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 8624 EXPECT_TRUE( | 8638 EXPECT_TRUE( |
| 8625 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); | 8639 ScrollInfoContains(*scroll_info, grand_child->id(), scroll_delta)); |
| 8626 ExpectNone(*scroll_info, child->id()); | 8640 ExpectNone(*scroll_info, child->id()); |
| 8627 | 8641 |
| 8628 // As the locked layer is at it's limit, no further scrolling can occur. | 8642 // As the locked layer is at it's limit, no further scrolling can occur. |
| 8629 EXPECT_FALSE( | 8643 EXPECT_FALSE( |
| 8630 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 8644 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 8631 .did_scroll); | 8645 .did_scroll); |
| 8632 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 8646 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 8647 grand_child->scroll_tree_index()); |
| 8633 host_impl_->ScrollEnd(EndState().get()); | 8648 host_impl_->ScrollEnd(EndState().get()); |
| 8634 } | 8649 } |
| 8635 } | 8650 } |
| 8636 | 8651 |
| 8637 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { | 8652 TEST_F(LayerTreeHostImplTest, WheelFlingShouldntBubble) { |
| 8638 // When flinging via wheel, we shouldn't bubble. | 8653 // When flinging via wheel, we shouldn't bubble. |
| 8639 gfx::Size surface_size(10, 10); | 8654 gfx::Size surface_size(10, 10); |
| 8640 gfx::Size content_size(20, 20); | 8655 gfx::Size content_size(20, 20); |
| 8641 LayerImpl* root_clip = | 8656 LayerImpl* root_clip = |
| 8642 CreateBasicVirtualViewportLayers(surface_size, surface_size); | 8657 CreateBasicVirtualViewportLayers(surface_size, surface_size); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8779 DrawFrame(); | 8794 DrawFrame(); |
| 8780 | 8795 |
| 8781 // We should have scrolled |child_scroll| even though it does not move | 8796 // We should have scrolled |child_scroll| even though it does not move |
| 8782 // any layer that is a drawn RSLL member. | 8797 // any layer that is a drawn RSLL member. |
| 8783 EXPECT_EQ( | 8798 EXPECT_EQ( |
| 8784 InputHandler::SCROLL_ON_IMPL_THREAD, | 8799 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 8785 host_impl_ | 8800 host_impl_ |
| 8786 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) | 8801 ->ScrollBegin(BeginState(gfx::Point()).get(), InputHandler::WHEEL) |
| 8787 .thread); | 8802 .thread); |
| 8788 | 8803 |
| 8789 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 8804 EXPECT_EQ(host_impl_->active_tree()->LayerById(7)->scroll_tree_index(), |
| 8805 host_impl_->CurrentlyScrollingNode()->id); |
| 8790 } | 8806 } |
| 8791 | 8807 |
| 8792 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 8808 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 8793 // in CompositorFrameMetadata. | 8809 // in CompositorFrameMetadata. |
| 8794 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 8810 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 8795 std::unique_ptr<SolidColorLayerImpl> root = | 8811 std::unique_ptr<SolidColorLayerImpl> root = |
| 8796 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 8812 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 8797 root->SetPosition(gfx::PointF()); | 8813 root->SetPosition(gfx::PointF()); |
| 8798 root->SetBounds(gfx::Size(10, 10)); | 8814 root->SetBounds(gfx::Size(10, 10)); |
| 8799 root->SetDrawsContent(true); | 8815 root->SetDrawsContent(true); |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9679 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9695 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9680 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9696 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9681 | 9697 |
| 9682 // Scrolling the viewport always sets the outer scroll layer as the | 9698 // Scrolling the viewport always sets the outer scroll layer as the |
| 9683 // currently scrolling layer. | 9699 // currently scrolling layer. |
| 9684 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9700 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9685 host_impl_ | 9701 host_impl_ |
| 9686 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9702 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9687 InputHandler::TOUCHSCREEN) | 9703 InputHandler::TOUCHSCREEN) |
| 9688 .thread); | 9704 .thread); |
| 9689 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9705 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9706 host_impl_->CurrentlyScrollingNode()->id); |
| 9690 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9707 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9691 host_impl_->FlingScrollBegin().thread); | 9708 host_impl_->FlingScrollBegin().thread); |
| 9692 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9709 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9710 host_impl_->CurrentlyScrollingNode()->id); |
| 9693 | 9711 |
| 9694 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, | 9712 gfx::Vector2d scroll_delta(inner_viewport.width() / 2.f, |
| 9695 inner_viewport.height() / 2.f); | 9713 inner_viewport.height() / 2.f); |
| 9696 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9714 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9697 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9715 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9698 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9716 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9717 host_impl_->CurrentlyScrollingNode()->id); |
| 9699 | 9718 |
| 9700 host_impl_->ScrollEnd(EndState().get()); | 9719 host_impl_->ScrollEnd(EndState().get()); |
| 9701 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9720 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 9702 | 9721 |
| 9703 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9722 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9704 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9723 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9705 | 9724 |
| 9706 // Fling past the inner viewport boundry, make sure outer viewport scrolls. | 9725 // Fling past the inner viewport boundry, make sure outer viewport scrolls. |
| 9707 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9726 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9708 host_impl_ | 9727 host_impl_ |
| 9709 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9728 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9710 InputHandler::TOUCHSCREEN) | 9729 InputHandler::TOUCHSCREEN) |
| 9711 .thread); | 9730 .thread); |
| 9712 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9731 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9732 host_impl_->CurrentlyScrollingNode()->id); |
| 9713 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9733 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9714 host_impl_->FlingScrollBegin().thread); | 9734 host_impl_->FlingScrollBegin().thread); |
| 9715 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9735 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9736 host_impl_->CurrentlyScrollingNode()->id); |
| 9716 | 9737 |
| 9717 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9738 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9718 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9739 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9719 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9740 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9741 host_impl_->CurrentlyScrollingNode()->id); |
| 9720 | 9742 |
| 9721 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 9743 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 9722 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 9744 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 9723 EXPECT_EQ(outer_scroll, host_impl_->CurrentlyScrollingLayer()); | 9745 EXPECT_EQ(outer_scroll->scroll_tree_index(), |
| 9746 host_impl_->CurrentlyScrollingNode()->id); |
| 9724 | 9747 |
| 9725 host_impl_->ScrollEnd(EndState().get()); | 9748 host_impl_->ScrollEnd(EndState().get()); |
| 9726 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingLayer()); | 9749 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 9727 | 9750 |
| 9728 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 9751 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 9729 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 9752 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 9730 } | 9753 } |
| 9731 } | 9754 } |
| 9732 | 9755 |
| 9733 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9756 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9734 DiagonalScrollBubblesPerfectlyToInner) { | 9757 DiagonalScrollBubblesPerfectlyToInner) { |
| 9735 gfx::Size content_size = gfx::Size(200, 320); | 9758 gfx::Size content_size = gfx::Size(200, 320); |
| 9736 gfx::Size outer_viewport = gfx::Size(100, 160); | 9759 gfx::Size outer_viewport = gfx::Size(100, 160); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9820 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9843 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 9821 .did_scroll); | 9844 .did_scroll); |
| 9822 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 9845 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9823 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9846 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9824 | 9847 |
| 9825 // The child should have scrolled up to its limit. | 9848 // The child should have scrolled up to its limit. |
| 9826 scroll_info = host_impl_->ProcessScrollDeltas(); | 9849 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 9827 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 9850 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 9828 EXPECT_TRUE( | 9851 EXPECT_TRUE( |
| 9829 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 9852 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 9830 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9853 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 9854 child_scroll->scroll_tree_index()); |
| 9831 | 9855 |
| 9832 // The fling have no effect on the currently scrolling layer. | 9856 // The fling have no effect on the currently scrolling layer. |
| 9833 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9857 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9834 host_impl_->FlingScrollBegin().thread); | 9858 host_impl_->FlingScrollBegin().thread); |
| 9835 EXPECT_FALSE( | 9859 EXPECT_FALSE( |
| 9836 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9860 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 9837 .did_scroll); | 9861 .did_scroll); |
| 9838 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9862 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 9863 child_scroll->scroll_tree_index()); |
| 9839 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( | 9864 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9840 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9865 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9841 | 9866 |
| 9842 // The inner viewport shouldn't have scrolled. | 9867 // The inner viewport shouldn't have scrolled. |
| 9843 scroll_info = host_impl_->ProcessScrollDeltas(); | 9868 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 9844 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 9869 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 9845 EXPECT_TRUE( | 9870 EXPECT_TRUE( |
| 9846 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); | 9871 ScrollInfoContains(*scroll_info, child_scroll->id(), scroll_delta)); |
| 9847 ExpectNone(*scroll_info, inner_scroll->id()); | 9872 ExpectNone(*scroll_info, inner_scroll->id()); |
| 9848 | 9873 |
| 9849 // As the locked layer is at its limit, no further scrolling can occur. | 9874 // As the locked layer is at its limit, no further scrolling can occur. |
| 9850 EXPECT_FALSE( | 9875 EXPECT_FALSE( |
| 9851 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 9876 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 9852 .did_scroll); | 9877 .did_scroll); |
| 9853 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9878 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 9879 child_scroll->scroll_tree_index()); |
| 9854 host_impl_->ScrollEnd(EndState().get()); | 9880 host_impl_->ScrollEnd(EndState().get()); |
| 9855 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( | 9881 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt( |
| 9856 gfx::Point(), InputHandler::TOUCHSCREEN)); | 9882 gfx::Point(), InputHandler::TOUCHSCREEN)); |
| 9857 } | 9883 } |
| 9858 } | 9884 } |
| 9859 | 9885 |
| 9860 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9886 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9861 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { | 9887 ScrollBeginEventThatTargetsViewportLayerSkipsHitTest) { |
| 9862 gfx::Size content_size = gfx::Size(100, 160); | 9888 gfx::Size content_size = gfx::Size(100, 160); |
| 9863 gfx::Size outer_viewport = gfx::Size(50, 80); | 9889 gfx::Size outer_viewport = gfx::Size(50, 80); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 9874 std::move(child)); | 9900 std::move(child)); |
| 9875 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 9901 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 9876 | 9902 |
| 9877 DrawFrame(); | 9903 DrawFrame(); |
| 9878 | 9904 |
| 9879 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9905 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9880 host_impl_ | 9906 host_impl_ |
| 9881 ->RootScrollBegin(BeginState(gfx::Point()).get(), | 9907 ->RootScrollBegin(BeginState(gfx::Point()).get(), |
| 9882 InputHandler::TOUCHSCREEN) | 9908 InputHandler::TOUCHSCREEN) |
| 9883 .thread); | 9909 .thread); |
| 9884 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), | 9910 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 9885 host_impl_->ViewportMainScrollLayer()); | 9911 host_impl_->ViewportMainScrollLayer()->scroll_tree_index()); |
| 9886 host_impl_->ScrollEnd(EndState().get()); | 9912 host_impl_->ScrollEnd(EndState().get()); |
| 9887 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9913 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9888 host_impl_ | 9914 host_impl_ |
| 9889 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9915 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 9890 InputHandler::TOUCHSCREEN) | 9916 InputHandler::TOUCHSCREEN) |
| 9891 .thread); | 9917 .thread); |
| 9892 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 9918 EXPECT_EQ(host_impl_->CurrentlyScrollingNode()->id, |
| 9919 child_scroll->scroll_tree_index()); |
| 9893 host_impl_->ScrollEnd(EndState().get()); | 9920 host_impl_->ScrollEnd(EndState().get()); |
| 9894 } | 9921 } |
| 9895 | 9922 |
| 9896 TEST_F(LayerTreeHostImplVirtualViewportTest, | 9923 TEST_F(LayerTreeHostImplVirtualViewportTest, |
| 9897 NoOverscrollWhenInnerViewportCantScroll) { | 9924 NoOverscrollWhenInnerViewportCantScroll) { |
| 9898 InputHandlerScrollResult scroll_result; | 9925 InputHandlerScrollResult scroll_result; |
| 9899 gfx::Size content_size = gfx::Size(100, 160); | 9926 gfx::Size content_size = gfx::Size(100, 160); |
| 9900 gfx::Size outer_viewport = gfx::Size(50, 80); | 9927 gfx::Size outer_viewport = gfx::Size(50, 80); |
| 9901 gfx::Size inner_viewport = gfx::Size(25, 40); | 9928 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 9902 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9929 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10065 EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER, | 10092 EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER, |
| 10066 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10))); | 10093 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(10, 10))); |
| 10067 // Flinging the child layer. | 10094 // Flinging the child layer. |
| 10068 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10095 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10069 host_impl_ | 10096 host_impl_ |
| 10070 ->ScrollBegin(BeginState(gfx::Point(60, 60)).get(), | 10097 ->ScrollBegin(BeginState(gfx::Point(60, 60)).get(), |
| 10071 InputHandler::TOUCHSCREEN) | 10098 InputHandler::TOUCHSCREEN) |
| 10072 .thread); | 10099 .thread); |
| 10073 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10100 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10074 host_impl_->FlingScrollBegin().thread); | 10101 host_impl_->FlingScrollBegin().thread); |
| 10075 EXPECT_EQ(child_layer, host_impl_->CurrentlyScrollingLayer()); | 10102 EXPECT_EQ(child_layer->scroll_tree_index(), |
| 10103 host_impl_->CurrentlyScrollingNode()->id); |
| 10076 // Touch on the child layer, which is an active fling layer, the touch | 10104 // Touch on the child layer, which is an active fling layer, the touch |
| 10077 // event handler will force to be passive. | 10105 // event handler will force to be passive. |
| 10078 EXPECT_EQ( | 10106 EXPECT_EQ( |
| 10079 InputHandler::TouchStartEventListenerType::HANDLER_ON_SCROLLING_LAYER, | 10107 InputHandler::TouchStartEventListenerType::HANDLER_ON_SCROLLING_LAYER, |
| 10080 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(70, 80))); | 10108 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(70, 80))); |
| 10081 // Touch on the grand child layer, which is a descendant of an active fling | 10109 // Touch on the grand child layer, which is a descendant of an active fling |
| 10082 // layer, the touch event handler will force to be passive. | 10110 // layer, the touch event handler will force to be passive. |
| 10083 EXPECT_EQ( | 10111 EXPECT_EQ( |
| 10084 InputHandler::TouchStartEventListenerType::HANDLER_ON_SCROLLING_LAYER, | 10112 InputHandler::TouchStartEventListenerType::HANDLER_ON_SCROLLING_LAYER, |
| 10085 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(20, 30))); | 10113 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(20, 30))); |
| 10086 | 10114 |
| 10087 // Now flinging on the grand child layer. | 10115 // Now flinging on the grand child layer. |
| 10088 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10116 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10089 host_impl_ | 10117 host_impl_ |
| 10090 ->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), | 10118 ->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), |
| 10091 InputHandler::TOUCHSCREEN) | 10119 InputHandler::TOUCHSCREEN) |
| 10092 .thread); | 10120 .thread); |
| 10093 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10121 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10094 host_impl_->FlingScrollBegin().thread); | 10122 host_impl_->FlingScrollBegin().thread); |
| 10095 EXPECT_EQ(grand_child_layer, host_impl_->CurrentlyScrollingLayer()); | 10123 EXPECT_EQ(grand_child_layer->scroll_tree_index(), |
| 10124 host_impl_->CurrentlyScrollingNode()->id); |
| 10096 // Touch on the child layer, the touch event handler will still be blocking. | 10125 // Touch on the child layer, the touch event handler will still be blocking. |
| 10097 EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER, | 10126 EXPECT_EQ(InputHandler::TouchStartEventListenerType::HANDLER, |
| 10098 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(60, 60))); | 10127 host_impl_->EventListenerTypeForTouchStartAt(gfx::Point(60, 60))); |
| 10099 } | 10128 } |
| 10100 } | 10129 } |
| 10101 | 10130 |
| 10102 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { | 10131 class ResourcelessSoftwareLayerTreeHostImplTest : public LayerTreeHostImplTest { |
| 10103 protected: | 10132 protected: |
| 10104 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { | 10133 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
| 10105 return FakeCompositorFrameSink::Create3d(); | 10134 return FakeCompositorFrameSink::Create3d(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10340 base::TimeTicks start_time = | 10369 base::TimeTicks start_time = |
| 10341 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10370 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10342 | 10371 |
| 10343 BeginFrameArgs begin_frame_args = | 10372 BeginFrameArgs begin_frame_args = |
| 10344 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10373 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10345 | 10374 |
| 10346 EXPECT_EQ( | 10375 EXPECT_EQ( |
| 10347 InputHandler::SCROLL_ON_IMPL_THREAD, | 10376 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10348 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10377 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10349 | 10378 |
| 10350 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10379 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10351 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10380 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10381 host_impl_->CurrentlyScrollingNode()->id); |
| 10352 | 10382 |
| 10353 begin_frame_args.frame_time = start_time; | 10383 begin_frame_args.frame_time = start_time; |
| 10354 begin_frame_args.sequence_number++; | 10384 begin_frame_args.sequence_number++; |
| 10355 host_impl_->WillBeginImplFrame(begin_frame_args); | 10385 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10356 host_impl_->Animate(); | 10386 host_impl_->Animate(); |
| 10357 host_impl_->UpdateAnimationState(true); | 10387 host_impl_->UpdateAnimationState(true); |
| 10358 | 10388 |
| 10359 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10389 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10360 host_impl_->DidFinishImplFrame(); | 10390 host_impl_->DidFinishImplFrame(); |
| 10361 | 10391 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 10377 | 10407 |
| 10378 begin_frame_args.frame_time = | 10408 begin_frame_args.frame_time = |
| 10379 start_time + base::TimeDelta::FromMilliseconds(200); | 10409 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10380 begin_frame_args.sequence_number++; | 10410 begin_frame_args.sequence_number++; |
| 10381 host_impl_->WillBeginImplFrame(begin_frame_args); | 10411 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10382 host_impl_->Animate(); | 10412 host_impl_->Animate(); |
| 10383 host_impl_->UpdateAnimationState(true); | 10413 host_impl_->UpdateAnimationState(true); |
| 10384 | 10414 |
| 10385 y = scrolling_layer->CurrentScrollOffset().y(); | 10415 y = scrolling_layer->CurrentScrollOffset().y(); |
| 10386 EXPECT_TRUE(y > 50 && y < 100); | 10416 EXPECT_TRUE(y > 50 && y < 100); |
| 10387 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10417 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10418 host_impl_->CurrentlyScrollingNode()->id); |
| 10388 host_impl_->DidFinishImplFrame(); | 10419 host_impl_->DidFinishImplFrame(); |
| 10389 | 10420 |
| 10390 begin_frame_args.frame_time = | 10421 begin_frame_args.frame_time = |
| 10391 start_time + base::TimeDelta::FromMilliseconds(250); | 10422 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10392 begin_frame_args.sequence_number++; | 10423 begin_frame_args.sequence_number++; |
| 10393 host_impl_->WillBeginImplFrame(begin_frame_args); | 10424 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10394 host_impl_->Animate(); | 10425 host_impl_->Animate(); |
| 10395 host_impl_->UpdateAnimationState(true); | 10426 host_impl_->UpdateAnimationState(true); |
| 10396 | 10427 |
| 10397 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10428 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10398 scrolling_layer->CurrentScrollOffset()); | 10429 scrolling_layer->CurrentScrollOffset()); |
| 10399 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10430 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 10400 host_impl_->DidFinishImplFrame(); | 10431 host_impl_->DidFinishImplFrame(); |
| 10401 } | 10432 } |
| 10402 | 10433 |
| 10403 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { | 10434 TEST_F(LayerTreeHostImplTest, SecondScrollAnimatedBeginNotIgnored) { |
| 10404 const gfx::Size content_size(1000, 1000); | 10435 const gfx::Size content_size(1000, 1000); |
| 10405 const gfx::Size viewport_size(50, 100); | 10436 const gfx::Size viewport_size(50, 100); |
| 10406 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10437 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10407 | 10438 |
| 10408 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10439 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10409 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); | 10440 host_impl_->ScrollAnimatedBegin(gfx::Point()).thread); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10452 host_impl_->DidFinishImplFrame(); | 10483 host_impl_->DidFinishImplFrame(); |
| 10453 | 10484 |
| 10454 begin_frame_args.frame_time = | 10485 begin_frame_args.frame_time = |
| 10455 start_time + base::TimeDelta::FromMilliseconds(300); | 10486 start_time + base::TimeDelta::FromMilliseconds(300); |
| 10456 begin_frame_args.sequence_number++; | 10487 begin_frame_args.sequence_number++; |
| 10457 // This is when the animation above gets ticked. | 10488 // This is when the animation above gets ticked. |
| 10458 host_impl_->WillBeginImplFrame(begin_frame_args); | 10489 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10459 host_impl_->UpdateAnimationState(true); | 10490 host_impl_->UpdateAnimationState(true); |
| 10460 host_impl_->DidFinishImplFrame(); | 10491 host_impl_->DidFinishImplFrame(); |
| 10461 | 10492 |
| 10462 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10493 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10463 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10494 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10495 host_impl_->CurrentlyScrollingNode()->id); |
| 10464 | 10496 |
| 10465 // Verify no jump. | 10497 // Verify no jump. |
| 10466 float y = scrolling_layer->CurrentScrollOffset().y(); | 10498 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 10467 EXPECT_TRUE(y > 1 && y < 49); | 10499 EXPECT_TRUE(y > 1 && y < 49); |
| 10468 } | 10500 } |
| 10469 | 10501 |
| 10470 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { | 10502 TEST_F(LayerTreeHostImplTest, ScrollAnimatedWithDelay) { |
| 10471 const gfx::Size content_size(1000, 1000); | 10503 const gfx::Size content_size(1000, 1000); |
| 10472 const gfx::Size viewport_size(50, 100); | 10504 const gfx::Size viewport_size(50, 100); |
| 10473 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10505 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10474 | 10506 |
| 10475 DrawFrame(); | 10507 DrawFrame(); |
| 10476 | 10508 |
| 10477 base::TimeTicks start_time = | 10509 base::TimeTicks start_time = |
| 10478 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10510 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10479 BeginFrameArgs begin_frame_args = | 10511 BeginFrameArgs begin_frame_args = |
| 10480 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10512 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10481 | 10513 |
| 10482 // Create animation with a 100ms delay. | 10514 // Create animation with a 100ms delay. |
| 10483 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10515 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10484 host_impl_ | 10516 host_impl_ |
| 10485 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), | 10517 ->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 100), |
| 10486 base::TimeDelta::FromMilliseconds(100)) | 10518 base::TimeDelta::FromMilliseconds(100)) |
| 10487 .thread); | 10519 .thread); |
| 10488 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10520 |
| 10489 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), scrolling_layer); | 10521 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10522 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10523 host_impl_->CurrentlyScrollingNode()->id); |
| 10490 | 10524 |
| 10491 // First tick, animation is started. | 10525 // First tick, animation is started. |
| 10492 begin_frame_args.frame_time = start_time; | 10526 begin_frame_args.frame_time = start_time; |
| 10493 begin_frame_args.sequence_number++; | 10527 begin_frame_args.sequence_number++; |
| 10494 host_impl_->WillBeginImplFrame(begin_frame_args); | 10528 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10495 host_impl_->UpdateAnimationState(true); | 10529 host_impl_->UpdateAnimationState(true); |
| 10496 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10530 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10497 host_impl_->DidFinishImplFrame(); | 10531 host_impl_->DidFinishImplFrame(); |
| 10498 | 10532 |
| 10499 // Second tick after 50ms, animation should be half way done since | 10533 // Second tick after 50ms, animation should be half way done since |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10536 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10570 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10537 | 10571 |
| 10538 BeginFrameArgs begin_frame_args = | 10572 BeginFrameArgs begin_frame_args = |
| 10539 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10573 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10540 | 10574 |
| 10541 // Perform animated scroll. | 10575 // Perform animated scroll. |
| 10542 EXPECT_EQ( | 10576 EXPECT_EQ( |
| 10543 InputHandler::SCROLL_ON_IMPL_THREAD, | 10577 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10544 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10578 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10545 | 10579 |
| 10546 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10580 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10581 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10582 host_impl_->CurrentlyScrollingNode()->id); |
| 10547 | 10583 |
| 10548 begin_frame_args.frame_time = start_time; | 10584 begin_frame_args.frame_time = start_time; |
| 10549 begin_frame_args.sequence_number++; | 10585 begin_frame_args.sequence_number++; |
| 10550 host_impl_->WillBeginImplFrame(begin_frame_args); | 10586 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10551 host_impl_->Animate(); | 10587 host_impl_->Animate(); |
| 10552 host_impl_->UpdateAnimationState(true); | 10588 host_impl_->UpdateAnimationState(true); |
| 10553 | 10589 |
| 10554 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( | 10590 EXPECT_TRUE(GetImplAnimationHost()->HasAnyAnimationTargetingProperty( |
| 10555 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); | 10591 scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET)); |
| 10556 | 10592 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 10584 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 10620 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 10585 InputHandler::WHEEL)); | 10621 InputHandler::WHEEL)); |
| 10586 | 10622 |
| 10587 // The instant scroll should have marked the smooth scroll animation as | 10623 // The instant scroll should have marked the smooth scroll animation as |
| 10588 // aborted. | 10624 // aborted. |
| 10589 EXPECT_FALSE(GetImplAnimationHost()->HasTickingAnimationForTesting( | 10625 EXPECT_FALSE(GetImplAnimationHost()->HasTickingAnimationForTesting( |
| 10590 scrolling_layer->element_id())); | 10626 scrolling_layer->element_id())); |
| 10591 | 10627 |
| 10592 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), | 10628 EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50), |
| 10593 scrolling_layer->CurrentScrollOffset()); | 10629 scrolling_layer->CurrentScrollOffset()); |
| 10594 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10630 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 10595 host_impl_->DidFinishImplFrame(); | 10631 host_impl_->DidFinishImplFrame(); |
| 10596 } | 10632 } |
| 10597 | 10633 |
| 10598 // Evolved from LayerTreeHostImplTest.ScrollAnimated. | 10634 // Evolved from LayerTreeHostImplTest.ScrollAnimated. |
| 10599 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { | 10635 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { |
| 10600 const gfx::Size content_size(1000, 1000); | 10636 const gfx::Size content_size(1000, 1000); |
| 10601 const gfx::Size viewport_size(500, 500); | 10637 const gfx::Size viewport_size(500, 500); |
| 10602 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10638 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10603 | 10639 |
| 10604 DrawFrame(); | 10640 DrawFrame(); |
| 10605 | 10641 |
| 10606 base::TimeTicks start_time = | 10642 base::TimeTicks start_time = |
| 10607 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10643 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10608 | 10644 |
| 10609 BeginFrameArgs begin_frame_args = | 10645 BeginFrameArgs begin_frame_args = |
| 10610 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10646 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10611 | 10647 |
| 10612 EXPECT_EQ( | 10648 EXPECT_EQ( |
| 10613 InputHandler::SCROLL_ON_IMPL_THREAD, | 10649 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10614 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); | 10650 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)).thread); |
| 10615 | 10651 |
| 10616 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10652 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10653 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10654 host_impl_->CurrentlyScrollingNode()->id); |
| 10655 |
| 10617 begin_frame_args.frame_time = start_time; | 10656 begin_frame_args.frame_time = start_time; |
| 10618 begin_frame_args.sequence_number++; | 10657 begin_frame_args.sequence_number++; |
| 10619 host_impl_->WillBeginImplFrame(begin_frame_args); | 10658 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10620 host_impl_->Animate(); | 10659 host_impl_->Animate(); |
| 10621 host_impl_->UpdateAnimationState(true); | 10660 host_impl_->UpdateAnimationState(true); |
| 10622 | 10661 |
| 10623 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10662 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10624 host_impl_->DidFinishImplFrame(); | 10663 host_impl_->DidFinishImplFrame(); |
| 10625 | 10664 |
| 10626 begin_frame_args.frame_time = | 10665 begin_frame_args.frame_time = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 10641 | 10680 |
| 10642 begin_frame_args.frame_time = | 10681 begin_frame_args.frame_time = |
| 10643 start_time + base::TimeDelta::FromMilliseconds(200); | 10682 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10644 begin_frame_args.sequence_number++; | 10683 begin_frame_args.sequence_number++; |
| 10645 host_impl_->WillBeginImplFrame(begin_frame_args); | 10684 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10646 host_impl_->Animate(); | 10685 host_impl_->Animate(); |
| 10647 host_impl_->UpdateAnimationState(true); | 10686 host_impl_->UpdateAnimationState(true); |
| 10648 | 10687 |
| 10649 y = scrolling_layer->CurrentScrollOffset().y(); | 10688 y = scrolling_layer->CurrentScrollOffset().y(); |
| 10650 EXPECT_TRUE(y > 50 && y < 100); | 10689 EXPECT_TRUE(y > 50 && y < 100); |
| 10651 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10690 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10691 host_impl_->CurrentlyScrollingNode()->id); |
| 10652 host_impl_->DidFinishImplFrame(); | 10692 host_impl_->DidFinishImplFrame(); |
| 10653 | 10693 |
| 10654 begin_frame_args.frame_time = | 10694 begin_frame_args.frame_time = |
| 10655 start_time + base::TimeDelta::FromMilliseconds(250); | 10695 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10656 begin_frame_args.sequence_number++; | 10696 begin_frame_args.sequence_number++; |
| 10657 host_impl_->WillBeginImplFrame(begin_frame_args); | 10697 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10658 host_impl_->Animate(); | 10698 host_impl_->Animate(); |
| 10659 host_impl_->UpdateAnimationState(true); | 10699 host_impl_->UpdateAnimationState(true); |
| 10660 | 10700 |
| 10661 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10701 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10662 scrolling_layer->CurrentScrollOffset()); | 10702 scrolling_layer->CurrentScrollOffset()); |
| 10663 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10703 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 10664 host_impl_->DidFinishImplFrame(); | 10704 host_impl_->DidFinishImplFrame(); |
| 10665 } | 10705 } |
| 10666 | 10706 |
| 10667 // Test that the scroll delta for an animated scroll is distributed correctly | 10707 // Test that the scroll delta for an animated scroll is distributed correctly |
| 10668 // between the inner and outer viewport. | 10708 // between the inner and outer viewport. |
| 10669 TEST_F(LayerTreeHostImplTimelinesTest, ImplPinchZoomScrollAnimated) { | 10709 TEST_F(LayerTreeHostImplTimelinesTest, ImplPinchZoomScrollAnimated) { |
| 10670 const gfx::Size content_size(200, 200); | 10710 const gfx::Size content_size(200, 200); |
| 10671 const gfx::Size viewport_size(100, 100); | 10711 const gfx::Size viewport_size(100, 100); |
| 10672 CreateBasicVirtualViewportLayers(viewport_size, content_size); | 10712 CreateBasicVirtualViewportLayers(viewport_size, content_size); |
| 10673 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 10713 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 10686 // viewport. | 10726 // viewport. |
| 10687 base::TimeTicks start_time = | 10727 base::TimeTicks start_time = |
| 10688 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); | 10728 base::TimeTicks() + base::TimeDelta::FromMilliseconds(250); |
| 10689 BeginFrameArgs begin_frame_args = | 10729 BeginFrameArgs begin_frame_args = |
| 10690 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10730 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10691 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 10731 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10692 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) | 10732 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(10.f, 20.f)) |
| 10693 .thread); | 10733 .thread); |
| 10694 host_impl_->Animate(); | 10734 host_impl_->Animate(); |
| 10695 host_impl_->UpdateAnimationState(true); | 10735 host_impl_->UpdateAnimationState(true); |
| 10696 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10736 EXPECT_EQ(inner_scroll_layer->scroll_tree_index(), |
| 10737 host_impl_->CurrentlyScrollingNode()->id); |
| 10697 | 10738 |
| 10698 begin_frame_args.sequence_number++; | 10739 begin_frame_args.sequence_number++; |
| 10699 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10740 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
| 10700 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), | 10741 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
| 10701 inner_scroll_layer->CurrentScrollOffset()); | 10742 inner_scroll_layer->CurrentScrollOffset()); |
| 10702 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10743 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10703 outer_scroll_layer->CurrentScrollOffset()); | 10744 outer_scroll_layer->CurrentScrollOffset()); |
| 10704 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); | 10745 EXPECT_VECTOR_EQ(gfx::Vector2dF(), outer_scroll_layer->CurrentScrollOffset()); |
| 10705 | 10746 |
| 10706 // Scroll by the inner viewport's max scroll extent, the remainder | 10747 // Scroll by the inner viewport's max scroll extent, the remainder |
| 10707 // should bubble up to the outer viewport. | 10748 // should bubble up to the outer viewport. |
| 10708 EXPECT_EQ( | 10749 EXPECT_EQ( |
| 10709 InputHandler::SCROLL_ON_IMPL_THREAD, | 10750 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10710 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(100.f, 100.f)) | 10751 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(100.f, 100.f)) |
| 10711 .thread); | 10752 .thread); |
| 10712 host_impl_->Animate(); | 10753 host_impl_->Animate(); |
| 10713 host_impl_->UpdateAnimationState(true); | 10754 host_impl_->UpdateAnimationState(true); |
| 10714 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10755 EXPECT_EQ(inner_scroll_layer->scroll_tree_index(), |
| 10756 host_impl_->CurrentlyScrollingNode()->id); |
| 10715 | 10757 |
| 10716 begin_frame_args.sequence_number++; | 10758 begin_frame_args.sequence_number++; |
| 10717 BeginImplFrameAndAnimate(begin_frame_args, | 10759 BeginImplFrameAndAnimate(begin_frame_args, |
| 10718 start_time + base::TimeDelta::FromMilliseconds(350)); | 10760 start_time + base::TimeDelta::FromMilliseconds(350)); |
| 10719 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), | 10761 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 10720 inner_scroll_layer->CurrentScrollOffset()); | 10762 inner_scroll_layer->CurrentScrollOffset()); |
| 10721 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), | 10763 EXPECT_VECTOR_EQ(gfx::Vector2dF(5, 10), |
| 10722 outer_scroll_layer->CurrentScrollOffset()); | 10764 outer_scroll_layer->CurrentScrollOffset()); |
| 10723 | 10765 |
| 10724 // Scroll by the outer viewport's max scroll extent, it should all go to the | 10766 // Scroll by the outer viewport's max scroll extent, it should all go to the |
| 10725 // outer viewport. | 10767 // outer viewport. |
| 10726 EXPECT_EQ( | 10768 EXPECT_EQ( |
| 10727 InputHandler::SCROLL_ON_IMPL_THREAD, | 10769 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10728 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(190.f, 180.f)) | 10770 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(190.f, 180.f)) |
| 10729 .thread); | 10771 .thread); |
| 10730 host_impl_->Animate(); | 10772 host_impl_->Animate(); |
| 10731 host_impl_->UpdateAnimationState(true); | 10773 host_impl_->UpdateAnimationState(true); |
| 10732 EXPECT_EQ(outer_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10774 EXPECT_EQ(outer_scroll_layer->scroll_tree_index(), |
| 10775 host_impl_->CurrentlyScrollingNode()->id); |
| 10733 | 10776 |
| 10734 begin_frame_args.sequence_number++; | 10777 begin_frame_args.sequence_number++; |
| 10735 BeginImplFrameAndAnimate(begin_frame_args, | 10778 BeginImplFrameAndAnimate(begin_frame_args, |
| 10736 start_time + base::TimeDelta::FromMilliseconds(850)); | 10779 start_time + base::TimeDelta::FromMilliseconds(850)); |
| 10737 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), | 10780 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 10738 inner_scroll_layer->CurrentScrollOffset()); | 10781 inner_scroll_layer->CurrentScrollOffset()); |
| 10739 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100), | 10782 EXPECT_VECTOR_EQ(gfx::Vector2dF(100, 100), |
| 10740 outer_scroll_layer->CurrentScrollOffset()); | 10783 outer_scroll_layer->CurrentScrollOffset()); |
| 10741 | 10784 |
| 10742 // Scroll upwards by the max scroll extent. The inner viewport should animate | 10785 // Scroll upwards by the max scroll extent. The inner viewport should animate |
| 10743 // and the remainder should bubble to the outer viewport. | 10786 // and the remainder should bubble to the outer viewport. |
| 10744 EXPECT_EQ( | 10787 EXPECT_EQ( |
| 10745 InputHandler::SCROLL_ON_IMPL_THREAD, | 10788 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10746 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(-110.f, -120.f)) | 10789 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(-110.f, -120.f)) |
| 10747 .thread); | 10790 .thread); |
| 10748 host_impl_->Animate(); | 10791 host_impl_->Animate(); |
| 10749 host_impl_->UpdateAnimationState(true); | 10792 host_impl_->UpdateAnimationState(true); |
| 10750 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10793 EXPECT_EQ(inner_scroll_layer->scroll_tree_index(), |
| 10794 host_impl_->CurrentlyScrollingNode()->id); |
| 10751 | 10795 |
| 10752 begin_frame_args.sequence_number++; | 10796 begin_frame_args.sequence_number++; |
| 10753 BeginImplFrameAndAnimate( | 10797 BeginImplFrameAndAnimate( |
| 10754 begin_frame_args, start_time + base::TimeDelta::FromMilliseconds(1200)); | 10798 begin_frame_args, start_time + base::TimeDelta::FromMilliseconds(1200)); |
| 10755 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10799 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10756 inner_scroll_layer->CurrentScrollOffset()); | 10800 inner_scroll_layer->CurrentScrollOffset()); |
| 10757 EXPECT_VECTOR_EQ(gfx::Vector2dF(95, 90), | 10801 EXPECT_VECTOR_EQ(gfx::Vector2dF(95, 90), |
| 10758 outer_scroll_layer->CurrentScrollOffset()); | 10802 outer_scroll_layer->CurrentScrollOffset()); |
| 10759 } | 10803 } |
| 10760 | 10804 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 10778 // Scroll the inner viewport. | 10822 // Scroll the inner viewport. |
| 10779 base::TimeTicks start_time = | 10823 base::TimeTicks start_time = |
| 10780 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); | 10824 base::TimeTicks() + base::TimeDelta::FromMilliseconds(50); |
| 10781 BeginFrameArgs begin_frame_args = | 10825 BeginFrameArgs begin_frame_args = |
| 10782 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10826 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10783 EXPECT_EQ( | 10827 EXPECT_EQ( |
| 10784 InputHandler::SCROLL_ON_IMPL_THREAD, | 10828 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10785 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); | 10829 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(90, 90)).thread); |
| 10786 host_impl_->Animate(); | 10830 host_impl_->Animate(); |
| 10787 host_impl_->UpdateAnimationState(true); | 10831 host_impl_->UpdateAnimationState(true); |
| 10788 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10832 EXPECT_EQ(inner_scroll_layer->scroll_tree_index(), |
| 10833 host_impl_->CurrentlyScrollingNode()->id); |
| 10789 | 10834 |
| 10790 begin_frame_args.sequence_number++; | 10835 begin_frame_args.sequence_number++; |
| 10791 BeginImplFrameAndAnimate(begin_frame_args, start_time); | 10836 BeginImplFrameAndAnimate(begin_frame_args, start_time); |
| 10792 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); | 10837 float inner_x = inner_scroll_layer->CurrentScrollOffset().x(); |
| 10793 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); | 10838 float inner_y = inner_scroll_layer->CurrentScrollOffset().y(); |
| 10794 EXPECT_TRUE(inner_x > 0 && inner_x < 45); | 10839 EXPECT_TRUE(inner_x > 0 && inner_x < 45); |
| 10795 EXPECT_TRUE(inner_y > 0 && inner_y < 45); | 10840 EXPECT_TRUE(inner_y > 0 && inner_y < 45); |
| 10796 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10841 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10797 outer_scroll_layer->CurrentScrollOffset()); | 10842 outer_scroll_layer->CurrentScrollOffset()); |
| 10798 | 10843 |
| 10799 // Update target. | 10844 // Update target. |
| 10800 EXPECT_EQ( | 10845 EXPECT_EQ( |
| 10801 InputHandler::SCROLL_ON_IMPL_THREAD, | 10846 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10802 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10847 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
| 10803 host_impl_->Animate(); | 10848 host_impl_->Animate(); |
| 10804 host_impl_->UpdateAnimationState(true); | 10849 host_impl_->UpdateAnimationState(true); |
| 10805 EXPECT_EQ(inner_scroll_layer, host_impl_->CurrentlyScrollingLayer()); | 10850 EXPECT_EQ(inner_scroll_layer->scroll_tree_index(), |
| 10851 host_impl_->CurrentlyScrollingNode()->id); |
| 10806 | 10852 |
| 10807 // Verify that all the delta is applied to the inner viewport and nothing is | 10853 // Verify that all the delta is applied to the inner viewport and nothing is |
| 10808 // carried forward. | 10854 // carried forward. |
| 10809 begin_frame_args.sequence_number++; | 10855 begin_frame_args.sequence_number++; |
| 10810 BeginImplFrameAndAnimate(begin_frame_args, | 10856 BeginImplFrameAndAnimate(begin_frame_args, |
| 10811 start_time + base::TimeDelta::FromMilliseconds(350)); | 10857 start_time + base::TimeDelta::FromMilliseconds(350)); |
| 10812 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), | 10858 EXPECT_VECTOR_EQ(gfx::Vector2dF(50, 50), |
| 10813 inner_scroll_layer->CurrentScrollOffset()); | 10859 inner_scroll_layer->CurrentScrollOffset()); |
| 10814 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), | 10860 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 0), |
| 10815 outer_scroll_layer->CurrentScrollOffset()); | 10861 outer_scroll_layer->CurrentScrollOffset()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 10832 base::TimeTicks start_time = | 10878 base::TimeTicks start_time = |
| 10833 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10879 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10834 | 10880 |
| 10835 BeginFrameArgs begin_frame_args = | 10881 BeginFrameArgs begin_frame_args = |
| 10836 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10882 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10837 | 10883 |
| 10838 EXPECT_EQ( | 10884 EXPECT_EQ( |
| 10839 InputHandler::SCROLL_ON_IMPL_THREAD, | 10885 InputHandler::SCROLL_ON_IMPL_THREAD, |
| 10840 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); | 10886 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(50, 50)).thread); |
| 10841 | 10887 |
| 10842 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10888 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10889 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10890 host_impl_->CurrentlyScrollingNode()->id); |
| 10891 |
| 10843 begin_frame_args.frame_time = start_time; | 10892 begin_frame_args.frame_time = start_time; |
| 10844 begin_frame_args.sequence_number++; | 10893 begin_frame_args.sequence_number++; |
| 10845 host_impl_->WillBeginImplFrame(begin_frame_args); | 10894 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10846 host_impl_->Animate(); | 10895 host_impl_->Animate(); |
| 10847 host_impl_->UpdateAnimationState(true); | 10896 host_impl_->UpdateAnimationState(true); |
| 10848 | 10897 |
| 10849 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 10898 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 10850 host_impl_->DidFinishImplFrame(); | 10899 host_impl_->DidFinishImplFrame(); |
| 10851 | 10900 |
| 10852 begin_frame_args.frame_time = | 10901 begin_frame_args.frame_time = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 10869 | 10918 |
| 10870 begin_frame_args.frame_time = | 10919 begin_frame_args.frame_time = |
| 10871 start_time + base::TimeDelta::FromMilliseconds(200); | 10920 start_time + base::TimeDelta::FromMilliseconds(200); |
| 10872 begin_frame_args.sequence_number++; | 10921 begin_frame_args.sequence_number++; |
| 10873 host_impl_->WillBeginImplFrame(begin_frame_args); | 10922 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10874 host_impl_->Animate(); | 10923 host_impl_->Animate(); |
| 10875 host_impl_->UpdateAnimationState(true); | 10924 host_impl_->UpdateAnimationState(true); |
| 10876 | 10925 |
| 10877 y = scrolling_layer->CurrentScrollOffset().y(); | 10926 y = scrolling_layer->CurrentScrollOffset().y(); |
| 10878 EXPECT_TRUE(y > 50 && y < 100); | 10927 EXPECT_TRUE(y > 50 && y < 100); |
| 10879 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 10928 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10929 host_impl_->CurrentlyScrollingNode()->id); |
| 10880 host_impl_->DidFinishImplFrame(); | 10930 host_impl_->DidFinishImplFrame(); |
| 10881 | 10931 |
| 10882 begin_frame_args.frame_time = | 10932 begin_frame_args.frame_time = |
| 10883 start_time + base::TimeDelta::FromMilliseconds(250); | 10933 start_time + base::TimeDelta::FromMilliseconds(250); |
| 10884 begin_frame_args.sequence_number++; | 10934 begin_frame_args.sequence_number++; |
| 10885 host_impl_->WillBeginImplFrame(begin_frame_args); | 10935 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10886 host_impl_->Animate(); | 10936 host_impl_->Animate(); |
| 10887 host_impl_->UpdateAnimationState(true); | 10937 host_impl_->UpdateAnimationState(true); |
| 10888 | 10938 |
| 10889 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 10939 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 10890 scrolling_layer->CurrentScrollOffset()); | 10940 scrolling_layer->CurrentScrollOffset()); |
| 10891 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 10941 EXPECT_EQ(nullptr, host_impl_->CurrentlyScrollingNode()); |
| 10892 host_impl_->DidFinishImplFrame(); | 10942 host_impl_->DidFinishImplFrame(); |
| 10893 } | 10943 } |
| 10894 | 10944 |
| 10895 // Test that smooth scrolls clamp correctly when bounds change mid-animation. | 10945 // Test that smooth scrolls clamp correctly when bounds change mid-animation. |
| 10896 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { | 10946 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedChangingBounds) { |
| 10897 const gfx::Size old_content_size(1000, 1000); | 10947 const gfx::Size old_content_size(1000, 1000); |
| 10898 const gfx::Size new_content_size(750, 750); | 10948 const gfx::Size new_content_size(750, 750); |
| 10899 const gfx::Size viewport_size(500, 500); | 10949 const gfx::Size viewport_size(500, 500); |
| 10900 | 10950 |
| 10901 LayerImpl* content_layer = | 10951 LayerImpl* content_layer = |
| 10902 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); | 10952 CreateBasicVirtualViewportLayers(viewport_size, old_content_size); |
| 10903 | 10953 |
| 10904 DrawFrame(); | 10954 DrawFrame(); |
| 10905 | 10955 |
| 10906 base::TimeTicks start_time = | 10956 base::TimeTicks start_time = |
| 10907 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 10957 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 10908 BeginFrameArgs begin_frame_args = | 10958 BeginFrameArgs begin_frame_args = |
| 10909 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 10959 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 10910 | 10960 |
| 10911 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); | 10961 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(500, 500)); |
| 10912 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 10962 |
| 10963 LayerImpl* scrolling_layer = host_impl_->OuterViewportScrollLayer(); |
| 10964 EXPECT_EQ(scrolling_layer->scroll_tree_index(), |
| 10965 host_impl_->CurrentlyScrollingNode()->id); |
| 10913 | 10966 |
| 10914 begin_frame_args.frame_time = start_time; | 10967 begin_frame_args.frame_time = start_time; |
| 10915 begin_frame_args.sequence_number++; | 10968 begin_frame_args.sequence_number++; |
| 10916 host_impl_->WillBeginImplFrame(begin_frame_args); | 10969 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 10917 host_impl_->Animate(); | 10970 host_impl_->Animate(); |
| 10918 host_impl_->UpdateAnimationState(true); | 10971 host_impl_->UpdateAnimationState(true); |
| 10919 host_impl_->DidFinishImplFrame(); | 10972 host_impl_->DidFinishImplFrame(); |
| 10920 | 10973 |
| 10921 content_layer->SetBounds(new_content_size); | 10974 content_layer->SetBounds(new_content_size); |
| 10922 scrolling_layer->SetBounds(new_content_size); | 10975 scrolling_layer->SetBounds(new_content_size); |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11911 else | 11964 else |
| 11912 EXPECT_FALSE(tile->HasRasterTask()); | 11965 EXPECT_FALSE(tile->HasRasterTask()); |
| 11913 } | 11966 } |
| 11914 Region expected_invalidation( | 11967 Region expected_invalidation( |
| 11915 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 11968 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
| 11916 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 11969 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 11917 } | 11970 } |
| 11918 | 11971 |
| 11919 } // namespace | 11972 } // namespace |
| 11920 } // namespace cc | 11973 } // namespace cc |
| OLD | NEW |