| 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 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2912 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = | 2912 std::unique_ptr<SolidColorScrollbarLayerImpl> scrollbar = |
| 2913 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, | 2913 SolidColorScrollbarLayerImpl::Create(host_impl_->active_tree(), 400, |
| 2914 VERTICAL, 10, 0, false, true); | 2914 VERTICAL, 10, 0, false, true); |
| 2915 scrollbar->test_properties()->opacity = 0.f; | 2915 scrollbar->test_properties()->opacity = 0.f; |
| 2916 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); | 2916 EXPECT_FLOAT_EQ(0.f, scrollbar->test_properties()->opacity); |
| 2917 | 2917 |
| 2918 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); | 2918 LayerImpl* scroll = host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 2919 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); | 2919 LayerImpl* root = host_impl_->active_tree()->InnerViewportContainerLayer(); |
| 2920 scrollbar->SetScrollElementId(scroll->element_id()); | 2920 scrollbar->SetScrollElementId(scroll->element_id()); |
| 2921 root->test_properties()->AddChild(std::move(scrollbar)); | 2921 root->test_properties()->AddChild(std::move(scrollbar)); |
| 2922 scroll->set_needs_show_scrollbars(true); | |
| 2923 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 2922 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
| 2924 host_impl_->active_tree()->DidBecomeActive(); | 2923 host_impl_->active_tree()->DidBecomeActive(); |
| 2925 host_impl_->active_tree()->HandleScrollbarShowRequestsFromMain(); | 2924 host_impl_->active_tree()->HandleScrollbarShowRequestsFromMain(); |
| 2926 DrawFrame(); | 2925 DrawFrame(); |
| 2927 | 2926 |
| 2928 // SetScrollElementId will initialize the scrollbar which will cause it to | 2927 // SetScrollElementId will initialize the scrollbar which will cause it to |
| 2929 // show and request a redraw. | 2928 // show and request a redraw. |
| 2930 did_request_redraw_ = false; | 2929 did_request_redraw_ = false; |
| 2931 } | 2930 } |
| 2932 | 2931 |
| 2933 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { | 2932 void RunTest(LayerTreeSettings::ScrollbarAnimator animator) { |
| 2934 LayerTreeSettings settings = DefaultSettings(); | 2933 LayerTreeSettings settings = DefaultSettings(); |
| 2935 settings.scrollbar_animator = animator; | 2934 settings.scrollbar_animator = animator; |
| 2936 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); | 2935 settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(20); |
| 2937 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); | 2936 settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(20); |
| 2938 | 2937 |
| 2939 // If no animator is set, scrollbar won't show and no animation is expected. | 2938 // If no animator is set, scrollbar won't show and no animation is expected. |
| 2940 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; | 2939 bool expecting_animations = animator != LayerTreeSettings::NO_ANIMATOR; |
| 2941 | 2940 |
| 2942 SetupLayers(settings); | 2941 SetupLayers(settings); |
| 2943 | 2942 |
| 2944 base::TimeTicks fake_now = base::TimeTicks::Now(); | 2943 base::TimeTicks fake_now = base::TimeTicks::Now(); |
| 2945 | 2944 |
| 2946 if (expecting_animations) { | 2945 // Android Overlay Scrollbar does not have a initial show and fade out. |
| 2946 if (animator == LayerTreeSettings::AURA_OVERLAY) { |
| 2947 // A task will be posted to fade the initial scrollbar. | 2947 // A task will be posted to fade the initial scrollbar. |
| 2948 EXPECT_FALSE(did_request_next_frame_); | 2948 EXPECT_FALSE(did_request_next_frame_); |
| 2949 EXPECT_FALSE(did_request_redraw_); | 2949 EXPECT_FALSE(did_request_redraw_); |
| 2950 EXPECT_FALSE(animation_task_.Equals(base::Closure())); | 2950 EXPECT_FALSE(animation_task_.Equals(base::Closure())); |
| 2951 requested_animation_delay_ = base::TimeDelta(); | 2951 requested_animation_delay_ = base::TimeDelta(); |
| 2952 animation_task_ = base::Closure(); | 2952 animation_task_ = base::Closure(); |
| 2953 } else { | 2953 } else { |
| 2954 EXPECT_FALSE(did_request_next_frame_); | 2954 EXPECT_FALSE(did_request_next_frame_); |
| 2955 EXPECT_FALSE(did_request_redraw_); | 2955 EXPECT_FALSE(did_request_redraw_); |
| 2956 EXPECT_TRUE(animation_task_.Equals(base::Closure())); | 2956 EXPECT_TRUE(animation_task_.Equals(base::Closure())); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3216 VERTICAL, 10, 0, false, true); | 3216 VERTICAL, 10, 0, false, true); |
| 3217 scrollbar->test_properties()->opacity = 0.f; | 3217 scrollbar->test_properties()->opacity = 0.f; |
| 3218 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); | 3218 LayerImpl* scroll = host_impl_->pending_tree()->OuterViewportScrollLayer(); |
| 3219 LayerImpl* container = | 3219 LayerImpl* container = |
| 3220 host_impl_->pending_tree()->InnerViewportContainerLayer(); | 3220 host_impl_->pending_tree()->InnerViewportContainerLayer(); |
| 3221 scrollbar->SetScrollElementId(scroll->element_id()); | 3221 scrollbar->SetScrollElementId(scroll->element_id()); |
| 3222 scrollbar->SetBounds(gfx::Size(10, 100)); | 3222 scrollbar->SetBounds(gfx::Size(10, 100)); |
| 3223 scrollbar->SetPosition(gfx::PointF(90, 0)); | 3223 scrollbar->SetPosition(gfx::PointF(90, 0)); |
| 3224 container->test_properties()->AddChild(std::move(scrollbar)); | 3224 container->test_properties()->AddChild(std::move(scrollbar)); |
| 3225 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 3225 host_impl_->pending_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 3226 scroll->set_needs_show_scrollbars(true); | |
| 3227 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); | 3226 host_impl_->pending_tree()->BuildPropertyTreesForTesting(); |
| 3228 host_impl_->ActivateSyncTree(); | 3227 host_impl_->ActivateSyncTree(); |
| 3229 | 3228 |
| 3230 ScrollbarAnimationController* scrollbar_controller = | 3229 ScrollbarAnimationController* scrollbar_controller = |
| 3231 host_impl_->ScrollbarAnimationControllerForElementId( | 3230 host_impl_->ScrollbarAnimationControllerForElementId( |
| 3232 scroll->element_id()); | 3231 scroll->element_id()); |
| 3233 | 3232 |
| 3234 // Scrollbars will flash shown but we should have a fade out animation | 3233 // Scrollbars will flash shown but we should have a fade out animation |
| 3235 // queued. Run it and fade out the scrollbars. | 3234 // queued. Run it and fade out the scrollbars. |
| 3236 { | 3235 { |
| (...skipping 9130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12367 else | 12366 else |
| 12368 EXPECT_FALSE(tile->HasRasterTask()); | 12367 EXPECT_FALSE(tile->HasRasterTask()); |
| 12369 } | 12368 } |
| 12370 Region expected_invalidation( | 12369 Region expected_invalidation( |
| 12371 raster_source->GetRectForImage(checkerable_image->uniqueID())); | 12370 raster_source->GetRectForImage(checkerable_image->uniqueID())); |
| 12372 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); | 12371 EXPECT_EQ(expected_invalidation, *(root->GetPendingInvalidation())); |
| 12373 } | 12372 } |
| 12374 | 12373 |
| 12375 } // namespace | 12374 } // namespace |
| 12376 } // namespace cc | 12375 } // namespace cc |
| OLD | NEW |