| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 enum RailsMode { | 224 enum RailsMode { |
| 225 RailsModeFree = 0, | 225 RailsModeFree = 0, |
| 226 RailsModeHorizontal = 1, | 226 RailsModeHorizontal = 1, |
| 227 RailsModeVertical = 2, | 227 RailsModeVertical = 2, |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey; | 230 static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey; |
| 231 | 231 |
| 232 static constexpr double TimeStampForTesting = 123.0; | 232 static constexpr double TimeStampForTesting = 123.0; |
| 233 | 233 |
| 234 double timeStampSeconds; // Seconds since platform start with microsecond | |
| 235 // resolution. | |
| 236 unsigned size; // The size of this structure, for serialization. | |
| 237 Type type; | |
| 238 int modifiers; | |
| 239 | |
| 240 // Returns true if the WebInputEvent |type| is a mouse event. | 234 // Returns true if the WebInputEvent |type| is a mouse event. |
| 241 static bool isMouseEventType(int type) { | 235 static bool isMouseEventType(int type) { |
| 242 return MouseTypeFirst <= type && type <= MouseTypeLast; | 236 return MouseTypeFirst <= type && type <= MouseTypeLast; |
| 243 } | 237 } |
| 244 | 238 |
| 245 // Returns true if the WebInputEvent |type| is a keyboard event. | 239 // Returns true if the WebInputEvent |type| is a keyboard event. |
| 246 static bool isKeyboardEventType(int type) { | 240 static bool isKeyboardEventType(int type) { |
| 247 return KeyboardTypeFirst <= type && type <= KeyboardTypeLast; | 241 return KeyboardTypeFirst <= type && type <= KeyboardTypeLast; |
| 248 } | 242 } |
| 249 | 243 |
| 250 // Returns true if the WebInputEvent |type| is a touch event. | 244 // Returns true if the WebInputEvent |type| is a touch event. |
| 251 static bool isTouchEventType(int type) { | 245 static bool isTouchEventType(int type) { |
| 252 return TouchTypeFirst <= type && type <= TouchTypeLast; | 246 return TouchTypeFirst <= type && type <= TouchTypeLast; |
| 253 } | 247 } |
| 254 | 248 |
| 255 // Returns true if the WebInputEvent is a gesture event. | 249 // Returns true if the WebInputEvent is a gesture event. |
| 256 static bool isGestureEventType(int type) { | 250 static bool isGestureEventType(int type) { |
| 257 return GestureTypeFirst <= type && type <= GestureTypeLast; | 251 return GestureTypeFirst <= type && type <= GestureTypeLast; |
| 258 } | 252 } |
| 259 | 253 |
| 260 bool isSameEventClass(const WebInputEvent& other) const { | 254 bool isSameEventClass(const WebInputEvent& other) const { |
| 261 if (isMouseEventType(type)) | 255 if (isMouseEventType(m_type)) |
| 262 return isMouseEventType(other.type); | 256 return isMouseEventType(other.m_type); |
| 263 if (isGestureEventType(type)) | 257 if (isGestureEventType(m_type)) |
| 264 return isGestureEventType(other.type); | 258 return isGestureEventType(other.m_type); |
| 265 if (isTouchEventType(type)) | 259 if (isTouchEventType(m_type)) |
| 266 return isTouchEventType(other.type); | 260 return isTouchEventType(other.m_type); |
| 267 if (isKeyboardEventType(type)) | 261 if (isKeyboardEventType(m_type)) |
| 268 return isKeyboardEventType(other.type); | 262 return isKeyboardEventType(other.m_type); |
| 269 return type == other.type; | 263 return m_type == other.m_type; |
| 270 } | 264 } |
| 271 | 265 |
| 272 BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type); | 266 BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type); |
| 273 | 267 |
| 274 float frameScale() const { return m_frameScale; } | 268 float frameScale() const { return m_frameScale; } |
| 275 void setFrameScale(float scale) { m_frameScale = scale; } | 269 void setFrameScale(float scale) { m_frameScale = scale; } |
| 276 | 270 |
| 277 WebFloatPoint frameTranslate() const { return m_frameTranslate; } | 271 WebFloatPoint frameTranslate() const { return m_frameTranslate; } |
| 278 void setFrameTranslate(WebFloatPoint translate) { | 272 void setFrameTranslate(WebFloatPoint translate) { |
| 279 m_frameTranslate = translate; | 273 m_frameTranslate = translate; |
| 280 } | 274 } |
| 281 | 275 |
| 282 void setType(Type typeParam) { type = typeParam; } | 276 Type type() const { return m_type; } |
| 277 void setType(Type typeParam) { m_type = typeParam; } |
| 283 | 278 |
| 284 void setModifiers(int modifiersParam) { modifiers = modifiersParam; } | 279 int modifiers() const { return m_modifiers; } |
| 280 void setModifiers(int modifiersParam) { m_modifiers = modifiersParam; } |
| 285 | 281 |
| 286 void setTimeStampSeconds(double seconds) { timeStampSeconds = seconds; } | 282 double timeStampSeconds() const { return m_timeStampSeconds; } |
| 283 void setTimeStampSeconds(double seconds) { m_timeStampSeconds = seconds; } |
| 284 |
| 285 unsigned size() const { return m_size; } |
| 287 | 286 |
| 288 protected: | 287 protected: |
| 289 // The root frame scale. | 288 // The root frame scale. |
| 290 float m_frameScale; | 289 float m_frameScale; |
| 291 | 290 |
| 292 // The root frame translation (applied post scale). | 291 // The root frame translation (applied post scale). |
| 293 WebFloatPoint m_frameTranslate; | 292 WebFloatPoint m_frameTranslate; |
| 294 | 293 |
| 295 WebInputEvent(unsigned sizeParam, | 294 WebInputEvent(unsigned sizeParam, |
| 296 Type typeParam, | 295 Type typeParam, |
| 297 int modifiersParam, | 296 int modifiersParam, |
| 298 double timeStampSecondsParam) { | 297 double timeStampSecondsParam) { |
| 298 // TODO(dtapuska): Remove this memset when we remove the chrome IPC of this |
| 299 // struct. |
| 299 memset(this, 0, sizeParam); | 300 memset(this, 0, sizeParam); |
| 300 timeStampSeconds = timeStampSecondsParam; | 301 m_timeStampSeconds = timeStampSecondsParam; |
| 301 size = sizeParam; | 302 m_size = sizeParam; |
| 302 type = typeParam; | 303 m_type = typeParam; |
| 303 modifiers = modifiersParam; | 304 m_modifiers = modifiersParam; |
| 304 #if DCHECK_IS_ON() | 305 #if DCHECK_IS_ON() |
| 305 // If dcheck is on force failures if frame scale is not initialized | 306 // If dcheck is on force failures if frame scale is not initialized |
| 306 // correctly by causing DIV0. | 307 // correctly by causing DIV0. |
| 307 m_frameScale = 0; | 308 m_frameScale = 0; |
| 308 #else | 309 #else |
| 309 m_frameScale = 1; | 310 m_frameScale = 1; |
| 310 #endif | 311 #endif |
| 311 } | 312 } |
| 312 | 313 |
| 313 WebInputEvent(unsigned sizeParam) { | 314 WebInputEvent(unsigned sizeParam) { |
| 315 // TODO(dtapuska): Remove this memset when we remove the chrome IPC of this |
| 316 // struct. |
| 314 memset(this, 0, sizeParam); | 317 memset(this, 0, sizeParam); |
| 315 timeStampSeconds = 0.0; | 318 m_timeStampSeconds = 0.0; |
| 316 size = sizeParam; | 319 m_size = sizeParam; |
| 317 type = Undefined; | 320 m_type = Undefined; |
| 318 #if DCHECK_IS_ON() | 321 #if DCHECK_IS_ON() |
| 319 // If dcheck is on force failures if frame scale is not initialized | 322 // If dcheck is on force failures if frame scale is not initialized |
| 320 // correctly by causing DIV0. | 323 // correctly by causing DIV0. |
| 321 m_frameScale = 0; | 324 m_frameScale = 0; |
| 322 #else | 325 #else |
| 323 m_frameScale = 1; | 326 m_frameScale = 1; |
| 324 #endif | 327 #endif |
| 325 } | 328 } |
| 329 |
| 330 double m_timeStampSeconds; // Seconds since platform start with microsecond |
| 331 // resolution. |
| 332 unsigned m_size; // The size of this structure, for serialization. |
| 333 Type m_type; |
| 334 int m_modifiers; |
| 326 }; | 335 }; |
| 327 | 336 |
| 328 // WebKeyboardEvent ----------------------------------------------------------- | 337 // WebKeyboardEvent ----------------------------------------------------------- |
| 329 | 338 |
| 330 class WebKeyboardEvent : public WebInputEvent { | 339 class WebKeyboardEvent : public WebInputEvent { |
| 331 public: | 340 public: |
| 332 // Caps on string lengths so we can make them static arrays and keep | 341 // Caps on string lengths so we can make them static arrays and keep |
| 333 // them PODs. | 342 // them PODs. |
| 334 static const size_t textLengthCap = 4; | 343 static const size_t textLengthCap = 4; |
| 335 | 344 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 WebTouchEvent(Type type, int modifiers, double timeStampSeconds) | 445 WebTouchEvent(Type type, int modifiers, double timeStampSeconds) |
| 437 : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds), | 446 : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds), |
| 438 dispatchType(Blocking) {} | 447 dispatchType(Blocking) {} |
| 439 }; | 448 }; |
| 440 | 449 |
| 441 #pragma pack(pop) | 450 #pragma pack(pop) |
| 442 | 451 |
| 443 } // namespace blink | 452 } // namespace blink |
| 444 | 453 |
| 445 #endif | 454 #endif |
| OLD | NEW |