| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | |
| 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * 1. Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 * notice, this list of conditions and the following disclaimer in the | |
| 12 * documentation and/or other materials provided with the distribution. | |
| 13 * | |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 25 */ | |
| 26 | |
| 27 #ifndef PlatformKeyboardEvent_h | |
| 28 #define PlatformKeyboardEvent_h | |
| 29 | |
| 30 #include "platform/PlatformEvent.h" | |
| 31 #include "platform/PlatformExport.h" | |
| 32 #include "wtf/text/WTFString.h" | |
| 33 | |
| 34 namespace blink { | |
| 35 | |
| 36 class PlatformKeyboardEvent : public PlatformEvent { | |
| 37 USING_FAST_MALLOC(PlatformKeyboardEvent); | |
| 38 public: | |
| 39 PlatformKeyboardEvent() | |
| 40 : PlatformEvent(PlatformEvent::KeyDown) | |
| 41 , m_windowsVirtualKeyCode(0) | |
| 42 , m_nativeVirtualKeyCode(0) | |
| 43 , m_isSystemKey(false) | |
| 44 { | |
| 45 } | |
| 46 | |
| 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) | |
| 49 , m_text(text) | |
| 50 , m_unmodifiedText(unmodifiedText) | |
| 51 , m_code(code) | |
| 52 , m_key(key) | |
| 53 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) | |
| 54 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) | |
| 55 , m_isSystemKey(isSystemKey) | |
| 56 { | |
| 57 } | |
| 58 | |
| 59 PLATFORM_EXPORT void disambiguateKeyDownEvent(EventType); | |
| 60 | |
| 61 // Text as as generated by processing a virtual key code with a keyboard lay
out | |
| 62 // (in most cases, just a character code, but the layout can emit several | |
| 63 // characters in a single keypress event on some platforms). | |
| 64 // This may bear no resemblance to the ultimately inserted text if an input
method | |
| 65 // processes the input. | |
| 66 // Will be null for KeyUp and RawKeyDown events. | |
| 67 String text() const { return m_text; } | |
| 68 | |
| 69 // Text that would have been generated by the keyboard if no modifiers were
pressed | |
| 70 // (except for Shift); useful for shortcut (accelerator) key handling. | |
| 71 // Otherwise, same as text(). | |
| 72 String unmodifiedText() const { return m_unmodifiedText; } | |
| 73 | |
| 74 String code() const { return m_code; } | |
| 75 String key() const { return m_key; } | |
| 76 | |
| 77 // Most compatible Windows virtual key code associated with the event. | |
| 78 // Zero for Char events. | |
| 79 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } | |
| 80 | |
| 81 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } | |
| 82 | |
| 83 bool isAutoRepeat() const { return getModifiers() & IsAutoRepeat; } | |
| 84 bool isKeypad() const { return getModifiers() & IsKeyPad; } | |
| 85 bool isSystemKey() const { return m_isSystemKey; } | |
| 86 | |
| 87 PLATFORM_EXPORT static bool currentCapsLockState(); | |
| 88 PLATFORM_EXPORT static Modifiers getCurrentModifierState(); | |
| 89 | |
| 90 // Returns accesskey activator used in page keyboard shortcuts in Chrome. | |
| 91 // See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/a
ccesskey. | |
| 92 PLATFORM_EXPORT static PlatformEvent::Modifiers accessKeyModifiers(); | |
| 93 | |
| 94 protected: | |
| 95 String m_text; | |
| 96 String m_unmodifiedText; | |
| 97 String m_code; | |
| 98 String m_key; | |
| 99 int m_windowsVirtualKeyCode; | |
| 100 int m_nativeVirtualKeyCode; | |
| 101 bool m_isSystemKey; | |
| 102 | |
| 103 private: | |
| 104 friend class Internals; | |
| 105 enum OverrideCapsLockState { | |
| 106 Default, | |
| 107 On, | |
| 108 Off | |
| 109 }; | |
| 110 // Allows overriding the current caps lock state for testing purposes. | |
| 111 PLATFORM_EXPORT static void setCurrentCapsLockState(OverrideCapsLockState st
ate) { s_overrideCapsLockState = state; } | |
| 112 PLATFORM_EXPORT static OverrideCapsLockState s_overrideCapsLockState; | |
| 113 }; | |
| 114 | |
| 115 } // namespace blink | |
| 116 | |
| 117 #endif // PlatformKeyboardEvent_h | |
| OLD | NEW |