Bug 1325234 (part 8) - Streamline nsIWidget::DispatchEvent. r=jimm.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 21 Dec 2016 11:18:40 +1100
changeset 356521 3ad2e4c9148888815661208134b21bd22f34986b
parent 356520 48f5a494d7edf85ee57f329ee75d83d874042294
child 356522 1e51e167058e06429deb642480c0c5691715601e
push id10621
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 16:02:43 +0000
treeherdermozilla-aurora@dca7b42e6c67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1325234
milestone53.0a1
Bug 1325234 (part 8) - Streamline nsIWidget::DispatchEvent. r=jimm. This patch changes it from |NS_IMETHOD| to |virtual nsresult| because some callsites are checked and some aren't.
gfx/tests/gtest/TestCompositor.cpp
widget/PuppetWidget.cpp
widget/PuppetWidget.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsCocoaWindow.mm
widget/gonk/nsWindow.cpp
widget/gonk/nsWindow.h
widget/nsIWidget.h
widget/uikit/nsWindow.h
widget/uikit/nsWindow.mm
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/gfx/tests/gtest/TestCompositor.cpp
+++ b/gfx/tests/gtest/TestCompositor.cpp
@@ -75,17 +75,17 @@ public:
 
   virtual void            Enable(bool aState) override {}
   virtual bool            IsEnabled() const override { return true; }
   virtual nsresult        SetFocus(bool aRaise) override { return NS_OK; }
   virtual nsresult        ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override { return NS_OK; }
   virtual void            Invalidate(const LayoutDeviceIntRect& aRect) override {}
   virtual nsresult        SetTitle(const nsAString& title) override { return NS_OK; }
   virtual LayoutDeviceIntPoint WidgetToScreenOffset() override { return LayoutDeviceIntPoint(0, 0); }
-  NS_IMETHOD              DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+  virtual nsresult        DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
                                         nsEventStatus& aStatus) override { return NS_OK; }
   NS_IMETHOD_(void)       SetInputContext(const InputContext& aContext,
                                           const InputContextAction& aAction) override {}
   NS_IMETHOD_(InputContext) GetInputContext() override { abort(); }
 
 private:
   ~MockWidget() {}
 };
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -312,17 +312,17 @@ PuppetWidget::InitEvent(WidgetGUIEvent& 
     event.mRefPoint = LayoutDeviceIntPoint(0, 0);
   } else {
     // use the point override if provided
     event.mRefPoint = *aPoint;
   }
   event.mTime = PR_Now() / 1000;
 }
 
-NS_IMETHODIMP
+nsresult
 PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
 {
 #ifdef DEBUG
   debug_DumpEvent(stdout, event->mWidget, event, "PuppetWidget", 0);
 #endif
 
   MOZ_ASSERT(!mChild || mChild->mWindowType == eWindowType_popup,
              "Unexpected event dispatch!");
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -134,17 +134,18 @@ public:
   virtual LayoutDeviceIntPoint WidgetToScreenOffset() override
   { return LayoutDeviceIntPoint::FromUnknownPoint(GetWindowPosition() + GetChromeDimensions()); }
 
   int32_t RoundsWidgetCoordinatesTo() override;
 
   void InitEvent(WidgetGUIEvent& aEvent,
                  LayoutDeviceIntPoint* aPoint = nullptr);
 
-  NS_IMETHOD DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
+  virtual nsresult DispatchEvent(WidgetGUIEvent* aEvent,
+                                 nsEventStatus& aStatus) override;
   nsEventStatus DispatchInputEvent(WidgetInputEvent* aEvent) override;
   void SetConfirmedTargetAPZC(uint64_t aInputBlockId,
                               const nsTArray<ScrollableLayerGuid>& aTargets) const override;
   void UpdateZoomConstraints(const uint32_t& aPresShellId,
                              const FrameMetrics::ViewID& aViewId,
                              const mozilla::Maybe<ZoomConstraints>& aConstraints) override;
   bool AsyncPanZoomEnabled() const override;
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1924,17 +1924,17 @@ nsWindow::WidgetToScreenOffset()
         p.y += w->mBounds.y;
 
         w = w->mParent;
     }
 
     return p;
 }
 
-NS_IMETHODIMP
+nsresult
 nsWindow::DispatchEvent(WidgetGUIEvent* aEvent,
                         nsEventStatus& aStatus)
 {
     aStatus = DispatchEvent(aEvent);
     return NS_OK;
 }
 
 nsEventStatus
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -180,18 +180,18 @@ public:
     void SetZIndex(int32_t aZIndex) override;
     virtual void SetSizeMode(nsSizeMode aMode) override;
     virtual void Enable(bool aState) override;
     virtual bool IsEnabled() const override;
     virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
     virtual nsresult SetFocus(bool aRaise = false) override;
     virtual LayoutDeviceIntRect GetScreenBounds() override;
     virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
