| 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 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3446 old_animation_controller->DidMouseLeave(); | 3446 old_animation_controller->DidMouseLeave(); |
| 3447 } | 3447 } |
| 3448 scroll_element_id_mouse_currently_over_ = new_element_id; | 3448 scroll_element_id_mouse_currently_over_ = new_element_id; |
| 3449 } | 3449 } |
| 3450 | 3450 |
| 3451 ScrollbarAnimationController* new_animation_controller = | 3451 ScrollbarAnimationController* new_animation_controller = |
| 3452 ScrollbarAnimationControllerForElementId(new_element_id); | 3452 ScrollbarAnimationControllerForElementId(new_element_id); |
| 3453 if (!new_animation_controller) | 3453 if (!new_animation_controller) |
| 3454 return; | 3454 return; |
| 3455 | 3455 |
| 3456 int new_layer_id = active_tree_->LayerIdByElementId(new_element_id); | 3456 for (auto* scrollbar : active_tree_->ScrollbarsFor(new_element_id)) { |
| 3457 for (ScrollbarLayerImplBase* scrollbar : | |
| 3458 active_tree_->ScrollbarsFor(new_layer_id)) { | |
| 3459 new_animation_controller->DidMouseMoveNear( | 3457 new_animation_controller->DidMouseMoveNear( |
| 3460 scrollbar->orientation(), | 3458 scrollbar->orientation(), |
| 3461 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / | 3459 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / |
| 3462 active_tree_->device_scale_factor()); | 3460 active_tree_->device_scale_factor()); |
| 3463 } | 3461 } |
| 3464 } | 3462 } |
| 3465 | 3463 |
| 3466 void LayerTreeHostImpl::MouseLeave() { | 3464 void LayerTreeHostImpl::MouseLeave() { |
| 3467 for (auto& pair : scrollbar_animation_controllers_) | 3465 for (auto& pair : scrollbar_animation_controllers_) |
| 3468 pair.second->DidMouseLeave(); | 3466 pair.second->DidMouseLeave(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3674 if (active_tree_->root_layer_for_testing()) { | 3672 if (active_tree_->root_layer_for_testing()) { |
| 3675 std::unique_ptr<base::Value> json( | 3673 std::unique_ptr<base::Value> json( |
| 3676 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); | 3674 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); |
| 3677 base::JSONWriter::WriteWithOptions( | 3675 base::JSONWriter::WriteWithOptions( |
| 3678 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3676 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
| 3679 } | 3677 } |
| 3680 return str; | 3678 return str; |
| 3681 } | 3679 } |
| 3682 | 3680 |
| 3683 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3681 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3684 int scroll_layer_id, | |
| 3685 ElementId scroll_element_id) { | 3682 ElementId scroll_element_id) { |
| 3686 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3683 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3687 return; | 3684 return; |
| 3688 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) | 3685 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) |
| 3689 return; | 3686 return; |
| 3690 scrollbar_animation_controllers_[scroll_element_id] = | 3687 scrollbar_animation_controllers_[scroll_element_id] = |
| 3691 active_tree_->CreateScrollbarAnimationController(scroll_layer_id); | 3688 active_tree_->CreateScrollbarAnimationController(scroll_element_id); |
| 3692 } | 3689 } |
| 3693 | 3690 |
| 3694 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( | 3691 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( |
| 3695 ElementId scroll_element_id) { | 3692 ElementId scroll_element_id) { |
| 3696 scrollbar_animation_controllers_.erase(scroll_element_id); | 3693 scrollbar_animation_controllers_.erase(scroll_element_id); |
| 3697 } | 3694 } |
| 3698 | 3695 |
| 3699 ScrollbarAnimationController* | 3696 ScrollbarAnimationController* |
| 3700 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( | 3697 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( |
| 3701 ElementId scroll_element_id) const { | 3698 ElementId scroll_element_id) const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3722 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); | 3719 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); |
| 3723 SetNeedsOneBeginImplFrame(); | 3720 SetNeedsOneBeginImplFrame(); |
| 3724 } | 3721 } |
| 3725 | 3722 |
| 3726 // TODO(danakj): Make this a return value from the Animate() call instead of an | 3723 // TODO(danakj): Make this a return value from the Animate() call instead of an |
| 3727 // interface on LTHI. (Also, crbug.com/551138.) | 3724 // interface on LTHI. (Also, crbug.com/551138.) |
| 3728 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { | 3725 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { |
| 3729 SetNeedsRedraw(); | 3726 SetNeedsRedraw(); |
| 3730 } | 3727 } |
| 3731 | 3728 |
| 3732 ScrollbarSet LayerTreeHostImpl::ScrollbarsFor(int scroll_layer_id) const { | 3729 ScrollbarSet LayerTreeHostImpl::ScrollbarsFor(ElementId id) const { |
| 3733 return active_tree_->ScrollbarsFor(scroll_layer_id); | 3730 return active_tree_->ScrollbarsFor(id); |
| 3734 } | 3731 } |
| 3735 | 3732 |
| 3736 void LayerTreeHostImpl::AddVideoFrameController( | 3733 void LayerTreeHostImpl::AddVideoFrameController( |
| 3737 VideoFrameController* controller) { | 3734 VideoFrameController* controller) { |
| 3738 bool was_empty = video_frame_controllers_.empty(); | 3735 bool was_empty = video_frame_controllers_.empty(); |
| 3739 video_frame_controllers_.insert(controller); | 3736 video_frame_controllers_.insert(controller); |
| 3740 if (current_begin_frame_tracker_.DangerousMethodHasStarted() && | 3737 if (current_begin_frame_tracker_.DangerousMethodHasStarted() && |
| 3741 !current_begin_frame_tracker_.DangerousMethodHasFinished()) | 3738 !current_begin_frame_tracker_.DangerousMethodHasFinished()) |
| 3742 controller->OnBeginFrame(current_begin_frame_tracker_.Current()); | 3739 controller->OnBeginFrame(current_begin_frame_tracker_.Current()); |
| 3743 if (was_empty) | 3740 if (was_empty) |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4286 } | 4283 } |
| 4287 | 4284 |
| 4288 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { | 4285 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { |
| 4289 if (is_wheel_scroll) | 4286 if (is_wheel_scroll) |
| 4290 has_scrolled_by_wheel_ = true; | 4287 has_scrolled_by_wheel_ = true; |
| 4291 else | 4288 else |
| 4292 has_scrolled_by_touch_ = true; | 4289 has_scrolled_by_touch_ = true; |
| 4293 } | 4290 } |
| 4294 | 4291 |
| 4295 } // namespace cc | 4292 } // namespace cc |
| OLD | NEW |