зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1433101 - part 2: Treat Enter and Shift+Enter as printable key r=smaug
Chromium dispatches a keypress event when pressing Enter or Shift+Enter. Actually, when user press them in <pre> element of HTML editor, ツ・n is inserted. It makes sense to treat the key combinations as inputting text. MozReview-Commit-ID: Hvx87MZtZkn --HG-- extra : rebase_source : 196b63843ebcb6e4b398f6b21a4f5f1d020b8db3
This commit is contained in:
Родитель
082c64aa0c
Коммит
e43e597a9e
|
@ -666,8 +666,7 @@ HTMLEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
|
|||
return TypedText(NS_LITERAL_STRING("\t"), eTypedText);
|
||||
}
|
||||
case NS_VK_RETURN:
|
||||
if (aKeyboardEvent->IsControl() || aKeyboardEvent->IsAlt() ||
|
||||
aKeyboardEvent->IsMeta() || aKeyboardEvent->IsOS()) {
|
||||
if (!aKeyboardEvent->IsInputtingLineBreak()) {
|
||||
return NS_OK;
|
||||
}
|
||||
aKeyboardEvent->PreventDefault(); // consumed
|
||||
|
|
|
@ -375,9 +375,7 @@ TextEditor::HandleKeyPressEvent(WidgetKeyboardEvent* aKeyboardEvent)
|
|||
return TypedText(NS_LITERAL_STRING("\t"), eTypedText);
|
||||
}
|
||||
case NS_VK_RETURN:
|
||||
if (IsSingleLineEditor() || aKeyboardEvent->IsControl() ||
|
||||
aKeyboardEvent->IsAlt() || aKeyboardEvent->IsMeta() ||
|
||||
aKeyboardEvent->IsOS()) {
|
||||
if (IsSingleLineEditor() || !aKeyboardEvent->IsInputtingLineBreak()) {
|
||||
return NS_OK;
|
||||
}
|
||||
aKeyboardEvent->PreventDefault();
|
||||
|
|
|
@ -696,7 +696,7 @@ TextEventDispatcher::DispatchKeyboardEventInternal(
|
|||
|
||||
if (sDispatchKeyPressEventsOnlySystemGroupInContent &&
|
||||
keyEvent.mMessage == eKeyPress &&
|
||||
!keyEvent.IsInputtingText()) {
|
||||
!keyEvent.IsInputtingText() && !keyEvent.IsInputtingLineBreak()) {
|
||||
keyEvent.mFlags.mOnlySystemGroupDispatchInContent = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -241,6 +241,16 @@ public:
|
|||
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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче