OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/common/input/event_with_latency_info.h" | 5 #include "content/common/input/event_with_latency_info.h" |
6 | 6 |
7 #include <bitset> | 7 #include <bitset> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 using blink::WebGestureEvent; | 10 using blink::WebGestureEvent; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 event->accelerationRatioY = | 106 event->accelerationRatioY = |
107 GetAccelerationRatio(event->deltaY, unaccelerated_y); | 107 GetAccelerationRatio(event->deltaY, unaccelerated_y); |
108 } | 108 } |
109 | 109 |
110 bool CanCoalesce(const WebTouchEvent& event_to_coalesce, | 110 bool CanCoalesce(const WebTouchEvent& event_to_coalesce, |
111 const WebTouchEvent& event) { | 111 const WebTouchEvent& event) { |
112 if (event.type != event_to_coalesce.type || | 112 if (event.type != event_to_coalesce.type || |
113 event.type != WebInputEvent::TouchMove || | 113 event.type != WebInputEvent::TouchMove || |
114 event.modifiers != event_to_coalesce.modifiers || | 114 event.modifiers != event_to_coalesce.modifiers || |
115 event.touchesLength != event_to_coalesce.touchesLength || | 115 event.touchesLength != event_to_coalesce.touchesLength || |
116 event.touchesLength > WebTouchEvent::touchesLengthCap) | 116 event.touchesLength > WebTouchEvent::kTouchesLengthCap) |
117 return false; | 117 return false; |
118 | 118 |
119 static_assert(WebTouchEvent::touchesLengthCap <= sizeof(int32_t) * 8U, | 119 static_assert(WebTouchEvent::kTouchesLengthCap <= sizeof(int32_t) * 8U, |
120 "suboptimal touchesLengthCap size"); | 120 "suboptimal kTouchesLengthCap size"); |
121 // Ensure that we have a 1-to-1 mapping of pointer ids between touches. | 121 // Ensure that we have a 1-to-1 mapping of pointer ids between touches. |
122 std::bitset<WebTouchEvent::touchesLengthCap> unmatched_event_touches( | 122 std::bitset<WebTouchEvent::kTouchesLengthCap> unmatched_event_touches( |
123 (1 << event.touchesLength) - 1); | 123 (1 << event.touchesLength) - 1); |
124 for (unsigned i = 0; i < event_to_coalesce.touchesLength; ++i) { | 124 for (unsigned i = 0; i < event_to_coalesce.touchesLength; ++i) { |
125 int event_touch_index = | 125 int event_touch_index = |
126 GetIndexOfTouchID(event, event_to_coalesce.touches[i].id); | 126 GetIndexOfTouchID(event, event_to_coalesce.touches[i].id); |
127 if (event_touch_index == kInvalidTouchIndex) | 127 if (event_touch_index == kInvalidTouchIndex) |
128 return false; | 128 return false; |
129 if (!unmatched_event_touches[event_touch_index]) | 129 if (!unmatched_event_touches[event_touch_index]) |
130 return false; | 130 return false; |
131 unmatched_event_touches[event_touch_index] = false; | 131 unmatched_event_touches[event_touch_index] = false; |
132 } | 132 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // we can reliably perform operations like log on the values. | 189 // we can reliably perform operations like log on the values. |
190 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) | 190 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) |
191 event->data.pinchUpdate.scale = numeric_limits<float>::min(); | 191 event->data.pinchUpdate.scale = numeric_limits<float>::min(); |
192 else if (event->data.pinchUpdate.scale > numeric_limits<float>::max()) | 192 else if (event->data.pinchUpdate.scale > numeric_limits<float>::max()) |
193 event->data.pinchUpdate.scale = numeric_limits<float>::max(); | 193 event->data.pinchUpdate.scale = numeric_limits<float>::max(); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 } // namespace internal | 197 } // namespace internal |
198 } // namespace content | 198 } // namespace content |
OLD | NEW |