This source file includes following definitions.
- disambiguateKeyDownEvent
- currentCapsLockState
- getCurrentModifierState
#include "config.h"
#include "platform/PlatformKeyboardEvent.h"
#if OS(WIN)
#include <windows.h>
#elif OS(MACOSX)
#import <Carbon/Carbon.h>
#else
#include "platform/NotImplemented.h"
#endif
namespace WebCore {
#if OS(WIN)
static const unsigned short HIGHBITMASKSHORT = 0x8000;
#endif
void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type)
{
#if OS(WIN)
ASSERT_NOT_REACHED();
#else
ASSERT(m_type == PlatformEvent::KeyDown);
ASSERT(type == PlatformEvent::RawKeyDown || type == PlatformEvent::Char);
m_type = type;
if (type == RawKeyDown) {
m_text = String();
m_unmodifiedText = String();
} else {
m_keyIdentifier = String();
m_windowsVirtualKeyCode = 0;
#if OS(MACOSX)
if (m_text.length() == 1 && (m_text[0U] >= 0xF700 && m_text[0U] <= 0xF7FF)) {
m_text = String();
m_unmodifiedText = String();
}
#endif
}
#endif
}
bool PlatformKeyboardEvent::currentCapsLockState()
{
#if OS(WIN)
return GetKeyState(VK_CAPITAL) & 1;
#elif OS(MACOSX)
return GetCurrentKeyModifiers() & alphaLock;
#else
notImplemented();
return false;
#endif
}
void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
{
#if OS(WIN)
shiftKey = GetKeyState(VK_SHIFT) & HIGHBITMASKSHORT;
ctrlKey = GetKeyState(VK_CONTROL) & HIGHBITMASKSHORT;
altKey = GetKeyState(VK_MENU) & HIGHBITMASKSHORT;
metaKey = false;
#elif OS(MACOSX)
UInt32 currentModifiers = GetCurrentKeyModifiers();
shiftKey = currentModifiers & ::shiftKey;
ctrlKey = currentModifiers & ::controlKey;
altKey = currentModifiers & ::optionKey;
metaKey = currentModifiers & ::cmdKey;
#else
shiftKey = false;
ctrlKey = false;
altKey = false;
metaKey = false;
notImplemented();
#endif
}
}