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

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

Issue 1223713004: Cleanup viewport scrolling for future scroll customization work. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix value of report_overscroll_only_for_scrollable_axes on Aura. Created 5 years, 5 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 | « no previous file | cc/layers/viewport.cc » ('j') | cc/trees/layer_tree_host_impl.cc » ('J')
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 #ifndef CC_LAYERS_VIEWPORT_H_ 5 #ifndef CC_LAYERS_VIEWPORT_H_
6 #define CC_LAYERS_VIEWPORT_H_ 6 #define CC_LAYERS_VIEWPORT_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/layers/layer_impl.h" 9 #include "cc/layers/layer_impl.h"
10 #include "ui/gfx/geometry/vector2d_f.h" 10 #include "ui/gfx/geometry/vector2d_f.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 class LayerTreeHostImpl; 14 class LayerTreeHostImpl;
15 15
16 // Encapsulates gesture handling logic on the viewport layers. The "viewport" 16 // Encapsulates gesture handling logic on the viewport layers. The "viewport"
17 // is made up of two scrolling layers, the inner viewport (visual) and the 17 // is made up of two scrolling layers, the inner viewport (visual) and the
18 // outer viewport (layout) scroll layers. These layers have different scroll 18 // outer viewport (layout) scroll layers. These layers have different scroll
19 // bubbling behavior from the rest of the layer tree which is encoded in this 19 // bubbling behavior from the rest of the layer tree which is encoded in this
20 // class. 20 // class.
21 class CC_EXPORT Viewport { 21 class CC_EXPORT Viewport {
22 public: 22 public:
23 // If the pinch zoom anchor on the first PinchUpdate is within this length 23 // If the pinch zoom anchor on the first PinchUpdate is within this length
24 // of the screen edge, "snap" the zoom to that edge. Experimentally 24 // of the screen edge, "snap" the zoom to that edge. Experimentally
25 // determined. 25 // determined.
26 static const int kPinchZoomSnapMarginDips = 100; 26 static const int kPinchZoomSnapMarginDips = 100;
27 27
28 struct ScrollResult {
29 gfx::Vector2dF applied_delta;
30 gfx::Vector2dF unused_scroll_delta;
31 gfx::Vector2dF top_controls_applied_delta;
32 };
33
34 static scoped_ptr<Viewport> Create(LayerTreeHostImpl* host_impl); 28 static scoped_ptr<Viewport> Create(LayerTreeHostImpl* host_impl);
35 29
36 // Differs from scrolling in that only the visual viewport is moved, without 30 // Differs from scrolling in that only the visual viewport is moved, without
37 // affecting the top controls or outer viewport. 31 // affecting the top controls or outer viewport.
38 void Pan(const gfx::Vector2dF& delta); 32 void Pan(const gfx::Vector2dF& delta);
39 33
40 // Scrolls the viewport, applying the unique bubbling between the inner and 34 // Scrolls the viewport, applying the unique bubbling between the inner and
41 // outer viewport. Scrolls can be consumed by top controls. 35 // outer viewport. Scrolls can be consumed by top controls.
42 ScrollResult ScrollBy(const gfx::Vector2dF& delta, 36 gfx::Vector2dF ScrollBy(const gfx::Vector2dF& delta,
43 const gfx::Point& viewport_point, 37 const gfx::Point& viewport_point,
44 bool is_wheel_scroll, 38 bool is_direct_manipulation,
45 bool affect_top_controls); 39 bool affect_top_controls);
46 40
47 void PinchUpdate(float magnify_delta, const gfx::Point& anchor); 41 void PinchUpdate(float magnify_delta, const gfx::Point& anchor);
48 void PinchEnd(); 42 void PinchEnd();
49 43
50 private: 44 private:
51 explicit Viewport(LayerTreeHostImpl* host_impl); 45 explicit Viewport(LayerTreeHostImpl* host_impl);
52 46
53 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const; 47 bool ShouldTopControlsConsumeScroll(const gfx::Vector2dF& scroll_delta) const;
54 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const; 48 gfx::Vector2dF AdjustOverscroll(const gfx::Vector2dF& delta) const;
55 49
(...skipping 15 matching lines...) Expand all
71 // The pinch zoom anchor point is adjusted by this amount during a pinch. This 65 // The pinch zoom anchor point is adjusted by this amount during a pinch. This
72 // is used to "snap" a pinch-zoom to the edge of the screen. 66 // is used to "snap" a pinch-zoom to the edge of the screen.
73 gfx::Vector2d pinch_anchor_adjustment_; 67 gfx::Vector2d pinch_anchor_adjustment_;
74 68
75 DISALLOW_COPY_AND_ASSIGN(Viewport); 69 DISALLOW_COPY_AND_ASSIGN(Viewport);
76 }; 70 };
77 71
78 } // namespace cc 72 } // namespace cc
79 73
80 #endif // CC_LAYERS_VIEWPORT_H_ 74 #endif // CC_LAYERS_VIEWPORT_H_
OLDNEW
« no previous file with comments | « no previous file | cc/layers/viewport.cc » ('j') | cc/trees/layer_tree_host_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698