Commit 283a6a84 authored by andersca@apple.com's avatar andersca@apple.com

2011-04-04 Anders Carlsson <andersca@apple.com>

        Reviewed by Darin Adler.

        Send NPCocoaEventFlagsChanged events
        https://bugs.webkit.org/show_bug.cgi?id=57811
        <rdar://problem/9215600>

        * Shared/WebEvent.h:
        (WebKit::WebEvent::capsLockKey):
        Add CapsLock modifier and getter.

        * Shared/mac/WebEventFactory.mm:
        (WebKit::modifiersForEvent):
        Check for NSAlphaShiftKeyMask and set the CapsLockKey modifier.

        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
        (WebKit::modifierFlags):
        Check for CapsLockKey and set NSAlphaShiftKeyMask.

        (WebKit::isFlagsChangedEvent):
        Return whether a given event is a Cocoa flags changed event.

        (WebKit::initializeKeyboardEvent):
        If this is a flags changed event, set the event type to NPCocoaEventFlagsChanged.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@82896 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ad3db521
2011-04-04 Anders Carlsson <andersca@apple.com>
Reviewed by Darin Adler.
Send NPCocoaEventFlagsChanged events
https://bugs.webkit.org/show_bug.cgi?id=57811
<rdar://problem/9215600>
* Shared/WebEvent.h:
(WebKit::WebEvent::capsLockKey):
Add CapsLock modifier and getter.
* Shared/mac/WebEventFactory.mm:
(WebKit::modifiersForEvent):
Check for NSAlphaShiftKeyMask and set the CapsLockKey modifier.
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::modifierFlags):
Check for CapsLockKey and set NSAlphaShiftKeyMask.
(WebKit::isFlagsChangedEvent):
Return whether a given event is a Cocoa flags changed event.
(WebKit::initializeKeyboardEvent):
If this is a flags changed event, set the event type to NPCocoaEventFlagsChanged.
2011-04-04 Anders Carlsson <andersca@apple.com>
Reviewed by Darin Adler.
......
......@@ -79,6 +79,7 @@ public:
ControlKey = 1 << 1,
AltKey = 1 << 2,
MetaKey = 1 << 3,
CapsLockKey = 1 << 4,
};
Type type() const { return static_cast<Type>(m_type); }
......@@ -87,6 +88,7 @@ public:
bool controlKey() const { return m_modifiers & ControlKey; }
bool altKey() const { return m_modifiers & AltKey; }
bool metaKey() const { return m_modifiers & MetaKey; }
bool capsLockKey() const { return m_modifiers & CapsLockKey; }
Modifiers modifiers() const { return static_cast<Modifiers>(m_modifiers); }
......
......@@ -1030,6 +1030,8 @@ static inline bool isKeyUpEvent(NSEvent *event)
static inline WebEvent::Modifiers modifiersForEvent(NSEvent *event)
{
unsigned modifiers = 0;
if ([event modifierFlags] & NSAlphaShiftKeyMask)
modifiers |= WebEvent::CapsLockKey;
if ([event modifierFlags] & NSShiftKeyMask)
modifiers |= WebEvent::ShiftKey;
if ([event modifierFlags] & NSControlKeyMask)
......
......@@ -647,6 +647,8 @@ static unsigned modifierFlags(const WebKeyboardEvent& keyboardEvent)
{
unsigned modifierFlags = 0;
if (keyboardEvent.capsLockKey())
modifierFlags |= NSAlphaShiftKeyMask;
if (keyboardEvent.shiftKey())
modifierFlags |= NSShiftKeyMask;
if (keyboardEvent.controlKey())
......@@ -659,20 +661,46 @@ static unsigned modifierFlags(const WebKeyboardEvent& keyboardEvent)
return modifierFlags;
}
static bool isFlagsChangedEvent(const WebKeyboardEvent& keyboardEvent)
{
switch (keyboardEvent.nativeVirtualKeyCode()) {
case 54: // Right Command
case 55: // Left Command
case 57: // Capslock
case 56: // Left Shift
case 60: // Right Shift
case 58: // Left Alt
case 61: // Right Alt
case 59: // Left Ctrl
case 62: // Right Ctrl
return true;
}
return false;
}
static NPCocoaEvent initializeKeyboardEvent(const WebKeyboardEvent& keyboardEvent)
{
NPCocoaEventType eventType;
switch (keyboardEvent.type()) {
case WebEvent::KeyDown:
eventType = NPCocoaEventKeyDown;
break;
case WebEvent::KeyUp:
eventType = NPCocoaEventKeyUp;
break;
default:
ASSERT_NOT_REACHED();
return NPCocoaEvent();
if (isFlagsChangedEvent(keyboardEvent))
eventType = NPCocoaEventFlagsChanged;
else {
switch (keyboardEvent.type()) {
case WebEvent::KeyDown:
eventType = NPCocoaEventKeyDown;
break;
case WebEvent::KeyUp:
eventType = NPCocoaEventKeyUp;
break;
default:
ASSERT_NOT_REACHED();
return NPCocoaEvent();
}
}
NPCocoaEvent event = initializeEvent(eventType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment