Bug 1296993 (part 2) - Streamline nsIWidget::Set{,Fake}Modal. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 25 Aug 2016 13:43:26 +1000
changeset 311801 6d772aecca501b8b1c083bf242c4a31c0cf3f768
parent 311800 ecf67f1108ea1f65df2810b5aceaedd6511d9512
child 311802 b349f99120ab97864c79a5b0a68ff1d490f5775e
push id20417
push userryanvm@gmail.com
push dateTue, 30 Aug 2016 13:55:34 +0000
treeherderfx-team@b18c8bcdc116 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1296993
milestone51.0a1
Bug 1296993 (part 2) - Streamline nsIWidget::Set{,Fake}Modal. r=mstange. This patch does the following. - Removes the return value, because none of the call sites check it. - Removes the empty implementations from several nsIWidget instances, because they can use the nsBaseWidget one.
widget/android/nsWindow.cpp
widget/android/nsWindow.h
widget/cocoa/nsCocoaWindow.h
widget/cocoa/nsCocoaWindow.mm
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/nsIWidget.h
widget/uikit/nsWindow.h
widget/uikit/nsWindow.mm
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1731,24 +1731,16 @@ nsWindow::Show(bool aState)
 
 #ifdef DEBUG_ANDROID_WIDGET
     DumpWindows();
 #endif
 
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsWindow::SetModal(bool aState)
-{
-    ALOG("nsWindow[%p]::SetModal %d ignored", (void*)this, aState);
-
-    return NS_OK;
-}
-
 bool
 nsWindow::IsVisible() const
 {
     return mIsVisible;
 }
 
 NS_IMETHODIMP
 nsWindow::ConstrainPosition(bool aAllowSlop,
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -135,17 +135,16 @@ public:
                                          nsWidgetInitData* aInitData) override;
     virtual void Destroy() override;
     NS_IMETHOD ConfigureChildren(const nsTArray<nsIWidget::Configuration>&) override;
     NS_IMETHOD SetParent(nsIWidget* aNewParent) override;
     virtual nsIWidget *GetParent(void) override;
     virtual float GetDPI() override;
     virtual double GetDefaultScaleInternal() override;
     NS_IMETHOD Show(bool aState) override;
-    NS_IMETHOD SetModal(bool aModal) override;
     virtual bool IsVisible() const override;
     NS_IMETHOD ConstrainPosition(bool aAllowSlop,
                                  int32_t *aX,
                                  int32_t *aY) override;
     NS_IMETHOD Move(double aX,
                     double aY) override;
     NS_IMETHOD Resize(double aWidth,
                       double aHeight,
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -236,18 +236,18 @@ public:
                                          override;
 
     virtual void            Destroy() override;
 
     NS_IMETHOD              Show(bool aState) override;
     virtual nsIWidget*      GetSheetWindowParent(void) override;
     NS_IMETHOD              Enable(bool aState) override;
     virtual bool            IsEnabled() const override;
-    NS_IMETHOD              SetModal(bool aState) override;
-    NS_IMETHOD              SetFakeModal(bool aState) override;
+    virtual void            SetModal(bool aState) override;
+    virtual void            SetFakeModal(bool aState) override;
     virtual bool            IsVisible() const override;
     NS_IMETHOD              SetFocus(bool aState=false) override;
     virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
     virtual LayoutDeviceIntPoint GetClientOffset() override;
     virtual LayoutDeviceIntSize
     ClientToWindowSize(const LayoutDeviceIntSize& aClientSize) override;
 
     virtual void* GetNativeData(uint32_t aDataType) override;
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -636,20 +636,23 @@ bool nsCocoaWindow::IsVisible() const
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   return (mWindow && ([mWindow isVisibleOrBeingShown] || mSheetNeedsShow));
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
 }
 
-NS_IMETHODIMP nsCocoaWindow::SetModal(bool aState)
+void
+nsCocoaWindow::SetModal(bool aState)
 {
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
   if (!mWindow)
-    return NS_OK;
+    return;
 
   // This is used during startup (outside the event loop) when creating
   // the add-ons compatibility checking dialog and the profile manager UI;
   // therefore, it needs to provide an autorelease pool to avoid cocoa
   // objects leaking.
   nsAutoreleasePool localPool;
 
   mModal = aState;
@@ -707,23 +710,25 @@ NS_IMETHODIMP nsCocoaWindow::SetModal(bo
         delete saved; // "window" not ADDREFed
       }
       if (mWindowType == eWindowType_popup)
         SetPopupWindowLevel();
       else
         [mWindow setLevel:NSNormalWindowLevel];
     }
   }
-  return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-NS_IMETHODIMP nsCocoaWindow::SetFakeModal(bool aState)
+void
+nsCocoaWindow::SetFakeModal(bool aState)
 {
     mFakeModal = aState;
-    return SetModal(aState);
+    SetModal(aState);
 }
 
 // Hide or show this window
 NS_IMETHODIMP nsCocoaWindow::Show(bool bState)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!mWindow)
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -936,26 +936,25 @@ nsWindow::ReparentNativeWidgetInternal(n
     nsWindow* newParent = static_cast<nsWindow*>(aNewParent);
     bool parentHasMappedToplevel =
         newParent && newParent->mHasMappedToplevel;
     if (mHasMappedToplevel != parentHasMappedToplevel) {
         SetHasMappedToplevel(parentHasMappedToplevel);
     }
 }
 
