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

Unified Diff: third_party/WebKit/Source/core/events/KeyboardEvent.cpp

Issue 2290313002: Remove PlatformKeyboardEvent (Closed)
Patch Set: One more fix Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/events/KeyboardEvent.cpp
diff --git a/third_party/WebKit/Source/core/events/KeyboardEvent.cpp b/third_party/WebKit/Source/core/events/KeyboardEvent.cpp
index 022698398a3e82288b704c5ce5db0b8fc4516c21..d0c4eacd48da6436775c31f64985494acdbcab5b 100644
--- a/third_party/WebKit/Source/core/events/KeyboardEvent.cpp
+++ b/third_party/WebKit/Source/core/events/KeyboardEvent.cpp
@@ -24,38 +24,39 @@
#include "bindings/core/v8/DOMWrapperWorld.h"
#include "bindings/core/v8/ScriptState.h"
-#include "platform/PlatformKeyboardEvent.h"
#include "platform/WindowsKeyboardCodes.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebInputEvent.h"
#include "wtf/PtrUtil.h"
namespace blink {
-static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::EventType type)
+static inline const AtomicString& eventTypeForKeyboardEventType(WebInputEvent::Type type)
{
switch (type) {
- case PlatformEvent::KeyUp:
- return EventTypeNames::keyup;
- case PlatformEvent::RawKeyDown:
- return EventTypeNames::keydown;
- case PlatformEvent::Char:
- return EventTypeNames::keypress;
- case PlatformEvent::KeyDown:
- // The caller should disambiguate the combined event into RawKeyDown or Char events.
- break;
- default:
- break;
+ case WebInputEvent::KeyUp:
+ return EventTypeNames::keyup;
+ case WebInputEvent::RawKeyDown:
+ return EventTypeNames::keydown;
+ case WebInputEvent::Char:
+ return EventTypeNames::keypress;
+ case WebInputEvent::KeyDown:
+ // The caller should disambiguate the combined event into RawKeyDown or Char events.
+ break;
+ default:
+ break;
}
NOTREACHED();
return EventTypeNames::keydown;
}
-static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeyboardEvent& key)
+static inline KeyboardEvent::KeyLocationCode keyLocationCode(const WebInputEvent& key)
{
- if (key.isKeypad())
+ if (key.modifiers & WebInputEvent::IsKeyPad)
return KeyboardEvent::kDomKeyLocationNumpad;
- if (key.getModifiers() & PlatformEvent::IsLeft)
+ if (key.modifiers & WebInputEvent::IsLeft)
return KeyboardEvent::kDomKeyLocationLeft;
- if (key.getModifiers() & PlatformEvent::IsRight)
+ if (key.modifiers & WebInputEvent::IsRight)
return KeyboardEvent::kDomKeyLocationRight;
return KeyboardEvent::kDomKeyLocationStandard;
}
@@ -72,11 +73,12 @@ KeyboardEvent::KeyboardEvent()
{
}
-KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view)
- : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), true, true, view, 0, key.getModifiers(), key.timestamp(), InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities())
- , m_keyEvent(wrapUnique(new PlatformKeyboardEvent(key)))
- , m_code(key.code())
- , m_key(key.key())
+KeyboardEvent::KeyboardEvent(const WebKeyboardEvent& key, AbstractView* view)
+ : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type), true, true, view, 0, static_cast<PlatformEvent::Modifiers>(key.modifiers), key.timeStampSeconds, InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities())
+ , m_keyEvent(wrapUnique(new WebKeyboardEvent(key)))
+ // TODO: BUG482880 Fix this initialization to lazy initialization.
+ , m_code(Platform::current()->domCodeStringFromEnum(key.domCode))
+ , m_key(Platform::current()->domKeyStringFromEnum(key.domKey))
, m_location(keyLocationCode(key))
{
initLocationModifiers(m_location);
@@ -135,12 +137,12 @@ int KeyboardEvent::keyCode() const
#if OS(ANDROID)
// FIXME: Check to see if this applies to other OS.
// If the key event belongs to IME composition then propagate to JS.
- if (m_keyEvent->nativeVirtualKeyCode() == 0xE5) // VKEY_PROCESSKEY
- return m_keyEvent->nativeVirtualKeyCode();
+ if (m_keyEvent->nativeKeyCode == 0xE5) // VKEY_PROCESSKEY
+ return m_keyEvent->nativeKeyCode;
#endif
if (type() == EventTypeNames::keydown || type() == EventTypeNames::keyup)
- return m_keyEvent->windowsVirtualKeyCode();
+ return m_keyEvent->windowsKeyCode;
return charCode();
}
@@ -153,8 +155,7 @@ int KeyboardEvent::charCode() const
if (!m_keyEvent || (type() != EventTypeNames::keypress))
return 0;
- String text = m_keyEvent->text();
- return static_cast<int>(text.characterStartingAt(0));
+ return m_keyEvent->text[0];
}
const AtomicString& KeyboardEvent::interfaceName() const

Powered by Google App Engine
This is Rietveld 408576698