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

Side by Side Diff: ui/events/gesture_event_details.h

Issue 2605193002: Fix mouse wheel over-scrolls when display is scaled and scroll is paginated (Closed)
Patch Set: More unittests. Created 3 years, 10 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 | « ui/events/blink/blink_event_util_unittest.cc ('k') | ui/events/gesture_event_details.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ 5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ 6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_
7 7
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "ui/events/event_constants.h" 11 #include "ui/events/event_constants.h"
12 #include "ui/events/events_base_export.h" 12 #include "ui/events/events_base_export.h"
13 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/geometry/rect_conversions.h" 14 #include "ui/gfx/geometry/rect_conversions.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 struct EVENTS_BASE_EXPORT GestureEventDetails { 18 struct EVENTS_BASE_EXPORT GestureEventDetails {
19 public: 19 public:
20 // The definition of ScrollUnits below is consistent with that in
21 // //src/third_party/WebKit/public/platform/WebGestureEvent.h
22 enum class ScrollUnits {
23 PRECISE_PIXELS = 0, // generated by high precision devices.
24 PIXELS, // large pixel jump duration; should animate to delta.
sky 2017/02/17 22:52:31 Are you sure this isn't DIPs and what you are call
chengx 2017/02/17 23:19:18 I agree the names here, which originate from WebGe
25 PAGE // page (visible viewport) based scrolling.
26 };
27
20 GestureEventDetails(); 28 GestureEventDetails();
21 explicit GestureEventDetails(EventType type); 29 explicit GestureEventDetails(EventType type);
22 GestureEventDetails(EventType type, float delta_x, float delta_y); 30
31 // ScrollUnits::PRECISE_PIXELS is the default in WebGestureEvent.h too.
32 GestureEventDetails(EventType type,
33 float delta_x,
34 float delta_y,
35 ScrollUnits units = ScrollUnits::PRECISE_PIXELS);
23 36
24 // The caller is responsible for ensuring that the gesture data from |other| 37 // The caller is responsible for ensuring that the gesture data from |other|
25 // is compatible and sufficient for that expected by gestures of |type|. 38 // is compatible and sufficient for that expected by gestures of |type|.
26 GestureEventDetails(EventType type, const GestureEventDetails& other); 39 GestureEventDetails(EventType type, const GestureEventDetails& other);
27 40
28 EventType type() const { return type_; } 41 EventType type() const { return type_; }
29 42
30 GestureDeviceType device_type() const { return device_type_; } 43 GestureDeviceType device_type() const { return device_type_; }
31 void set_device_type(GestureDeviceType device_type) { 44 void set_device_type(GestureDeviceType device_type) {
32 device_type_ = device_type; 45 device_type_ = device_type;
(...skipping 18 matching lines...) Expand all
51 float scroll_x_hint() const { 64 float scroll_x_hint() const {
52 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); 65 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_);
53 return data_.scroll_begin.x_hint; 66 return data_.scroll_begin.x_hint;
54 } 67 }
55 68
56 float scroll_y_hint() const { 69 float scroll_y_hint() const {
57 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_); 70 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_);
58 return data_.scroll_begin.y_hint; 71 return data_.scroll_begin.y_hint;
59 } 72 }
60 73
74 ScrollUnits scroll_begin_units() const {
75 DCHECK_EQ(ET_GESTURE_SCROLL_BEGIN, type_);
76 return data_.scroll_begin.delta_hint_units;
77 }
78
61 float scroll_x() const { 79 float scroll_x() const {
62 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); 80 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_);
63 return data_.scroll_update.x; 81 return data_.scroll_update.x;
64 } 82 }
65 83
66 float scroll_y() const { 84 float scroll_y() const {
67 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_); 85 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_);
68 return data_.scroll_update.y; 86 return data_.scroll_update.y;
69 } 87 }
70 88
89 ScrollUnits scroll_update_units() const {
90 DCHECK_EQ(ET_GESTURE_SCROLL_UPDATE, type_);
91 return data_.scroll_update.delta_units;
92 }
93
71 float velocity_x() const { 94 float velocity_x() const {
72 DCHECK_EQ(ET_SCROLL_FLING_START, type_); 95 DCHECK_EQ(ET_SCROLL_FLING_START, type_);
73 return data_.fling_velocity.x; 96 return data_.fling_velocity.x;
74 } 97 }
75 98
76 float velocity_y() const { 99 float velocity_y() const {
77 DCHECK_EQ(ET_SCROLL_FLING_START, type_); 100 DCHECK_EQ(ET_SCROLL_FLING_START, type_);
78 return data_.fling_velocity.y; 101 return data_.fling_velocity.y;
79 } 102 }
80 103
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 178
156 private: 179 private:
157 EventType type_; 180 EventType type_;
158 union Details { 181 union Details {
159 Details(); 182 Details();
160 struct { // SCROLL start details. 183 struct { // SCROLL start details.
161 // Distance that caused the scroll to start. Generally redundant with 184 // Distance that caused the scroll to start. Generally redundant with
162 // the x/y values from the first scroll_update. 185 // the x/y values from the first scroll_update.
163 float x_hint; 186 float x_hint;
164 float y_hint; 187 float y_hint;
188 ScrollUnits delta_hint_units;
165 } scroll_begin; 189 } scroll_begin;
166 190
167 struct { // SCROLL delta. 191 struct { // SCROLL delta.
168 float x; 192 float x;
169 float y; 193 float y;
194 ScrollUnits delta_units;
170 // Whether any previous scroll update in the current scroll sequence was 195 // Whether any previous scroll update in the current scroll sequence was
171 // suppressed because the underlying touch was consumed. 196 // suppressed because the underlying touch was consumed.
172 bool previous_update_in_sequence_prevented; 197 bool previous_update_in_sequence_prevented;
173 } scroll_update; 198 } scroll_update;
174 199
175 float scale; // PINCH scale. 200 float scale; // PINCH scale.
176 201
177 struct { // FLING velocity. 202 struct { // FLING velocity.
178 float x; 203 float x;
179 float y; 204 float y;
(...skipping 23 matching lines...) Expand all
203 int touch_points_; // Number of active touch points in the gesture. 228 int touch_points_; // Number of active touch points in the gesture.
204 229
205 // Bounding box is an axis-aligned rectangle that contains all the 230 // Bounding box is an axis-aligned rectangle that contains all the
206 // enclosing rectangles of the touch-points in the gesture. 231 // enclosing rectangles of the touch-points in the gesture.
207 gfx::RectF bounding_box_; 232 gfx::RectF bounding_box_;
208 }; 233 };
209 234
210 } // namespace ui 235 } // namespace ui
211 236
212 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_ 237 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DETAILS_H_
OLDNEW
« no previous file with comments | « ui/events/blink/blink_event_util_unittest.cc ('k') | ui/events/gesture_event_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698