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

Side by Side Diff: Source/platform/PlatformKeyboardEvent.h

Issue 1311233004: Cleanup IsKeyPad and IsAutoRepeat in PlatformKeyboardEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « Source/platform/PlatformEvent.h ('k') | Source/web/WebInputEventConversion.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 33
34 namespace blink { 34 namespace blink {
35 35
36 class PlatformKeyboardEvent : public PlatformEvent { 36 class PlatformKeyboardEvent : public PlatformEvent {
37 WTF_MAKE_FAST_ALLOCATED(PlatformKeyboardEvent); 37 WTF_MAKE_FAST_ALLOCATED(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_autoRepeat(false)
44 , m_isKeypad(false)
45 , m_isSystemKey(false) 43 , m_isSystemKey(false)
46 { 44 {
47 } 45 }
48 46
49 PlatformKeyboardEvent(Type type, const String& text, const String& unmodifie dText, const String& keyIdentifier, const String& code, const String& key, int w indowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad , bool isSystemKey, Modifiers modifiers, double timestamp) 47 PlatformKeyboardEvent(Type type, const String& text, const String& unmodifie dText, const String& keyIdentifier, const String& code, const String& key, int w indowsVirtualKeyCode, int nativeVirtualKeyCode, bool isSystemKey, Modifiers modi fiers, double timestamp)
50 : PlatformEvent(type, modifiers, timestamp) 48 : PlatformEvent(type, modifiers, timestamp)
51 , m_text(text) 49 , m_text(text)
52 , m_unmodifiedText(unmodifiedText) 50 , m_unmodifiedText(unmodifiedText)
53 , m_keyIdentifier(keyIdentifier) 51 , m_keyIdentifier(keyIdentifier)
54 , m_code(code) 52 , m_code(code)
55 , m_key(key) 53 , m_key(key)
56 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) 54 , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
57 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) 55 , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
58 , m_autoRepeat(isAutoRepeat)
59 , m_isKeypad(isKeypad)
60 , m_isSystemKey(isSystemKey) 56 , m_isSystemKey(isSystemKey)
61 { 57 {
62 } 58 }
63 59
64 PLATFORM_EXPORT void disambiguateKeyDownEvent(Type); 60 PLATFORM_EXPORT void disambiguateKeyDownEvent(Type);
65 61
66 // Text as as generated by processing a virtual key code with a keyboard lay out 62 // Text as as generated by processing a virtual key code with a keyboard lay out
67 // (in most cases, just a character code, but the layout can emit several 63 // (in most cases, just a character code, but the layout can emit several
68 // characters in a single keypress event on some platforms). 64 // characters in a single keypress event on some platforms).
69 // This may bear no resemblance to the ultimately inserted text if an input method 65 // This may bear no resemblance to the ultimately inserted text if an input method
(...skipping 10 matching lines...) Expand all
80 76
81 String code() const { return m_code; } 77 String code() const { return m_code; }
82 String key() const { return m_key; } 78 String key() const { return m_key; }
83 79
84 // Most compatible Windows virtual key code associated with the event. 80 // Most compatible Windows virtual key code associated with the event.
85 // Zero for Char events. 81 // Zero for Char events.
86 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } 82 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
87 83
88 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } 84 int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
89 85
90 bool isAutoRepeat() const { return m_autoRepeat; } 86 bool isAutoRepeat() const { return modifiers() & IsAutoRepeat; }
91 bool isKeypad() const { return m_isKeypad; } 87 bool isKeypad() const { return modifiers() & IsKeyPad; }
92 bool isSystemKey() const { return m_isSystemKey; } 88 bool isSystemKey() const { return m_isSystemKey; }
93 89
94 PLATFORM_EXPORT static bool currentCapsLockState(); 90 PLATFORM_EXPORT static bool currentCapsLockState();
95 PLATFORM_EXPORT static void getCurrentModifierState(bool& shiftKey, bool& ct rlKey, bool& altKey, bool& metaKey); 91 PLATFORM_EXPORT static void getCurrentModifierState(bool& shiftKey, bool& ct rlKey, bool& altKey, bool& metaKey);
96 92
97 protected: 93 protected:
98 String m_text; 94 String m_text;
99 String m_unmodifiedText; 95 String m_unmodifiedText;
100 String m_keyIdentifier; 96 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_autoRepeat;
106 bool m_isKeypad;
107 bool m_isSystemKey; 101 bool m_isSystemKey;
108 102
109 private: 103 private:
110 friend class Internals; 104 friend class Internals;
111 enum OverrideCapsLockState { 105 enum OverrideCapsLockState {
112 Default, 106 Default,
113 On, 107 On,
114 Off 108 Off
115 }; 109 };
116 // Allows overriding the current caps lock state for testing purposes. 110 // Allows overriding the current caps lock state for testing purposes.
117 PLATFORM_EXPORT static void setCurrentCapsLockState(OverrideCapsLockState st ate) { s_overrideCapsLockState = state; } 111 PLATFORM_EXPORT static void setCurrentCapsLockState(OverrideCapsLockState st ate) { s_overrideCapsLockState = state; }
118 PLATFORM_EXPORT static OverrideCapsLockState s_overrideCapsLockState; 112 PLATFORM_EXPORT static OverrideCapsLockState s_overrideCapsLockState;
119 }; 113 };
120 114
121 } // namespace blink 115 } // namespace blink
122 116
123 #endif // PlatformKeyboardEvent_h 117 #endif // PlatformKeyboardEvent_h
OLDNEW
« no previous file with comments | « Source/platform/PlatformEvent.h ('k') | Source/web/WebInputEventConversion.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698