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

Side by Side Diff: Source/core/events/KeyboardEvent.cpp

Issue 797243003: [Events] Propagate IME composition event to JS on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 * Copyright (C) 2003, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 10 matching lines...) Expand all
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/events/KeyboardEvent.h" 24 #include "core/events/KeyboardEvent.h"
25 25
26 #include "platform/PlatformKeyboardEvent.h" 26 #include "platform/PlatformKeyboardEvent.h"
27 #include "platform/WindowsKeyboardCodes.h" 27 #include "platform/WindowsKeyboardCodes.h"
28 28
29 namespace blink { 29 namespace blink {
30 30
31 namespace {
32
33 #if OS(ANDROID)
34 int kInputMethodEditorCompositionKeyCode = 229;
bcwhite 2015/01/12 21:02:44 Is this constant available anywhere else already o
huangs 2015/01/12 23:25:57 Searched for 229 and 0xE5. Something close is ht
35 #endif
36
37 } // namespace
38
31 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::T ype type) 39 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformEvent::T ype type)
32 { 40 {
33 switch (type) { 41 switch (type) {
34 case PlatformEvent::KeyUp: 42 case PlatformEvent::KeyUp:
35 return EventTypeNames::keyup; 43 return EventTypeNames::keyup;
36 case PlatformEvent::RawKeyDown: 44 case PlatformEvent::RawKeyDown:
37 return EventTypeNames::keydown; 45 return EventTypeNames::keydown;
38 case PlatformEvent::Char: 46 case PlatformEvent::Char:
39 return EventTypeNames::keypress; 47 return EventTypeNames::keypress;
40 case PlatformEvent::KeyDown: 48 case PlatformEvent::KeyDown:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return false; 164 return false;
157 } 165 }
158 166
159 int KeyboardEvent::keyCode() const 167 int KeyboardEvent::keyCode() const
160 { 168 {
161 // IE: virtual key code for keyup/keydown, character code for keypress 169 // IE: virtual key code for keyup/keydown, character code for keypress
162 // Firefox: virtual key code for keyup/keydown, zero for keypress 170 // Firefox: virtual key code for keyup/keydown, zero for keypress
163 // We match IE. 171 // We match IE.
164 if (!m_keyEvent) 172 if (!m_keyEvent)
165 return 0; 173 return 0;
174
175 #if OS(ANDROID)
bcwhite 2015/01/12 21:02:44 // TODO: Check if this applies to other OS
huangs 2015/01/12 23:25:57 Done (using FIXME instead).
176 // If the key event belongs to IME composition then propagate to JS.
177 if (m_keyEvent->nativeVirtualKeyCode() == kInputMethodEditorCompositionKeyCo de)
178 return kInputMethodEditorCompositionKeyCode;
179 #endif
180
166 if (type() == EventTypeNames::keydown || type() == EventTypeNames::keyup) 181 if (type() == EventTypeNames::keydown || type() == EventTypeNames::keyup)
167 return windowsVirtualKeyCodeWithoutLocation(m_keyEvent->windowsVirtualKe yCode()); 182 return windowsVirtualKeyCodeWithoutLocation(m_keyEvent->windowsVirtualKe yCode());
168 183
169 return charCode(); 184 return charCode();
170 } 185 }
171 186
172 int KeyboardEvent::charCode() const 187 int KeyboardEvent::charCode() const
173 { 188 {
174 // IE: not supported 189 // IE: not supported
175 // Firefox: 0 for keydown/keyup events, character code for keypress 190 // Firefox: 0 for keydown/keyup events, character code for keypress
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 { 228 {
214 } 229 }
215 230
216 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) c onst 231 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher& dispatcher) c onst
217 { 232 {
218 // Make sure not to return true if we already took default action while hand ling the event. 233 // Make sure not to return true if we already took default action while hand ling the event.
219 return EventDispatchMediator::dispatchEvent(dispatcher) && !event().defaultH andled(); 234 return EventDispatchMediator::dispatchEvent(dispatcher) && !event().defaultH andled();
220 } 235 }
221 236
222 } // namespace blink 237 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698