Commit b04acc1e authored by dtapuska@chromium.org's avatar dtapuska@chromium.org

Cleanup IsKeyPad and IsAutoRepeat in PlatformKeyboardEvent

Switch keypad and auto repeat booleans to use enum flags. Space was reserved
for them; this just brings PlatformKeyboardEvent more inline with
WebInputEvent.

BUG=524626

Review URL: https://codereview.chromium.org/1311233004

git-svn-id: svn://svn.chromium.org/blink/trunk@201258 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 78d09f01
...@@ -78,6 +78,9 @@ public: ...@@ -78,6 +78,9 @@ public:
MetaKey = 1 << 2, MetaKey = 1 << 2,
ShiftKey = 1 << 3, ShiftKey = 1 << 3,
IsKeyPad = 1 << 4,
IsAutoRepeat = 1 << 5,
LeftButtonDown = 1 << 6, LeftButtonDown = 1 << 6,
MiddleButtonDown = 1 << 7, MiddleButtonDown = 1 << 7,
RightButtonDown = 1 << 8, RightButtonDown = 1 << 8,
......
...@@ -40,13 +40,11 @@ public: ...@@ -40,13 +40,11 @@ public:
: PlatformEvent(PlatformEvent::KeyDown) : PlatformEvent(PlatformEvent::KeyDown)
, m_windowsVirtualKeyCode(0) , m_windowsVirtualKeyCode(0)
, m_nativeVirtualKeyCode(0) , m_nativeVirtualKeyCode(0)
, m_autoRepeat(false)
, m_isKeypad(false)
, m_isSystemKey(false) , m_isSystemKey(false)
{ {
} }
PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, const String& code, const String& key, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, Modifiers modifiers, double timestamp) PlatformKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& keyIdentifier, const String& code, const String& key, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isSystemKey, Modifiers modifiers, double timestamp)
: PlatformEvent(type, modifiers, timestamp) : PlatformEvent(type, modifiers, timestamp)
, m_text(text) , m_text(text)
, m_unmodifiedText(unmodifiedText) , m_unmodifiedText(unmodifiedText)
...@@ -55,8 +53,6 @@ public: ...@@ -55,8 +53,6 @@ public:
, m_key(key) , m_key(key)
, m_windowsVirtualKeyCode(windowsVirtualKeyCode) , m_windowsVirtualKeyCode(windowsVirtualKeyCode)
, m_nativeVirtualKeyCode(nativeVirtualKeyCode) , m_nativeVirtualKeyCode(nativeVirtualKeyCode)
, m_autoRepeat(isAutoRepeat)
, m_isKeypad(isKeypad)
, m_isSystemKey(isSystemKey) , m_isSystemKey(isSystemKey)
{ {
} }
...@@ -87,8 +83,8 @@ public: ...@@ -87,8 +83,8 @@ public:
int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
bool isAutoRepeat() const { return m_autoRepeat; } bool isAutoRepeat() const { return modifiers() & IsAutoRepeat; }
bool isKeypad() const { return m_isKeypad; } bool isKeypad() const { return modifiers() & IsKeyPad; }
bool isSystemKey() const { return m_isSystemKey; } bool isSystemKey() const { return m_isSystemKey; }
PLATFORM_EXPORT static bool currentCapsLockState(); PLATFORM_EXPORT static bool currentCapsLockState();
...@@ -102,8 +98,6 @@ protected: ...@@ -102,8 +98,6 @@ protected:
String m_key; String m_key;
int m_windowsVirtualKeyCode; int m_windowsVirtualKeyCode;
int m_nativeVirtualKeyCode; int m_nativeVirtualKeyCode;
bool m_autoRepeat;
bool m_isKeypad;
bool m_isSystemKey; bool m_isSystemKey;
private: private:
......
...@@ -102,6 +102,16 @@ static unsigned toPlatformEventModifiers(int webModifiers) ...@@ -102,6 +102,16 @@ static unsigned toPlatformEventModifiers(int webModifiers)
return newModifiers; return newModifiers;
} }
static unsigned toPlatformKeyboardEventModifiers(int webModifiers)
{
unsigned newModifiers = toPlatformEventModifiers(webModifiers);
if (webModifiers & WebInputEvent::IsKeyPad)
newModifiers |= PlatformEvent::IsKeyPad;
if (webModifiers & WebInputEvent::IsAutoRepeat)
newModifiers |= PlatformEvent::IsAutoRepeat;
return newModifiers;
}
unsigned toPlatformMouseEventModifiers(int webModifiers) unsigned toPlatformMouseEventModifiers(int webModifiers)
{ {
unsigned newModifiers = toPlatformEventModifiers(webModifiers); unsigned newModifiers = toPlatformEventModifiers(webModifiers);
...@@ -303,15 +313,13 @@ PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven ...@@ -303,15 +313,13 @@ PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven
m_text = String(e.text); m_text = String(e.text);
m_unmodifiedText = String(e.unmodifiedText); m_unmodifiedText = String(e.unmodifiedText);
m_keyIdentifier = String(e.keyIdentifier); m_keyIdentifier = String(e.keyIdentifier);
m_autoRepeat = (e.modifiers & WebInputEvent::IsAutoRepeat);
m_nativeVirtualKeyCode = e.nativeKeyCode; m_nativeVirtualKeyCode = e.nativeKeyCode;
m_isKeypad = (e.modifiers & WebInputEvent::IsKeyPad);
m_isSystemKey = e.isSystemKey; m_isSystemKey = e.isSystemKey;
// TODO: BUG482880 Fix this initialization to lazy initialization. // TODO: BUG482880 Fix this initialization to lazy initialization.
m_code = Platform::current()->domCodeStringFromEnum(e.domCode); m_code = Platform::current()->domCodeStringFromEnum(e.domCode);
m_key = Platform::current()->domKeyStringFromEnum(e.domKey); m_key = Platform::current()->domKeyStringFromEnum(e.domKey);
m_modifiers = toPlatformEventModifiers(e.modifiers); m_modifiers = toPlatformKeyboardEventModifiers(e.modifiers);
// FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT // FIXME: PlatformKeyboardEvents expect a locational version of the keycode (e.g. VK_LSHIFT
// instead of VK_SHIFT). This should be changed so the location/keycode are stored separately, // instead of VK_SHIFT). This should be changed so the location/keycode are stored separately,
......
...@@ -271,7 +271,7 @@ TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) ...@@ -271,7 +271,7 @@ TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
#if OS(MACOSX) #if OS(MACOSX)
modifierKey = PlatformEvent::MetaKey; modifierKey = PlatformEvent::MetaKey;
#endif #endif
PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", "", "", 67, 0, false, false, false, modifierKey, 0.0); PlatformKeyboardEvent platformKeyboardEventC(PlatformEvent::RawKeyDown, "", "", "67", "", "", 67, 0, false, modifierKey, 0.0);
RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0); RefPtrWillBeRawPtr<KeyboardEvent> keyEventC = KeyboardEvent::create(platformKeyboardEventC, 0);
toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventC.get()); toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventC.get());
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer())); EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
...@@ -280,7 +280,7 @@ TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest) ...@@ -280,7 +280,7 @@ TEST_F(WebPluginContainerTest, CopyInsertKeyboardEventsTest)
Platform::current()->clipboard()->writePlainText(WebString("")); Platform::current()->clipboard()->writePlainText(WebString(""));
EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer())); EXPECT_EQ(WebString(""), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", "", "", 45, 0, false, false, false, modifierKey, 0.0); PlatformKeyboardEvent platformKeyboardEventInsert(PlatformEvent::RawKeyDown, "", "", "45", "", "", 45, 0, false, modifierKey, 0.0);
RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboardEventInsert, 0); RefPtrWillBeRawPtr<KeyboardEvent> keyEventInsert = KeyboardEvent::create(platformKeyboardEventInsert, 0);
toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventInsert.get()); toWebPluginContainerImpl(pluginContainerOneElement.pluginContainer())->handleEvent(keyEventInsert.get());
EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer())); EXPECT_EQ(WebString("x"), Platform::current()->clipboard()->readPlainText(WebClipboard::Buffer()));
......
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