Bug 1365761 - Do not dispatch mouse-move events targeted as a slider frame to web content. r=smaug draft
authorBotond Ballo <botond@mozilla.com>
Mon, 05 Jun 2017 15:05:47 -0400
changeset 589181 5564a0e857cfb572dde0cdd538c453a7f81884f8
parent 589150 cad53f061da634a16ea75887558301b77f65745d
child 631784 07fc81e7d71eeee0ab47c670333f7d0cc120a9ad
push id62268
push userbballo@mozilla.com
push dateMon, 05 Jun 2017 19:19:34 +0000
reviewerssmaug
bugs1365761
milestone55.0a1
Bug 1365761 - Do not dispatch mouse-move events targeted as a slider frame to web content. r=smaug MozReview-Commit-ID: Cpi7orSO7dS
layout/base/PresShell.cpp
layout/generic/nsIFrame.h
layout/xul/nsSliderFrame.cpp
layout/xul/nsSliderFrame.h
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -8118,16 +8118,19 @@ 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 (GetCurrentEventFrame()->ShouldMarkEventAsChromeOnly(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 be marked as chrome-only.
+   */
+  virtual bool ShouldMarkEventAsChromeOnly(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,17 @@ nsSliderFrame::UnsuppressDisplayport()
 {
   if (mSuppressionActive) {
     MOZ_ASSERT(PresContext()->PresShell());
     APZCCallbackHelper::SuppressDisplayport(false, PresContext()->PresShell());
     mSuppressionActive = false;
   }
 }
 
+bool
+nsSliderFrame::ShouldMarkEventAsChromeOnly(EventMessage aMessage) const {
+  // Do not dispatch mouse-move events targeted at the slider frame to
+  // web content. This matches the behaviour of other browsers.
+  return aMessage == eMouseMove;
+}
+
 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 ShouldMarkEventAsChromeOnly(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);