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 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 content_is_suitable_for_gpu_rasterization_(true), | 202 content_is_suitable_for_gpu_rasterization_(true), |
| 203 has_gpu_rasterization_trigger_(false), | 203 has_gpu_rasterization_trigger_(false), |
| 204 use_gpu_rasterization_(false), | 204 use_gpu_rasterization_(false), |
| 205 use_msaa_(false), | 205 use_msaa_(false), |
| 206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), | 206 gpu_rasterization_status_(GpuRasterizationStatus::OFF_DEVICE), |
| 207 input_handler_client_(NULL), | 207 input_handler_client_(NULL), |
| 208 did_lock_scrolling_layer_(false), | 208 did_lock_scrolling_layer_(false), |
| 209 wheel_scrolling_(false), | 209 wheel_scrolling_(false), |
| 210 scroll_affects_scroll_handler_(false), | 210 scroll_affects_scroll_handler_(false), |
| 211 scroll_layer_id_when_mouse_over_scrollbar_(Layer::INVALID_ID), | 211 scroll_layer_id_when_mouse_over_scrollbar_(Layer::INVALID_ID), |
| 212 scroll_layer_id_when_mouse_near_scrollbar_(Layer::INVALID_ID), | |
| 212 captured_scrollbar_layer_id_(Layer::INVALID_ID), | 213 captured_scrollbar_layer_id_(Layer::INVALID_ID), |
| 213 tile_priorities_dirty_(false), | 214 tile_priorities_dirty_(false), |
| 214 settings_(settings), | 215 settings_(settings), |
| 215 visible_(false), | 216 visible_(false), |
| 216 cached_managed_memory_policy_(settings.gpu_memory_policy), | 217 cached_managed_memory_policy_(settings.gpu_memory_policy), |
| 217 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && | 218 is_synchronous_single_threaded_(!task_runner_provider->HasImplThread() && |
| 218 !settings.single_thread_proxy_scheduler), | 219 !settings.single_thread_proxy_scheduler), |
| 219 // Must be initialized after is_synchronous_single_threaded_ and | 220 // Must be initialized after is_synchronous_single_threaded_ and |
| 220 // task_runner_provider_. | 221 // task_runner_provider_. |
| 221 tile_manager_(this, | 222 tile_manager_(this, |
| (...skipping 3027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3249 uint32_t main_thread_scrolling_reasons; | 3250 uint32_t main_thread_scrolling_reasons; |
| 3250 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3251 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 3251 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3252 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
| 3252 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3253 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
| 3253 // Scrollbars for the viewport are registered with the outer viewport layer. | 3254 // Scrollbars for the viewport are registered with the outer viewport layer. |
| 3254 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3255 if (scroll_layer_impl == InnerViewportScrollLayer()) |
| 3255 scroll_layer_impl = OuterViewportScrollLayer(); | 3256 scroll_layer_impl = OuterViewportScrollLayer(); |
| 3256 if (scroll_on_main_thread || !scroll_layer_impl) | 3257 if (scroll_on_main_thread || !scroll_layer_impl) |
| 3257 return; | 3258 return; |
| 3258 | 3259 |
| 3259 ScrollbarAnimationController* animation_controller = | 3260 if (scroll_layer_impl->id() != scroll_layer_id_when_mouse_near_scrollbar_) { |
| 3261 ScrollbarAnimationController* old_animation_controller = | |
| 3262 ScrollbarAnimationControllerForId( | |
|
bokan
2016/10/18 15:44:35
Hmm...too much of this logic is starting to creep
sahel
2016/10/19 21:29:17
Done.
| |
| 3263 scroll_layer_id_when_mouse_near_scrollbar_); | |
| 3264 if (old_animation_controller) | |
| 3265 old_animation_controller->DidMouseMoveOffScrollbar(); | |
| 3266 } | |
| 3267 | |
| 3268 ScrollbarAnimationController* new_animation_controller = | |
| 3260 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); | 3269 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); |
| 3261 if (!animation_controller) | 3270 if (!new_animation_controller) |
| 3262 return; | 3271 return; |
| 3263 | 3272 |
| 3264 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 3273 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
| 3265 for (ScrollbarLayerImplBase* scrollbar : | 3274 for (ScrollbarLayerImplBase* scrollbar : |
| 3266 ScrollbarsFor(scroll_layer_impl->id())) | 3275 ScrollbarsFor(scroll_layer_impl->id())) |
| 3267 distance_to_scrollbar = | 3276 distance_to_scrollbar = |
| 3268 std::min(distance_to_scrollbar, | 3277 std::min(distance_to_scrollbar, |
| 3269 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); | 3278 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); |
| 3270 | 3279 |
| 3271 animation_controller->DidMouseMoveNear(distance_to_scrollbar / | 3280 new_animation_controller->DidMouseMoveNear( |
| 3272 active_tree_->device_scale_factor()); | 3281 distance_to_scrollbar / active_tree_->device_scale_factor()); |
| 3282 if (new_animation_controller->MouseIsNearScrollbar()) | |
| 3283 scroll_layer_id_when_mouse_near_scrollbar_ = scroll_layer_impl->id(); | |
| 3273 } | 3284 } |
| 3274 | 3285 |
| 3275 void LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl) { | 3286 void LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl) { |
| 3276 int new_id = Layer::INVALID_ID; | 3287 int new_id = Layer::INVALID_ID; |
| 3277 if (layer_impl && layer_impl->ToScrollbarLayer()) | 3288 if (layer_impl && layer_impl->ToScrollbarLayer()) |
| 3278 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 3289 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
| 3279 | 3290 |
| 3280 if (new_id == scroll_layer_id_when_mouse_over_scrollbar_) | 3291 if (new_id == scroll_layer_id_when_mouse_over_scrollbar_) |
| 3281 return; | 3292 return; |
| 3282 | 3293 |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4088 if (is_visible) { | 4099 if (is_visible) { |
| 4089 worker_context_visibility_ = | 4100 worker_context_visibility_ = |
| 4090 worker_context->CacheController()->ClientBecameVisible(); | 4101 worker_context->CacheController()->ClientBecameVisible(); |
| 4091 } else { | 4102 } else { |
| 4092 worker_context->CacheController()->ClientBecameNotVisible( | 4103 worker_context->CacheController()->ClientBecameNotVisible( |
| 4093 std::move(worker_context_visibility_)); | 4104 std::move(worker_context_visibility_)); |
| 4094 } | 4105 } |
| 4095 } | 4106 } |
| 4096 | 4107 |
| 4097 } // namespace cc | 4108 } // namespace cc |
| OLD | NEW |