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
--- 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
@@ -516,16 +516,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
@@ -310,16 +310,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