From 67f65b43208958479447b59aa278e55a4607e79a Mon Sep 17 00:00:00 2001 From: Mirko Brodesser Date: Tue, 23 Feb 2021 13:27:41 +0000 Subject: [PATCH] Bug 1674658: part 2) Don't peform the default action for `mousemove` events when it should be prevented. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D106083 --- layout/generic/nsIFrame.cpp | 6 ++++++ layout/generic/nsIFrame.h | 5 +++++ .../uievents/mouse/mousemove_prevent_default_action.tentative.html | 2 ++ 3 files changed, 13 insertions(+) diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index d33aa2344b2a..11cf4c3a95b0 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -4905,6 +4905,12 @@ NS_IMETHODIMP nsIFrame::HandleDrag(nsPresContext* aPresContext, MOZ_ASSERT(aEvent->mClass == eMouseEventClass, "HandleDrag can only handle mouse event"); + NS_ENSURE_ARG_POINTER(aEventStatus); + + if (*aEventStatus == nsEventStatus_eConsumeNoDefault) { + return NS_OK; + } + RefPtr frameselection = GetFrameSelection(); if (!frameselection) { return NS_OK; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 141a154a0aa3..0ba6ac6dc209 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -2179,6 +2179,11 @@ class nsIFrame : public nsQueryFrame { nsPresContext* aPresContext, mozilla::WidgetGUIEvent* aEvent, nsEventStatus* aEventStatus, bool aControlHeld); + /** + * @param aPresContext must be non-nullptr. + * @param aEvent must be non-nullptr. + * @param aEventStatus must be non-nullptr. + */ MOZ_CAN_RUN_SCRIPT NS_IMETHOD HandleDrag(nsPresContext* aPresContext, mozilla::WidgetGUIEvent* aEvent, diff --git a/testing/web-platform/tests/uievents/mouse/mousemove_prevent_default_action.tentative.html b/testing/web-platform/tests/uievents/mouse/mousemove_prevent_default_action.tentative.html index d19be51afb28..b87385d79c5c 100644 --- a/testing/web-platform/tests/uievents/mouse/mousemove_prevent_default_action.tentative.html +++ b/testing/web-platform/tests/uievents/mouse/mousemove_prevent_default_action.tentative.html @@ -3,6 +3,8 @@ mousemove event: preventDefault() + + -- 2.11.4.GIT