| 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 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 scrollbar->test_properties()->opacity = 0.f; | 2796 scrollbar->test_properties()->opacity = 0.f; |
| 2797 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); | 2797 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); |
| 2798 | 2798 |
| 2799 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); | 2799 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2800 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); | 2800 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 2801 scrollbar->SetScrollLayerId(scroll->id()); | 2801 scrollbar->SetScrollLayerId(scroll->id()); |
| 2802 root->test_properties()->AddChild(std::move(scrollbar)); | 2802 root->test_properties()->AddChild(std::move(scrollbar)); |
| 2803 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 2803 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2804 host_impl_->active_tree()->DidBecomeActive(); | 2804 host_impl_->active_tree()->DidBecomeActive(); |
| 2805 DrawFrame(); | 2805 DrawFrame(); |
| 2806 |
| 2807 // SetScrollLayerId will initialize the scrollbar which will cause it to |
| 2808 // show and request a redraw. |
| 2809 did_request_redraw_ = false; |
| 2806 } | 2810 } |
| 2807 | 2811 |
| 2808 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2812 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 2809 LayerTreeSettings settings = DefaultSettings(); | 2813 LayerTreeSettings settings = DefaultSettings(); |
| 2810 settings.scrollbar_animator = animator; | 2814 settings.scrollbar_animator = animator; |
| 2811 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); | 2815 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); |
| 2812 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); | 2816 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); |
| 2813 settings.scrollbar_fade_out_resize_delay = | 2817 settings.scrollbar_fade_out_resize_delay = |
| 2814 base::TimeDelta::FromMilliseconds(20); | 2818 base::TimeDelta::FromMilliseconds(20); |
| 2815 settings.scrollbar_fade_out_duration = | 2819 settings.scrollbar_fade_out_duration = |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3121 } | 3125 } |
| 3122 | 3126 |
| 3123 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) { | 3127 TEST_F(LayerTreeHostImplTestScrollbarOpacity, AuraOverlay) { |
| 3124 RunTest(LayerTreeSettings::AURA_OVERLAY); | 3128 RunTest(LayerTreeSettings::AURA_OVERLAY); |
| 3125 } | 3129 } |
| 3126 | 3130 |
| 3127 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { | 3131 TEST_F(LayerTreeHostImplTestScrollbarOpacity, NoAnimator) { |
| 3128 RunTest(LayerTreeSettings::NO_ANIMATOR); | 3132 RunTest(LayerTreeSettings::NO_ANIMATOR); |
| 3129 } | 3133 } |
| 3130 | 3134 |
| 3135 TEST_F(LayerTreeHostImplTest, ScrollbarVisibilityChangeCausesRedrawAndCommit) { |
| 3136 LayerTreeSettings settings = DefaultSettings(); |
| 3137 settings.scrollbar_animator = LayerTreeSettings::AURA_OVERLAY; |
| 3138 settings.scrollbar_show_delay = base::TimeDelta::FromMilliseconds(20); |
| 3139 settings.scrollbar_fade_out_delay = base::TimeDelta::FromMilliseconds(20); |
| 3140 settings.scrollbar_fade_out_duration = base::TimeDelta::FromMilliseconds(20); |
| 3141 gfx::Size content_size(100, 100); |
| 3142 |
| 3143 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3144 host_impl_->CreatePendingTree(); |
| 3145 CreateScrollAndContentsLayers(host_impl_->pending_tree(), content_size); |
| 3146 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 3147 SolidColorScrollbarLayerImpl::Create(host_impl_->pending_tree(), 400, |
| 3148 VERTICAL, 10, 0, false, true); |
| 3149 scrollbar->test_properties()->opacity = 0.f; |
| 3150 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
| 3151 LayerImpl* container = |
| 3152 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
| 3153 scrollbar->SetScrollLayerId(scroll->id()); |
| 3154 container->test_properties()->AddChild(std::move(scrollbar)); |
| 3155 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3156 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 3157 host_impl_->ActivateSyncTree(); |
| 3158 |
| 3159 ScrollbarAnimationController* scrollbar_controller = |
| 3160 host_impl_->ScrollbarAnimationControllerForId(scroll->id()); |
| 3161 |
| 3162 // Scrollbars will flash shown but we should have a fade out animation |
| 3163 // queued. Run it and fade out the scrollbars. |
| 3164 { |
| 3165 ASSERT_FALSE(animation_task_.Equals(base::Closure())); |
| 3166 ASSERT_FALSE(animation_task_.IsCancelled()); |
| 3167 animation_task_.Run(); |
| 3168 |
| 3169 base::TimeTicks fake_now = base::TimeTicks::Now(); |
| 3170 scrollbar_controller->Animate(fake_now); |
| 3171 fake_now += settings.scrollbar_fade_out_delay; |
| 3172 scrollbar_controller->Animate(fake_now); |
| 3173 |
| 3174 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); |
| 3175 } |
| 3176 |
| 3177 // Move the mouse over the scrollbar region. This should post a delayed show |
| 3178 // task. Execute it to show the scrollbars. |
| 3179 { |
| 3180 animation_task_ = base::Closure(); |
| 3181 scrollbar_controller->DidMouseMoveNear(VERTICAL, 0); |
| 3182 ASSERT_FALSE(animation_task_.Equals(base::Closure())); |
| 3183 ASSERT_FALSE(animation_task_.IsCancelled()); |
| 3184 } |
| 3185 |
| 3186 // The show task should cause the scrollbars to show. Ensure that we |
| 3187 // requested a redraw and a commit. |
| 3188 { |
| 3189 did_request_redraw_ = false; |
| 3190 did_request_commit_ = false; |
| 3191 ASSERT_TRUE(scrollbar_controller->ScrollbarsHidden()); |
| 3192 animation_task_.Run(); |
| 3193 ASSERT_FALSE(scrollbar_controller->ScrollbarsHidden()); |
| 3194 EXPECT_TRUE(did_request_redraw_); |
| 3195 EXPECT_TRUE(did_request_commit_); |
| 3196 } |
| 3197 } |
| 3198 |
| 3131 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { | 3199 TEST_F(LayerTreeHostImplTest, ScrollbarInnerLargerThanOuter) { |
| 3132 LayerTreeSettings settings = DefaultSettings(); | 3200 LayerTreeSettings settings = DefaultSettings(); |
| 3133 CreateHostImpl(settings, CreateCompositorFrameSink()); | 3201 CreateHostImpl(settings, CreateCompositorFrameSink()); |
| 3134 | 3202 |
| 3135 gfx::Size inner_viewport_size(315, 200); | 3203 gfx::Size inner_viewport_size(315, 200); |
| 3136 gfx::Size outer_viewport_size(300, 200); | 3204 gfx::Size outer_viewport_size(300, 200); |
| 3137 gfx::Size content_size(1000, 1000); | 3205 gfx::Size content_size(1000, 1000); |
| 3138 | 3206 |
| 3139 const int horiz_id = 11; | 3207 const int horiz_id = 11; |
| 3140 const int child_clip_id = 14; | 3208 const int child_clip_id = 14; |
| (...skipping 8886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12027 else | 12095 else |
| 12028 EXPECT_FALSE(tile->HasRasterTask()); | 12096 EXPECT_FALSE(tile->HasRasterTask()); |
| 12029 } | 12097 } |
| 12030 Region expected_invalidation( | 12098 Region expected_invalidation( |
| 12031 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12099 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
| 12032 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12100 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 12033 } | 12101 } |
| 12034 | 12102 |
| 12035 } // namespace | 12103 } // namespace |
| 12036 } // namespace cc | 12104 } // namespace cc |
| OLD | NEW |