Bug 1589497 - Make PendingAction of TSFStore copy of key message r=m_kato

`TSFTextStore::sHandlingKeyMsg` refers pointer of struct, but referred via
`TSFTextStore::PendingAction` so that we should make it has a copy of
`sHandlingKeyMsg` because of for async handling.

Differential Revision: https://phabricator.services.mozilla.com/D68049

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2020-03-26 07:33:37 +00:00
Родитель a67aefcc66
Коммит 3fd73c16fb
3 изменённых файлов: 14 добавлений и 12 удалений

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

@ -1560,8 +1560,10 @@ void NativeKey::InitWithKeyOrChar() {
ComputeVirtualKeyCodeFromScanCodeEx();
NS_ASSERTION(mVirtualKeyCode, "Failed to compute virtual keycode");
break;
default:
MOZ_CRASH("Unsupported message");
default: {
MOZ_CRASH_UNSAFE_PRINTF("Unsupported message: 0x%04X", mMsg.message);
break;
}
}
if (!mVirtualKeyCode) {

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

@ -2341,15 +2341,15 @@ void TSFTextStore::FlushPendingActions() {
switch (action.mType) {
case PendingAction::Type::eKeyboardEvent:
if (mDestroyed) {
MOZ_LOG(
sTextStoreLog, LogLevel::Warning,
("0x%p TSFTextStore::FlushPendingActions() "
"IGNORED pending KeyboardEvent(%s) due to already destroyed",
action.mKeyMsg->message == WM_KEYDOWN ? "eKeyDown" : "eKeyUp",
this));
MOZ_LOG(sTextStoreLog, LogLevel::Warning,
("0x%p TSFTextStore::FlushPendingActions() "
"IGNORED pending KeyboardEvent(%s) due to already destroyed",
action.mKeyMsg.message == WM_KEYDOWN ? "eKeyDown" : "eKeyUp",
this));
}
MOZ_DIAGNOSTIC_ASSERT(action.mKeyMsg);
DispatchKeyboardEventAsProcessedByIME(*action.mKeyMsg);
MOZ_DIAGNOSTIC_ASSERT(action.mKeyMsg.message == WM_KEYDOWN ||
action.mKeyMsg.message == WM_KEYUP);
DispatchKeyboardEventAsProcessedByIME(action.mKeyMsg);
if (!widget || widget->Destroyed()) {
break;
}
@ -2665,7 +2665,7 @@ void TSFTextStore::MaybeDispatchKeyboardEventAsProcessedByIME() {
this));
PendingAction* action = mPendingActions.AppendElement();
action->mType = PendingAction::Type::eKeyboardEvent;
action->mKeyMsg = sHandlingKeyMsg;
memcpy(&action->mKeyMsg, sHandlingKeyMsg, sizeof(MSG));
return;
}

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

@ -679,7 +679,7 @@ class TSFTextStore final : public ITextStoreACP,
// For eCompositionUpdate
RefPtr<TextRangeArray> mRanges;
// For eKeyboardEvent
const MSG* mKeyMsg;
MSG mKeyMsg;
// For eSetSelection
bool mSelectionReversed;
// For eCompositionUpdate