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

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

Issue 2639273002: Give WebTouchEvent and WebKeyboardEvent their own headers (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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 #endif 327 #endif
328 } 328 }
329 329
330 double m_timeStampSeconds; // Seconds since platform start with microsecond 330 double m_timeStampSeconds; // Seconds since platform start with microsecond
331 // resolution. 331 // resolution.
332 unsigned m_size; // The size of this structure, for serialization. 332 unsigned m_size; // The size of this structure, for serialization.
333 Type m_type; 333 Type m_type;
334 int m_modifiers; 334 int m_modifiers;
335 }; 335 };
336 336
337 // WebKeyboardEvent -----------------------------------------------------------
338
339 class WebKeyboardEvent : public WebInputEvent {
340 public:
341 // Caps on string lengths so we can make them static arrays and keep
342 // them PODs.
343 static const size_t textLengthCap = 4;
344
345 // |windowsKeyCode| is the Windows key code associated with this key
346 // event. Sometimes it's direct from the event (i.e. on Windows),
347 // sometimes it's via a mapping function. If you want a list, see
348 // WebCore/platform/chromium/KeyboardCodes* . Note that this should
349 // ALWAYS store the non-locational version of a keycode as this is
350 // what is returned by the Windows API. For example, it should
351 // store VK_SHIFT instead of VK_RSHIFT. The location information
352 // should be stored in |modifiers|.
353 int windowsKeyCode;
354
355 // The actual key code genenerated by the platform. The DOM spec runs
356 // on Windows-equivalent codes (thus |windowsKeyCode| above) but it
357 // doesn't hurt to have this one around.
358 int nativeKeyCode;
359
360 // The DOM code enum of the key pressed as passed by the embedder. DOM
361 // code enum are defined in ui/events/keycodes/dom4/keycode_converter_data.h.
362 int domCode;
363
364 // The DOM key enum of the key pressed as passed by the embedder. DOM
365 // key enum are defined in ui/events/keycodes/dom3/dom_key_data.h
366 int domKey;
367
368 // This identifies whether this event was tagged by the system as being
369 // a "system key" event (see
370 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for
371 // details). Other platforms don't have this concept, but it's just
372 // easier to leave it always false than ifdef.
373 bool isSystemKey;
374
375 // Whether the event forms part of a browser-handled keyboard shortcut.
376 // This can be used to conditionally suppress Char events after a
377 // shortcut-triggering RawKeyDown goes unhandled.
378 bool isBrowserShortcut;
379
380 // |text| is the text generated by this keystroke. |unmodifiedText| is
381 // |text|, but unmodified by an concurrently-held modifiers (except
382 // shift). This is useful for working out shortcut keys. Linux and
383 // Windows guarantee one character per event. The Mac does not, but in
384 // reality that's all it ever gives. We're generous, and cap it a bit
385 // longer.
386 WebUChar text[textLengthCap];
387 WebUChar unmodifiedText[textLengthCap];
388
389 WebKeyboardEvent(Type type, int modifiers, double timeStampSeconds)
390 : WebInputEvent(sizeof(WebKeyboardEvent),
391 type,
392 modifiers,
393 timeStampSeconds) {}
394
395 WebKeyboardEvent() : WebInputEvent(sizeof(WebKeyboardEvent)) {}
396
397 // Please refer to bug http://b/issue?id=961192, which talks about Webkit
398 // keyboard event handling changes. It also mentions the list of keys
399 // which don't have associated character events.
400 bool isCharacterKey() const {
401 // TODO(dtapuska): Determine if we can remove this method and just
402 // not actually generate events for these instead of filtering them out.
403 switch (windowsKeyCode) {
404 case 0x08: // VK_BACK
405 case 0x1b: // VK_ESCAPE
406 return false;
407 }
408 return true;
409 }
410 };
411
412 // WebTouchEvent --------------------------------------------------------------
413
414 // TODO(e_hakkinen): Replace with WebPointerEvent. crbug.com/508283
415 class WebTouchEvent : public WebInputEvent {
416 public:
417 // Maximum number of simultaneous touches supported on
418 // Ash/Aura.
419 enum { kTouchesLengthCap = 16 };
420
421 unsigned touchesLength;
422 // List of all touches, regardless of state.
423 WebTouchPoint touches[kTouchesLengthCap];
424
425 // Whether the event is blocking, non-blocking, all event
426 // listeners were passive or was forced to be non-blocking.
427 DispatchType dispatchType;
428
429 // For a single touch, this is true after the touch-point has moved beyond
430 // the platform slop region. For a multitouch, this is true after any
431 // touch-point has moved (by whatever amount).
432 bool movedBeyondSlopRegion;
433
434 // Whether this touch event is a touchstart or a first touchmove event per
435 // scroll.
436 bool touchStartOrFirstTouchMove;
437
438 // A unique identifier for the touch event. Valid ids start at one and
439 // increase monotonically. Zero means an unknown id.
440 uint32_t uniqueTouchEventId;
441
442 WebTouchEvent()
443 : WebInputEvent(sizeof(WebTouchEvent)), dispatchType(Blocking) {}
444
445 WebTouchEvent(Type type, int modifiers, double timeStampSeconds)
446 : WebInputEvent(sizeof(WebTouchEvent), type, modifiers, timeStampSeconds),
447 dispatchType(Blocking) {}
448 };
449
450 #pragma pack(pop) 337 #pragma pack(pop)
451 338
452 } // namespace blink 339 } // namespace blink
453 340
454 #endif 341 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebViewTest.cpp ('k') | third_party/WebKit/public/platform/WebKeyboardEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698