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