| 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 3426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3437 old_animation_controller->DidMouseLeave(); | 3437 old_animation_controller->DidMouseLeave(); |
| 3438 } | 3438 } |
| 3439 scroll_element_id_mouse_currently_over_ = scroll_element_id; | 3439 scroll_element_id_mouse_currently_over_ = scroll_element_id; |
| 3440 } | 3440 } |
| 3441 | 3441 |
| 3442 ScrollbarAnimationController* new_animation_controller = | 3442 ScrollbarAnimationController* new_animation_controller = |
| 3443 ScrollbarAnimationControllerForElementId(scroll_element_id); | 3443 ScrollbarAnimationControllerForElementId(scroll_element_id); |
| 3444 if (!new_animation_controller) | 3444 if (!new_animation_controller) |
| 3445 return; | 3445 return; |
| 3446 | 3446 |
| 3447 int scroll_layer_id = active_tree_->LayerIdByElementId(scroll_element_id); | 3447 for (auto* scrollbar : active_tree_->ScrollbarsFor(scroll_element_id)) { |
| 3448 for (ScrollbarLayerImplBase* scrollbar : | |
| 3449 active_tree_->ScrollbarsFor(scroll_layer_id)) { | |
| 3450 new_animation_controller->DidMouseMoveNear( | 3448 new_animation_controller->DidMouseMoveNear( |
| 3451 scrollbar->orientation(), | 3449 scrollbar->orientation(), |
| 3452 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / | 3450 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / |
| 3453 active_tree_->device_scale_factor()); | 3451 active_tree_->device_scale_factor()); |
| 3454 } | 3452 } |
| 3455 } | 3453 } |
| 3456 | 3454 |
| 3457 void LayerTreeHostImpl::MouseLeave() { | 3455 void LayerTreeHostImpl::MouseLeave() { |
| 3458 for (auto& pair : scrollbar_animation_controllers_) | 3456 for (auto& pair : scrollbar_animation_controllers_) |
| 3459 pair.second->DidMouseLeave(); | 3457 pair.second->DidMouseLeave(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3665 if (active_tree_->root_layer_for_testing()) { | 3663 if (active_tree_->root_layer_for_testing()) { |
| 3666 std::unique_ptr<base::Value> json( | 3664 std::unique_ptr<base::Value> json( |
| 3667 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); | 3665 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); |
| 3668 base::JSONWriter::WriteWithOptions( | 3666 base::JSONWriter::WriteWithOptions( |
| 3669 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3667 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
| 3670 } | 3668 } |
| 3671 return str; | 3669 return str; |
| 3672 } | 3670 } |
| 3673 | 3671 |
| 3674 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3672 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3675 int scroll_layer_id, | |
| 3676 ElementId scroll_element_id) { | 3673 ElementId scroll_element_id) { |
| 3677 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3674 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3678 return; | 3675 return; |
| 3679 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) | 3676 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) |
| 3680 return; | 3677 return; |
| 3681 scrollbar_animation_controllers_[scroll_element_id] = | 3678 scrollbar_animation_controllers_[scroll_element_id] = |
| 3682 active_tree_->CreateScrollbarAnimationController(scroll_layer_id); | 3679 active_tree_->CreateScrollbarAnimationController(scroll_element_id); |
| 3683 } | 3680 } |
| 3684 | 3681 |
| 3685 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( | 3682 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( |
| 3686 ElementId scroll_element_id) { | 3683 ElementId scroll_element_id) { |
| 3687 scrollbar_animation_controllers_.erase(scroll_element_id); | 3684 scrollbar_animation_controllers_.erase(scroll_element_id); |
| 3688 } | 3685 } |
| 3689 | 3686 |
| 3690 ScrollbarAnimationController* | 3687 ScrollbarAnimationController* |
| 3691 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( | 3688 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( |
| 3692 ElementId scroll_element_id) const { | 3689 ElementId scroll_element_id) const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3713 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); | 3710 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); |
| 3714 SetNeedsOneBeginImplFrame(); | 3711 SetNeedsOneBeginImplFrame(); |
| 3715 } | 3712 } |
| 3716 | 3713 |
| 3717 // TODO(danakj): Make this a return value from the Animate() call instead of an | 3714 // TODO(danakj): Make this a return value from the Animate() call instead of an |
| 3718 // interface on LTHI. (Also, crbug.com/551138.) | 3715 // interface on LTHI. (Also, crbug.com/551138.) |
| 3719 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { | 3716 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { |
| 3720 SetNeedsRedraw(); | 3717 SetNeedsRedraw(); |
| 3721 } | 3718 } |
| 3722 | 3719 |
| 3723 ScrollbarSet LayerTreeHostImpl::ScrollbarsFor(int scroll_layer_id) const { | 3720 ScrollbarSet LayerTreeHostImpl::ScrollbarsFor(ElementId id) const { |
| 3724 return active_tree_->ScrollbarsFor(scroll_layer_id); | 3721 return active_tree_->ScrollbarsFor(id); |
| 3725 } | 3722 } |
| 3726 | 3723 |
| 3727 void LayerTreeHostImpl::AddVideoFrameController( | 3724 void LayerTreeHostImpl::AddVideoFrameController( |
| 3728 VideoFrameController* controller) { | 3725 VideoFrameController* controller) { |
| 3729 bool was_empty = video_frame_controllers_.empty(); | 3726 bool was_empty = video_frame_controllers_.empty(); |
| 3730 video_frame_controllers_.insert(controller); | 3727 video_frame_controllers_.insert(controller); |
| 3731 if (current_begin_frame_tracker_.DangerousMethodHasStarted() && | 3728 if (current_begin_frame_tracker_.DangerousMethodHasStarted() && |
| 3732 !current_begin_frame_tracker_.DangerousMethodHasFinished()) | 3729 !current_begin_frame_tracker_.DangerousMethodHasFinished()) |
| 3733 controller->OnBeginFrame(current_begin_frame_tracker_.Current()); | 3730 controller->OnBeginFrame(current_begin_frame_tracker_.Current()); |
| 3734 if (was_empty) | 3731 if (was_empty) |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4277 } | 4274 } |
| 4278 | 4275 |
| 4279 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { | 4276 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { |
| 4280 if (is_wheel_scroll) | 4277 if (is_wheel_scroll) |
| 4281 has_scrolled_by_wheel_ = true; | 4278 has_scrolled_by_wheel_ = true; |
| 4282 else | 4279 else |
| 4283 has_scrolled_by_touch_ = true; | 4280 has_scrolled_by_touch_ = true; |
| 4284 } | 4281 } |
| 4285 | 4282 |
| 4286 } // namespace cc | 4283 } // namespace cc |
| OLD | NEW |