Bug 427448 - Applescript curl & ptit query worked in FF2 fails in FF3
authorLuis de la Rosa <bugzilla@luisdelarosa.com>
Thu, 17 Jul 2008 13:02:34 -0400
changeset 16020 2ac85f53e36b49274aeff8685038016c00468f06
parent 16019 e888893e48ba591e6003a6106ef3b039dbe484e3
child 16021 884012d735c9e77b7e2e1e3315e8eb1e4c4b4cb6
push idunknown
push userunknown
push dateunknown
bugs427448
milestone1.9.1a1pre
Bug 427448 - Applescript curl & ptit query worked in FF2 fails in FF3 r=josh, sr=roc
xpfe/bootstrap/appleevents/nsWindowUtils.cpp
--- a/xpfe/bootstrap/appleevents/nsWindowUtils.cpp
+++ b/xpfe/bootstrap/appleevents/nsWindowUtils.cpp
@@ -40,16 +40,17 @@
 
 #include "nsCommandLineServiceMac.h"
 #include "nsCOMPtr.h"
 #include "nsIBaseWindow.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIContent.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
+#include "nsIDocShellTreeOwner.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNode.h"
 #include "nsIServiceManager.h"
@@ -401,19 +402,37 @@ TAEListIndex nsWindowUtils::GetWindowInd
 
 	return 0L; // error: theWindow wasn't found. Return an invalid index.
 }
 
 
 //---------------------------------------------------------
 void nsWindowUtils::GetCleanedWindowName(WindowPtr wind, char* outName, long maxLen)
 {
-	Str255 uncleanName;
-	GetWTitle(wind, uncleanName);
-	CopyPascalToCString(uncleanName, outName, maxLen);
+  nsCOMPtr<nsIXULWindow> xulWindow;
+  GetXULWindowFromWindowPtr(wind, getter_AddRefs(xulWindow));
+  ThrowErrIfNil(xulWindow, paramErr);
+
+  nsCOMPtr<nsIDocShellTreeItem> contentShell;
+  xulWindow->GetPrimaryContentShell(getter_AddRefs(contentShell));
+  ThrowErrIfNil(contentShell, paramErr);
+
+  nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
+  contentShell->GetTreeOwner(getter_AddRefs(treeOwner));
+
+  nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(treeOwner));
+  ThrowErrIfNil(baseWindow, paramErr);
+
+  nsXPIDLString title;
+  baseWindow->GetTitle(getter_Copies(title));
+  ThrowErrIfNil(title, paramErr);
+
+  const char* cTitle = NS_ConvertUTF16toUTF8(title).get();
+  strncpy(outName, cTitle, maxLen);
+  outName[maxLen - 1] = '\0';
 }
 
 //---------------------------------------------------------
 void nsWindowUtils::GetWindowUrlString(WindowPtr wind, char** outUrlStringPtr)
 {
 	*outUrlStringPtr = NULL;
 
 	nsCOMPtr<nsIXULWindow>		xulWindow;