Commit 80afbdbf authored by noel@chromium.org's avatar noel@chromium.org

Add a GTK support routine that returns a simulated nativeKeyCode for a given

windowKeyCode.  Simulated since there's no keyboard attached when testing in
webkit DRT, so DRT::eventSender.keyDown() must simulate keyboard events.

https://bugs.webkit.org/show_bug.cgi?id=66679

BUG=94211
TEST=webkit LayoutTests/plugins/keyboard-events.html

Review URL: http://codereview.chromium.org/7740048

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98599 0039d316-1c4b-4281-b951-d872f2087c98
parent afc941e8
...@@ -621,6 +621,15 @@ int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift) { ...@@ -621,6 +621,15 @@ int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift) {
} }
} }
int GdkNativeKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift) {
int keyval = GdkKeyCodeForWindowsKeyCode(keycode, shift);
GdkKeymapKey* keys;
gint n_keys;
if (keyval && gdk_keymap_get_entries_for_keyval(0, keyval, &keys, &n_keys))
return keys[0].keycode;
return 0;
}
KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event) { KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event) {
KeyboardCode keycode = WindowsKeyCodeForGdkKeyCode(event->keyval); KeyboardCode keycode = WindowsKeyCodeForGdkKeyCode(event->keyval);
#ifdef USE_X11 #ifdef USE_X11
......
...@@ -48,6 +48,11 @@ UI_EXPORT KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode); ...@@ -48,6 +48,11 @@ UI_EXPORT KeyboardCode WindowsKeyCodeForGdkKeyCode(int keycode);
UI_EXPORT int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift); UI_EXPORT int GdkKeyCodeForWindowsKeyCode(KeyboardCode keycode, bool shift);
// For WebKit DRT testing: simulate the native keycode for the given
// input |keycode|. Return the native keycode.
UI_EXPORT int GdkNativeKeyCodeForWindowsKeyCode(KeyboardCode keycode,
bool shift);
UI_EXPORT KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event); UI_EXPORT KeyboardCode KeyboardCodeFromGdkEventKey(GdkEventKey* event);
} // namespace ui } // namespace ui
......
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
#if defined(OS_LINUX)
#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
#endif
#include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_implementation.h" #include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_surface.h" #include "ui/gfx/gl/gl_surface.h"
...@@ -612,6 +615,14 @@ void OpenFileSystem(WebFrame* frame, WebFileSystem::Type type, ...@@ -612,6 +615,14 @@ void OpenFileSystem(WebFrame* frame, WebFileSystem::Type type,
fileSystem->OpenFileSystem(frame, type, size, create, callbacks); fileSystem->OpenFileSystem(frame, type, size, create, callbacks);
} }
// Keyboard code
#if defined(OS_LINUX)
int NativeKeyCodeForWindowsKeyCode(int keycode, bool shift) {
ui::KeyboardCode code = static_cast<ui::KeyboardCode>(keycode);
return ui::GdkNativeKeyCodeForWindowsKeyCode(code, shift);
}
#endif
// Timers // Timers
double GetForegroundTabTimerInterval() { double GetForegroundTabTimerInterval() {
return webkit_glue::kForegroundTabTimerInterval; return webkit_glue::kForegroundTabTimerInterval;
......
...@@ -212,6 +212,10 @@ enum { ...@@ -212,6 +212,10 @@ enum {
VKEY_F1 = ui::VKEY_F1, VKEY_F1 = ui::VKEY_F1,
}; };
#if defined(OS_LINUX)
int NativeKeyCodeForWindowsKeyCode(int keycode, bool shift);
#endif
// - Timers // - Timers
double GetForegroundTabTimerInterval(); double GetForegroundTabTimerInterval();
......
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