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

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

Issue 2714713003: Rename cc::ScrollNode's inner and outer viewport members (Closed)
Patch Set: Created 3 years, 9 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_common_unittest.cc ('k') | cc/trees/property_tree.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 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 !impl_scroll_node) { 2593 !impl_scroll_node) {
2594 impl_scroll_node = scroll_node; 2594 impl_scroll_node = scroll_node;
2595 } 2595 }
2596 } 2596 }
2597 } 2597 }
2598 2598
2599 // Falling back to the viewport layer ensures generation of root overscroll 2599 // Falling back to the viewport layer ensures generation of root overscroll
2600 // notifications. We use the viewport's main scroll layer to represent the 2600 // notifications. We use the viewport's main scroll layer to represent the
2601 // viewport in scrolling code. 2601 // viewport in scrolling code.
2602 bool scrolls_inner_viewport = 2602 bool scrolls_inner_viewport =
2603 impl_scroll_node && InnerViewportScrollLayer() && 2603 impl_scroll_node && impl_scroll_node->scrolls_inner_viewport;
2604 InnerViewportScrollLayer()->scroll_tree_index() == impl_scroll_node->id;
2605 bool scrolls_outer_viewport = 2604 bool scrolls_outer_viewport =
2606 impl_scroll_node && OuterViewportScrollLayer() && 2605 impl_scroll_node && impl_scroll_node->scrolls_outer_viewport;
2607 OuterViewportScrollLayer()->scroll_tree_index() == impl_scroll_node->id;
2608 if (!impl_scroll_node || scrolls_inner_viewport || scrolls_outer_viewport) { 2606 if (!impl_scroll_node || scrolls_inner_viewport || scrolls_outer_viewport) {
2609 if (auto* mainScrollLayer = viewport()->MainScrollLayer()) 2607 if (auto* mainScrollLayer = viewport()->MainScrollLayer())
2610 impl_scroll_node = scroll_tree.Node(mainScrollLayer->scroll_tree_index()); 2608 impl_scroll_node = scroll_tree.Node(mainScrollLayer->scroll_tree_index());
2611 else 2609 else
2612 impl_scroll_node = nullptr; 2610 impl_scroll_node = nullptr;
2613 } 2611 }
2614 2612
2615 if (impl_scroll_node) { 2613 if (impl_scroll_node) {
2616 // Ensure that final layer scrolls on impl thread (crbug.com/625100) 2614 // Ensure that final layer scrolls on impl thread (crbug.com/625100)
2617 ScrollStatus status = 2615 ScrollStatus status =
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
3041 3039
3042 bool scrolls_main_viewport_scroll_layer = 3040 bool scrolls_main_viewport_scroll_layer =
3043 viewport()->MainScrollLayer() && 3041 viewport()->MainScrollLayer() &&
3044 viewport()->MainScrollLayer()->scroll_tree_index() == scroll_node->id; 3042 viewport()->MainScrollLayer()->scroll_tree_index() == scroll_node->id;
3045 3043
3046 // This is needed if the scroll chains up to the viewport without going 3044 // This is needed if the scroll chains up to the viewport without going
3047 // through the outer viewport scroll node. This can happen if we scroll an 3045 // through the outer viewport scroll node. This can happen if we scroll an
3048 // element that's not a descendant of the document.rootScroller. In that case 3046 // element that's not a descendant of the document.rootScroller. In that case
3049 // we want to scroll the inner viewport -- to allow panning while zoomed -- 3047 // we want to scroll the inner viewport -- to allow panning while zoomed --
3050 // but also move browser controls if needed. 3048 // but also move browser controls if needed.
3051 bool scrolls_inner_viewport_layer = 3049 bool scrolls_inner_viewport = scroll_node->scrolls_inner_viewport;
3052 InnerViewportScrollLayer() &&
3053 InnerViewportScrollLayer()->scroll_tree_index() == scroll_node->id;
3054 3050
3055 if (scrolls_main_viewport_scroll_layer || scrolls_inner_viewport_layer) { 3051 if (scrolls_main_viewport_scroll_layer || scrolls_inner_viewport) {
3056 Viewport::ScrollResult result = viewport()->ScrollBy( 3052 Viewport::ScrollResult result = viewport()->ScrollBy(
3057 delta, viewport_point, scroll_state->is_direct_manipulation(), 3053 delta, viewport_point, scroll_state->is_direct_manipulation(),
3058 !wheel_scrolling_, scrolls_main_viewport_scroll_layer); 3054 !wheel_scrolling_, scrolls_main_viewport_scroll_layer);
3059 3055
3060 applied_delta = result.consumed_delta; 3056 applied_delta = result.consumed_delta;
3061 delta_applied_to_content = result.content_scrolled_delta; 3057 delta_applied_to_content = result.content_scrolled_delta;
3062 } else { 3058 } else {
3063 applied_delta = ScrollSingleNode( 3059 applied_delta = ScrollSingleNode(
3064 scroll_node, delta, viewport_point, 3060 scroll_node, delta, viewport_point,
3065 scroll_state->is_direct_manipulation(), 3061 scroll_state->is_direct_manipulation(),
3066 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); 3062 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree);
3067 } 3063 }
3068 3064
3069 // If the layer wasn't able to move, try the next one in the hierarchy. 3065 // If the layer wasn't able to move, try the next one in the hierarchy.
3070 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; 3066 bool scrolled = std::abs(applied_delta.x()) > kEpsilon;
3071 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; 3067 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon;
3072 if (!scrolled) { 3068 if (!scrolled) {
3073 // TODO(bokan): This preserves existing behavior by not allowing tiny 3069 // TODO(bokan): This preserves existing behavior by not allowing tiny
3074 // scrolls to produce overscroll but is inconsistent in how delta gets 3070 // scrolls to produce overscroll but is inconsistent in how delta gets
3075 // chained up. We need to clean this up. 3071 // chained up. We need to clean this up.
3076 if (scrolls_main_viewport_scroll_layer) 3072 if (scrolls_main_viewport_scroll_layer)
3077 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 3073 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
3078 return; 3074 return;
3079 } 3075 }
3080 3076
3081 if (!scrolls_main_viewport_scroll_layer && !scrolls_inner_viewport_layer) { 3077 if (!scrolls_main_viewport_scroll_layer && !scrolls_inner_viewport) {
3082 // If the applied delta is within 45 degrees of the input 3078 // If the applied delta is within 45 degrees of the input
3083 // delta, bail out to make it easier to scroll just one layer 3079 // delta, bail out to make it easier to scroll just one layer
3084 // in one direction without affecting any of its parents. 3080 // in one direction without affecting any of its parents.
3085 float angle_threshold = 45; 3081 float angle_threshold = 45;
3086 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < 3082 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) <
3087 angle_threshold) { 3083 angle_threshold) {
3088 applied_delta = delta; 3084 applied_delta = delta;
3089 } else { 3085 } else {
3090 // Allow further movement only on an axis perpendicular to the direction 3086 // Allow further movement only on an axis perpendicular to the direction
3091 // in which the layer moved. 3087 // in which the layer moved.
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 worker_context_visibility_ = 4138 worker_context_visibility_ =
4143 worker_context->CacheController()->ClientBecameVisible(); 4139 worker_context->CacheController()->ClientBecameVisible();
4144 } else { 4140 } else {
4145 worker_context->CacheController()->ClientBecameNotVisible( 4141 worker_context->CacheController()->ClientBecameNotVisible(
4146 std::move(worker_context_visibility_)); 4142 std::move(worker_context_visibility_));
4147 } 4143 }
4148 } 4144 }
4149 } 4145 }
4150 4146
4151 } // namespace cc 4147 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698