Bug 501496 part.4 Don't dispatch keypress events if defaultPrevent() of the keydown event is called on Qt r=smaug+romaxa

This commit is contained in:
Masayuki Nakano 2013-07-25 15:09:28 +09:00
parent 9cfb44c724
commit 87981fb43c

View File

@ -1523,8 +1523,6 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
// The user has done something.
UserActivity();
bool setNoDefault = false;
if (aEvent->key() == Qt::Key_AltGr) {
sAltGrModifier = true;
}
@ -1633,9 +1631,10 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
return status;
}
// If prevent default on keydown, do same for keypress
if (status == nsEventStatus_eConsumeNoDefault)
setNoDefault = true;
// If prevent default on keydown, don't dispatch keypress event
if (status == nsEventStatus_eConsumeNoDefault) {
return nsEventStatus_eConsumeNoDefault;
}
}
// Don't pass modifiers as NS_KEY_PRESS events.
@ -1649,9 +1648,7 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
aEvent->key() == Qt::Key_Alt ||
aEvent->key() == Qt::Key_AltGr) {
return setNoDefault ?
nsEventStatus_eConsumeNoDefault :
nsEventStatus_eIgnore;
return nsEventStatus_eIgnore;
}
// Look for specialized app-command keys
@ -1695,11 +1692,6 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
nsKeyEvent event(true, NS_KEY_PRESS, this);
InitKeyEvent(event, aEvent);
// If prevent default on keydown, do same for keypress
if (setNoDefault) {
event.mFlags.mDefaultPrevented = true;
}
// If there is no charcode attainable from the text, try to
// generate it from the keycode. Check shift state for case
// Also replace the charcode if ControlModifier is the only
@ -1875,9 +1867,10 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
nsEventStatus status = DispatchEvent(&downEvent);
// If prevent default on keydown, do same for keypress
if (status == nsEventStatus_eConsumeNoDefault)
setNoDefault = true;
// If prevent default on keydown, don't dispatch keypress event
if (status == nsEventStatus_eConsumeNoDefault) {
return nsEventStatus_eConsumeNoDefault;
}
}
nsKeyEvent event(true, NS_KEY_PRESS, this);
@ -1888,9 +1881,6 @@ nsWindow::OnKeyPressEvent(QKeyEvent *aEvent)
event.keyCode = domCharCode ? 0 : domKeyCode;
event.mKeyNameIndex = keyNameIndex;
if (setNoDefault)
event.mFlags.mDefaultPrevented = true;
// send the key press event
return DispatchEvent(&event);
#endif