Bug 1310796 part 1. Get rid of GetTargetableShellCount in favor of a more explicit GetTabCount. r=mystor,gijs
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 08 Dec 2016 16:41:45 -1000
changeset 325471 f5616da76211c2121d4a4d2e9ba8b59ba9bed20e
parent 325470 b57b890350b0e607b4d9b4ca266a761d20fae15e
child 325472 5e6b91cd71b12d411031e942aa1e3d220b5f73e4
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersmystor, gijs
bugs1310796
milestone53.0a1
Bug 1310796 part 1. Get rid of GetTargetableShellCount in favor of a more explicit GetTabCount. r=mystor,gijs
docshell/base/nsIDocShellTreeOwner.idl
dom/base/nsGlobalWindow.cpp
embedding/browser/nsDocShellTreeOwner.cpp
xpfe/appshell/nsChromeTreeOwner.cpp
xpfe/appshell/nsContentTreeOwner.cpp
xpfe/appshell/nsXULWindow.cpp
xpfe/appshell/nsXULWindow.h
--- a/docshell/base/nsIDocShellTreeOwner.idl
+++ b/docshell/base/nsIDocShellTreeOwner.idl
@@ -92,18 +92,19 @@ interface nsIDocShellTreeOwner : nsISupp
 	/*
 	Gets the current persistence states of the window.
 	*/
 	void getPersistence(out boolean aPersistPosition,
                             out boolean aPersistSize,
                             out boolean aPersistSizeMode);
 
 	/*
-	Gets the number of targettable docshells.
+	Gets the number of tabs currently open in our window, assuming
+	this tree owner has such a concept.
 	*/
-	readonly attribute unsigned long targetableShellCount;
+	readonly attribute unsigned long tabCount;
 
 	/*
 	Returns true if there is a primary content shell or a primary
 	tab parent.
 	*/
 	readonly attribute bool hasPrimaryContent;
 };
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7015,18 +7015,18 @@ nsGlobalWindow::CanMoveResizeWindows(boo
       if (docShell) {
         nsCOMPtr<nsITabChild> child = docShell->GetTabChild();
         if (child) {
           child->SendGetTabCount(&itemCount);
         }
       }
     } else {
       nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
-      if (treeOwner) {
-        treeOwner->GetTargetableShellCount(&itemCount);
+      if (!treeOwner || NS_FAILED(treeOwner->GetTabCount(&itemCount))) {
+        itemCount = 0;
       }
     }
     if (itemCount > 1) {
       return false;
     }
   }
 
   if (mDocShell) {
--- a/embedding/browser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/nsDocShellTreeOwner.cpp
@@ -473,24 +473,23 @@ NS_IMETHODIMP
 nsDocShellTreeOwner::GetPersistence(bool* aPersistPosition,
                                     bool* aPersistSize,
                                     bool* aPersistSizeMode)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-nsDocShellTreeOwner::GetTargetableShellCount(uint32_t* aResult)
+nsDocShellTreeOwner::GetTabCount(uint32_t* aResult)
 {
   if (mTreeOwner) {
-    mTreeOwner->GetTargetableShellCount(aResult);
-  } else {
-    *aResult = 0;
+    return mTreeOwner->GetTabCount(aResult);
   }
 
+  *aResult = 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShellTreeOwner::GetHasPrimaryContent(bool* aResult)
 {
   *aResult = mPrimaryTabParent || mPrimaryContentShell;
   return NS_OK;
--- a/xpfe/appshell/nsChromeTreeOwner.cpp
+++ b/xpfe/appshell/nsChromeTreeOwner.cpp
@@ -282,18 +282,22 @@ nsChromeTreeOwner::GetPersistence(bool* 
                     persistString.Find(gLiterals->kHeight) > kNotFound;
   if (aPersistSizeMode)
     *aPersistSizeMode = persistString.Find(gLiterals->kSizemode) > kNotFound;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsChromeTreeOwner::GetTargetableShellCount(uint32_t* aResult)
+nsChromeTreeOwner::GetTabCount(uint32_t* aResult)
 {
+  if (mXULWindow) {
+    return mXULWindow->GetTabCount(aResult);
+  }
+
   *aResult = 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsChromeTreeOwner::GetHasPrimaryContent(bool* aResult)
 {
   NS_ENSURE_STATE(mXULWindow);
--- a/xpfe/appshell/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/nsContentTreeOwner.cpp
@@ -345,20 +345,23 @@ nsContentTreeOwner::GetPersistence(bool*
     *aPersistSize = persistString.Find("width") >= 0 || persistString.Find("height") >= 0 ? true : false;
   if (aPersistSizeMode)
     *aPersistSizeMode = persistString.Find("sizemode") >= 0 ? true : false;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsContentTreeOwner::GetTargetableShellCount(uint32_t* aResult)
+nsContentTreeOwner::GetTabCount(uint32_t* aResult)
 {
-  NS_ENSURE_STATE(mXULWindow);
-  *aResult = mXULWindow->mTargetableShells.Count();
+  if (mXULWindow) {
+    return mXULWindow->GetTabCount(aResult);
+  }
+
+  *aResult = 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsContentTreeOwner::GetHasPrimaryContent(bool* aResult)
 {
   NS_ENSURE_STATE(mXULWindow);
   return mXULWindow->GetHasPrimaryContent(aResult);
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -2295,16 +2295,27 @@ void nsXULWindow::SizeShellToWithLimit(i
     // function assumes that the outer docshell is adding some constant
     // "border" chrome to the content area.
     winWidth = std::max(winWidth + widthDelta, aDesiredWidth);
     winHeight = std::max(winHeight + heightDelta, aDesiredHeight);
     SetSize(winWidth, winHeight, true);
   }
 }
 
+nsresult
+nsXULWindow::GetTabCount(uint32_t* aResult)
+{
+  if (mXULBrowserWindow) {
+    return mXULBrowserWindow->GetTabCount(aResult);
+  }
+
+  *aResult = 0;
+  return NS_OK;
+}
+
 //*****************************************************************************
 //*** nsContentShellInfo: Object Management
 //*****************************************************************************   
 
 nsContentShellInfo::nsContentShellInfo(const nsAString& aID,
                                        nsIWeakReference* aContentShell)
   : id(aID),
     child(aContentShell)
--- a/xpfe/appshell/nsXULWindow.h
+++ b/xpfe/appshell/nsXULWindow.h
@@ -128,16 +128,17 @@ protected:
    void       EnableParent(bool aEnable);
    bool       ConstrainToZLevel(bool aImmediate, nsWindowZ *aPlacement,
                                 nsIWidget *aReqBelow, nsIWidget **aActualBelow);
    void       PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel,
                                       nsIXULWindow *aBehind);
    void       SetContentScrollbarVisibility(bool aVisible);
    bool       GetContentScrollbarVisibility();
    void       PersistentAttributesDirty(uint32_t aDirtyFlags);
+   nsresult   GetTabCount(uint32_t* aResult);
 
    nsChromeTreeOwner*      mChromeTreeOwner;
    nsContentTreeOwner*     mContentTreeOwner;
    nsContentTreeOwner*     mPrimaryContentTreeOwner;
    nsCOMPtr<nsIWidget>     mWindow;
    nsCOMPtr<nsIDocShell>   mDocShell;
    nsCOMPtr<nsPIDOMWindowOuter>  mDOMWindow;
    nsCOMPtr<nsIWeakReference> mParentWindow;