-NS_IMETHODIMP
+void
 nsWindow::SetModal(bool aModal)
 {
     LOG(("nsWindow::SetModal [%p] %d\n", (void *)this, aModal));
     if (mIsDestroyed)
-        return aModal ? NS_ERROR_NOT_AVAILABLE : NS_OK;
+        return;
     if (!mIsTopLevel || !mShell)
-        return NS_ERROR_FAILURE;
+        return;
     gtk_window_set_modal(GTK_WINDOW(mShell), aModal ? TRUE : FALSE);
-    return NS_OK;
 }
 
 // nsIWidget method, which means IsShown.
 bool
 nsWindow::IsVisible() const
 {
     return mIsShown;
 }
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -102,17 +102,17 @@ public:
     virtual float      GetDPI() override;
     virtual double     GetDefaultScaleInternal() override;
     // Under Gtk, we manage windows using device pixels so no scaling is needed:
     mozilla::DesktopToLayoutDeviceScale GetDesktopToDeviceScale() final
     {
         return mozilla::DesktopToLayoutDeviceScale(1.0);
     }
     virtual nsresult   SetParent(nsIWidget* aNewParent) override;
-    NS_IMETHOD         SetModal(bool aModal) override;
+    virtual void       SetModal(bool aModal) override;
     virtual bool       IsVisible() const override;
     NS_IMETHOD         ConstrainPosition(bool aAllowSlop,
                                          int32_t *aX,
                                          int32_t *aY) override;
     virtual void       SetSizeConstraints(const SizeConstraints& aConstraints) override;
     NS_IMETHOD         Move(double aX,
                             double aY) override;
     NS_IMETHOD         Show             (bool aState) override;
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1599,21 +1599,16 @@ nsBaseWidget::SetNonClientMargins(Layout
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 uint32_t nsBaseWidget::GetMaxTouchPoints() const
 {
   return 0;
 }
 
-NS_IMETHODIMP nsBaseWidget::SetModal(bool aModal)
-{
-  return NS_ERROR_FAILURE;
-}
-
 NS_IMETHODIMP
 nsBaseWidget::GetAttention(int32_t aCycleCount) {
     return NS_OK;
 }
 
 bool
 nsBaseWidget::HasPendingInputEvent()
 {
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -190,17 +190,17 @@ public:
                                           LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
 
   mozilla::CompositorVsyncDispatcher* GetCompositorVsyncDispatcher();
   void            CreateCompositorVsyncDispatcher();
   virtual void            CreateCompositor();
   virtual void            CreateCompositor(int aWidth, int aHeight);
   virtual void            PrepareWindowEffects() override {}
   virtual void            UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override {}
-  NS_IMETHOD              SetModal(bool aModal) override;
+  virtual void            SetModal(bool aModal) override {}
   virtual uint32_t        GetMaxTouchPoints() const override;
   NS_IMETHOD              SetWindowClass(const nsAString& xulWinType) override;
   virtual nsresult        SetWindowClipRegion(const nsTArray<LayoutDeviceIntRect>& aRects, bool aIntersectWithExisting) override;
   // Return whether this widget interprets parameters to Move and Resize APIs
   // as "desktop pixels" rather than "device pixels", and therefore
   // applies its GetDefaultScale() value to them before using them as mBounds
   // etc (which are always stored in device pixels).
   // Note that APIs that -get- the widget's position/size/bounds, rather than
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -634,28 +634,27 @@ class nsIWidget : public nsISupports
      * Show or hide this widget
      *
      * @param aState true to show the Widget, false to hide it
      *
      */
     NS_IMETHOD Show(bool aState) = 0;
 
     /**
-     * Make the window modal
-     *
+     * Make the window modal.
      */
-    NS_IMETHOD SetModal(bool aModal) = 0;
+    virtual void SetModal(bool aModal) = 0;
 
     /**
      * Make the non-modal window opened by modal window fake-modal, that will
      * call SetFakeModal(false) on destroy on Cocoa.
      */
-    NS_IMETHOD SetFakeModal(bool aModal)
+    virtual void SetFakeModal(bool aModal)
     {
-        return SetModal(aModal);
+        SetModal(aModal);
     }
 
     /**
      * The maximum number of simultaneous touch contacts supported by the device.
      * In the case of devices with multiple digitizers (e.g. multiple touch screens),
      * the value will be the maximum of the set of maximum supported contacts by
      * each individual digitizer.
      */
--- a/widget/uikit/nsWindow.h
+++ b/widget/uikit/nsWindow.h
@@ -37,17 +37,16 @@ public:
     virtual void Destroy() override;
     NS_IMETHOD Show(bool aState) override;
     NS_IMETHOD              Enable(bool aState) override {
         return NS_OK;
     }
     virtual bool            IsEnabled() const override {
         return true;
     }
-    NS_IMETHOD              SetModal(bool aState) override;
     virtual bool            IsVisible() const override {
         return mVisible;
     }
     NS_IMETHOD              SetFocus(bool aState=false) override;
     virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
 
     virtual void SetBackgroundColor(const nscolor &aColor) override;
     virtual void* GetNativeData(uint32_t aDataType) override;
--- a/widget/uikit/nsWindow.mm
+++ b/widget/uikit/nsWindow.mm
@@ -578,22 +578,16 @@ nsWindow::Show(bool aState)
           [mNativeView setNeedsDisplay];
       }
       mVisible = aState;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsWindow::SetModal(bool aModal)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsWindow::ConstrainPosition(bool aAllowSlop,
                             int32_t *aX,
                             int32_t *aY)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP