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

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

Issue 1604053002: cc: Fix enum style conformance in InputHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enumname: fixcasts Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
16 #include "base/containers/scoped_ptr_hash_map.h" 16 #include "base/containers/scoped_ptr_hash_map.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "cc/animation/animation_events.h" 19 #include "cc/animation/animation_events.h"
20 #include "cc/animation/animation_host.h" 20 #include "cc/animation/animation_host.h"
21 #include "cc/animation/animation_id_provider.h" 21 #include "cc/animation/animation_id_provider.h"
22 #include "cc/animation/scrollbar_animation_controller_thinning.h" 22 #include "cc/animation/scrollbar_animation_controller_thinning.h"
23 #include "cc/animation/transform_operations.h" 23 #include "cc/animation/transform_operations.h"
24 #include "cc/base/math_util.h" 24 #include "cc/base/math_util.h"
25 #include "cc/input/main_thread_scrolling_reason.h"
25 #include "cc/input/page_scale_animation.h" 26 #include "cc/input/page_scale_animation.h"
26 #include "cc/input/top_controls_manager.h" 27 #include "cc/input/top_controls_manager.h"
27 #include "cc/layers/append_quads_data.h" 28 #include "cc/layers/append_quads_data.h"
28 #include "cc/layers/delegated_renderer_layer_impl.h" 29 #include "cc/layers/delegated_renderer_layer_impl.h"
29 #include "cc/layers/heads_up_display_layer_impl.h" 30 #include "cc/layers/heads_up_display_layer_impl.h"
30 #include "cc/layers/io_surface_layer_impl.h" 31 #include "cc/layers/io_surface_layer_impl.h"
31 #include "cc/layers/layer_impl.h" 32 #include "cc/layers/layer_impl.h"
32 #include "cc/layers/painted_scrollbar_layer_impl.h" 33 #include "cc/layers/painted_scrollbar_layer_impl.h"
33 #include "cc/layers/render_surface_impl.h" 34 #include "cc/layers/render_surface_impl.h"
34 #include "cc/layers/solid_color_layer_impl.h" 35 #include "cc/layers/solid_color_layer_impl.h"
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } 618 }
618 619
619 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) { 620 TEST_F(LayerTreeHostImplTest, ScrollRootCallsCommitAndRedraw) {
620 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 621 SetupScrollAndContentsLayers(gfx::Size(100, 100));
621 host_impl_->SetViewportSize(gfx::Size(50, 50)); 622 host_impl_->SetViewportSize(gfx::Size(50, 50));
622 DrawFrame(); 623 DrawFrame();
623 624
624 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 625 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
625 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 626 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
626 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 627 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
627 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 628 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
628 status.main_thread_scrolling_reasons); 629 status.main_thread_scrolling_reasons);
629 630
630 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 631 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
631 InputHandler::WHEEL)); 632 InputHandler::WHEEL));
632 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 633 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
633 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10), 634 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(0, 10),
634 InputHandler::WHEEL)); 635 InputHandler::WHEEL));
635 host_impl_->ScrollEnd(EndState().get()); 636 host_impl_->ScrollEnd(EndState().get());
636 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(), 637 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(),
637 InputHandler::WHEEL)); 638 InputHandler::WHEEL));
638 EXPECT_TRUE(did_request_redraw_); 639 EXPECT_TRUE(did_request_redraw_);
639 EXPECT_TRUE(did_request_commit_); 640 EXPECT_TRUE(did_request_commit_);
640 } 641 }
641 642
642 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) { 643 TEST_F(LayerTreeHostImplTest, ScrollActiveOnlyAfterScrollMovement) {
643 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 644 SetupScrollAndContentsLayers(gfx::Size(100, 100));
644 host_impl_->SetViewportSize(gfx::Size(50, 50)); 645 host_impl_->SetViewportSize(gfx::Size(50, 50));
645 DrawFrame(); 646 DrawFrame();
646 647
647 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 648 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
648 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 649 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
649 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 650 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
650 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 651 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
651 status.main_thread_scrolling_reasons); 652 status.main_thread_scrolling_reasons);
652 653
653 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); 654 EXPECT_FALSE(host_impl_->IsActivelyScrolling());
654 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 655 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
655 EXPECT_TRUE(host_impl_->IsActivelyScrolling()); 656 EXPECT_TRUE(host_impl_->IsActivelyScrolling());
656 host_impl_->ScrollEnd(EndState().get()); 657 host_impl_->ScrollEnd(EndState().get());
657 EXPECT_FALSE(host_impl_->IsActivelyScrolling()); 658 EXPECT_FALSE(host_impl_->IsActivelyScrolling());
658 } 659 }
659 660
660 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) { 661 TEST_F(LayerTreeHostImplTest, ScrollWithoutRootLayer) {
661 // We should not crash when trying to scroll an empty layer tree. 662 // We should not crash when trying to scroll an empty layer tree.
662 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 663 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
663 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 664 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
664 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 665 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
665 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 666 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
666 status.main_thread_scrolling_reasons); 667 status.main_thread_scrolling_reasons);
667 } 668 }
668 669
669 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) { 670 TEST_F(LayerTreeHostImplTest, ScrollWithoutRenderer) {
670 scoped_ptr<TestWebGraphicsContext3D> context_owned = 671 scoped_ptr<TestWebGraphicsContext3D> context_owned =
671 TestWebGraphicsContext3D::Create(); 672 TestWebGraphicsContext3D::Create();
672 context_owned->set_context_lost(true); 673 context_owned->set_context_lost(true);
673 674
674 // Initialization will fail. 675 // Initialization will fail.
675 EXPECT_FALSE( 676 EXPECT_FALSE(
676 CreateHostImpl(DefaultSettings(), 677 CreateHostImpl(DefaultSettings(),
677 FakeOutputSurface::Create3d(std::move(context_owned)))); 678 FakeOutputSurface::Create3d(std::move(context_owned))));
678 679
679 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 680 SetupScrollAndContentsLayers(gfx::Size(100, 100));
680 681
681 // We should not crash when trying to scroll after the renderer initialization 682 // We should not crash when trying to scroll after the renderer initialization
682 // fails. 683 // fails.
683 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 684 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
684 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 685 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
685 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 686 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
686 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 687 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
687 status.main_thread_scrolling_reasons); 688 status.main_thread_scrolling_reasons);
688 } 689 }
689 690
690 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) { 691 TEST_F(LayerTreeHostImplTest, ReplaceTreeWhileScrolling) {
691 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 692 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100));
692 host_impl_->SetViewportSize(gfx::Size(50, 50)); 693 host_impl_->SetViewportSize(gfx::Size(50, 50));
693 DrawFrame(); 694 DrawFrame();
694 695
695 // We should not crash if the tree is replaced while we are scrolling. 696 // We should not crash if the tree is replaced while we are scrolling.
696 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, 697 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
(...skipping 19 matching lines...) Expand all
716 host_impl_->SetViewportSize(gfx::Size(50, 50)); 717 host_impl_->SetViewportSize(gfx::Size(50, 50));
717 DrawFrame(); 718 DrawFrame();
718 LayerImpl* root = host_impl_->active_tree()->root_layer(); 719 LayerImpl* root = host_impl_->active_tree()->root_layer();
719 720
720 // With registered event handlers, wheel scrolls don't necessarily 721 // With registered event handlers, wheel scrolls don't necessarily
721 // have to go to the main thread. 722 // have to go to the main thread.
722 root->SetHaveWheelEventHandlers(true); 723 root->SetHaveWheelEventHandlers(true);
723 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 724 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
724 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 725 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
725 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 726 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
726 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 727 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
727 status.main_thread_scrolling_reasons); 728 status.main_thread_scrolling_reasons);
728 host_impl_->ScrollEnd(EndState().get()); 729 host_impl_->ScrollEnd(EndState().get());
729 730
730 // But typically the scroll-blocks-on mode will require them to. 731 // But typically the scroll-blocks-on mode will require them to.
731 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | 732 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT |
732 SCROLL_BLOCKS_ON_START_TOUCH); 733 SCROLL_BLOCKS_ON_START_TOUCH);
733 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 734 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
734 InputHandler::WHEEL); 735 InputHandler::WHEEL);
735 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 736 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
736 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 737 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
738 status.main_thread_scrolling_reasons);
737 739
738 // But gesture scrolls can still be handled. 740 // But gesture scrolls can still be handled.
739 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 741 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
740 InputHandler::GESTURE); 742 InputHandler::GESTURE);
741 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 743 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
742 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 744 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
743 status.main_thread_scrolling_reasons); 745 status.main_thread_scrolling_reasons);
744 host_impl_->ScrollEnd(EndState().get()); 746 host_impl_->ScrollEnd(EndState().get());
745 747
746 // And if the handlers go away, wheel scrolls can again be processed 748 // And if the handlers go away, wheel scrolls can again be processed
747 // on impl (despite the scroll-blocks-on mode). 749 // on impl (despite the scroll-blocks-on mode).
748 root->SetHaveWheelEventHandlers(false); 750 root->SetHaveWheelEventHandlers(false);
749 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 751 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
750 InputHandler::WHEEL); 752 InputHandler::WHEEL);
751 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 753 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
752 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 754 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
753 status.main_thread_scrolling_reasons); 755 status.main_thread_scrolling_reasons);
754 host_impl_->ScrollEnd(EndState().get()); 756 host_impl_->ScrollEnd(EndState().get());
755 } 757 }
756 758
757 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { 759 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) {
758 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 760 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100));
759 host_impl_->SetViewportSize(gfx::Size(50, 50)); 761 host_impl_->SetViewportSize(gfx::Size(50, 50));
760 DrawFrame(); 762 DrawFrame();
761 LayerImpl* root = host_impl_->active_tree()->root_layer(); 763 LayerImpl* root = host_impl_->active_tree()->root_layer();
762 764
(...skipping 13 matching lines...) Expand all
776 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); 778 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100));
777 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); 779 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10)));
778 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH | 780 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH |
779 SCROLL_BLOCKS_ON_WHEEL_EVENT); 781 SCROLL_BLOCKS_ON_WHEEL_EVENT);
780 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); 782 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10)));
781 783
782 // But they don't influence the actual handling of the scroll gestures. 784 // But they don't influence the actual handling of the scroll gestures.
783 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 785 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
784 BeginState(gfx::Point()).get(), InputHandler::GESTURE); 786 BeginState(gfx::Point()).get(), InputHandler::GESTURE);
785 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 787 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
786 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 788 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
787 status.main_thread_scrolling_reasons); 789 status.main_thread_scrolling_reasons);
788 host_impl_->ScrollEnd(EndState().get()); 790 host_impl_->ScrollEnd(EndState().get());
789 791
790 // It's the union of scroll-blocks-on mode bits across all layers in the 792 // It's the union of scroll-blocks-on mode bits across all layers in the
791 // scroll paret chain that matters. 793 // scroll paret chain that matters.
792 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); 794 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
793 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_NONE); 795 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_NONE);
794 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); 796 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
795 child->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH); 797 child->SetScrollBlocksOn(SCROLL_BLOCKS_ON_START_TOUCH);
796 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); 798 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30)));
797 } 799 }
798 800
799 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnScrollEventHandlers) { 801 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnScrollEventHandlers) {
800 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 802 SetupScrollAndContentsLayers(gfx::Size(100, 100));
801 host_impl_->SetViewportSize(gfx::Size(50, 50)); 803 host_impl_->SetViewportSize(gfx::Size(50, 50));
802 DrawFrame(); 804 DrawFrame();
803 LayerImpl* root = host_impl_->active_tree()->root_layer(); 805 LayerImpl* root = host_impl_->active_tree()->root_layer();
804 806
805 // With registered scroll handlers, scrolls don't generally have to go 807 // With registered scroll handlers, scrolls don't generally have to go
806 // to the main thread. 808 // to the main thread.
807 root->SetHaveScrollEventHandlers(true); 809 root->SetHaveScrollEventHandlers(true);
808 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 810 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
809 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 811 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
810 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 812 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
811 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 813 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
812 status.main_thread_scrolling_reasons); 814 status.main_thread_scrolling_reasons);
813 815
814 host_impl_->ScrollEnd(EndState().get()); 816 host_impl_->ScrollEnd(EndState().get());
815 817
816 // Even the default scroll blocks on mode doesn't require this. 818 // Even the default scroll blocks on mode doesn't require this.
817 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | 819 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT |
818 SCROLL_BLOCKS_ON_START_TOUCH); 820 SCROLL_BLOCKS_ON_START_TOUCH);
819 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 821 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
820 InputHandler::GESTURE); 822 InputHandler::GESTURE);
821 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 823 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
822 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 824 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
823 status.main_thread_scrolling_reasons); 825 status.main_thread_scrolling_reasons);
824 826
825 host_impl_->ScrollEnd(EndState().get()); 827 host_impl_->ScrollEnd(EndState().get());
826 828
827 // But the page can opt in to blocking on scroll event handlers. 829 // But the page can opt in to blocking on scroll event handlers.
828 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); 830 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT);
829 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 831 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
830 InputHandler::GESTURE); 832 InputHandler::GESTURE);
831 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 833 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
832 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 834 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
835 status.main_thread_scrolling_reasons);
833 836
834 // GESTURE and WHEEL scrolls behave identically in this regard. 837 // GESTURE and WHEEL scrolls behave identically in this regard.
835 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 838 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
836 InputHandler::WHEEL); 839 InputHandler::WHEEL);
837 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 840 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
838 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 841 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
842 status.main_thread_scrolling_reasons);
839 843
840 // And if the handlers go away, scrolls can again be processed on impl 844 // And if the handlers go away, scrolls can again be processed on impl
841 // (despite the scroll-blocks-on mode). 845 // (despite the scroll-blocks-on mode).
842 root->SetHaveScrollEventHandlers(false); 846 root->SetHaveScrollEventHandlers(false);
843 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 847 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
844 InputHandler::GESTURE); 848 InputHandler::GESTURE);
845 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 849 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
846 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 850 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
847 status.main_thread_scrolling_reasons); 851 status.main_thread_scrolling_reasons);
848 852
849 host_impl_->ScrollEnd(EndState().get()); 853 host_impl_->ScrollEnd(EndState().get());
850 } 854 }
851 855
852 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { 856 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) {
853 host_impl_->SetViewportSize(gfx::Size(50, 50)); 857 host_impl_->SetViewportSize(gfx::Size(50, 50));
854 858
855 // Create a normal scrollable root layer 859 // Create a normal scrollable root layer
856 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); 860 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 29 matching lines...) Expand all
886 scrollable_child_2->SetHaveScrollEventHandlers(true); 890 scrollable_child_2->SetHaveScrollEventHandlers(true);
887 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2)); 891 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2));
888 root_child->AddChild(std::move(scrollable_child_clip_2)); 892 root_child->AddChild(std::move(scrollable_child_clip_2));
889 RebuildPropertyTrees(); 893 RebuildPropertyTrees();
890 } 894 }
891 895
892 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 896 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
893 BeginState(gfx::Point(10, 10)).get(), InputHandler::GESTURE); 897 BeginState(gfx::Point(10, 10)).get(), InputHandler::GESTURE);
894 // Scroll-blocks-on on a layer affects scrolls that hit that layer. 898 // Scroll-blocks-on on a layer affects scrolls that hit that layer.
895 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 899 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
896 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 900 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
897 status.main_thread_scrolling_reasons); 901 status.main_thread_scrolling_reasons);
898 host_impl_->ScrollEnd(EndState().get()); 902 host_impl_->ScrollEnd(EndState().get());
899 903
900 child1->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); 904 child1->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT);
901 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 905 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
902 InputHandler::GESTURE); 906 InputHandler::GESTURE);
903 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 907 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
904 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 908 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
909 status.main_thread_scrolling_reasons);
905 910
906 // But not those that hit only other layers. 911 // But not those that hit only other layers.
907 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 912 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
908 InputHandler::GESTURE); 913 InputHandler::GESTURE);
909 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 914 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
910 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 915 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
911 status.main_thread_scrolling_reasons); 916 status.main_thread_scrolling_reasons);
912 host_impl_->ScrollEnd(EndState().get()); 917 host_impl_->ScrollEnd(EndState().get());
913 918
914 // It's the union of bits set across the scroll ancestor chain that matters. 919 // It's the union of bits set across the scroll ancestor chain that matters.
915 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 920 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
916 InputHandler::GESTURE); 921 InputHandler::GESTURE);
917 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 922 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
918 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 923 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
919 status.main_thread_scrolling_reasons); 924 status.main_thread_scrolling_reasons);
920 925
921 host_impl_->ScrollEnd(EndState().get()); 926 host_impl_->ScrollEnd(EndState().get());
922 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 927 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
923 InputHandler::WHEEL); 928 InputHandler::WHEEL);
924 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 929 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
925 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 930 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
926 status.main_thread_scrolling_reasons); 931 status.main_thread_scrolling_reasons);
927 932
928 host_impl_->ScrollEnd(EndState().get()); 933 host_impl_->ScrollEnd(EndState().get());
929 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT); 934 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT);
930 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 935 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
931 InputHandler::GESTURE); 936 InputHandler::GESTURE);
932 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 937 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
933 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 938 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
934 status.main_thread_scrolling_reasons); 939 status.main_thread_scrolling_reasons);
935 940
936 host_impl_->ScrollEnd(EndState().get()); 941 host_impl_->ScrollEnd(EndState().get());
937 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 942 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
938 InputHandler::WHEEL); 943 InputHandler::WHEEL);
939 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 944 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
940 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 945 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
946 status.main_thread_scrolling_reasons);
941 947
942 child2->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT); 948 child2->SetScrollBlocksOn(SCROLL_BLOCKS_ON_SCROLL_EVENT);
943 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 949 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
944 InputHandler::WHEEL); 950 InputHandler::WHEEL);
945 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 951 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
946 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 952 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
953 status.main_thread_scrolling_reasons);
947 954
948 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(), 955 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 25)).get(),
949 InputHandler::GESTURE); 956 InputHandler::GESTURE);
950 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 957 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
951 EXPECT_EQ(InputHandler::EVENT_HANDLERS, status.main_thread_scrolling_reasons); 958 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers,
959 status.main_thread_scrolling_reasons);
952 } 960 }
953 961
954 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { 962 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) {
955 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 963 SetupScrollAndContentsLayers(gfx::Size(100, 100));
956 host_impl_->SetViewportSize(gfx::Size(50, 50)); 964 host_impl_->SetViewportSize(gfx::Size(50, 50));
957 DrawFrame(); 965 DrawFrame();
958 966
959 // Ignore the fling since no layer is being scrolled 967 // Ignore the fling since no layer is being scrolled
960 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin(); 968 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin();
961 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 969 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
962 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 970 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
963 status.main_thread_scrolling_reasons); 971 status.main_thread_scrolling_reasons);
964 972
965 // Start scrolling a layer 973 // Start scrolling a layer
966 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 974 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
967 InputHandler::GESTURE); 975 InputHandler::GESTURE);
968 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 976 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
969 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 977 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
970 status.main_thread_scrolling_reasons); 978 status.main_thread_scrolling_reasons);
971 979
972 // Now the fling should go ahead since we've started scrolling a layer 980 // Now the fling should go ahead since we've started scrolling a layer
973 status = host_impl_->FlingScrollBegin(); 981 status = host_impl_->FlingScrollBegin();
974 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 982 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
975 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 983 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
976 status.main_thread_scrolling_reasons); 984 status.main_thread_scrolling_reasons);
977 } 985 }
978 986
979 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchpad) { 987 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchpad) {
980 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 988 SetupScrollAndContentsLayers(gfx::Size(100, 100));
981 host_impl_->SetViewportSize(gfx::Size(50, 50)); 989 host_impl_->SetViewportSize(gfx::Size(50, 50));
982 DrawFrame(); 990 DrawFrame();
983 991
984 // Ignore the fling since no layer is being scrolled 992 // Ignore the fling since no layer is being scrolled
985 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin(); 993 InputHandler::ScrollStatus status = host_impl_->FlingScrollBegin();
986 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 994 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
987 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 995 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
988 status.main_thread_scrolling_reasons); 996 status.main_thread_scrolling_reasons);
989 997
990 // Start scrolling a layer 998 // Start scrolling a layer
991 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 999 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
992 InputHandler::WHEEL); 1000 InputHandler::WHEEL);
993 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1001 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
994 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 1002 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
995 status.main_thread_scrolling_reasons); 1003 status.main_thread_scrolling_reasons);
996 1004
997 // Now the fling should go ahead since we've started scrolling a layer 1005 // Now the fling should go ahead since we've started scrolling a layer
998 status = host_impl_->FlingScrollBegin(); 1006 status = host_impl_->FlingScrollBegin();
999 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1007 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1000 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 1008 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1001 status.main_thread_scrolling_reasons); 1009 status.main_thread_scrolling_reasons);
1002 } 1010 }
1003 1011
1004 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) { 1012 TEST_F(LayerTreeHostImplTest, NoFlingWhenScrollingOnMain) {
1005 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 1013 SetupScrollAndContentsLayers(gfx::Size(100, 100));
1006 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1014 host_impl_->SetViewportSize(gfx::Size(50, 50));
1007 DrawFrame(); 1015 DrawFrame();
1008 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1016 LayerImpl* root = host_impl_->active_tree()->root_layer();
1009 1017
1010 root->set_main_thread_scrolling_reasons( 1018 root->set_main_thread_scrolling_reasons(
1011 InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS); 1019 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
1012 1020
1013 // Start scrolling a layer 1021 // Start scrolling a layer
1014 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1022 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
1015 BeginState(gfx::Point()).get(), InputHandler::GESTURE); 1023 BeginState(gfx::Point()).get(), InputHandler::GESTURE);
1016 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1024 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1017 EXPECT_EQ(InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS, 1025 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
1018 status.main_thread_scrolling_reasons); 1026 status.main_thread_scrolling_reasons);
1019 1027
1020 // The fling should be ignored since there's no layer being scrolled impl-side 1028 // The fling should be ignored since there's no layer being scrolled impl-side
1021 status = host_impl_->FlingScrollBegin(); 1029 status = host_impl_->FlingScrollBegin();
1022 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 1030 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
1023 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 1031 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
1024 status.main_thread_scrolling_reasons); 1032 status.main_thread_scrolling_reasons);
1025 } 1033 }
1026 1034
1027 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) { 1035 TEST_F(LayerTreeHostImplTest, ShouldScrollOnMainThread) {
1028 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 1036 SetupScrollAndContentsLayers(gfx::Size(100, 100));
1029 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1037 host_impl_->SetViewportSize(gfx::Size(50, 50));
1030 DrawFrame(); 1038 DrawFrame();
1031 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1039 LayerImpl* root = host_impl_->active_tree()->root_layer();
1032 1040
1033 root->set_main_thread_scrolling_reasons( 1041 root->set_main_thread_scrolling_reasons(
1034 InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS); 1042 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
1035 1043
1036 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1044 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
1037 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 1045 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
1038 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1046 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1039 EXPECT_EQ(InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS, 1047 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
1040 status.main_thread_scrolling_reasons); 1048 status.main_thread_scrolling_reasons);
1041 1049
1042 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 1050 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
1043 InputHandler::GESTURE); 1051 InputHandler::GESTURE);
1044 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1052 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1045 EXPECT_EQ(InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS, 1053 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
1046 status.main_thread_scrolling_reasons); 1054 status.main_thread_scrolling_reasons);
1047 } 1055 }
1048 1056
1049 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) { 1057 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionBasic) {
1050 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1058 SetupScrollAndContentsLayers(gfx::Size(200, 200));
1051 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1059 host_impl_->SetViewportSize(gfx::Size(100, 100));
1052 1060
1053 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1061 LayerImpl* root = host_impl_->active_tree()->root_layer();
1054 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 1062 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
1055 1063
1056 DrawFrame(); 1064 DrawFrame();
1057 1065
1058 // All scroll types inside the non-fast scrollable region should fail. 1066 // All scroll types inside the non-fast scrollable region should fail.
1059 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1067 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
1060 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL); 1068 BeginState(gfx::Point(25, 25)).get(), InputHandler::WHEEL);
1061 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1069 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1062 EXPECT_EQ(InputHandler::NON_FAST_SCROLLABLE_REGION, 1070 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion,
1063 status.main_thread_scrolling_reasons); 1071 status.main_thread_scrolling_reasons);
1064 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), 1072 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
1065 InputHandler::WHEEL)); 1073 InputHandler::WHEEL));
1066 1074
1067 status = host_impl_->ScrollBegin(BeginState(gfx::Point(25, 25)).get(), 1075 status = host_impl_->ScrollBegin(BeginState(gfx::Point(25, 25)).get(),
1068 InputHandler::GESTURE); 1076 InputHandler::GESTURE);
1069 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1077 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1070 EXPECT_EQ(InputHandler::NON_FAST_SCROLLABLE_REGION, 1078 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion,
1071 status.main_thread_scrolling_reasons); 1079 status.main_thread_scrolling_reasons);
1072 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), 1080 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
1073 InputHandler::GESTURE)); 1081 InputHandler::GESTURE));
1074 1082
1075 // All scroll types outside this region should succeed. 1083 // All scroll types outside this region should succeed.
1076 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), 1084 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(),
1077 InputHandler::WHEEL); 1085 InputHandler::WHEEL);
1078 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1086 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1079 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 1087 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1080 status.main_thread_scrolling_reasons); 1088 status.main_thread_scrolling_reasons);
1081 1089
1082 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), 1090 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
1083 InputHandler::GESTURE)); 1091 InputHandler::GESTURE));
1084 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 1092 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
1085 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25), 1093 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(25, 25),
1086 InputHandler::GESTURE)); 1094 InputHandler::GESTURE));
1087 host_impl_->ScrollEnd(EndState().get()); 1095 host_impl_->ScrollEnd(EndState().get());
1088 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), 1096 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
1089 InputHandler::GESTURE)); 1097 InputHandler::GESTURE));
1090 1098
1091 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(), 1099 status = host_impl_->ScrollBegin(BeginState(gfx::Point(75, 75)).get(),
1092 InputHandler::GESTURE); 1100 InputHandler::GESTURE);
1093 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1101 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1094 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 1102 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1095 status.main_thread_scrolling_reasons); 1103 status.main_thread_scrolling_reasons);
1096 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), 1104 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
1097 InputHandler::GESTURE)); 1105 InputHandler::GESTURE));
1098 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get()); 1106 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 10)).get());
1099 host_impl_->ScrollEnd(EndState().get()); 1107 host_impl_->ScrollEnd(EndState().get());
1100 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75), 1108 EXPECT_FALSE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(75, 75),
1101 InputHandler::GESTURE)); 1109 InputHandler::GESTURE));
1102 } 1110 }
1103 1111
1104 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) { 1112 TEST_F(LayerTreeHostImplTest, NonFastScrollableRegionWithOffset) {
1105 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1113 SetupScrollAndContentsLayers(gfx::Size(200, 200));
1106 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1114 host_impl_->SetViewportSize(gfx::Size(100, 100));
1107 1115
1108 LayerImpl* root = host_impl_->active_tree()->root_layer(); 1116 LayerImpl* root = host_impl_->active_tree()->root_layer();
1109 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 1117 root->SetNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
1110 root->SetPosition(gfx::PointF(-25.f, 0.f)); 1118 root->SetPosition(gfx::PointF(-25.f, 0.f));
1111 root->SetDrawsContent(true); 1119 root->SetDrawsContent(true);
1112 1120
1113 DrawFrame(); 1121 DrawFrame();
1114 1122
1115 // This point would fall into the non-fast scrollable region except that we've 1123 // This point would fall into the non-fast scrollable region except that we've
1116 // moved the layer down by 25 pixels. 1124 // moved the layer down by 25 pixels.
1117 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1125 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
1118 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL); 1126 BeginState(gfx::Point(40, 10)).get(), InputHandler::WHEEL);
1119 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1127 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1120 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 1128 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1121 status.main_thread_scrolling_reasons); 1129 status.main_thread_scrolling_reasons);
1122 1130
1123 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10), 1131 EXPECT_TRUE(host_impl_->IsCurrentlyScrollingLayerAt(gfx::Point(40, 10),
1124 InputHandler::WHEEL)); 1132 InputHandler::WHEEL));
1125 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 1)).get()); 1133 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2d(0, 1)).get());
1126 host_impl_->ScrollEnd(EndState().get()); 1134 host_impl_->ScrollEnd(EndState().get());
1127 1135
1128 // This point is still inside the non-fast region. 1136 // This point is still inside the non-fast region.
1129 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 1137 status = host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
1130 InputHandler::WHEEL); 1138 InputHandler::WHEEL);
1131 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 1139 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
1132 EXPECT_EQ(InputHandler::NON_FAST_SCROLLABLE_REGION, 1140 EXPECT_EQ(MainThreadScrollingReason::kNonFastScrollableRegion,
1133 status.main_thread_scrolling_reasons); 1141 status.main_thread_scrolling_reasons);
1134 } 1142 }
1135 1143
1136 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) { 1144 TEST_F(LayerTreeHostImplTest, ScrollHandlerNotPresent) {
1137 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1145 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200));
1138 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers()); 1146 EXPECT_FALSE(scroll_layer->have_scroll_event_handlers());
1139 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1147 host_impl_->SetViewportSize(gfx::Size(50, 50));
1140 DrawFrame(); 1148 DrawFrame();
1141 1149
1142 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler()); 1150 EXPECT_FALSE(host_impl_->scroll_affects_scroll_handler());
(...skipping 20 matching lines...) Expand all
1163 1171
1164 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) { 1172 TEST_F(LayerTreeHostImplTest, ScrollByReturnsCorrectValue) {
1165 SetupScrollAndContentsLayers(gfx::Size(200, 200)); 1173 SetupScrollAndContentsLayers(gfx::Size(200, 200));
1166 host_impl_->SetViewportSize(gfx::Size(100, 100)); 1174 host_impl_->SetViewportSize(gfx::Size(100, 100));
1167 1175
1168 DrawFrame(); 1176 DrawFrame();
1169 1177
1170 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 1178 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
1171 BeginState(gfx::Point()).get(), InputHandler::GESTURE); 1179 BeginState(gfx::Point()).get(), InputHandler::GESTURE);
1172 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); 1180 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread);
1173 EXPECT_EQ(InputHandler::NOT_SCROLLING_ON_MAIN, 1181 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
1174 status.main_thread_scrolling_reasons); 1182 status.main_thread_scrolling_reasons);
1175 1183
1176 // Trying to scroll to the left/top will not succeed. 1184 // Trying to scroll to the left/top will not succeed.
1177 EXPECT_FALSE( 1185 EXPECT_FALSE(
1178 host_impl_->ScrollBy( 1186 host_impl_->ScrollBy(
1179 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get()) 1187 UpdateState(gfx::Point(), gfx::Vector2d(-10, 0)).get())
1180 .did_scroll); 1188 .did_scroll);
1181 EXPECT_FALSE( 1189 EXPECT_FALSE(
1182 host_impl_->ScrollBy( 1190 host_impl_->ScrollBy(
1183 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get()) 1191 UpdateState(gfx::Point(), gfx::Vector2d(0, -10)).get())
(...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after
3769 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 3777 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
3770 root->SetScrollClipLayer(Layer::INVALID_ID); 3778 root->SetScrollClipLayer(Layer::INVALID_ID);
3771 root->SetForceRenderSurface(true); 3779 root->SetForceRenderSurface(true);
3772 host_impl_->active_tree()->SetRootLayer(std::move(root)); 3780 host_impl_->active_tree()->SetRootLayer(std::move(root));
3773 DrawFrame(); 3781 DrawFrame();
3774 3782
3775 // Scroll event is ignored because layer is not scrollable. 3783 // Scroll event is ignored because layer is not scrollable.
3776 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 3784 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
3777 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 3785 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
3778 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 3786 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
3779 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 3787 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
3780 status.main_thread_scrolling_reasons); 3788 status.main_thread_scrolling_reasons);
3781 EXPECT_FALSE(did_request_redraw_); 3789 EXPECT_FALSE(did_request_redraw_);
3782 EXPECT_FALSE(did_request_commit_); 3790 EXPECT_FALSE(did_request_commit_);
3783 } 3791 }
3784 3792
3785 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) { 3793 TEST_F(LayerTreeHostImplTest, ClampingAfterActivation) {
3786 host_impl_->CreatePendingTree(); 3794 host_impl_->CreatePendingTree();
3787 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 3795 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
3788 CreateScrollAndContentsLayers(host_impl_->pending_tree(), 3796 CreateScrollAndContentsLayers(host_impl_->pending_tree(),
3789 gfx::Size(100, 100)); 3797 gfx::Size(100, 100));
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
4621 root->SetForceRenderSurface(true); 4629 root->SetForceRenderSurface(true);
4622 host_impl_->active_tree()->SetRootLayer(std::move(root)); 4630 host_impl_->active_tree()->SetRootLayer(std::move(root));
4623 host_impl_->SetViewportSize(surface_size); 4631 host_impl_->SetViewportSize(surface_size);
4624 DrawFrame(); 4632 DrawFrame();
4625 4633
4626 // Scroll event is ignored because the input coordinate is outside the layer 4634 // Scroll event is ignored because the input coordinate is outside the layer
4627 // boundaries. 4635 // boundaries.
4628 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 4636 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
4629 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL); 4637 BeginState(gfx::Point(15, 5)).get(), InputHandler::WHEEL);
4630 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 4638 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
4631 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 4639 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
4632 status.main_thread_scrolling_reasons); 4640 status.main_thread_scrolling_reasons);
4633 4641
4634 EXPECT_FALSE(did_request_redraw_); 4642 EXPECT_FALSE(did_request_redraw_);
4635 EXPECT_FALSE(did_request_commit_); 4643 EXPECT_FALSE(did_request_commit_);
4636 } 4644 }
4637 4645
4638 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) { 4646 TEST_F(LayerTreeHostImplTest, ScrollMissesBackfacingChild) {
4639 gfx::Size surface_size(10, 10); 4647 gfx::Size surface_size(10, 10);
4640 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1); 4648 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl_->active_tree(), 1);
4641 root->SetForceRenderSurface(true); 4649 root->SetForceRenderSurface(true);
4642 scoped_ptr<LayerImpl> child = 4650 scoped_ptr<LayerImpl> child =
4643 CreateScrollableLayer(2, surface_size, root.get()); 4651 CreateScrollableLayer(2, surface_size, root.get());
4644 host_impl_->SetViewportSize(surface_size); 4652 host_impl_->SetViewportSize(surface_size);
4645 4653
4646 gfx::Transform matrix; 4654 gfx::Transform matrix;
4647 matrix.RotateAboutXAxis(180.0); 4655 matrix.RotateAboutXAxis(180.0);
4648 child->SetTransform(matrix); 4656 child->SetTransform(matrix);
4649 child->SetDoubleSided(false); 4657 child->SetDoubleSided(false);
4650 4658
4651 root->AddChild(std::move(child)); 4659 root->AddChild(std::move(child));
4652 host_impl_->active_tree()->SetRootLayer(std::move(root)); 4660 host_impl_->active_tree()->SetRootLayer(std::move(root));
4653 DrawFrame(); 4661 DrawFrame();
4654 4662
4655 // Scroll event is ignored because the scrollable layer is not facing the 4663 // Scroll event is ignored because the scrollable layer is not facing the
4656 // viewer and there is nothing scrollable behind it. 4664 // viewer and there is nothing scrollable behind it.
4657 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 4665 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
4658 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); 4666 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL);
4659 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); 4667 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread);
4660 EXPECT_EQ(InputHandler::NO_SCROLLING_LAYER, 4668 EXPECT_EQ(MainThreadScrollingReason::kNoScrollingLayer,
4661 status.main_thread_scrolling_reasons); 4669 status.main_thread_scrolling_reasons);
4662 4670
4663 EXPECT_FALSE(did_request_redraw_); 4671 EXPECT_FALSE(did_request_redraw_);
4664 EXPECT_FALSE(did_request_commit_); 4672 EXPECT_FALSE(did_request_commit_);
4665 } 4673 }
4666 4674
4667 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) { 4675 TEST_F(LayerTreeHostImplTest, ScrollBlockedByContentLayer) {
4668 gfx::Size surface_size(10, 10); 4676 gfx::Size surface_size(10, 10);
4669 scoped_ptr<LayerImpl> clip_layer = 4677 scoped_ptr<LayerImpl> clip_layer =
4670 LayerImpl::Create(host_impl_->active_tree(), 3); 4678 LayerImpl::Create(host_impl_->active_tree(), 3);
4671 scoped_ptr<LayerImpl> content_layer = 4679 scoped_ptr<LayerImpl> content_layer =
4672 CreateScrollableLayer(1, surface_size, clip_layer.get()); 4680 CreateScrollableLayer(1, surface_size, clip_layer.get());
4673 content_layer->set_main_thread_scrolling_reasons( 4681 content_layer->set_main_thread_scrolling_reasons(
4674 InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS); 4682 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
4675 content_layer->SetScrollClipLayer(Layer::INVALID_ID); 4683 content_layer->SetScrollClipLayer(Layer::INVALID_ID);
4676 4684
4677 // Note: we can use the same clip layer for both since both calls to 4685 // Note: we can use the same clip layer for both since both calls to
4678 // CreateScrollableLayer() use the same surface size. 4686 // CreateScrollableLayer() use the same surface size.
4679 scoped_ptr<LayerImpl> scroll_layer = 4687 scoped_ptr<LayerImpl> scroll_layer =
4680 CreateScrollableLayer(2, surface_size, clip_layer.get()); 4688 CreateScrollableLayer(2, surface_size, clip_layer.get());
4681 scroll_layer->AddChild(std::move(content_layer)); 4689 scroll_layer->AddChild(std::move(content_layer));
4682 clip_layer->AddChild(std::move(scroll_layer)); 4690 clip_layer->AddChild(std::move(scroll_layer));
4683 clip_layer->SetForceRenderSurface(true); 4691 clip_layer->SetForceRenderSurface(true);
4684 4692
4685 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer)); 4693 host_impl_->active_tree()->SetRootLayer(std::move(clip_layer));
4686 host_impl_->SetViewportSize(surface_size); 4694 host_impl_->SetViewportSize(surface_size);
4687 DrawFrame(); 4695 DrawFrame();
4688 4696
4689 // Scrolling fails because the content layer is asking to be scrolled on the 4697 // Scrolling fails because the content layer is asking to be scrolled on the
4690 // main thread. 4698 // main thread.
4691 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 4699 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
4692 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL); 4700 BeginState(gfx::Point(5, 5)).get(), InputHandler::WHEEL);
4693 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); 4701 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread);
4694 EXPECT_EQ(InputHandler::HAS_BACKGROUND_ATTACHMENT_FIXED_OBJECTS, 4702 EXPECT_EQ(MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
4695 status.main_thread_scrolling_reasons); 4703 status.main_thread_scrolling_reasons);
4696 } 4704 }
4697 4705
4698 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { 4706 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) {
4699 gfx::Size viewport_size(20, 20); 4707 gfx::Size viewport_size(20, 20);
4700 float page_scale = 2.f; 4708 float page_scale = 2.f;
4701 4709
4702 SetupScrollAndContentsLayers(viewport_size); 4710 SetupScrollAndContentsLayers(viewport_size);
4703 4711
4704 // Setup the layers so that the outer viewport is scrollable. 4712 // Setup the layers so that the outer viewport is scrollable.
(...skipping 3087 matching lines...) Expand 10 before | Expand all | Expand 10 after
7792 occluder_layer->SetPosition(gfx::PointF()); 7800 occluder_layer->SetPosition(gfx::PointF());
7793 7801
7794 // The parent of the occluder is *above* the scroller. 7802 // The parent of the occluder is *above* the scroller.
7795 page_scale_layer->AddChild(std::move(occluder_layer)); 7803 page_scale_layer->AddChild(std::move(occluder_layer));
7796 7804
7797 DrawFrame(); 7805 DrawFrame();
7798 7806
7799 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 7807 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
7800 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 7808 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
7801 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); 7809 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread);
7802 EXPECT_EQ(InputHandler::FAILED_HIT_TEST, 7810 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest,
7803 status.main_thread_scrolling_reasons); 7811 status.main_thread_scrolling_reasons);
7804 } 7812 }
7805 7813
7806 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) { 7814 TEST_F(LayerTreeHostImplTest, ScrollUnknownScrollAncestorMismatch) {
7807 // If we ray cast a scroller this is on the first layer's ancestor chain, but 7815 // If we ray cast a scroller this is on the first layer's ancestor chain, but
7808 // is not the first scroller we encounter when walking up from the layer, we 7816 // is not the first scroller we encounter when walking up from the layer, we
7809 // should also return SCROLL_UNKNOWN. 7817 // should also return SCROLL_UNKNOWN.
7810 gfx::Size content_size(100, 100); 7818 gfx::Size content_size(100, 100);
7811 SetupScrollAndContentsLayers(content_size); 7819 SetupScrollAndContentsLayers(content_size);
7812 7820
(...skipping 20 matching lines...) Expand all
7833 child_scroll->SetPosition(gfx::PointF(10.f, 10.f)); 7841 child_scroll->SetPosition(gfx::PointF(10.f, 10.f));
7834 7842
7835 child_scroll->AddChild(std::move(occluder_layer)); 7843 child_scroll->AddChild(std::move(occluder_layer));
7836 scroll_layer->AddChild(std::move(child_scroll)); 7844 scroll_layer->AddChild(std::move(child_scroll));
7837 7845
7838 DrawFrame(); 7846 DrawFrame();
7839 7847
7840 InputHandler::ScrollStatus status = host_impl_->ScrollBegin( 7848 InputHandler::ScrollStatus status = host_impl_->ScrollBegin(
7841 BeginState(gfx::Point()).get(), InputHandler::WHEEL); 7849 BeginState(gfx::Point()).get(), InputHandler::WHEEL);
7842 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread); 7850 EXPECT_EQ(InputHandler::SCROLL_UNKNOWN, status.thread);
7843 EXPECT_EQ(InputHandler::FAILED_HIT_TEST, 7851 EXPECT_EQ(MainThreadScrollingReason::kFailedHitTest,
7844 status.main_thread_scrolling_reasons); 7852 status.main_thread_scrolling_reasons);
7845 } 7853 }
7846 7854
7847 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) { 7855 TEST_F(LayerTreeHostImplTest, NotScrollInvisibleScroller) {
7848 gfx::Size content_size(100, 100); 7856 gfx::Size content_size(100, 100);
7849 SetupScrollAndContentsLayers(content_size); 7857 SetupScrollAndContentsLayers(content_size);
7850 7858
7851 LayerImpl* root = host_impl_->active_tree()->LayerById(1); 7859 LayerImpl* root = host_impl_->active_tree()->LayerById(1);
7852 7860
7853 int scroll_layer_id = 2; 7861 int scroll_layer_id = 2;
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
10016 // There should not be any jitter measured till we hit the fixed point hits 10024 // There should not be any jitter measured till we hit the fixed point hits
10017 // threshold. 10025 // threshold.
10018 float expected_jitter = 10026 float expected_jitter =
10019 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10027 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10020 EXPECT_EQ(jitter, expected_jitter); 10028 EXPECT_EQ(jitter, expected_jitter);
10021 } 10029 }
10022 } 10030 }
10023 10031
10024 } // namespace 10032 } // namespace
10025 } // namespace cc 10033 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698