Bug 1208944 - Part 5. Send PluginEvent to content process. r=jmathies
☠☠ backed out by 54a19e8d57c4 ☠ ☠
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 29 Dec 2015 22:57:38 +0900
changeset 277835 3c2b9372dd36e85c901633bd847b899ebb7e8dec
parent 277834 18160d30649322977fb874e6400bb98435492369
child 277836 7685dcb63e5f6b1e823447c07741b1f759556a31
push idunknown
push userunknown
push dateunknown
reviewersjmathies
bugs1208944
milestone46.0a1
Bug 1208944 - Part 5. Send PluginEvent to content process. r=jmathies
dom/events/EventStateManager.cpp
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
widget/MiscEvents.h
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1205,16 +1205,20 @@ EventStateManager::DispatchCrossProcessE
       }
     }
 
     bool retval = remote->SendRealDragEvent(*aEvent->AsDragEvent(),
                                             action, dropEffect);
 
     return retval;
   }
+  case ePluginEventClass: {
+    *aStatus = nsEventStatus_eConsumeNoDefault;
+    return remote->SendPluginEvent(*aEvent->AsPluginEvent());
+  }
   default: {
     MOZ_CRASH("Attempt to send non-whitelisted event?");
   }
   }
 }
 
 bool
 EventStateManager::IsRemoteTarget(nsIContent* target) {
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -47,16 +47,17 @@ using mozilla::gfx::IntRect from "mozill
 using class mozilla::ContentCache from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetDragEvent from "ipc/nsGUIEventIPC.h";
 using struct nsRect from "nsRect.h";
 using class mozilla::WidgetSelectionEvent from "ipc/nsGUIEventIPC.h";
 using class mozilla::WidgetTouchEvent from "ipc/nsGUIEventIPC.h";
+using class mozilla::WidgetPluginEvent from "ipc/nsGUIEventIPC.h";
 using struct mozilla::dom::RemoteDOMEvent from "mozilla/dom/TabMessageUtils.h";
 using mozilla::dom::ScreenOrientationInternal from "mozilla/dom/ScreenOrientation.h";
 using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h";
 using mozilla::CSSPoint from "Units.h";
 using mozilla::CSSToScreenScale from "Units.h";
 using mozilla::CommandInt from "mozilla/EventForwards.h";
 using mozilla::Modifiers from "mozilla/EventForwards.h";
 using mozilla::layers::GeckoContentController::APZStateChange from "mozilla/layers/GeckoContentController.h";
@@ -629,16 +630,17 @@ child:
                    ScrollableLayerGuid aGuid,
                    uint64_t aInputBlockId,
                    nsEventStatus aApzResponse);
     RealTouchMoveEvent(WidgetTouchEvent aEvent,
                        ScrollableLayerGuid aGuid,
                        uint64_t aInputBlockId,
                        nsEventStatus aApzResponse);
     RealDragEvent(WidgetDragEvent aEvent, uint32_t aDragAction, uint32_t aDropEffect);
+    PluginEvent(WidgetPluginEvent aEvent);
 
     /**
      * @see nsIDOMWindowUtils sendKeyEvent.
      */
     KeyEvent(nsString aType,
              int32_t aKeyCode,
              int32_t aCharCode,
              int32_t aModifiers,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1938,16 +1938,26 @@ TabChild::RecvRealDragEvent(const Widget
       dragService->FireDragEventAtSource(eDrag);
     }
   }
 
   APZCCallbackHelper::DispatchWidgetEvent(localEvent);
   return true;
 }
 
+bool
+TabChild::RecvPluginEvent(const WidgetPluginEvent& aEvent)
+{
+  WidgetPluginEvent localEvent(aEvent);
+  localEvent.widget = mPuppetWidget;
+  APZCCallbackHelper::DispatchWidgetEvent(localEvent);
+  // XXX If not consumed, we should call default action (ex. DefWindowProc)?
+  return true;
+}
+
 void
 TabChild::RequestNativeKeyBindings(AutoCacheNativeKeyCommands* aAutoCache,
                                    WidgetKeyboardEvent* aEvent)
 {
   MaybeNativeKeyBinding maybeBindings;
   if (!SendRequestNativeKeyBindings(*aEvent, &maybeBindings)) {
     return;
   }
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -374,16 +374,17 @@ public:
                               const int32_t&  aKeyCode,
                               const int32_t&  aCharCode,
                               const int32_t&  aModifiers,
                               const bool&     aPreventDefault) override;
     virtual bool RecvMouseScrollTestEvent(const FrameMetrics::ViewID& aScrollId,
                                           const nsString& aEvent) override;
     virtual bool RecvNativeSynthesisResponse(const uint64_t& aObserverId,
                                              const nsCString& aResponse) override;
+    virtual bool RecvPluginEvent(const WidgetPluginEvent& aEvent) override;
     virtual bool RecvCompositionEvent(const mozilla::WidgetCompositionEvent& event) override;
     virtual bool RecvSelectionEvent(const mozilla::WidgetSelectionEvent& event) override;
     virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture) override;
     virtual bool RecvLoadRemoteScript(const nsString& aURL,
                                       const bool& aRunInGlobalScope) override;
     virtual bool RecvAsyncMessage(const nsString& aMessage,
                                   const ClonedMessageData& aData,
                                   InfallibleTArray<CpowEntry>&& aCpows,
--- a/widget/MiscEvents.h
+++ b/widget/MiscEvents.h
@@ -10,16 +10,21 @@
 
 #include "mozilla/BasicEvents.h"
 #include "nsCOMPtr.h"
 #include "nsIAtom.h"
 #include "nsITransferable.h"
 
 namespace mozilla {
 
+namespace dom {
+  class PBrowserParent;
+  class PBrowserChild;
+} // namespace dom
+
 /******************************************************************************
  * mozilla::WidgetContentCommandEvent
  ******************************************************************************/
 
 class WidgetContentCommandEvent : public WidgetGUIEvent
 {
 public:
   virtual WidgetContentCommandEvent* AsContentCommandEvent() override
@@ -137,16 +142,20 @@ public:
 /******************************************************************************
  * mozilla::WidgetPluginEvent
  *
  * This event delivers only a native event to focused plugin.
  ******************************************************************************/
 
 class WidgetPluginEvent : public WidgetGUIEvent
 {
+private:
+  friend class dom::PBrowserParent;
+  friend class dom::PBrowserChild;
+
 public:
   virtual WidgetPluginEvent* AsPluginEvent() override { return this; }
 
   WidgetPluginEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget)
     : WidgetGUIEvent(aIsTrusted, aMessage, aWidget, ePluginEventClass)
     , retargetToFocusedDocument(false)
   {
   }
@@ -170,13 +179,18 @@ public:
 
   void AssignPluginEventData(const WidgetPluginEvent& aEvent,
                              bool aCopyTargets)
   {
     AssignGUIEventData(aEvent, aCopyTargets);
 
     retargetToFocusedDocument = aEvent.retargetToFocusedDocument;
   }
+
+protected:
+  WidgetPluginEvent()
+  {
+  }
 };
 
 } // namespace mozilla
 
 #endif // mozilla_MiscEvents_h__