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