OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 679 } |
680 | 680 |
681 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 681 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
682 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 682 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
683 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 683 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
684 DrawFrame(); | 684 DrawFrame(); |
685 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 685 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
686 | 686 |
687 // With registered event handlers, wheel scrolls don't necessarily | 687 // With registered event handlers, wheel scrolls don't necessarily |
688 // have to go to the main thread. | 688 // have to go to the main thread. |
689 root->SetHaveWheelEventHandlers(true); | 689 root->SetWheelEventProperties(EventListenerProperties::BLOCKING); |
690 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 690 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
691 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 691 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
692 host_impl_->ScrollEnd(); | 692 host_impl_->ScrollEnd(); |
693 | 693 |
694 // But typically the scroll-blocks-on mode will require them to. | 694 // But typically the scroll-blocks-on mode will require them to. |
695 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | | 695 root->SetScrollBlocksOn(SCROLL_BLOCKS_ON_WHEEL_EVENT | |
696 SCROLL_BLOCKS_ON_START_TOUCH); | 696 SCROLL_BLOCKS_ON_START_TOUCH); |
697 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, | 697 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, |
698 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 698 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
699 | 699 |
700 // But gesture scrolls can still be handled. | 700 // But gesture scrolls can still be handled. |
701 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 701 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
702 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); | 702 host_impl_->ScrollBegin(gfx::Point(), InputHandler::GESTURE)); |
703 host_impl_->ScrollEnd(); | 703 host_impl_->ScrollEnd(); |
704 | 704 |
705 // And if the handlers go away, wheel scrolls can again be processed | 705 // And if the handlers go away, wheel scrolls can again be processed |
706 // on impl (despite the scroll-blocks-on mode). | 706 // on impl (despite the scroll-blocks-on mode). |
707 root->SetHaveWheelEventHandlers(false); | 707 root->SetWheelEventProperties(EventListenerProperties::NONE); |
708 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 708 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
709 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); | 709 host_impl_->ScrollBegin(gfx::Point(), InputHandler::WHEEL)); |
710 host_impl_->ScrollEnd(); | 710 host_impl_->ScrollEnd(); |
711 } | 711 } |
712 | 712 |
713 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 713 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
714 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 714 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
715 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 715 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
716 DrawFrame(); | 716 DrawFrame(); |
717 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 717 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 | 797 |
798 // Create two child scrollable layers | 798 // Create two child scrollable layers |
799 LayerImpl* child1 = 0; | 799 LayerImpl* child1 = 0; |
800 { | 800 { |
801 scoped_ptr<LayerImpl> scrollable_child_clip_1 = | 801 scoped_ptr<LayerImpl> scrollable_child_clip_1 = |
802 LayerImpl::Create(host_impl_->active_tree(), 6); | 802 LayerImpl::Create(host_impl_->active_tree(), 6); |
803 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer( | 803 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer( |
804 7, gfx::Size(10, 10), scrollable_child_clip_1.get()); | 804 7, gfx::Size(10, 10), scrollable_child_clip_1.get()); |
805 child1 = scrollable_child_1.get(); | 805 child1 = scrollable_child_1.get(); |
806 scrollable_child_1->SetPosition(gfx::PointF(5.f, 5.f)); | 806 scrollable_child_1->SetPosition(gfx::PointF(5.f, 5.f)); |
807 scrollable_child_1->SetHaveWheelEventHandlers(true); | 807 scrollable_child_1->SetWheelEventProperties( |
| 808 EventListenerProperties::BLOCKING); |
808 scrollable_child_1->SetHaveScrollEventHandlers(true); | 809 scrollable_child_1->SetHaveScrollEventHandlers(true); |
809 scrollable_child_clip_1->AddChild(std::move(scrollable_child_1)); | 810 scrollable_child_clip_1->AddChild(std::move(scrollable_child_1)); |
810 root_child->AddChild(std::move(scrollable_child_clip_1)); | 811 root_child->AddChild(std::move(scrollable_child_clip_1)); |
811 RebuildPropertyTrees(); | 812 RebuildPropertyTrees(); |
812 } | 813 } |
813 | 814 |
814 LayerImpl* child2 = 0; | 815 LayerImpl* child2 = 0; |
815 { | 816 { |
816 scoped_ptr<LayerImpl> scrollable_child_clip_2 = | 817 scoped_ptr<LayerImpl> scrollable_child_clip_2 = |
817 LayerImpl::Create(host_impl_->active_tree(), 8); | 818 LayerImpl::Create(host_impl_->active_tree(), 8); |
818 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer( | 819 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer( |
819 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); | 820 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); |
820 child2 = scrollable_child_2.get(); | 821 child2 = scrollable_child_2.get(); |
821 scrollable_child_2->SetPosition(gfx::PointF(5.f, 20.f)); | 822 scrollable_child_2->SetPosition(gfx::PointF(5.f, 20.f)); |
822 scrollable_child_2->SetHaveWheelEventHandlers(true); | 823 scrollable_child_2->SetWheelEventProperties( |
| 824 EventListenerProperties::BLOCKING); |
823 scrollable_child_2->SetHaveScrollEventHandlers(true); | 825 scrollable_child_2->SetHaveScrollEventHandlers(true); |
824 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2)); | 826 scrollable_child_clip_2->AddChild(std::move(scrollable_child_2)); |
825 root_child->AddChild(std::move(scrollable_child_clip_2)); | 827 root_child->AddChild(std::move(scrollable_child_clip_2)); |
826 RebuildPropertyTrees(); | 828 RebuildPropertyTrees(); |
827 } | 829 } |
828 | 830 |
829 // Scroll-blocks-on on a layer affects scrolls that hit that layer. | 831 // Scroll-blocks-on on a layer affects scrolls that hit that layer. |
830 EXPECT_EQ(InputHandler::SCROLL_STARTED, | 832 EXPECT_EQ(InputHandler::SCROLL_STARTED, |
831 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); | 833 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::GESTURE)); |
832 host_impl_->ScrollEnd(); | 834 host_impl_->ScrollEnd(); |
(...skipping 8642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9475 // There should not be any jitter measured till we hit the fixed point hits | 9477 // There should not be any jitter measured till we hit the fixed point hits |
9476 // threshold. | 9478 // threshold. |
9477 float expected_jitter = | 9479 float expected_jitter = |
9478 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; | 9480 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; |
9479 EXPECT_EQ(jitter, expected_jitter); | 9481 EXPECT_EQ(jitter, expected_jitter); |
9480 } | 9482 } |
9481 } | 9483 } |
9482 | 9484 |
9483 } // namespace | 9485 } // namespace |
9484 } // namespace cc | 9486 } // namespace cc |
OLD | NEW |