Chromium Code Reviews| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 enum RailsMode { | 220 enum RailsMode { |
| 221 RailsModeFree = 0, | 221 RailsModeFree = 0, |
| 222 RailsModeHorizontal = 1, | 222 RailsModeHorizontal = 1, |
| 223 RailsModeVertical = 2, | 223 RailsModeVertical = 2, |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey; | 226 static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey; |
| 227 | 227 |
| 228 static constexpr double TimeStampForTesting = 123.0; | 228 static constexpr double TimeStampForTesting = 123.0; |
| 229 | 229 |
| 230 double timeStampSeconds; // Seconds since platform start with microsecond | |
| 231 // resolution. | |
| 232 unsigned size; // The size of this structure, for serialization. | |
| 233 Type type; | |
| 234 int modifiers; | |
| 235 | |
| 236 // Returns true if the WebInputEvent |type| is a mouse event. | 230 // Returns true if the WebInputEvent |type| is a mouse event. |
| 237 static bool isMouseEventType(int type) { | 231 static bool isMouseEventType(int type) { |
| 238 return MouseTypeFirst <= type && type <= MouseTypeLast; | 232 return MouseTypeFirst <= type && type <= MouseTypeLast; |
| 239 } | 233 } |
| 240 | 234 |
| 241 // Returns true if the WebInputEvent |type| is a keyboard event. | 235 // Returns true if the WebInputEvent |type| is a keyboard event. |
| 242 static bool isKeyboardEventType(int type) { | 236 static bool isKeyboardEventType(int type) { |
| 243 return KeyboardTypeFirst <= type && type <= KeyboardTypeLast; | 237 return KeyboardTypeFirst <= type && type <= KeyboardTypeLast; |
| 244 } | 238 } |
| 245 | 239 |
| 246 // Returns true if the WebInputEvent |type| is a touch event. | 240 // Returns true if the WebInputEvent |type| is a touch event. |
| 247 static bool isTouchEventType(int type) { | 241 static bool isTouchEventType(int type) { |
| 248 return TouchTypeFirst <= type && type <= TouchTypeLast; | 242 return TouchTypeFirst <= type && type <= TouchTypeLast; |
| 249 } | 243 } |
| 250 | 244 |
| 251 // Returns true if the WebInputEvent is a gesture event. | 245 // Returns true if the WebInputEvent is a gesture event. |
| 252 static bool isGestureEventType(int type) { | 246 static bool isGestureEventType(int type) { |
| 253 return GestureTypeFirst <= type && type <= GestureTypeLast; | 247 return GestureTypeFirst <= type && type <= GestureTypeLast; |
| 254 } | 248 } |
| 255 | 249 |
| 256 bool isSameEventClass(const WebInputEvent& other) const { | 250 bool isSameEventClass(const WebInputEvent& other) const { |
| 257 if (isMouseEventType(type)) | 251 if (isMouseEventType(m_type)) |
| 258 return isMouseEventType(other.type); | 252 return isMouseEventType(other.m_type); |
| 259 if (isGestureEventType(type)) | 253 if (isGestureEventType(m_type)) |
| 260 return isGestureEventType(other.type); | 254 return isGestureEventType(other.m_type); |
| 261 if (isTouchEventType(type)) | 255 if (isTouchEventType(m_type)) |
| 262 return isTouchEventType(other.type); | 256 return isTouchEventType(other.m_type); |
| 263 if (isKeyboardEventType(type)) | 257 if (isKeyboardEventType(m_type)) |
| 264 return isKeyboardEventType(other.type); | 258 return isKeyboardEventType(other.m_type); |
| 265 return type == other.type; | 259 return m_type == other.m_type; |
| 266 } | 260 } |
| 267 | 261 |
| 268 BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type); | 262 BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type); |
| 269 | 263 |
| 270 void setType(Type typeParam) { type = typeParam; } | 264 Type type() const { return m_type; } |
| 265 void setType(Type typeParam) { m_type = typeParam; } | |
| 271 | 266 |
| 272 void setModifiers(int modifiersParam) { modifiers = modifiersParam; } | 267 int modifiers() const { return m_modifiers; } |
| 268 void setModifiers(int modifiersParam) { m_modifiers = modifiersParam; } | |
| 273 | 269 |
| 274 void setTimeStampSeconds(double seconds) { timeStampSeconds = seconds; } | 270 double timeStampSeconds() const { return m_timeStampSeconds; } |
| 271 void setTimeStampSeconds(double seconds) { m_timeStampSeconds = seconds; } | |
| 272 | |
| 273 unsigned size() const { return m_size; } | |
| 275 | 274 |
| 276 protected: | 275 protected: |
| 277 WebInputEvent(unsigned sizeParam, | 276 WebInputEvent(unsigned sizeParam, |
| 278 Type typeParam, | 277 Type typeParam, |
| 279 int modifiersParam, | 278 int modifiersParam, |
| 280 double timeStampSecondsParam) { | 279 double timeStampSecondsParam) { |
| 281 memset(this, 0, sizeParam); | 280 memset(this, 0, sizeParam); |
|
esprehn
2016/12/14 19:03:05
It's very weird to memset yourself once you're a r
dtapuska
2017/01/12 16:45:13
I've added a TODO. I think the memset is necessary
| |
| 282 timeStampSeconds = timeStampSecondsParam; | 281 m_timeStampSeconds = timeStampSecondsParam; |
| 283 size = sizeParam; | 282 m_size = sizeParam; |
| 284 type = typeParam; | 283 m_type = typeParam; |
| 285 modifiers = modifiersParam; | 284 m_modifiers = modifiersParam; |
| 286 } | 285 } |
| 287 | 286 |
| 288 explicit WebInputEvent(unsigned sizeParam) { | 287 explicit WebInputEvent(unsigned sizeParam) { |
| 289 memset(this, 0, sizeParam); | 288 memset(this, 0, sizeParam); |
| 290 timeStampSeconds = 0.0; | 289 m_timeStampSeconds = 0.0; |
|
esprehn
2016/12/14 19:03:05
this is a duplicate of the memset?
dtapuska
2017/01/12 16:45:13
The code was that way before and I presume someone
| |
| 291 size = sizeParam; | 290 m_size = sizeParam; |
| 292 type = Undefined; | 291 m_type = Undefined; |
| 293 } | 292 } |
| 293 | |
| 294 double m_timeStampSeconds; // Seconds since platform start with microsecond | |
| 295 // resolution. | |
| 296 unsigned m_size; // The size of this structure, for serialization. | |
| 297 Type m_type; | |
| 298 int m_modifiers; | |
| 294 }; | 299 }; |
| 295 | 300 |
| 296 // WebKeyboardEvent ----------------------------------------------------------- | 301 // WebKeyboardEvent ----------------------------------------------------------- |
| 297 | 302 |
| 298 class WebKeyboardEvent : public WebInputEvent { | 303 class WebKeyboardEvent : public WebInputEvent { |
| 299 public: | 304 public: |
| 300 // Caps on string lengths so we can make them static arrays and keep | 305 // Caps on string lengths so we can make them static arrays and keep |
| 301 // them PODs. | 306 // them PODs. |
| 302 static const size_t textLengthCap = 4; | 307 static const size_t textLengthCap = 4; |
| 303 | 308 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 WebTouchEvent(Type type, int modifiers, double timeStampSeconds) | 524 WebTouchEvent(Type type, int modifiers, double timeStampSeconds) |
| 520 : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds), | 525 : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds), |
| 521 dispatchType(Blocking) {} | 526 dispatchType(Blocking) {} |
| 522 }; | 527 }; |
| 523 | 528 |
| 524 #pragma pack(pop) | 529 #pragma pack(pop) |
| 525 | 530 |
| 526 } // namespace blink | 531 } // namespace blink |
| 527 | 532 |
| 528 #endif | 533 #endif |
| OLD | NEW |