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:
Masayuki Nakano 2018-01-25 23:59:20 +09:00
Родитель 082c64aa0c
Коммит e43e597a9e
4 изменённых файлов: 13 добавлений и 6 удалений

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

@ -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,