| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 kGestureScrollBegin, | 123 kGestureScrollBegin, |
| 124 kGestureTypeFirst = kGestureScrollBegin, | 124 kGestureTypeFirst = kGestureScrollBegin, |
| 125 kGestureScrollEnd, | 125 kGestureScrollEnd, |
| 126 kGestureScrollUpdate, | 126 kGestureScrollUpdate, |
| 127 // Fling is a high-velocity and quickly released finger movement. | 127 // Fling is a high-velocity and quickly released finger movement. |
| 128 // FlingStart is sent once and kicks off a scroll animation. | 128 // FlingStart is sent once and kicks off a scroll animation. |
| 129 kGestureFlingStart, | 129 kGestureFlingStart, |
| 130 kGestureFlingCancel, | 130 kGestureFlingCancel, |
| 131 // Pinch is two fingers moving closer or farther apart. | 131 // Pinch is two fingers moving closer or farther apart. |
| 132 kGesturePinchBegin, | 132 kGesturePinchBegin, |
| 133 kGesturePinchTypeFirst = kGesturePinchBegin, |
| 133 kGesturePinchEnd, | 134 kGesturePinchEnd, |
| 134 kGesturePinchUpdate, | 135 kGesturePinchUpdate, |
| 136 kGesturePinchTypeLast = kGesturePinchUpdate, |
| 135 | 137 |
| 136 // The following types are variations and subevents of single-taps. | 138 // The following types are variations and subevents of single-taps. |
| 137 // | 139 // |
| 138 // Sent the moment the user's finger hits the screen. | 140 // Sent the moment the user's finger hits the screen. |
| 139 kGestureTapDown, | 141 kGestureTapDown, |
| 140 // Sent a short interval later, after it seems the finger is staying in | 142 // Sent a short interval later, after it seems the finger is staying in |
| 141 // place. It's used to activate the link highlight ("show the press"). | 143 // place. It's used to activate the link highlight ("show the press"). |
| 142 kGestureShowPress, | 144 kGestureShowPress, |
| 143 // Sent on finger lift for a simple, static, quick finger tap. This is the | 145 // Sent on finger lift for a simple, static, quick finger tap. This is the |
| 144 // "main" event which maps to a synthetic mouse click event. | 146 // "main" event which maps to a synthetic mouse click event. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 kRailsModeHorizontal = 1, | 274 kRailsModeHorizontal = 1, |
| 273 kRailsModeVertical = 2, | 275 kRailsModeVertical = 2, |
| 274 }; | 276 }; |
| 275 | 277 |
| 276 static const int kInputModifiers = | 278 static const int kInputModifiers = |
| 277 kShiftKey | kControlKey | kAltKey | kMetaKey; | 279 kShiftKey | kControlKey | kAltKey | kMetaKey; |
| 278 | 280 |
| 279 static constexpr double kTimeStampForTesting = 123.0; | 281 static constexpr double kTimeStampForTesting = 123.0; |
| 280 | 282 |
| 281 // Returns true if the WebInputEvent |type| is a mouse event. | 283 // Returns true if the WebInputEvent |type| is a mouse event. |
| 282 static bool IsMouseEventType(int type) { | 284 static bool IsMouseEventType(WebInputEvent::Type type) { |
| 283 return kMouseTypeFirst <= type && type <= kMouseTypeLast; | 285 return kMouseTypeFirst <= type && type <= kMouseTypeLast; |
| 284 } | 286 } |
| 285 | 287 |
| 286 // Returns true if the WebInputEvent |type| is a keyboard event. | 288 // Returns true if the WebInputEvent |type| is a keyboard event. |
| 287 static bool IsKeyboardEventType(int type) { | 289 static bool IsKeyboardEventType(WebInputEvent::Type type) { |
| 288 return kKeyboardTypeFirst <= type && type <= kKeyboardTypeLast; | 290 return kKeyboardTypeFirst <= type && type <= kKeyboardTypeLast; |
| 289 } | 291 } |
| 290 | 292 |
| 291 // Returns true if the WebInputEvent |type| is a touch event. | 293 // Returns true if the WebInputEvent |type| is a touch event. |
| 292 static bool IsTouchEventType(int type) { | 294 static bool IsTouchEventType(WebInputEvent::Type type) { |
| 293 return kTouchTypeFirst <= type && type <= kTouchTypeLast; | 295 return kTouchTypeFirst <= type && type <= kTouchTypeLast; |
| 294 } | 296 } |
| 295 | 297 |
| 296 // Returns true if the WebInputEvent is a gesture event. | 298 // Returns true if the WebInputEvent is a gesture event. |
| 297 static bool IsGestureEventType(int type) { | 299 static bool IsGestureEventType(WebInputEvent::Type type) { |
| 298 return kGestureTypeFirst <= type && type <= kGestureTypeLast; | 300 return kGestureTypeFirst <= type && type <= kGestureTypeLast; |
| 299 } | 301 } |
| 300 | 302 |
| 301 bool IsSameEventClass(const WebInputEvent& other) const { | 303 bool IsSameEventClass(const WebInputEvent& other) const { |
| 302 if (IsMouseEventType(type_)) | 304 if (IsMouseEventType(type_)) |
| 303 return IsMouseEventType(other.type_); | 305 return IsMouseEventType(other.type_); |
| 304 if (IsGestureEventType(type_)) | 306 if (IsGestureEventType(type_)) |
| 305 return IsGestureEventType(other.type_); | 307 return IsGestureEventType(other.type_); |
| 306 if (IsTouchEventType(type_)) | 308 if (IsTouchEventType(type_)) |
| 307 return IsTouchEventType(other.type_); | 309 return IsTouchEventType(other.type_); |
| 308 if (IsKeyboardEventType(type_)) | 310 if (IsKeyboardEventType(type_)) |
| 309 return IsKeyboardEventType(other.type_); | 311 return IsKeyboardEventType(other.type_); |
| 310 return type_ == other.type_; | 312 return type_ == other.type_; |
| 311 } | 313 } |
| 312 | 314 |
| 315 // Returns true if the WebInputEvent |type| is a pinch gesture event. |
| 316 static bool IsPinchGestureEventType(WebInputEvent::Type type) { |
| 317 return kGesturePinchTypeFirst <= type && type <= kGesturePinchTypeLast; |
| 318 } |
| 319 |
| 313 static const char* GetName(WebInputEvent::Type type) { | 320 static const char* GetName(WebInputEvent::Type type) { |
| 314 #define CASE_TYPE(t) \ | 321 #define CASE_TYPE(t) \ |
| 315 case WebInputEvent::k##t: \ | 322 case WebInputEvent::k##t: \ |
| 316 return #t | 323 return #t |
| 317 switch (type) { | 324 switch (type) { |
| 318 CASE_TYPE(Undefined); | 325 CASE_TYPE(Undefined); |
| 319 CASE_TYPE(MouseDown); | 326 CASE_TYPE(MouseDown); |
| 320 CASE_TYPE(MouseUp); | 327 CASE_TYPE(MouseUp); |
| 321 CASE_TYPE(MouseMove); | 328 CASE_TYPE(MouseMove); |
| 322 CASE_TYPE(MouseEnter); | 329 CASE_TYPE(MouseEnter); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 modifiers_ = modifiers_param; | 402 modifiers_ = modifiers_param; |
| 396 #if DCHECK_IS_ON() | 403 #if DCHECK_IS_ON() |
| 397 // If dcheck is on force failures if frame scale is not initialized | 404 // If dcheck is on force failures if frame scale is not initialized |
| 398 // correctly by causing DIV0. | 405 // correctly by causing DIV0. |
| 399 frame_scale_ = 0; | 406 frame_scale_ = 0; |
| 400 #else | 407 #else |
| 401 frame_scale_ = 1; | 408 frame_scale_ = 1; |
| 402 #endif | 409 #endif |
| 403 } | 410 } |
| 404 | 411 |
| 405 WebInputEvent(unsigned size_param) { | 412 explicit WebInputEvent(unsigned size_param) { |
| 406 // TODO(dtapuska): Remove this memset when we remove the chrome IPC of this | 413 // TODO(dtapuska): Remove this memset when we remove the chrome IPC of this |
| 407 // struct. | 414 // struct. |
| 408 memset(this, 0, size_param); | 415 memset(this, 0, size_param); |
| 409 time_stamp_seconds_ = 0.0; | 416 time_stamp_seconds_ = 0.0; |
| 410 size_ = size_param; | 417 size_ = size_param; |
| 411 type_ = kUndefined; | 418 type_ = kUndefined; |
| 412 #if DCHECK_IS_ON() | 419 #if DCHECK_IS_ON() |
| 413 // If dcheck is on force failures if frame scale is not initialized | 420 // If dcheck is on force failures if frame scale is not initialized |
| 414 // correctly by causing DIV0. | 421 // correctly by causing DIV0. |
| 415 frame_scale_ = 0; | 422 frame_scale_ = 0; |
| 416 #else | 423 #else |
| 417 frame_scale_ = 1; | 424 frame_scale_ = 1; |
| 418 #endif | 425 #endif |
| 419 } | 426 } |
| 420 | 427 |
| 421 double time_stamp_seconds_; // Seconds since platform start with microsecond | 428 double time_stamp_seconds_; // Seconds since platform start with microsecond |
| 422 // resolution. | 429 // resolution. |
| 423 unsigned size_; // The size of this structure, for serialization. | 430 unsigned size_; // The size of this structure, for serialization. |
| 424 Type type_; | 431 Type type_; |
| 425 int modifiers_; | 432 int modifiers_; |
| 426 }; | 433 }; |
| 427 | 434 |
| 428 #pragma pack(pop) | 435 #pragma pack(pop) |
| 429 | 436 |
| 430 } // namespace blink | 437 } // namespace blink |
| 431 | 438 |
| 432 #endif | 439 #endif |
| OLD | NEW |