summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-10-17 12:07:37 +0000
committerMoonchild <moonchild@palemoon.org>2022-10-17 12:28:26 +0000
commit74b3ce90d73f576a36888c06e413b99b61687b80 (patch)
tree81949969871ddf07f10d27a85a352ef2bbc09f22 /editor
parentebd7672d6ba8617c99f80f026b1415a6aafe00a5 (diff)
downloaduxp-74b3ce90d73f576a36888c06e413b99b61687b80.tar.gz
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.
Diffstat (limited to 'editor')
-rw-r--r--editor/libeditor/HTMLEditor.cpp9
-rw-r--r--editor/libeditor/TextEditor.cpp10
2 files changed, 4 insertions, 15 deletions
diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
index 6a630cb1c4..130b033bd1 100644
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -664,8 +664,7 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
return TypedText(NS_LITERAL_STRING("\t"), eTypedText);
}
case NS_VK_RETURN:
- if (nativeKeyEvent->IsControl() || nativeKeyEvent->IsAlt() ||
- nativeKeyEvent->IsMeta() || nativeKeyEvent->IsOS()) {
+ if (!nativeKeyEvent->IsInputtingLineBreak()) {
return NS_OK;
}
aKeyEvent->AsEvent()->PreventDefault(); // consumed
@@ -677,11 +676,7 @@ HTMLEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
return TypedText(EmptyString(), eTypedBreak);
}
- // NOTE: On some keyboard layout, some characters are inputted with Control
- // key or Alt key, but at that time, widget sets FALSE to these keys.
- if (!nativeKeyEvent->mCharCode || nativeKeyEvent->IsControl() ||
- nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
- nativeKeyEvent->IsOS()) {
+ if (!nativeKeyEvent->IsInputtingText()) {
// we don't PreventDefault() here or keybindings like control-x won't work
return NS_OK;
}
diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp
index 3bee7843ce..4b26eff9cd 100644
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -397,20 +397,14 @@ TextEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
return TypedText(NS_LITERAL_STRING("\t"), eTypedText);
}
case NS_VK_RETURN:
- if (IsSingleLineEditor() || nativeKeyEvent->IsControl() ||
- nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
- nativeKeyEvent->IsOS()) {
+ if (IsSingleLineEditor() || !nativeKeyEvent->IsInputtingLineBreak()) {
return NS_OK;
}
aKeyEvent->AsEvent()->PreventDefault();
return TypedText(EmptyString(), eTypedBreak);
}
- // NOTE: On some keyboard layout, some characters are inputted with Control
- // key or Alt key, but at that time, widget sets FALSE to these keys.
- if (!nativeKeyEvent->mCharCode || nativeKeyEvent->IsControl() ||
- nativeKeyEvent->IsAlt() || nativeKeyEvent->IsMeta() ||
- nativeKeyEvent->IsOS()) {
+ if (!nativeKeyEvent->IsInputtingText()) {
// we don't PreventDefault() here or keybindings like control-x won't work
return NS_OK;
}