From 552210fa4dba606de0962b1914831cc594d541cb Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Tue, 21 Dec 1999 00:11:33 +0000 Subject: [PATCH] Fixed a couple of previously unitialized member variables. Implemented the setting and getting of the ChromeEventHandler attribute. Implemented the setting and getting of the title. git-svn-id: svn://10.0.0.236/trunk@56251 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 43 +++++++++++++++++++++------- mozilla/docshell/base/nsDocShell.h | 9 +++--- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index baa895ed604..668c04584e9 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -36,6 +36,7 @@ #include "nsIFrame.h" #include "nsIMarkupDocumentViewer.h" #include "nsXPIDLString.h" +#include "nsIChromeEventHandler.h" #ifdef XXX_NS_DEBUG // XXX: we'll need a logging facility for debugging #define WEB_TRACE(_bit,_args) \ @@ -56,13 +57,15 @@ //***************************************************************************** nsDocShell::nsDocShell() : - mCreated(PR_FALSE), + mCreated(PR_FALSE), + mInitInfo(nsnull), mContentListener(nsnull), mItemType(typeContent), mMarginWidth(0), mMarginHeight(0), mParent(nsnull), - mTreeOwner(nsnull) + mTreeOwner(nsnull), + mChromeEventHandler(nsnull) { NS_INIT_REFCNT(); } @@ -329,7 +332,8 @@ NS_IMETHODIMP nsDocShell::GetContentViewer(nsIContentViewer** aContentViewer) NS_IMETHODIMP nsDocShell::SetChromeEventHandler(nsIChromeEventHandler* aChromeEventHandler) { - //XXX Implement + // Weak reference. Don't addref. + mChromeEventHandler = aChromeEventHandler; return NS_OK; } @@ -337,7 +341,8 @@ NS_IMETHODIMP nsDocShell::GetChromeEventHandler(nsIChromeEventHandler** aChromeE { NS_ENSURE_ARG_POINTER(aChromeEventHandler); - //XXX Implement + *aChromeEventHandler = mChromeEventHandler; + NS_IF_ADDREF(*aChromeEventHandler); return NS_OK; } @@ -1158,18 +1163,34 @@ NS_IMETHODIMP nsDocShell::FocusAvailable(nsIBaseWindow* aCurrentFocus, return NS_OK; } -NS_IMETHODIMP nsDocShell::GetTitle(PRUnichar** title) +NS_IMETHODIMP nsDocShell::GetTitle(PRUnichar** aTitle) { - NS_ENSURE_ARG_POINTER(title); + NS_ENSURE_ARG_POINTER(aTitle); - //XXX First Check - return NS_ERROR_FAILURE; + *aTitle = mTitle.ToNewUnicode(); + return NS_OK; } -NS_IMETHODIMP nsDocShell::SetTitle(const PRUnichar* title) +NS_IMETHODIMP nsDocShell::SetTitle(const PRUnichar* aTitle) { - //XXX First Check - return NS_ERROR_FAILURE; + // Store local title + mTitle = aTitle; + + nsCOMPtr parent; + GetSameTypeParent(getter_AddRefs(parent)); + + // When title is set on the top object it should then be passed to the + // tree owner. + if(!parent) + { + nsCOMPtr treeOwnerAsWin(do_QueryInterface(mTreeOwner)); + if(!treeOwnerAsWin) + return NS_OK; + + treeOwnerAsWin->SetTitle(aTitle); + } + + return NS_OK; } //***************************************************************************** diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 51897a8ecb8..2890972bb16 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -132,6 +132,7 @@ protected: protected: PRBool mCreated; nsString mName; + nsString mTitle; nsVoidArray mChildren; nsDSURIContentListener* mContentListener; nsDocShellInitInfo* mInitInfo; @@ -148,12 +149,12 @@ protected: PRInt32 mMarginHeight; PRInt32 mItemType; - /* Note this can not be nsCOMPtr as that that would cause an addref on the - parent thus a cycle. A weak reference would work, but not required as the - interface states a requirement to zero out the parent when the parent is - releasing the interface.*/ + /* WEAK REFERENCES BELOW HERE. + Note these are intentionally not addrefd. Doing so will create a cycle. + For that reasons don't use nsCOMPtr.*/ nsIDocShellTreeItem* mParent; // Weak Reference nsIDocShellTreeOwner* mTreeOwner; // Weak Reference + nsIChromeEventHandler* mChromeEventHandler; //Weak Reference }; #endif /* nsDocShell_h__ */