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