| 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 3524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 tree_impl->InnerViewportScrollLayer() | 3535 tree_impl->InnerViewportScrollLayer() |
| 3536 ? tree_impl->InnerViewportScrollLayer()->id() | 3536 ? tree_impl->InnerViewportScrollLayer()->id() |
| 3537 : Layer::INVALID_ID; | 3537 : Layer::INVALID_ID; |
| 3538 | 3538 |
| 3539 tree_impl->property_trees()->scroll_tree.CollectScrollDeltas( | 3539 tree_impl->property_trees()->scroll_tree.CollectScrollDeltas( |
| 3540 scroll_info, inner_viewport_layer_id); | 3540 scroll_info, inner_viewport_layer_id); |
| 3541 } | 3541 } |
| 3542 | 3542 |
| 3543 static void CollectScrollbarUpdates( | 3543 static void CollectScrollbarUpdates( |
| 3544 ScrollAndScaleSet* scroll_info, | 3544 ScrollAndScaleSet* scroll_info, |
| 3545 std::unordered_map<ElementId, | 3545 std::unordered_map<ElementId::Id, |
| 3546 std::unique_ptr<ScrollbarAnimationController>, | 3546 std::unique_ptr<ScrollbarAnimationController>>* |
| 3547 ElementIdHash>* controllers) { | 3547 controllers) { |
| 3548 scroll_info->scrollbars.reserve(controllers->size()); | 3548 scroll_info->scrollbars.reserve(controllers->size()); |
| 3549 for (auto& pair : *controllers) { | 3549 for (auto& pair : *controllers) { |
| 3550 ElementId element_id; |
| 3551 element_id.id = pair.first; |
| 3550 scroll_info->scrollbars.push_back(LayerTreeHostCommon::ScrollbarsUpdateInfo( | 3552 scroll_info->scrollbars.push_back(LayerTreeHostCommon::ScrollbarsUpdateInfo( |
| 3551 pair.first, pair.second->ScrollbarsHidden())); | 3553 element_id, pair.second->ScrollbarsHidden())); |
| 3552 } | 3554 } |
| 3553 } | 3555 } |
| 3554 | 3556 |
| 3555 std::unique_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 3557 std::unique_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
| 3556 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 3558 std::unique_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
| 3557 | 3559 |
| 3558 CollectScrollDeltas(scroll_info.get(), active_tree_.get()); | 3560 CollectScrollDeltas(scroll_info.get(), active_tree_.get()); |
| 3559 CollectScrollbarUpdates(scroll_info.get(), &scrollbar_animation_controllers_); | 3561 CollectScrollbarUpdates(scroll_info.get(), &scrollbar_animation_controllers_); |
| 3560 scroll_info->page_scale_delta = | 3562 scroll_info->page_scale_delta = |
| 3561 active_tree_->page_scale_factor()->PullDeltaForMainThread(); | 3563 active_tree_->page_scale_factor()->PullDeltaForMainThread(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3687 return str; | 3689 return str; |
| 3688 } | 3690 } |
| 3689 | 3691 |
| 3690 void LayerTreeHostImpl::RegisterScrollbarAnimationController( | 3692 void LayerTreeHostImpl::RegisterScrollbarAnimationController( |
| 3691 ElementId scroll_element_id) { | 3693 ElementId scroll_element_id) { |
| 3692 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) | 3694 if (settings().scrollbar_animator == LayerTreeSettings::NO_ANIMATOR) |
| 3693 return; | 3695 return; |
| 3694 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) | 3696 if (ScrollbarAnimationControllerForElementId(scroll_element_id)) |
| 3695 return; | 3697 return; |
| 3696 | 3698 |
| 3697 scrollbar_animation_controllers_[scroll_element_id] = | 3699 scrollbar_animation_controllers_[scroll_element_id.id] = |
| 3698 active_tree_->CreateScrollbarAnimationController(scroll_element_id); | 3700 active_tree_->CreateScrollbarAnimationController(scroll_element_id); |
| 3699 } | 3701 } |
| 3700 | 3702 |
| 3701 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( | 3703 void LayerTreeHostImpl::UnregisterScrollbarAnimationController( |
| 3702 ElementId scroll_element_id) { | 3704 ElementId scroll_element_id) { |
| 3703 scrollbar_animation_controllers_.erase(scroll_element_id); | 3705 scrollbar_animation_controllers_.erase(scroll_element_id.id); |
| 3704 } | 3706 } |
| 3705 | 3707 |
| 3706 ScrollbarAnimationController* | 3708 ScrollbarAnimationController* |
| 3707 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( | 3709 LayerTreeHostImpl::ScrollbarAnimationControllerForElementId( |
| 3708 ElementId scroll_element_id) const { | 3710 ElementId scroll_element_id) const { |
| 3709 // The viewport layers have only one set of scrollbars and their controller | 3711 // The viewport layers have only one set of scrollbars and their controller |
| 3710 // is registered with the outer viewport. | 3712 // is registered with the outer viewport. |
| 3711 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && | 3713 if (InnerViewportScrollLayer() && OuterViewportScrollLayer() && |
| 3712 scroll_element_id == InnerViewportScrollLayer()->element_id()) | 3714 scroll_element_id == InnerViewportScrollLayer()->element_id()) |
| 3713 scroll_element_id = OuterViewportScrollLayer()->element_id(); | 3715 scroll_element_id = OuterViewportScrollLayer()->element_id(); |
| 3714 auto i = scrollbar_animation_controllers_.find(scroll_element_id); | 3716 auto i = scrollbar_animation_controllers_.find(scroll_element_id.id); |
| 3715 if (i == scrollbar_animation_controllers_.end()) | 3717 if (i == scrollbar_animation_controllers_.end()) |
| 3716 return nullptr; | 3718 return nullptr; |
| 3717 return i->second.get(); | 3719 return i->second.get(); |
| 3718 } | 3720 } |
| 3719 | 3721 |
| 3720 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( | 3722 void LayerTreeHostImpl::PostDelayedScrollbarAnimationTask( |
| 3721 const base::Closure& task, | 3723 const base::Closure& task, |
| 3722 base::TimeDelta delay) { | 3724 base::TimeDelta delay) { |
| 3723 client_->PostDelayedAnimationTaskOnImplThread(task, delay); | 3725 client_->PostDelayedAnimationTaskOnImplThread(task, delay); |
| 3724 } | 3726 } |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4298 | 4300 |
| 4299 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { | 4301 void LayerTreeHostImpl::ShowScrollbarsForImplScroll(ElementId element_id) { |
| 4300 if (!element_id) | 4302 if (!element_id) |
| 4301 return; | 4303 return; |
| 4302 if (ScrollbarAnimationController* animation_controller = | 4304 if (ScrollbarAnimationController* animation_controller = |
| 4303 ScrollbarAnimationControllerForElementId(element_id)) | 4305 ScrollbarAnimationControllerForElementId(element_id)) |
| 4304 animation_controller->DidScrollUpdate(); | 4306 animation_controller->DidScrollUpdate(); |
| 4305 } | 4307 } |
| 4306 | 4308 |
| 4307 } // namespace cc | 4309 } // namespace cc |
| OLD | NEW |