Bug 630813 part.7 Implement IsKeyPressEventNecessary() in mozilla::widget::KeymapWrapper r=karlt

This commit is contained in:
Masayuki Nakano 2012-02-22 16:34:31 +09:00
Родитель 69b7b8cea6
Коммит 7c65f01056
3 изменённых файлов: 25 добавлений и 8 удалений

Просмотреть файл

@ -942,5 +942,23 @@ KeymapWrapper::InitKeypressEvent(nsKeyEvent& aKeyEvent,
altLatinCharCodes.mShiftedCharCode));
}
/* static */ bool
KeymapWrapper::IsKeyPressEventNecessary(GdkEventKey* aGdkKeyEvent)
{
// If this is a modifier key event, we shouldn't send keypress event.
switch (ComputeDOMKeyCode(aGdkKeyEvent->keyval)) {
case NS_VK_SHIFT:
case NS_VK_CONTROL:
case NS_VK_META:
case NS_VK_ALT:
case NS_VK_CAPS_LOCK:
case NS_VK_NUM_LOCK:
case NS_VK_SCROLL_LOCK:
return false;
default:
return true;
}
}
} // namespace widget
} // namespace mozilla

Просмотреть файл

@ -133,6 +133,12 @@ public:
*/
static void InitKeyEvent(nsKeyEvent& aKeyEvent, GdkEventKey* aGdkKeyEvent);
/**
* IsKeyPressEventNecessary() returns TRUE when aGdkKeyEvent should cause
* a DOM keypress event. Otherwise, FALSE.
*/
static bool IsKeyPressEventNecessary(GdkEventKey* aGdkKeyEvent);
protected:
/**

Просмотреть файл

@ -2996,14 +2996,7 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
// TODO: Instead of selectively excluding some keys from NS_KEY_PRESS events,
// we should instead selectively include (as per MSDN spec; no official
// spec covers KeyPress events).
if (aEvent->keyval == GDK_Shift_L
|| aEvent->keyval == GDK_Shift_R
|| aEvent->keyval == GDK_Control_L
|| aEvent->keyval == GDK_Control_R
|| aEvent->keyval == GDK_Alt_L
|| aEvent->keyval == GDK_Alt_R
|| aEvent->keyval == GDK_Meta_L
|| aEvent->keyval == GDK_Meta_R) {
if (!KeymapWrapper::IsKeyPressEventNecessary(aEvent)) {
return TRUE;
}