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

Side by Side Diff: third_party/WebKit/public/platform/WebInputEvent.h

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Rebase Created 3 years, 11 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 /* 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 ScrollLockOn = 1 << 18, 188 ScrollLockOn = 1 << 18,
189 189
190 // The set of non-stateful modifiers that specifically change the 190 // The set of non-stateful modifiers that specifically change the
191 // interpretation of the key being pressed. For example; IsLeft, 191 // interpretation of the key being pressed. For example; IsLeft,
192 // IsRight, IsComposing don't change the meaning of the key 192 // IsRight, IsComposing don't change the meaning of the key
193 // being pressed. NumLockOn, ScrollLockOn, CapsLockOn are stateful 193 // being pressed. NumLockOn, ScrollLockOn, CapsLockOn are stateful
194 // and don't indicate explicit depressed state. 194 // and don't indicate explicit depressed state.
195 KeyModifiers = 195 KeyModifiers =
196 SymbolKey | FnKey | AltGrKey | MetaKey | AltKey | ControlKey | ShiftKey, 196 SymbolKey | FnKey | AltGrKey | MetaKey | AltKey | ControlKey | ShiftKey,
197 NoModifiers = 0,
197 }; 198 };
198 199
199 // Indicates whether the browser needs to block on the ACK result for 200 // Indicates whether the browser needs to block on the ACK result for
200 // this event, and if not, why (for metrics/diagnostics purposes). 201 // this event, and if not, why (for metrics/diagnostics purposes).
201 // These values are direct mappings of the values in PlatformEvent 202 // These values are direct mappings of the values in PlatformEvent
202 // so the values can be cast between the enumerations. static_asserts 203 // so the values can be cast between the enumerations. static_asserts
203 // checking this are in web/WebInputEventConversion.cpp. 204 // checking this are in web/WebInputEventConversion.cpp.
204 enum DispatchType { 205 enum DispatchType {
205 // Event can be canceled. 206 // Event can be canceled.
206 Blocking, 207 Blocking,
(...skipping 14 matching lines...) Expand all
221 // expected to stick. If this axis is set to Free, then scrolling is not 222 // expected to stick. If this axis is set to Free, then scrolling is not
222 // stuck to any axis. 223 // stuck to any axis.
223 enum RailsMode { 224 enum RailsMode {
224 RailsModeFree = 0, 225 RailsModeFree = 0,
225 RailsModeHorizontal = 1, 226 RailsModeHorizontal = 1,
226 RailsModeVertical = 2, 227 RailsModeVertical = 2,
227 }; 228 };
228 229
229 static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey; 230 static const int InputModifiers = ShiftKey | ControlKey | AltKey | MetaKey;
230 231
232 static constexpr double TimeStampForTesting = 123.0;
233
231 double timeStampSeconds; // Seconds since platform start with microsecond 234 double timeStampSeconds; // Seconds since platform start with microsecond
232 // resolution. 235 // resolution.
233 unsigned size; // The size of this structure, for serialization. 236 unsigned size; // The size of this structure, for serialization.
234 Type type; 237 Type type;
235 int modifiers; 238 int modifiers;
236 239
237 // Returns true if the WebInputEvent |type| is a mouse event. 240 // Returns true if the WebInputEvent |type| is a mouse event.
238 static bool isMouseEventType(int type) { 241 static bool isMouseEventType(int type) {
239 return MouseTypeFirst <= type && type <= MouseTypeLast; 242 return MouseTypeFirst <= type && type <= MouseTypeLast;
240 } 243 }
(...skipping 28 matching lines...) Expand all
269 BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type); 272 BLINK_COMMON_EXPORT static const char* GetName(WebInputEvent::Type);
270 273
271 float frameScale() const { return m_frameScale; } 274 float frameScale() const { return m_frameScale; }
272 void setFrameScale(float scale) { m_frameScale = scale; } 275 void setFrameScale(float scale) { m_frameScale = scale; }
273 276
274 WebFloatPoint frameTranslate() const { return m_frameTranslate; } 277 WebFloatPoint frameTranslate() const { return m_frameTranslate; }
275 void setFrameTranslate(WebFloatPoint translate) { 278 void setFrameTranslate(WebFloatPoint translate) {
276 m_frameTranslate = translate; 279 m_frameTranslate = translate;
277 } 280 }
278 281
282 void setType(Type typeParam) { type = typeParam; }
283
284 void setModifiers(int modifiersParam) { modifiers = modifiersParam; }
285
286 void setTimeStampSeconds(double seconds) { timeStampSeconds = seconds; }
287
279 protected: 288 protected:
280 // The root frame scale. 289 // The root frame scale.
281 float m_frameScale; 290 float m_frameScale;
282 291
283 // The root frame translation (applied post scale). 292 // The root frame translation (applied post scale).
284 WebFloatPoint m_frameTranslate; 293 WebFloatPoint m_frameTranslate;
285 294
286 explicit WebInputEvent(unsigned sizeParam) { 295 WebInputEvent(unsigned sizeParam,
296 Type typeParam,
297 int modifiersParam,
298 double timeStampSecondsParam) {
299 memset(this, 0, sizeParam);
300 timeStampSeconds = timeStampSecondsParam;
301 size = sizeParam;
302 type = typeParam;
303 modifiers = modifiersParam;
304 #if DCHECK_IS_ON()
305 // If dcheck is on force failures if frame scale is not initialized
306 // correctly by causing DIV0.
307 m_frameScale = 0;
308 #else
309 m_frameScale = 1;
310 #endif
311 }
312
313 WebInputEvent(unsigned sizeParam) {
287 memset(this, 0, sizeParam); 314 memset(this, 0, sizeParam);
288 timeStampSeconds = 0.0; 315 timeStampSeconds = 0.0;
289 size = sizeParam; 316 size = sizeParam;
290 type = Undefined; 317 type = Undefined;
291 modifiers = 0;
292 #if DCHECK_IS_ON() 318 #if DCHECK_IS_ON()
293 // If dcheck is on force failures if frame scale is not initialized 319 // If dcheck is on force failures if frame scale is not initialized
294 // correctly by causing DIV0. 320 // correctly by causing DIV0.
295 m_frameScale = 0; 321 m_frameScale = 0;
296 #else 322 #else
297 m_frameScale = 1; 323 m_frameScale = 1;
298 #endif 324 #endif
299 } 325 }
300 }; 326 };
301 327
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 370
345 // |text| is the text generated by this keystroke. |unmodifiedText| is 371 // |text| is the text generated by this keystroke. |unmodifiedText| is
346 // |text|, but unmodified by an concurrently-held modifiers (except 372 // |text|, but unmodified by an concurrently-held modifiers (except
347 // shift). This is useful for working out shortcut keys. Linux and 373 // shift). This is useful for working out shortcut keys. Linux and
348 // Windows guarantee one character per event. The Mac does not, but in 374 // Windows guarantee one character per event. The Mac does not, but in
349 // reality that's all it ever gives. We're generous, and cap it a bit 375 // reality that's all it ever gives. We're generous, and cap it a bit
350 // longer. 376 // longer.
351 WebUChar text[textLengthCap]; 377 WebUChar text[textLengthCap];
352 WebUChar unmodifiedText[textLengthCap]; 378 WebUChar unmodifiedText[textLengthCap];
353 379
354 WebKeyboardEvent() 380 WebKeyboardEvent(Type type, int modifiers, double timeStampSeconds)
355 : WebInputEvent(sizeof(WebKeyboardEvent)), 381 : WebInputEvent(sizeof(WebKeyboardEvent),
356 windowsKeyCode(0), 382 type,
357 nativeKeyCode(0), 383 modifiers,
358 isSystemKey(false), 384 timeStampSeconds) {}
359 isBrowserShortcut(false) { 385
360 } 386 WebKeyboardEvent() : WebInputEvent(sizeof(WebKeyboardEvent)) {}
361 387
362 // Please refer to bug http://b/issue?id=961192, which talks about Webkit 388 // Please refer to bug http://b/issue?id=961192, which talks about Webkit
363 // keyboard event handling changes. It also mentions the list of keys 389 // keyboard event handling changes. It also mentions the list of keys
364 // which don't have associated character events. 390 // which don't have associated character events.
365 bool isCharacterKey() const { 391 bool isCharacterKey() const {
366 // TODO(dtapuska): Determine if we can remove this method and just 392 // TODO(dtapuska): Determine if we can remove this method and just
367 // not actually generate events for these instead of filtering them out. 393 // not actually generate events for these instead of filtering them out.
368 switch (windowsKeyCode) { 394 switch (windowsKeyCode) {
369 case 0x08: // VK_BACK 395 case 0x08: // VK_BACK
370 case 0x1b: // VK_ESCAPE 396 case 0x1b: // VK_ESCAPE
(...skipping 18 matching lines...) Expand all
389 int windowY; 415 int windowY;
390 416
391 // Screen coordinate 417 // Screen coordinate
392 int globalX; 418 int globalX;
393 int globalY; 419 int globalY;
394 420
395 int movementX; 421 int movementX;
396 int movementY; 422 int movementY;
397 int clickCount; 423 int clickCount;
398 424
425 WebMouseEvent(Type type, int modifiers, double timeStampSeconds)
426 : WebInputEvent(sizeof(WebMouseEvent), type, modifiers, timeStampSeconds),
427 WebPointerProperties() {}
428
399 WebMouseEvent() 429 WebMouseEvent()
400 : WebInputEvent(sizeof(WebMouseEvent)), 430 : WebInputEvent(sizeof(WebMouseEvent)), WebPointerProperties() {}
401 WebPointerProperties(),
402 x(0),
403 y(0),
404 windowX(0),
405 windowY(0),
406 globalX(0),
407 globalY(0),
408 movementX(0),
409 movementY(0),
410 clickCount(0) {}
411 431
412 protected: 432 protected:
413 explicit WebMouseEvent(unsigned sizeParam) 433 explicit WebMouseEvent(unsigned sizeParam)
414 : WebInputEvent(sizeParam), 434 : WebInputEvent(sizeParam), WebPointerProperties() {}
415 WebPointerProperties(), 435
416 x(0), 436 WebMouseEvent(unsigned sizeParam,
417 y(0), 437 Type type,
418 windowX(0), 438 int modifiers,
419 windowY(0), 439 double timeStampSeconds)
420 globalX(0), 440 : WebInputEvent(sizeParam, type, modifiers, timeStampSeconds),
421 globalY(0), 441 WebPointerProperties() {}
422 movementX(0),
423 movementY(0),
424 clickCount(0) {}
425 }; 442 };
426 443
427 // WebTouchEvent -------------------------------------------------------------- 444 // WebTouchEvent --------------------------------------------------------------
428 445
429 // TODO(e_hakkinen): Replace with WebPointerEvent. crbug.com/508283 446 // TODO(e_hakkinen): Replace with WebPointerEvent. crbug.com/508283
430 class WebTouchEvent : public WebInputEvent { 447 class WebTouchEvent : public WebInputEvent {
431 public: 448 public:
432 // Maximum number of simultaneous touches supported on 449 // Maximum number of simultaneous touches supported on
433 // Ash/Aura. 450 // Ash/Aura.
434 enum { kTouchesLengthCap = 16 }; 451 enum { kTouchesLengthCap = 16 };
(...skipping 13 matching lines...) Expand all
448 465
449 // Whether this touch event is a touchstart or a first touchmove event per 466 // Whether this touch event is a touchstart or a first touchmove event per
450 // scroll. 467 // scroll.
451 bool touchStartOrFirstTouchMove; 468 bool touchStartOrFirstTouchMove;
452 469
453 // A unique identifier for the touch event. Valid ids start at one and 470 // A unique identifier for the touch event. Valid ids start at one and
454 // increase monotonically. Zero means an unknown id. 471 // increase monotonically. Zero means an unknown id.
455 uint32_t uniqueTouchEventId; 472 uint32_t uniqueTouchEventId;
456 473
457 WebTouchEvent() 474 WebTouchEvent()
458 : WebInputEvent(sizeof(WebTouchEvent)), 475 : WebInputEvent(sizeof(WebTouchEvent)), dispatchType(Blocking) {}
459 touchesLength(0), 476
460 dispatchType(Blocking), 477 WebTouchEvent(Type type, int modifiers, double timeStampSeconds)
461 movedBeyondSlopRegion(false), 478 : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds),
462 touchStartOrFirstTouchMove(false), 479 dispatchType(Blocking) {}
463 uniqueTouchEventId(0) {}
464 }; 480 };
465 481
466 #pragma pack(pop) 482 #pragma pack(pop)
467 483
468 } // namespace blink 484 } // namespace blink
469 485
470 #endif 486 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698