Converted a number of places to use the docShell APIs instead of the webShell ones.

This commit is contained in:
tbogard%aol.net 2000-03-11 00:28:44 +00:00
Родитель 53b6e571ee
Коммит 5ba6095a17
4 изменённых файлов: 107 добавлений и 85 удалений

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

@ -33,6 +33,7 @@
#include "nsIContentViewerContainer.h"
#include "nsIContentViewer.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIDocumentLoader.h"
#include "nsIHTMLContent.h"
@ -75,7 +76,6 @@
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
@ -249,7 +249,6 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
return rv;
}
nsIWebShell* webShell = nsnull;
nsAutoString charset("UTF-8");
PRBool bIsHTML = PR_FALSE;
char* aContentType;
@ -317,13 +316,14 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
if (NS_OK == rv) {
nsIXMLContentSink* sink;
if (aContainer)
rv = aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
nsCOMPtr<nsIDocShell> docShell;
if(aContainer)
docShell = do_QueryInterface(aContainer, &rv);
else rv = NS_NewXMLContentSink(&sink, this, aUrl, nsnull);
if(NS_SUCCEEDED(rv) && (nsnull != webShell)) {
if(NS_SUCCEEDED(rv) && (docShell)) {
nsCOMPtr<nsIContentViewer> cv;
webShell->GetContentViewer(getter_AddRefs(cv));
docShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIMarkupDocumentViewer> muCV = do_QueryInterface(cv);
if (muCV) {
@ -362,18 +362,18 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
// get user default charset
if(kCharsetFromUserDefault > charsetSource)
{
PRUnichar* defaultCharsetFromWebShell = NULL;
PRUnichar* defaultCharsetFromDocShell = NULL;
if (muCV) {
rv = muCV->GetDefaultCharacterSet(&defaultCharsetFromWebShell);
rv = muCV->GetDefaultCharacterSet(&defaultCharsetFromDocShell);
if(NS_SUCCEEDED(rv)) {
#ifdef DEBUG_charset
nsAutoString d(defaultCharsetFromWebShell);
nsAutoString d(defaultCharsetFromDocShell);
char* cCharset = d.ToNewCString();
printf("From default charset, charset = %s\n", cCharset);
Recycle(cCharset);
#endif
charset = defaultCharsetFromWebShell;
Recycle(defaultCharsetFromWebShell);
charset = defaultCharsetFromDocShell;
Recycle(defaultCharsetFromDocShell);
charsetSource = kCharsetFromUserDefault;
}
}//user default
@ -399,20 +399,20 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
//charset from previous loading
if(kCharsetFromPreviousLoading > charsetSource)
{
PRUnichar* forceCharsetFromWebShell = NULL;
PRUnichar* forceCharsetFromDocShell = NULL;
if (muCV) {
rv = muCV->GetForceCharacterSet(&forceCharsetFromWebShell);
rv = muCV->GetForceCharacterSet(&forceCharsetFromDocShell);
}
if(NS_SUCCEEDED(rv) && (nsnull != forceCharsetFromWebShell))
if(NS_SUCCEEDED(rv) && (nsnull != forceCharsetFromDocShell))
{
#ifdef DEBUG_charset
nsAutoString d(forceCharsetFromWebShell);
nsAutoString d(forceCharsetFromDocShell);
char* cCharset = d.ToNewCString();
printf("From force, charset = %s \n", cCharset);
Recycle(cCharset);
#endif
charset = forceCharsetFromWebShell;
Recycle(forceCharsetFromWebShell);
charset = forceCharsetFromDocShell;
Recycle(forceCharsetFromDocShell);
//TODO: we should define appropriate constant for force charset
charsetSource = kCharsetFromPreviousLoading;
}
@ -445,7 +445,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
{
// we could do charset detection
nsICharsetDetector *cdet = nsnull;
nsIWebShellServices *wss = nsnull;
nsCOMPtr<nsIWebShellServices> wss;
nsICharsetDetectionAdaptor *adp = nsnull;
if(NS_SUCCEEDED( rv_detect =
@ -462,9 +462,10 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
cdetflt->QueryInterface(
NS_GET_IID(nsICharsetDetectionAdaptor),(void**) &adp)))
{
if( NS_SUCCEEDED( rv_detect=
webShell->QueryInterface(
NS_GET_IID(nsIWebShellServices),(void**) &wss)))
wss = do_QueryInterface(docShell,
&rv_detect);
if( NS_SUCCEEDED(rv_detect))
{
rv_detect = adp->Init(wss, cdet, (nsIDocument*)this,
mParser, charset.GetUnicode(),aCommand);
@ -485,7 +486,6 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
gPlugDetector = PR_FALSE;
}
NS_IF_RELEASE(wss);
NS_IF_RELEASE(cdet);
NS_IF_RELEASE(adp);
// NO NS_IF_RELEASE(cdetflt); here, do it after mParser->SetParserFilter
@ -497,8 +497,10 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
}
}
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell);
NS_IF_RELEASE(webShell);
}
}
if (NS_OK == rv) {

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

@ -33,6 +33,7 @@
#include "nsIContentViewerContainer.h"
#include "nsIContentViewer.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIDocumentLoader.h"
#include "nsIHTMLContent.h"
@ -75,7 +76,6 @@
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIDOMElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
@ -249,7 +249,6 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
return rv;
}
nsIWebShell* webShell = nsnull;
nsAutoString charset("UTF-8");
PRBool bIsHTML = PR_FALSE;
char* aContentType;
@ -317,13 +316,14 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
if (NS_OK == rv) {
nsIXMLContentSink* sink;
if (aContainer)
rv = aContainer->QueryInterface(kIWebShellIID, (void**)&webShell);
nsCOMPtr<nsIDocShell> docShell;
if(aContainer)
docShell = do_QueryInterface(aContainer, &rv);
else rv = NS_NewXMLContentSink(&sink, this, aUrl, nsnull);
if(NS_SUCCEEDED(rv) && (nsnull != webShell)) {
if(NS_SUCCEEDED(rv) && (docShell)) {
nsCOMPtr<nsIContentViewer> cv;
webShell->GetContentViewer(getter_AddRefs(cv));
docShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
nsCOMPtr<nsIMarkupDocumentViewer> muCV = do_QueryInterface(cv);
if (muCV) {
@ -362,18 +362,18 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
// get user default charset
if(kCharsetFromUserDefault > charsetSource)
{
PRUnichar* defaultCharsetFromWebShell = NULL;
PRUnichar* defaultCharsetFromDocShell = NULL;
if (muCV) {
rv = muCV->GetDefaultCharacterSet(&defaultCharsetFromWebShell);
rv = muCV->GetDefaultCharacterSet(&defaultCharsetFromDocShell);
if(NS_SUCCEEDED(rv)) {
#ifdef DEBUG_charset
nsAutoString d(defaultCharsetFromWebShell);
nsAutoString d(defaultCharsetFromDocShell);
char* cCharset = d.ToNewCString();
printf("From default charset, charset = %s\n", cCharset);
Recycle(cCharset);
#endif
charset = defaultCharsetFromWebShell;
Recycle(defaultCharsetFromWebShell);
charset = defaultCharsetFromDocShell;
Recycle(defaultCharsetFromDocShell);
charsetSource = kCharsetFromUserDefault;
}
}//user default
@ -399,20 +399,20 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
//charset from previous loading
if(kCharsetFromPreviousLoading > charsetSource)
{
PRUnichar* forceCharsetFromWebShell = NULL;
PRUnichar* forceCharsetFromDocShell = NULL;
if (muCV) {
rv = muCV->GetForceCharacterSet(&forceCharsetFromWebShell);
rv = muCV->GetForceCharacterSet(&forceCharsetFromDocShell);
}
if(NS_SUCCEEDED(rv) && (nsnull != forceCharsetFromWebShell))
if(NS_SUCCEEDED(rv) && (nsnull != forceCharsetFromDocShell))
{
#ifdef DEBUG_charset
nsAutoString d(forceCharsetFromWebShell);
nsAutoString d(forceCharsetFromDocShell);
char* cCharset = d.ToNewCString();
printf("From force, charset = %s \n", cCharset);
Recycle(cCharset);
#endif
charset = forceCharsetFromWebShell;
Recycle(forceCharsetFromWebShell);
charset = forceCharsetFromDocShell;
Recycle(forceCharsetFromDocShell);
//TODO: we should define appropriate constant for force charset
charsetSource = kCharsetFromPreviousLoading;
}
@ -445,7 +445,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
{
// we could do charset detection
nsICharsetDetector *cdet = nsnull;
nsIWebShellServices *wss = nsnull;
nsCOMPtr<nsIWebShellServices> wss;
nsICharsetDetectionAdaptor *adp = nsnull;
if(NS_SUCCEEDED( rv_detect =
@ -462,9 +462,10 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
cdetflt->QueryInterface(
NS_GET_IID(nsICharsetDetectionAdaptor),(void**) &adp)))
{
if( NS_SUCCEEDED( rv_detect=
webShell->QueryInterface(
NS_GET_IID(nsIWebShellServices),(void**) &wss)))
wss = do_QueryInterface(docShell,
&rv_detect);
if( NS_SUCCEEDED(rv_detect))
{
rv_detect = adp->Init(wss, cdet, (nsIDocument*)this,
mParser, charset.GetUnicode(),aCommand);
@ -485,7 +486,6 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
gPlugDetector = PR_FALSE;
}
NS_IF_RELEASE(wss);
NS_IF_RELEASE(cdet);
NS_IF_RELEASE(adp);
// NO NS_IF_RELEASE(cdetflt); here, do it after mParser->SetParserFilter
@ -497,8 +497,10 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
}
}
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
rv = NS_NewXMLContentSink(&sink, this, aUrl, webShell);
NS_IF_RELEASE(webShell);
}
}
if (NS_OK == rv) {

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

@ -58,7 +58,8 @@
#include "nsIWebShellWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
// mail
#include "nsMsgUtils.h"
@ -295,12 +296,21 @@ nsMessenger::SetWindow(nsIDOMWindow *aWin, nsIMsgWindow *aMsgWindow)
{
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIWebShell> rootWebShell;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
webShell->GetRootWebShell(*getter_AddRefs(rootWebShell));
if (nsnull != rootWebShell)
nsCOMPtr<nsIDocShellTreeItem> rootDocShellAsItem;
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootDocShellAsItem));
nsCOMPtr<nsIDocShellTreeNode>
rootDocShellAsNode(do_QueryInterface(rootDocShellAsItem));
if (rootDocShellAsNode)
{
nsresult rv = rootWebShell->FindChildWithName(webShellName.GetUnicode(), *getter_AddRefs(mWebShell));
nsCOMPtr<nsIDocShellTreeItem> childAsItem;
nsresult rv = rootDocShellAsNode->FindChildWithName(webShellName.GetUnicode(),
PR_TRUE, PR_FALSE, nsnull, getter_AddRefs(childAsItem));
mWebShell = do_QueryInterface(childAsItem);
if (NS_SUCCEEDED(rv) && mWebShell) {
@ -311,7 +321,8 @@ nsMessenger::SetWindow(nsIDOMWindow *aWin, nsIMsgWindow *aMsgWindow)
m_docLoaderObserver = do_QueryInterface(aStatusFeedback);
if (aStatusFeedback)
aStatusFeedback->SetWebShell(mWebShell, mWindow);
mWebShell->SetDocLoaderObserver(m_docLoaderObserver);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
docShell->SetDocLoaderObserver(m_docLoaderObserver);
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &rv);
if(NS_SUCCEEDED(rv))
mailSession->SetTemporaryMsgWindow(aMsgWindow);
@ -331,11 +342,12 @@ nsMessenger::InitializeDisplayCharset()
return;
// libmime always converts to UTF-8 (both HTML and XML)
if (mWebShell)
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
if (docShell)
{
nsAutoString aForceCharacterSet("UTF-8");
nsCOMPtr<nsIContentViewer> cv;
mWebShell->GetContentViewer(getter_AddRefs(cv));
docShell->GetContentViewer(getter_AddRefs(cv));
if (cv)
{
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
@ -1219,11 +1231,12 @@ nsMessenger::GetTransactionManager(nsITransactionManager* *aTxnMgr)
NS_IMETHODIMP nsMessenger::SetDocumentCharset(const PRUnichar *characterSet)
{
// Set a default charset of the webshell.
if (mWebShell)
// Set a default charset of the webshell.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
if (docShell)
{
nsCOMPtr<nsIContentViewer> cv;
mWebShell->GetContentViewer(getter_AddRefs(cv));
docShell->GetContentViewer(getter_AddRefs(cv));
if (cv)
{
nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(cv);
@ -1335,14 +1348,12 @@ NS_IMETHODIMP nsMessenger::DoPrint()
#endif
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIContentViewer> viewer;
NS_ASSERTION(mWebShell,"can't print, there is no webshell");
if (!mWebShell) {
return rv;
}
mWebShell->GetContentViewer(getter_AddRefs(viewer));
docShell->GetContentViewer(getter_AddRefs(viewer));
if (viewer)
{

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

@ -24,6 +24,8 @@
#include "nsIURILoader.h"
#include "nsCURILoader.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMElement.h"
#include "nsIDOMWindow.h"
@ -200,31 +202,36 @@ NS_IMETHODIMP nsMsgWindow::SetDOMWindow(nsIDOMWindow *aWindow)
nsresult rv = NS_OK;
nsCOMPtr<nsIScriptGlobalObject>
globalScript(do_QueryInterface(aWindow));
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(aWindow));
nsCOMPtr<nsIDocShell> docShell;
if (globalScript)
globalScript->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIWebShell> webshell(do_QueryInterface(docShell));
nsCOMPtr<nsIWebShell> rootWebshell;
if (webshell)
{
webshell->GetRootWebShell(mRootWebShell);
nsIWebShell *root = mRootWebShell;
NS_RELEASE(root); // don't hold reference
if (mRootWebShell)
{
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mRootWebShell));
if (docShell)
docShell->SetParentURIContentListener(this);
}
nsAutoString webShellName("messagepane");
nsCOMPtr<nsIWebShell> msgWebShell;
rv = mRootWebShell->FindChildWithName(webShellName.GetUnicode(), *getter_AddRefs(msgWebShell));
// we don't own mMessageWindowWebShell so don't try to keep a reference to it!
mMessageWindowWebShell = msgWebShell;
}
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
if(docShellAsItem)
{
nsCOMPtr<nsIDocShellTreeItem> rootAsItem;
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootAsItem));
nsCOMPtr<nsIDocShell> rootAsShell(do_QueryInterface(rootAsItem));
if(rootAsShell)
rootAsShell->SetParentURIContentListener(this);
nsAutoString childName("messagepane");
nsCOMPtr<nsIDocShellTreeNode> rootAsNode(do_QueryInterface(rootAsItem));
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(rootAsItem));
mRootWebShell = webShell;
nsCOMPtr<nsIDocShellTreeItem> msgDocShellItem;
if(rootAsNode)
rootAsNode->FindChildWithName(childName.GetUnicode(), PR_TRUE, PR_FALSE,
nsnull, getter_AddRefs(msgDocShellItem));
nsCOMPtr<nsIWebShell> msgWebShell(do_QueryInterface(msgDocShellItem));
// we don't own mMessageWindowWebShell so don't try to keep a reference to it!
mMessageWindowWebShell = msgWebShell;
}
return rv;
}