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 20 matching lines...) Expand all Loading... |
31 #if OS(WINDOWS) | 31 #if OS(WINDOWS) |
32 #include "WindowsExtras.h" | 32 #include "WindowsExtras.h" |
33 #endif | 33 #endif |
34 #include <wtf/text/WTFString.h> | 34 #include <wtf/text/WTFString.h> |
35 | 35 |
36 #if PLATFORM(MAC) | 36 #if PLATFORM(MAC) |
37 #include <wtf/RetainPtr.h> | 37 #include <wtf/RetainPtr.h> |
38 OBJC_CLASS NSEvent; | 38 OBJC_CLASS NSEvent; |
39 #endif | 39 #endif |
40 | 40 |
41 #if PLATFORM(GTK) | |
42 typedef struct _GdkEventKey GdkEventKey; | |
43 #include "CompositionResults.h" | |
44 #endif | |
45 | |
46 #if PLATFORM(QT) | |
47 QT_BEGIN_NAMESPACE | |
48 class QKeyEvent; | |
49 QT_END_NAMESPACE | |
50 #endif | |
51 | |
52 #if PLATFORM(BLACKBERRY) | |
53 namespace BlackBerry { | |
54 namespace Platform { | |
55 class KeyboardEvent; | |
56 } | |
57 } | |
58 #endif | |
59 | |
60 namespace WebCore { | 41 namespace WebCore { |
61 | 42 |
62 class PlatformKeyboardEvent : public PlatformEvent { | 43 class PlatformKeyboardEvent : public PlatformEvent { |
63 WTF_MAKE_FAST_ALLOCATED; | 44 WTF_MAKE_FAST_ALLOCATED; |
64 public: | 45 public: |
65 PlatformKeyboardEvent() | 46 PlatformKeyboardEvent() |
66 : PlatformEvent(PlatformEvent::KeyDown) | 47 : PlatformEvent(PlatformEvent::KeyDown) |
67 , m_windowsVirtualKeyCode(0) | 48 , m_windowsVirtualKeyCode(0) |
68 , m_nativeVirtualKeyCode(0) | 49 , m_nativeVirtualKeyCode(0) |
69 , m_macCharCode(0) | 50 , m_macCharCode(0) |
70 , m_autoRepeat(false) | 51 , m_autoRepeat(false) |
71 , m_isKeypad(false) | 52 , m_isKeypad(false) |
72 , m_isSystemKey(false) | 53 , m_isSystemKey(false) |
73 #if PLATFORM(BLACKBERRY) | |
74 , m_unmodifiedCharacter(0) | |
75 #endif | |
76 #if PLATFORM(GTK) | |
77 , m_gdkEventKey(0) | |
78 #endif | |
79 #if PLATFORM(QT) | |
80 , m_qtEvent(0) | |
81 #endif | |
82 { | 54 { |
83 } | 55 } |
84 | 56 |
85 PlatformKeyboardEvent(Type type, const String& text, const String& unmod
ifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVir
tualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey
, Modifiers modifiers, double timestamp) | 57 PlatformKeyboardEvent(Type type, const String& text, const String& unmod
ifiedText, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVir
tualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey
, Modifiers modifiers, double timestamp) |
86 : PlatformEvent(type, modifiers, timestamp) | 58 : PlatformEvent(type, modifiers, timestamp) |
87 , m_text(text) | 59 , m_text(text) |
88 , m_unmodifiedText(unmodifiedText) | 60 , m_unmodifiedText(unmodifiedText) |
89 , m_keyIdentifier(keyIdentifier) | 61 , m_keyIdentifier(keyIdentifier) |
90 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) | 62 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) |
91 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) | 63 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) |
(...skipping 28 matching lines...) Expand all Loading... |
120 | 92 |
121 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } | 93 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } |
122 int macCharCode() const { return m_macCharCode; } | 94 int macCharCode() const { return m_macCharCode; } |
123 | 95 |
124 bool isAutoRepeat() const { return m_autoRepeat; } | 96 bool isAutoRepeat() const { return m_autoRepeat; } |
125 bool isKeypad() const { return m_isKeypad; } | 97 bool isKeypad() const { return m_isKeypad; } |
126 bool isSystemKey() const { return m_isSystemKey; } | 98 bool isSystemKey() const { return m_isSystemKey; } |
127 | 99 |
128 static bool currentCapsLockState(); | 100 static bool currentCapsLockState(); |
129 static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool&
altKey, bool& metaKey); | 101 static void getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool&
altKey, bool& metaKey); |
130 | |
131 #if PLATFORM(BLACKBERRY) | |
132 unsigned unmodifiedCharacter() const { return m_unmodifiedCharacter; } | |
133 #endif | |
134 | |
135 #if PLATFORM(MAC) | |
136 NSEvent* macEvent() const { return m_macEvent.get(); } | |
137 #endif | |
138 | |
139 #if PLATFORM(WIN) | |
140 PlatformKeyboardEvent(HWND, WPARAM, LPARAM, Type, bool); | |
141 #endif | |
142 | |
143 #if PLATFORM(GTK) | |
144 PlatformKeyboardEvent(GdkEventKey*, const CompositionResults&); | |
145 GdkEventKey* gdkEventKey() const { return m_gdkEventKey; } | |
146 const CompositionResults& compositionResults() const { return m_composit
ionResults; } | |
147 | |
148 // Used by WebKit2 | |
149 static String keyIdentifierForGdkKeyCode(unsigned); | |
150 static int windowsKeyCodeForGdkKeyCode(unsigned); | |
151 static String singleCharacterString(unsigned); | |
152 #endif | |
153 | |
154 #if PLATFORM(QT) | |
155 PlatformKeyboardEvent(QKeyEvent*); | |
156 QKeyEvent* qtEvent() const { return m_qtEvent; } | |
157 uint32_t nativeModifiers() const; | |
158 uint32_t nativeScanCode() const; | |
159 #endif | |
160 | |
161 #if PLATFORM(BLACKBERRY) | |
162 PlatformKeyboardEvent(const BlackBerry::Platform::KeyboardEvent&); | |
163 #endif | |
164 | |
165 protected: | 102 protected: |
166 String m_text; | 103 String m_text; |
167 String m_unmodifiedText; | 104 String m_unmodifiedText; |
168 String m_keyIdentifier; | 105 String m_keyIdentifier; |
169 int m_windowsVirtualKeyCode; | 106 int m_windowsVirtualKeyCode; |
170 int m_nativeVirtualKeyCode; | 107 int m_nativeVirtualKeyCode; |
171 int m_macCharCode; | 108 int m_macCharCode; |
172 bool m_autoRepeat; | 109 bool m_autoRepeat; |
173 bool m_isKeypad; | 110 bool m_isKeypad; |
174 bool m_isSystemKey; | 111 bool m_isSystemKey; |
175 | |
176 #if PLATFORM(BLACKBERRY) | |
177 unsigned m_unmodifiedCharacter; | |
178 #endif | |
179 | |
180 #if PLATFORM(MAC) | |
181 RetainPtr<NSEvent> m_macEvent; | |
182 #endif | |
183 #if PLATFORM(GTK) | |
184 GdkEventKey* m_gdkEventKey; | |
185 CompositionResults m_compositionResults; | |
186 #endif | |
187 #if PLATFORM(QT) | |
188 QKeyEvent* m_qtEvent; | |
189 #endif | |
190 }; | 112 }; |
191 | 113 |
192 #if PLATFORM(QT) | |
193 // Used by WebKit2. | |
194 String keyIdentifierForQtKeyCode(int keyCode); | |
195 int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad = false); | |
196 #endif | |
197 | |
198 } // namespace WebCore | 114 } // namespace WebCore |
199 | 115 |
200 #endif // PlatformKeyboardEvent_h | 116 #endif // PlatformKeyboardEvent_h |
OLD | NEW |