Bug 1294553 - Don't pretend that nsCocoaWindow is an interface in nsPIWidgetCocoa.idl, r=mstange draft
authorMichael Layzell <michael@thelayzells.com>
Thu, 11 Aug 2016 17:51:11 -0400
changeset 399697 14738dbd78d6ec2fd8ef17b973063e47bcfa3fb1
parent 399696 2aeba88e851e09e4c284beb2fdc79d9b2b2a37d3
child 528029 fed6308ceae1676e0525b766595b3d5f828032d8
push id25946
push userbmo:michael@thelayzells.com
push dateThu, 11 Aug 2016 21:53:07 +0000
reviewersmstange
bugs1294553
milestone51.0a1
Bug 1294553 - Don't pretend that nsCocoaWindow is an interface in nsPIWidgetCocoa.idl, r=mstange MozReview-Commit-ID: 4a6UTI4TxV9
widget/cocoa/nsCocoaWindow.mm
widget/cocoa/nsPIWidgetCocoa.idl
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -765,18 +765,19 @@ NS_IMETHODIMP nsCocoaWindow::Show(bool b
       // return once there are no more child sheets.
       bool parentIsSheet = false;
       if (NS_SUCCEEDED(piParentWidget->GetIsSheet(&parentIsSheet)) &&
           parentIsSheet) {
         piParentWidget->GetSheetWindowParent(&topNonSheetWindow);
         [NSApp endSheet:nativeParentWindow];
       }
 
-      nsCocoaWindow* sheetShown = nullptr;
-      if (NS_SUCCEEDED(piParentWidget->GetChildSheet(true, &sheetShown)) &&
+      nsCOMPtr<nsIWidget> sheetShown;
+      if (NS_SUCCEEDED(piParentWidget->GetChildSheet(
+                           true, getter_AddRefs(sheetShown))) &&
           (!sheetShown || sheetShown == this)) {
         // If this sheet is already the sheet actually being shown, don't
         // tell it to show again. Otherwise the number of calls to
         // [NSApp beginSheet...] won't match up with [NSApp endSheet...].
         if (![mWindow isVisible]) {
           mSheetNeedsShow = false;
           mSheetWindowParent = topNonSheetWindow;
           // Only set contextInfo if our parent isn't a sheet.
@@ -883,21 +884,22 @@ NS_IMETHODIMP nsCocoaWindow::Show(bool b
         // get sheet's parent *before* hiding the sheet (which breaks the linkage)
         NSWindow* sheetParent = mSheetWindowParent;
         
         // hide the sheet
         [NSApp endSheet:mWindow];
         
         [TopLevelWindowData deactivateInWindow:mWindow];
 
-        nsCocoaWindow* siblingSheetToShow = nullptr;
+        nsCOMPtr<nsIWidget> siblingSheetToShow;
         bool parentIsSheet = false;
 
         if (nativeParentWindow && piParentWidget &&
-            NS_SUCCEEDED(piParentWidget->GetChildSheet(false, &siblingSheetToShow)) &&
+            NS_SUCCEEDED(piParentWidget->GetChildSheet(
+                             false, getter_AddRefs(siblingSheetToShow))) &&
             siblingSheetToShow) {
           // First, give sibling sheets an opportunity to show.
           siblingSheetToShow->Show(true);
         }
         else if (nativeParentWindow && piParentWidget &&
                  NS_SUCCEEDED(piParentWidget->GetIsSheet(&parentIsSheet)) &&
                  parentIsSheet) {
           // Only set contextInfo if the parent of the parent sheet we're about
@@ -1837,28 +1839,29 @@ NS_IMETHODIMP nsCocoaWindow::SendSetZLev
 {
   nsWindowZ placement = nsWindowZTop;
   nsIWidget* actualBelow;
   if (mWidgetListener)
     mWidgetListener->ZLevelChanged(true, &placement, nullptr, &actualBelow);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsCocoaWindow::GetChildSheet(bool aShown, nsCocoaWindow** _retval)
+NS_IMETHODIMP nsCocoaWindow::GetChildSheet(bool aShown, nsIWidget** _retval)
 {
   nsIWidget* child = GetFirstChild();
 
   while (child) {
     if (child->WindowType() == eWindowType_sheet) {
       // if it's a sheet, it must be an nsCocoaWindow
       nsCocoaWindow* cocoaWindow = static_cast<nsCocoaWindow*>(child);
       if (cocoaWindow->mWindow &&
           ((aShown && [cocoaWindow->mWindow isVisible]) ||
           (!aShown && cocoaWindow->mSheetNeedsShow))) {
-        *_retval = cocoaWindow;
+        nsCOMPtr<nsIWidget> widget = cocoaWindow;
+        widget.forget(_retval);
         return NS_OK;
       }
     }
     child = child->GetNextSibling();
   }
 
   *_retval = nullptr;
 
--- a/widget/cocoa/nsPIWidgetCocoa.idl
+++ b/widget/cocoa/nsPIWidgetCocoa.idl
@@ -1,17 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsMenuBarX;
-interface nsCocoaWindow;
 interface nsIWidget;
 
 [ptr] native NSWindowPtr(NSWindow);
 
 //
 // nsPIWidgetCocoa
 //
 // A private interface (unfrozen, private to the widget implementation) that
@@ -19,17 +17,17 @@ interface nsIWidget;
 //
 [uuid(f75ff69e-3a51-419e-bd29-042f804bc2ed)]
 interface nsPIWidgetCocoa : nsISupports
 {
   void SendSetZLevelEvent();
 
   // Find the displayed child sheet (if aShown) or a child sheet that
   // wants to be displayed (if !aShown)
-  nsCocoaWindow GetChildSheet(in boolean aShown);
+  nsIWidget GetChildSheet(in boolean aShown);
   
   // Get the parent widget (if any) StandardCreate() was called with.
   nsIWidget GetRealParent();
   
   // If the object implementing this interface is a sheet, this will return the
   // native NSWindow it is attached to
   readonly attribute NSWindowPtr sheetWindowParent;