Bug 1719150 - Push delayed mouse event to the right pres shell. r=smaug

Otherwise if we get an event targeting a different suppressed pres shell
while we're unsuppressing we might get stuck delaying the event over and
over, see the links in comment 33.

Not sure how to get a repro for this, the patch is written based on the
pernosco session, but suggestions welcome.

Differential Revision: https://phabricator.services.mozilla.com/D130100
This commit is contained in:
Emilio Cobos Álvarez 2021-11-01 19:29:01 +00:00
Родитель f64fd4ecbc
Коммит 4c732f8b08
2 изменённых файлов: 6 добавлений и 8 удалений

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

@ -7598,7 +7598,7 @@ bool PresShell::EventHandler::MaybeDiscardOrDelayKeyboardEvent(
} else if (!mPresShell->mNoDelayedKeyEvents) {
UniquePtr<DelayedKeyEvent> delayedKeyEvent =
MakeUnique<DelayedKeyEvent>(aGUIEvent->AsKeyboardEvent());
PushDelayedEventIntoQueue(std::move(delayedKeyEvent));
mPresShell->mDelayedEvents.AppendElement(std::move(delayedKeyEvent));
}
aGUIEvent->mFlags.mIsSuppressedOrDelayed = true;
return true;
@ -7623,9 +7623,11 @@ bool PresShell::EventHandler::MaybeDiscardOrDelayMouseEvent(
aGUIEvent->mMessage != eMouseMove,
!InputTaskManager::Get()->IsSuspended());
RefPtr<PresShell> ps = aFrameToHandleEvent->PresShell();
if (aGUIEvent->mMessage == eMouseDown) {
mPresShell->mNoDelayedMouseEvents = true;
} else if (!mPresShell->mNoDelayedMouseEvents &&
ps->mNoDelayedMouseEvents = true;
} else if (!ps->mNoDelayedMouseEvents &&
(aGUIEvent->mMessage == eMouseUp ||
// contextmenu is triggered after right mouseup on Windows and
// right mousedown on other platforms.
@ -7633,7 +7635,7 @@ bool PresShell::EventHandler::MaybeDiscardOrDelayMouseEvent(
aGUIEvent->mMessage == eMouseExitFromWidget)) {
UniquePtr<DelayedMouseEvent> delayedMouseEvent =
MakeUnique<DelayedMouseEvent>(aGUIEvent->AsMouseEvent());
PushDelayedEventIntoQueue(std::move(delayedMouseEvent));
ps->mDelayedEvents.AppendElement(std::move(delayedMouseEvent));
}
// If there is a suppressed event listener associated with the document,

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

@ -2742,10 +2742,6 @@ class PresShell final : public nsStubDocumentObserver,
already_AddRefed<PresShell> GetParentPresShellForEventHandling() {
return mPresShell->GetParentPresShellForEventHandling();
}
void PushDelayedEventIntoQueue(UniquePtr<DelayedEvent>&& aDelayedEvent) {
mPresShell->mDelayedEvents.AppendElement(std::move(aDelayedEvent));
}
OwningNonNull<PresShell> mPresShell;
AutoCurrentEventInfoSetter* mCurrentEventInfoSetter;
static TimeStamp sLastInputCreated;