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

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

Issue 2708493002: Refactor scroll chaining to use ScrollNodes without going through LayerImpl (Closed)
Patch Set: Created 3 years, 10 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
« cc/input/scroll_state.h ('K') | « cc/layers/layer_impl.cc ('k') | no next file » | 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 2992 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 return ScrollNodeWithViewportSpaceDelta( 3003 return ScrollNodeWithViewportSpaceDelta(
3004 scroll_node, gfx::PointF(viewport_point), delta, scroll_tree); 3004 scroll_node, gfx::PointF(viewport_point), delta, scroll_tree);
3005 } 3005 }
3006 float scale_factor = active_tree()->current_page_scale_factor(); 3006 float scale_factor = active_tree()->current_page_scale_factor();
3007 return ScrollNodeWithLocalDelta(scroll_node, delta, scale_factor, 3007 return ScrollNodeWithLocalDelta(scroll_node, delta, scale_factor,
3008 active_tree()); 3008 active_tree());
3009 } 3009 }
3010 3010
3011 void LayerTreeHostImpl::ApplyScroll(ScrollNode* scroll_node, 3011 void LayerTreeHostImpl::ApplyScroll(ScrollNode* scroll_node,
3012 ScrollState* scroll_state) { 3012 ScrollState* scroll_state) {
3013 DCHECK(scroll_state); 3013 DCHECK(scroll_node && scroll_state);
3014 gfx::Point viewport_point(scroll_state->position_x(), 3014 gfx::Point viewport_point(scroll_state->position_x(),
3015 scroll_state->position_y()); 3015 scroll_state->position_y());
3016 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); 3016 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y());
3017 gfx::Vector2dF applied_delta; 3017 gfx::Vector2dF applied_delta;
3018 gfx::Vector2dF delta_applied_to_content; 3018 gfx::Vector2dF delta_applied_to_content;
3019 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for 3019 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for
3020 // details. 3020 // details.
3021 const float kEpsilon = 0.1f; 3021 const float kEpsilon = 0.1f;
3022 3022
3023 bool is_viewport_scroll_layer = 3023 bool is_viewport_scroll_layer =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 3081 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
3082 3082
3083 scroll_state->set_current_native_scrolling_node(scroll_node); 3083 scroll_state->set_current_native_scrolling_node(scroll_node);
3084 } 3084 }
3085 3085
3086 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) { 3086 void LayerTreeHostImpl::DistributeScrollDelta(ScrollState* scroll_state) {
3087 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which 3087 // TODO(majidvp): in Blink we compute scroll chain only at scroll begin which
3088 // is not the case here. We eventually want to have the same behaviour on both 3088 // is not the case here. We eventually want to have the same behaviour on both
3089 // sides but it may become a non issue if we get rid of scroll chaining (see 3089 // sides but it may become a non issue if we get rid of scroll chaining (see
3090 // crbug.com/526462) 3090 // crbug.com/526462)
3091 std::list<const ScrollNode*> current_scroll_chain; 3091 std::list<ScrollNode*> current_scroll_chain;
3092 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 3092 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3093 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 3093 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
3094 ScrollNode* viewport_scroll_node = 3094 ScrollNode* viewport_scroll_node =
3095 viewport()->MainScrollLayer() 3095 viewport()->MainScrollLayer()
3096 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index()) 3096 ? scroll_tree.Node(viewport()->MainScrollLayer()->scroll_tree_index())
3097 : nullptr; 3097 : nullptr;
3098 if (scroll_node) { 3098 if (scroll_node) {
3099 // TODO(bokan): The loop checks for a null parent but don't we still want to 3099 // TODO(bokan): The loop checks for a null parent but don't we still want to
3100 // distribute to the root scroll node? 3100 // distribute to the root scroll node?
3101 for (; scroll_tree.parent(scroll_node); 3101 for (; scroll_tree.parent(scroll_node);
3102 scroll_node = scroll_tree.parent(scroll_node)) { 3102 scroll_node = scroll_tree.parent(scroll_node)) {
3103 if (scroll_node == viewport_scroll_node) { 3103 if (scroll_node == viewport_scroll_node) {
3104 // Don't chain scrolls past the outer viewport scroll layer. Once we 3104 // Don't chain scrolls past the outer viewport scroll layer. Once we
3105 // reach that, we should scroll the viewport which is represented by the 3105 // reach that, we should scroll the viewport which is represented by the
3106 // main viewport scroll layer. 3106 // main viewport scroll layer.
3107 DCHECK(viewport_scroll_node); 3107 DCHECK(viewport_scroll_node);
3108 current_scroll_chain.push_front(viewport_scroll_node); 3108 current_scroll_chain.push_front(viewport_scroll_node);
3109 break; 3109 break;
3110 } 3110 }
3111 3111
3112 if (!scroll_node->scrollable) 3112 if (!scroll_node->scrollable)
3113 continue; 3113 continue;
3114 3114
3115 current_scroll_chain.push_front(scroll_node); 3115 current_scroll_chain.push_front(scroll_node);
3116 } 3116 }
3117 } 3117 }
3118 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, 3118 scroll_state->set_scroll_chain_and_layer_tree(&current_scroll_chain,
3119 active_tree()); 3119 active_tree());
3120 scroll_state->DistributeToScrollChainDescendant(); 3120 scroll_state->DistributeToScrollChainDescendant();
3121 } 3121 }
3122 3122
3123 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( 3123 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
3124 ScrollState* scroll_state) { 3124 ScrollState* scroll_state) {
3125 DCHECK(scroll_state); 3125 DCHECK(scroll_state);
3126 3126
3127 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy"); 3127 TRACE_EVENT0("cc", "LayerTreeHostImpl::ScrollBy");
3128 if (!CurrentlyScrollingLayer()) 3128 if (!CurrentlyScrollingLayer())
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
4116 worker_context_visibility_ = 4116 worker_context_visibility_ =
4117 worker_context->CacheController()->ClientBecameVisible(); 4117 worker_context->CacheController()->ClientBecameVisible();
4118 } else { 4118 } else {
4119 worker_context->CacheController()->ClientBecameNotVisible( 4119 worker_context->CacheController()->ClientBecameNotVisible(
4120 std::move(worker_context_visibility_)); 4120 std::move(worker_context_visibility_));
4121 } 4121 }
4122 } 4122 }
4123 } 4123 }
4124 4124
4125 } // namespace cc 4125 } // namespace cc
OLDNEW
« cc/input/scroll_state.h ('K') | « cc/layers/layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698