Chromium Code Reviews| 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 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2730 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 2730 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2731 host_impl_->active_tree()->DidBecomeActive(); | 2731 host_impl_->active_tree()->DidBecomeActive(); |
| 2732 DrawFrame(); | 2732 DrawFrame(); |
| 2733 } | 2733 } |
| 2734 | 2734 |
| 2735 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2735 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 2736 LayerTreeSettings settings = DefaultSettings(); | 2736 LayerTreeSettings settings = DefaultSettings(); |
| 2737 settings.scrollbar_animator = animator; | 2737 settings.scrollbar_animator = animator; |
| 2738 settings.scrollbar_fade_in_delay = base::TimeDelta::FromMilliseconds(20); | 2738 settings.scrollbar_fade_in_delay = base::TimeDelta::FromMilliseconds(20); |
| 2739 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); | 2739 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); |
| 2740 settings.scrollbar_fade_out_resize_delay = | |
| 2741 base::TimeDelta::FromMilliseconds(20); | |
| 2740 settings.scrollbar_fade_out_duration = | 2742 settings.scrollbar_fade_out_duration = |
| 2741 base::TimeDelta::FromMilliseconds(20); | 2743 base::TimeDelta::FromMilliseconds(20); |
| 2742 | 2744 |
| 2743 // If no animator is set, scrollbar won't show and no animation is expected. | 2745 // If no animator is set, scrollbar won't show and no animation is expected. |
| 2744 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; | 2746 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; |
| 2745 | 2747 |
| 2746 SetupLayers(settings); | 2748 SetupLayers(settings); |
| 2747 | 2749 |
| 2748 base::TimeTicks fake_now = base::TimeTicks::Now(); | 2750 base::TimeTicks fake_now = base::TimeTicks::Now(); |
| 2749 | 2751 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2763 | 2765 |
| 2764 // If no scroll happened during a scroll gesture, it should have no effect. | 2766 // If no scroll happened during a scroll gesture, it should have no effect. |
| 2765 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 2767 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 2766 InputHandler::WHEEL); | 2768 InputHandler::WHEEL); |
| 2767 host_impl_->ScrollEnd(EndState().get()); | 2769 host_impl_->ScrollEnd(EndState().get()); |
| 2768 EXPECT_FALSE(did_request_next_frame_); | 2770 EXPECT_FALSE(did_request_next_frame_); |
| 2769 EXPECT_FALSE(did_request_redraw_); | 2771 EXPECT_FALSE(did_request_redraw_); |
| 2770 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2772 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2771 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2773 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2772 | 2774 |
| 2775 // If no scroll happened during a scroll gesture, it appears scrollbars and | |
|
bokan
2017/02/28 14:16:07
nit: "appears" -> "fades in"
| |
| 2776 // schedules a fade out delay. | |
| 2777 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | |
| 2778 InputHandler::WHEEL); | |
| 2779 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(0, 0)).get()); | |
| 2780 host_impl_->ScrollEnd(EndState().get()); | |
| 2781 EXPECT_FALSE(did_request_next_frame_); | |
| 2782 EXPECT_FALSE(did_request_redraw_); | |
| 2783 if (expecting_animations) { | |
| 2784 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | |
| 2785 requested_animation_delay_); | |
| 2786 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | |
| 2787 requested_animation_delay_ = base::TimeDelta(); | |
| 2788 animation_task_ = base::Closure(); | |
| 2789 } else { | |
| 2790 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | |
| 2791 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | |
| 2792 } | |
| 2793 | |
| 2773 // Before the scrollbar animation exists, we should not get redraws. | 2794 // Before the scrollbar animation exists, we should not get redraws. |
| 2774 BeginFrameArgs begin_frame_args = | 2795 BeginFrameArgs begin_frame_args = |
| 2775 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); | 2796 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 2, fake_now); |
| 2776 host_impl_->WillBeginImplFrame(begin_frame_args); | 2797 host_impl_->WillBeginImplFrame(begin_frame_args); |
| 2777 host_impl_->Animate(); | 2798 host_impl_->Animate(); |
| 2778 EXPECT_FALSE(did_request_next_frame_); | 2799 EXPECT_FALSE(did_request_next_frame_); |
| 2779 did_request_next_frame_ = false; | 2800 did_request_next_frame_ = false; |
| 2780 EXPECT_FALSE(did_request_redraw_); | 2801 EXPECT_FALSE(did_request_redraw_); |
| 2781 did_request_redraw_ = false; | 2802 did_request_redraw_ = false; |
| 2782 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2803 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2883 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); | 2904 host_impl_->ScrollBy(UpdateState(gfx::Point(), gfx::Vector2dF(5, 0)).get()); |
| 2884 EXPECT_FALSE(did_request_next_frame_); | 2905 EXPECT_FALSE(did_request_next_frame_); |
| 2885 EXPECT_TRUE(did_request_redraw_); | 2906 EXPECT_TRUE(did_request_redraw_); |
| 2886 did_request_redraw_ = false; | 2907 did_request_redraw_ = false; |
| 2887 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2908 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); |
| 2888 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2909 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| 2889 | 2910 |
| 2890 host_impl_->ScrollEnd(EndState().get()); | 2911 host_impl_->ScrollEnd(EndState().get()); |
| 2891 EXPECT_FALSE(did_request_next_frame_); | 2912 EXPECT_FALSE(did_request_next_frame_); |
| 2892 EXPECT_FALSE(did_request_redraw_); | 2913 EXPECT_FALSE(did_request_redraw_); |
| 2893 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | 2914 |
| 2894 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2915 if (expecting_animations) { |
| 2916 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | |
| 2917 requested_animation_delay_); | |
| 2918 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | |
| 2919 requested_animation_delay_ = base::TimeDelta(); | |
| 2920 animation_task_ = base::Closure(); | |
| 2921 } else { | |
| 2922 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); | |
| 2923 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | |
| 2924 } | |
| 2895 | 2925 |
| 2896 // Changing page scale triggers scrollbar animation. | 2926 // Changing page scale triggers scrollbar animation. |
| 2897 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); | 2927 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 4.f); |
| 2898 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); | 2928 host_impl_->active_tree()->SetPageScaleOnActiveTree(1.1f); |
| 2899 EXPECT_FALSE(did_request_next_frame_); | 2929 EXPECT_FALSE(did_request_next_frame_); |
| 2900 EXPECT_FALSE(did_request_redraw_); | 2930 EXPECT_FALSE(did_request_redraw_); |
| 2901 if (expecting_animations) { | 2931 if (expecting_animations) { |
| 2902 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), | 2932 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), |
| 2903 requested_animation_delay_); | 2933 requested_animation_delay_); |
| 2904 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2934 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3919 host_impl_->ActivateSyncTree(); | 3949 host_impl_->ActivateSyncTree(); |
| 3920 // Scrolloffsets on the active tree will be clamped after activation. | 3950 // Scrolloffsets on the active tree will be clamped after activation. |
| 3921 EXPECT_EQ(active_outer_layer->CurrentScrollOffset(), gfx::ScrollOffset(0, 0)); | 3951 EXPECT_EQ(active_outer_layer->CurrentScrollOffset(), gfx::ScrollOffset(0, 0)); |
| 3922 } | 3952 } |
| 3923 | 3953 |
| 3924 class LayerTreeHostImplBrowserControlsTest : public LayerTreeHostImplTest { | 3954 class LayerTreeHostImplBrowserControlsTest : public LayerTreeHostImplTest { |
| 3925 public: | 3955 public: |
| 3926 LayerTreeHostImplBrowserControlsTest() | 3956 LayerTreeHostImplBrowserControlsTest() |
| 3927 // Make the clip size the same as the layer (content) size so the layer is | 3957 // Make the clip size the same as the layer (content) size so the layer is |
| 3928 // non-scrollable. | 3958 // non-scrollable. |
| 3929 : layer_size_(10, 10), | 3959 : layer_size_(10, 10), clip_size_(layer_size_), top_controls_height_(50) { |
| 3930 clip_size_(layer_size_), | |
| 3931 top_controls_height_(50) { | |
| 3932 viewport_size_ = gfx::Size(clip_size_.width(), | 3960 viewport_size_ = gfx::Size(clip_size_.width(), |
| 3933 clip_size_.height() + top_controls_height_); | 3961 clip_size_.height() + top_controls_height_); |
| 3934 } | 3962 } |
| 3935 | 3963 |
| 3936 bool CreateHostImpl( | 3964 bool CreateHostImpl( |
| 3937 const LayerTreeSettings& settings, | 3965 const LayerTreeSettings& settings, |
| 3938 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override { | 3966 std::unique_ptr<CompositorFrameSink> compositor_frame_sink) override { |
| 3939 bool init = LayerTreeHostImplTest::CreateHostImpl( | 3967 bool init = LayerTreeHostImplTest::CreateHostImpl( |
| 3940 settings, std::move(compositor_frame_sink)); | 3968 settings, std::move(compositor_frame_sink)); |
| 3941 if (init) { | 3969 if (init) { |
| (...skipping 7916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11858 else | 11886 else |
| 11859 EXPECT_FALSE(tile->HasRasterTask()); | 11887 EXPECT_FALSE(tile->HasRasterTask()); |
| 11860 } | 11888 } |
| 11861 Region expected_invalidation( | 11889 Region expected_invalidation( |
| 11862 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 11890 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
| 11863 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 11891 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 11864 } | 11892 } |
| 11865 | 11893 |
| 11866 } // namespace | 11894 } // namespace |
| 11867 } // namespace cc | 11895 } // namespace cc |
| OLD | NEW |