Issue #2019 - Do not dispatch keypress event for non-printable keys.

This will prevent the keypress DOM event from firing on keypresses
that do not produce printable keys (e.g. editing nav keys) in content.
This should not affect any chrome events that are in use.
Event dispatch can be re-enabled if necessary with the added pref.
This commit is contained in:
Moonchild 2022-10-17 12:07:37 +00:00 • committed by roytam1
commit 1392f5f223
6 changed files with 48 additions and 15 deletions

View file

@ -183,6 +183,30 @@ public:
return IsKeyEventOnPlugin(mMessage);
}
bool IsInputtingText() const
{
// NOTE: On some keyboard layouts, some characters are put in with Control
// or Alt keys, but at that time, widget unsets the modifier flag
// from the eKeyPress event, so it does not count as a modifier in
// this check.
return mMessage == eKeyPress &&
mCharCode &&
!(mModifiers & (MODIFIER_ALT |
MODIFIER_CONTROL |
MODIFIER_META |
MODIFIER_OS));
}
bool IsInputtingLineBreak() const
{
return mMessage == eKeyPress &&
mKeyNameIndex == KEY_NAME_INDEX_Enter &&
!(mModifiers & (MODIFIER_ALT |
MODIFIER_CONTROL |
MODIFIER_META |
MODIFIER_OS));
}
virtual WidgetEvent* Duplicate() const override
{
MOZ_ASSERT(mClass == eKeyboardEventClass,