| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 root->ScrollBy(gfx::Vector2d()); | 490 root->ScrollBy(gfx::Vector2d()); |
| 491 scroll_info = host_impl_->ProcessScrollDeltas(); | 491 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 492 ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2); | 492 ExpectContains(*scroll_info, root->id(), scroll_delta + scroll_delta2); |
| 493 } | 493 } |
| 494 | 494 |
| 495 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { | 495 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { |
| 496 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 496 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 497 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 497 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 498 DrawFrame(); | 498 DrawFrame(); |
| 499 | 499 |
| 500 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 500 EXPECT_EQ(InputHandler::ScrollStarted, |
| 501 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 501 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 502 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 502 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 503 InputHandler::WHEEL)); | 503 InputHandler::Wheel)); |
| 504 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 504 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 505 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), | 505 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), |
| 506 InputHandler::WHEEL)); | 506 InputHandler::Wheel)); |
| 507 host_impl_->ScrollEnd(); | 507 host_impl_->ScrollEnd(); |
| 508 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), | 508 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), |
| 509 InputHandler::WHEEL)); | 509 InputHandler::Wheel)); |
| 510 EXPECT_TRUE(did_request_redraw_); | 510 EXPECT_TRUE(did_request_redraw_); |
| 511 EXPECT_TRUE(did_request_commit_); | 511 EXPECT_TRUE(did_request_commit_); |
| 512 } | 512 } |
| 513 | 513 |
| 514 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { | 514 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { |
| 515 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 515 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 516 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 516 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 517 DrawFrame(); | 517 DrawFrame(); |
| 518 | 518 |
| 519 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 519 EXPECT_EQ(InputHandler::ScrollStarted, |
| 520 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 520 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 521 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 521 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| 522 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 522 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 523 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); | 523 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); |
| 524 host_impl_->ScrollEnd(); | 524 host_impl_->ScrollEnd(); |
| 525 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); | 525 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); |
| 526 } | 526 } |
| 527 | 527 |
| 528 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { | 528 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { |
| 529 // We should not crash when trying to scroll an empty layer tree. | 529 // We should not crash when trying to scroll an empty layer tree. |
| 530 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 530 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 531 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 531 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 532 } | 532 } |
| 533 | 533 |
| 534 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { | 534 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { |
| 535 scoped_ptr<TestWebGraphicsContext3D> context_owned = | 535 scoped_ptr<TestWebGraphicsContext3D> context_owned = |
| 536 TestWebGraphicsContext3D::Create(); | 536 TestWebGraphicsContext3D::Create(); |
| 537 context_owned->set_context_lost(true); | 537 context_owned->set_context_lost(true); |
| 538 | 538 |
| 539 // Initialization will fail. | 539 // Initialization will fail. |
| 540 EXPECT_FALSE(CreateHostImpl( | 540 EXPECT_FALSE(CreateHostImpl( |
| 541 DefaultSettings(), FakeOutputSurface::Create3d(context_owned.Pass()))); | 541 DefaultSettings(), FakeOutputSurface::Create3d(context_owned.Pass()))); |
| 542 | 542 |
| 543 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 543 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 544 | 544 |
| 545 // We should not crash when trying to scroll after the renderer initialization | 545 // We should not crash when trying to scroll after the renderer initialization |
| 546 // fails. | 546 // fails. |
| 547 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 547 EXPECT_EQ(InputHandler::ScrollStarted, |
| 548 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 548 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 549 } | 549 } |
| 550 | 550 |
| 551 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { | 551 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { |
| 552 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 552 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 553 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 553 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 554 DrawFrame(); | 554 DrawFrame(); |
| 555 | 555 |
| 556 // We should not crash if the tree is replaced while we are scrolling. | 556 // We should not crash if the tree is replaced while we are scrolling. |
| 557 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 557 EXPECT_EQ(InputHandler::ScrollStarted, |
| 558 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 558 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 559 host_impl_->active_tree()->DetachLayerTree(); | 559 host_impl_->active_tree()->DetachLayerTree(); |
| 560 | 560 |
| 561 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 561 scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 562 | 562 |
| 563 // We should still be scrolling, because the scrolled layer also exists in the | 563 // We should still be scrolling, because the scrolled layer also exists in the |
| 564 // new tree. | 564 // new tree. |
| 565 gfx::Vector2d scroll_delta(0, 10); | 565 gfx::Vector2d scroll_delta(0, 10); |
| 566 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 566 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 567 host_impl_->ScrollEnd(); | 567 host_impl_->ScrollEnd(); |
| 568 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 568 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 569 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 569 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
| 570 } | 570 } |
| 571 | 571 |
| 572 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 572 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
| 573 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 573 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 574 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 574 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 575 DrawFrame(); | 575 DrawFrame(); |
| 576 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 576 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 577 | 577 |
| 578 // With registered event handlers, wheel scrolls don't necessarily | 578 // With registered event handlers, wheel scrolls don't necessarily |
| 579 // have to go to the main thread. | 579 // have to go to the main thread. |
| 580 root->SetHaveWheelEventHandlers(true); | 580 root->SetHaveWheelEventHandlers(true); |
| 581 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 581 EXPECT_EQ(InputHandler::ScrollStarted, |
| 582 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 582 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 583 host_impl_->ScrollEnd(); | 583 host_impl_->ScrollEnd(); |
| 584 | 584 |
| 585 // But typically the scroll-blocks-on mode will require them to. | 585 // But typically the scroll-blocks-on mode will require them to. |
| 586 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | | 586 root->SetScrollBlocksOn(ScrollBlocksOnWheelEvent | ScrollBlocksOnStartTouch); |
| 587 SCROLL_BLOCKS_ON_START_TOUCH); | 587 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 588 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 588 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 589 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | |
| 590 | 589 |
| 591 // But gesture scrolls can still be handled. | 590 // But gesture scrolls can still be handled. |
| 592 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 591 EXPECT_EQ(InputHandler::ScrollStarted, |
| 593 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 592 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 594 host_impl_->ScrollEnd(); | 593 host_impl_->ScrollEnd(); |
| 595 | 594 |
| 596 // And if the handlers go away, wheel scrolls can again be processed | 595 // And if the handlers go away, wheel scrolls can again be processed |
| 597 // on impl (despite the scroll-blocks-on mode). | 596 // on impl (despite the scroll-blocks-on mode). |
| 598 root->SetHaveWheelEventHandlers(false); | 597 root->SetHaveWheelEventHandlers(false); |
| 599 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 598 EXPECT_EQ(InputHandler::ScrollStarted, |
| 600 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 599 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 601 host_impl_->ScrollEnd(); | 600 host_impl_->ScrollEnd(); |
| 602 } | 601 } |
| 603 | 602 |
| 604 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 603 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
| 605 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 604 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 606 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 605 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 607 DrawFrame(); | 606 DrawFrame(); |
| 608 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 607 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 609 | 608 |
| 610 LayerImpl* child = 0; | 609 LayerImpl* child = 0; |
| 611 { | 610 { |
| 612 scoped_ptr<LayerImpl> child_layer = | 611 scoped_ptr<LayerImpl> child_layer = |
| 613 LayerImpl::Create(host_impl_->active_tree(), 6); | 612 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 614 child = child_layer.get(); | 613 child = child_layer.get(); |
| 615 child_layer->SetDrawsContent(true); | 614 child_layer->SetDrawsContent(true); |
| 616 child_layer->SetPosition(gfx::PointF(0, 20)); | 615 child_layer->SetPosition(gfx::PointF(0, 20)); |
| 617 child_layer->SetBounds(gfx::Size(50, 50)); | 616 child_layer->SetBounds(gfx::Size(50, 50)); |
| 618 child_layer->SetContentBounds(gfx::Size(50, 50)); | 617 child_layer->SetContentBounds(gfx::Size(50, 50)); |
| 619 scroll->AddChild(child_layer.Pass()); | 618 scroll->AddChild(child_layer.Pass()); |
| 620 } | 619 } |
| 621 | 620 |
| 622 // Touch handler regions determine whether touch events block scroll. | 621 // Touch handler regions determine whether touch events block scroll. |
| 623 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | 622 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| 624 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 623 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
| 625 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH | | 624 root->SetScrollBlocksOn(ScrollBlocksOnStartTouch | ScrollBlocksOnWheelEvent); |
| 626 SCROLL_BLOCKS_ON_WHEEL_EVENT); | |
| 627 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); | 625 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
| 628 | 626 |
| 629 // But they don't influence the actual handling of the scroll gestures. | 627 // But they don't influence the actual handling of the scroll gestures. |
| 630 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 628 EXPECT_EQ(InputHandler::ScrollStarted, |
| 631 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 629 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 632 host_impl_->ScrollEnd(); | 630 host_impl_->ScrollEnd(); |
| 633 | 631 |
| 634 // It's the union of scroll-blocks-on mode bits across all layers in the | 632 // It's the union of scroll-blocks-on mode bits across all layers in the |
| 635 // scroll paret chain that matters. | 633 // scroll paret chain that matters. |
| 636 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 634 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 637 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_NONE); | 635 root->SetScrollBlocksOn(ScrollBlocksOnNone); |
| 638 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 636 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 639 child->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH); | 637 child->SetScrollBlocksOn(ScrollBlocksOnStartTouch); |
| 640 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); | 638 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 641 } | 639 } |
| 642 | 640 |
| 643 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnScrollEventHandlers) { | 641 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnScrollEventHandlers) { |
| 644 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 642 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 645 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 643 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 646 DrawFrame(); | 644 DrawFrame(); |
| 647 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 645 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 648 | 646 |
| 649 // With registered scroll handlers, scrolls don't generally have to go | 647 // With registered scroll handlers, scrolls don't generally have to go |
| 650 // to the main thread. | 648 // to the main thread. |
| 651 root->SetHaveScrollEventHandlers(true); | 649 root->SetHaveScrollEventHandlers(true); |
| 652 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 650 EXPECT_EQ(InputHandler::ScrollStarted, |
| 653 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 651 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 654 host_impl_->ScrollEnd(); | 652 host_impl_->ScrollEnd(); |
| 655 | 653 |
| 656 // Even the default scroll blocks on mode doesn't require this. | 654 // Even the default scroll blocks on mode doesn't require this. |
| 657 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | | 655 root->SetScrollBlocksOn(ScrollBlocksOnWheelEvent | ScrollBlocksOnStartTouch); |
| 658 SCROLL_BLOCKS_ON_START_TOUCH); | 656 EXPECT_EQ(InputHandler::ScrollStarted, |
| 659 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 657 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 660 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | |
| 661 host_impl_->ScrollEnd(); | 658 host_impl_->ScrollEnd(); |
| 662 | 659 |
| 663 // But the page can opt in to blocking on scroll event handlers. | 660 // But the page can opt in to blocking on scroll event handlers. |
| 664 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); | 661 root->SetScrollBlocksOn(ScrollBlocksOnScrollEvent); |
| 665 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 662 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 666 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 663 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 667 | 664 |
| 668 // GESTURE and WHEEL scrolls behave identically in this regard. | 665 // Gesture and Wheel scrolls behave identically in this regard. |
| 669 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 666 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 670 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 667 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 671 | 668 |
| 672 // And if the handlers go away, scrolls can again be processed on impl | 669 // And if the handlers go away, scrolls can again be processed on impl |
| 673 // (despite the scroll-blocks-on mode). | 670 // (despite the scroll-blocks-on mode). |
| 674 root->SetHaveScrollEventHandlers(false); | 671 root->SetHaveScrollEventHandlers(false); |
| 675 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 672 EXPECT_EQ(InputHandler::ScrollStarted, |
| 676 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 673 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 677 host_impl_->ScrollEnd(); | 674 host_impl_->ScrollEnd(); |
| 678 } | 675 } |
| 679 | 676 |
| 680 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { | 677 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { |
| 681 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 678 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 682 | 679 |
| 683 // Create a normal scrollable root layer | 680 // Create a normal scrollable root layer |
| 684 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 681 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 685 LayerImpl* root_child = root_scroll->children()[0]; | 682 LayerImpl* root_child = root_scroll->children()[0]; |
| 686 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 683 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 709 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); | 706 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); |
| 710 child2 = scrollable_child_2.get(); | 707 child2 = scrollable_child_2.get(); |
| 711 scrollable_child_2->SetPosition(gfx::Point(5, 20)); | 708 scrollable_child_2->SetPosition(gfx::Point(5, 20)); |
| 712 scrollable_child_2->SetHaveWheelEventHandlers(true); | 709 scrollable_child_2->SetHaveWheelEventHandlers(true); |
| 713 scrollable_child_2->SetHaveScrollEventHandlers(true); | 710 scrollable_child_2->SetHaveScrollEventHandlers(true); |
| 714 scrollable_child_clip_2->AddChild(scrollable_child_2.Pass()); | 711 scrollable_child_clip_2->AddChild(scrollable_child_2.Pass()); |
| 715 root_child->AddChild(scrollable_child_clip_2.Pass()); | 712 root_child->AddChild(scrollable_child_clip_2.Pass()); |
| 716 } | 713 } |
| 717 | 714 |
| 718 // Scroll-blocks-on on a layer affects scrolls that hit that layer. | 715 // Scroll-blocks-on on a layer affects scrolls that hit that layer. |
| 719 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 716 EXPECT_EQ(InputHandler::ScrollStarted, |
| 720 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); | 717 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture)); |
| 721 host_impl_->ScrollEnd(); | 718 host_impl_->ScrollEnd(); |
| 722 child1->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); | 719 child1->SetScrollBlocksOn(ScrollBlocksOnScrollEvent); |
| 723 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 720 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 724 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); | 721 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture)); |
| 725 | 722 |
| 726 // But not those that hit only other layers. | 723 // But not those that hit only other layers. |
| 727 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 724 EXPECT_EQ(InputHandler::ScrollStarted, |
| 728 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::GESTURE)); | 725 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 729 host_impl_->ScrollEnd(); | 726 host_impl_->ScrollEnd(); |
| 730 | 727 |
| 731 // It's the union of bits set across the scroll ancestor chain that matters. | 728 // It's the union of bits set across the scroll ancestor chain that matters. |
| 732 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 729 EXPECT_EQ(InputHandler::ScrollStarted, |
| 733 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::GESTURE)); | 730 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 734 host_impl_->ScrollEnd(); | 731 host_impl_->ScrollEnd(); |
| 735 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 732 EXPECT_EQ(InputHandler::ScrollStarted, |
| 736 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::WHEEL)); | 733 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Wheel)); |
| 737 host_impl_->ScrollEnd(); | 734 host_impl_->ScrollEnd(); |
| 738 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT); | 735 root->SetScrollBlocksOn(ScrollBlocksOnWheelEvent); |
| 739 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 736 EXPECT_EQ(InputHandler::ScrollStarted, |
| 740 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::GESTURE)); | 737 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 741 host_impl_->ScrollEnd(); | 738 host_impl_->ScrollEnd(); |
| 742 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 739 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 743 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::WHEEL)); | 740 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Wheel)); |
| 744 child2->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); | 741 child2->SetScrollBlocksOn(ScrollBlocksOnScrollEvent); |
| 745 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 742 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 746 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::WHEEL)); | 743 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Wheel)); |
| 747 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 744 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 748 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::GESTURE)); | 745 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 749 } | 746 } |
| 750 | 747 |
| 751 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { | 748 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { |
| 752 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 749 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 753 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 750 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 754 DrawFrame(); | 751 DrawFrame(); |
| 755 | 752 |
| 756 // Ignore the fling since no layer is being scrolled | 753 // Ignore the fling since no layer is being scrolled |
| 757 EXPECT_EQ(InputHandler::SCROLL_IGNORED, host_impl_->FlingScrollBegin()); | 754 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 755 host_impl_->FlingScrollBegin()); |
| 758 | 756 |
| 759 // Start scrolling a layer | 757 // Start scrolling a layer |
| 760 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 758 EXPECT_EQ(InputHandler::ScrollStarted, |
| 761 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 759 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 762 | 760 |
| 763 // Now the fling should go ahead since we've started scrolling a layer | 761 // Now the fling should go ahead since we've started scrolling a layer |
| 764 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 762 EXPECT_EQ(InputHandler::ScrollStarted, |
| 763 host_impl_->FlingScrollBegin()); |
| 765 } | 764 } |
| 766 | 765 |
| 767 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchpad) { | 766 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchpad) { |
| 768 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 767 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 769 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 768 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 770 DrawFrame(); | 769 DrawFrame(); |
| 771 | 770 |
| 772 // Ignore the fling since no layer is being scrolled | 771 // Ignore the fling since no layer is being scrolled |
| 773 EXPECT_EQ(InputHandler::SCROLL_IGNORED, host_impl_->FlingScrollBegin()); | 772 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 773 host_impl_->FlingScrollBegin()); |
| 774 | 774 |
| 775 // Start scrolling a layer | 775 // Start scrolling a layer |
| 776 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 776 EXPECT_EQ(InputHandler::ScrollStarted, |
| 777 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 777 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 778 | 778 |
| 779 // Now the fling should go ahead since we've started scrolling a layer | 779 // Now the fling should go ahead since we've started scrolling a layer |
| 780 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 780 EXPECT_EQ(InputHandler::ScrollStarted, |
| 781 host_impl_->FlingScrollBegin()); |
| 781 } | 782 } |
| 782 | 783 |
| 783 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { | 784 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { |
| 784 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 785 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 785 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 786 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 786 DrawFrame(); | 787 DrawFrame(); |
| 787 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 788 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 788 | 789 |
| 789 root->SetShouldScrollOnMainThread(true); | 790 root->SetShouldScrollOnMainThread(true); |
| 790 | 791 |
| 791 // Start scrolling a layer | 792 // Start scrolling a layer |
| 792 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 793 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 793 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 794 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 794 | 795 |
| 795 // The fling should be ignored since there's no layer being scrolled impl-side | 796 // The fling should be ignored since there's no layer being scrolled impl-side |
| 796 EXPECT_EQ(InputHandler::SCROLL_IGNORED, host_impl_->FlingScrollBegin()); | 797 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 798 host_impl_->FlingScrollBegin()); |
| 797 } | 799 } |
| 798 | 800 |
| 799 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { | 801 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { |
| 800 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 802 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 801 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 803 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 802 DrawFrame(); | 804 DrawFrame(); |
| 803 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 805 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 804 | 806 |
| 805 root->SetShouldScrollOnMainThread(true); | 807 root->SetShouldScrollOnMainThread(true); |
| 806 | 808 |
| 807 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 809 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 808 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 810 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 809 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 811 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 810 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 812 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 811 } | 813 } |
| 812 | 814 |
| 813 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { | 815 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { |
| 814 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 816 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 815 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 817 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 816 | 818 |
| 817 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 819 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 818 root->SetContentsScale(2.f, 2.f); | 820 root->SetContentsScale(2.f, 2.f); |
| 819 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 821 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 820 | 822 |
| 821 DrawFrame(); | 823 DrawFrame(); |
| 822 | 824 |
| 823 // All scroll types inside the non-fast scrollable region should fail. | 825 // All scroll types inside the non-fast scrollable region should fail. |
| 824 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 826 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 825 host_impl_->ScrollBegin(gfx::Point(25, 25), InputHandler::WHEEL)); | 827 host_impl_->ScrollBegin(gfx::Point(25, 25), |
| 828 InputHandler::Wheel)); |
| 826 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 829 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
| 827 InputHandler::WHEEL)); | 830 InputHandler::Wheel)); |
| 828 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 831 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 829 host_impl_->ScrollBegin(gfx::Point(25, 25), InputHandler::GESTURE)); | 832 host_impl_->ScrollBegin(gfx::Point(25, 25), |
| 833 InputHandler::Gesture)); |
| 830 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 834 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
| 831 InputHandler::GESTURE)); | 835 InputHandler::Gesture)); |
| 832 | 836 |
| 833 // All scroll types outside this region should succeed. | 837 // All scroll types outside this region should succeed. |
| 834 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 838 EXPECT_EQ(InputHandler::ScrollStarted, |
| 835 host_impl_->ScrollBegin(gfx::Point(75, 75), InputHandler::WHEEL)); | 839 host_impl_->ScrollBegin(gfx::Point(75, 75), |
| 840 InputHandler::Wheel)); |
| 836 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 841 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
| 837 InputHandler::GESTURE)); | 842 InputHandler::Gesture)); |
| 838 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 843 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 839 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), | 844 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), |
| 840 InputHandler::GESTURE)); | 845 InputHandler::Gesture)); |
| 841 host_impl_->ScrollEnd(); | 846 host_impl_->ScrollEnd(); |
| 842 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 847 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
| 843 InputHandler::GESTURE)); | 848 InputHandler::Gesture)); |
| 844 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 849 EXPECT_EQ(InputHandler::ScrollStarted, |
| 845 host_impl_->ScrollBegin(gfx::Point(75, 75), InputHandler::GESTURE)); | 850 host_impl_->ScrollBegin(gfx::Point(75, 75), |
| 851 InputHandler::Gesture)); |
| 846 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 852 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
| 847 InputHandler::GESTURE)); | 853 InputHandler::Gesture)); |
| 848 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 854 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 849 host_impl_->ScrollEnd(); | 855 host_impl_->ScrollEnd(); |
| 850 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), | 856 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), |
| 851 InputHandler::GESTURE)); | 857 InputHandler::Gesture)); |
| 852 } | 858 } |
| 853 | 859 |
| 854 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { | 860 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { |
| 855 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 861 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 856 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 862 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 857 | 863 |
| 858 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 864 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 859 root->SetContentsScale(2.f, 2.f); | 865 root->SetContentsScale(2.f, 2.f); |
| 860 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); | 866 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); |
| 861 root->SetPosition(gfx::PointF(-25.f, 0.f)); | 867 root->SetPosition(gfx::PointF(-25.f, 0.f)); |
| 862 | 868 |
| 863 DrawFrame(); | 869 DrawFrame(); |
| 864 | 870 |
| 865 // This point would fall into the non-fast scrollable region except that we've | 871 // This point would fall into the non-fast scrollable region except that we've |
| 866 // moved the layer down by 25 pixels. | 872 // moved the layer down by 25 pixels. |
| 867 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 873 EXPECT_EQ(InputHandler::ScrollStarted, |
| 868 host_impl_->ScrollBegin(gfx::Point(40, 10), InputHandler::WHEEL)); | 874 host_impl_->ScrollBegin(gfx::Point(40, 10), |
| 875 InputHandler::Wheel)); |
| 869 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10), | 876 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10), |
| 870 InputHandler::WHEEL)); | 877 InputHandler::Wheel)); |
| 871 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 1)); | 878 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 1)); |
| 872 host_impl_->ScrollEnd(); | 879 host_impl_->ScrollEnd(); |
| 873 | 880 |
| 874 // This point is still inside the non-fast region. | 881 // This point is still inside the non-fast region. |
| 875 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 882 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 876 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::WHEEL)); | 883 host_impl_->ScrollBegin(gfx::Point(10, 10), |
| 884 InputHandler::Wheel)); |
| 877 } | 885 } |
| 878 | 886 |
| 879 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { | 887 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { |
| 880 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 888 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 881 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); | 889 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); |
| 882 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 890 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 883 DrawFrame(); | 891 DrawFrame(); |
| 884 | 892 |
| 885 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 893 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 886 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 894 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 887 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 895 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 888 host_impl_->ScrollEnd(); | 896 host_impl_->ScrollEnd(); |
| 889 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 897 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 890 } | 898 } |
| 891 | 899 |
| 892 TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) { | 900 TEST_F(LayerTreeHostImplTest, ScrollHandlerPresent) { |
| 893 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 901 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 894 scroll_layer->SetHaveScrollEventHandlers(true); | 902 scroll_layer->SetHaveScrollEventHandlers(true); |
| 895 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 903 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 896 DrawFrame(); | 904 DrawFrame(); |
| 897 | 905 |
| 898 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 906 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 899 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 907 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 900 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); | 908 EXPECT_TRUE(host_impl_->scroll_affects_scroll_handler()); |
| 901 host_impl_->ScrollEnd(); | 909 host_impl_->ScrollEnd(); |
| 902 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); | 910 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); |
| 903 } | 911 } |
| 904 | 912 |
| 905 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { | 913 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { |
| 906 SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 914 SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 907 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 915 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 908 | 916 |
| 909 DrawFrame(); | 917 DrawFrame(); |
| 910 | 918 |
| 911 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 919 EXPECT_EQ(InputHandler::ScrollStarted, |
| 912 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 920 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 913 | 921 |
| 914 // Trying to scroll to the left/top will not succeed. | 922 // Trying to scroll to the left/top will not succeed. |
| 915 EXPECT_FALSE( | 923 EXPECT_FALSE( |
| 916 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); | 924 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)).did_scroll); |
| 917 EXPECT_FALSE( | 925 EXPECT_FALSE( |
| 918 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll); | 926 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, -10)).did_scroll); |
| 919 EXPECT_FALSE( | 927 EXPECT_FALSE( |
| 920 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll); | 928 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(-10, -10)).did_scroll); |
| 921 | 929 |
| 922 // Scrolling to the right/bottom will succeed. | 930 // Scrolling to the right/bottom will succeed. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 947 EXPECT_TRUE( | 955 EXPECT_TRUE( |
| 948 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)).did_scroll); | 956 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)).did_scroll); |
| 949 } | 957 } |
| 950 | 958 |
| 951 TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) { | 959 TEST_F(LayerTreeHostImplTest, ScrollVerticallyByPageReturnsCorrectValue) { |
| 952 SetupScrollAndContentsLayers(gfx::Size(200, 2000)); | 960 SetupScrollAndContentsLayers(gfx::Size(200, 2000)); |
| 953 host_impl_->SetViewportSize(gfx::Size(100, 1000)); | 961 host_impl_->SetViewportSize(gfx::Size(100, 1000)); |
| 954 | 962 |
| 955 DrawFrame(); | 963 DrawFrame(); |
| 956 | 964 |
| 957 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 965 EXPECT_EQ(InputHandler::ScrollStarted, |
| 958 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 966 host_impl_->ScrollBegin(gfx::Point(), |
| 967 InputHandler::Wheel)); |
| 959 | 968 |
| 960 // Trying to scroll without a vertical scrollbar will fail. | 969 // Trying to scroll without a vertical scrollbar will fail. |
| 961 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 970 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
| 962 gfx::Point(), SCROLL_FORWARD)); | 971 gfx::Point(), SCROLL_FORWARD)); |
| 963 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( | 972 EXPECT_FALSE(host_impl_->ScrollVerticallyByPage( |
| 964 gfx::Point(), SCROLL_BACKWARD)); | 973 gfx::Point(), SCROLL_BACKWARD)); |
| 965 | 974 |
| 966 scoped_ptr<PaintedScrollbarLayerImpl> vertical_scrollbar( | 975 scoped_ptr<PaintedScrollbarLayerImpl> vertical_scrollbar( |
| 967 PaintedScrollbarLayerImpl::Create( | 976 PaintedScrollbarLayerImpl::Create( |
| 968 host_impl_->active_tree(), | 977 host_impl_->active_tree(), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 990 LayerImpl* overflow = scroll_layer->children()[0]; | 999 LayerImpl* overflow = scroll_layer->children()[0]; |
| 991 overflow->SetBounds(overflow_size); | 1000 overflow->SetBounds(overflow_size); |
| 992 overflow->SetContentBounds(overflow_size); | 1001 overflow->SetContentBounds(overflow_size); |
| 993 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); | 1002 overflow->SetScrollClipLayer(scroll_layer->parent()->id()); |
| 994 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); | 1003 overflow->PushScrollOffsetFromMainThread(gfx::ScrollOffset()); |
| 995 overflow->SetPosition(gfx::PointF()); | 1004 overflow->SetPosition(gfx::PointF()); |
| 996 | 1005 |
| 997 DrawFrame(); | 1006 DrawFrame(); |
| 998 gfx::Point scroll_position(10, 10); | 1007 gfx::Point scroll_position(10, 10); |
| 999 | 1008 |
| 1000 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1009 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1001 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1010 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 1002 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1011 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1003 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); | 1012 EXPECT_VECTOR_EQ(gfx::Vector2dF(), overflow->CurrentScrollOffset()); |
| 1004 | 1013 |
| 1005 gfx::Vector2dF scroll_delta(10, 10); | 1014 gfx::Vector2dF scroll_delta(10, 10); |
| 1006 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1015 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 1007 host_impl_->ScrollEnd(); | 1016 host_impl_->ScrollEnd(); |
| 1008 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1017 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1009 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1018 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1010 | 1019 |
| 1011 overflow->set_user_scrollable_horizontal(false); | 1020 overflow->set_user_scrollable_horizontal(false); |
| 1012 | 1021 |
| 1013 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1022 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1014 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1023 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 1015 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 1024 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 1016 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); | 1025 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 10), overflow->CurrentScrollOffset()); |
| 1017 | 1026 |
| 1018 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1027 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 1019 host_impl_->ScrollEnd(); | 1028 host_impl_->ScrollEnd(); |
| 1020 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); | 1029 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
| 1021 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1030 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1022 | 1031 |
| 1023 overflow->set_user_scrollable_vertical(false); | 1032 overflow->set_user_scrollable_vertical(false); |
| 1024 | 1033 |
| 1025 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1034 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1026 host_impl_->ScrollBegin(scroll_position, InputHandler::WHEEL)); | 1035 host_impl_->ScrollBegin(scroll_position, InputHandler::Wheel)); |
| 1027 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); | 1036 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 0), scroll_layer->CurrentScrollOffset()); |
| 1028 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1037 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1029 | 1038 |
| 1030 host_impl_->ScrollBy(scroll_position, scroll_delta); | 1039 host_impl_->ScrollBy(scroll_position, scroll_delta); |
| 1031 host_impl_->ScrollEnd(); | 1040 host_impl_->ScrollEnd(); |
| 1032 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); | 1041 EXPECT_VECTOR_EQ(gfx::Vector2dF(20, 10), scroll_layer->CurrentScrollOffset()); |
| 1033 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); | 1042 EXPECT_VECTOR_EQ(gfx::Vector2dF(10, 20), overflow->CurrentScrollOffset()); |
| 1034 } | 1043 } |
| 1035 | 1044 |
| 1036 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { | 1045 TEST_F(LayerTreeHostImplTest, ImplPinchZoom) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1047 | 1056 |
| 1048 // The impl-based pinch zoom should adjust the max scroll position. | 1057 // The impl-based pinch zoom should adjust the max scroll position. |
| 1049 { | 1058 { |
| 1050 host_impl_->active_tree()->PushPageScaleFromMainThread( | 1059 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 1051 page_scale_factor, min_page_scale, max_page_scale); | 1060 page_scale_factor, min_page_scale, max_page_scale); |
| 1052 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); | 1061 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); |
| 1053 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1062 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1054 | 1063 |
| 1055 float page_scale_delta = 2.f; | 1064 float page_scale_delta = 2.f; |
| 1056 | 1065 |
| 1057 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::GESTURE); | 1066 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
| 1058 host_impl_->PinchGestureBegin(); | 1067 host_impl_->PinchGestureBegin(); |
| 1059 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 1068 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 1060 host_impl_->PinchGestureEnd(); | 1069 host_impl_->PinchGestureEnd(); |
| 1061 host_impl_->ScrollEnd(); | 1070 host_impl_->ScrollEnd(); |
| 1062 EXPECT_FALSE(did_request_animate_); | 1071 EXPECT_FALSE(did_request_animate_); |
| 1063 EXPECT_TRUE(did_request_redraw_); | 1072 EXPECT_TRUE(did_request_redraw_); |
| 1064 EXPECT_TRUE(did_request_commit_); | 1073 EXPECT_TRUE(did_request_commit_); |
| 1065 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 1074 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
| 1066 | 1075 |
| 1067 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1076 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1068 host_impl_->ProcessScrollDeltas(); | 1077 host_impl_->ProcessScrollDeltas(); |
| 1069 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1078 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1070 | 1079 |
| 1071 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), | 1080 EXPECT_EQ(gfx::ScrollOffset(75.0, 75.0).ToString(), |
| 1072 scroll_layer->MaxScrollOffset().ToString()); | 1081 scroll_layer->MaxScrollOffset().ToString()); |
| 1073 } | 1082 } |
| 1074 | 1083 |
| 1075 // Scrolling after a pinch gesture should always be in local space. The | 1084 // Scrolling after a pinch gesture should always be in local space. The |
| 1076 // scroll deltas have the page scale factor applied. | 1085 // scroll deltas have the page scale factor applied. |
| 1077 { | 1086 { |
| 1078 host_impl_->active_tree()->PushPageScaleFromMainThread( | 1087 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 1079 page_scale_factor, min_page_scale, max_page_scale); | 1088 page_scale_factor, min_page_scale, max_page_scale); |
| 1080 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); | 1089 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); |
| 1081 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1090 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1082 | 1091 |
| 1083 float page_scale_delta = 2.f; | 1092 float page_scale_delta = 2.f; |
| 1084 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 1093 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 1085 host_impl_->PinchGestureBegin(); | 1094 host_impl_->PinchGestureBegin(); |
| 1086 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1095 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 1087 host_impl_->PinchGestureEnd(); | 1096 host_impl_->PinchGestureEnd(); |
| 1088 host_impl_->ScrollEnd(); | 1097 host_impl_->ScrollEnd(); |
| 1089 | 1098 |
| 1090 gfx::Vector2d scroll_delta(0, 10); | 1099 gfx::Vector2d scroll_delta(0, 10); |
| 1091 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1100 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1092 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 1101 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 1102 InputHandler::Wheel)); |
| 1093 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 1103 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 1094 host_impl_->ScrollEnd(); | 1104 host_impl_->ScrollEnd(); |
| 1095 | 1105 |
| 1096 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1106 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1097 host_impl_->ProcessScrollDeltas(); | 1107 host_impl_->ProcessScrollDeltas(); |
| 1098 ExpectContains(*scroll_info.get(), scroll_layer->id(), | 1108 ExpectContains(*scroll_info.get(), scroll_layer->id(), |
| 1099 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)); | 1109 gfx::Vector2d(0, scroll_delta.y() / page_scale_delta)); |
| 1100 } | 1110 } |
| 1101 } | 1111 } |
| 1102 | 1112 |
| 1103 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { | 1113 TEST_F(LayerTreeHostImplTest, ScrollWithSwapPromises) { |
| 1104 ui::LatencyInfo latency_info; | 1114 ui::LatencyInfo latency_info; |
| 1105 latency_info.trace_id = 1234; | 1115 latency_info.trace_id = 1234; |
| 1106 scoped_ptr<SwapPromise> swap_promise( | 1116 scoped_ptr<SwapPromise> swap_promise( |
| 1107 new LatencyInfoSwapPromise(latency_info)); | 1117 new LatencyInfoSwapPromise(latency_info)); |
| 1108 | 1118 |
| 1109 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1119 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1110 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1120 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1111 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 1121 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 1112 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1122 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 1113 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); | 1123 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate(swap_promise.Pass()); |
| 1114 host_impl_->ScrollEnd(); | 1124 host_impl_->ScrollEnd(); |
| 1115 | 1125 |
| 1116 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 1126 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 1117 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 1127 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
| 1118 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); | 1128 EXPECT_EQ(latency_info.trace_id, scroll_info->swap_promises[0]->TraceId()); |
| 1119 } | 1129 } |
| 1120 | 1130 |
| 1121 TEST_F(LayerTreeHostImplTest, PinchGesture) { | 1131 TEST_F(LayerTreeHostImplTest, PinchGesture) { |
| 1122 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 1132 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 1123 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1133 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1124 DrawFrame(); | 1134 DrawFrame(); |
| 1125 | 1135 |
| 1126 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); | 1136 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); |
| 1127 DCHECK(scroll_layer); | 1137 DCHECK(scroll_layer); |
| 1128 | 1138 |
| 1129 float min_page_scale = 1.f; | 1139 float min_page_scale = 1.f; |
| 1130 float max_page_scale = 4.f; | 1140 float max_page_scale = 4.f; |
| 1131 | 1141 |
| 1132 // Basic pinch zoom in gesture | 1142 // Basic pinch zoom in gesture |
| 1133 { | 1143 { |
| 1134 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1144 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1135 max_page_scale); | 1145 max_page_scale); |
| 1136 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1146 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1137 | 1147 |
| 1138 float page_scale_delta = 2.f; | 1148 float page_scale_delta = 2.f; |
| 1139 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::GESTURE); | 1149 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
| 1140 host_impl_->PinchGestureBegin(); | 1150 host_impl_->PinchGestureBegin(); |
| 1141 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 1151 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 1142 host_impl_->PinchGestureEnd(); | 1152 host_impl_->PinchGestureEnd(); |
| 1143 host_impl_->ScrollEnd(); | 1153 host_impl_->ScrollEnd(); |
| 1144 EXPECT_FALSE(did_request_animate_); | 1154 EXPECT_FALSE(did_request_animate_); |
| 1145 EXPECT_TRUE(did_request_redraw_); | 1155 EXPECT_TRUE(did_request_redraw_); |
| 1146 EXPECT_TRUE(did_request_commit_); | 1156 EXPECT_TRUE(did_request_commit_); |
| 1147 | 1157 |
| 1148 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1158 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1149 host_impl_->ProcessScrollDeltas(); | 1159 host_impl_->ProcessScrollDeltas(); |
| 1150 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1160 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1151 } | 1161 } |
| 1152 | 1162 |
| 1153 // Zoom-in clamping | 1163 // Zoom-in clamping |
| 1154 { | 1164 { |
| 1155 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1165 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1156 max_page_scale); | 1166 max_page_scale); |
| 1157 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1167 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1158 float page_scale_delta = 10.f; | 1168 float page_scale_delta = 10.f; |
| 1159 | 1169 |
| 1160 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::GESTURE); | 1170 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
| 1161 host_impl_->PinchGestureBegin(); | 1171 host_impl_->PinchGestureBegin(); |
| 1162 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 1172 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
| 1163 host_impl_->PinchGestureEnd(); | 1173 host_impl_->PinchGestureEnd(); |
| 1164 host_impl_->ScrollEnd(); | 1174 host_impl_->ScrollEnd(); |
| 1165 | 1175 |
| 1166 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1176 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1167 host_impl_->ProcessScrollDeltas(); | 1177 host_impl_->ProcessScrollDeltas(); |
| 1168 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); | 1178 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); |
| 1169 } | 1179 } |
| 1170 | 1180 |
| 1171 // Zoom-out clamping | 1181 // Zoom-out clamping |
| 1172 { | 1182 { |
| 1173 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1183 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1174 max_page_scale); | 1184 max_page_scale); |
| 1175 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1185 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1176 scroll_layer->PullDeltaForMainThread(); | 1186 scroll_layer->PullDeltaForMainThread(); |
| 1177 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); | 1187 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); |
| 1178 | 1188 |
| 1179 float page_scale_delta = 0.1f; | 1189 float page_scale_delta = 0.1f; |
| 1180 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 1190 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 1181 host_impl_->PinchGestureBegin(); | 1191 host_impl_->PinchGestureBegin(); |
| 1182 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 1192 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 1183 host_impl_->PinchGestureEnd(); | 1193 host_impl_->PinchGestureEnd(); |
| 1184 host_impl_->ScrollEnd(); | 1194 host_impl_->ScrollEnd(); |
| 1185 | 1195 |
| 1186 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1196 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1187 host_impl_->ProcessScrollDeltas(); | 1197 host_impl_->ProcessScrollDeltas(); |
| 1188 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 1198 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
| 1189 | 1199 |
| 1190 EXPECT_TRUE(scroll_info->scrolls.empty()); | 1200 EXPECT_TRUE(scroll_info->scrolls.empty()); |
| 1191 } | 1201 } |
| 1192 | 1202 |
| 1193 // Two-finger panning should not happen based on pinch events only | 1203 // Two-finger panning should not happen based on pinch events only |
| 1194 { | 1204 { |
| 1195 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1205 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1196 max_page_scale); | 1206 max_page_scale); |
| 1197 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1207 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1198 scroll_layer->PullDeltaForMainThread(); | 1208 scroll_layer->PullDeltaForMainThread(); |
| 1199 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); | 1209 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
| 1200 | 1210 |
| 1201 float page_scale_delta = 1.f; | 1211 float page_scale_delta = 1.f; |
| 1202 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE); | 1212 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); |
| 1203 host_impl_->PinchGestureBegin(); | 1213 host_impl_->PinchGestureBegin(); |
| 1204 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1214 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
| 1205 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1215 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
| 1206 host_impl_->PinchGestureEnd(); | 1216 host_impl_->PinchGestureEnd(); |
| 1207 host_impl_->ScrollEnd(); | 1217 host_impl_->ScrollEnd(); |
| 1208 | 1218 |
| 1209 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1219 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1210 host_impl_->ProcessScrollDeltas(); | 1220 host_impl_->ProcessScrollDeltas(); |
| 1211 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1221 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1212 EXPECT_TRUE(scroll_info->scrolls.empty()); | 1222 EXPECT_TRUE(scroll_info->scrolls.empty()); |
| 1213 } | 1223 } |
| 1214 | 1224 |
| 1215 // Two-finger panning should work with interleaved scroll events | 1225 // Two-finger panning should work with interleaved scroll events |
| 1216 { | 1226 { |
| 1217 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, | 1227 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, |
| 1218 max_page_scale); | 1228 max_page_scale); |
| 1219 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1229 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1220 scroll_layer->PullDeltaForMainThread(); | 1230 scroll_layer->PullDeltaForMainThread(); |
| 1221 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); | 1231 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); |
| 1222 | 1232 |
| 1223 float page_scale_delta = 1.f; | 1233 float page_scale_delta = 1.f; |
| 1224 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE); | 1234 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture); |
| 1225 host_impl_->PinchGestureBegin(); | 1235 host_impl_->PinchGestureBegin(); |
| 1226 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); | 1236 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); |
| 1227 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 1237 host_impl_->ScrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
| 1228 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); | 1238 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); |
| 1229 host_impl_->PinchGestureEnd(); | 1239 host_impl_->PinchGestureEnd(); |
| 1230 host_impl_->ScrollEnd(); | 1240 host_impl_->ScrollEnd(); |
| 1231 | 1241 |
| 1232 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1242 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1233 host_impl_->ProcessScrollDeltas(); | 1243 host_impl_->ProcessScrollDeltas(); |
| 1234 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 1244 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
| 1235 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); | 1245 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-10, -10)); |
| 1236 } | 1246 } |
| 1237 | 1247 |
| 1238 // Two-finger panning should work when starting fully zoomed out. | 1248 // Two-finger panning should work when starting fully zoomed out. |
| 1239 { | 1249 { |
| 1240 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); | 1250 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); |
| 1241 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 1251 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 1242 scroll_layer->PullDeltaForMainThread(); | 1252 scroll_layer->PullDeltaForMainThread(); |
| 1243 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); | 1253 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); |
| 1244 | 1254 |
| 1245 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::GESTURE); | 1255 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Gesture); |
| 1246 host_impl_->PinchGestureBegin(); | 1256 host_impl_->PinchGestureBegin(); |
| 1247 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); | 1257 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); |
| 1248 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); | 1258 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); |
| 1249 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); | 1259 host_impl_->ScrollBy(gfx::Point(0, 0), gfx::Vector2d(10, 10)); |
| 1250 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); | 1260 host_impl_->PinchGestureUpdate(1.f, gfx::Point(10, 10)); |
| 1251 host_impl_->PinchGestureEnd(); | 1261 host_impl_->PinchGestureEnd(); |
| 1252 host_impl_->ScrollEnd(); | 1262 host_impl_->ScrollEnd(); |
| 1253 | 1263 |
| 1254 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1264 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 1255 host_impl_->ProcessScrollDeltas(); | 1265 host_impl_->ProcessScrollDeltas(); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 root->AddChild(scrollbar.Pass()); \ | 1611 root->AddChild(scrollbar.Pass()); \ |
| 1602 \ | 1612 \ |
| 1603 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ | 1613 host_impl_->active_tree()->SetRootLayer(root.Pass()); \ |
| 1604 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ | 1614 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, \ |
| 1605 Layer::INVALID_ID); \ | 1615 Layer::INVALID_ID); \ |
| 1606 host_impl_->active_tree()->DidBecomeActive(); \ | 1616 host_impl_->active_tree()->DidBecomeActive(); \ |
| 1607 DrawFrame(); | 1617 DrawFrame(); |
| 1608 | 1618 |
| 1609 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { | 1619 TEST_F(LayerTreeHostImplTest, ScrollbarLinearFadeScheduling) { |
| 1610 LayerTreeSettings settings; | 1620 LayerTreeSettings settings; |
| 1611 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; | 1621 settings.scrollbar_animator = LayerTreeSettings::LinearFade; |
| 1612 settings.scrollbar_fade_delay_ms = 20; | 1622 settings.scrollbar_fade_delay_ms = 20; |
| 1613 settings.scrollbar_fade_duration_ms = 20; | 1623 settings.scrollbar_fade_duration_ms = 20; |
| 1614 | 1624 |
| 1615 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); | 1625 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |
| 1616 | 1626 |
| 1617 base::TimeTicks fake_now = gfx::FrameTime::Now(); | 1627 base::TimeTicks fake_now = gfx::FrameTime::Now(); |
| 1618 | 1628 |
| 1619 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1629 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1620 EXPECT_FALSE(did_request_redraw_); | 1630 EXPECT_FALSE(did_request_redraw_); |
| 1621 | 1631 |
| 1622 // If no scroll happened during a scroll gesture, it should have no effect. | 1632 // If no scroll happened during a scroll gesture, it should have no effect. |
| 1623 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1633 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1624 host_impl_->ScrollEnd(); | 1634 host_impl_->ScrollEnd(); |
| 1625 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1635 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1626 EXPECT_FALSE(did_request_redraw_); | 1636 EXPECT_FALSE(did_request_redraw_); |
| 1627 EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure())); | 1637 EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure())); |
| 1628 | 1638 |
| 1629 // After a scroll, a fade animation should be scheduled about 20ms from now. | 1639 // After a scroll, a fade animation should be scheduled about 20ms from now. |
| 1630 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1640 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1631 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5)); | 1641 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5)); |
| 1632 host_impl_->ScrollEnd(); | 1642 host_impl_->ScrollEnd(); |
| 1633 did_request_redraw_ = false; | 1643 did_request_redraw_ = false; |
| 1634 did_request_animate_ = false; | 1644 did_request_animate_ = false; |
| 1635 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1645 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
| 1636 requested_scrollbar_animation_delay_); | 1646 requested_scrollbar_animation_delay_); |
| 1637 EXPECT_FALSE(did_request_redraw_); | 1647 EXPECT_FALSE(did_request_redraw_); |
| 1638 EXPECT_FALSE(did_request_animate_); | 1648 EXPECT_FALSE(did_request_animate_); |
| 1639 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1649 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
| 1640 scrollbar_fade_start_.Run(); | 1650 scrollbar_fade_start_.Run(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1651 // to appear and to schedule a fade. | 1661 // to appear and to schedule a fade. |
| 1652 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( | 1662 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( |
| 1653 gfx::ScrollOffset(5, 5)); | 1663 gfx::ScrollOffset(5, 5)); |
| 1654 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1664 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
| 1655 requested_scrollbar_animation_delay_); | 1665 requested_scrollbar_animation_delay_); |
| 1656 EXPECT_FALSE(did_request_redraw_); | 1666 EXPECT_FALSE(did_request_redraw_); |
| 1657 EXPECT_FALSE(did_request_animate_); | 1667 EXPECT_FALSE(did_request_animate_); |
| 1658 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1668 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
| 1659 | 1669 |
| 1660 // Unnecessarily Fade animation of solid color scrollbar is not triggered. | 1670 // Unnecessarily Fade animation of solid color scrollbar is not triggered. |
| 1661 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1671 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1662 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1672 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
| 1663 host_impl_->ScrollEnd(); | 1673 host_impl_->ScrollEnd(); |
| 1664 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1674 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1665 } | 1675 } |
| 1666 | 1676 |
| 1667 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { | 1677 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { |
| 1668 LayerTreeSettings settings; | 1678 LayerTreeSettings settings; |
| 1669 settings.scrollbar_animator = LayerTreeSettings::LINEAR_FADE; | 1679 settings.scrollbar_animator = LayerTreeSettings::LinearFade; |
| 1670 settings.scrollbar_fade_delay_ms = 20; | 1680 settings.scrollbar_fade_delay_ms = 20; |
| 1671 settings.scrollbar_fade_duration_ms = 20; | 1681 settings.scrollbar_fade_duration_ms = 20; |
| 1672 settings.use_pinch_zoom_scrollbars = true; | 1682 settings.use_pinch_zoom_scrollbars = true; |
| 1673 | 1683 |
| 1674 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); | 1684 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |
| 1675 | 1685 |
| 1676 base::TimeTicks fake_now = gfx::FrameTime::Now(); | 1686 base::TimeTicks fake_now = gfx::FrameTime::Now(); |
| 1677 | 1687 |
| 1678 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 1688 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
| 1679 | 1689 |
| 1680 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1690 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1681 EXPECT_FALSE(did_request_animate_); | 1691 EXPECT_FALSE(did_request_animate_); |
| 1682 | 1692 |
| 1683 // If no scroll happened during a scroll gesture, it should have no effect. | 1693 // If no scroll happened during a scroll gesture, it should have no effect. |
| 1684 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1694 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1685 host_impl_->ScrollEnd(); | 1695 host_impl_->ScrollEnd(); |
| 1686 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1696 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1687 EXPECT_FALSE(did_request_animate_); | 1697 EXPECT_FALSE(did_request_animate_); |
| 1688 EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure())); | 1698 EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure())); |
| 1689 | 1699 |
| 1690 // After a scroll, no fade animation should be scheduled. | 1700 // After a scroll, no fade animation should be scheduled. |
| 1691 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1701 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1692 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1702 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
| 1693 host_impl_->ScrollEnd(); | 1703 host_impl_->ScrollEnd(); |
| 1694 did_request_redraw_ = false; | 1704 did_request_redraw_ = false; |
| 1695 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1705 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1696 EXPECT_FALSE(did_request_animate_); | 1706 EXPECT_FALSE(did_request_animate_); |
| 1697 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1707 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
| 1698 | 1708 |
| 1699 // We should not see any draw requests. | 1709 // We should not see any draw requests. |
| 1700 fake_now += base::TimeDelta::FromMilliseconds(25); | 1710 fake_now += base::TimeDelta::FromMilliseconds(25); |
| 1701 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1711 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
| 1702 EXPECT_FALSE(did_request_animate_); | 1712 EXPECT_FALSE(did_request_animate_); |
| 1703 | 1713 |
| 1704 // Make page scale > min so that subsequent scrolls will trigger fades. | 1714 // Make page scale > min so that subsequent scrolls will trigger fades. |
| 1705 host_impl_->SetPageScaleOnActiveTree(1.1f); | 1715 host_impl_->SetPageScaleOnActiveTree(1.1f); |
| 1706 | 1716 |
| 1707 // After a scroll, a fade animation should be scheduled about 20ms from now. | 1717 // After a scroll, a fade animation should be scheduled about 20ms from now. |
| 1708 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL); | 1718 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
| 1709 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1719 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
| 1710 host_impl_->ScrollEnd(); | 1720 host_impl_->ScrollEnd(); |
| 1711 did_request_redraw_ = false; | 1721 did_request_redraw_ = false; |
| 1712 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1722 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
| 1713 requested_scrollbar_animation_delay_); | 1723 requested_scrollbar_animation_delay_); |
| 1714 EXPECT_FALSE(did_request_animate_); | 1724 EXPECT_FALSE(did_request_animate_); |
| 1715 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1725 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
| 1716 scrollbar_fade_start_.Run(); | 1726 scrollbar_fade_start_.Run(); |
| 1717 | 1727 |
| 1718 // After the fade begins, we should start getting redraws instead of a | 1728 // After the fade begins, we should start getting redraws instead of a |
| 1719 // scheduled animation. | 1729 // scheduled animation. |
| 1720 fake_now += base::TimeDelta::FromMilliseconds(25); | 1730 fake_now += base::TimeDelta::FromMilliseconds(25); |
| 1721 host_impl_->Animate(fake_now); | 1731 host_impl_->Animate(fake_now); |
| 1722 EXPECT_TRUE(did_request_animate_); | 1732 EXPECT_TRUE(did_request_animate_); |
| 1723 } | 1733 } |
| 1724 | 1734 |
| 1725 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( | 1735 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( |
| 1726 float device_scale_factor) { | 1736 float device_scale_factor) { |
| 1727 LayerTreeSettings settings; | 1737 LayerTreeSettings settings; |
| 1728 settings.scrollbar_fade_delay_ms = 500; | 1738 settings.scrollbar_fade_delay_ms = 500; |
| 1729 settings.scrollbar_fade_duration_ms = 300; | 1739 settings.scrollbar_fade_duration_ms = 300; |
| 1730 settings.scrollbar_animator = LayerTreeSettings::THINNING; | 1740 settings.scrollbar_animator = LayerTreeSettings::Thinning; |
| 1731 | 1741 |
| 1732 gfx::Size viewport_size(300, 200); | 1742 gfx::Size viewport_size(300, 200); |
| 1733 gfx::Size device_viewport_size = gfx::ToFlooredSize( | 1743 gfx::Size device_viewport_size = gfx::ToFlooredSize( |
| 1734 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1744 gfx::ScaleSize(viewport_size, device_scale_factor)); |
| 1735 gfx::Size content_size(1000, 1000); | 1745 gfx::Size content_size(1000, 1000); |
| 1736 | 1746 |
| 1737 CreateHostImpl(settings, CreateOutputSurface()); | 1747 CreateHostImpl(settings, CreateOutputSurface()); |
| 1738 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 1748 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 1739 host_impl_->SetViewportSize(device_viewport_size); | 1749 host_impl_->SetViewportSize(device_viewport_size); |
| 1740 | 1750 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 EXPECT_EQ(1.f, metadata.page_scale_factor); | 1837 EXPECT_EQ(1.f, metadata.page_scale_factor); |
| 1828 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); | 1838 EXPECT_EQ(gfx::SizeF(50.f, 50.f), metadata.scrollable_viewport_size); |
| 1829 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); | 1839 EXPECT_EQ(gfx::SizeF(100.f, 100.f), metadata.root_layer_size); |
| 1830 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 1840 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 1831 EXPECT_EQ(4.f, metadata.max_page_scale_factor); | 1841 EXPECT_EQ(4.f, metadata.max_page_scale_factor); |
| 1832 EXPECT_FALSE(metadata.root_overflow_x_hidden); | 1842 EXPECT_FALSE(metadata.root_overflow_x_hidden); |
| 1833 EXPECT_FALSE(metadata.root_overflow_y_hidden); | 1843 EXPECT_FALSE(metadata.root_overflow_y_hidden); |
| 1834 } | 1844 } |
| 1835 | 1845 |
| 1836 // Scrolling should update metadata immediately. | 1846 // Scrolling should update metadata immediately. |
| 1837 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 1847 EXPECT_EQ(InputHandler::ScrollStarted, |
| 1838 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 1848 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 1839 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 1849 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 1840 { | 1850 { |
| 1841 CompositorFrameMetadata metadata = | 1851 CompositorFrameMetadata metadata = |
| 1842 host_impl_->MakeCompositorFrameMetadata(); | 1852 host_impl_->MakeCompositorFrameMetadata(); |
| 1843 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1853 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| 1844 } | 1854 } |
| 1845 host_impl_->ScrollEnd(); | 1855 host_impl_->ScrollEnd(); |
| 1846 { | 1856 { |
| 1847 CompositorFrameMetadata metadata = | 1857 CompositorFrameMetadata metadata = |
| 1848 host_impl_->MakeCompositorFrameMetadata(); | 1858 host_impl_->MakeCompositorFrameMetadata(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1861 | 1871 |
| 1862 host_impl_->active_tree() | 1872 host_impl_->active_tree() |
| 1863 ->InnerViewportScrollLayer() | 1873 ->InnerViewportScrollLayer() |
| 1864 ->set_user_scrollable_vertical(false); | 1874 ->set_user_scrollable_vertical(false); |
| 1865 metadata = host_impl_->MakeCompositorFrameMetadata(); | 1875 metadata = host_impl_->MakeCompositorFrameMetadata(); |
| 1866 EXPECT_TRUE(metadata.root_overflow_x_hidden); | 1876 EXPECT_TRUE(metadata.root_overflow_x_hidden); |
| 1867 EXPECT_TRUE(metadata.root_overflow_y_hidden); | 1877 EXPECT_TRUE(metadata.root_overflow_y_hidden); |
| 1868 } | 1878 } |
| 1869 | 1879 |
| 1870 // Page scale should update metadata correctly (shrinking only the viewport). | 1880 // Page scale should update metadata correctly (shrinking only the viewport). |
| 1871 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 1881 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 1872 host_impl_->PinchGestureBegin(); | 1882 host_impl_->PinchGestureBegin(); |
| 1873 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); | 1883 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); |
| 1874 host_impl_->PinchGestureEnd(); | 1884 host_impl_->PinchGestureEnd(); |
| 1875 host_impl_->ScrollEnd(); | 1885 host_impl_->ScrollEnd(); |
| 1876 { | 1886 { |
| 1877 CompositorFrameMetadata metadata = | 1887 CompositorFrameMetadata metadata = |
| 1878 host_impl_->MakeCompositorFrameMetadata(); | 1888 host_impl_->MakeCompositorFrameMetadata(); |
| 1879 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); | 1889 EXPECT_EQ(gfx::Vector2dF(0.f, 10.f), metadata.root_scroll_offset); |
| 1880 EXPECT_EQ(2.f, metadata.page_scale_factor); | 1890 EXPECT_EQ(2.f, metadata.page_scale_factor); |
| 1881 EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size); | 1891 EXPECT_EQ(gfx::SizeF(25.f, 25.f), metadata.scrollable_viewport_size); |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2427 } | 2437 } |
| 2428 | 2438 |
| 2429 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { | 2439 TEST_F(LayerTreeHostImplTest, ScrollRootIgnored) { |
| 2430 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 2440 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 2431 root->SetScrollClipLayer(Layer::INVALID_ID); | 2441 root->SetScrollClipLayer(Layer::INVALID_ID); |
| 2432 root->SetHasRenderSurface(true); | 2442 root->SetHasRenderSurface(true); |
| 2433 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 2443 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 2434 DrawFrame(); | 2444 DrawFrame(); |
| 2435 | 2445 |
| 2436 // Scroll event is ignored because layer is not scrollable. | 2446 // Scroll event is ignored because layer is not scrollable. |
| 2437 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 2447 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 2438 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 2448 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 2439 EXPECT_FALSE(did_request_redraw_); | 2449 EXPECT_FALSE(did_request_redraw_); |
| 2440 EXPECT_FALSE(did_request_commit_); | 2450 EXPECT_FALSE(did_request_commit_); |
| 2441 } | 2451 } |
| 2442 | 2452 |
| 2443 // TODO(bokan): Convert these tests to create inner and outer viewports. | 2453 // TODO(bokan): Convert these tests to create inner and outer viewports. |
| 2444 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { | 2454 class LayerTreeHostImplTopControlsTest : public LayerTreeHostImplTest { |
| 2445 public: | 2455 public: |
| 2446 LayerTreeHostImplTopControlsTest() | 2456 LayerTreeHostImplTopControlsTest() |
| 2447 // Make the clip size the same as the layer (content) size so the layer is | 2457 // Make the clip size the same as the layer (content) size so the layer is |
| 2448 // non-scrollable. | 2458 // non-scrollable. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 float top_controls_height_; | 2595 float top_controls_height_; |
| 2586 | 2596 |
| 2587 LayerTreeSettings settings_; | 2597 LayerTreeSettings settings_; |
| 2588 }; // class LayerTreeHostImplTopControlsTest | 2598 }; // class LayerTreeHostImplTopControlsTest |
| 2589 | 2599 |
| 2590 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { | 2600 TEST_F(LayerTreeHostImplTopControlsTest, ScrollTopControlsByFractionalAmount) { |
| 2591 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2601 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2592 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); | 2602 gfx::Size(10, 10), gfx::Size(10, 10), gfx::Size(10, 10)); |
| 2593 DrawFrame(); | 2603 DrawFrame(); |
| 2594 | 2604 |
| 2595 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2605 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2596 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2606 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2597 | 2607 |
| 2598 // Make the test scroll delta a fractional amount, to verify that the | 2608 // Make the test scroll delta a fractional amount, to verify that the |
| 2599 // fixed container size delta is (1) non-zero, and (2) fractional, and | 2609 // fixed container size delta is (1) non-zero, and (2) fractional, and |
| 2600 // (3) matches the movement of the top controls. | 2610 // (3) matches the movement of the top controls. |
| 2601 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); | 2611 gfx::Vector2dF top_controls_scroll_delta(0.f, 5.25f); |
| 2602 host_impl_->top_controls_manager()->ScrollBegin(); | 2612 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2603 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2613 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2604 host_impl_->top_controls_manager()->ScrollEnd(); | 2614 host_impl_->top_controls_manager()->ScrollEnd(); |
| 2605 | 2615 |
| 2606 LayerImpl* inner_viewport_scroll_layer = | 2616 LayerImpl* inner_viewport_scroll_layer = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2626 host_impl_->active_tree()->InnerViewportContainerLayer(); | 2636 host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 2627 LayerImpl *outer_scroll = | 2637 LayerImpl *outer_scroll = |
| 2628 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2638 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2629 LayerImpl *outer_container = | 2639 LayerImpl *outer_container = |
| 2630 host_impl_->active_tree()->OuterViewportContainerLayer(); | 2640 host_impl_->active_tree()->OuterViewportContainerLayer(); |
| 2631 | 2641 |
| 2632 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. | 2642 // Need SetDrawsContent so ScrollBegin's hit test finds an actual layer. |
| 2633 outer_scroll->SetDrawsContent(true); | 2643 outer_scroll->SetDrawsContent(true); |
| 2634 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); | 2644 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 1.f, 2.f); |
| 2635 | 2645 |
| 2636 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2646 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2637 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2647 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2638 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); | 2648 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 50.f)); |
| 2639 | 2649 |
| 2640 // The entire scroll delta should have been used to hide the top controls. | 2650 // The entire scroll delta should have been used to hide the top controls. |
| 2641 // The viewport layers should be resized back to their full sizes. | 2651 // The viewport layers should be resized back to their full sizes. |
| 2642 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 2652 EXPECT_EQ(0.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2643 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); | 2653 EXPECT_EQ(0.f, inner_scroll->CurrentScrollOffset().y()); |
| 2644 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); | 2654 EXPECT_EQ(100.f, inner_container->BoundsForScrolling().height()); |
| 2645 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); | 2655 EXPECT_EQ(100.f, outer_container->BoundsForScrolling().height()); |
| 2646 | 2656 |
| 2647 // The inner viewport should be scrollable by 50px * page_scale. | 2657 // The inner viewport should be scrollable by 50px * page_scale. |
| 2648 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); | 2658 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, 100.f)); |
| 2649 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); | 2659 EXPECT_EQ(50.f, inner_scroll->CurrentScrollOffset().y()); |
| 2650 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); | 2660 EXPECT_EQ(0.f, outer_scroll->CurrentScrollOffset().y()); |
| 2651 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); | 2661 EXPECT_EQ(gfx::ScrollOffset(), outer_scroll->MaxScrollOffset()); |
| 2652 | 2662 |
| 2653 host_impl_->ScrollEnd(); | 2663 host_impl_->ScrollEnd(); |
| 2654 | 2664 |
| 2655 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2665 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2656 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2666 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2657 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 2667 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 2658 | 2668 |
| 2659 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); | 2669 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.f, -50.f)); |
| 2660 | 2670 |
| 2661 // The entire scroll delta should have been used to show the top controls. | 2671 // The entire scroll delta should have been used to show the top controls. |
| 2662 // The outer viewport should be resized to accomodate and scrolled to the | 2672 // The outer viewport should be resized to accomodate and scrolled to the |
| 2663 // bottom of the document to keep the viewport in place. | 2673 // bottom of the document to keep the viewport in place. |
| 2664 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 2674 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2665 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); | 2675 EXPECT_EQ(50.f, outer_container->BoundsForScrolling().height()); |
| 2666 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); | 2676 EXPECT_EQ(50.f, inner_container->BoundsForScrolling().height()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2692 DrawFrame(); | 2702 DrawFrame(); |
| 2693 | 2703 |
| 2694 float page_scale = 1.5f; | 2704 float page_scale = 1.5f; |
| 2695 LayerImpl* outer_viewport_scroll_layer = | 2705 LayerImpl* outer_viewport_scroll_layer = |
| 2696 host_impl_->active_tree()->OuterViewportScrollLayer(); | 2706 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2697 | 2707 |
| 2698 // Zoom in, since the fixed container is the outer viewport, the delta should | 2708 // Zoom in, since the fixed container is the outer viewport, the delta should |
| 2699 // not be scaled. | 2709 // not be scaled. |
| 2700 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); | 2710 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, 2.f); |
| 2701 | 2711 |
| 2702 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2712 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2703 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2713 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2704 | 2714 |
| 2705 // Scroll down, the top controls hiding should expand the viewport size so | 2715 // Scroll down, the top controls hiding should expand the viewport size so |
| 2706 // the delta should be equal to the scroll distance. | 2716 // the delta should be equal to the scroll distance. |
| 2707 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); | 2717 gfx::Vector2dF top_controls_scroll_delta(0.f, 20.f); |
| 2708 host_impl_->top_controls_manager()->ScrollBegin(); | 2718 host_impl_->top_controls_manager()->ScrollBegin(); |
| 2709 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); | 2719 host_impl_->top_controls_manager()->ScrollBy(top_controls_scroll_delta); |
| 2710 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), | 2720 EXPECT_FLOAT_EQ(top_controls_height_ - top_controls_scroll_delta.y(), |
| 2711 host_impl_->top_controls_manager()->ContentTopOffset()); | 2721 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2712 EXPECT_VECTOR_EQ(top_controls_scroll_delta, | 2722 EXPECT_VECTOR_EQ(top_controls_scroll_delta, |
| 2713 outer_viewport_scroll_layer->FixedContainerSizeDelta()); | 2723 outer_viewport_scroll_layer->FixedContainerSizeDelta()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 child->SetDrawsContent(true); | 2774 child->SetDrawsContent(true); |
| 2765 child->SetIsContainerForFixedPositionLayers(true); | 2775 child->SetIsContainerForFixedPositionLayers(true); |
| 2766 | 2776 |
| 2767 // scroll child to limit | 2777 // scroll child to limit |
| 2768 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); | 2778 child->SetScrollDelta(gfx::Vector2dF(0, 100.f)); |
| 2769 child_clip->AddChild(child.Pass()); | 2779 child_clip->AddChild(child.Pass()); |
| 2770 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); | 2780 outer_viewport_scroll_layer->AddChild(child_clip.Pass()); |
| 2771 | 2781 |
| 2772 // Scroll 25px to hide top controls | 2782 // Scroll 25px to hide top controls |
| 2773 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2783 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2774 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2784 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2775 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2785 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2776 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2786 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2777 host_impl_->ScrollEnd(); | 2787 host_impl_->ScrollEnd(); |
| 2778 | 2788 |
| 2779 // Top controls should be hidden | 2789 // Top controls should be hidden |
| 2780 EXPECT_EQ(scroll_delta.y(), | 2790 EXPECT_EQ(scroll_delta.y(), |
| 2781 top_controls_height_ - | 2791 top_controls_height_ - |
| 2782 host_impl_->top_controls_manager()->ContentTopOffset()); | 2792 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2783 } | 2793 } |
| 2784 | 2794 |
| 2785 // Ensure setting the top controls position explicitly using the setters on the | 2795 // Ensure setting the top controls position explicitly using the setters on the |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2913 // Scroll the viewports to max scroll offset. | 2923 // Scroll the viewports to max scroll offset. |
| 2914 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 2924 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
| 2915 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 2925 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
| 2916 | 2926 |
| 2917 gfx::ScrollOffset viewport_offset = | 2927 gfx::ScrollOffset viewport_offset = |
| 2918 host_impl_->active_tree()->TotalScrollOffset(); | 2928 host_impl_->active_tree()->TotalScrollOffset(); |
| 2919 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); | 2929 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), viewport_offset); |
| 2920 | 2930 |
| 2921 // Hide the top controls by 25px. | 2931 // Hide the top controls by 25px. |
| 2922 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2932 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2923 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2933 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2924 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2934 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2925 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2935 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2926 | 2936 |
| 2927 // scrolling down at the max extents no longer hides the top controls | 2937 // scrolling down at the max extents no longer hides the top controls |
| 2928 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); | 2938 EXPECT_EQ(1.f, host_impl_->active_tree()->CurrentTopControlsShownRatio()); |
| 2929 | 2939 |
| 2930 // forcefully hide the top controls by 25px | 2940 // forcefully hide the top controls by 25px |
| 2931 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); | 2941 host_impl_->top_controls_manager()->ScrollBy(scroll_delta); |
| 2932 host_impl_->ScrollEnd(); | 2942 host_impl_->ScrollEnd(); |
| 2933 | 2943 |
| 2934 EXPECT_FLOAT_EQ(scroll_delta.y(), | 2944 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 2935 top_controls_height_ - | 2945 top_controls_height_ - |
| 2936 host_impl_->top_controls_manager()->ContentTopOffset()); | 2946 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2937 | 2947 |
| 2938 inner_scroll->ClampScrollToMaxScrollOffset(); | 2948 inner_scroll->ClampScrollToMaxScrollOffset(); |
| 2939 outer_scroll->ClampScrollToMaxScrollOffset(); | 2949 outer_scroll->ClampScrollToMaxScrollOffset(); |
| 2940 | 2950 |
| 2941 // We should still be fully scrolled. | 2951 // We should still be fully scrolled. |
| 2942 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 2952 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 2943 host_impl_->active_tree()->TotalScrollOffset()); | 2953 host_impl_->active_tree()->TotalScrollOffset()); |
| 2944 | 2954 |
| 2945 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); | 2955 viewport_offset = host_impl_->active_tree()->TotalScrollOffset(); |
| 2946 | 2956 |
| 2947 // Bring the top controls down by 25px. | 2957 // Bring the top controls down by 25px. |
| 2948 scroll_delta = gfx::Vector2dF(0.f, -25.f); | 2958 scroll_delta = gfx::Vector2dF(0.f, -25.f); |
| 2949 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2959 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2950 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2960 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2951 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2961 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2952 host_impl_->ScrollEnd(); | 2962 host_impl_->ScrollEnd(); |
| 2953 | 2963 |
| 2954 // The viewport offset shouldn't have changed. | 2964 // The viewport offset shouldn't have changed. |
| 2955 EXPECT_EQ(viewport_offset, | 2965 EXPECT_EQ(viewport_offset, |
| 2956 host_impl_->active_tree()->TotalScrollOffset()); | 2966 host_impl_->active_tree()->TotalScrollOffset()); |
| 2957 | 2967 |
| 2958 // Scroll the viewports to max scroll offset. | 2968 // Scroll the viewports to max scroll offset. |
| 2959 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); | 2969 outer_scroll->SetScrollDelta(gfx::Vector2dF(0, 200.f)); |
| 2960 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); | 2970 inner_scroll->SetScrollDelta(gfx::Vector2dF(100, 100.f)); |
| 2961 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), | 2971 EXPECT_EQ(host_impl_->active_tree()->TotalMaxScrollOffset(), |
| 2962 host_impl_->active_tree()->TotalScrollOffset()); | 2972 host_impl_->active_tree()->TotalScrollOffset()); |
| 2963 } | 2973 } |
| 2964 | 2974 |
| 2965 // Test that the top controls coming in and out maintains the same aspect ratio | 2975 // Test that the top controls coming in and out maintains the same aspect ratio |
| 2966 // between the inner and outer viewports. | 2976 // between the inner and outer viewports. |
| 2967 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { | 2977 TEST_F(LayerTreeHostImplTopControlsTest, TopControlsAspectRatio) { |
| 2968 SetupTopControlsAndScrollLayerWithVirtualViewport( | 2978 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 2969 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 2979 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 2970 DrawFrame(); | 2980 DrawFrame(); |
| 2971 | 2981 |
| 2972 EXPECT_FLOAT_EQ(top_controls_height_, | 2982 EXPECT_FLOAT_EQ(top_controls_height_, |
| 2973 host_impl_->top_controls_manager()->ContentTopOffset()); | 2983 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2974 | 2984 |
| 2975 gfx::Vector2dF scroll_delta(0.f, 25.f); | 2985 gfx::Vector2dF scroll_delta(0.f, 25.f); |
| 2976 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 2986 EXPECT_EQ(InputHandler::ScrollStarted, |
| 2977 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 2987 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 2978 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 2988 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 2979 host_impl_->ScrollEnd(); | 2989 host_impl_->ScrollEnd(); |
| 2980 | 2990 |
| 2981 EXPECT_FLOAT_EQ(scroll_delta.y(), | 2991 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 2982 top_controls_height_ - | 2992 top_controls_height_ - |
| 2983 host_impl_->top_controls_manager()->ContentTopOffset()); | 2993 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 2984 | 2994 |
| 2985 // Top controls were hidden by 25px so the inner viewport should have expanded | 2995 // Top controls were hidden by 25px so the inner viewport should have expanded |
| 2986 // by that much. | 2996 // by that much. |
| 2987 LayerImpl* outer_container = | 2997 LayerImpl* outer_container = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3004 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3014 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3005 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); | 3015 gfx::Size(100, 100), gfx::Size(200, 200), gfx::Size(200, 400)); |
| 3006 DrawFrame(); | 3016 DrawFrame(); |
| 3007 | 3017 |
| 3008 EXPECT_EQ(top_controls_height_, | 3018 EXPECT_EQ(top_controls_height_, |
| 3009 host_impl_->top_controls_manager()->ContentTopOffset()); | 3019 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3010 | 3020 |
| 3011 // Send a gesture scroll that will scroll the outer viewport, make sure the | 3021 // Send a gesture scroll that will scroll the outer viewport, make sure the |
| 3012 // top controls get scrolled. | 3022 // top controls get scrolled. |
| 3013 gfx::Vector2dF scroll_delta(0.f, 15.f); | 3023 gfx::Vector2dF scroll_delta(0.f, 15.f); |
| 3014 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3024 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3015 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3025 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3016 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3026 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3017 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3027 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 3018 host_impl_->CurrentlyScrollingLayer()); | 3028 host_impl_->CurrentlyScrollingLayer()); |
| 3019 host_impl_->ScrollEnd(); | 3029 host_impl_->ScrollEnd(); |
| 3020 | 3030 |
| 3021 EXPECT_FLOAT_EQ(scroll_delta.y(), | 3031 EXPECT_FLOAT_EQ(scroll_delta.y(), |
| 3022 top_controls_height_ - | 3032 top_controls_height_ - |
| 3023 host_impl_->top_controls_manager()->ContentTopOffset()); | 3033 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3024 | 3034 |
| 3025 scroll_delta = gfx::Vector2dF(0.f, 50.f); | 3035 scroll_delta = gfx::Vector2dF(0.f, 50.f); |
| 3026 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3036 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3027 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3037 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3028 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3038 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3029 | 3039 |
| 3030 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); | 3040 EXPECT_EQ(0, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3031 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), | 3041 EXPECT_EQ(host_impl_->OuterViewportScrollLayer(), |
| 3032 host_impl_->CurrentlyScrollingLayer()); | 3042 host_impl_->CurrentlyScrollingLayer()); |
| 3033 | 3043 |
| 3034 host_impl_->ScrollEnd(); | 3044 host_impl_->ScrollEnd(); |
| 3035 | 3045 |
| 3036 // Position the viewports such that the inner viewport will be scrolled. | 3046 // Position the viewports such that the inner viewport will be scrolled. |
| 3037 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); | 3047 gfx::Vector2dF inner_viewport_offset(0.f, 25.f); |
| 3038 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); | 3048 host_impl_->OuterViewportScrollLayer()->SetScrollDelta(gfx::Vector2dF()); |
| 3039 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); | 3049 host_impl_->InnerViewportScrollLayer()->SetScrollDelta(inner_viewport_offset); |
| 3040 | 3050 |
| 3041 scroll_delta = gfx::Vector2dF(0.f, -65.f); | 3051 scroll_delta = gfx::Vector2dF(0.f, -65.f); |
| 3042 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3052 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3043 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3053 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3044 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3054 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3045 | 3055 |
| 3046 EXPECT_EQ(top_controls_height_, | 3056 EXPECT_EQ(top_controls_height_, |
| 3047 host_impl_->top_controls_manager()->ContentTopOffset()); | 3057 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3048 EXPECT_FLOAT_EQ( | 3058 EXPECT_FLOAT_EQ( |
| 3049 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), | 3059 inner_viewport_offset.y() + (scroll_delta.y() + top_controls_height_), |
| 3050 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); | 3060 host_impl_->InnerViewportScrollLayer()->ScrollDelta().y()); |
| 3051 | 3061 |
| 3052 host_impl_->ScrollEnd(); | 3062 host_impl_->ScrollEnd(); |
| 3053 } | 3063 } |
| 3054 | 3064 |
| 3055 TEST_F(LayerTreeHostImplTopControlsTest, | 3065 TEST_F(LayerTreeHostImplTopControlsTest, |
| 3056 ScrollNonScrollableRootWithTopControls) { | 3066 ScrollNonScrollableRootWithTopControls) { |
| 3057 CreateHostImpl(settings_, CreateOutputSurface()); | 3067 CreateHostImpl(settings_, CreateOutputSurface()); |
| 3058 SetupTopControlsAndScrollLayer(); | 3068 SetupTopControlsAndScrollLayer(); |
| 3059 DrawFrame(); | 3069 DrawFrame(); |
| 3060 | 3070 |
| 3061 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3071 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3062 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3072 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3063 | 3073 |
| 3064 host_impl_->top_controls_manager()->ScrollBegin(); | 3074 host_impl_->top_controls_manager()->ScrollBegin(); |
| 3065 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 3075 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
| 3066 host_impl_->top_controls_manager()->ScrollEnd(); | 3076 host_impl_->top_controls_manager()->ScrollEnd(); |
| 3067 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 3077 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3068 // Now that top controls have moved, expect the clip to resize. | 3078 // Now that top controls have moved, expect the clip to resize. |
| 3069 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); | 3079 LayerImpl* root_clip_ptr = host_impl_->active_tree()->root_layer(); |
| 3070 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); | 3080 EXPECT_EQ(viewport_size_, root_clip_ptr->bounds()); |
| 3071 | 3081 |
| 3072 host_impl_->ScrollEnd(); | 3082 host_impl_->ScrollEnd(); |
| 3073 | 3083 |
| 3074 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3084 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3075 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3085 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3076 | 3086 |
| 3077 float scroll_increment_y = -25.f; | 3087 float scroll_increment_y = -25.f; |
| 3078 host_impl_->top_controls_manager()->ScrollBegin(); | 3088 host_impl_->top_controls_manager()->ScrollBegin(); |
| 3079 host_impl_->top_controls_manager()->ScrollBy( | 3089 host_impl_->top_controls_manager()->ScrollBy( |
| 3080 gfx::Vector2dF(0.f, scroll_increment_y)); | 3090 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 3081 EXPECT_FLOAT_EQ(-scroll_increment_y, | 3091 EXPECT_FLOAT_EQ(-scroll_increment_y, |
| 3082 host_impl_->top_controls_manager()->ContentTopOffset()); | 3092 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3083 // Now that top controls have moved, expect the clip to resize. | 3093 // Now that top controls have moved, expect the clip to resize. |
| 3084 EXPECT_EQ(gfx::Size(viewport_size_.width(), | 3094 EXPECT_EQ(gfx::Size(viewport_size_.width(), |
| 3085 viewport_size_.height() + scroll_increment_y), | 3095 viewport_size_.height() + scroll_increment_y), |
| 3086 root_clip_ptr->bounds()); | 3096 root_clip_ptr->bounds()); |
| 3087 | 3097 |
| 3088 host_impl_->top_controls_manager()->ScrollBy( | 3098 host_impl_->top_controls_manager()->ScrollBy( |
| 3089 gfx::Vector2dF(0.f, scroll_increment_y)); | 3099 gfx::Vector2dF(0.f, scroll_increment_y)); |
| 3090 host_impl_->top_controls_manager()->ScrollEnd(); | 3100 host_impl_->top_controls_manager()->ScrollEnd(); |
| 3091 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, | 3101 EXPECT_FLOAT_EQ(-2 * scroll_increment_y, |
| 3092 host_impl_->top_controls_manager()->ContentTopOffset()); | 3102 host_impl_->top_controls_manager()->ContentTopOffset()); |
| 3093 // Now that top controls have moved, expect the clip to resize. | 3103 // Now that top controls have moved, expect the clip to resize. |
| 3094 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); | 3104 EXPECT_EQ(clip_size_, root_clip_ptr->bounds()); |
| 3095 | 3105 |
| 3096 host_impl_->ScrollEnd(); | 3106 host_impl_->ScrollEnd(); |
| 3097 | 3107 |
| 3098 // Verify the layer is once-again non-scrollable. | 3108 // Verify the layer is once-again non-scrollable. |
| 3099 EXPECT_EQ( | 3109 EXPECT_EQ( |
| 3100 gfx::ScrollOffset(), | 3110 gfx::ScrollOffset(), |
| 3101 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); | 3111 host_impl_->active_tree()->InnerViewportScrollLayer()->MaxScrollOffset()); |
| 3102 | 3112 |
| 3103 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3113 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3104 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3114 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3105 } | 3115 } |
| 3106 | 3116 |
| 3107 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { | 3117 TEST_F(LayerTreeHostImplTest, ScrollNonCompositedRoot) { |
| 3108 // Test the configuration where a non-composited root layer is embedded in a | 3118 // Test the configuration where a non-composited root layer is embedded in a |
| 3109 // scrollable outer layer. | 3119 // scrollable outer layer. |
| 3110 gfx::Size surface_size(10, 10); | 3120 gfx::Size surface_size(10, 10); |
| 3111 gfx::Size contents_size(20, 20); | 3121 gfx::Size contents_size(20, 20); |
| 3112 | 3122 |
| 3113 scoped_ptr<LayerImpl> content_layer = | 3123 scoped_ptr<LayerImpl> content_layer = |
| 3114 LayerImpl::Create(host_impl_->active_tree(), 1); | 3124 LayerImpl::Create(host_impl_->active_tree(), 1); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3129 scroll_layer->SetContentBounds(contents_size); | 3139 scroll_layer->SetContentBounds(contents_size); |
| 3130 scroll_layer->SetPosition(gfx::PointF()); | 3140 scroll_layer->SetPosition(gfx::PointF()); |
| 3131 scroll_layer->AddChild(content_layer.Pass()); | 3141 scroll_layer->AddChild(content_layer.Pass()); |
| 3132 scroll_clip_layer->AddChild(scroll_layer.Pass()); | 3142 scroll_clip_layer->AddChild(scroll_layer.Pass()); |
| 3133 | 3143 |
| 3134 scroll_clip_layer->SetHasRenderSurface(true); | 3144 scroll_clip_layer->SetHasRenderSurface(true); |
| 3135 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); | 3145 host_impl_->active_tree()->SetRootLayer(scroll_clip_layer.Pass()); |
| 3136 host_impl_->SetViewportSize(surface_size); | 3146 host_impl_->SetViewportSize(surface_size); |
| 3137 DrawFrame(); | 3147 DrawFrame(); |
| 3138 | 3148 |
| 3139 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3149 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3140 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3150 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3151 InputHandler::Wheel)); |
| 3141 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3152 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 3142 host_impl_->ScrollEnd(); | 3153 host_impl_->ScrollEnd(); |
| 3143 EXPECT_TRUE(did_request_redraw_); | 3154 EXPECT_TRUE(did_request_redraw_); |
| 3144 EXPECT_TRUE(did_request_commit_); | 3155 EXPECT_TRUE(did_request_commit_); |
| 3145 } | 3156 } |
| 3146 | 3157 |
| 3147 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { | 3158 TEST_F(LayerTreeHostImplTest, ScrollChildCallsCommitAndRedraw) { |
| 3148 gfx::Size surface_size(10, 10); | 3159 gfx::Size surface_size(10, 10); |
| 3149 gfx::Size contents_size(20, 20); | 3160 gfx::Size contents_size(20, 20); |
| 3150 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3161 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3151 root->SetBounds(surface_size); | 3162 root->SetBounds(surface_size); |
| 3152 root->SetContentBounds(contents_size); | 3163 root->SetContentBounds(contents_size); |
| 3153 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); | 3164 root->AddChild(CreateScrollableLayer(2, contents_size, root.get())); |
| 3154 root->SetHasRenderSurface(true); | 3165 root->SetHasRenderSurface(true); |
| 3155 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3166 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3156 host_impl_->SetViewportSize(surface_size); | 3167 host_impl_->SetViewportSize(surface_size); |
| 3157 DrawFrame(); | 3168 DrawFrame(); |
| 3158 | 3169 |
| 3159 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3170 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3160 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3171 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3172 InputHandler::Wheel)); |
| 3161 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3173 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 3162 host_impl_->ScrollEnd(); | 3174 host_impl_->ScrollEnd(); |
| 3163 EXPECT_TRUE(did_request_redraw_); | 3175 EXPECT_TRUE(did_request_redraw_); |
| 3164 EXPECT_TRUE(did_request_commit_); | 3176 EXPECT_TRUE(did_request_commit_); |
| 3165 } | 3177 } |
| 3166 | 3178 |
| 3167 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { | 3179 TEST_F(LayerTreeHostImplTest, ScrollMissesChild) { |
| 3168 gfx::Size surface_size(10, 10); | 3180 gfx::Size surface_size(10, 10); |
| 3169 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3181 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3170 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); | 3182 root->AddChild(CreateScrollableLayer(2, surface_size, root.get())); |
| 3171 root->SetHasRenderSurface(true); | 3183 root->SetHasRenderSurface(true); |
| 3172 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3184 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3173 host_impl_->SetViewportSize(surface_size); | 3185 host_impl_->SetViewportSize(surface_size); |
| 3174 DrawFrame(); | 3186 DrawFrame(); |
| 3175 | 3187 |
| 3176 // Scroll event is ignored because the input coordinate is outside the layer | 3188 // Scroll event is ignored because the input coordinate is outside the layer |
| 3177 // boundaries. | 3189 // boundaries. |
| 3178 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 3190 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 3179 host_impl_->ScrollBegin(gfx::Point(15, 5), InputHandler::WHEEL)); | 3191 host_impl_->ScrollBegin(gfx::Point(15, 5), |
| 3192 InputHandler::Wheel)); |
| 3180 EXPECT_FALSE(did_request_redraw_); | 3193 EXPECT_FALSE(did_request_redraw_); |
| 3181 EXPECT_FALSE(did_request_commit_); | 3194 EXPECT_FALSE(did_request_commit_); |
| 3182 } | 3195 } |
| 3183 | 3196 |
| 3184 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { | 3197 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { |
| 3185 gfx::Size surface_size(10, 10); | 3198 gfx::Size surface_size(10, 10); |
| 3186 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3199 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3187 root->SetHasRenderSurface(true); | 3200 root->SetHasRenderSurface(true); |
| 3188 scoped_ptr<LayerImpl> child = | 3201 scoped_ptr<LayerImpl> child = |
| 3189 CreateScrollableLayer(2, surface_size, root.get()); | 3202 CreateScrollableLayer(2, surface_size, root.get()); |
| 3190 host_impl_->SetViewportSize(surface_size); | 3203 host_impl_->SetViewportSize(surface_size); |
| 3191 | 3204 |
| 3192 gfx::Transform matrix; | 3205 gfx::Transform matrix; |
| 3193 matrix.RotateAboutXAxis(180.0); | 3206 matrix.RotateAboutXAxis(180.0); |
| 3194 child->SetTransform(matrix); | 3207 child->SetTransform(matrix); |
| 3195 child->SetDoubleSided(false); | 3208 child->SetDoubleSided(false); |
| 3196 | 3209 |
| 3197 root->AddChild(child.Pass()); | 3210 root->AddChild(child.Pass()); |
| 3198 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3211 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3199 DrawFrame(); | 3212 DrawFrame(); |
| 3200 | 3213 |
| 3201 // Scroll event is ignored because the scrollable layer is not facing the | 3214 // Scroll event is ignored because the scrollable layer is not facing the |
| 3202 // viewer and there is nothing scrollable behind it. | 3215 // viewer and there is nothing scrollable behind it. |
| 3203 EXPECT_EQ(InputHandler::SCROLL_IGNORED, | 3216 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 3204 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3217 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3218 InputHandler::Wheel)); |
| 3205 EXPECT_FALSE(did_request_redraw_); | 3219 EXPECT_FALSE(did_request_redraw_); |
| 3206 EXPECT_FALSE(did_request_commit_); | 3220 EXPECT_FALSE(did_request_commit_); |
| 3207 } | 3221 } |
| 3208 | 3222 |
| 3209 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { | 3223 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { |
| 3210 gfx::Size surface_size(10, 10); | 3224 gfx::Size surface_size(10, 10); |
| 3211 scoped_ptr<LayerImpl> clip_layer = | 3225 scoped_ptr<LayerImpl> clip_layer = |
| 3212 LayerImpl::Create(host_impl_->active_tree(), 3); | 3226 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3213 scoped_ptr<LayerImpl> content_layer = | 3227 scoped_ptr<LayerImpl> content_layer = |
| 3214 CreateScrollableLayer(1, surface_size, clip_layer.get()); | 3228 CreateScrollableLayer(1, surface_size, clip_layer.get()); |
| 3215 content_layer->SetShouldScrollOnMainThread(true); | 3229 content_layer->SetShouldScrollOnMainThread(true); |
| 3216 content_layer->SetScrollClipLayer(Layer::INVALID_ID); | 3230 content_layer->SetScrollClipLayer(Layer::INVALID_ID); |
| 3217 | 3231 |
| 3218 // Note: we can use the same clip layer for both since both calls to | 3232 // Note: we can use the same clip layer for both since both calls to |
| 3219 // CreateScrollableLayer() use the same surface size. | 3233 // CreateScrollableLayer() use the same surface size. |
| 3220 scoped_ptr<LayerImpl> scroll_layer = | 3234 scoped_ptr<LayerImpl> scroll_layer = |
| 3221 CreateScrollableLayer(2, surface_size, clip_layer.get()); | 3235 CreateScrollableLayer(2, surface_size, clip_layer.get()); |
| 3222 scroll_layer->AddChild(content_layer.Pass()); | 3236 scroll_layer->AddChild(content_layer.Pass()); |
| 3223 clip_layer->AddChild(scroll_layer.Pass()); | 3237 clip_layer->AddChild(scroll_layer.Pass()); |
| 3224 clip_layer->SetHasRenderSurface(true); | 3238 clip_layer->SetHasRenderSurface(true); |
| 3225 | 3239 |
| 3226 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); | 3240 host_impl_->active_tree()->SetRootLayer(clip_layer.Pass()); |
| 3227 host_impl_->SetViewportSize(surface_size); | 3241 host_impl_->SetViewportSize(surface_size); |
| 3228 DrawFrame(); | 3242 DrawFrame(); |
| 3229 | 3243 |
| 3230 // Scrolling fails because the content layer is asking to be scrolled on the | 3244 // Scrolling fails because the content layer is asking to be scrolled on the |
| 3231 // main thread. | 3245 // main thread. |
| 3232 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 3246 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 3233 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3247 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3248 InputHandler::Wheel)); |
| 3234 } | 3249 } |
| 3235 | 3250 |
| 3236 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 3251 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
| 3237 gfx::Size surface_size(20, 20); | 3252 gfx::Size surface_size(20, 20); |
| 3238 gfx::Size viewport_size(10, 10); | 3253 gfx::Size viewport_size(10, 10); |
| 3239 float page_scale = 2.f; | 3254 float page_scale = 2.f; |
| 3240 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); | 3255 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); |
| 3241 scoped_ptr<LayerImpl> root_clip = | 3256 scoped_ptr<LayerImpl> root_clip = |
| 3242 LayerImpl::Create(host_impl_->active_tree(), 2); | 3257 LayerImpl::Create(host_impl_->active_tree(), 2); |
| 3243 scoped_ptr<LayerImpl> root_scrolling = | 3258 scoped_ptr<LayerImpl> root_scrolling = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3256 host_impl_->SetViewportSize(viewport_size); | 3271 host_impl_->SetViewportSize(viewport_size); |
| 3257 DrawFrame(); | 3272 DrawFrame(); |
| 3258 | 3273 |
| 3259 LayerImpl* root_scroll = | 3274 LayerImpl* root_scroll = |
| 3260 host_impl_->active_tree()->InnerViewportScrollLayer(); | 3275 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 3261 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 3276 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| 3262 | 3277 |
| 3263 gfx::Vector2d scroll_delta(0, 10); | 3278 gfx::Vector2d scroll_delta(0, 10); |
| 3264 gfx::Vector2d expected_scroll_delta = scroll_delta; | 3279 gfx::Vector2d expected_scroll_delta = scroll_delta; |
| 3265 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 3280 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
| 3266 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3281 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3267 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3282 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3283 InputHandler::Wheel)); |
| 3268 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3284 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3269 host_impl_->ScrollEnd(); | 3285 host_impl_->ScrollEnd(); |
| 3270 | 3286 |
| 3271 // Set new page scale from main thread. | 3287 // Set new page scale from main thread. |
| 3272 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, page_scale, | 3288 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, page_scale, |
| 3273 page_scale); | 3289 page_scale); |
| 3274 | 3290 |
| 3275 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3291 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3276 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); | 3292 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); |
| 3277 | 3293 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3307 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale); | 3323 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, page_scale); |
| 3308 DrawFrame(); | 3324 DrawFrame(); |
| 3309 | 3325 |
| 3310 LayerImpl* root_scroll = | 3326 LayerImpl* root_scroll = |
| 3311 host_impl_->active_tree()->InnerViewportScrollLayer(); | 3327 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 3312 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 3328 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| 3313 | 3329 |
| 3314 gfx::Vector2d scroll_delta(0, 10); | 3330 gfx::Vector2d scroll_delta(0, 10); |
| 3315 gfx::Vector2d expected_scroll_delta = scroll_delta; | 3331 gfx::Vector2d expected_scroll_delta = scroll_delta; |
| 3316 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); | 3332 gfx::ScrollOffset expected_max_scroll = root_scroll->MaxScrollOffset(); |
| 3317 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3333 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3318 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3334 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3335 InputHandler::Wheel)); |
| 3319 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3336 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3320 host_impl_->ScrollEnd(); | 3337 host_impl_->ScrollEnd(); |
| 3321 | 3338 |
| 3322 // Set new page scale on impl thread by pinching. | 3339 // Set new page scale on impl thread by pinching. |
| 3323 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 3340 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 3324 host_impl_->PinchGestureBegin(); | 3341 host_impl_->PinchGestureBegin(); |
| 3325 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); | 3342 host_impl_->PinchGestureUpdate(page_scale, gfx::Point()); |
| 3326 host_impl_->PinchGestureEnd(); | 3343 host_impl_->PinchGestureEnd(); |
| 3327 host_impl_->ScrollEnd(); | 3344 host_impl_->ScrollEnd(); |
| 3328 DrawOneFrame(); | 3345 DrawOneFrame(); |
| 3329 | 3346 |
| 3330 // The scroll delta is not scaled because the main thread did not scale. | 3347 // The scroll delta is not scaled because the main thread did not scale. |
| 3331 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3348 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3332 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); | 3349 ExpectContains(*scroll_info.get(), root_scroll->id(), expected_scroll_delta); |
| 3333 | 3350 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3355 | 3372 |
| 3356 scoped_ptr<LayerImpl> scrollable_child_clip = | 3373 scoped_ptr<LayerImpl> scrollable_child_clip = |
| 3357 LayerImpl::Create(host_impl_->active_tree(), 6); | 3374 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 3358 scoped_ptr<LayerImpl> scrollable_child = | 3375 scoped_ptr<LayerImpl> scrollable_child = |
| 3359 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 3376 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
| 3360 scrollable_child_clip->AddChild(scrollable_child.Pass()); | 3377 scrollable_child_clip->AddChild(scrollable_child.Pass()); |
| 3361 child->AddChild(scrollable_child_clip.Pass()); | 3378 child->AddChild(scrollable_child_clip.Pass()); |
| 3362 LayerImpl* grand_child = child->children()[0]; | 3379 LayerImpl* grand_child = child->children()[0]; |
| 3363 | 3380 |
| 3364 // Set new page scale on impl thread by pinching. | 3381 // Set new page scale on impl thread by pinching. |
| 3365 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 3382 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 3366 host_impl_->PinchGestureBegin(); | 3383 host_impl_->PinchGestureBegin(); |
| 3367 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 3384 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
| 3368 host_impl_->PinchGestureEnd(); | 3385 host_impl_->PinchGestureEnd(); |
| 3369 host_impl_->ScrollEnd(); | 3386 host_impl_->ScrollEnd(); |
| 3370 DrawOneFrame(); | 3387 DrawOneFrame(); |
| 3371 | 3388 |
| 3372 EXPECT_EQ(1.f, root->contents_scale_x()); | 3389 EXPECT_EQ(1.f, root->contents_scale_x()); |
| 3373 EXPECT_EQ(1.f, root->contents_scale_y()); | 3390 EXPECT_EQ(1.f, root->contents_scale_y()); |
| 3374 EXPECT_EQ(1.f, scroll->contents_scale_x()); | 3391 EXPECT_EQ(1.f, scroll->contents_scale_x()); |
| 3375 EXPECT_EQ(1.f, scroll->contents_scale_y()); | 3392 EXPECT_EQ(1.f, scroll->contents_scale_y()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3418 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3435 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3419 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, | 3436 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 1, 2, |
| 3420 Layer::INVALID_ID); | 3437 Layer::INVALID_ID); |
| 3421 host_impl_->active_tree()->DidBecomeActive(); | 3438 host_impl_->active_tree()->DidBecomeActive(); |
| 3422 host_impl_->SetViewportSize(surface_size); | 3439 host_impl_->SetViewportSize(surface_size); |
| 3423 DrawFrame(); | 3440 DrawFrame(); |
| 3424 | 3441 |
| 3425 gfx::Vector2d scroll_delta(0, 10); | 3442 gfx::Vector2d scroll_delta(0, 10); |
| 3426 gfx::Vector2d expected_scroll_delta(scroll_delta); | 3443 gfx::Vector2d expected_scroll_delta(scroll_delta); |
| 3427 gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset()); | 3444 gfx::ScrollOffset expected_max_scroll(child->MaxScrollOffset()); |
| 3428 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3445 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3429 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3446 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3447 InputHandler::Wheel)); |
| 3430 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3448 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3431 host_impl_->ScrollEnd(); | 3449 host_impl_->ScrollEnd(); |
| 3432 | 3450 |
| 3433 float page_scale = 2.f; | 3451 float page_scale = 2.f; |
| 3434 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, | 3452 host_impl_->active_tree()->PushPageScaleFromMainThread(page_scale, 1.f, |
| 3435 page_scale); | 3453 page_scale); |
| 3436 | 3454 |
| 3437 DrawOneFrame(); | 3455 DrawOneFrame(); |
| 3438 | 3456 |
| 3439 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3457 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3469 root->AddChild(child.Pass()); | 3487 root->AddChild(child.Pass()); |
| 3470 host_impl_->active_tree()->SetRootLayer(root.Pass()); | 3488 host_impl_->active_tree()->SetRootLayer(root.Pass()); |
| 3471 host_impl_->active_tree()->DidBecomeActive(); | 3489 host_impl_->active_tree()->DidBecomeActive(); |
| 3472 host_impl_->SetViewportSize(surface_size); | 3490 host_impl_->SetViewportSize(surface_size); |
| 3473 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); | 3491 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 5)); |
| 3474 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); | 3492 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(3, 0)); |
| 3475 | 3493 |
| 3476 DrawFrame(); | 3494 DrawFrame(); |
| 3477 { | 3495 { |
| 3478 gfx::Vector2d scroll_delta(-8, -7); | 3496 gfx::Vector2d scroll_delta(-8, -7); |
| 3479 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3497 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3480 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3498 host_impl_->ScrollBegin(gfx::Point(), |
| 3499 InputHandler::Wheel)); |
| 3481 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3500 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3482 host_impl_->ScrollEnd(); | 3501 host_impl_->ScrollEnd(); |
| 3483 | 3502 |
| 3484 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3503 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3485 host_impl_->ProcessScrollDeltas(); | 3504 host_impl_->ProcessScrollDeltas(); |
| 3486 | 3505 |
| 3487 // The grand child should have scrolled up to its limit. | 3506 // The grand child should have scrolled up to its limit. |
| 3488 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 3507 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; |
| 3489 LayerImpl* grand_child = child->children()[0]; | 3508 LayerImpl* grand_child = child->children()[0]; |
| 3490 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5)); | 3509 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -5)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3522 Layer::INVALID_ID); | 3541 Layer::INVALID_ID); |
| 3523 host_impl_->active_tree()->DidBecomeActive(); | 3542 host_impl_->active_tree()->DidBecomeActive(); |
| 3524 host_impl_->SetViewportSize(viewport_size); | 3543 host_impl_->SetViewportSize(viewport_size); |
| 3525 | 3544 |
| 3526 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 3545 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
| 3527 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); | 3546 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
| 3528 | 3547 |
| 3529 DrawFrame(); | 3548 DrawFrame(); |
| 3530 { | 3549 { |
| 3531 gfx::Vector2d scroll_delta(0, -10); | 3550 gfx::Vector2d scroll_delta(0, -10); |
| 3532 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3551 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3533 host_impl_->ScrollBegin(gfx::Point(), | 3552 host_impl_->ScrollBegin(gfx::Point(), |
| 3534 InputHandler::NON_BUBBLING_GESTURE)); | 3553 InputHandler::NonBubblingGesture)); |
| 3535 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3554 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3536 host_impl_->ScrollEnd(); | 3555 host_impl_->ScrollEnd(); |
| 3537 | 3556 |
| 3538 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3557 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3539 host_impl_->ProcessScrollDeltas(); | 3558 host_impl_->ProcessScrollDeltas(); |
| 3540 | 3559 |
| 3541 // The grand child should have scrolled up to its limit. | 3560 // The grand child should have scrolled up to its limit. |
| 3542 LayerImpl* child = | 3561 LayerImpl* child = |
| 3543 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 3562 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; |
| 3544 LayerImpl* grand_child = child->children()[0]; | 3563 LayerImpl* grand_child = child->children()[0]; |
| 3545 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); | 3564 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); |
| 3546 | 3565 |
| 3547 // The child should not have scrolled. | 3566 // The child should not have scrolled. |
| 3548 ExpectNone(*scroll_info.get(), child->id()); | 3567 ExpectNone(*scroll_info.get(), child->id()); |
| 3549 | 3568 |
| 3550 // The next time we scroll we should only scroll the parent. | 3569 // The next time we scroll we should only scroll the parent. |
| 3551 scroll_delta = gfx::Vector2d(0, -3); | 3570 scroll_delta = gfx::Vector2d(0, -3); |
| 3552 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3571 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3553 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3572 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3554 InputHandler::NON_BUBBLING_GESTURE)); | 3573 InputHandler::NonBubblingGesture)); |
| 3555 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 3574 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 3556 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3575 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3557 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 3576 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
| 3558 host_impl_->ScrollEnd(); | 3577 host_impl_->ScrollEnd(); |
| 3559 | 3578 |
| 3560 scroll_info = host_impl_->ProcessScrollDeltas(); | 3579 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3561 | 3580 |
| 3562 // The child should have scrolled up to its limit. | 3581 // The child should have scrolled up to its limit. |
| 3563 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); | 3582 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); |
| 3564 | 3583 |
| 3565 // The grand child should not have scrolled. | 3584 // The grand child should not have scrolled. |
| 3566 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); | 3585 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, -2)); |
| 3567 | 3586 |
| 3568 // After scrolling the parent, another scroll on the opposite direction | 3587 // After scrolling the parent, another scroll on the opposite direction |
| 3569 // should still scroll the child. | 3588 // should still scroll the child. |
| 3570 scroll_delta = gfx::Vector2d(0, 7); | 3589 scroll_delta = gfx::Vector2d(0, 7); |
| 3571 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3590 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3572 host_impl_->ScrollBegin(gfx::Point(5, 5), | 3591 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3573 InputHandler::NON_BUBBLING_GESTURE)); | 3592 InputHandler::NonBubblingGesture)); |
| 3574 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 3593 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 3575 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3594 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3576 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 3595 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 3577 host_impl_->ScrollEnd(); | 3596 host_impl_->ScrollEnd(); |
| 3578 | 3597 |
| 3579 scroll_info = host_impl_->ProcessScrollDeltas(); | 3598 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3580 | 3599 |
| 3581 // The grand child should have scrolled. | 3600 // The grand child should have scrolled. |
| 3582 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 5)); | 3601 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 5)); |
| 3583 | 3602 |
| 3584 // The child should not have scrolled. | 3603 // The child should not have scrolled. |
| 3585 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); | 3604 ExpectContains(*scroll_info.get(), child->id(), gfx::Vector2d(0, -3)); |
| 3586 | 3605 |
| 3587 | 3606 |
| 3588 // Scrolling should be adjusted from viewport space. | 3607 // Scrolling should be adjusted from viewport space. |
| 3589 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); | 3608 host_impl_->active_tree()->PushPageScaleFromMainThread(2.f, 2.f, 2.f); |
| 3590 host_impl_->SetPageScaleOnActiveTree(2.f); | 3609 host_impl_->SetPageScaleOnActiveTree(2.f); |
| 3591 | 3610 |
| 3592 scroll_delta = gfx::Vector2d(0, -2); | 3611 scroll_delta = gfx::Vector2d(0, -2); |
| 3593 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3612 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3594 host_impl_->ScrollBegin(gfx::Point(1, 1), | 3613 host_impl_->ScrollBegin(gfx::Point(1, 1), |
| 3595 InputHandler::NON_BUBBLING_GESTURE)); | 3614 InputHandler::NonBubblingGesture)); |
| 3596 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); | 3615 EXPECT_EQ(grand_child, host_impl_->CurrentlyScrollingLayer()); |
| 3597 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3616 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3598 host_impl_->ScrollEnd(); | 3617 host_impl_->ScrollEnd(); |
| 3599 | 3618 |
| 3600 scroll_info = host_impl_->ProcessScrollDeltas(); | 3619 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3601 | 3620 |
| 3602 // Should have scrolled by half the amount in layer space (5 - 2/2) | 3621 // Should have scrolled by half the amount in layer space (5 - 2/2) |
| 3603 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); | 3622 ExpectContains(*scroll_info.get(), grand_child->id(), gfx::Vector2d(0, 4)); |
| 3604 } | 3623 } |
| 3605 } | 3624 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3625 root_clip->AddChild(root.Pass()); | 3644 root_clip->AddChild(root.Pass()); |
| 3626 | 3645 |
| 3627 host_impl_->SetViewportSize(surface_size); | 3646 host_impl_->SetViewportSize(surface_size); |
| 3628 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3647 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 3629 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, | 3648 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 2, |
| 3630 Layer::INVALID_ID); | 3649 Layer::INVALID_ID); |
| 3631 host_impl_->active_tree()->DidBecomeActive(); | 3650 host_impl_->active_tree()->DidBecomeActive(); |
| 3632 DrawFrame(); | 3651 DrawFrame(); |
| 3633 { | 3652 { |
| 3634 gfx::Vector2d scroll_delta(0, 4); | 3653 gfx::Vector2d scroll_delta(0, 4); |
| 3635 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3654 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3636 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3655 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3656 InputHandler::Wheel)); |
| 3637 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3657 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3638 host_impl_->ScrollEnd(); | 3658 host_impl_->ScrollEnd(); |
| 3639 | 3659 |
| 3640 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3660 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3641 host_impl_->ProcessScrollDeltas(); | 3661 host_impl_->ProcessScrollDeltas(); |
| 3642 | 3662 |
| 3643 // Only the root scroll should have scrolled. | 3663 // Only the root scroll should have scrolled. |
| 3644 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 3664 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 3645 ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); | 3665 ExpectContains(*scroll_info.get(), root_scroll_id, scroll_delta); |
| 3646 } | 3666 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3671 CreateScrollableLayer(4, surface_size, root_clip2.get()); | 3691 CreateScrollableLayer(4, surface_size, root_clip2.get()); |
| 3672 root_scroll2->SetIsContainerForFixedPositionLayers(true); | 3692 root_scroll2->SetIsContainerForFixedPositionLayers(true); |
| 3673 root_clip2->AddChild(root_scroll2.Pass()); | 3693 root_clip2->AddChild(root_scroll2.Pass()); |
| 3674 root_clip2->SetHasRenderSurface(true); | 3694 root_clip2->SetHasRenderSurface(true); |
| 3675 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); | 3695 host_impl_->active_tree()->SetRootLayer(root_clip2.Pass()); |
| 3676 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, | 3696 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 4, |
| 3677 Layer::INVALID_ID); | 3697 Layer::INVALID_ID); |
| 3678 host_impl_->active_tree()->DidBecomeActive(); | 3698 host_impl_->active_tree()->DidBecomeActive(); |
| 3679 | 3699 |
| 3680 // Scrolling should still work even though we did not draw yet. | 3700 // Scrolling should still work even though we did not draw yet. |
| 3681 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3701 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3682 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 3702 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 3703 InputHandler::Wheel)); |
| 3683 } | 3704 } |
| 3684 | 3705 |
| 3685 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { | 3706 TEST_F(LayerTreeHostImplTest, ScrollAxisAlignedRotatedLayer) { |
| 3686 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 3707 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 3687 | 3708 |
| 3688 // Rotate the root layer 90 degrees counter-clockwise about its center. | 3709 // Rotate the root layer 90 degrees counter-clockwise about its center. |
| 3689 gfx::Transform rotate_transform; | 3710 gfx::Transform rotate_transform; |
| 3690 rotate_transform.Rotate(-90.0); | 3711 rotate_transform.Rotate(-90.0); |
| 3691 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); | 3712 host_impl_->active_tree()->root_layer()->SetTransform(rotate_transform); |
| 3692 | 3713 |
| 3693 gfx::Size surface_size(50, 50); | 3714 gfx::Size surface_size(50, 50); |
| 3694 host_impl_->SetViewportSize(surface_size); | 3715 host_impl_->SetViewportSize(surface_size); |
| 3695 DrawFrame(); | 3716 DrawFrame(); |
| 3696 | 3717 |
| 3697 // Scroll to the right in screen coordinates with a gesture. | 3718 // Scroll to the right in screen coordinates with a gesture. |
| 3698 gfx::Vector2d gesture_scroll_delta(10, 0); | 3719 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 3699 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3720 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3700 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3721 host_impl_->ScrollBegin(gfx::Point(), |
| 3722 InputHandler::Gesture)); |
| 3701 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3723 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 3702 host_impl_->ScrollEnd(); | 3724 host_impl_->ScrollEnd(); |
| 3703 | 3725 |
| 3704 // The layer should have scrolled down in its local coordinates. | 3726 // The layer should have scrolled down in its local coordinates. |
| 3705 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3727 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3706 ExpectContains(*scroll_info.get(), scroll_layer->id(), | 3728 ExpectContains(*scroll_info.get(), scroll_layer->id(), |
| 3707 gfx::Vector2dF(0, gesture_scroll_delta.x())); | 3729 gfx::Vector2dF(0, gesture_scroll_delta.x())); |
| 3708 | 3730 |
| 3709 // Reset and scroll down with the wheel. | 3731 // Reset and scroll down with the wheel. |
| 3710 scroll_layer->SetScrollDelta(gfx::Vector2dF()); | 3732 scroll_layer->SetScrollDelta(gfx::Vector2dF()); |
| 3711 gfx::Vector2d wheel_scroll_delta(0, 10); | 3733 gfx::Vector2d wheel_scroll_delta(0, 10); |
| 3712 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3734 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3713 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3735 host_impl_->ScrollBegin(gfx::Point(), |
| 3736 InputHandler::Wheel)); |
| 3714 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); | 3737 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); |
| 3715 host_impl_->ScrollEnd(); | 3738 host_impl_->ScrollEnd(); |
| 3716 | 3739 |
| 3717 // The layer should have scrolled down in its local coordinates. | 3740 // The layer should have scrolled down in its local coordinates. |
| 3718 scroll_info = host_impl_->ProcessScrollDeltas(); | 3741 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3719 ExpectContains(*scroll_info.get(), | 3742 ExpectContains(*scroll_info.get(), |
| 3720 scroll_layer->id(), | 3743 scroll_layer->id(), |
| 3721 wheel_scroll_delta); | 3744 wheel_scroll_delta); |
| 3722 } | 3745 } |
| 3723 | 3746 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3749 LayerImpl* child_ptr = child.get(); | 3772 LayerImpl* child_ptr = child.get(); |
| 3750 clip_layer->AddChild(child.Pass()); | 3773 clip_layer->AddChild(child.Pass()); |
| 3751 scroll_layer->AddChild(clip_layer.Pass()); | 3774 scroll_layer->AddChild(clip_layer.Pass()); |
| 3752 | 3775 |
| 3753 gfx::Size surface_size(50, 50); | 3776 gfx::Size surface_size(50, 50); |
| 3754 host_impl_->SetViewportSize(surface_size); | 3777 host_impl_->SetViewportSize(surface_size); |
| 3755 DrawFrame(); | 3778 DrawFrame(); |
| 3756 { | 3779 { |
| 3757 // Scroll down in screen coordinates with a gesture. | 3780 // Scroll down in screen coordinates with a gesture. |
| 3758 gfx::Vector2d gesture_scroll_delta(0, 10); | 3781 gfx::Vector2d gesture_scroll_delta(0, 10); |
| 3759 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3782 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3760 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); | 3783 host_impl_->ScrollBegin(gfx::Point(1, 1), |
| 3784 InputHandler::Gesture)); |
| 3761 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3785 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 3762 host_impl_->ScrollEnd(); | 3786 host_impl_->ScrollEnd(); |
| 3763 | 3787 |
| 3764 // The child layer should have scrolled down in its local coordinates an | 3788 // The child layer should have scrolled down in its local coordinates an |
| 3765 // amount proportional to the angle between it and the input scroll delta. | 3789 // amount proportional to the angle between it and the input scroll delta. |
| 3766 gfx::Vector2dF expected_scroll_delta( | 3790 gfx::Vector2dF expected_scroll_delta( |
| 3767 0, gesture_scroll_delta.y() * | 3791 0, gesture_scroll_delta.y() * |
| 3768 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | 3792 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
| 3769 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3793 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3770 host_impl_->ProcessScrollDeltas(); | 3794 host_impl_->ProcessScrollDeltas(); |
| 3771 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 3795 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
| 3772 | 3796 |
| 3773 // The root scroll layer should not have scrolled, because the input delta | 3797 // The root scroll layer should not have scrolled, because the input delta |
| 3774 // was close to the layer's axis of movement. | 3798 // was close to the layer's axis of movement. |
| 3775 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 3799 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
| 3776 } | 3800 } |
| 3777 { | 3801 { |
| 3778 // Now reset and scroll the same amount horizontally. | 3802 // Now reset and scroll the same amount horizontally. |
| 3779 child_ptr->SetScrollDelta(gfx::Vector2dF()); | 3803 child_ptr->SetScrollDelta(gfx::Vector2dF()); |
| 3780 gfx::Vector2d gesture_scroll_delta(10, 0); | 3804 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 3781 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3805 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3782 host_impl_->ScrollBegin(gfx::Point(1, 1), InputHandler::GESTURE)); | 3806 host_impl_->ScrollBegin(gfx::Point(1, 1), |
| 3807 InputHandler::Gesture)); |
| 3783 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3808 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 3784 host_impl_->ScrollEnd(); | 3809 host_impl_->ScrollEnd(); |
| 3785 | 3810 |
| 3786 // The child layer should have scrolled down in its local coordinates an | 3811 // The child layer should have scrolled down in its local coordinates an |
| 3787 // amount proportional to the angle between it and the input scroll delta. | 3812 // amount proportional to the angle between it and the input scroll delta. |
| 3788 gfx::Vector2dF expected_scroll_delta( | 3813 gfx::Vector2dF expected_scroll_delta( |
| 3789 0, -gesture_scroll_delta.x() * | 3814 0, -gesture_scroll_delta.x() * |
| 3790 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 3815 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
| 3791 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3816 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3792 host_impl_->ProcessScrollDeltas(); | 3817 host_impl_->ProcessScrollDeltas(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3813 gfx::Transform scale_transform; | 3838 gfx::Transform scale_transform; |
| 3814 scale_transform.Scale(scale, scale); | 3839 scale_transform.Scale(scale, scale); |
| 3815 scroll_layer->SetTransform(scale_transform); | 3840 scroll_layer->SetTransform(scale_transform); |
| 3816 | 3841 |
| 3817 gfx::Size surface_size(50, 50); | 3842 gfx::Size surface_size(50, 50); |
| 3818 host_impl_->SetViewportSize(surface_size); | 3843 host_impl_->SetViewportSize(surface_size); |
| 3819 DrawFrame(); | 3844 DrawFrame(); |
| 3820 | 3845 |
| 3821 // Scroll down in screen coordinates with a gesture. | 3846 // Scroll down in screen coordinates with a gesture. |
| 3822 gfx::Vector2d scroll_delta(0, 10); | 3847 gfx::Vector2d scroll_delta(0, 10); |
| 3823 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3848 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3824 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 3849 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3825 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 3850 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3826 host_impl_->ScrollEnd(); | 3851 host_impl_->ScrollEnd(); |
| 3827 | 3852 |
| 3828 // The layer should have scrolled down in its local coordinates, but half the | 3853 // The layer should have scrolled down in its local coordinates, but half the |
| 3829 // amount. | 3854 // amount. |
| 3830 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3855 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3831 ExpectContains(*scroll_info.get(), | 3856 ExpectContains(*scroll_info.get(), |
| 3832 scroll_layer->id(), | 3857 scroll_layer->id(), |
| 3833 gfx::Vector2d(0, scroll_delta.y() / scale)); | 3858 gfx::Vector2d(0, scroll_delta.y() / scale)); |
| 3834 | 3859 |
| 3835 // Reset and scroll down with the wheel. | 3860 // Reset and scroll down with the wheel. |
| 3836 scroll_layer->SetScrollDelta(gfx::Vector2dF()); | 3861 scroll_layer->SetScrollDelta(gfx::Vector2dF()); |
| 3837 gfx::Vector2d wheel_scroll_delta(0, 10); | 3862 gfx::Vector2d wheel_scroll_delta(0, 10); |
| 3838 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 3863 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3839 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 3864 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 3840 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); | 3865 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); |
| 3841 host_impl_->ScrollEnd(); | 3866 host_impl_->ScrollEnd(); |
| 3842 | 3867 |
| 3843 // It should apply the scale factor to the scroll delta for the wheel event. | 3868 // It should apply the scale factor to the scroll delta for the wheel event. |
| 3844 scroll_info = host_impl_->ProcessScrollDeltas(); | 3869 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3845 ExpectContains(*scroll_info.get(), | 3870 ExpectContains(*scroll_info.get(), |
| 3846 scroll_layer->id(), | 3871 scroll_layer->id(), |
| 3847 wheel_scroll_delta); | 3872 wheel_scroll_delta); |
| 3848 } | 3873 } |
| 3849 | 3874 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3968 EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor()); | 3993 EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor()); |
| 3969 host_impl_->SetPageScaleOnActiveTree(2.f); | 3994 host_impl_->SetPageScaleOnActiveTree(2.f); |
| 3970 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 3995 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 3971 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); | 3996 EXPECT_EQ(1.f, scroll_delegate.page_scale_factor()); |
| 3972 EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor()); | 3997 EXPECT_EQ(0.5f, scroll_delegate.min_page_scale_factor()); |
| 3973 EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor()); | 3998 EXPECT_EQ(4.f, scroll_delegate.max_page_scale_factor()); |
| 3974 | 3999 |
| 3975 // The pinch gesture doesn't put the delegate into a state where the scroll | 4000 // The pinch gesture doesn't put the delegate into a state where the scroll |
| 3976 // offset is outside of the scroll range. (this is verified by DCHECKs in the | 4001 // offset is outside of the scroll range. (this is verified by DCHECKs in the |
| 3977 // delegate). | 4002 // delegate). |
| 3978 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 4003 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 3979 host_impl_->PinchGestureBegin(); | 4004 host_impl_->PinchGestureBegin(); |
| 3980 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); | 4005 host_impl_->PinchGestureUpdate(2.f, gfx::Point()); |
| 3981 host_impl_->PinchGestureUpdate(.5f, gfx::Point()); | 4006 host_impl_->PinchGestureUpdate(.5f, gfx::Point()); |
| 3982 host_impl_->PinchGestureEnd(); | 4007 host_impl_->PinchGestureEnd(); |
| 3983 host_impl_->ScrollEnd(); | 4008 host_impl_->ScrollEnd(); |
| 3984 | 4009 |
| 3985 // Scrolling should be relative to the offset as returned by the delegate. | 4010 // Scrolling should be relative to the offset as returned by the delegate. |
| 3986 gfx::Vector2dF scroll_delta(0.f, 10.f); | 4011 gfx::Vector2dF scroll_delta(0.f, 10.f); |
| 3987 gfx::ScrollOffset current_offset(7.f, 8.f); | 4012 gfx::ScrollOffset current_offset(7.f, 8.f); |
| 3988 | 4013 |
| 3989 scroll_delegate.set_getter_return_value(current_offset); | 4014 scroll_delegate.set_getter_return_value(current_offset); |
| 3990 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4015 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3991 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 4016 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 3992 | 4017 |
| 3993 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4018 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 3994 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), | 4019 EXPECT_EQ(ScrollOffsetWithDelta(current_offset, scroll_delta), |
| 3995 scroll_delegate.last_set_scroll_offset()); | 4020 scroll_delegate.last_set_scroll_offset()); |
| 3996 | 4021 |
| 3997 current_offset = gfx::ScrollOffset(42.f, 41.f); | 4022 current_offset = gfx::ScrollOffset(42.f, 41.f); |
| 3998 scroll_delegate.set_getter_return_value(current_offset); | 4023 scroll_delegate.set_getter_return_value(current_offset); |
| 3999 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4024 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4000 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta), | 4025 EXPECT_EQ(current_offset + gfx::ScrollOffset(scroll_delta), |
| 4001 scroll_delegate.last_set_scroll_offset()); | 4026 scroll_delegate.last_set_scroll_offset()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4062 | 4087 |
| 4063 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { | 4088 TEST_F(LayerTreeHostImplTest, OverscrollRoot) { |
| 4064 InputHandlerScrollResult scroll_result; | 4089 InputHandlerScrollResult scroll_result; |
| 4065 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 4090 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 4066 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 4091 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 4067 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 4092 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 4068 DrawFrame(); | 4093 DrawFrame(); |
| 4069 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4094 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4070 | 4095 |
| 4071 // In-bounds scrolling does not affect overscroll. | 4096 // In-bounds scrolling does not affect overscroll. |
| 4072 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4097 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4073 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 4098 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 4074 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4099 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 4075 EXPECT_TRUE(scroll_result.did_scroll); | 4100 EXPECT_TRUE(scroll_result.did_scroll); |
| 4076 EXPECT_FALSE(scroll_result.did_overscroll_root); | 4101 EXPECT_FALSE(scroll_result.did_overscroll_root); |
| 4077 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); | 4102 EXPECT_EQ(gfx::Vector2dF(), scroll_result.unused_scroll_delta); |
| 4078 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4103 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4079 | 4104 |
| 4080 // Overscroll events are reflected immediately. | 4105 // Overscroll events are reflected immediately. |
| 4081 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50)); | 4106 scroll_result = host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 50)); |
| 4082 EXPECT_TRUE(scroll_result.did_scroll); | 4107 EXPECT_TRUE(scroll_result.did_scroll); |
| 4083 EXPECT_TRUE(scroll_result.did_overscroll_root); | 4108 EXPECT_TRUE(scroll_result.did_overscroll_root); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4197 root->AddChild(child.Pass()); | 4222 root->AddChild(child.Pass()); |
| 4198 root_clip->AddChild(root.Pass()); | 4223 root_clip->AddChild(root.Pass()); |
| 4199 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); | 4224 child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 3)); |
| 4200 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); | 4225 grand_child_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 2)); |
| 4201 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4226 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 4202 host_impl_->active_tree()->DidBecomeActive(); | 4227 host_impl_->active_tree()->DidBecomeActive(); |
| 4203 host_impl_->SetViewportSize(surface_size); | 4228 host_impl_->SetViewportSize(surface_size); |
| 4204 DrawFrame(); | 4229 DrawFrame(); |
| 4205 { | 4230 { |
| 4206 gfx::Vector2d scroll_delta(0, -10); | 4231 gfx::Vector2d scroll_delta(0, -10); |
| 4207 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4232 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4208 host_impl_->ScrollBegin(gfx::Point(), | 4233 host_impl_->ScrollBegin(gfx::Point(), |
| 4209 InputHandler::NON_BUBBLING_GESTURE)); | 4234 InputHandler::NonBubblingGesture)); |
| 4210 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4235 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4211 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4236 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4212 host_impl_->ScrollEnd(); | 4237 host_impl_->ScrollEnd(); |
| 4213 | 4238 |
| 4214 // The next time we scroll we should only scroll the parent, but overscroll | 4239 // The next time we scroll we should only scroll the parent, but overscroll |
| 4215 // should still not reach the root layer. | 4240 // should still not reach the root layer. |
| 4216 scroll_delta = gfx::Vector2d(0, -30); | 4241 scroll_delta = gfx::Vector2d(0, -30); |
| 4217 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4242 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4218 host_impl_->ScrollBegin(gfx::Point(5, 5), | 4243 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 4219 InputHandler::NON_BUBBLING_GESTURE)); | 4244 InputHandler::NonBubblingGesture)); |
| 4220 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 4245 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
| 4221 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4246 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4222 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4247 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4223 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer); | 4248 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_layer); |
| 4224 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4249 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4225 host_impl_->ScrollEnd(); | 4250 host_impl_->ScrollEnd(); |
| 4226 | 4251 |
| 4227 // After scrolling the parent, another scroll on the opposite direction | 4252 // After scrolling the parent, another scroll on the opposite direction |
| 4228 // should scroll the child. | 4253 // should scroll the child. |
| 4229 scroll_delta = gfx::Vector2d(0, 70); | 4254 scroll_delta = gfx::Vector2d(0, 70); |
| 4230 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4255 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4231 host_impl_->ScrollBegin(gfx::Point(5, 5), | 4256 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 4232 InputHandler::NON_BUBBLING_GESTURE)); | 4257 InputHandler::NonBubblingGesture)); |
| 4233 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 4258 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
| 4234 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4259 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4235 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); | 4260 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child_layer); |
| 4236 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4261 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4237 host_impl_->ScrollEnd(); | 4262 host_impl_->ScrollEnd(); |
| 4238 } | 4263 } |
| 4239 } | 4264 } |
| 4240 | 4265 |
| 4241 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { | 4266 TEST_F(LayerTreeHostImplTest, OverscrollChildEventBubbling) { |
| 4242 // When we try to scroll a non-scrollable child layer, the scroll delta | 4267 // When we try to scroll a non-scrollable child layer, the scroll delta |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4259 root_clip->AddChild(root.Pass()); | 4284 root_clip->AddChild(root.Pass()); |
| 4260 | 4285 |
| 4261 host_impl_->SetViewportSize(surface_size); | 4286 host_impl_->SetViewportSize(surface_size); |
| 4262 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4287 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 4263 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 4288 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
| 4264 Layer::INVALID_ID); | 4289 Layer::INVALID_ID); |
| 4265 host_impl_->active_tree()->DidBecomeActive(); | 4290 host_impl_->active_tree()->DidBecomeActive(); |
| 4266 DrawFrame(); | 4291 DrawFrame(); |
| 4267 { | 4292 { |
| 4268 gfx::Vector2d scroll_delta(0, 8); | 4293 gfx::Vector2d scroll_delta(0, 8); |
| 4269 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4294 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4270 host_impl_->ScrollBegin(gfx::Point(5, 5), InputHandler::WHEEL)); | 4295 host_impl_->ScrollBegin(gfx::Point(5, 5), |
| 4296 InputHandler::Wheel)); |
| 4271 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4297 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4272 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4298 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4273 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4299 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4274 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); | 4300 EXPECT_EQ(gfx::Vector2dF(0, 6), host_impl_->accumulated_root_overscroll()); |
| 4275 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 4301 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 4276 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); | 4302 EXPECT_EQ(gfx::Vector2dF(0, 14), host_impl_->accumulated_root_overscroll()); |
| 4277 host_impl_->ScrollEnd(); | 4303 host_impl_->ScrollEnd(); |
| 4278 } | 4304 } |
| 4279 } | 4305 } |
| 4280 | 4306 |
| 4281 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 4307 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
| 4282 LayerTreeSettings settings; | 4308 LayerTreeSettings settings; |
| 4283 CreateHostImpl(settings, CreateOutputSurface()); | 4309 CreateHostImpl(settings, CreateOutputSurface()); |
| 4284 | 4310 |
| 4285 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 4311 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
| 4286 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 4312 LayerImpl* clip_layer = scroll_layer->parent()->parent(); |
| 4287 clip_layer->SetBounds(gfx::Size(50, 50)); | 4313 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 4288 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 4314 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 4289 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 4315 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 4290 DrawFrame(); | 4316 DrawFrame(); |
| 4291 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 4317 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 4292 | 4318 |
| 4293 // Even though the layer can't scroll the overscroll still happens. | 4319 // Even though the layer can't scroll the overscroll still happens. |
| 4294 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4320 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4295 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 4321 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 4296 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 4322 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 4297 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 4323 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 4298 } | 4324 } |
| 4299 | 4325 |
| 4300 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { | 4326 TEST_F(LayerTreeHostImplTest, NoOverscrollOnFractionalDeviceScale) { |
| 4301 gfx::Size surface_size(980, 1439); | 4327 gfx::Size surface_size(980, 1439); |
| 4302 gfx::Size content_size(980, 1438); | 4328 gfx::Size content_size(980, 1438); |
| 4303 float device_scale_factor = 1.5f; | 4329 float device_scale_factor = 1.5f; |
| 4304 scoped_ptr<LayerImpl> root_clip = | 4330 scoped_ptr<LayerImpl> root_clip = |
| 4305 LayerImpl::Create(host_impl_->active_tree(), 3); | 4331 LayerImpl::Create(host_impl_->active_tree(), 3); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4322 host_impl_->SetDeviceScaleFactor(device_scale_factor); | 4348 host_impl_->SetDeviceScaleFactor(device_scale_factor); |
| 4323 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4349 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 4324 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 4350 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
| 4325 Layer::INVALID_ID); | 4351 Layer::INVALID_ID); |
| 4326 host_impl_->active_tree()->DidBecomeActive(); | 4352 host_impl_->active_tree()->DidBecomeActive(); |
| 4327 DrawFrame(); | 4353 DrawFrame(); |
| 4328 { | 4354 { |
| 4329 // Horizontal & Vertical GlowEffect should not be applied when | 4355 // Horizontal & Vertical GlowEffect should not be applied when |
| 4330 // content size is less then view port size. For Example Horizontal & | 4356 // content size is less then view port size. For Example Horizontal & |
| 4331 // vertical GlowEffect should not be applied in about:blank page. | 4357 // vertical GlowEffect should not be applied in about:blank page. |
| 4332 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4358 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4333 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); | 4359 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |
| 4334 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1)); | 4360 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -1)); |
| 4335 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4361 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 4336 host_impl_->accumulated_root_overscroll().ToString()); | 4362 host_impl_->accumulated_root_overscroll().ToString()); |
| 4337 | 4363 |
| 4338 host_impl_->ScrollEnd(); | 4364 host_impl_->ScrollEnd(); |
| 4339 } | 4365 } |
| 4340 } | 4366 } |
| 4341 | 4367 |
| 4342 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { | 4368 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 4343 gfx::Size surface_size(100, 100); | 4369 gfx::Size surface_size(100, 100); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4359 host_impl_->SetViewportSize(surface_size); | 4385 host_impl_->SetViewportSize(surface_size); |
| 4360 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 4386 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 4361 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 4387 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
| 4362 Layer::INVALID_ID); | 4388 Layer::INVALID_ID); |
| 4363 host_impl_->active_tree()->DidBecomeActive(); | 4389 host_impl_->active_tree()->DidBecomeActive(); |
| 4364 DrawFrame(); | 4390 DrawFrame(); |
| 4365 { | 4391 { |
| 4366 // Edge glow effect should be applicable only upon reaching Edges | 4392 // Edge glow effect should be applicable only upon reaching Edges |
| 4367 // of the content. unnecessary glow effect calls shouldn't be | 4393 // of the content. unnecessary glow effect calls shouldn't be |
| 4368 // called while scrolling up without reaching the edge of the content. | 4394 // called while scrolling up without reaching the edge of the content. |
| 4369 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4395 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4370 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); | 4396 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |
| 4371 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); | 4397 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); |
| 4372 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4398 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 4373 host_impl_->accumulated_root_overscroll().ToString()); | 4399 host_impl_->accumulated_root_overscroll().ToString()); |
| 4374 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); | 4400 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); |
| 4375 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4401 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 4376 host_impl_->accumulated_root_overscroll().ToString()); | 4402 host_impl_->accumulated_root_overscroll().ToString()); |
| 4377 host_impl_->ScrollEnd(); | 4403 host_impl_->ScrollEnd(); |
| 4378 // unusedrootDelta should be subtracted from applied delta so that | 4404 // unusedrootDelta should be subtracted from applied delta so that |
| 4379 // unwanted glow effect calls are not called. | 4405 // unwanted glow effect calls are not called. |
| 4380 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4406 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4381 host_impl_->ScrollBegin(gfx::Point(0, 0), | 4407 host_impl_->ScrollBegin(gfx::Point(0, 0), |
| 4382 InputHandler::NON_BUBBLING_GESTURE)); | 4408 InputHandler::NonBubblingGesture)); |
| 4383 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 4409 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 4384 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20)); | 4410 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20)); |
| 4385 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), | 4411 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), |
| 4386 host_impl_->accumulated_root_overscroll().ToString()); | 4412 host_impl_->accumulated_root_overscroll().ToString()); |
| 4387 | 4413 |
| 4388 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)); | 4414 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)); |
| 4389 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), | 4415 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), |
| 4390 host_impl_->accumulated_root_overscroll().ToString()); | 4416 host_impl_->accumulated_root_overscroll().ToString()); |
| 4391 host_impl_->ScrollEnd(); | 4417 host_impl_->ScrollEnd(); |
| 4392 // TestCase to check kEpsilon, which prevents minute values to trigger | 4418 // TestCase to check kEpsilon, which prevents minute values to trigger |
| 4393 // gloweffect without reaching edge. | 4419 // gloweffect without reaching edge. |
| 4394 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 4420 EXPECT_EQ(InputHandler::ScrollStarted, |
| 4395 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::WHEEL)); | 4421 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |
| 4396 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)); | 4422 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)); |
| 4397 EXPECT_EQ(gfx::Vector2dF().ToString(), | 4423 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 4398 host_impl_->accumulated_root_overscroll().ToString()); | 4424 host_impl_->accumulated_root_overscroll().ToString()); |
| 4399 host_impl_->ScrollEnd(); | 4425 host_impl_->ScrollEnd(); |
| 4400 } | 4426 } |
| 4401 } | 4427 } |
| 4402 | 4428 |
| 4403 class BlendStateCheckLayer : public LayerImpl { | 4429 class BlendStateCheckLayer : public LayerImpl { |
| 4404 public: | 4430 public: |
| 4405 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 4431 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4460 ResourceProvider* resource_provider) | 4486 ResourceProvider* resource_provider) |
| 4461 : LayerImpl(tree_impl, id), | 4487 : LayerImpl(tree_impl, id), |
| 4462 blend_(false), | 4488 blend_(false), |
| 4463 has_render_surface_(false), | 4489 has_render_surface_(false), |
| 4464 quads_appended_(false), | 4490 quads_appended_(false), |
| 4465 quad_rect_(5, 5, 5, 5), | 4491 quad_rect_(5, 5, 5, 5), |
| 4466 quad_visible_rect_(5, 5, 5, 5), | 4492 quad_visible_rect_(5, 5, 5, 5), |
| 4467 resource_id_(resource_provider->CreateResource( | 4493 resource_id_(resource_provider->CreateResource( |
| 4468 gfx::Size(1, 1), | 4494 gfx::Size(1, 1), |
| 4469 GL_CLAMP_TO_EDGE, | 4495 GL_CLAMP_TO_EDGE, |
| 4470 ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 4496 ResourceProvider::TextureHintImmutable, |
| 4471 RGBA_8888)) { | 4497 RGBA_8888)) { |
| 4472 resource_provider->AllocateForTesting(resource_id_); | 4498 resource_provider->AllocateForTesting(resource_id_); |
| 4473 SetBounds(gfx::Size(10, 10)); | 4499 SetBounds(gfx::Size(10, 10)); |
| 4474 SetContentBounds(gfx::Size(10, 10)); | 4500 SetContentBounds(gfx::Size(10, 10)); |
| 4475 SetDrawsContent(true); | 4501 SetDrawsContent(true); |
| 4476 } | 4502 } |
| 4477 | 4503 |
| 4478 bool blend_; | 4504 bool blend_; |
| 4479 bool has_render_surface_; | 4505 bool has_render_surface_; |
| 4480 bool quads_appended_; | 4506 bool quads_appended_; |
| (...skipping 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6403 content_layer->SetDrawsContent(true); | 6429 content_layer->SetDrawsContent(true); |
| 6404 | 6430 |
| 6405 root->SetBounds(root_size); | 6431 root->SetBounds(root_size); |
| 6406 | 6432 |
| 6407 gfx::ScrollOffset scroll_offset(100000, 0); | 6433 gfx::ScrollOffset scroll_offset(100000, 0); |
| 6408 scrolling_layer->SetScrollClipLayer(root->id()); | 6434 scrolling_layer->SetScrollClipLayer(root->id()); |
| 6409 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); | 6435 scrolling_layer->PushScrollOffsetFromMainThread(scroll_offset); |
| 6410 | 6436 |
| 6411 host_impl_->ActivateSyncTree(); | 6437 host_impl_->ActivateSyncTree(); |
| 6412 | 6438 |
| 6413 bool update_lcd_text = false; | 6439 host_impl_->active_tree()->UpdateDrawProperties(); |
| 6414 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | |
| 6415 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); | 6440 ASSERT_EQ(1u, host_impl_->active_tree()->RenderSurfaceLayerList().size()); |
| 6416 | 6441 |
| 6417 LayerTreeHostImpl::FrameData frame; | 6442 LayerTreeHostImpl::FrameData frame; |
| 6418 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); | 6443 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); |
| 6419 | 6444 |
| 6420 ASSERT_EQ(1u, frame.render_passes.size()); | 6445 ASSERT_EQ(1u, frame.render_passes.size()); |
| 6421 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); | 6446 ASSERT_LE(1u, frame.render_passes[0]->quad_list.size()); |
| 6422 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); | 6447 const DrawQuad* quad = frame.render_passes[0]->quad_list.front(); |
| 6423 | 6448 |
| 6424 bool antialiased = | 6449 bool antialiased = |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6885 int root_id = root->id(); | 6910 int root_id = root->id(); |
| 6886 root_clip->AddChild(root.Pass()); | 6911 root_clip->AddChild(root.Pass()); |
| 6887 | 6912 |
| 6888 host_impl_->SetViewportSize(surface_size); | 6913 host_impl_->SetViewportSize(surface_size); |
| 6889 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 6914 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 6890 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, | 6915 host_impl_->active_tree()->SetViewportLayersFromIds(Layer::INVALID_ID, 3, 1, |
| 6891 Layer::INVALID_ID); | 6916 Layer::INVALID_ID); |
| 6892 host_impl_->active_tree()->DidBecomeActive(); | 6917 host_impl_->active_tree()->DidBecomeActive(); |
| 6893 DrawFrame(); | 6918 DrawFrame(); |
| 6894 { | 6919 { |
| 6895 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 6920 EXPECT_EQ(InputHandler::ScrollStarted, |
| 6896 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 6921 host_impl_->ScrollBegin(gfx::Point(), |
| 6922 InputHandler::Gesture)); |
| 6897 | 6923 |
| 6898 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 6924 EXPECT_EQ(InputHandler::ScrollStarted, |
| 6925 host_impl_->FlingScrollBegin()); |
| 6899 | 6926 |
| 6900 gfx::Vector2d scroll_delta(0, 100); | 6927 gfx::Vector2d scroll_delta(0, 100); |
| 6901 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 6928 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 6902 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 6929 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 6903 | 6930 |
| 6904 host_impl_->ScrollEnd(); | 6931 host_impl_->ScrollEnd(); |
| 6905 | 6932 |
| 6906 scoped_ptr<ScrollAndScaleSet> scroll_info = | 6933 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 6907 host_impl_->ProcessScrollDeltas(); | 6934 host_impl_->ProcessScrollDeltas(); |
| 6908 | 6935 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6936 host_impl_->active_tree()->DidBecomeActive(); | 6963 host_impl_->active_tree()->DidBecomeActive(); |
| 6937 host_impl_->SetViewportSize(surface_size); | 6964 host_impl_->SetViewportSize(surface_size); |
| 6938 DrawFrame(); | 6965 DrawFrame(); |
| 6939 { | 6966 { |
| 6940 scoped_ptr<ScrollAndScaleSet> scroll_info; | 6967 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 6941 LayerImpl* child = | 6968 LayerImpl* child = |
| 6942 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 6969 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; |
| 6943 LayerImpl* grand_child = child->children()[0]; | 6970 LayerImpl* grand_child = child->children()[0]; |
| 6944 | 6971 |
| 6945 gfx::Vector2d scroll_delta(0, -2); | 6972 gfx::Vector2d scroll_delta(0, -2); |
| 6946 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 6973 EXPECT_EQ(InputHandler::ScrollStarted, |
| 6947 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 6974 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 6948 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6975 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6949 | 6976 |
| 6950 // The grand child should have scrolled up to its limit. | 6977 // The grand child should have scrolled up to its limit. |
| 6951 scroll_info = host_impl_->ProcessScrollDeltas(); | 6978 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6952 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 6979 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 6953 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); | 6980 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
| 6954 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 6981 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 6955 | 6982 |
| 6956 // The child should have received the bubbled delta, but the locked | 6983 // The child should have received the bubbled delta, but the locked |
| 6957 // scrolling layer should remain set as the grand child. | 6984 // scrolling layer should remain set as the grand child. |
| 6958 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6985 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6959 scroll_info = host_impl_->ProcessScrollDeltas(); | 6986 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6960 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 6987 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
| 6961 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); | 6988 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
| 6962 ExpectContains(*scroll_info, child->id(), scroll_delta); | 6989 ExpectContains(*scroll_info, child->id(), scroll_delta); |
| 6963 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); | 6990 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), grand_child); |
| 6964 | 6991 |
| 6965 // The first |ScrollBy| after the fling should re-lock the scrolling | 6992 // The first |ScrollBy| after the fling should re-lock the scrolling |
| 6966 // layer to the first layer that scrolled, which is the child. | 6993 // layer to the first layer that scrolled, which is the child. |
| 6967 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 6994 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 6968 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 6995 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 6969 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); | 6996 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child); |
| 6970 | 6997 |
| 6971 // The child should have scrolled up to its limit. | 6998 // The child should have scrolled up to its limit. |
| 6972 scroll_info = host_impl_->ProcessScrollDeltas(); | 6999 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 6973 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7000 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
| 6974 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); | 7001 ExpectContains(*scroll_info, grand_child->id(), scroll_delta); |
| 6975 ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta); | 7002 ExpectContains(*scroll_info, child->id(), scroll_delta + scroll_delta); |
| 6976 | 7003 |
| 6977 // As the locked layer is at it's limit, no further scrolling can occur. | 7004 // As the locked layer is at it's limit, no further scrolling can occur. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6996 CreateScrollableLayer(2, content_size, root_clip.get()); | 7023 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 6997 | 7024 |
| 6998 root_scroll->AddChild(child.Pass()); | 7025 root_scroll->AddChild(child.Pass()); |
| 6999 root_clip->AddChild(root_scroll.Pass()); | 7026 root_clip->AddChild(root_scroll.Pass()); |
| 7000 | 7027 |
| 7001 host_impl_->SetViewportSize(surface_size); | 7028 host_impl_->SetViewportSize(surface_size); |
| 7002 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 7029 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 7003 host_impl_->active_tree()->DidBecomeActive(); | 7030 host_impl_->active_tree()->DidBecomeActive(); |
| 7004 DrawFrame(); | 7031 DrawFrame(); |
| 7005 { | 7032 { |
| 7006 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7033 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7007 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7034 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 7008 | 7035 |
| 7009 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7036 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7037 host_impl_->FlingScrollBegin()); |
| 7010 | 7038 |
| 7011 gfx::Vector2d scroll_delta(0, 100); | 7039 gfx::Vector2d scroll_delta(0, 100); |
| 7012 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7040 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7013 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7041 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7014 | 7042 |
| 7015 host_impl_->ScrollEnd(); | 7043 host_impl_->ScrollEnd(); |
| 7016 | 7044 |
| 7017 scoped_ptr<ScrollAndScaleSet> scroll_info = | 7045 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 7018 host_impl_->ProcessScrollDeltas(); | 7046 host_impl_->ProcessScrollDeltas(); |
| 7019 | 7047 |
| 7020 // The root should have scrolled. | 7048 // The root should have scrolled. |
| 7021 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7049 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
| 7022 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); | 7050 ExpectContains(*scroll_info.get(), root_scroll_id, gfx::Vector2d(0, 10)); |
| 7023 } | 7051 } |
| 7024 } | 7052 } |
| 7025 | 7053 |
| 7026 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { | 7054 TEST_F(LayerTreeHostImplTest, ScrollUnknownNotOnAncestorChain) { |
| 7027 // If we ray cast a scroller that is not on the first layer's ancestor chain, | 7055 // If we ray cast a scroller that is not on the first layer's ancestor chain, |
| 7028 // we should return SCROLL_UNKNOWN. | 7056 // we should return ScrollUnknown. |
| 7029 gfx::Size content_size(100, 100); | 7057 gfx::Size content_size(100, 100); |
| 7030 SetupScrollAndContentsLayers(content_size); | 7058 SetupScrollAndContentsLayers(content_size); |
| 7031 | 7059 |
| 7032 int scroll_layer_id = 2; | 7060 int scroll_layer_id = 2; |
| 7033 LayerImpl* scroll_layer = | 7061 LayerImpl* scroll_layer = |
| 7034 host_impl_->active_tree()->LayerById(scroll_layer_id); | 7062 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 7035 scroll_layer->SetDrawsContent(true); | 7063 scroll_layer->SetDrawsContent(true); |
| 7036 | 7064 |
| 7037 int page_scale_layer_id = 5; | 7065 int page_scale_layer_id = 5; |
| 7038 LayerImpl* page_scale_layer = | 7066 LayerImpl* page_scale_layer = |
| 7039 host_impl_->active_tree()->LayerById(page_scale_layer_id); | 7067 host_impl_->active_tree()->LayerById(page_scale_layer_id); |
| 7040 | 7068 |
| 7041 int occluder_layer_id = 6; | 7069 int occluder_layer_id = 6; |
| 7042 scoped_ptr<LayerImpl> occluder_layer = | 7070 scoped_ptr<LayerImpl> occluder_layer = |
| 7043 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); | 7071 LayerImpl::Create(host_impl_->active_tree(), occluder_layer_id); |
| 7044 occluder_layer->SetDrawsContent(true); | 7072 occluder_layer->SetDrawsContent(true); |
| 7045 occluder_layer->SetBounds(content_size); | 7073 occluder_layer->SetBounds(content_size); |
| 7046 occluder_layer->SetContentBounds(content_size); | 7074 occluder_layer->SetContentBounds(content_size); |
| 7047 occluder_layer->SetPosition(gfx::PointF()); | 7075 occluder_layer->SetPosition(gfx::PointF()); |
| 7048 | 7076 |
| 7049 // The parent of the occluder is *above* the scroller. | 7077 // The parent of the occluder is *above* the scroller. |
| 7050 page_scale_layer->AddChild(occluder_layer.Pass()); | 7078 page_scale_layer->AddChild(occluder_layer.Pass()); |
| 7051 | 7079 |
| 7052 DrawFrame(); | 7080 DrawFrame(); |
| 7053 | 7081 |
| 7054 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, | 7082 EXPECT_EQ(InputHandler::ScrollUnknown, |
| 7055 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7083 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 7056 } | 7084 } |
| 7057 | 7085 |
| 7058 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { | 7086 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { |
| 7059 // If we ray cast a scroller this is on the first layer's ancestor chain, but | 7087 // If we ray cast a scroller this is on the first layer's ancestor chain, but |
| 7060 // is not the first scroller we encounter when walking up from the layer, we | 7088 // is not the first scroller we encounter when walking up from the layer, we |
| 7061 // should also return SCROLL_UNKNOWN. | 7089 // should also return ScrollUnknown. |
| 7062 gfx::Size content_size(100, 100); | 7090 gfx::Size content_size(100, 100); |
| 7063 SetupScrollAndContentsLayers(content_size); | 7091 SetupScrollAndContentsLayers(content_size); |
| 7064 | 7092 |
| 7065 int scroll_layer_id = 2; | 7093 int scroll_layer_id = 2; |
| 7066 LayerImpl* scroll_layer = | 7094 LayerImpl* scroll_layer = |
| 7067 host_impl_->active_tree()->LayerById(scroll_layer_id); | 7095 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 7068 scroll_layer->SetDrawsContent(true); | 7096 scroll_layer->SetDrawsContent(true); |
| 7069 | 7097 |
| 7070 int occluder_layer_id = 6; | 7098 int occluder_layer_id = 6; |
| 7071 scoped_ptr<LayerImpl> occluder_layer = | 7099 scoped_ptr<LayerImpl> occluder_layer = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7083 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( | 7111 scoped_ptr<LayerImpl> child_scroll = CreateScrollableLayer( |
| 7084 child_scroll_layer_id, content_size, child_scroll_clip.get()); | 7112 child_scroll_layer_id, content_size, child_scroll_clip.get()); |
| 7085 | 7113 |
| 7086 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); | 7114 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); |
| 7087 | 7115 |
| 7088 child_scroll->AddChild(occluder_layer.Pass()); | 7116 child_scroll->AddChild(occluder_layer.Pass()); |
| 7089 scroll_layer->AddChild(child_scroll.Pass()); | 7117 scroll_layer->AddChild(child_scroll.Pass()); |
| 7090 | 7118 |
| 7091 DrawFrame(); | 7119 DrawFrame(); |
| 7092 | 7120 |
| 7093 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, | 7121 EXPECT_EQ(InputHandler::ScrollUnknown, |
| 7094 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7122 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 7095 } | 7123 } |
| 7096 | 7124 |
| 7097 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) { | 7125 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScroller) { |
| 7098 gfx::Size content_size(100, 100); | 7126 gfx::Size content_size(100, 100); |
| 7099 SetupScrollAndContentsLayers(content_size); | 7127 SetupScrollAndContentsLayers(content_size); |
| 7100 | 7128 |
| 7101 LayerImpl* root = host_impl_->active_tree()->LayerById(1); | 7129 LayerImpl* root = host_impl_->active_tree()->LayerById(1); |
| 7102 | 7130 |
| 7103 int scroll_layer_id = 2; | 7131 int scroll_layer_id = 2; |
| 7104 LayerImpl* scroll_layer = | 7132 LayerImpl* scroll_layer = |
| 7105 host_impl_->active_tree()->LayerById(scroll_layer_id); | 7133 host_impl_->active_tree()->LayerById(scroll_layer_id); |
| 7106 | 7134 |
| 7107 int child_scroll_layer_id = 7; | 7135 int child_scroll_layer_id = 7; |
| 7108 scoped_ptr<LayerImpl> child_scroll = | 7136 scoped_ptr<LayerImpl> child_scroll = |
| 7109 CreateScrollableLayer(child_scroll_layer_id, content_size, root); | 7137 CreateScrollableLayer(child_scroll_layer_id, content_size, root); |
| 7110 child_scroll->SetDrawsContent(false); | 7138 child_scroll->SetDrawsContent(false); |
| 7111 | 7139 |
| 7112 scroll_layer->AddChild(child_scroll.Pass()); | 7140 scroll_layer->AddChild(child_scroll.Pass()); |
| 7113 | 7141 |
| 7114 DrawFrame(); | 7142 DrawFrame(); |
| 7115 | 7143 |
| 7116 // We should not have scrolled |child_scroll| even though we technically "hit" | 7144 // We should not have scrolled |child_scroll| even though we technically "hit" |
| 7117 // it. The reason for this is that if the scrolling the scroll would not move | 7145 // it. The reason for this is that if the scrolling the scroll would not move |
| 7118 // any layer that is a drawn RSLL member, then we can ignore the hit. | 7146 // any layer that is a drawn RSLL member, then we can ignore the hit. |
| 7119 // | 7147 // |
| 7120 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and | 7148 // Why ScrollStarted? In this case, it's because we've bubbled out and started |
| 7121 // started overscrolling the inner viewport. | 7149 // overscrolling the inner viewport. |
| 7122 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7150 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7123 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7151 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 7124 | 7152 |
| 7125 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); | 7153 EXPECT_EQ(2, host_impl_->CurrentlyScrollingLayer()->id()); |
| 7126 } | 7154 } |
| 7127 | 7155 |
| 7128 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { | 7156 TEST_F(LayerTreeHostImplTest, ScrollInvisibleScrollerWithVisibleScrollChild) { |
| 7129 // This test case is very similar to the one above with one key difference: | 7157 // This test case is very similar to the one above with one key difference: |
| 7130 // the invisible scroller has a scroll child that is indeed draw contents. | 7158 // the invisible scroller has a scroll child that is indeed draw contents. |
| 7131 // If we attempt to initiate a gesture scroll off of the visible scroll child | 7159 // If we attempt to initiate a gesture scroll off of the visible scroll child |
| 7132 // we should still start the scroll child. | 7160 // we should still start the scroll child. |
| 7133 gfx::Size content_size(100, 100); | 7161 gfx::Size content_size(100, 100); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7167 container->AddChild(scroll_child.Pass()); | 7195 container->AddChild(scroll_child.Pass()); |
| 7168 | 7196 |
| 7169 scroll_layer->AddChild(container.Pass()); | 7197 scroll_layer->AddChild(container.Pass()); |
| 7170 | 7198 |
| 7171 DrawFrame(); | 7199 DrawFrame(); |
| 7172 | 7200 |
| 7173 // We should not have scrolled |child_scroll| even though we technically "hit" | 7201 // We should not have scrolled |child_scroll| even though we technically "hit" |
| 7174 // it. The reason for this is that if the scrolling the scroll would not move | 7202 // it. The reason for this is that if the scrolling the scroll would not move |
| 7175 // any layer that is a drawn RSLL member, then we can ignore the hit. | 7203 // any layer that is a drawn RSLL member, then we can ignore the hit. |
| 7176 // | 7204 // |
| 7177 // Why SCROLL_STARTED? In this case, it's because we've bubbled out and | 7205 // Why ScrollStarted? In this case, it's because we've bubbled out and started |
| 7178 // started overscrolling the inner viewport. | 7206 // overscrolling the inner viewport. |
| 7179 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7207 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7180 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 7208 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 7181 | 7209 |
| 7182 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); | 7210 EXPECT_EQ(7, host_impl_->CurrentlyScrollingLayer()->id()); |
| 7183 } | 7211 } |
| 7184 | 7212 |
| 7185 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed | 7213 // Make sure LatencyInfo carried by LatencyInfoSwapPromise are passed |
| 7186 // to CompositorFrameMetadata after SwapBuffers(); | 7214 // to CompositorFrameMetadata after SwapBuffers(); |
| 7187 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { | 7215 TEST_F(LayerTreeHostImplTest, LatencyInfoPassedToCompositorFrameMetadata) { |
| 7188 scoped_ptr<SolidColorLayerImpl> root = | 7216 scoped_ptr<SolidColorLayerImpl> root = |
| 7189 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); | 7217 SolidColorLayerImpl::Create(host_impl_->active_tree(), 1); |
| 7190 root->SetPosition(gfx::PointF()); | 7218 root->SetPosition(gfx::PointF()); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7366 forward_to_main_count = 0; | 7394 forward_to_main_count = 0; |
| 7367 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( | 7395 scoped_ptr<SimpleSwapPromiseMonitor> swap_promise_monitor( |
| 7368 new SimpleSwapPromiseMonitor(NULL, | 7396 new SimpleSwapPromiseMonitor(NULL, |
| 7369 host_impl_.get(), | 7397 host_impl_.get(), |
| 7370 &set_needs_commit_count, | 7398 &set_needs_commit_count, |
| 7371 &set_needs_redraw_count, | 7399 &set_needs_redraw_count, |
| 7372 &forward_to_main_count)); | 7400 &forward_to_main_count)); |
| 7373 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 7401 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 7374 | 7402 |
| 7375 // Scrolling normally should not trigger any forwarding. | 7403 // Scrolling normally should not trigger any forwarding. |
| 7376 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7404 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7377 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7405 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7378 EXPECT_TRUE( | 7406 EXPECT_TRUE( |
| 7379 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); | 7407 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); |
| 7380 host_impl_->ScrollEnd(); | 7408 host_impl_->ScrollEnd(); |
| 7381 | 7409 |
| 7382 EXPECT_EQ(0, set_needs_commit_count); | 7410 EXPECT_EQ(0, set_needs_commit_count); |
| 7383 EXPECT_EQ(1, set_needs_redraw_count); | 7411 EXPECT_EQ(1, set_needs_redraw_count); |
| 7384 EXPECT_EQ(0, forward_to_main_count); | 7412 EXPECT_EQ(0, forward_to_main_count); |
| 7385 | 7413 |
| 7386 // Scrolling with a scroll handler should defer the swap to the main | 7414 // Scrolling with a scroll handler should defer the swap to the main |
| 7387 // thread. | 7415 // thread. |
| 7388 scroll_layer->SetHaveScrollEventHandlers(true); | 7416 scroll_layer->SetHaveScrollEventHandlers(true); |
| 7389 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7417 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7390 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7418 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7391 EXPECT_TRUE( | 7419 EXPECT_TRUE( |
| 7392 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); | 7420 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)).did_scroll); |
| 7393 host_impl_->ScrollEnd(); | 7421 host_impl_->ScrollEnd(); |
| 7394 | 7422 |
| 7395 EXPECT_EQ(0, set_needs_commit_count); | 7423 EXPECT_EQ(0, set_needs_commit_count); |
| 7396 EXPECT_EQ(2, set_needs_redraw_count); | 7424 EXPECT_EQ(2, set_needs_redraw_count); |
| 7397 EXPECT_EQ(1, forward_to_main_count); | 7425 EXPECT_EQ(1, forward_to_main_count); |
| 7398 } | 7426 } |
| 7399 } | 7427 } |
| 7400 | 7428 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7455 EXPECT_TRUE(did_request_redraw_); | 7483 EXPECT_TRUE(did_request_redraw_); |
| 7456 } | 7484 } |
| 7457 | 7485 |
| 7458 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { | 7486 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { |
| 7459 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7487 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7460 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7488 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 7461 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7489 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 7462 BOTH, SHOWN, false); | 7490 BOTH, SHOWN, false); |
| 7463 DrawFrame(); | 7491 DrawFrame(); |
| 7464 | 7492 |
| 7465 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7493 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7466 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7494 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7467 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7495 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7468 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7496 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7469 scroll_layer->CurrentScrollOffset().ToString()); | 7497 scroll_layer->CurrentScrollOffset().ToString()); |
| 7470 | 7498 |
| 7471 // Scroll just the top controls and verify that the scroll succeeds. | 7499 // Scroll just the top controls and verify that the scroll succeeds. |
| 7472 const float residue = 10; | 7500 const float residue = 10; |
| 7473 float offset = top_controls_height_ - residue; | 7501 float offset = top_controls_height_ - residue; |
| 7474 EXPECT_TRUE( | 7502 EXPECT_TRUE( |
| 7475 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7503 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7476 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7504 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7514 host_impl_->ScrollEnd(); | 7542 host_impl_->ScrollEnd(); |
| 7515 } | 7543 } |
| 7516 | 7544 |
| 7517 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { | 7545 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAtOrigin) { |
| 7518 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7546 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7519 host_impl_->SetViewportSize(gfx::Size(100, 200)); | 7547 host_impl_->SetViewportSize(gfx::Size(100, 200)); |
| 7520 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7548 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 7521 BOTH, SHOWN, false); | 7549 BOTH, SHOWN, false); |
| 7522 DrawFrame(); | 7550 DrawFrame(); |
| 7523 | 7551 |
| 7524 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7552 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7525 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7553 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7526 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7554 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7527 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7555 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7528 scroll_layer->CurrentScrollOffset().ToString()); | 7556 scroll_layer->CurrentScrollOffset().ToString()); |
| 7529 | 7557 |
| 7530 // Scroll the top controls partially. | 7558 // Scroll the top controls partially. |
| 7531 const float residue = 35; | 7559 const float residue = 35; |
| 7532 float offset = top_controls_height_ - residue; | 7560 float offset = top_controls_height_ - residue; |
| 7533 EXPECT_TRUE( | 7561 EXPECT_TRUE( |
| 7534 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7562 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7535 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7563 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7584 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { | 7612 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { |
| 7585 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7613 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7586 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7614 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 7587 host_impl_->top_controls_manager()->UpdateTopControlsState( | 7615 host_impl_->top_controls_manager()->UpdateTopControlsState( |
| 7588 BOTH, SHOWN, false); | 7616 BOTH, SHOWN, false); |
| 7589 float initial_scroll_offset = 50; | 7617 float initial_scroll_offset = 50; |
| 7590 scroll_layer->PushScrollOffsetFromMainThread( | 7618 scroll_layer->PushScrollOffsetFromMainThread( |
| 7591 gfx::ScrollOffset(0, initial_scroll_offset)); | 7619 gfx::ScrollOffset(0, initial_scroll_offset)); |
| 7592 DrawFrame(); | 7620 DrawFrame(); |
| 7593 | 7621 |
| 7594 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7622 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7595 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7623 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7596 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7624 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7597 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), | 7625 EXPECT_EQ(gfx::Vector2dF(0, initial_scroll_offset).ToString(), |
| 7598 scroll_layer->CurrentScrollOffset().ToString()); | 7626 scroll_layer->CurrentScrollOffset().ToString()); |
| 7599 | 7627 |
| 7600 // Scroll the top controls partially. | 7628 // Scroll the top controls partially. |
| 7601 const float residue = 15; | 7629 const float residue = 15; |
| 7602 float offset = top_controls_height_ - residue; | 7630 float offset = top_controls_height_ - residue; |
| 7603 EXPECT_TRUE( | 7631 EXPECT_TRUE( |
| 7604 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7632 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7605 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7633 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7645 TopControlsScrollDeltaInOverScroll) { | 7673 TopControlsScrollDeltaInOverScroll) { |
| 7646 // test varifies that the overscroll delta should not have accumulated in | 7674 // test varifies that the overscroll delta should not have accumulated in |
| 7647 // the top controls if we do a hide and show without releasing finger. | 7675 // the top controls if we do a hide and show without releasing finger. |
| 7648 | 7676 |
| 7649 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7677 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7650 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 7678 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 7651 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, | 7679 host_impl_->top_controls_manager()->UpdateTopControlsState(BOTH, SHOWN, |
| 7652 false); | 7680 false); |
| 7653 DrawFrame(); | 7681 DrawFrame(); |
| 7654 | 7682 |
| 7655 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7683 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7656 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7684 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7657 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7685 EXPECT_EQ(0, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7658 | 7686 |
| 7659 float offset = 50; | 7687 float offset = 50; |
| 7660 EXPECT_TRUE( | 7688 EXPECT_TRUE( |
| 7661 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); | 7689 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, offset)).did_scroll); |
| 7662 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); | 7690 EXPECT_EQ(-offset, host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 7663 EXPECT_EQ(gfx::Vector2dF().ToString(), | 7691 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 7664 scroll_layer->CurrentScrollOffset().ToString()); | 7692 scroll_layer->CurrentScrollOffset().ToString()); |
| 7665 | 7693 |
| 7666 EXPECT_TRUE( | 7694 EXPECT_TRUE( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7778 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7806 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 7779 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7807 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 7780 DrawFrame(); | 7808 DrawFrame(); |
| 7781 { | 7809 { |
| 7782 gfx::Vector2dF inner_expected; | 7810 gfx::Vector2dF inner_expected; |
| 7783 gfx::Vector2dF outer_expected; | 7811 gfx::Vector2dF outer_expected; |
| 7784 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7812 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7785 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7813 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7786 | 7814 |
| 7787 // Make sure the fling goes to the outer viewport first | 7815 // Make sure the fling goes to the outer viewport first |
| 7788 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7816 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7789 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7817 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7790 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7818 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7791 | 7819 |
| 7792 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7820 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
| 7793 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7821 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7794 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7822 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7795 | 7823 |
| 7796 host_impl_->ScrollEnd(); | 7824 host_impl_->ScrollEnd(); |
| 7797 | 7825 |
| 7798 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7826 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7799 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7827 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7800 | 7828 |
| 7801 // Fling past the outer viewport boundry, make sure inner viewport scrolls. | 7829 // Fling past the outer viewport boundry, make sure inner viewport scrolls. |
| 7802 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7830 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7803 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7831 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7804 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7832 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7805 | 7833 |
| 7806 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7834 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7807 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7835 outer_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7808 | 7836 |
| 7809 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7837 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7810 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); | 7838 inner_expected += gfx::Vector2dF(scroll_delta.x(), scroll_delta.y()); |
| 7811 | 7839 |
| 7812 host_impl_->ScrollEnd(); | 7840 host_impl_->ScrollEnd(); |
| 7813 | 7841 |
| 7814 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7842 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7827 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 7855 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 7828 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 7856 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 7829 DrawFrame(); | 7857 DrawFrame(); |
| 7830 { | 7858 { |
| 7831 gfx::Vector2dF inner_expected; | 7859 gfx::Vector2dF inner_expected; |
| 7832 gfx::Vector2dF outer_expected; | 7860 gfx::Vector2dF outer_expected; |
| 7833 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7861 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7834 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7862 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7835 | 7863 |
| 7836 // Make sure the scroll goes to the outer viewport first. | 7864 // Make sure the scroll goes to the outer viewport first. |
| 7837 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7865 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7838 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7866 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7839 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7867 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7840 | 7868 |
| 7841 // Scroll near the edge of the outer viewport. | 7869 // Scroll near the edge of the outer viewport. |
| 7842 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); | 7870 gfx::Vector2d scroll_delta(inner_viewport.width(), inner_viewport.height()); |
| 7843 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 7871 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 7844 outer_expected += scroll_delta; | 7872 outer_expected += scroll_delta; |
| 7845 | 7873 |
| 7846 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); | 7874 EXPECT_VECTOR_EQ(inner_expected, inner_scroll->CurrentScrollOffset()); |
| 7847 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); | 7875 EXPECT_VECTOR_EQ(outer_expected, outer_scroll->CurrentScrollOffset()); |
| 7848 | 7876 |
| 7849 // Now diagonal scroll across the outer viewport boundary in a single event. | 7877 // Now diagonal scroll across the outer viewport boundary in a single event. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7873 scoped_ptr<LayerImpl> child = | 7901 scoped_ptr<LayerImpl> child = |
| 7874 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 7902 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 7875 LayerImpl* child_scroll = child.get(); | 7903 LayerImpl* child_scroll = child.get(); |
| 7876 outer_scroll->children()[0]->AddChild(child.Pass()); | 7904 outer_scroll->children()[0]->AddChild(child.Pass()); |
| 7877 | 7905 |
| 7878 DrawFrame(); | 7906 DrawFrame(); |
| 7879 { | 7907 { |
| 7880 scoped_ptr<ScrollAndScaleSet> scroll_info; | 7908 scoped_ptr<ScrollAndScaleSet> scroll_info; |
| 7881 | 7909 |
| 7882 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 7910 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
| 7883 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7911 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7884 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 7912 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 7885 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7913 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 7886 | 7914 |
| 7887 // The child should have scrolled up to its limit. | 7915 // The child should have scrolled up to its limit. |
| 7888 scroll_info = host_impl_->ProcessScrollDeltas(); | 7916 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 7889 ASSERT_EQ(1u, scroll_info->scrolls.size()); | 7917 ASSERT_EQ(1u, scroll_info->scrolls.size()); |
| 7890 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); | 7918 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); |
| 7891 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); | 7919 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), child_scroll); |
| 7892 | 7920 |
| 7893 // The first |ScrollBy| after the fling should re-lock the scrolling | 7921 // The first |ScrollBy| after the fling should re-lock the scrolling |
| 7894 // layer to the first layer that scrolled, the inner viewport scroll layer. | 7922 // layer to the first layer that scrolled, the inner viewport scroll layer. |
| 7895 EXPECT_EQ(InputHandler::SCROLL_STARTED, host_impl_->FlingScrollBegin()); | 7923 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 7896 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); | 7924 EXPECT_TRUE(host_impl_->ScrollBy(gfx::Point(), scroll_delta).did_scroll); |
| 7897 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 7925 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| 7898 | 7926 |
| 7899 // The inner viewport should have scrolled up to its limit. | 7927 // The inner viewport should have scrolled up to its limit. |
| 7900 scroll_info = host_impl_->ProcessScrollDeltas(); | 7928 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 7901 ASSERT_EQ(2u, scroll_info->scrolls.size()); | 7929 ASSERT_EQ(2u, scroll_info->scrolls.size()); |
| 7902 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); | 7930 ExpectContains(*scroll_info, child_scroll->id(), scroll_delta); |
| 7903 ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta); | 7931 ExpectContains(*scroll_info, inner_scroll->id(), scroll_delta); |
| 7904 | 7932 |
| 7905 // As the locked layer is at its limit, no further scrolling can occur. | 7933 // As the locked layer is at its limit, no further scrolling can occur. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7961 external_transform, layer->draw_properties().target_space_transform); | 7989 external_transform, layer->draw_properties().target_space_transform); |
| 7962 } | 7990 } |
| 7963 | 7991 |
| 7964 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { | 7992 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { |
| 7965 SetupScrollAndContentsLayers(gfx::Size(100, 200)); | 7993 SetupScrollAndContentsLayers(gfx::Size(100, 200)); |
| 7966 DrawFrame(); | 7994 DrawFrame(); |
| 7967 | 7995 |
| 7968 base::TimeTicks start_time = | 7996 base::TimeTicks start_time = |
| 7969 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); | 7997 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); |
| 7970 | 7998 |
| 7971 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 7999 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7972 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 8000 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
| 7973 | 8001 |
| 7974 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); | 8002 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); |
| 7975 | 8003 |
| 7976 host_impl_->Animate(start_time); | 8004 host_impl_->Animate(start_time); |
| 7977 host_impl_->UpdateAnimationState(true); | 8005 host_impl_->UpdateAnimationState(true); |
| 7978 | 8006 |
| 7979 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); | 8007 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); |
| 7980 | 8008 |
| 7981 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); | 8009 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); |
| 7982 host_impl_->UpdateAnimationState(true); | 8010 host_impl_->UpdateAnimationState(true); |
| 7983 | 8011 |
| 7984 float y = scrolling_layer->CurrentScrollOffset().y(); | 8012 float y = scrolling_layer->CurrentScrollOffset().y(); |
| 7985 EXPECT_TRUE(y > 1 && y < 49); | 8013 EXPECT_TRUE(y > 1 && y < 49); |
| 7986 | 8014 |
| 7987 // Update target. | 8015 // Update target. |
| 7988 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8016 EXPECT_EQ(InputHandler::ScrollStarted, |
| 7989 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); | 8017 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); |
| 7990 | 8018 |
| 7991 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); | 8019 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); |
| 7992 host_impl_->UpdateAnimationState(true); | 8020 host_impl_->UpdateAnimationState(true); |
| 7993 | 8021 |
| 7994 y = scrolling_layer->CurrentScrollOffset().y(); | 8022 y = scrolling_layer->CurrentScrollOffset().y(); |
| 7995 EXPECT_TRUE(y > 50 && y < 100); | 8023 EXPECT_TRUE(y > 50 && y < 100); |
| 7996 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); | 8024 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); |
| 7997 | 8025 |
| 7998 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 8026 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8321 float page_scale_factor = 1.f; | 8349 float page_scale_factor = 1.f; |
| 8322 | 8350 |
| 8323 // The scroll deltas should have the page scale factor applied. | 8351 // The scroll deltas should have the page scale factor applied. |
| 8324 { | 8352 { |
| 8325 host_impl_->active_tree()->PushPageScaleFromMainThread( | 8353 host_impl_->active_tree()->PushPageScaleFromMainThread( |
| 8326 page_scale_factor, min_page_scale, max_page_scale); | 8354 page_scale_factor, min_page_scale, max_page_scale); |
| 8327 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); | 8355 host_impl_->SetPageScaleOnActiveTree(page_scale_factor); |
| 8328 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 8356 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
| 8329 | 8357 |
| 8330 float page_scale_delta = 2.f; | 8358 float page_scale_delta = 2.f; |
| 8331 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE); | 8359 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture); |
| 8332 host_impl_->PinchGestureBegin(); | 8360 host_impl_->PinchGestureBegin(); |
| 8333 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); | 8361 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); |
| 8334 host_impl_->PinchGestureEnd(); | 8362 host_impl_->PinchGestureEnd(); |
| 8335 host_impl_->ScrollEnd(); | 8363 host_impl_->ScrollEnd(); |
| 8336 | 8364 |
| 8337 gfx::Vector2dF scroll_delta(0, 5); | 8365 gfx::Vector2dF scroll_delta(0, 5); |
| 8338 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 8366 EXPECT_EQ(InputHandler::ScrollStarted, |
| 8339 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 8367 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 8340 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); | 8368 EXPECT_VECTOR_EQ(gfx::Vector2dF(), scroll_layer->CurrentScrollOffset()); |
| 8341 | 8369 |
| 8342 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 8370 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 8343 host_impl_->ScrollEnd(); | 8371 host_impl_->ScrollEnd(); |
| 8344 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), | 8372 EXPECT_VECTOR_EQ(gfx::Vector2dF(0, 2.5), |
| 8345 scroll_layer->CurrentScrollOffset()); | 8373 scroll_layer->CurrentScrollOffset()); |
| 8346 } | 8374 } |
| 8347 } | 8375 } |
| 8348 | 8376 |
| 8349 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { | 8377 class LayerTreeHostImplCountingLostSurfaces : public LayerTreeHostImplTest { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8361 // surface. | 8389 // surface. |
| 8362 EXPECT_EQ(0, num_lost_surfaces_); | 8390 EXPECT_EQ(0, num_lost_surfaces_); |
| 8363 host_impl_->DidLoseOutputSurface(); | 8391 host_impl_->DidLoseOutputSurface(); |
| 8364 EXPECT_EQ(1, num_lost_surfaces_); | 8392 EXPECT_EQ(1, num_lost_surfaces_); |
| 8365 host_impl_->DidLoseOutputSurface(); | 8393 host_impl_->DidLoseOutputSurface(); |
| 8366 EXPECT_LE(1, num_lost_surfaces_); | 8394 EXPECT_LE(1, num_lost_surfaces_); |
| 8367 } | 8395 } |
| 8368 | 8396 |
| 8369 } // namespace | 8397 } // namespace |
| 8370 } // namespace cc | 8398 } // namespace cc |
| OLD | NEW |