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 3003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3225 return; | 3226 return; |
3226 | 3227 |
3227 ScrollbarAnimationController* animation_controller = | 3228 ScrollbarAnimationController* animation_controller = |
3228 ScrollbarAnimationControllerForId(captured_scrollbar_layer_id_); | 3229 ScrollbarAnimationControllerForId(captured_scrollbar_layer_id_); |
3229 if (animation_controller) | 3230 if (animation_controller) |
3230 animation_controller->DidCaptureScrollbarEnd(); | 3231 animation_controller->DidCaptureScrollbarEnd(); |
3231 captured_scrollbar_layer_id_ = Layer::INVALID_ID; | 3232 captured_scrollbar_layer_id_ = Layer::INVALID_ID; |
3232 } | 3233 } |
3233 | 3234 |
3234 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { | 3235 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { |
3236 scroll_layer_id_when_mouse_near_scrollbar_ = Layer::INVALID_ID; | |
3235 gfx::PointF device_viewport_point = gfx::ScalePoint( | 3237 gfx::PointF device_viewport_point = gfx::ScalePoint( |
3236 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 3238 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
3237 LayerImpl* layer_impl = | 3239 LayerImpl* layer_impl = |
3238 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 3240 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
3239 HandleMouseOverScrollbar(layer_impl); | 3241 HandleMouseOverScrollbar(layer_impl); |
3240 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) | 3242 if (scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID) |
3241 return; | 3243 return; |
3242 | 3244 |
3243 bool scroll_on_main_thread = false; | 3245 bool scroll_on_main_thread = false; |
3244 uint32_t main_thread_scrolling_reasons; | 3246 uint32_t main_thread_scrolling_reasons; |
3245 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( | 3247 LayerImpl* scroll_layer_impl = FindScrollLayerForDeviceViewportPoint( |
3246 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, | 3248 device_viewport_point, InputHandler::TOUCHSCREEN, layer_impl, |
3247 &scroll_on_main_thread, &main_thread_scrolling_reasons); | 3249 &scroll_on_main_thread, &main_thread_scrolling_reasons); |
3248 if (scroll_layer_impl == InnerViewportScrollLayer()) | 3250 if (scroll_layer_impl == InnerViewportScrollLayer()) |
3249 scroll_layer_impl = OuterViewportScrollLayer(); | 3251 scroll_layer_impl = OuterViewportScrollLayer(); |
3250 if (scroll_on_main_thread || !scroll_layer_impl) | 3252 if (scroll_on_main_thread || !scroll_layer_impl) |
3251 return; | 3253 return; |
3252 | 3254 |
3253 ScrollbarAnimationController* animation_controller = | 3255 ScrollbarAnimationController* animation_controller = |
3254 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); | 3256 ScrollbarAnimationControllerForId(scroll_layer_impl->id()); |
3255 if (!animation_controller) | 3257 if (!animation_controller) |
3256 return; | 3258 return; |
3257 | 3259 |
3260 scroll_layer_id_when_mouse_near_scrollbar_ = scroll_layer_impl->id(); | |
3261 | |
3258 float distance_to_scrollbar = std::numeric_limits<float>::max(); | 3262 float distance_to_scrollbar = std::numeric_limits<float>::max(); |
3259 for (ScrollbarLayerImplBase* scrollbar : | 3263 for (ScrollbarLayerImplBase* scrollbar : |
3260 ScrollbarsFor(scroll_layer_impl->id())) | 3264 ScrollbarsFor(scroll_layer_impl->id())) |
3261 distance_to_scrollbar = | 3265 distance_to_scrollbar = |
3262 std::min(distance_to_scrollbar, | 3266 std::min(distance_to_scrollbar, |
3263 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); | 3267 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar)); |
3264 | 3268 |
3265 animation_controller->DidMouseMoveNear(distance_to_scrollbar / | 3269 animation_controller->DidMouseMoveNear(distance_to_scrollbar / |
3266 active_tree_->device_scale_factor()); | 3270 active_tree_->device_scale_factor()); |
3267 } | 3271 } |
3268 | 3272 |
3273 void LayerTreeHostImpl::MouseLeave() { | |
3274 // scroll_layer_id_when_mouse_near_scrollbar_ and | |
3275 // scroll_layer_id_when_mouse_over_scrollbar_ should not be both true | |
3276 DCHECK(!(scroll_layer_id_when_mouse_near_scrollbar_ != Layer::INVALID_ID && | |
bokan
2016/10/05 14:00:09
This is more clearly expressed as:
mouse_near_scr
| |
3277 scroll_layer_id_when_mouse_over_scrollbar_ != Layer::INVALID_ID)); | |
3278 | |
3279 int scroll_layer_id = | |
3280 scroll_layer_id_when_mouse_near_scrollbar_ != Layer::INVALID_ID | |
3281 ? scroll_layer_id_when_mouse_near_scrollbar_ | |
3282 : scroll_layer_id_when_mouse_over_scrollbar_; | |
3283 | |
3284 ScrollbarAnimationController* animation_controller = | |
3285 ScrollbarAnimationControllerForId(scroll_layer_id); | |
3286 | |
3287 if (animation_controller) | |
3288 animation_controller->DidMouseLeave(); | |
3289 } | |
3290 | |
3269 void LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl) { | 3291 void LayerTreeHostImpl::HandleMouseOverScrollbar(LayerImpl* layer_impl) { |
3270 int new_id = Layer::INVALID_ID; | 3292 int new_id = Layer::INVALID_ID; |
3271 if (layer_impl && layer_impl->ToScrollbarLayer()) | 3293 if (layer_impl && layer_impl->ToScrollbarLayer()) |
3272 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); | 3294 new_id = layer_impl->ToScrollbarLayer()->ScrollLayerId(); |
3273 | 3295 |
3274 if (new_id == scroll_layer_id_when_mouse_over_scrollbar_) | 3296 if (new_id == scroll_layer_id_when_mouse_over_scrollbar_) |
3275 return; | 3297 return; |
3276 | 3298 |
3277 ScrollbarAnimationController* old_animation_controller = | 3299 ScrollbarAnimationController* old_animation_controller = |
3278 ScrollbarAnimationControllerForId( | 3300 ScrollbarAnimationControllerForId( |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4165 if (is_visible) { | 4187 if (is_visible) { |
4166 worker_context_visibility_ = | 4188 worker_context_visibility_ = |
4167 worker_context->CacheController()->ClientBecameVisible(); | 4189 worker_context->CacheController()->ClientBecameVisible(); |
4168 } else { | 4190 } else { |
4169 worker_context->CacheController()->ClientBecameNotVisible( | 4191 worker_context->CacheController()->ClientBecameNotVisible( |
4170 std::move(worker_context_visibility_)); | 4192 std::move(worker_context_visibility_)); |
4171 } | 4193 } |
4172 } | 4194 } |
4173 | 4195 |
4174 } // namespace cc | 4196 } // namespace cc |
OLD | NEW |