Bug 1332191 Move CrossProcessSafeEvent() in EventStateManager.cpp to WidgetEvent::CanBeSentToRemoteProcess() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 19 Jan 2017 16:46:59 +0900
changeset 375252 bdc55c839eb3cf3c430d37b8d87e9a03a1267d10
parent 375251 dad8acbe41e952e0b021a59784f45ac81ceb9516
child 375253 6638661271a77c239a322147cf41ef462321e90b
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1332191
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1332191 Move CrossProcessSafeEvent() in EventStateManager.cpp to WidgetEvent::CanBeSentToRemoteProcess() r=smaug It doesn't make sense to check this in a static method of EventStateManager.cpp. Instead, it should be a class method of WidgetEvent. Then, everybody can check this in everywhere. This patch adds mFlags.mNoCrossProcessBoundaryForwarding because when it's true, any events shouldn't be sent to remote process. MozReview-Commit-ID: oCuxAwotDA
dom/events/EventStateManager.cpp
widget/BasicEvents.h
widget/WidgetEventImpl.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1272,66 +1272,21 @@ EventStateManager::IsRemoteTarget(nsICon
   nsCOMPtr<nsIMozBrowserFrame> browserFrame = do_QueryInterface(target);
   if (browserFrame && browserFrame->GetReallyIsBrowser()) {
     return !!TabParent::GetFrom(target);
   }
 
   return false;
 }
 
-static bool
-CrossProcessSafeEvent(const WidgetEvent& aEvent)
-{
-  switch (aEvent.mClass) {
-  case eKeyboardEventClass:
-  case eWheelEventClass:
-    return true;
-  case eMouseEventClass:
-    switch (aEvent.mMessage) {
-    case eMouseDown:
-    case eMouseUp:
-    case eMouseMove:
-    case eContextMenu:
-    case eMouseEnterIntoWidget:
-    case eMouseExitFromWidget:
-    case eMouseTouchDrag:
-      return true;
-    default:
-      return false;
-    }
-  case eTouchEventClass:
-    switch (aEvent.mMessage) {
-    case eTouchStart:
-    case eTouchMove:
-    case eTouchEnd:
-    case eTouchCancel:
-      return true;
-    default:
-      return false;
-    }
-  case eDragEventClass:
-    switch (aEvent.mMessage) {
-    case eDragOver:
-    case eDragExit:
-    case eDrop:
-      return true;
-    default:
-      return false;
-    }
-  default:
-    return false;
-  }
-}
-
 bool
 EventStateManager::HandleCrossProcessEvent(WidgetEvent* aEvent,
                                            nsEventStatus *aStatus) {
   if (*aStatus == nsEventStatus_eConsumeNoDefault ||
-      aEvent->mFlags.mNoCrossProcessBoundaryForwarding ||
-      !CrossProcessSafeEvent(*aEvent)) {
+      !aEvent->CanBeSentToRemoteProcess()) {
     return false;
   }
 
   // Collect the remote event targets we're going to forward this
   // event to.
   //
   // NB: the elements of |targets| must be unique, for correctness.
   AutoTArray<nsCOMPtr<nsIContent>, 1> targets;
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -504,16 +504,20 @@ public:
    */
   bool HasIMEEventMessage() const;
   /**
    * Returns true if the event mMessage is one of plugin activation events.
    */
   bool HasPluginActivationEventMessage() const;
 
   /**
+   * Returns true if the event can be sent to remote process.
+   */
+  bool CanBeSentToRemoteProcess() const;
+  /**
    * Returns true if the event is native event deliverer event for plugin and
    * it should be retarted to focused document.
    */
   bool IsRetargetedNativeEventDelivererForPlugin() const;
   /**
    * Returns true if the event is native event deliverer event for plugin and
    * it should NOT be retarted to focused document.
    */
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -309,16 +309,51 @@ WidgetEvent::HasPluginActivationEventMes
 
 /******************************************************************************
  * mozilla::WidgetEvent
  *
  * Specific event checking methods.
  ******************************************************************************/
 
 bool
+WidgetEvent::CanBeSentToRemoteProcess() const
+{
+  // If this event is explicitly marked as shouldn't be sent to remote process,
+  // just return false.
+  if (mFlags.mNoCrossProcessBoundaryForwarding) {
+    return false;
+  }
+
+  if (mClass == eKeyboardEventClass ||
+      mClass == eWheelEventClass) {
+    return true;
+  }
+
+  switch (mMessage) {
+    case eMouseDown:
+    case eMouseUp:
+    case eMouseMove:
+    case eContextMenu:
+    case eMouseEnterIntoWidget:
+    case eMouseExitFromWidget:
+    case eMouseTouchDrag:
+    case eTouchStart:
+    case eTouchMove:
+    case eTouchEnd:
+    case eTouchCancel:
+    case eDragOver:
+    case eDragExit:
+    case eDrop:
+      return true;
+    default:
+      return false;
+  }
+}
+
+bool
 WidgetEvent::IsRetargetedNativeEventDelivererForPlugin() const
 {
   const WidgetPluginEvent* pluginEvent = AsPluginEvent();
   return pluginEvent && pluginEvent->mRetargetToFocusedDocument;
 }
 
 bool
 WidgetEvent::IsNonRetargetedNativeEventDelivererForPlugin() const