summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 17:45:35 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 17:45:35 +0000
commitb0a52f7440bba5e8865afadc3c4c1b50cd531ecf (patch)
tree93cb2738f7a3aca480d3a88fbf92b201e3220c31 /webkit/glue/plugins
parent999d7d8721fe1a0962de952dd9d2b6cdb5611517 (diff)
downloadchromium_src-b0a52f7440bba5e8865afadc3c4c1b50cd531ecf.zip
chromium_src-b0a52f7440bba5e8865afadc3c4c1b50cd531ecf.tar.gz
chromium_src-b0a52f7440bba5e8865afadc3c4c1b50cd531ecf.tar.bz2
Simplify Mac plugin event conversion now that caps lock information is available for keys
BUG=None TEST=Caps lock continues to work in plugins Review URL: http://codereview.chromium.org/4326003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65390 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/plugin_web_event_converter_mac.mm23
1 files changed, 7 insertions, 16 deletions
diff --git a/webkit/glue/plugins/plugin_web_event_converter_mac.mm b/webkit/glue/plugins/plugin_web_event_converter_mac.mm
index 030ed06..12d5cc6 100644
--- a/webkit/glue/plugins/plugin_web_event_converter_mac.mm
+++ b/webkit/glue/plugins/plugin_web_event_converter_mac.mm
@@ -16,23 +16,14 @@ using WebKit::WebMouseWheelEvent;
namespace {
// Returns true if the caps lock flag should be set for the given event.
-// TODO: Ideally the event itself would know about the caps lock key; see
-// <http://crbug.com/38226>. This function is only a temporary workaround that
-// guesses based on live state.
bool CapsLockIsActive(const WebInputEvent& event) {
- NSUInteger current_flags = [[NSApp currentEvent] modifierFlags];
- bool caps_lock_on = (current_flags & NSAlphaShiftKeyMask) ? true : false;
- // If this a caps lock keypress, then the event stream state can be wrong.
- // Luckily, the weird event stream for caps lock makes it easy to tell whether
- // caps lock is being turned on or off.
- if (event.type == WebInputEvent::KeyDown ||
- event.type == WebInputEvent::KeyUp) {
- const WebKeyboardEvent* key_event =
- static_cast<const WebKeyboardEvent*>(&event);
- if (key_event->nativeKeyCode == 57)
- caps_lock_on = (event.type == WebInputEvent::KeyDown);
- }
- return caps_lock_on;
+ // Only key events have accurate information for the caps lock flag; see
+ // <https://bugs.webkit.org/show_bug.cgi?id=46518>.
+ // For other types, use the live state.
+ if (WebInputEvent::isKeyboardEventType(event.type))
+ return (event.modifiers & WebInputEvent::CapsLockOn) != 0;
+ else
+ return ([[NSApp currentEvent] modifierFlags] & NSAlphaShiftKeyMask) != 0;
}
} // namespace