| 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 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3463 old_animation_controller->DidMouseLeave(); | 3463 old_animation_controller->DidMouseLeave(); |
| 3464 } | 3464 } |
| 3465 scroll_element_id_mouse_currently_over_ = new_element_id; | 3465 scroll_element_id_mouse_currently_over_ = new_element_id; |
| 3466 } | 3466 } |
| 3467 | 3467 |
| 3468 ScrollbarAnimationController* new_animation_controller = | 3468 ScrollbarAnimationController* new_animation_controller = |
| 3469 ScrollbarAnimationControllerForElementId(new_element_id); | 3469 ScrollbarAnimationControllerForElementId(new_element_id); |
| 3470 if (!new_animation_controller) | 3470 if (!new_animation_controller) |
| 3471 return; | 3471 return; |
| 3472 | 3472 |
| 3473 int new_layer_id = active_tree_->LayerIdByElementId(new_element_id); | 3473 for (auto* scrollbar : active_tree_->ScrollbarsFor(new_element_id)) { |
| 3474 for (ScrollbarLayerImplBase* scrollbar : | |
| 3475 active_tree_->ScrollbarsFor(new_layer_id)) { | |
| 3476 new_animation_controller->DidMouseMoveNear( | 3474 new_animation_controller->DidMouseMoveNear( |
| 3477 scrollbar->orientation(), | 3475 scrollbar->orientation(), |
| 3478 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / | 3476 DeviceSpaceDistanceToLayer(device_viewport_point, scrollbar) / |
| 3479 active_tree_->device_scale_factor()); | 3477 active_tree_->device_scale_factor()); |
| 3480 } | 3478 } |
| 3481 } | 3479 } |
| 3482 | 3480 |
| 3483 void LayerTreeHostImpl::MouseLeave() { | 3481 void LayerTreeHostImpl::MouseLeave() { |
| 3484 for (auto& pair : scrollbar_animation_controllers_) | 3482 for (auto& pair : scrollbar_animation_controllers_) |
| 3485 pair.second->DidMouseLeave(); | 3483 pair.second->DidMouseLeave(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3691 if (active_tree_->root_layer_for_testing()) { | 3689 if (active_tree_->root_layer_for_testing()) { |
| 3692 std::unique_ptr<base::Value> json( | 3690 std::unique_ptr<base::Value> json( |
| 3693 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); | 3691 active_tree_->root_layer_for_testing()->LayerTreeAsJson()); |
| 3694 base::JSONWriter::WriteWithOptions( | 3692 base::JSONWriter::WriteWithOptions( |
| 3695 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); | 3693 *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &str); |
| 3696 } | 3694 } |
| 3697 return str; | 3695 return str; |
| 3698 } | 3696 } |
| 3699 | 3697 |
| 3700 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3698 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3701 int scroll_layer_id, | |
| 3702 ElementId scroll_element_id) { | 3699 ElementId scroll_element_id) { |
| 3703 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3700 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3704 return; | 3701 return; |
| 3705 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) | 3702 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) |
| 3706 return; | 3703 return; |
| 3707 scrollbar_animation_controllers_[scroll_element_id] = | 3704 scrollbar_animation_controllers_[scroll_element_id] = |
| 3708 active_tree_->CreateScrollbarAnimationController(scroll_layer_id); | 3705 active_tree_->CreateScrollbarAnimationController(scroll_element_id); |
| 3709 } | 3706 } |
| 3710 | 3707 |
| 3711 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( | 3708 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( |
| 3712 ElementId scroll_element_id) { | 3709 ElementId scroll_element_id) { |
| 3713 scrollbar_animation_controllers_.erase(scroll_element_id); | 3710 scrollbar_animation_controllers_.erase(scroll_element_id); |
| 3714 } | 3711 } |
| 3715 | 3712 |
| 3716 ScrollbarAnimationController* | 3713 ScrollbarAnimationController* |
| 3717 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( | 3714 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( |
| 3718 ElementId scroll_element_id) const { | 3715 ElementId scroll_element_id) const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3739 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); | 3736 TRACE_EVENT0("cc", "LayerTreeHostImpl::SetNeedsAnimateForScrollbarAnimation"); |
| 3740 SetNeedsOneBeginImplFrame(); | 3737 SetNeedsOneBeginImplFrame(); |
| 3741 } | 3738 } |
| 3742 | 3739 |
| 3743 // TODO(danakj): Make this a return value from the Animate() call instead of an | 3740 // TODO(danakj): Make this a return value from the Animate() call instead of an |
| 3744 // interface on LTHI. (Also, crbug.com/551138.) | 3741 // interface on LTHI. (Also, crbug.com/551138.) |
| 3745 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { | 3742 void LayerTreeHostImpl::SetNeedsRedrawForScrollbarAnimation() { |
| 3746 SetNeedsRedraw(); | 3743 SetNeedsRedraw(); |
| 3747 } | 3744 } |
| 3748 | 3745 |
| 3749 ScrollbarSet LayerTreeHostImpl::ScrollbarsFor(int scroll_layer_id) const { | 3746 ScrollbarSet LayerTreeHostImpl::ScrollbarsFor(ElementId id) const { |
| 3750 return active_tree_->ScrollbarsFor(scroll_layer_id); | 3747 return active_tree_->ScrollbarsFor(id); |
| 3751 } | 3748 } |
| 3752 | 3749 |
| 3753 void LayerTreeHostImpl::AddVideoFrameController( | 3750 void LayerTreeHostImpl::AddVideoFrameController( |
| 3754 VideoFrameController* controller) { | 3751 VideoFrameController* controller) { |
| 3755 bool was_empty = video_frame_controllers_.empty(); | 3752 bool was_empty = video_frame_controllers_.empty(); |
| 3756 video_frame_controllers_.insert(controller); | 3753 video_frame_controllers_.insert(controller); |
| 3757 if (current_begin_frame_tracker_.DangerousMethodHasStarted() && | 3754 if (current_begin_frame_tracker_.DangerousMethodHasStarted() && |
| 3758 !current_begin_frame_tracker_.DangerousMethodHasFinished()) | 3755 !current_begin_frame_tracker_.DangerousMethodHasFinished()) |
| 3759 controller->OnBeginFrame(current_begin_frame_tracker_.Current()); | 3756 controller->OnBeginFrame(current_begin_frame_tracker_.Current()); |
| 3760 if (was_empty) | 3757 if (was_empty) |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4303 } | 4300 } |
| 4304 | 4301 |
| 4305 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { | 4302 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { |
| 4306 if (is_wheel_scroll) | 4303 if (is_wheel_scroll) |
| 4307 has_scrolled_by_wheel_ = true; | 4304 has_scrolled_by_wheel_ = true; |
| 4308 else | 4305 else |
| 4309 has_scrolled_by_touch_ = true; | 4306 has_scrolled_by_touch_ = true; |
| 4310 } | 4307 } |
| 4311 | 4308 |
| 4312 } // namespace cc | 4309 } // namespace cc |
| OLD | NEW |