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

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

Issue 2454073005: Add isComposing support for KeyboardEvents (Closed)
Patch Set: Fix windows and linux Created 4 years, 1 month 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 b0bd8899d123c4eac38cdb90ec97b0f0faaf1ef9..140f0829fb282e3b6448d57637e1e34bf869d8f4 100644
--- a/third_party/WebKit/Source/core/events/KeyboardEvent.cpp
+++ b/third_party/WebKit/Source/core/events/KeyboardEvent.cpp
@@ -24,6 +24,7 @@
#include "bindings/core/v8/DOMWrapperWorld.h"
#include "bindings/core/v8/ScriptState.h"
+#include "core/editing/InputMethodController.h"
#include "platform/WindowsKeyboardCodes.h"
#include "public/platform/Platform.h"
#include "public/platform/WebInputEvent.h"
@@ -31,8 +32,9 @@
namespace blink {
-static inline const AtomicString& eventTypeForKeyboardEventType(
- WebInputEvent::Type type) {
+namespace {
+
+const AtomicString& eventTypeForKeyboardEventType(WebInputEvent::Type type) {
switch (type) {
case WebInputEvent::KeyUp:
return EventTypeNames::keyup;
@@ -51,8 +53,7 @@ static inline const AtomicString& eventTypeForKeyboardEventType(
return EventTypeNames::keydown;
}
-static inline KeyboardEvent::KeyLocationCode keyLocationCode(
- const WebInputEvent& key) {
+KeyboardEvent::KeyLocationCode keyLocationCode(const WebInputEvent& key) {
if (key.modifiers & WebInputEvent::IsKeyPad)
return KeyboardEvent::kDomKeyLocationNumpad;
if (key.modifiers & WebInputEvent::IsLeft)
@@ -62,6 +63,17 @@ static inline KeyboardEvent::KeyLocationCode keyLocationCode(
return KeyboardEvent::kDomKeyLocationStandard;
}
+bool hasCurrentComposition(LocalDOMWindow* domWindow) {
+ if (!domWindow)
+ return false;
+ LocalFrame* localFrame = domWindow->frame();
+ if (!localFrame)
+ return false;
+ return localFrame->inputMethodController().hasComposition();
+}
+
+} // namespace
+
KeyboardEvent* KeyboardEvent::create(ScriptState* scriptState,
const AtomicString& type,
const KeyboardEventInit& initializer) {
@@ -74,12 +86,13 @@ KeyboardEvent* KeyboardEvent::create(ScriptState* scriptState,
KeyboardEvent::KeyboardEvent() : m_location(kDomKeyLocationStandard) {}
-KeyboardEvent::KeyboardEvent(const WebKeyboardEvent& key, AbstractView* view)
+KeyboardEvent::KeyboardEvent(const WebKeyboardEvent& key,
+ LocalDOMWindow* domWindow)
: UIEventWithKeyState(
eventTypeForKeyboardEventType(key.type),
true,
true,
- view,
+ domWindow,
0,
static_cast<PlatformEvent::Modifiers>(key.modifiers),
key.timeStampSeconds,
@@ -88,7 +101,8 @@ KeyboardEvent::KeyboardEvent(const WebKeyboardEvent& key, AbstractView* view)
// TODO(crbug.com/482880): Fix this initialization to lazy initialization.
m_code(Platform::current()->domCodeStringFromEnum(key.domCode)),
m_key(Platform::current()->domKeyStringFromEnum(key.domKey)),
- m_location(keyLocationCode(key)) {
+ m_location(keyLocationCode(key)),
+ m_isComposing(hasCurrentComposition(domWindow)) {
initLocationModifiers(m_location);
}
@@ -97,36 +111,13 @@ KeyboardEvent::KeyboardEvent(const AtomicString& eventType,
: UIEventWithKeyState(eventType, initializer),
m_code(initializer.code()),
m_key(initializer.key()),
- m_location(initializer.location()) {
+ m_location(initializer.location()),
+ m_isComposing(initializer.isComposing()) {
if (initializer.repeat())
m_modifiers |= PlatformEvent::IsAutoRepeat;
initLocationModifiers(initializer.location());
}
-KeyboardEvent::KeyboardEvent(const AtomicString& eventType,
- bool canBubble,
- bool cancelable,
- AbstractView* view,
- const String& code,
- const String& key,
- unsigned location,
- PlatformEvent::Modifiers modifiers,
- double plaformTimeStamp)
- : UIEventWithKeyState(
- eventType,
- canBubble,
- cancelable,
- view,
- 0,
- modifiers,
- plaformTimeStamp,
- InputDeviceCapabilities::doesntFireTouchEventsSourceCapabilities()),
- m_code(code),
- m_key(key),
- m_location(location) {
- initLocationModifiers(location);
-}
-
KeyboardEvent::~KeyboardEvent() {}
void KeyboardEvent::initKeyboardEvent(ScriptState* scriptState,
« no previous file with comments | « third_party/WebKit/Source/core/events/KeyboardEvent.h ('k') | third_party/WebKit/Source/core/events/KeyboardEvent.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698