Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2824693002: Refactor LayerTreeImpl's scrollbar map to be keyed on element ids (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698