| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef SKY_ENGINE_PUBLIC_PLATFORM_WEBINPUTEVENT_H_ | 31 #ifndef SKY_ENGINE_PUBLIC_PLATFORM_WEBINPUTEVENT_H_ |
| 32 #define SKY_ENGINE_PUBLIC_PLATFORM_WEBINPUTEVENT_H_ | 32 #define SKY_ENGINE_PUBLIC_PLATFORM_WEBINPUTEVENT_H_ |
| 33 | 33 |
| 34 #include <string.h> | 34 #include <string.h> |
| 35 #include "sky/engine/public/platform/WebCommon.h" | 35 #include "sky/engine/public/platform/WebCommon.h" |
| 36 #include "sky/engine/public/platform/WebGestureDevice.h" | 36 #include "sky/engine/public/platform/WebGestureDevice.h" |
| 37 #include "sky/engine/public/platform/WebRect.h" | 37 #include "sky/engine/public/platform/WebRect.h" |
| 38 #include "sky/engine/public/platform/WebTouchPoint.h" | |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 // The classes defined in this file are intended to be used with | 41 // The classes defined in this file are intended to be used with |
| 43 // WebWidget's handleInputEvent method. These event types are cross- | 42 // WebWidget's handleInputEvent method. These event types are cross- |
| 44 // platform and correspond closely to WebCore's Platform*Event classes. | 43 // platform and correspond closely to WebCore's Platform*Event classes. |
| 45 // | 44 // |
| 46 // WARNING! These classes must remain PODs (plain old data). They are | 45 // WARNING! These classes must remain PODs (plain old data). They are |
| 47 // intended to be "serializable" by copying their raw bytes, so they must | 46 // intended to be "serializable" by copying their raw bytes, so they must |
| 48 // not contain any non-bit-copyable member variables! | 47 // not contain any non-bit-copyable member variables! |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 GestureTapDown, | 115 GestureTapDown, |
| 117 GestureTapCancel, | 116 GestureTapCancel, |
| 118 GestureDoubleTap, | 117 GestureDoubleTap, |
| 119 GestureTwoFingerTap, | 118 GestureTwoFingerTap, |
| 120 GestureLongPress, | 119 GestureLongPress, |
| 121 GestureLongTap, | 120 GestureLongTap, |
| 122 GesturePinchBegin, | 121 GesturePinchBegin, |
| 123 GesturePinchEnd, | 122 GesturePinchEnd, |
| 124 GesturePinchUpdate, | 123 GesturePinchUpdate, |
| 125 GestureTypeLast = GesturePinchUpdate, | 124 GestureTypeLast = GesturePinchUpdate, |
| 126 | |
| 127 // WebTouchEvent | |
| 128 TouchStart, | |
| 129 TouchTypeFirst = TouchStart, | |
| 130 TouchMove, | |
| 131 TouchEnd, | |
| 132 TouchCancel, | |
| 133 TouchTypeLast = TouchCancel, | |
| 134 | |
| 135 TypeLast = TouchTypeLast | |
| 136 }; | 125 }; |
| 137 | 126 |
| 138 enum Modifiers { | 127 enum Modifiers { |
| 139 // modifiers for all events: | 128 // modifiers for all events: |
| 140 ShiftKey = 1 << 0, | 129 ShiftKey = 1 << 0, |
| 141 ControlKey = 1 << 1, | 130 ControlKey = 1 << 1, |
| 142 AltKey = 1 << 2, | 131 AltKey = 1 << 2, |
| 143 MetaKey = 1 << 3, | 132 MetaKey = 1 << 3, |
| 144 | 133 |
| 145 // modifiers for keyboard events: | 134 // modifiers for keyboard events: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 { | 170 { |
| 182 return PointerTypeFirst <= type && type <= PointerTypeLast; | 171 return PointerTypeFirst <= type && type <= PointerTypeLast; |
| 183 } | 172 } |
| 184 | 173 |
| 185 // Returns true if the WebInputEvent |type| is a keyboard event. | 174 // Returns true if the WebInputEvent |type| is a keyboard event. |
| 186 static bool isKeyboardEventType(int type) | 175 static bool isKeyboardEventType(int type) |
| 187 { | 176 { |
| 188 return KeyboardTypeFirst <= type && type <= KeyboardTypeLast; | 177 return KeyboardTypeFirst <= type && type <= KeyboardTypeLast; |
| 189 } | 178 } |
| 190 | 179 |
| 191 // Returns true if the WebInputEvent |type| is a touch event. | |
| 192 static bool isTouchEventType(int type) | |
| 193 { | |
| 194 return TouchTypeFirst <= type && type <= TouchTypeLast; | |
| 195 } | |
| 196 | |
| 197 // Returns true if the WebInputEvent is a gesture event. | 180 // Returns true if the WebInputEvent is a gesture event. |
| 198 static bool isGestureEventType(int type) | 181 static bool isGestureEventType(int type) |
| 199 { | 182 { |
| 200 return GestureTypeFirst <= type && type <= GestureTypeLast; | 183 return GestureTypeFirst <= type && type <= GestureTypeLast; |
| 201 } | 184 } |
| 202 | 185 |
| 203 protected: | 186 protected: |
| 204 explicit WebInputEvent(unsigned sizeParam) | 187 explicit WebInputEvent(unsigned sizeParam) |
| 205 { | 188 { |
| 206 memset(this, 0, sizeParam); | 189 memset(this, 0, sizeParam); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 : WebInputEvent(sizeof(WebGestureEvent)) | 361 : WebInputEvent(sizeof(WebGestureEvent)) |
| 379 , x(0) | 362 , x(0) |
| 380 , y(0) | 363 , y(0) |
| 381 , globalX(0) | 364 , globalX(0) |
| 382 , globalY(0) | 365 , globalY(0) |
| 383 { | 366 { |
| 384 memset(&data, 0, sizeof(data)); | 367 memset(&data, 0, sizeof(data)); |
| 385 } | 368 } |
| 386 }; | 369 }; |
| 387 | 370 |
| 388 // WebTouchEvent -------------------------------------------------------------- | |
| 389 | |
| 390 class WebTouchEvent : public WebInputEvent { | |
| 391 public: | |
| 392 // Maximum number of simultaneous touches supported on | |
| 393 // Ash/Aura. | |
| 394 enum { touchesLengthCap = 12 }; | |
| 395 | |
| 396 unsigned touchesLength; | |
| 397 // List of all touches which are currently down. | |
| 398 WebTouchPoint touches[touchesLengthCap]; | |
| 399 | |
| 400 unsigned changedTouchesLength; | |
| 401 // List of all touches whose state has changed since the last WebTouchEvent | |
| 402 WebTouchPoint changedTouches[touchesLengthCap]; | |
| 403 | |
| 404 unsigned targetTouchesLength; | |
| 405 // List of all touches which are currently down and are targeting the event
recipient. | |
| 406 WebTouchPoint targetTouches[touchesLengthCap]; | |
| 407 | |
| 408 // Whether the event can be canceled (with preventDefault). If true then the
browser | |
| 409 // must wait for an ACK for this event. If false then no ACK IPC is expected
. | |
| 410 // See comment at the top for why an int is used here instead of a bool. | |
| 411 int cancelable; | |
| 412 | |
| 413 WebTouchEvent() | |
| 414 : WebInputEvent(sizeof(WebTouchEvent)) | |
| 415 , touchesLength(0) | |
| 416 , changedTouchesLength(0) | |
| 417 , targetTouchesLength(0) | |
| 418 , cancelable(true) | |
| 419 { | |
| 420 } | |
| 421 }; | |
| 422 | |
| 423 #pragma pack(pop) | 371 #pragma pack(pop) |
| 424 | 372 |
| 425 } // namespace blink | 373 } // namespace blink |
| 426 | 374 |
| 427 #endif // SKY_ENGINE_PUBLIC_PLATFORM_WEBINPUTEVENT_H_ | 375 #endif // SKY_ENGINE_PUBLIC_PLATFORM_WEBINPUTEVENT_H_ |
| OLD | NEW |