Fixing some places when talking to the webshell object to start talking through the new docshell interfaces.

This commit is contained in:
tbogard%aol.net 1999-12-18 02:09:29 +00:00
Родитель 3a0585e79d
Коммит 780e191953
14 изменённых файлов: 256 добавлений и 272 удалений

Просмотреть файл

@ -60,6 +60,9 @@
#include "nsIContentViewerFile.h" #include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShell.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
@ -566,16 +569,19 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
nsIView *view; nsIView *view;
nsresult rv; nsresult rv;
PRInt32 count,i; PRInt32 count,i;
nsCOMPtr<nsIWebShell> childWebShell;
nsCOMPtr<nsIContentViewer> viewer; nsCOMPtr<nsIContentViewer> viewer;
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(aParent));
aParent->GetChildCount(count); parentAsNode->GetChildCount(&count);
if(count> 0) { if(count> 0) {
for(i=0;i<count;i++) { for(i=0;i<count;i++) {
aParent->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
childWebShell->GetContentViewer(getter_AddRefs(viewer)); parentAsNode->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer); nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
childAsShell->GetContentViewer(getter_AddRefs(viewer));
nsCOMPtr<nsIContentViewerFile> viewerFile(do_QueryInterface(viewer));
if (viewerFile) { if (viewerFile) {
nsCOMPtr<nsIWebShell> childWebShell(do_QueryInterface(child));
NS_ENSURE_SUCCESS(viewerFile->PrintContent(childWebShell,aDContext), NS_ERROR_FAILURE); 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 mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet
// now set the default char set on all children of mContainer // now set the default char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1321,22 +1327,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCh
{ {
mForceCharacterSet = aForceCharacterSet; mForceCharacterSet = aForceCharacterSet;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1380,22 +1386,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact
{ {
mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource; mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1413,22 +1419,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintChar
{ {
mHintCharset = aHintCharacterSet; mHintCharset = aHintCharacterSet;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);

Просмотреть файл

@ -33,6 +33,7 @@
#include "nsIURL.h" #include "nsIURL.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsITextContent.h" #include "nsITextContent.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
@ -1568,13 +1569,13 @@ nsXMLContentSink::StartLayout()
NS_RELEASE(url); NS_RELEASE(url);
} }
PRBool topLevelFrameset = PR_FALSE; PRBool topLevelFrameset = PR_FALSE;
if (mWebShell) { nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mWebShell));
nsIWebShell* rootWebShell; if (docShellAsItem) {
mWebShell->GetRootWebShell(rootWebShell); nsCOMPtr<nsIDocShellTreeItem> root;
if (mWebShell == rootWebShell) { docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if(docShellAsItem.get() == root.get()) {
topLevelFrameset = PR_TRUE; topLevelFrameset = PR_TRUE;
} }
NS_IF_RELEASE(rootWebShell);
} }
if ((nsnull != ref) || topLevelFrameset) { if ((nsnull != ref) || topLevelFrameset) {

Просмотреть файл

@ -60,6 +60,9 @@
#include "nsIContentViewerFile.h" #include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShell.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
@ -566,16 +569,19 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
nsIView *view; nsIView *view;
nsresult rv; nsresult rv;
PRInt32 count,i; PRInt32 count,i;
nsCOMPtr<nsIWebShell> childWebShell;
nsCOMPtr<nsIContentViewer> viewer; nsCOMPtr<nsIContentViewer> viewer;
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(aParent));
aParent->GetChildCount(count); parentAsNode->GetChildCount(&count);
if(count> 0) { if(count> 0) {
for(i=0;i<count;i++) { for(i=0;i<count;i++) {
aParent->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
childWebShell->GetContentViewer(getter_AddRefs(viewer)); parentAsNode->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer); nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
childAsShell->GetContentViewer(getter_AddRefs(viewer));
nsCOMPtr<nsIContentViewerFile> viewerFile(do_QueryInterface(viewer));
if (viewerFile) { if (viewerFile) {
nsCOMPtr<nsIWebShell> childWebShell(do_QueryInterface(child));
NS_ENSURE_SUCCESS(viewerFile->PrintContent(childWebShell,aDContext), NS_ERROR_FAILURE); 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 mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet
// now set the default char set on all children of mContainer // now set the default char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1321,22 +1327,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCh
{ {
mForceCharacterSet = aForceCharacterSet; mForceCharacterSet = aForceCharacterSet;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1380,22 +1386,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact
{ {
mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource; mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1413,22 +1419,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintChar
{ {
mHintCharset = aHintCharacterSet; mHintCharset = aHintCharacterSet;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);

Просмотреть файл

@ -86,7 +86,7 @@
#include "nsIClipboard.h" #include "nsIClipboard.h"
#include "nsITransferable.h" #include "nsITransferable.h"
#include "nsIFormatConverter.h" #include "nsIFormatConverter.h"
#include "nsIWebShell.h" #include "nsIDocShellTreeItem.h"
#include "nsIBrowserWindow.h" #include "nsIBrowserWindow.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIEventQueue.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(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); 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); static NS_DEFINE_IID(kIScrollableFrameIID, NS_ISCROLLABLE_FRAME_IID);
// Largest chunk size we recycle // Largest chunk size we recycle
@ -774,13 +773,12 @@ PresShell::Init(nsIDocument* aDocument,
nsCOMPtr<nsISupports> container; nsCOMPtr<nsISupports> container;
result = aPresContext->GetContainer(getter_AddRefs(container)); result = aPresContext->GetContainer(getter_AddRefs(container));
if (NS_SUCCEEDED(result) && container) { if (NS_SUCCEEDED(result) && container) {
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(container, &result));
webShell = do_QueryInterface(container,&result); if (NS_SUCCEEDED(result) && docShell){
if (NS_SUCCEEDED(result) && webShell){ PRInt32 docShellType;
nsWebShellType webShellType; result = docShell->GetItemType(&docShellType);
result = webShell->GetWebShellType(webShellType);
if (NS_SUCCEEDED(result)){ if (NS_SUCCEEDED(result)){
if (nsWebShellContent == webShellType){ if (nsIDocShellTreeItem::typeContent == docShellType){
mDocument->SetDisplaySelection(PR_TRUE); mDocument->SetDisplaySelection(PR_TRUE);
} }
} }
@ -2613,16 +2611,6 @@ PresShell::HandleEvent(nsIView *aView,
if (nsnull != frame) { if (nsnull != frame) {
PushCurrentEventFrame(); 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; nsIEventStateManager *manager;
nsIContent* focusContent = nsnull; nsIContent* focusContent = nsnull;
if (NS_OK == mPresContext->GetEventStateManager(&manager)) { if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
@ -2674,7 +2662,6 @@ PresShell::HandleEvent(nsIView *aView,
NS_IF_RELEASE(focusContent); NS_IF_RELEASE(focusContent);
} }
PopCurrentEventFrame(); PopCurrentEventFrame();
NS_IF_RELEASE(webShell);
} }
else { else {
rv = NS_OK; rv = NS_OK;

Просмотреть файл

@ -60,6 +60,9 @@
#include "nsIContentViewerFile.h" #include "nsIContentViewerFile.h"
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIDocShell.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
@ -566,16 +569,19 @@ DocumentViewerImpl::PrintContent(nsIWebShell *aParent,nsIDeviceContext *aDConte
nsIView *view; nsIView *view;
nsresult rv; nsresult rv;
PRInt32 count,i; PRInt32 count,i;
nsCOMPtr<nsIWebShell> childWebShell;
nsCOMPtr<nsIContentViewer> viewer; nsCOMPtr<nsIContentViewer> viewer;
nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(aParent));
aParent->GetChildCount(count); parentAsNode->GetChildCount(&count);
if(count> 0) { if(count> 0) {
for(i=0;i<count;i++) { for(i=0;i<count;i++) {
aParent->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
childWebShell->GetContentViewer(getter_AddRefs(viewer)); parentAsNode->GetChildAt(i, getter_AddRefs(child));
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer); nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
childAsShell->GetContentViewer(getter_AddRefs(viewer));
nsCOMPtr<nsIContentViewerFile> viewerFile(do_QueryInterface(viewer));
if (viewerFile) { if (viewerFile) {
nsCOMPtr<nsIWebShell> childWebShell(do_QueryInterface(child));
NS_ENSURE_SUCCESS(viewerFile->PrintContent(childWebShell,aDContext), NS_ERROR_FAILURE); 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 mDefaultCharacterSet = aDefaultCharacterSet; // this does a copy of aDefaultCharacterSet
// now set the default char set on all children of mContainer // now set the default char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1321,22 +1327,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetForceCharacterSet(const PRUnichar* aForceCh
{ {
mForceCharacterSet = aForceCharacterSet; mForceCharacterSet = aForceCharacterSet;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1380,22 +1386,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSetSource(PRInt32 aHintCharact
{ {
mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource; mHintCharsetSource = (nsCharsetSource)aHintCharacterSetSource;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);
@ -1413,22 +1419,22 @@ NS_IMETHODIMP DocumentViewerImpl::SetHintCharacterSet(const PRUnichar* aHintChar
{ {
mHintCharset = aHintCharacterSet; mHintCharset = aHintCharacterSet;
// now set the force char set on all children of mContainer // now set the force char set on all children of mContainer
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeNode> docShellNode(do_QueryInterface(mContainer));
webShell = do_QueryInterface(mContainer); if (docShellNode)
if (webShell)
{ {
nsCOMPtr<nsIWebShell> childWebShell;
PRInt32 i; PRInt32 i;
PRInt32 n; PRInt32 n;
webShell->GetChildCount(n); docShellNode->GetChildCount(&n);
for (i=0; i < n; i++) for (i=0; i < n; i++)
{ {
webShell->ChildAt(i, *(getter_AddRefs(childWebShell))); nsCOMPtr<nsIDocShellTreeItem> child;
NS_WARN_IF_FALSE(childWebShell, "null child in docshell"); docShellNode->GetChildAt(i, getter_AddRefs(child));
if (childWebShell) nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
NS_ASSERTION(childAsShell, "null child in docshell");
if (childAsShell)
{ {
nsCOMPtr<nsIContentViewer> childCV; nsCOMPtr<nsIContentViewer> childCV;
childWebShell->GetContentViewer(getter_AddRefs(childCV)); childAsShell->GetContentViewer(getter_AddRefs(childCV));
if (childCV) if (childCV)
{ {
nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV); nsCOMPtr<nsIMarkupDocumentViewer> markupCV = do_QueryInterface(childCV);

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
// Class IDs // Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID); 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)) if ((NS_OK == rv) && (nsnull != cont))
{ {
nsCOMPtr<nsIWebShell> ws(do_QueryInterface(cont)); nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
if (NS_OK == rv) if (docShellItem)
{ {
nsCOMPtr<nsIWebShell> rootWebShell; nsCOMPtr<nsIDocShellTreeItem> root;
ws->GetRootWebShell(*getter_AddRefs(rootWebShell)); docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if (nsnull != rootWebShell) nsCOMPtr<nsIWebShell> rootWebShell(do_QueryInterface(root));
if (rootWebShell)
{ {
nsCOMPtr<nsIWebShellContainer> rootContainer; nsCOMPtr<nsIWebShellContainer> rootContainer;

Просмотреть файл

@ -24,6 +24,9 @@
#include "nsHTMLContainerFrame.h" #include "nsHTMLContainerFrame.h"
#include "nsIHTMLContent.h" #include "nsIHTMLContent.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIBaseWindow.h" #include "nsIBaseWindow.h"
#include "nsIContentViewer.h" #include "nsIContentViewer.h"
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
@ -687,7 +690,8 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
GetParentContent(content); GetParentContent(content);
mWebShell = do_CreateInstance(kWebShellCID); mWebShell = do_CreateInstance(kWebShellCID);
NS_ENSURE_TRUE(mWebShell, NS_ERROR_FAILURE); nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mWebShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
// pass along marginwidth, marginheight, scrolling so sub document can use it // pass along marginwidth, marginheight, scrolling so sub document can use it
mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content)); mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content));
@ -697,7 +701,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
mWebShell->SetScrolling(GetScrolling(content, mode)); mWebShell->SetScrolling(GetScrolling(content, mode));
nsString frameName; nsString frameName;
if (GetName(content, 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 // If our container is a web-shell, inform it that it has a new
@ -706,10 +710,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
nsISupports* container; nsISupports* container;
aPresContext->GetContainer(&container); aPresContext->GetContainer(&container);
if (nsnull != container) { if (nsnull != container) {
nsIWebShell* outerShell = nsnull; nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(container));
container->QueryInterface(kIWebShellIID, (void**) &outerShell); if (parentAsNode) {
if (nsnull != outerShell) { parentAsNode->AddChild(docShellAsItem);
outerShell->AddChild(mWebShell);
// connect the container... // connect the container...
nsIWebShellContainer* outerContainer = nsnull; nsIWebShellContainer* outerContainer = nsnull;
@ -720,8 +723,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
} }
#ifdef INCLUDE_XUL #ifdef INCLUDE_XUL
nsWebShellType parentType; nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsNode));
outerShell->GetWebShellType(parentType); PRInt32 parentType;
parentAsItem->GetItemType(&parentType);
nsIAtom* typeAtom = NS_NewAtom("type"); nsIAtom* typeAtom = NS_NewAtom("type");
nsAutoString value, valuePiece; nsAutoString value, valuePiece;
PRBool isContent; PRBool isContent;
@ -740,20 +744,19 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
} }
if (isContent) { if (isContent) {
// The web shell's type is content. // The web shell's type is content.
mWebShell->SetWebShellType(nsWebShellContent); docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent);
nsCOMPtr<nsIWebShellContainer> shellAsContainer; nsCOMPtr<nsIWebShellContainer> shellAsContainer(do_QueryInterface(mWebShell));
shellAsContainer = do_QueryInterface(mWebShell);
shellAsContainer->ContentShellAdded(mWebShell, content); shellAsContainer->ContentShellAdded(mWebShell, content);
} else { } else {
// Inherit our type from our parent webshell. If it is // Inherit our type from our parent webshell. If it is
// chrome, we'll be chrome. If it is content, we'll be // chrome, we'll be chrome. If it is content, we'll be
// content. // content.
mWebShell->SetWebShellType(parentType); docShellAsItem->SetItemType(parentType);
} }
// Make sure all shells have links back to the content element in the // Make sure all shells have links back to the content element in the
// nearest enclosing chrome shell. // nearest enclosing chrome shell.
nsCOMPtr<nsIDocShell> parentShell(do_QueryInterface(parentAsNode));
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler; nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
if (parentType == nsWebShellChrome) { if (parentType == nsWebShellChrome) {
// Our parent shell is a chrome shell. It is therefore our nearest // Our parent shell is a chrome shell. It is therefore our nearest
@ -764,20 +767,18 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
else { else {
// Our parent shell is a content shell. Get the chrome info from // Our parent shell is a content shell. Get the chrome info from
// it and use that for our shell as well. // it and use that for our shell as well.
outerShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
} }
mWebShell->SetChromeEventHandler(chromeEventHandler); mWebShell->SetChromeEventHandler(chromeEventHandler);
#endif // INCLUDE_XUL #endif // INCLUDE_XUL
nsIPref* outerPrefs = nsnull; // connect the prefs nsCOMPtr<nsIPref> parentPrefs; // connect the prefs
outerShell->GetPrefs(outerPrefs); parentShell->GetPrefs(getter_AddRefs(parentPrefs));
if (nsnull != outerPrefs) { if (parentPrefs) {
mWebShell->SetPrefs(outerPrefs); mWebShell->SetPrefs(parentPrefs);
NS_RELEASE(outerPrefs);
} }
NS_RELEASE(outerShell);
} }
NS_RELEASE(container); NS_RELEASE(container);
} }

Просмотреть файл

@ -50,6 +50,7 @@
#include "nsITimer.h" #include "nsITimer.h"
#include "nsITimerCallback.h" #include "nsITimerCallback.h"
#include "nsLayoutAtoms.h" #include "nsLayoutAtoms.h"
#include "nsIDocShellTreeItem.h"
// XXX For temporary paint code // XXX For temporary paint code
#include "nsIStyleContext.h" #include "nsIStyleContext.h"
@ -1733,50 +1734,40 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg)
if (nsnull != mContext) if (nsnull != mContext)
{ {
nsISupports *cont; nsCOMPtr<nsISupports> cont;
rv = mContext->GetContainer(&cont); rv = mContext->GetContainer(getter_AddRefs(cont));
if ((NS_OK == rv) && (nsnull != cont)) if ((NS_OK == rv) && (nsnull != cont))
{ {
nsIWebShell *ws; nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
if (docShellItem)
rv = cont->QueryInterface(nsIWebShell::GetIID(), (void **)&ws);
if (NS_OK == rv)
{ {
nsIWebShell *rootWebShell; nsCOMPtr<nsIDocShellTreeItem> root;
ws->GetRootWebShell(rootWebShell); docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if (nsnull != rootWebShell) nsCOMPtr<nsIWebShell> rootWebShell(do_QueryInterface(root));
if (rootWebShell)
{ {
nsIWebShellContainer *rootContainer; nsCOMPtr<nsIWebShellContainer> rootContainer;
rv = rootWebShell->GetContainer(rootContainer); rv = rootWebShell->GetContainer(*getter_AddRefs(rootContainer));
if (nsnull != rootContainer) if (nsnull != rootContainer)
{ {
nsIBrowserWindow *browserWindow; nsCOMPtr<nsIBrowserWindow> browserWindow(do_QueryInterface(rootContainer));
if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) if (rootContainer)
{ {
nsAutoString msg = nsAutoString(aStatusMsg); nsAutoString msg = nsAutoString(aStatusMsg);
rv = browserWindow->SetStatus(msg.GetUnicode()); rv = browserWindow->SetStatus(msg.GetUnicode());
NS_RELEASE(browserWindow);
} }
NS_RELEASE(rootContainer);
} }
NS_RELEASE(rootWebShell);
} }
NS_RELEASE(ws);
} }
NS_RELEASE(cont);
} }
} }

Просмотреть файл

@ -50,6 +50,7 @@
#include "nsITimer.h" #include "nsITimer.h"
#include "nsITimerCallback.h" #include "nsITimerCallback.h"
#include "nsLayoutAtoms.h" #include "nsLayoutAtoms.h"
#include "nsIDocShellTreeItem.h"
// XXX For temporary paint code // XXX For temporary paint code
#include "nsIStyleContext.h" #include "nsIStyleContext.h"
@ -1733,50 +1734,40 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const char *aStatusMsg)
if (nsnull != mContext) if (nsnull != mContext)
{ {
nsISupports *cont; nsCOMPtr<nsISupports> cont;
rv = mContext->GetContainer(&cont); rv = mContext->GetContainer(getter_AddRefs(cont));
if ((NS_OK == rv) && (nsnull != cont)) if ((NS_OK == rv) && (nsnull != cont))
{ {
nsIWebShell *ws; nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
if (docShellItem)
rv = cont->QueryInterface(nsIWebShell::GetIID(), (void **)&ws);
if (NS_OK == rv)
{ {
nsIWebShell *rootWebShell; nsCOMPtr<nsIDocShellTreeItem> root;
ws->GetRootWebShell(rootWebShell); docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if (nsnull != rootWebShell) nsCOMPtr<nsIWebShell> rootWebShell(do_QueryInterface(root));
if (rootWebShell)
{ {
nsIWebShellContainer *rootContainer; nsCOMPtr<nsIWebShellContainer> rootContainer;
rv = rootWebShell->GetContainer(rootContainer); rv = rootWebShell->GetContainer(*getter_AddRefs(rootContainer));
if (nsnull != rootContainer) if (nsnull != rootContainer)
{ {
nsIBrowserWindow *browserWindow; nsCOMPtr<nsIBrowserWindow> browserWindow(do_QueryInterface(rootContainer));
if (NS_OK == rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&browserWindow)) if (rootContainer)
{ {
nsAutoString msg = nsAutoString(aStatusMsg); nsAutoString msg = nsAutoString(aStatusMsg);
rv = browserWindow->SetStatus(msg.GetUnicode()); rv = browserWindow->SetStatus(msg.GetUnicode());
NS_RELEASE(browserWindow);
} }
NS_RELEASE(rootContainer);
} }
NS_RELEASE(rootWebShell);
} }
NS_RELEASE(ws);
} }
NS_RELEASE(cont);
} }
} }

Просмотреть файл

@ -86,7 +86,7 @@
#include "nsIClipboard.h" #include "nsIClipboard.h"
#include "nsITransferable.h" #include "nsITransferable.h"
#include "nsIFormatConverter.h" #include "nsIFormatConverter.h"
#include "nsIWebShell.h" #include "nsIDocShellTreeItem.h"
#include "nsIBrowserWindow.h" #include "nsIBrowserWindow.h"
#include "nsIURI.h" #include "nsIURI.h"
#include "nsIEventQueue.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(kIContentIID, NS_ICONTENT_IID);
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID); static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID); 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); static NS_DEFINE_IID(kIScrollableFrameIID, NS_ISCROLLABLE_FRAME_IID);
// Largest chunk size we recycle // Largest chunk size we recycle
@ -774,13 +773,12 @@ PresShell::Init(nsIDocument* aDocument,
nsCOMPtr<nsISupports> container; nsCOMPtr<nsISupports> container;
result = aPresContext->GetContainer(getter_AddRefs(container)); result = aPresContext->GetContainer(getter_AddRefs(container));
if (NS_SUCCEEDED(result) && container) { if (NS_SUCCEEDED(result) && container) {
nsCOMPtr<nsIWebShell> webShell; nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(container, &result));
webShell = do_QueryInterface(container,&result); if (NS_SUCCEEDED(result) && docShell){
if (NS_SUCCEEDED(result) && webShell){ PRInt32 docShellType;
nsWebShellType webShellType; result = docShell->GetItemType(&docShellType);
result = webShell->GetWebShellType(webShellType);
if (NS_SUCCEEDED(result)){ if (NS_SUCCEEDED(result)){
if (nsWebShellContent == webShellType){ if (nsIDocShellTreeItem::typeContent == docShellType){
mDocument->SetDisplaySelection(PR_TRUE); mDocument->SetDisplaySelection(PR_TRUE);
} }
} }
@ -2613,16 +2611,6 @@ PresShell::HandleEvent(nsIView *aView,
if (nsnull != frame) { if (nsnull != frame) {
PushCurrentEventFrame(); 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; nsIEventStateManager *manager;
nsIContent* focusContent = nsnull; nsIContent* focusContent = nsnull;
if (NS_OK == mPresContext->GetEventStateManager(&manager)) { if (NS_OK == mPresContext->GetEventStateManager(&manager)) {
@ -2674,7 +2662,6 @@ PresShell::HandleEvent(nsIView *aView,
NS_IF_RELEASE(focusContent); NS_IF_RELEASE(focusContent);
} }
PopCurrentEventFrame(); PopCurrentEventFrame();
NS_IF_RELEASE(webShell);
} }
else { else {
rv = NS_OK; rv = NS_OK;

Просмотреть файл

@ -24,6 +24,9 @@
#include "nsHTMLContainerFrame.h" #include "nsHTMLContainerFrame.h"
#include "nsIHTMLContent.h" #include "nsIHTMLContent.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIBaseWindow.h" #include "nsIBaseWindow.h"
#include "nsIContentViewer.h" #include "nsIContentViewer.h"
#include "nsIMarkupDocumentViewer.h" #include "nsIMarkupDocumentViewer.h"
@ -687,7 +690,8 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
GetParentContent(content); GetParentContent(content);
mWebShell = do_CreateInstance(kWebShellCID); mWebShell = do_CreateInstance(kWebShellCID);
NS_ENSURE_TRUE(mWebShell, NS_ERROR_FAILURE); nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mWebShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
// pass along marginwidth, marginheight, scrolling so sub document can use it // pass along marginwidth, marginheight, scrolling so sub document can use it
mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content)); mWebShell->SetMarginWidth(GetMarginWidth(aPresContext, content));
@ -697,7 +701,7 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
mWebShell->SetScrolling(GetScrolling(content, mode)); mWebShell->SetScrolling(GetScrolling(content, mode));
nsString frameName; nsString frameName;
if (GetName(content, 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 // If our container is a web-shell, inform it that it has a new
@ -706,10 +710,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
nsISupports* container; nsISupports* container;
aPresContext->GetContainer(&container); aPresContext->GetContainer(&container);
if (nsnull != container) { if (nsnull != container) {
nsIWebShell* outerShell = nsnull; nsCOMPtr<nsIDocShellTreeNode> parentAsNode(do_QueryInterface(container));
container->QueryInterface(kIWebShellIID, (void**) &outerShell); if (parentAsNode) {
if (nsnull != outerShell) { parentAsNode->AddChild(docShellAsItem);
outerShell->AddChild(mWebShell);
// connect the container... // connect the container...
nsIWebShellContainer* outerContainer = nsnull; nsIWebShellContainer* outerContainer = nsnull;
@ -720,8 +723,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
} }
#ifdef INCLUDE_XUL #ifdef INCLUDE_XUL
nsWebShellType parentType; nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsNode));
outerShell->GetWebShellType(parentType); PRInt32 parentType;
parentAsItem->GetItemType(&parentType);
nsIAtom* typeAtom = NS_NewAtom("type"); nsIAtom* typeAtom = NS_NewAtom("type");
nsAutoString value, valuePiece; nsAutoString value, valuePiece;
PRBool isContent; PRBool isContent;
@ -740,20 +744,19 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
} }
if (isContent) { if (isContent) {
// The web shell's type is content. // The web shell's type is content.
mWebShell->SetWebShellType(nsWebShellContent); docShellAsItem->SetItemType(nsIDocShellTreeItem::typeContent);
nsCOMPtr<nsIWebShellContainer> shellAsContainer; nsCOMPtr<nsIWebShellContainer> shellAsContainer(do_QueryInterface(mWebShell));
shellAsContainer = do_QueryInterface(mWebShell);
shellAsContainer->ContentShellAdded(mWebShell, content); shellAsContainer->ContentShellAdded(mWebShell, content);
} else { } else {
// Inherit our type from our parent webshell. If it is // Inherit our type from our parent webshell. If it is
// chrome, we'll be chrome. If it is content, we'll be // chrome, we'll be chrome. If it is content, we'll be
// content. // content.
mWebShell->SetWebShellType(parentType); docShellAsItem->SetItemType(parentType);
} }
// Make sure all shells have links back to the content element in the // Make sure all shells have links back to the content element in the
// nearest enclosing chrome shell. // nearest enclosing chrome shell.
nsCOMPtr<nsIDocShell> parentShell(do_QueryInterface(parentAsNode));
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler; nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
if (parentType == nsWebShellChrome) { if (parentType == nsWebShellChrome) {
// Our parent shell is a chrome shell. It is therefore our nearest // Our parent shell is a chrome shell. It is therefore our nearest
@ -764,20 +767,18 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext* aPresContext,
else { else {
// Our parent shell is a content shell. Get the chrome info from // Our parent shell is a content shell. Get the chrome info from
// it and use that for our shell as well. // it and use that for our shell as well.
outerShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); parentShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
} }
mWebShell->SetChromeEventHandler(chromeEventHandler); mWebShell->SetChromeEventHandler(chromeEventHandler);
#endif // INCLUDE_XUL #endif // INCLUDE_XUL
nsIPref* outerPrefs = nsnull; // connect the prefs nsCOMPtr<nsIPref> parentPrefs; // connect the prefs
outerShell->GetPrefs(outerPrefs); parentShell->GetPrefs(getter_AddRefs(parentPrefs));
if (nsnull != outerPrefs) { if (parentPrefs) {
mWebShell->SetPrefs(outerPrefs); mWebShell->SetPrefs(parentPrefs);
NS_RELEASE(outerPrefs);
} }
NS_RELEASE(outerShell);
} }
NS_RELEASE(container); NS_RELEASE(container);
} }

Просмотреть файл

@ -33,6 +33,7 @@
#include "nsIURL.h" #include "nsIURL.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsITextContent.h" #include "nsITextContent.h"
#include "nsIPresContext.h" #include "nsIPresContext.h"
@ -1568,13 +1569,13 @@ nsXMLContentSink::StartLayout()
NS_RELEASE(url); NS_RELEASE(url);
} }
PRBool topLevelFrameset = PR_FALSE; PRBool topLevelFrameset = PR_FALSE;
if (mWebShell) { nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mWebShell));
nsIWebShell* rootWebShell; if (docShellAsItem) {
mWebShell->GetRootWebShell(rootWebShell); nsCOMPtr<nsIDocShellTreeItem> root;
if (mWebShell == rootWebShell) { docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if(docShellAsItem.get() == root.get()) {
topLevelFrameset = PR_TRUE; topLevelFrameset = PR_TRUE;
} }
NS_IF_RELEASE(rootWebShell);
} }
if ((nsnull != ref) || topLevelFrameset) { if ((nsnull != ref) || topLevelFrameset) {

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
// Class IDs // Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID); 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)) if ((NS_OK == rv) && (nsnull != cont))
{ {
nsCOMPtr<nsIWebShell> ws(do_QueryInterface(cont)); nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
if (NS_OK == rv) if (docShellItem)
{ {
nsCOMPtr<nsIWebShell> rootWebShell; nsCOMPtr<nsIDocShellTreeItem> root;
ws->GetRootWebShell(*getter_AddRefs(rootWebShell)); docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if (nsnull != rootWebShell) nsCOMPtr<nsIWebShell> rootWebShell(do_QueryInterface(root));
if (rootWebShell)
{ {
nsCOMPtr<nsIWebShellContainer> rootContainer; nsCOMPtr<nsIWebShellContainer> rootContainer;

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsIDocShellTreeItem.h"
// Class IDs // Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID); 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)) if ((NS_OK == rv) && (nsnull != cont))
{ {
nsCOMPtr<nsIWebShell> ws(do_QueryInterface(cont)); nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
if (NS_OK == rv) if (docShellItem)
{ {
nsCOMPtr<nsIWebShell> rootWebShell; nsCOMPtr<nsIDocShellTreeItem> root;
ws->GetRootWebShell(*getter_AddRefs(rootWebShell)); docShellItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
if (nsnull != rootWebShell) nsCOMPtr<nsIWebShell> rootWebShell(do_QueryInterface(root));
if (rootWebShell)
{ {
nsCOMPtr<nsIWebShellContainer> rootContainer; nsCOMPtr<nsIWebShellContainer> rootContainer;