Bug 1365761 - Do not dispatch mouse-move events targeted as a slider frame to web content. r=smaug
MozReview-Commit-ID: Cpi7orSO7dS
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -8118,16 +8118,21 @@ PresShell::HandleEventInternal(WidgetEve
nsContentUtils::IsHandlingKeyBoardEvent();
if (aEvent->mClass == eKeyboardEventClass) {
nsContentUtils::SetIsHandlingKeyBoardEvent(true);
}
if (aEvent->IsAllowedToDispatchDOMEvent()) {
MOZ_ASSERT(nsContentUtils::IsSafeToRunScript(),
"Somebody changed aEvent to cause a DOM event!");
nsPresShellEventCB eventCB(this);
+ if (nsIFrame* target = GetCurrentEventFrame()) {
+ if (target->OnlySystemGroupDispatch(aEvent->mMessage)) {
+ aEvent->StopPropagation();
+ }
+ }
if (aEvent->mClass == eTouchEventClass) {
DispatchTouchEventToDOM(aEvent, aStatus, &eventCB, touchIsNew);
} else {
DispatchEventToDOM(aEvent, aStatus, &eventCB);
}
}
nsContentUtils::SetIsHandlingKeyBoardEvent(wasHandlingKeyBoardEvent);
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2583,16 +2583,23 @@ public:
/**
* Returns true if the frame contains any non-collapsed characters.
* This method is only available for text frames, and it will return false
* for all other frame types.
*/
virtual bool HasAnyNoncollapsedCharacters()
{ return false; }
+ /**
+ * Returns true if events of the given type targeted at this frame
+ * should only be dispatched to the system group.
+ */
+ virtual bool OnlySystemGroupDispatch(mozilla::EventMessage aMessage) const
+ { return false; }
+
//
// Accessor functions to an associated view object:
//
bool HasView() const { return !!(mState & NS_FRAME_HAS_VIEW); }
protected:
virtual nsView* GetViewInternal() const
{
MOZ_ASSERT_UNREACHABLE("method should have been overridden by subclass");
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -1633,10 +1633,19 @@ nsSliderFrame::UnsuppressDisplayport()
{
if (mSuppressionActive) {
MOZ_ASSERT(PresContext()->PresShell());
APZCCallbackHelper::SuppressDisplayport(false, PresContext()->PresShell());
mSuppressionActive = false;
}
}
+bool
+nsSliderFrame::OnlySystemGroupDispatch(EventMessage aMessage) const
+{
+ // If we are in a native anonymous subtree, do not dispatch mouse-move events
+ // targeted at this slider frame to web content. This matches the behaviour
+ // of other browsers.
+ return aMessage == eMouseMove && GetContent()->IsInNativeAnonymousSubtree();
+}
+
NS_IMPL_ISUPPORTS(nsSliderMediator,
nsIDOMEventListener)
--- a/layout/xul/nsSliderFrame.h
+++ b/layout/xul/nsSliderFrame.h
@@ -134,16 +134,18 @@ public:
// scrolled frame.
float GetThumbRatio() const;
// Notify the slider frame than an async scrollbar drag requested in
// StartAPZDrag() was rejected by APZ, and the slider frame should
// fall back to main-thread dragging.
void AsyncScrollbarDragRejected();
+ bool OnlySystemGroupDispatch(mozilla::EventMessage aMessage) const override;
+
private:
bool GetScrollToClick();
nsIFrame* GetScrollbar();
bool ShouldScrollForEvent(mozilla::WidgetGUIEvent* aEvent);
bool ShouldScrollToClickForEvent(mozilla::WidgetGUIEvent* aEvent);
bool IsEventOverThumb(mozilla::WidgetGUIEvent* aEvent);