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 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 host_impl_->ProcessScrollDeltas(); | 758 host_impl_->ProcessScrollDeltas(); |
759 EXPECT_TRUE( | 759 EXPECT_TRUE( |
760 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); | 760 ScrollInfoContains(*scroll_info, scroll_layer->id(), scroll_delta)); |
761 } | 761 } |
762 | 762 |
763 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { | 763 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
764 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 764 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
765 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 765 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
766 DrawFrame(); | 766 DrawFrame(); |
767 | 767 |
768 // Wheel handlers determine whether mouse events block scroll. | 768 // With registered event handlers, wheel scrolls don't necessarily |
| 769 // have to go to the main thread. |
769 host_impl_->active_tree()->set_event_listener_properties( | 770 host_impl_->active_tree()->set_event_listener_properties( |
770 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); | 771 EventListenerClass::kMouseWheel, EventListenerProperties::kBlocking); |
771 EXPECT_EQ( | |
772 EventListenerProperties::kBlocking, | |
773 host_impl_->GetEventListenerProperties(EventListenerClass::kMouseWheel)); | |
774 | |
775 // But they don't influence the actual handling of the scroll gestures. | |
776 InputHandler::ScrollStatus status = | 772 InputHandler::ScrollStatus status = |
777 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 773 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
778 InputHandler::WHEEL); | 774 InputHandler::WHEEL); |
| 775 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 776 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, |
| 777 status.main_thread_scrolling_reasons); |
| 778 |
| 779 host_impl_->active_tree()->set_event_listener_properties( |
| 780 EventListenerClass::kMouseWheel, |
| 781 EventListenerProperties::kBlockingAndPassive); |
| 782 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 783 InputHandler::WHEEL); |
| 784 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, status.thread); |
| 785 EXPECT_EQ(MainThreadScrollingReason::kEventHandlers, |
| 786 status.main_thread_scrolling_reasons); |
| 787 |
| 788 // But gesture scrolls can still be handled. |
| 789 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 790 InputHandler::TOUCHSCREEN); |
779 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); | 791 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
780 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 792 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 793 status.main_thread_scrolling_reasons); |
| 794 host_impl_->ScrollEnd(EndState().get()); |
| 795 |
| 796 // And if the handlers go away, wheel scrolls can again be processed |
| 797 // on impl. |
| 798 host_impl_->active_tree()->set_event_listener_properties( |
| 799 EventListenerClass::kMouseWheel, EventListenerProperties::kNone); |
| 800 status = host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 801 InputHandler::WHEEL); |
| 802 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, status.thread); |
| 803 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
781 status.main_thread_scrolling_reasons); | 804 status.main_thread_scrolling_reasons); |
782 host_impl_->ScrollEnd(EndState().get()); | 805 host_impl_->ScrollEnd(EndState().get()); |
783 } | 806 } |
784 | 807 |
785 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { | 808 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
786 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 809 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
787 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 810 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
788 DrawFrame(); | 811 DrawFrame(); |
789 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 812 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
790 | 813 |
(...skipping 10023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10814 | 10837 |
10815 // Re-initialize with a software output surface. | 10838 // Re-initialize with a software output surface. |
10816 output_surface_ = FakeOutputSurface::CreateSoftware( | 10839 output_surface_ = FakeOutputSurface::CreateSoftware( |
10817 base::WrapUnique(new SoftwareOutputDevice)); | 10840 base::WrapUnique(new SoftwareOutputDevice)); |
10818 host_impl_->InitializeRenderer(output_surface_.get()); | 10841 host_impl_->InitializeRenderer(output_surface_.get()); |
10819 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10842 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
10820 } | 10843 } |
10821 | 10844 |
10822 } // namespace | 10845 } // namespace |
10823 } // namespace cc | 10846 } // namespace cc |
OLD | NEW |