summaryrefslogtreecommitdiff
path: root/layout
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-26 14:13:32 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-26 14:13:32 +0200
commit818a3abca5e0ba25ada99085fd4169b35866f1a7 (patch)
treeb9c79b7f13f0fac5ad645c07e77892596cfb122a /layout
parent5c1f92eb94465efa949f452b933ecfc5f2904cb5 (diff)
downloaduxp-818a3abca5e0ba25ada99085fd4169b35866f1a7.tar.gz
Capture delayed events and cancel as necessary.
Tag mcp-graveyard/UXP#1052
Diffstat (limited to 'layout')
-rw-r--r--layout/base/nsPresShell.cpp12
-rw-r--r--layout/base/nsPresShell.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
index 5dfbb8dba6..d4fbebbf2f 100644
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -8192,6 +8192,9 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent,
}
}
}
+ if (aEvent->mMessage == eKeyDown) {
+ mIsLastKeyDownCanceled = aEvent->mFlags.mDefaultPrevented;
+ }
break;
}
case eMouseUp:
@@ -8981,6 +8984,9 @@ PresShell::FireOrClearDelayedEvents(bool aFireEvents)
!doc->EventHandlingSuppressed()) {
nsAutoPtr<DelayedEvent> ev(mDelayedEvents[0].forget());
mDelayedEvents.RemoveElementAt(0);
+ if (ev->IsKeyPressEvent() && mIsLastKeyDownCanceled) {
+ continue;
+ }
ev->Dispatch();
}
if (!doc->EventHandlingSuppressed()) {
@@ -9775,6 +9781,12 @@ PresShell::DelayedKeyEvent::DelayedKeyEvent(WidgetKeyboardEvent* aEvent) :
mEvent = keyEvent;
}
+bool
+PresShell::DelayedKeyEvent::IsKeyPressEvent()
+{
+ return mEvent->mMessage == eKeyPress;
+}
+
// Start of DEBUG only code
#ifdef DEBUG
diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h
index 7a9056a383..1a8dd3fefa 100644
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -617,6 +617,7 @@ protected:
public:
virtual ~DelayedEvent() { }
virtual void Dispatch() { }
+ virtual bool IsKeyPressEvent() { return false; }
};
class DelayedInputEvent : public DelayedEvent
@@ -641,6 +642,7 @@ protected:
{
public:
explicit DelayedKeyEvent(mozilla::WidgetKeyboardEvent* aEvent);
+ virtual bool IsKeyPressEvent() override;
};
// Check if aEvent is a mouse event and record the mouse location for later
@@ -951,6 +953,8 @@ protected:
// Whether the widget has received a paint message yet.
bool mHasReceivedPaintMessage : 1;
+ bool mIsLastKeyDownCanceled : 1;
+
static bool sDisableNonTestMouseEvents;
};