Bug 1315862 Part1: Stop dispatching pointer events in the system group. r=masayuki,smaug draft
authorStone Shih <sshih@mozilla.com>
Fri, 11 Nov 2016 18:02:37 +0800
changeset 440254 25afbefb19e5ae613e9e493ea2f275a36004d523
parent 438550 71fd23fa0803a548b6e571aa25d0533a06cd0421
child 440255 634cef3c217ab427d12e8f961c59ed3a1248b267
push id36184
push usersshih@mozilla.com
push dateThu, 17 Nov 2016 06:22:58 +0000
reviewersmasayuki, smaug
bugs1315862
milestone53.0a1
Bug 1315862 Part1: Stop dispatching pointer events in the system group. r=masayuki,smaug MozReview-Commit-ID: 8Xqp3bxlRFt
dom/events/EventDispatcher.cpp
widget/BasicEvents.h
widget/WidgetEventImpl.cpp
--- a/dom/events/EventDispatcher.cpp
+++ b/dom/events/EventDispatcher.cpp
@@ -402,17 +402,18 @@ EventTargetChainItem::HandleEventTargetC
       }
       if (aVisitor.mEvent->mFlags.mInSystemGroup) {
         item.PostHandleEvent(aVisitor);
       }
     }
   }
   aVisitor.mEvent->mFlags.mInBubblingPhase = false;
 
-  if (!aVisitor.mEvent->mFlags.mInSystemGroup) {
+  if (!aVisitor.mEvent->mFlags.mInSystemGroup &&
+      aVisitor.mEvent->IsAllowedToDispatchInSystemGroup()) {
     // Dispatch to the system event group.  Make sure to clear the
     // STOP_DISPATCH flag since this resets for each event group.
     aVisitor.mEvent->mFlags.mPropagationStopped = false;
     aVisitor.mEvent->mFlags.mImmediatePropagationStopped = false;
 
     // Setting back the original target of the event.
     aVisitor.mEvent->mTarget = aVisitor.mEvent->mOriginalTarget;
 
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -546,16 +546,20 @@ public:
    * the last focused window.
    */
   bool IsTargetedAtFocusedContent() const;
   /**
    * Whether the event should cause a DOM event.
    */
   bool IsAllowedToDispatchDOMEvent() const;
   /**
+   * Whether the event should be dispatched in system group.
+   */
+  bool IsAllowedToDispatchInSystemGroup() const;
+  /**
    * Initialize mComposed
    */
   void SetDefaultComposed()
   {
     switch (mClass) {
       case eCompositionEventClass:
         mFlags.mComposed = mMessage == eCompositionStart ||
                            mMessage == eCompositionUpdate ||
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -400,16 +400,25 @@ WidgetEvent::IsAllowedToDispatchDOMEvent
     case eContentCommandEventClass:
       return false;
 
     default:
       return true;
   }
 }
 
+bool
+WidgetEvent::IsAllowedToDispatchInSystemGroup() const
+{
+  // We don't expect to implement default behaviors with pointer events because
+  // if we do, prevent default on mouse events can't prevent default behaviors
+  // anymore.
+  return mClass != ePointerEventClass;
+}
+
 /******************************************************************************
  * mozilla::WidgetInputEvent
  ******************************************************************************/
 
 /* static */
 Modifier
 WidgetInputEvent::GetModifier(const nsAString& aDOMKeyName)
 {