OLD | NEW |
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_INPUT_SCROLL_STATE_DATA_H_ | 5 #ifndef CC_INPUT_SCROLL_STATE_DATA_H_ |
6 #define CC_INPUT_SCROLL_STATE_DATA_H_ | 6 #define CC_INPUT_SCROLL_STATE_DATA_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <list> | 10 #include <list> |
9 | 11 |
10 #include "cc/base/cc_export.h" | 12 #include "cc/base/cc_export.h" |
11 | 13 |
12 namespace cc { | 14 namespace cc { |
13 | 15 |
14 class LayerImpl; | 16 class LayerImpl; |
15 | 17 |
16 struct CC_EXPORT ScrollStateData { | 18 class CC_EXPORT ScrollStateData { |
17 public: | 19 public: |
18 ScrollStateData(); | 20 ScrollStateData(); |
19 ScrollStateData(double delta_x, | 21 |
20 double delta_y, | |
21 int start_position_x, | |
22 int start_position_y, | |
23 double velocity_x, | |
24 double velocity_y, | |
25 bool is_beginning, | |
26 bool is_in_inertial_phase, | |
27 bool is_ending, | |
28 bool should_propagate, | |
29 bool delta_consumed_for_scroll_sequence, | |
30 bool is_direct_manipulation); | |
31 // Scroll delta in viewport coordinates (DIP). | 22 // Scroll delta in viewport coordinates (DIP). |
32 double delta_x; | 23 double delta_x; |
33 double delta_y; | 24 double delta_y; |
34 // Scroll position in viewport coordinates (DIP). | 25 // Scroll position in viewport coordinates (DIP). |
35 int start_position_x; | 26 int start_position_x; |
36 int start_position_y; | 27 int start_position_y; |
37 // Scroll velocity in DIP/seconds. | 28 // Scroll velocity in DIP/seconds. |
38 double velocity_x; | 29 double velocity_x; |
39 double velocity_y; | 30 double velocity_y; |
40 | 31 |
41 bool is_beginning; | 32 bool is_beginning; |
42 bool is_in_inertial_phase; | 33 bool is_in_inertial_phase; |
43 bool is_ending; | 34 bool is_ending; |
44 | 35 |
45 bool should_propagate; | 36 bool should_propagate; |
| 37 bool from_user_input; |
46 | 38 |
47 // The last layer to respond to a scroll, or null if none exists. | |
48 LayerImpl* current_native_scrolling_layer; | |
49 // Whether the scroll sequence has had any delta consumed, in the | 39 // Whether the scroll sequence has had any delta consumed, in the |
50 // current frame, or any child frames. | 40 // current frame, or any child frames. |
51 bool delta_consumed_for_scroll_sequence; | 41 bool delta_consumed_for_scroll_sequence; |
52 // True if the user interacts directly with the display, e.g., via | 42 // True if the user interacts directly with the display, e.g., via |
53 // touch. | 43 // touch. |
54 bool is_direct_manipulation; | 44 bool is_direct_manipulation; |
| 45 // Minimum amount this input device can scroll. |
| 46 double delta_granularity; |
| 47 |
55 // TODO(tdresser): ScrollState shouldn't need to keep track of whether or not | 48 // TODO(tdresser): ScrollState shouldn't need to keep track of whether or not |
56 // this ScrollState object has caused a scroll. Ideally, any native scroller | 49 // this ScrollState object has caused a scroll. Ideally, any native scroller |
57 // consuming delta has caused a scroll. Currently, there are some cases where | 50 // consuming delta has caused a scroll. Currently, there are some cases where |
58 // we consume delta without scrolling, such as in | 51 // we consume delta without scrolling, such as in |
59 // |Viewport::AdjustOverscroll|. Once these cases are fixed, we should get rid | 52 // |Viewport::AdjustOverscroll|. Once these cases are fixed, we should get rid |
60 // of |caused_scroll_*_|. See crbug.com/510045 for details. | 53 // of |caused_scroll_*_|. See crbug.com/510045 for details. |
61 bool caused_scroll_x; | 54 bool caused_scroll_x; |
62 bool caused_scroll_y; | 55 bool caused_scroll_y; |
| 56 |
| 57 LayerImpl* current_native_scrolling_layer() const; |
| 58 void set_current_native_scrolling_layer( |
| 59 LayerImpl* current_native_scrolling_layer); |
| 60 uint64_t current_native_scrolling_element() const; |
| 61 void set_current_native_scrolling_element(uint64_t element_id); |
| 62 |
| 63 private: |
| 64 // Only one of current_native_scrolling_layer_ and |
| 65 // current_native_scrolling_element_ may be non-null at a time. Whenever |
| 66 // possible, we should store the layer. |
| 67 |
| 68 // The last layer to respond to a scroll, or null if none exists. |
| 69 LayerImpl* current_native_scrolling_layer_; |
| 70 // The id of the last native element to respond to a scroll, or 0 if none |
| 71 // exists. |
| 72 uint64_t current_native_scrolling_element_; |
63 }; | 73 }; |
64 | 74 |
65 } // namespace cc | 75 } // namespace cc |
66 | 76 |
67 #endif // CC_INPUT_SCROLL_STATE_DATA_H_ | 77 #endif // CC_INPUT_SCROLL_STATE_DATA_H_ |
OLD | NEW |