| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WebKeyboardEvent_h |
| 6 #define WebKeyboardEvent_h |
| 7 |
| 8 #include "WebInputEvent.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 // See WebInputEvent.h for details why this pack is here. |
| 13 #pragma pack(push, 4) |
| 14 |
| 15 // WebKeyboardEvent ----------------------------------------------------------- |
| 16 |
| 17 class WebKeyboardEvent : public WebInputEvent { |
| 18 public: |
| 19 // Caps on string lengths so we can make them static arrays and keep |
| 20 // them PODs. |
| 21 static const size_t textLengthCap = 4; |
| 22 |
| 23 // |windowsKeyCode| is the Windows key code associated with this key |
| 24 // event. Sometimes it's direct from the event (i.e. on Windows), |
| 25 // sometimes it's via a mapping function. If you want a list, see |
| 26 // WebCore/platform/chromium/KeyboardCodes* . Note that this should |
| 27 // ALWAYS store the non-locational version of a keycode as this is |
| 28 // what is returned by the Windows API. For example, it should |
| 29 // store VK_SHIFT instead of VK_RSHIFT. The location information |
| 30 // should be stored in |modifiers|. |
| 31 int windowsKeyCode; |
| 32 |
| 33 // The actual key code genenerated by the platform. The DOM spec runs |
| 34 // on Windows-equivalent codes (thus |windowsKeyCode| above) but it |
| 35 // doesn't hurt to have this one around. |
| 36 int nativeKeyCode; |
| 37 |
| 38 // The DOM code enum of the key pressed as passed by the embedder. DOM |
| 39 // code enum are defined in ui/events/keycodes/dom4/keycode_converter_data.h. |
| 40 int domCode; |
| 41 |
| 42 // The DOM key enum of the key pressed as passed by the embedder. DOM |
| 43 // key enum are defined in ui/events/keycodes/dom3/dom_key_data.h |
| 44 int domKey; |
| 45 |
| 46 // This identifies whether this event was tagged by the system as being |
| 47 // a "system key" event (see |
| 48 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx for |
| 49 // details). Other platforms don't have this concept, but it's just |
| 50 // easier to leave it always false than ifdef. |
| 51 bool isSystemKey; |
| 52 |
| 53 // Whether the event forms part of a browser-handled keyboard shortcut. |
| 54 // This can be used to conditionally suppress Char events after a |
| 55 // shortcut-triggering RawKeyDown goes unhandled. |
| 56 bool isBrowserShortcut; |
| 57 |
| 58 // |text| is the text generated by this keystroke. |unmodifiedText| is |
| 59 // |text|, but unmodified by an concurrently-held modifiers (except |
| 60 // shift). This is useful for working out shortcut keys. Linux and |
| 61 // Windows guarantee one character per event. The Mac does not, but in |
| 62 // reality that's all it ever gives. We're generous, and cap it a bit |
| 63 // longer. |
| 64 WebUChar text[textLengthCap]; |
| 65 WebUChar unmodifiedText[textLengthCap]; |
| 66 |
| 67 WebKeyboardEvent(Type type, int modifiers, double timeStampSeconds) |
| 68 : WebInputEvent(sizeof(WebKeyboardEvent), |
| 69 type, |
| 70 modifiers, |
| 71 timeStampSeconds) {} |
| 72 |
| 73 WebKeyboardEvent() : WebInputEvent(sizeof(WebKeyboardEvent)) {} |
| 74 |
| 75 // Please refer to bug http://b/issue?id=961192, which talks about Webkit |
| 76 // keyboard event handling changes. It also mentions the list of keys |
| 77 // which don't have associated character events. |
| 78 bool isCharacterKey() const { |
| 79 // TODO(dtapuska): Determine if we can remove this method and just |
| 80 // not actually generate events for these instead of filtering them out. |
| 81 switch (windowsKeyCode) { |
| 82 case 0x08: // VK_BACK |
| 83 case 0x1b: // VK_ESCAPE |
| 84 return false; |
| 85 } |
| 86 return true; |
| 87 } |
| 88 }; |
| 89 |
| 90 #pragma pack(pop) |
| 91 |
| 92 } // namespace blink |
| 93 |
| 94 #endif // WebKeyboardEvent_h |
| OLD | NEW |