summaryrefslogtreecommitdiffstats
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
commit3424afccaebc71c4acd4fa9eadf519c408c5965b (patch)
treeb9c79b7f13f0fac5ad645c07e77892596cfb122a
parentace7f20fa76c0a1594ab80d3a07fda92a7edea67 (diff)
downloadUXP-3424afccaebc71c4acd4fa9eadf519c408c5965b.tar
UXP-3424afccaebc71c4acd4fa9eadf519c408c5965b.tar.gz
UXP-3424afccaebc71c4acd4fa9eadf519c408c5965b.tar.lz
UXP-3424afccaebc71c4acd4fa9eadf519c408c5965b.tar.xz
UXP-3424afccaebc71c4acd4fa9eadf519c408c5965b.zip
Capture delayed events and cancel as necessary.
Tag #1052
-rw-r--r--dom/base/nsGlobalWindow.cpp4
-rw-r--r--layout/base/nsPresShell.cpp12
-rw-r--r--layout/base/nsPresShell.h4
-rw-r--r--toolkit/components/passwordmgr/test/subtst_master_pass.html9
4 files changed, 20 insertions, 9 deletions
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index ac85e34c0..f9126f4da 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -9335,7 +9335,7 @@ nsGlobalWindow::EnterModalState()
topWin->mSuspendedDoc = topDoc;
if (topDoc) {
- topDoc->SuppressEventHandling(nsIDocument::eAnimationsOnly);
+ topDoc->SuppressEventHandling(nsIDocument::eEvents);
}
nsGlobalWindow* inner = topWin->GetCurrentInnerWindowInternal();
@@ -9372,7 +9372,7 @@ nsGlobalWindow::LeaveModalState()
if (topWin->mSuspendedDoc) {
nsCOMPtr<nsIDocument> currentDoc = topWin->GetExtantDoc();
- topWin->mSuspendedDoc->UnsuppressEventHandlingAndFireEvents(nsIDocument::eAnimationsOnly,
+ topWin->mSuspendedDoc->UnsuppressEventHandlingAndFireEvents(nsIDocument::eEvents,
currentDoc == topWin->mSuspendedDoc);
topWin->mSuspendedDoc = nullptr;
}
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
index 5dfbb8dba..d4fbebbf2 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 7a9056a38..1a8dd3fef 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;
};
diff --git a/toolkit/components/passwordmgr/test/subtst_master_pass.html b/toolkit/components/passwordmgr/test/subtst_master_pass.html
index 20211866a..14174726a 100644
--- a/toolkit/components/passwordmgr/test/subtst_master_pass.html
+++ b/toolkit/components/passwordmgr/test/subtst_master_pass.html
@@ -2,11 +2,6 @@
This form triggers a MP and gets filled in.<br>
<form>
Username: <input type="text" id="userfield" name="u"><br>
-Password: <input type="password" id="passfield" name="p"><br>
-<script>
- // Only notify when we fill in the password field.
- document.getElementById("passfield").addEventListener("input", function() {
- parent.postMessage("filled", "*");
- });
-</script>
+Password: <input type="password" id="passfield" name="p"
+ oninput="parent.postMessage('filled', '*');"><br>
</form>