From b5cb13131ec0bdc967f87c18a1ca2895bab1529a Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Sat, 18 Dec 1999 02:09:29 +0000 Subject: [PATCH] Fixing some places when talking to the webshell object to start talking through the new docshell interfaces. git-svn-id: svn://10.0.0.236/trunk@56167 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 88 ++++++++++--------- .../xml/document/src/nsXMLContentSink.cpp | 11 +-- mozilla/layout/base/nsDocumentViewer.cpp | 88 ++++++++++--------- mozilla/layout/base/nsPresShell.cpp | 25 ++---- mozilla/layout/base/src/nsDocumentViewer.cpp | 88 ++++++++++--------- mozilla/layout/base/src/nsPluginViewer.cpp | 12 +-- mozilla/layout/generic/nsFrameFrame.cpp | 41 ++++----- mozilla/layout/generic/nsObjectFrame.cpp | 37 +++----- .../layout/html/base/src/nsObjectFrame.cpp | 37 +++----- mozilla/layout/html/base/src/nsPresShell.cpp | 25 ++---- .../layout/html/document/src/nsFrameFrame.cpp | 41 ++++----- .../xml/document/src/nsXMLContentSink.cpp | 11 +-- .../plugin/base/src/nsPluginViewer.cpp | 12 +-- .../modules/plugin/nglsrc/nsPluginViewer.cpp | 12 +-- 14 files changed, 256 insertions(+), 272 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index c7154eab266..be3a417b881 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -60,6 +60,9 @@ #include "nsIContentViewerFile.h" #include "nsIMarkupDocumentViewer.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeNode.h" +#include "nsIDocShell.h" #include "nsIServiceManager.h" @@ -566,16 +569,19 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte nsIView *view; nsresult rv; PRInt32 count,i; - nsCOMPtr childWebShell; nsCOMPtr viewer; + nsCOMPtr parentAsNode(do_QueryInterface(aParent)); - aParent->GetChildCount(count); + parentAsNode->GetChildCount(&count); if(count> 0) { for(i=0;iChildAt(i, *(getter_AddRefs(childWebShell))); - childWebShell->GetContentViewer(getter_AddRefs(viewer)); - nsCOMPtr viewerFile = do_QueryInterface(viewer); + nsCOMPtr child; + parentAsNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + childAsShell->GetContentViewer(getter_AddRefs(viewer)); + nsCOMPtr viewerFile(do_QueryInterface(viewer)); if (viewerFile) { + nsCOMPtr childWebShell(do_QueryInterface(child)); NS_ENSURE_SUCCESS(viewerFile->PrintContent(childWebShell,aDContext), NS_ERROR_FAILURE); } } @@ -1271,22 +1277,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetDefaultCharacterSet(const PRUnichar* aDefau { mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet // now set the default char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1321,22 +1327,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCh { mForceCharacterSet = aForceCharacterSet; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1380,22 +1386,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact { mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1413,22 +1419,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintChar { mHintCharset = aHintCharacterSet; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 60d5a80624d..ff0bf9d5c83 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -33,6 +33,7 @@ #include "nsIURL.h" #include "nsNetUtil.h" #include "nsIWebShell.h" +#include "nsIDocShellTreeItem.h" #include "nsIContent.h" #include "nsITextContent.h" #include "nsIPresContext.h" @@ -1568,13 +1569,13 @@ nsXMLContentSink::StartLayout() NS_RELEASE(url); } PRBool topLevelFrameset = PR_FALSE; - if (mWebShell) { - nsIWebShell* rootWebShell; - mWebShell->GetRootWebShell(rootWebShell); - if (mWebShell == rootWebShell) { + nsCOMPtr docShellAsItem(do_QueryInterface(mWebShell)); + if (docShellAsItem) { + nsCOMPtr root; + docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); + if(docShellAsItem.get() == root.get()) { topLevelFrameset = PR_TRUE; } - NS_IF_RELEASE(rootWebShell); } if ((nsnull != ref) || topLevelFrameset) { diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index c7154eab266..be3a417b881 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -60,6 +60,9 @@ #include "nsIContentViewerFile.h" #include "nsIMarkupDocumentViewer.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeNode.h" +#include "nsIDocShell.h" #include "nsIServiceManager.h" @@ -566,16 +569,19 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte nsIView *view; nsresult rv; PRInt32 count,i; - nsCOMPtr childWebShell; nsCOMPtr viewer; + nsCOMPtr parentAsNode(do_QueryInterface(aParent)); - aParent->GetChildCount(count); + parentAsNode->GetChildCount(&count); if(count> 0) { for(i=0;iChildAt(i, *(getter_AddRefs(childWebShell))); - childWebShell->GetContentViewer(getter_AddRefs(viewer)); - nsCOMPtr viewerFile = do_QueryInterface(viewer); + nsCOMPtr child; + parentAsNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + childAsShell->GetContentViewer(getter_AddRefs(viewer)); + nsCOMPtr viewerFile(do_QueryInterface(viewer)); if (viewerFile) { + nsCOMPtr childWebShell(do_QueryInterface(child)); NS_ENSURE_SUCCESS(viewerFile->PrintContent(childWebShell,aDContext), NS_ERROR_FAILURE); } } @@ -1271,22 +1277,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetDefaultCharacterSet(const PRUnichar* aDefau { mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet // now set the default char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1321,22 +1327,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCh { mForceCharacterSet = aForceCharacterSet; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1380,22 +1386,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact { mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1413,22 +1419,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintChar { mHintCharset = aHintCharacterSet; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index be23d61d525..7c6f3dc6917 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -86,7 +86,7 @@ #include "nsIClipboard.h" #include "nsITransferable.h" #include "nsIFormatConverter.h" -#include "nsIWebShell.h" +#include "nsIDocShellTreeItem.h" #include "nsIBrowserWindow.h" #include "nsIURI.h" #include "nsIEventQueue.h" @@ -130,7 +130,6 @@ static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID); static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kIScrollableFrameIID, NS_ISCROLLABLE_FRAME_IID); // Largest chunk size we recycle @@ -774,13 +773,12 @@ PresShell::Init(nsIDocument* aDocument, nsCOMPtr container; result = aPresContext->GetContainer(getter_AddRefs(container)); if (NS_SUCCEEDED(result) && container) { - nsCOMPtr webShell; - webShell = do_QueryInterface(container,&result); - if (NS_SUCCEEDED(result) && webShell){ - nsWebShellType webShellType; - result = webShell->GetWebShellType(webShellType); + nsCOMPtr docShell(do_QueryInterface(container, &result)); + if (NS_SUCCEEDED(result) && docShell){ + PRInt32 docShellType; + result = docShell->GetItemType(&docShellType); if (NS_SUCCEEDED(result)){ - if (nsWebShellContent == webShellType){ + if (nsIDocShellTreeItem::typeContent == docShellType){ mDocument->SetDisplaySelection(PR_TRUE); } } @@ -2613,16 +2611,6 @@ PresShell::HandleEvent(nsIView *aView, if (nsnull != frame) { PushCurrentEventFrame(); - nsIWebShell* webShell = nsnull; - nsISupports* container; - mPresContext->GetContainer(&container); - if (nsnull != container) { - if (NS_OK != container->QueryInterface(kIWebShellIID, (void**)&webShell)) { - NS_ASSERTION(webShell, "No webshell to grab during event dispatch"); - } - NS_RELEASE(container); - } - nsIEventStateManager *manager; nsIContent* focusContent = nsnull; if (NS_OK == mPresContext->GetEventStateManager(&manager)) { @@ -2674,7 +2662,6 @@ PresShell::HandleEvent(nsIView *aView, NS_IF_RELEASE(focusContent); } PopCurrentEventFrame(); - NS_IF_RELEASE(webShell); } else { rv = NS_OK; diff --git a/mozilla/layout/base/src/nsDocumentViewer.cpp b/mozilla/layout/base/src/nsDocumentViewer.cpp index c7154eab266..be3a417b881 100644 --- a/mozilla/layout/base/src/nsDocumentViewer.cpp +++ b/mozilla/layout/base/src/nsDocumentViewer.cpp @@ -60,6 +60,9 @@ #include "nsIContentViewerFile.h" #include "nsIMarkupDocumentViewer.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeNode.h" +#include "nsIDocShell.h" #include "nsIServiceManager.h" @@ -566,16 +569,19 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte nsIView *view; nsresult rv; PRInt32 count,i; - nsCOMPtr childWebShell; nsCOMPtr viewer; + nsCOMPtr parentAsNode(do_QueryInterface(aParent)); - aParent->GetChildCount(count); + parentAsNode->GetChildCount(&count); if(count> 0) { for(i=0;iChildAt(i, *(getter_AddRefs(childWebShell))); - childWebShell->GetContentViewer(getter_AddRefs(viewer)); - nsCOMPtr viewerFile = do_QueryInterface(viewer); + nsCOMPtr child; + parentAsNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + childAsShell->GetContentViewer(getter_AddRefs(viewer)); + nsCOMPtr viewerFile(do_QueryInterface(viewer)); if (viewerFile) { + nsCOMPtr childWebShell(do_QueryInterface(child)); NS_ENSURE_SUCCESS(viewerFile->PrintContent(childWebShell,aDContext), NS_ERROR_FAILURE); } } @@ -1271,22 +1277,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetDefaultCharacterSet(const PRUnichar* aDefau { mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet // now set the default char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1321,22 +1327,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCh { mForceCharacterSet = aForceCharacterSet; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1380,22 +1386,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact { mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); @@ -1413,22 +1419,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintChar { mHintCharset = aHintCharacterSet; // now set the force char set on all children of mContainer - nsCOMPtr webShell; - webShell = do_QueryInterface(mContainer); - if (webShell) + nsCOMPtr docShellNode(do_QueryInterface(mContainer)); + if (docShellNode) { - nsCOMPtr childWebShell; PRInt32 i; PRInt32 n; - webShell->GetChildCount(n); + docShellNode->GetChildCount(&n); for (i=0; i < n; i++) { - webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); - NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); - if (childWebShell) + nsCOMPtr child; + docShellNode->GetChildAt(i, getter_AddRefs(child)); + nsCOMPtr childAsShell(do_QueryInterface(child)); + NS_ASSERTION(childAsShell, "null child in docshell"); + if (childAsShell) { nsCOMPtr childCV; - childWebShell->GetContentViewer(getter_AddRefs(childCV)); + childAsShell->GetContentViewer(getter_AddRefs(childCV)); if (childCV) { nsCOMPtr markupCV = do_QueryInterface(childCV); diff --git a/mozilla/layout/base/src/nsPluginViewer.cpp b/mozilla/layout/base/src/nsPluginViewer.cpp index 128930c4419..992465592ca 100644 --- a/mozilla/layout/base/src/nsPluginViewer.cpp +++ b/mozilla/layout/base/src/nsPluginViewer.cpp @@ -39,6 +39,7 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" // Class IDs static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID); @@ -834,15 +835,16 @@ NS_IMETHODIMP pluginInstanceOwner :: ShowStatus(const char *aStatusMsg) if ((NS_OK == rv) && (nsnull != cont)) { - nsCOMPtr ws(do_QueryInterface(cont)); + nsCOMPtr docShellItem(do_QueryInterface(cont)); - if (NS_OK == rv) + if (docShellItem) { - nsCOMPtr rootWebShell; + nsCOMPtr root; - ws->GetRootWebShell(*getter_AddRefs(rootWebShell)); + docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); - if (nsnull != rootWebShell) + nsCOMPtr rootWebShell(do_QueryInterface(root)); + if (rootWebShell) { nsCOMPtr rootContainer; diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 3656840fe3a..aff00cfc2f0 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -24,6 +24,9 @@ #include "nsHTMLContainerFrame.h" #include "nsIHTMLContent.h" #include "nsIWebShell.h" +#include "nsIDocShell.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeNode.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" @@ -687,7 +690,8 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, GetParentContent(content); mWebShell = do_CreateInstance(kWebShellCID); - NS_ENSURE_TRUE(mWebShell, NS_ERROR_FAILURE); + nsCOMPtr docShellAsItem(do_QueryInterface(mWebShell)); + NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); // pass along marginwidth, marginheight, scrolling so sub document can use it mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content)); @@ -697,7 +701,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, mWebShell->SetScrolling(GetScrolling(content, mode)); nsString frameName; if (GetName(content, frameName)) { - mWebShell->SetName(frameName.GetUnicode()); + docShellAsItem->SetName(frameName.GetUnicode()); } // If our container is a web-shell, inform it that it has a new @@ -706,10 +710,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, nsISupports* container; aPresContext->GetContainer(&container); if (nsnull != container) { - nsIWebShell* outerShell = nsnull; - container->QueryInterface(kIWebShellIID, (void**) &outerShell); - if (nsnull != outerShell) { - outerShell->AddChild(mWebShell); + nsCOMPtr parentAsNode(do_QueryInterface(container)); + if (parentAsNode) { + parentAsNode->AddChild(docShellAsItem); // connect the container... nsIWebShellContainer* outerContainer = nsnull; @@ -720,8 +723,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, } #ifdef INCLUDE_XUL - nsWebShellType parentType; - outerShell->GetWebShellType(parentType); + nsCOMPtr parentAsItem(do_QueryInterface(parentAsNode)); + PRInt32 parentType; + parentAsItem->GetItemType(&parentType); nsIAtom* typeAtom = NS_NewAtom("type"); nsAutoString value, valuePiece; PRBool isContent; @@ -740,20 +744,19 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, } if (isContent) { // The web shell's type is content. - mWebShell->SetWebShellType(nsWebShellContent); - nsCOMPtr shellAsContainer; - shellAsContainer = do_QueryInterface(mWebShell); + docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent); + nsCOMPtr shellAsContainer(do_QueryInterface(mWebShell)); shellAsContainer->ContentShellAdded(mWebShell, content); } else { // Inherit our type from our parent webshell. If it is // chrome, we'll be chrome. If it is content, we'll be // content. - mWebShell->SetWebShellType(parentType); + docShellAsItem->SetItemType(parentType); } // Make sure all shells have links back to the content element in the // nearest enclosing chrome shell. - + nsCOMPtr parentShell(do_QueryInterface(parentAsNode)); nsCOMPtr chromeEventHandler; if (parentType == nsWebShellChrome) { // Our parent shell is a chrome shell. It is therefore our nearest @@ -764,20 +767,18 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, else { // Our parent shell is a content shell. Get the chrome info from // it and use that for our shell as well. - outerShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); + parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); } mWebShell->SetChromeEventHandler(chromeEventHandler); #endif // INCLUDE_XUL - nsIPref* outerPrefs = nsnull; // connect the prefs - outerShell->GetPrefs(outerPrefs); - if (nsnull != outerPrefs) { - mWebShell->SetPrefs(outerPrefs); - NS_RELEASE(outerPrefs); + nsCOMPtr parentPrefs; // connect the prefs + parentShell->GetPrefs(getter_AddRefs(parentPrefs)); + if (parentPrefs) { + mWebShell->SetPrefs(parentPrefs); } - NS_RELEASE(outerShell); } NS_RELEASE(container); } diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 477d0c5c47f..d9ac0f7117d 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -50,6 +50,7 @@ #include "nsITimer.h" #include "nsITimerCallback.h" #include "nsLayoutAtoms.h" +#include "nsIDocShellTreeItem.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -1733,50 +1734,40 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg) if (nsnull != mContext) { - nsISupports *cont; + nsCOMPtr cont; - rv = mContext->GetContainer(&cont); + rv = mContext->GetContainer(getter_AddRefs(cont)); if ((NS_OK == rv) && (nsnull != cont)) { - nsIWebShell *ws; - - rv = cont->QueryInterface(nsIWebShell::GetIID(), (void **)&ws); - - if (NS_OK == rv) + nsCOMPtr docShellItem(do_QueryInterface(cont)); + if (docShellItem) { - nsIWebShell *rootWebShell; + nsCOMPtr root; - ws->GetRootWebShell(rootWebShell); + docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); - if (nsnull != rootWebShell) + nsCOMPtr rootWebShell(do_QueryInterface(root)); + + if (rootWebShell) { - nsIWebShellContainer *rootContainer; + nsCOMPtr rootContainer; - rv = rootWebShell->GetContainer(rootContainer); + rv = rootWebShell->GetContainer(*getter_AddRefs(rootContainer)); if (nsnull != rootContainer) { - nsIBrowserWindow *browserWindow; + nsCOMPtr browserWindow(do_QueryInterface(rootContainer)); - if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) + if (rootContainer) { nsAutoString msg = nsAutoString(aStatusMsg); rv = browserWindow->SetStatus(msg.GetUnicode()); - NS_RELEASE(browserWindow); } - - NS_RELEASE(rootContainer); } - - NS_RELEASE(rootWebShell); } - - NS_RELEASE(ws); } - - NS_RELEASE(cont); } } diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 477d0c5c47f..d9ac0f7117d 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -50,6 +50,7 @@ #include "nsITimer.h" #include "nsITimerCallback.h" #include "nsLayoutAtoms.h" +#include "nsIDocShellTreeItem.h" // XXX For temporary paint code #include "nsIStyleContext.h" @@ -1733,50 +1734,40 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg) if (nsnull != mContext) { - nsISupports *cont; + nsCOMPtr cont; - rv = mContext->GetContainer(&cont); + rv = mContext->GetContainer(getter_AddRefs(cont)); if ((NS_OK == rv) && (nsnull != cont)) { - nsIWebShell *ws; - - rv = cont->QueryInterface(nsIWebShell::GetIID(), (void **)&ws); - - if (NS_OK == rv) + nsCOMPtr docShellItem(do_QueryInterface(cont)); + if (docShellItem) { - nsIWebShell *rootWebShell; + nsCOMPtr root; - ws->GetRootWebShell(rootWebShell); + docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); - if (nsnull != rootWebShell) + nsCOMPtr rootWebShell(do_QueryInterface(root)); + + if (rootWebShell) { - nsIWebShellContainer *rootContainer; + nsCOMPtr rootContainer; - rv = rootWebShell->GetContainer(rootContainer); + rv = rootWebShell->GetContainer(*getter_AddRefs(rootContainer)); if (nsnull != rootContainer) { - nsIBrowserWindow *browserWindow; + nsCOMPtr browserWindow(do_QueryInterface(rootContainer)); - if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) + if (rootContainer) { nsAutoString msg = nsAutoString(aStatusMsg); rv = browserWindow->SetStatus(msg.GetUnicode()); - NS_RELEASE(browserWindow); } - - NS_RELEASE(rootContainer); } - - NS_RELEASE(rootWebShell); } - - NS_RELEASE(ws); } - - NS_RELEASE(cont); } } diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index be23d61d525..7c6f3dc6917 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -86,7 +86,7 @@ #include "nsIClipboard.h" #include "nsITransferable.h" #include "nsIFormatConverter.h" -#include "nsIWebShell.h" +#include "nsIDocShellTreeItem.h" #include "nsIBrowserWindow.h" #include "nsIURI.h" #include "nsIEventQueue.h" @@ -130,7 +130,6 @@ static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID); static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); -static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kIScrollableFrameIID, NS_ISCROLLABLE_FRAME_IID); // Largest chunk size we recycle @@ -774,13 +773,12 @@ PresShell::Init(nsIDocument* aDocument, nsCOMPtr container; result = aPresContext->GetContainer(getter_AddRefs(container)); if (NS_SUCCEEDED(result) && container) { - nsCOMPtr webShell; - webShell = do_QueryInterface(container,&result); - if (NS_SUCCEEDED(result) && webShell){ - nsWebShellType webShellType; - result = webShell->GetWebShellType(webShellType); + nsCOMPtr docShell(do_QueryInterface(container, &result)); + if (NS_SUCCEEDED(result) && docShell){ + PRInt32 docShellType; + result = docShell->GetItemType(&docShellType); if (NS_SUCCEEDED(result)){ - if (nsWebShellContent == webShellType){ + if (nsIDocShellTreeItem::typeContent == docShellType){ mDocument->SetDisplaySelection(PR_TRUE); } } @@ -2613,16 +2611,6 @@ PresShell::HandleEvent(nsIView *aView, if (nsnull != frame) { PushCurrentEventFrame(); - nsIWebShell* webShell = nsnull; - nsISupports* container; - mPresContext->GetContainer(&container); - if (nsnull != container) { - if (NS_OK != container->QueryInterface(kIWebShellIID, (void**)&webShell)) { - NS_ASSERTION(webShell, "No webshell to grab during event dispatch"); - } - NS_RELEASE(container); - } - nsIEventStateManager *manager; nsIContent* focusContent = nsnull; if (NS_OK == mPresContext->GetEventStateManager(&manager)) { @@ -2674,7 +2662,6 @@ PresShell::HandleEvent(nsIView *aView, NS_IF_RELEASE(focusContent); } PopCurrentEventFrame(); - NS_IF_RELEASE(webShell); } else { rv = NS_OK; diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 3656840fe3a..aff00cfc2f0 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -24,6 +24,9 @@ #include "nsHTMLContainerFrame.h" #include "nsIHTMLContent.h" #include "nsIWebShell.h" +#include "nsIDocShell.h" +#include "nsIDocShellTreeItem.h" +#include "nsIDocShellTreeNode.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" @@ -687,7 +690,8 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, GetParentContent(content); mWebShell = do_CreateInstance(kWebShellCID); - NS_ENSURE_TRUE(mWebShell, NS_ERROR_FAILURE); + nsCOMPtr docShellAsItem(do_QueryInterface(mWebShell)); + NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); // pass along marginwidth, marginheight, scrolling so sub document can use it mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content)); @@ -697,7 +701,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, mWebShell->SetScrolling(GetScrolling(content, mode)); nsString frameName; if (GetName(content, frameName)) { - mWebShell->SetName(frameName.GetUnicode()); + docShellAsItem->SetName(frameName.GetUnicode()); } // If our container is a web-shell, inform it that it has a new @@ -706,10 +710,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, nsISupports* container; aPresContext->GetContainer(&container); if (nsnull != container) { - nsIWebShell* outerShell = nsnull; - container->QueryInterface(kIWebShellIID, (void**) &outerShell); - if (nsnull != outerShell) { - outerShell->AddChild(mWebShell); + nsCOMPtr parentAsNode(do_QueryInterface(container)); + if (parentAsNode) { + parentAsNode->AddChild(docShellAsItem); // connect the container... nsIWebShellContainer* outerContainer = nsnull; @@ -720,8 +723,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, } #ifdef INCLUDE_XUL - nsWebShellType parentType; - outerShell->GetWebShellType(parentType); + nsCOMPtr parentAsItem(do_QueryInterface(parentAsNode)); + PRInt32 parentType; + parentAsItem->GetItemType(&parentType); nsIAtom* typeAtom = NS_NewAtom("type"); nsAutoString value, valuePiece; PRBool isContent; @@ -740,20 +744,19 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, } if (isContent) { // The web shell's type is content. - mWebShell->SetWebShellType(nsWebShellContent); - nsCOMPtr shellAsContainer; - shellAsContainer = do_QueryInterface(mWebShell); + docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent); + nsCOMPtr shellAsContainer(do_QueryInterface(mWebShell)); shellAsContainer->ContentShellAdded(mWebShell, content); } else { // Inherit our type from our parent webshell. If it is // chrome, we'll be chrome. If it is content, we'll be // content. - mWebShell->SetWebShellType(parentType); + docShellAsItem->SetItemType(parentType); } // Make sure all shells have links back to the content element in the // nearest enclosing chrome shell. - + nsCOMPtr parentShell(do_QueryInterface(parentAsNode)); nsCOMPtr chromeEventHandler; if (parentType == nsWebShellChrome) { // Our parent shell is a chrome shell. It is therefore our nearest @@ -764,20 +767,18 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext, else { // Our parent shell is a content shell. Get the chrome info from // it and use that for our shell as well. - outerShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); + parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); } mWebShell->SetChromeEventHandler(chromeEventHandler); #endif // INCLUDE_XUL - nsIPref* outerPrefs = nsnull; // connect the prefs - outerShell->GetPrefs(outerPrefs); - if (nsnull != outerPrefs) { - mWebShell->SetPrefs(outerPrefs); - NS_RELEASE(outerPrefs); + nsCOMPtr parentPrefs; // connect the prefs + parentShell->GetPrefs(getter_AddRefs(parentPrefs)); + if (parentPrefs) { + mWebShell->SetPrefs(parentPrefs); } - NS_RELEASE(outerShell); } NS_RELEASE(container); } diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index 60d5a80624d..ff0bf9d5c83 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -33,6 +33,7 @@ #include "nsIURL.h" #include "nsNetUtil.h" #include "nsIWebShell.h" +#include "nsIDocShellTreeItem.h" #include "nsIContent.h" #include "nsITextContent.h" #include "nsIPresContext.h" @@ -1568,13 +1569,13 @@ nsXMLContentSink::StartLayout() NS_RELEASE(url); } PRBool topLevelFrameset = PR_FALSE; - if (mWebShell) { - nsIWebShell* rootWebShell; - mWebShell->GetRootWebShell(rootWebShell); - if (mWebShell == rootWebShell) { + nsCOMPtr docShellAsItem(do_QueryInterface(mWebShell)); + if (docShellAsItem) { + nsCOMPtr root; + docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); + if(docShellAsItem.get() == root.get()) { topLevelFrameset = PR_TRUE; } - NS_IF_RELEASE(rootWebShell); } if ((nsnull != ref) || topLevelFrameset) { diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index 128930c4419..992465592ca 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -39,6 +39,7 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" // Class IDs static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID); @@ -834,15 +835,16 @@ NS_IMETHODIMP pluginInstanceOwner :: ShowStatus(const char *aStatusMsg) if ((NS_OK == rv) && (nsnull != cont)) { - nsCOMPtr ws(do_QueryInterface(cont)); + nsCOMPtr docShellItem(do_QueryInterface(cont)); - if (NS_OK == rv) + if (docShellItem) { - nsCOMPtr rootWebShell; + nsCOMPtr root; - ws->GetRootWebShell(*getter_AddRefs(rootWebShell)); + docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); - if (nsnull != rootWebShell) + nsCOMPtr rootWebShell(do_QueryInterface(root)); + if (rootWebShell) { nsCOMPtr rootContainer; diff --git a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp index 128930c4419..992465592ca 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -39,6 +39,7 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIInterfaceRequestor.h" +#include "nsIDocShellTreeItem.h" // Class IDs static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID); @@ -834,15 +835,16 @@ NS_IMETHODIMP pluginInstanceOwner :: ShowStatus(const char *aStatusMsg) if ((NS_OK == rv) && (nsnull != cont)) { - nsCOMPtr ws(do_QueryInterface(cont)); + nsCOMPtr docShellItem(do_QueryInterface(cont)); - if (NS_OK == rv) + if (docShellItem) { - nsCOMPtr rootWebShell; + nsCOMPtr root; - ws->GetRootWebShell(*getter_AddRefs(rootWebShell)); + docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); - if (nsnull != rootWebShell) + nsCOMPtr rootWebShell(do_QueryInterface(root)); + if (rootWebShell) { nsCOMPtr rootContainer;