-    NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
-                             nsEventStatus& aStatus) override;
+    virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+                                   nsEventStatus& aStatus) override;
     nsEventStatus DispatchEvent(mozilla::WidgetGUIEvent* aEvent);
     virtual already_AddRefed<nsIScreen> GetWidgetScreen() override;
     virtual nsresult MakeFullScreen(bool aFullScreen,
                                     nsIScreen* aTargetScreen = nullptr)
                                     override;
 
     virtual void SetCursor(nsCursor aCursor) override {}
     virtual nsresult SetCursor(imgIContainer* aCursor, uint32_t aHotspotX,
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -351,17 +351,17 @@ public:
 
   virtual void*           GetNativeData(uint32_t aDataType) override;
   virtual nsresult        ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
   virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
   virtual bool            ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
 
   static  bool            ConvertStatus(nsEventStatus aStatus)
                           { return aStatus == nsEventStatus_eConsumeNoDefault; }
-  NS_IMETHOD              DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+  virtual nsresult        DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
                                         nsEventStatus& aStatus) override;
 
   virtual bool            WidgetTypeSupportsAcceleration() override;
   virtual bool            ShouldUseOffMainThreadCompositing() override;
 
   virtual void      SetCursor(nsCursor aCursor) override;
   virtual nsresult  SetCursor(imgIContainer* aCursor,
                               uint32_t aHotspotX, uint32_t aHotspotY) override;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1390,18 +1390,18 @@ inline uint16_t COLOR8TOCOLOR16(uint8_t 
 #pragma mark -
 
 nsresult nsChildView::ConfigureChildren(const nsTArray<Configuration>& aConfigurations)
 {
   return NS_OK;
 }
 
 // Invokes callback and ProcessEvent methods on Event Listener object
-NS_IMETHODIMP nsChildView::DispatchEvent(WidgetGUIEvent* event,
-                                         nsEventStatus& aStatus)
+nsresult
+nsChildView::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
 {
   RefPtr<nsChildView> kungFuDeathGrip(this);
 
 #ifdef DEBUG
   debug_DumpEvent(stdout, event->mWidget, event, "something", 0);
 #endif
 
   NS_ASSERTION(!(mTextInputHandler && mTextInputHandler->IsIMEComposing() &&
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -301,18 +301,18 @@ public:
 
     virtual nsresult        SetTitle(const nsAString& aTitle) override;
 
     virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
     virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
     virtual LayerManager* GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,
                                           LayersBackend aBackendHint = mozilla::layers::LayersBackend::LAYERS_NONE,
                                           LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
-    NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
-                             nsEventStatus& aStatus) override;
+    virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+                                   nsEventStatus& aStatus) override;
     virtual void CaptureRollupEvents(nsIRollupListener * aListener,
                                      bool aDoCapture) override;
     virtual MOZ_MUST_USE nsresult GetAttention(int32_t aCycleCount) override;
     virtual bool HasPendingInputEvent() override;
     virtual nsTransparencyMode GetTransparencyMode() override;
     virtual void SetTransparencyMode(nsTransparencyMode aMode) override;
     virtual void SetWindowShadowStyle(int32_t aStyle) override;
     virtual void SetShowsToolbarButton(bool aShow) override;
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1890,17 +1890,17 @@ NS_IMETHODIMP nsCocoaWindow::GetIsSheet(
 
 NS_IMETHODIMP nsCocoaWindow::GetSheetWindowParent(NSWindow** sheetWindowParent)
 {
   *sheetWindowParent = mSheetWindowParent;
   return NS_OK;
 }
 
 // Invokes callback and ProcessEvent methods on Event Listener object
-NS_IMETHODIMP 
+nsresult
 nsCocoaWindow::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
 {
   aStatus = nsEventStatus_eIgnore;
 
   nsCOMPtr<nsIWidget> kungFuDeathGrip(event->mWidget);
   mozilla::Unused << kungFuDeathGrip; // Not used within this function
 
   if (mWidgetListener)
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -518,17 +518,17 @@ nsWindow::SetNativeData(uint32_t aDataTy
         }
         mScreen->SetEGLInfo(GLContextEGL::Cast(context)->GetEGLDisplay(),
                             GLContextEGL::Cast(context)->GetEGLSurface(),
                             context);
         return;
     }
 }
 
-NS_IMETHODIMP
+nsresult
 nsWindow::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
 {
     if (mWidgetListener) {
       aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents);
     }
     return NS_OK;
 }
 
--- a/widget/gonk/nsWindow.h
+++ b/widget/gonk/nsWindow.h
@@ -78,18 +78,18 @@ public:
         return NS_OK;
     }
     virtual LayoutDeviceIntPoint WidgetToScreenOffset();
     void DispatchTouchInputViaAPZ(mozilla::MultiTouchInput& aInput);
     void DispatchTouchEventForAPZ(const mozilla::MultiTouchInput& aInput,
                                   const ScrollableLayerGuid& aGuid,
                                   const uint64_t aInputBlockId,
                                   nsEventStatus aApzResponse);
