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 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3380 if (!CurrentlyScrollingNode()) { | 3380 if (!CurrentlyScrollingNode()) { |
3381 scroll_status.thread = SCROLL_IGNORED; | 3381 scroll_status.thread = SCROLL_IGNORED; |
3382 scroll_status.main_thread_scrolling_reasons = | 3382 scroll_status.main_thread_scrolling_reasons = |
3383 MainThreadScrollingReason::kNoScrollingLayer; | 3383 MainThreadScrollingReason::kNoScrollingLayer; |
3384 } else { | 3384 } else { |
3385 scroll_status.thread = SCROLL_ON_IMPL_THREAD; | 3385 scroll_status.thread = SCROLL_ON_IMPL_THREAD; |
3386 } | 3386 } |
3387 return scroll_status; | 3387 return scroll_status; |
3388 } | 3388 } |
3389 | 3389 |
3390 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( | |
3391 const gfx::PointF& device_viewport_point, | |
3392 LayerImpl* layer_impl) { | |
3393 if (!layer_impl) | |
3394 return std::numeric_limits<float>::max(); | |
3395 | |
3396 gfx::Rect layer_impl_bounds(layer_impl->bounds()); | |
3397 | |
3398 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( | |
3399 layer_impl->ScreenSpaceTransform(), gfx::RectF(layer_impl_bounds)); | |
3400 | |
3401 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint( | |
3402 device_viewport_point); | |
3403 } | |
3404 | |
3405 void LayerTreeHostImpl::MouseDown() { | 3390 void LayerTreeHostImpl::MouseDown() { |
3406 ScrollbarAnimationController* animation_controller = | 3391 ScrollbarAnimationController* animation_controller = |
3407 ScrollbarAnimationControllerForElementId( | 3392 ScrollbarAnimationControllerForElementId( |
3408 scroll_element_id_mouse_currently_over_); | 3393 scroll_element_id_mouse_currently_over_); |
3409 if (animation_controller) { | 3394 if (animation_controller) { |
3410 animation_controller->DidMouseDown(); | 3395 animation_controller->DidMouseDown(); |
3411 scroll_element_id_mouse_currently_captured_ = | 3396 scroll_element_id_mouse_currently_captured_ = |
3412 scroll_element_id_mouse_currently_over_; | 3397 scroll_element_id_mouse_currently_over_; |
3413 } | 3398 } |
3414 } | 3399 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3463 } | 3448 } |
3464 scroll_element_id_mouse_currently_over_ = scroll_element_id; | 3449 scroll_element_id_mouse_currently_over_ = scroll_element_id; |
3465 } | 3450 } |
3466 | 3451 |
3467 ScrollbarAnimationController* new_animation_controller = | 3452 ScrollbarAnimationController* new_animation_controller = |
3468 ScrollbarAnimationControllerForElementId(scroll_element_id); | 3453 ScrollbarAnimationControllerForElementId(scroll_element_id); |
3469 if (!new_animation_controller) | 3454 if (!new_animation_controller) |
3470 return; | 3455 return; |
3471 | 3456 |
3472 for (auto* scrollbar : active_tree_->ScrollbarsFor(scroll_element_id)) { | 3457 for (auto* scrollbar : active_tree_->ScrollbarsFor(scroll_element_id)) { |
3473 new_animation_controller->DidMouseMoveNear( | 3458 new_animation_controller->DidMouseMoveNear(scrollbar->orientation(), |
3474 scrollbar->orientation(), | 3459 device_viewport_point); |
3475 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / | |
3476 active_tree_->device_scale_factor()); | |
3477 } | 3460 } |
3478 } | 3461 } |
3479 | 3462 |
3480 void LayerTreeHostImpl::MouseLeave() { | 3463 void LayerTreeHostImpl::MouseLeave() { |
3481 for (auto& pair : scrollbar_animation_controllers_) | 3464 for (auto& pair : scrollbar_animation_controllers_) |
3482 pair.second->DidMouseLeave(); | 3465 pair.second->DidMouseLeave(); |
3483 scroll_element_id_mouse_currently_over_ = ElementId(); | 3466 scroll_element_id_mouse_currently_over_ = ElementId(); |
3484 } | 3467 } |
3485 | 3468 |
3486 void LayerTreeHostImpl::PinchGestureBegin() { | 3469 void LayerTreeHostImpl::PinchGestureBegin() { |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4296 } | 4279 } |
4297 | 4280 |
4298 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { | 4281 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { |
4299 if (is_wheel_scroll) | 4282 if (is_wheel_scroll) |
4300 has_scrolled_by_wheel_ = true; | 4283 has_scrolled_by_wheel_ = true; |
4301 else | 4284 else |
4302 has_scrolled_by_touch_ = true; | 4285 has_scrolled_by_touch_ = true; |
4303 } | 4286 } |
4304 | 4287 |
4305 } // namespace cc | 4288 } // namespace cc |
OLD | NEW |