OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. | 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 26 matching lines...) Expand all Loading... |
37 USING_FAST_MALLOC(PlatformKeyboardEvent); | 37 USING_FAST_MALLOC(PlatformKeyboardEvent); |
38 public: | 38 public: |
39 PlatformKeyboardEvent() | 39 PlatformKeyboardEvent() |
40 : PlatformEvent(PlatformEvent::KeyDown) | 40 : PlatformEvent(PlatformEvent::KeyDown) |
41 , m_windowsVirtualKeyCode(0) | 41 , m_windowsVirtualKeyCode(0) |
42 , m_nativeVirtualKeyCode(0) | 42 , m_nativeVirtualKeyCode(0) |
43 , m_isSystemKey(false) | 43 , m_isSystemKey(false) |
44 { | 44 { |
45 } | 45 } |
46 | 46 |
47 PlatformKeyboardEvent(EventType type, const String& text, const String& unmo
difiedText, const String& keyIdentifier, const String& code, const String& key,
int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isSystemKey, Modifiers
modifiers, double timestamp) | 47 PlatformKeyboardEvent(EventType type, const String& text, const String& unmo
difiedText, const String& code, const String& key, int windowsVirtualKeyCode, in
t nativeVirtualKeyCode, bool isSystemKey, Modifiers modifiers, double timestamp) |
48 : PlatformEvent(type, modifiers, timestamp) | 48 : PlatformEvent(type, modifiers, timestamp) |
49 , m_text(text) | 49 , m_text(text) |
50 , m_unmodifiedText(unmodifiedText) | 50 , m_unmodifiedText(unmodifiedText) |
51 , m_keyIdentifier(keyIdentifier) | |
52 , m_code(code) | 51 , m_code(code) |
53 , m_key(key) | 52 , m_key(key) |
54 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) | 53 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) |
55 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) | 54 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) |
56 , m_isSystemKey(isSystemKey) | 55 , m_isSystemKey(isSystemKey) |
57 { | 56 { |
58 } | 57 } |
59 | 58 |
60 PLATFORM_EXPORT void disambiguateKeyDownEvent(EventType); | 59 PLATFORM_EXPORT void disambiguateKeyDownEvent(EventType); |
61 | 60 |
62 // Text as as generated by processing a virtual key code with a keyboard lay
out | 61 // Text as as generated by processing a virtual key code with a keyboard lay
out |
63 // (in most cases, just a character code, but the layout can emit several | 62 // (in most cases, just a character code, but the layout can emit several |
64 // characters in a single keypress event on some platforms). | 63 // characters in a single keypress event on some platforms). |
65 // This may bear no resemblance to the ultimately inserted text if an input
method | 64 // This may bear no resemblance to the ultimately inserted text if an input
method |
66 // processes the input. | 65 // processes the input. |
67 // Will be null for KeyUp and RawKeyDown events. | 66 // Will be null for KeyUp and RawKeyDown events. |
68 String text() const { return m_text; } | 67 String text() const { return m_text; } |
69 | 68 |
70 // Text that would have been generated by the keyboard if no modifiers were
pressed | 69 // Text that would have been generated by the keyboard if no modifiers were
pressed |
71 // (except for Shift); useful for shortcut (accelerator) key handling. | 70 // (except for Shift); useful for shortcut (accelerator) key handling. |
72 // Otherwise, same as text(). | 71 // Otherwise, same as text(). |
73 String unmodifiedText() const { return m_unmodifiedText; } | 72 String unmodifiedText() const { return m_unmodifiedText; } |
74 | 73 |
75 String keyIdentifier() const { return m_keyIdentifier; } | |
76 | |
77 String code() const { return m_code; } | 74 String code() const { return m_code; } |
78 String key() const { return m_key; } | 75 String key() const { return m_key; } |
79 | 76 |
80 // Most compatible Windows virtual key code associated with the event. | 77 // Most compatible Windows virtual key code associated with the event. |
81 // Zero for Char events. | 78 // Zero for Char events. |
82 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } | 79 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } |
83 | 80 |
84 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } | 81 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } |
85 | 82 |
86 bool isAutoRepeat() const { return getModifiers() & IsAutoRepeat; } | 83 bool isAutoRepeat() const { return getModifiers() & IsAutoRepeat; } |
87 bool isKeypad() const { return getModifiers() & IsKeyPad; } | 84 bool isKeypad() const { return getModifiers() & IsKeyPad; } |
88 bool isSystemKey() const { return m_isSystemKey; } | 85 bool isSystemKey() const { return m_isSystemKey; } |
89 | 86 |
90 PLATFORM_EXPORT static bool currentCapsLockState(); | 87 PLATFORM_EXPORT static bool currentCapsLockState(); |
91 PLATFORM_EXPORT static Modifiers getCurrentModifierState(); | 88 PLATFORM_EXPORT static Modifiers getCurrentModifierState(); |
92 | 89 |
93 // Returns accesskey activator used in page keyboard shortcuts in Chrome. | 90 // Returns accesskey activator used in page keyboard shortcuts in Chrome. |
94 // See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/a
ccesskey. | 91 // See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/a
ccesskey. |
95 PLATFORM_EXPORT static PlatformEvent::Modifiers accessKeyModifiers(); | 92 PLATFORM_EXPORT static PlatformEvent::Modifiers accessKeyModifiers(); |
96 | 93 |
97 protected: | 94 protected: |
98 String m_text; | 95 String m_text; |
99 String m_unmodifiedText; | 96 String m_unmodifiedText; |
100 String m_keyIdentifier; | |
101 String m_code; | 97 String m_code; |
102 String m_key; | 98 String m_key; |
103 int m_windowsVirtualKeyCode; | 99 int m_windowsVirtualKeyCode; |
104 int m_nativeVirtualKeyCode; | 100 int m_nativeVirtualKeyCode; |
105 bool m_isSystemKey; | 101 bool m_isSystemKey; |
106 | 102 |
107 private: | 103 private: |
108 friend class Internals; | 104 friend class Internals; |
109 enum OverrideCapsLockState { | 105 enum OverrideCapsLockState { |
110 Default, | 106 Default, |
111 On, | 107 On, |
112 Off | 108 Off |
113 }; | 109 }; |
114 // Allows overriding the current caps lock state for testing purposes. | 110 // Allows overriding the current caps lock state for testing purposes. |
115 PLATFORM_EXPORT static void setCurrentCapsLockState(OverrideCapsLockState st
ate) { s_overrideCapsLockState = state; } | 111 PLATFORM_EXPORT static void setCurrentCapsLockState(OverrideCapsLockState st
ate) { s_overrideCapsLockState = state; } |
116 PLATFORM_EXPORT static OverrideCapsLockState s_overrideCapsLockState; | 112 PLATFORM_EXPORT static OverrideCapsLockState s_overrideCapsLockState; |
117 }; | 113 }; |
118 | 114 |
119 } // namespace blink | 115 } // namespace blink |
120 | 116 |
121 #endif // PlatformKeyboardEvent_h | 117 #endif // PlatformKeyboardEvent_h |
OLD | NEW |