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

Side by Side Diff: cc/input/scroll_state.h

Issue 1215183004: Arrange compositor scrolling into scroll customization format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit. Created 5 years, 4 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/cc_tests.gyp ('k') | cc/input/scroll_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_INPUT_SCROLL_STATE_H_
6 #define CC_INPUT_SCROLL_STATE_H_
7
8 #include <list>
9
10 #include "cc/base/cc_export.h"
11
12 namespace cc {
13
14 class LayerImpl;
15
16 // ScrollState is based on the proposal for scroll customization in blink, found
17 // here: https://goo.gl/1ipTpP.
18 class CC_EXPORT ScrollState {
19 public:
20 ScrollState(double delta_x,
21 double delta_y,
22 int start_position_x,
23 int start_position_y,
24 bool should_propagate,
25 bool delta_consumed_for_scroll_sequence,
26 bool is_direct_manipulation);
27 ~ScrollState();
28
29 // Reduce deltas by x, y.
30 void ConsumeDelta(double x, double y);
31 // Pops the first layer off of |scroll_chain_| and calls
32 // |DistributeScroll| on it.
33 void DistributeToScrollChainDescendant();
34 // Positive when scrolling left.
35 double delta_x() const { return delta_x_; }
36 // Positive when scrolling up.
37 double delta_y() const { return delta_y_; }
38 // The location the scroll started at. For touch, the starting
39 // position of the finger. For mouse, the location of the cursor.
40 int start_position_x() const { return start_position_x_; }
41 int start_position_y() const { return start_position_y_; }
42
43 // True if this scroll is allowed to bubble upwards.
44 bool should_propagate() const { return should_propagate_; }
45 // True if the user interacts directly with the screen, e.g., via touch.
46 bool is_direct_manipulation() const { return is_direct_manipulation_; }
47
48 void set_scroll_chain(const std::list<LayerImpl*>& scroll_chain) {
49 scroll_chain_ = scroll_chain;
50 }
51
52 void set_current_native_scrolling_layer(LayerImpl* layer) {
53 current_native_scrolling_layer_ = layer;
54 }
55
56 LayerImpl* current_native_scrolling_layer() const {
57 return current_native_scrolling_layer_;
58 }
59
60 bool delta_consumed_for_scroll_sequence() const {
61 return delta_consumed_for_scroll_sequence_;
62 }
63
64 bool FullyConsumed() const { return !delta_x_ && !delta_y_; }
65
66 void set_caused_scroll(bool x, bool y) {
67 caused_scroll_x_ |= x;
68 caused_scroll_y_ |= y;
69 }
70
71 bool caused_scroll_x() const { return caused_scroll_x_; }
72 bool caused_scroll_y() const { return caused_scroll_y_; }
73
74 private:
75 ScrollState();
76 double delta_x_;
77 double delta_y_;
78 double start_position_x_;
79 double start_position_y_;
80
81 bool should_propagate_;
82
83 // The last layer to respond to a scroll, or null if none exists.
84 LayerImpl* current_native_scrolling_layer_;
85 // Whether the scroll sequence has had any delta consumed, in the
86 // current frame, or any child frames.
87 bool delta_consumed_for_scroll_sequence_;
88 // True if the user interacts directly with the display, e.g., via
89 // touch.
90 bool is_direct_manipulation_;
91 // TODO(tdresser): ScrollState shouldn't need to keep track of whether or not
92 // this ScrollState object has caused a scroll. Ideally, any native scroller
93 // consuming delta has caused a scroll. Currently, there are some cases where
94 // we consume delta without scrolling, such as in
95 // |Viewport::AdjustOverscroll|. Once these cases are fixed, we should get rid
96 // of |caused_scroll_*_|. See crbug.com/510045 for details.
97 bool caused_scroll_x_;
98 bool caused_scroll_y_;
99
100 // TODO(tdresser): Change LayerImpl* to an abstract scrollable type. See
101 // crbug.com/476553 for detail on the effort to unify impl and main thread
102 // scrolling, which will require an abstract scrollable type.
103 std::list<LayerImpl*> scroll_chain_;
104 };
105
106 } // namespace cc
107
108 #endif // CC_INPUT_SCROLL_STATE_H_
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/input/scroll_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698