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

Side by Side Diff: ui/events/blink/blink_event_util.cc

Issue 1645613007: Redefined the bit WebTouchEvent.causesScrollingIfUncanceled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Redefined the bit semantic, updated tests. Created 4 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
OLDNEW
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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/events/blink/blink_event_util.h" 8 #include "ui/events/blink/blink_event_util.h"
9 9
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 touch.tiltX = touch.tiltY = 0; 172 touch.tiltX = touch.tiltY = 0;
173 } 173 }
174 174
175 return touch; 175 return touch;
176 } 176 }
177 177
178 } // namespace 178 } // namespace
179 179
180 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( 180 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
181 const MotionEvent& event, 181 const MotionEvent& event,
182 bool may_cause_scrolling) { 182 bool moved_beyond_slop_region) {
183 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == 183 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) ==
184 static_cast<int>(blink::WebTouchEvent::touchesLengthCap), 184 static_cast<int>(blink::WebTouchEvent::touchesLengthCap),
185 "inconsistent maximum number of active touch points"); 185 "inconsistent maximum number of active touch points");
186 186
187 blink::WebTouchEvent result; 187 blink::WebTouchEvent result;
188 188
189 result.type = ToWebInputEventType(event.GetAction()); 189 result.type = ToWebInputEventType(event.GetAction());
190 result.cancelable = (result.type != WebInputEvent::TouchCancel); 190 result.cancelable = (result.type != WebInputEvent::TouchCancel);
191 result.timeStampSeconds = 191 result.timeStampSeconds =
192 (event.GetEventTime() - base::TimeTicks()).InSecondsF(), 192 (event.GetEventTime() - base::TimeTicks()).InSecondsF();
193 result.causesScrollingIfUncanceled = may_cause_scrolling; 193 result.movedBeyondSlopRegion = moved_beyond_slop_region;
194 result.modifiers = EventFlagsToWebEventModifiers(event.GetFlags()); 194 result.modifiers = EventFlagsToWebEventModifiers(event.GetFlags());
195 DCHECK_NE(event.GetUniqueEventId(), 0U); 195 DCHECK_NE(event.GetUniqueEventId(), 0U);
196 result.uniqueTouchEventId = event.GetUniqueEventId(); 196 result.uniqueTouchEventId = event.GetUniqueEventId();
197 result.touchesLength = 197 result.touchesLength =
198 std::min(static_cast<unsigned>(event.GetPointerCount()), 198 std::min(static_cast<unsigned>(event.GetPointerCount()),
199 static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); 199 static_cast<unsigned>(WebTouchEvent::touchesLengthCap));
200 DCHECK_GT(result.touchesLength, 0U); 200 DCHECK_GT(result.touchesLength, 0U);
201 201
202 for (size_t i = 0; i < result.touchesLength; ++i) 202 for (size_t i = 0; i < result.touchesLength; ++i)
203 result.touches[i] = CreateWebTouchPoint(event, i); 203 result.touches[i] = CreateWebTouchPoint(event, i);
204 204
205 return result; 205 return result;
206 } 206 }
207 207
208 bool IsTouchSequenceStart(const MotionEvent& event) {
tdresser 2016/02/05 14:19:00 Isn't this equivalent to event.GetAction() == ACTI
mustaq 2016/02/05 15:29:18 Thanks for the catch: I was trying to return true
209 if (ToWebInputEventType(event.GetAction()) != WebInputEvent::TouchStart)
210 return false;
211
212 size_t num_touches = event.GetPointerCount();
213 if (!num_touches)
214 return false;
215
216 for (size_t i = 0; i < num_touches; i++) {
217 if (ToWebTouchPointState(event, i) != WebTouchPoint::StatePressed)
218 return false;
219 }
220
221 return true;
222 }
223
208 int EventFlagsToWebEventModifiers(int flags) { 224 int EventFlagsToWebEventModifiers(int flags) {
209 int modifiers = 0; 225 int modifiers = 0;
210 226
211 if (flags & EF_SHIFT_DOWN) 227 if (flags & EF_SHIFT_DOWN)
212 modifiers |= blink::WebInputEvent::ShiftKey; 228 modifiers |= blink::WebInputEvent::ShiftKey;
213 if (flags & EF_CONTROL_DOWN) 229 if (flags & EF_CONTROL_DOWN)
214 modifiers |= blink::WebInputEvent::ControlKey; 230 modifiers |= blink::WebInputEvent::ControlKey;
215 if (flags & EF_ALT_DOWN) 231 if (flags & EF_ALT_DOWN)
216 modifiers |= blink::WebInputEvent::AltKey; 232 modifiers |= blink::WebInputEvent::AltKey;
217 if (flags & EF_COMMAND_DOWN) 233 if (flags & EF_COMMAND_DOWN)
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 481
466 // TODO(oshima): Find out if ContextMenu needs to be scaled. 482 // TODO(oshima): Find out if ContextMenu needs to be scaled.
467 default: 483 default:
468 break; 484 break;
469 } 485 }
470 } 486 }
471 return scaled_event; 487 return scaled_event;
472 } 488 }
473 489
474 } // namespace ui 490 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698