Bug 565541 (1/2) - Add targetableShellCount to nsIDocShellTreeOwner. r=bz
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 14 Apr 2011 14:27:53 -0700
changeset 70394 1c52f2d68d3949465ab6db0750ab624d6fa403a0
parent 70393 acd4a2d5d3d1348255f92a2b0e069639a54104aa
child 70395 3c723f2fe07ce7e41337b2fd0f59076a2c6e5d2f
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-esr52@cba007ad1747 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs565541
milestone7.0a1
Bug 565541 (1/2) - Add targetableShellCount to nsIDocShellTreeOwner. r=bz Basically, this will return a the number of tabs when nsIDocShellTreeOwner is a nsContentTreeOwner.
docshell/base/nsIDocShellTreeOwner.idl
embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
xpfe/appshell/src/nsChromeTreeOwner.cpp
xpfe/appshell/src/nsContentTreeOwner.cpp
--- a/docshell/base/nsIDocShellTreeOwner.idl
+++ b/docshell/base/nsIDocShellTreeOwner.idl
@@ -40,17 +40,17 @@
 #include "nsISupports.idl"
 
 /**
  * The nsIDocShellTreeOwner
  */
 
 interface nsIDocShellTreeItem;
 
-[scriptable, uuid(bc0eb30e-656e-491e-a7ae-7f460b660c8d)]
+[scriptable, uuid(932f9f93-8e21-4728-a527-cafc64b4d831)]
 interface nsIDocShellTreeOwner : nsISupports
 {
 	/*
 	Return the child DocShellTreeItem with the specified name.
 	name - This is the name of the item that is trying to be found.
 	aRequestor - This is the docshellTreeItem that is requesting the find.  This
 	parameter is used to identify when the child is asking its parent to find
 	a child with the specific name.  The parent uses this parameter to ensure
@@ -111,9 +111,14 @@ interface nsIDocShellTreeOwner : nsISupp
                             in boolean aPersistSizeMode);
 
 	/*
 	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.
+	*/
+	readonly attribute unsigned long targetableShellCount;
 };
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -462,16 +462,28 @@ nsDocShellTreeOwner::SetPersistence(PRBo
 NS_IMETHODIMP
 nsDocShellTreeOwner::GetPersistence(PRBool* aPersistPosition,
                                     PRBool* aPersistSize,
                                     PRBool* aPersistSizeMode)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP
+nsDocShellTreeOwner::GetTargetableShellCount(PRUint32* aResult)
+{
+  if(mTreeOwner) {
+    mTreeOwner->GetTargetableShellCount(aResult);
+  } else {
+    *aResult = 0;
+  }
+
+  return NS_OK;
+}
+
 //*****************************************************************************
 // nsDocShellTreeOwner::nsIBaseWindow
 //*****************************************************************************   
 
 
 NS_IMETHODIMP
 nsDocShellTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
                                 nsIWidget* aParentWidget, PRInt32 aX,
--- a/xpfe/appshell/src/nsChromeTreeOwner.cpp
+++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp
@@ -352,16 +352,23 @@ nsChromeTreeOwner::GetPersistence(PRBool
     *aPersistSize = persistString.Find(gLiterals->kWidth) > kNotFound ||
                     persistString.Find(gLiterals->kHeight) > kNotFound;
   if (aPersistSizeMode)
     *aPersistSizeMode = persistString.Find(gLiterals->kSizemode) > kNotFound;
 
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsChromeTreeOwner::GetTargetableShellCount(PRUint32* aResult)
+{
+  *aResult = 0;
+  return NS_OK;
+}
+
 //*****************************************************************************
 // nsChromeTreeOwner::nsIBaseWindow
 //*****************************************************************************   
 
 NS_IMETHODIMP nsChromeTreeOwner::InitWindow(nativeWindow aParentNativeWindow,
    nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)   
 {
    // Ignore widget parents for now.  Don't think those are a vaild thing to call.
--- a/xpfe/appshell/src/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/src/nsContentTreeOwner.cpp
@@ -429,16 +429,24 @@ nsContentTreeOwner::GetPersistence(PRBoo
   if (aPersistSize)
     *aPersistSize = persistString.Find("width") >= 0 || persistString.Find("height") >= 0 ? PR_TRUE : PR_FALSE;
   if (aPersistSizeMode)
     *aPersistSizeMode = persistString.Find("sizemode") >= 0 ? PR_TRUE : PR_FALSE;
 
   return NS_OK;
 }
 
+NS_IMETHODIMP
+nsContentTreeOwner::GetTargetableShellCount(PRUint32* aResult)
+{
+  NS_ENSURE_STATE(mXULWindow);
+  *aResult = mXULWindow->mTargetableShells.Count();
+  return NS_OK;
+}
+
 //*****************************************************************************
 // nsContentTreeOwner::nsIWebBrowserChrome3
 //*****************************************************************************   
 
 NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal(const nsAString &originalTarget,
                                                         nsIURI *linkURI,
                                                         nsIDOMNode *linkNode,
                                                         PRBool isAppTab,