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