-    NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
-                             nsEventStatus& aStatus);
+    virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+                                   nsEventStatus& aStatus);
     virtual nsresult SynthesizeNativeTouchPoint(uint32_t aPointerId,
                                                 TouchPointerState aPointerState,
                                                 LayoutDeviceIntPoint aPoint,
                                                 double aPointerPressure,
                                                 uint32_t aPointerOrientation,
                                                 nsIObserver* aObserver) override;
 
     virtual nsresult MakeFullScreen(
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -1335,20 +1335,19 @@ class nsIWidget : public nsISupports
      * which includes the area for the borders and titlebar. This method
      * should work even when the window is not yet visible.
      */
     virtual LayoutDeviceIntSize ClientToWindowSize(
                 const LayoutDeviceIntSize& aClientSize) = 0;
 
     /**
      * Dispatches an event to the widget
-     *
      */
-    NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* event,
-                             nsEventStatus & aStatus) = 0;
+    virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* event,
+                                   nsEventStatus & aStatus) = 0;
 
     /**
      * Dispatches an event to APZ only.
      * No-op in the child process.
      */
     virtual void DispatchEventToAPZOnly(mozilla::WidgetInputEvent* aEvent) = 0;
 
     /**
--- a/widget/uikit/nsWindow.h
+++ b/widget/uikit/nsWindow.h
@@ -71,18 +71,18 @@ public:
     virtual int32_t         RoundsWidgetCoordinatesTo() override;
 
     virtual nsresult        SetTitle(const nsAString& aTitle) override {
         return NS_OK;
     }
 
     virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
     virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
-    NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
-                             nsEventStatus& aStatus) override;
+    virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+                                   nsEventStatus& aStatus) override;
 
     void WillPaintWindow();
     bool PaintWindow(LayoutDeviceIntRegion aRegion);
 
     bool HasModalDescendents() { return false; }
 
     //virtual nsresult
     //NotifyIME(const IMENotification& aIMENotification) override;
--- a/widget/uikit/nsWindow.mm
+++ b/widget/uikit/nsWindow.mm
@@ -752,17 +752,17 @@ LayoutDeviceIntPoint nsWindow::WidgetToS
     }
 
     offset.x += temp.x;
     offset.y += temp.y;
 
     return offset;
 }
 
-NS_IMETHODIMP
+nsresult
 nsWindow::DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
                         nsEventStatus& aStatus)
 {
   aStatus = nsEventStatus_eIgnore;
   nsCOMPtr<nsIWidget> kungFuDeathGrip(aEvent->mWidget);
 
   if (mWidgetListener)
     aStatus = mWidgetListener->HandleEvent(aEvent, mUseAttachedEvents);
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3997,18 +3997,18 @@ nsWindow::CurrentMessageWidgetEventTime(
  * SECTION: Moz event dispatch helpers
  *
  * Helpers for dispatching different types of moz events.
  *
  **************************************************************/
 
 // Main event dispatch. Invokes callback and ProcessEvent method on
 // Event Listener object. Part of nsIWidget.
-NS_IMETHODIMP nsWindow::DispatchEvent(WidgetGUIEvent* event,
-                                      nsEventStatus& aStatus)
+nsresult
+nsWindow::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
 {
 #ifdef WIDGET_DEBUG_OUTPUT
   debug_DumpEvent(stdout,
                   event->mWidget,
                   event,
                   "something",
                   (int32_t) mWnd);
 #endif // WIDGET_DEBUG_OUTPUT
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -160,17 +160,17 @@ public:
   virtual void            Invalidate(const LayoutDeviceIntRect& aRect);
   virtual void*           GetNativeData(uint32_t aDataType) override;
   void                    SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
   virtual void            FreeNativeData(void * data, uint32_t aDataType) override;
   virtual nsresult        SetTitle(const nsAString& aTitle) override;
   virtual void            SetIcon(const nsAString& aIconSpec) override;
   virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
   virtual LayoutDeviceIntSize ClientToWindowSize(const LayoutDeviceIntSize& aClientSize) override;
-  NS_IMETHOD              DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
+  virtual nsresult        DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
                                         nsEventStatus& aStatus) override;
   virtual void            EnableDragDrop(bool aEnable) override;
   virtual void            CaptureMouse(bool aCapture) override;
   virtual void            CaptureRollupEvents(nsIRollupListener* aListener,
                                               bool aDoCapture) override;
   virtual MOZ_MUST_USE nsresult GetAttention(int32_t aCycleCount) override;
   virtual bool            HasPendingInputEvent() override;
   virtual LayerManager*   GetLayerManager(PLayerTransactionChild* aShadowManager = nullptr,