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

Side by Side Diff: cc/layers/viewport.cc

Issue 2443613002: Rename classes related to top controls (Closed)
Patch Set: fix test Created 4 years, 1 month 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/layers/viewport.h ('k') | cc/proto/layer_tree.proto » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/layers/viewport.h" 5 #include "cc/layers/viewport.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "cc/input/top_controls_manager.h" 9 #include "cc/input/browser_controls_offset_manager.h"
10 #include "cc/trees/layer_tree_host_impl.h" 10 #include "cc/trees/layer_tree_host_impl.h"
11 #include "cc/trees/layer_tree_impl.h" 11 #include "cc/trees/layer_tree_impl.h"
12 #include "cc/trees/scroll_node.h" 12 #include "cc/trees/scroll_node.h"
13 #include "ui/gfx/geometry/vector2d_conversions.h" 13 #include "ui/gfx/geometry/vector2d_conversions.h"
14 #include "ui/gfx/geometry/vector2d_f.h" 14 #include "ui/gfx/geometry/vector2d_f.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 // static 18 // static
19 std::unique_ptr<Viewport> Viewport::Create(LayerTreeHostImpl* host_impl) { 19 std::unique_ptr<Viewport> Viewport::Create(LayerTreeHostImpl* host_impl) {
(...skipping 15 matching lines...) Expand all
35 35
36 Viewport::ScrollResult Viewport::ScrollBy(const gfx::Vector2dF& delta, 36 Viewport::ScrollResult Viewport::ScrollBy(const gfx::Vector2dF& delta,
37 const gfx::Point& viewport_point, 37 const gfx::Point& viewport_point,
38 bool is_direct_manipulation, 38 bool is_direct_manipulation,
39 bool affect_top_controls) { 39 bool affect_top_controls) {
40 if (!OuterScrollLayer()) 40 if (!OuterScrollLayer())
41 return ScrollResult(); 41 return ScrollResult();
42 42
43 gfx::Vector2dF content_delta = delta; 43 gfx::Vector2dF content_delta = delta;
44 44
45 if (affect_top_controls && ShouldTopControlsConsumeScroll(delta)) 45 if (affect_top_controls && ShouldBrowserControlsConsumeScroll(delta))
46 content_delta -= ScrollTopControls(delta); 46 content_delta -= ScrollBrowserControls(delta);
47 47
48 gfx::Vector2dF pending_content_delta = content_delta; 48 gfx::Vector2dF pending_content_delta = content_delta;
49 49
50 ScrollTree& scroll_tree = 50 ScrollTree& scroll_tree =
51 host_impl_->active_tree()->property_trees()->scroll_tree; 51 host_impl_->active_tree()->property_trees()->scroll_tree;
52 ScrollNode* inner_node = 52 ScrollNode* inner_node =
53 scroll_tree.Node(InnerScrollLayer()->scroll_tree_index()); 53 scroll_tree.Node(InnerScrollLayer()->scroll_tree_index());
54 pending_content_delta -= host_impl_->ScrollSingleNode( 54 pending_content_delta -= host_impl_->ScrollSingleNode(
55 inner_node, pending_content_delta, viewport_point, is_direct_manipulation, 55 inner_node, pending_content_delta, viewport_point, is_direct_manipulation,
56 &scroll_tree); 56 &scroll_tree);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 void Viewport::PinchEnd() { 192 void Viewport::PinchEnd() {
193 pinch_anchor_adjustment_ = gfx::Vector2d(); 193 pinch_anchor_adjustment_ = gfx::Vector2d();
194 pinch_zoom_active_ = false; 194 pinch_zoom_active_ = false;
195 } 195 }
196 196
197 LayerImpl* Viewport::MainScrollLayer() const { 197 LayerImpl* Viewport::MainScrollLayer() const {
198 return OuterScrollLayer(); 198 return OuterScrollLayer();
199 } 199 }
200 200
201 gfx::Vector2dF Viewport::ScrollTopControls(const gfx::Vector2dF& delta) { 201 gfx::Vector2dF Viewport::ScrollBrowserControls(const gfx::Vector2dF& delta) {
202 gfx::Vector2dF excess_delta = 202 gfx::Vector2dF excess_delta =
203 host_impl_->top_controls_manager()->ScrollBy(delta); 203 host_impl_->browser_controls_manager()->ScrollBy(delta);
204 204
205 return delta - excess_delta; 205 return delta - excess_delta;
206 } 206 }
207 207
208 bool Viewport::ShouldTopControlsConsumeScroll( 208 bool Viewport::ShouldBrowserControlsConsumeScroll(
209 const gfx::Vector2dF& scroll_delta) const { 209 const gfx::Vector2dF& scroll_delta) const {
210 // Always consume if it's in the direction to show the top controls. 210 // Always consume if it's in the direction to show the browser controls.
211 if (scroll_delta.y() < 0) 211 if (scroll_delta.y() < 0)
212 return true; 212 return true;
213 213
214 if (TotalScrollOffset().y() < MaxTotalScrollOffset().y()) 214 if (TotalScrollOffset().y() < MaxTotalScrollOffset().y())
215 return true; 215 return true;
216 216
217 return false; 217 return false;
218 } 218 }
219 219
220 gfx::Vector2dF Viewport::AdjustOverscroll(const gfx::Vector2dF& delta) const { 220 gfx::Vector2dF Viewport::AdjustOverscroll(const gfx::Vector2dF& delta) const {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 LayerImpl* Viewport::InnerScrollLayer() const { 256 LayerImpl* Viewport::InnerScrollLayer() const {
257 return host_impl_->InnerViewportScrollLayer(); 257 return host_impl_->InnerViewportScrollLayer();
258 } 258 }
259 259
260 LayerImpl* Viewport::OuterScrollLayer() const { 260 LayerImpl* Viewport::OuterScrollLayer() const {
261 return host_impl_->OuterViewportScrollLayer(); 261 return host_impl_->OuterViewportScrollLayer();
262 } 262 }
263 263
264 } // namespace cc 264 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/viewport.h ('k') | cc/proto/layer_tree.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698