Remove the long-deprecated nsIWebShell interface. Bug 273319, r=biesi, sr=jst.

git-svn-id: svn://10.0.0.236/trunk@167223 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2005-01-03 22:51:17 +00:00
parent e9dbf792c8
commit e272c87dda
72 changed files with 438 additions and 1126 deletions

View File

@@ -63,7 +63,6 @@ XPIDLSRCS = \
EXPORTS = \
nsILinkHandler.h \
nsIWebShell.h \
nsIWebShellServices.h \
$(NULL)

View File

@@ -1,116 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIWebShell_h___
#define nsIWebShell_h___
#include "nsIContentViewerContainer.h"
class nsIDocumentLoader;
class nsIURI;
// Interface ID for nsIWebShell
// e1c77239-eb80-42bb-8b94-54b49fe1b25b
#define NS_IWEB_SHELL_IID \
{ 0xe1c77239, 0xeb80, 0x42bb,{0x8b, 0x94, 0x54, 0xb4, 0x9f, 0xe1, 0xb2, 0x5b}}
// Interface ID for nsIWebShellContainer
#define NS_IWEB_SHELL_CONTAINER_IID \
{ 0xa6cf905a, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// Class ID for an implementation of nsIWebShell
#define NS_WEB_SHELL_CID \
{ 0xa6cf9059, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
//----------------------------------------------------------------------
typedef enum {
nsLoadURL,
nsLoadHistory,
nsLoadLink,
nsLoadRefresh
} nsLoadType;
// Container for web shell's
class nsIWebShellContainer : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_CONTAINER_IID)
};
//----------------------------------------------------------------------
/**
* The web shell is a container for implementations of nsIContentViewer.
* It is a content-viewer-container and also knows how to delegate certain
* behavior to an nsIWebShellContainer.
*
* Web shells can be arranged in a tree.
*
* Web shells are also nsIWebShellContainer's because they can contain
* other web shells.
*/
class nsIWebShell : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_IID)
/**
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING !!!!
*
* THIS INTERFACE IS DEPRECATED. DO NOT ADD STUFF OR CODE TO IT!!!!
*/
// XXXbz there is no need for this interface anymore... Callers can either
// just get the parent treeitem, or when they want the container of the root
// docshell can get the treeowner and GetInterface nsIXULWindow to get what
// GetContainer currently returns...
// XXXbz oh, and the Show() method on nsIWebShellWindow is just redundant
// with SetVisibility on nsIBaseWindow.... Mailnews uses this interface for
// that stuff, but it doesn't have to.
/**
* Set the nsIWebShellContainer for the WebShell.
*/
NS_IMETHOD SetContainer(nsIWebShellContainer* aContainer) = 0;
/**
* Return the current nsIWebShellContainer.
*/
NS_IMETHOD GetContainer(nsIWebShellContainer*& aResult) = 0;
};
#endif /* nsIWebShell_h___ */

View File

@@ -75,6 +75,7 @@
#include "nsIDocumentViewer.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerFile.h"
#include "nsIContentViewerContainer.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIDocument.h"
@@ -800,13 +801,6 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
case VIEW_SOURCE:
{
// PRInt32 theIndex;
// nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
// webShell->GetHistoryIndex(theIndex);
// nsXPIDLString theURL;
// webShell->GetURL(theIndex, getter_Copies(theURL));
// nsAutoString theString(theURL);
// mApp->ViewSource(theString);
//XXX Find out how the string is allocated, and perhaps delete it...
}
break;
@@ -1278,7 +1272,7 @@ nsBrowserWindow::~nsBrowserWindow()
}
}
NS_IMPL_ISUPPORTS4(nsBrowserWindow, nsIBaseWindow, nsIInterfaceRequestor, nsIProgressEventSink, nsIWebShellContainer)
NS_IMPL_ISUPPORTS3(nsBrowserWindow, nsIBaseWindow, nsIInterfaceRequestor, nsIProgressEventSink)
nsresult
nsBrowserWindow::GetInterface(const nsIID& aIID,
@@ -1352,8 +1346,6 @@ nsBrowserWindow::Init(nsIAppShell* aAppShell,
mDocShell = do_GetInterface(mWebBrowser);
mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->SetContainer((nsIWebShellContainer*) this);
webBrowserWin->SetVisibility(PR_TRUE);
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
@@ -1424,8 +1416,6 @@ nsnull, r.x, r.y, r.width, r.height);
webBrowserWin->Create();
mDocShell = do_GetInterface(mWebBrowser);
mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->SetContainer((nsIWebShellContainer*) this);
webBrowserWin->SetVisibility(PR_TRUE);
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
rv = CreateMenuBar(r.width);
@@ -1837,20 +1827,16 @@ nsBrowserWindow::GetChrome(PRUint32& aChromeMaskResult)
}
NS_IMETHODIMP
nsBrowserWindow::GetWebShell(nsIWebShell*& aResult)
nsBrowserWindow::GetDocShell(nsIDocShell*& aResult)
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
aResult = webShell;
NS_IF_ADDREF(aResult);
NS_IF_ADDREF(aResult = mDocShell);
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::GetContentWebShell(nsIWebShell **aResult)
nsBrowserWindow::GetContentDocShell(nsIDocShell **aResult)
{
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
*aResult = webShell;
NS_IF_ADDREF(*aResult);
NS_IF_ADDREF(*aResult = mDocShell);
return NS_OK;
}
@@ -1867,133 +1853,6 @@ nsBrowserWindow::ShowMenuBar(PRBool aShow)
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL,
nsLoadType aReason)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::ProgressLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
PRInt32 aProgress,
PRInt32 aProgressMax)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::EndLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsresult aStatus)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell*& aNewWebShell)
{
nsresult rv = NS_OK;
if (mWebCrawler) {
if (mWebCrawler->Crawling() || mWebCrawler->LoadingURLList()) {
// Do not fly javascript popups when we are crawling
aNewWebShell = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
}
// Create new window. By default, the refcnt will be 1 because of
// the registration of the browser window in gBrowsers.
nsNativeBrowserWindow* browser;
NS_NEWXPCOM(browser, nsNativeBrowserWindow);
if (nsnull != browser)
{
nsRect bounds;
GetContentBounds(bounds);
browser->SetApp(mApp);
// Assume no controls for now
rv = browser->Init(mAppShell, bounds, aChromeMask, mAllowPlugins);
if (NS_OK == rv)
{
// Default is to startup hidden
if (aVisible) {
browser->SetVisibility(PR_TRUE);
}
nsIWebShell *shell;
rv = browser->GetWebShell(shell);
aNewWebShell = shell;
}
else
{
browser->Destroy();
}
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
NS_IMETHODIMP
nsBrowserWindow::ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode)
{
return NS_OK;
}
NS_IMETHODIMP
nsBrowserWindow::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult)
{
PRInt32 i, n = gBrowsers ? gBrowsers->Count() : 0;
aResult = nsnull;
nsString aNameStr(aName);
for (i = 0; i < n; i++) {
nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers->ElementAt(i);
nsCOMPtr<nsIWebShell> webShell;
if (NS_OK == bw->GetWebShell(*getter_AddRefs(webShell))) {
nsXPIDLString name;
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
if (NS_OK == docShellAsItem->GetName(getter_Copies(name))) {
if (aNameStr.Equals(name)) {
aResult = webShell;
NS_ADDREF(aResult);
return NS_OK;
}
}
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(mDocShell));
nsCOMPtr<nsIDocShellTreeItem> result;
if (NS_OK == docShellAsNode->FindChildWithName(aName, PR_TRUE, PR_FALSE, nsnull,
getter_AddRefs(result))) {
if (result) {
CallQueryInterface(result, &aResult);
return NS_OK;
}
}
}
}
return NS_OK;
}
//----------------------------------------
NS_IMETHODIMP

View File

@@ -53,7 +53,6 @@
#include "nsIWebBrowser.h"
#include "nsIStreamListener.h"
#include "nsIProgressEventSink.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsString.h"
#include "nsVoidArray.h"
@@ -87,8 +86,7 @@ class nsIContent;
*/
class nsBrowserWindow : public nsIBaseWindow,
public nsIInterfaceRequestor,
public nsIProgressEventSink,
public nsIWebShellContainer
public nsIProgressEventSink
{
friend class nsWebBrowserChrome;
@@ -124,23 +122,12 @@ public:
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
NS_IMETHOD SetProgress(PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD ShowMenuBar(PRBool aShow);
NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
NS_IMETHOD GetDocShell(nsIDocShell*& aResult);
NS_IMETHOD GetContentDocShell(nsIDocShell **aResult);
// nsIProgressEventSink
NS_DECL_NSIPROGRESSEVENTSINK
// nsIWebShellContainer
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsresult aStatus);
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
// nsBrowserWindow
void SetWebCrawler(nsWebCrawler* aWebCrawler);
virtual nsresult CreateMenuBar(PRInt32 aWidth) = 0;

View File

@@ -46,7 +46,6 @@
#include "nsCOMPtr.h"
#include "nsWebCrawler.h"
#include "nsViewerApp.h"
#include "nsIWebShell.h"
#include "nsIContentViewer.h"
#include "nsIDocumentViewer.h"
#include "nsIDocument.h"
@@ -235,18 +234,17 @@ void
nsWebCrawler::DumpRegressionData()
{
#ifdef NS_DEBUG
nsCOMPtr<nsIWebShell> webshell;
mBrowser->GetWebShell(*getter_AddRefs(webshell));
if (! webshell)
nsCOMPtr<nsIDocShell> docshell;
mBrowser->GetDocShell(*getter_AddRefs(docshell));
if (! docshell)
return;
if (mOutputDir.Length() > 0) {
nsIPresShell* shell = GetPresShell(webshell);
nsCOMPtr<nsIPresShell> shell = GetPresShell(docshell);
if (!shell) return;
if ( mPrinterTestType > 0 ) {
nsCOMPtr <nsIContentViewer> viewer;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webshell));
docShell->GetContentViewer(getter_AddRefs(viewer));
docshell->GetContentViewer(getter_AddRefs(viewer));
if (viewer){
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
@@ -321,7 +319,6 @@ nsWebCrawler::DumpRegressionData()
}
}
}
NS_RELEASE(shell);
}
#endif
}
@@ -334,11 +331,10 @@ nsWebCrawler::LoadNextURLCallback(nsITimer *aTimer, void *aClosure)
// if we are doing printing regression tests, check to see
// if we can print (a previous job is not printing)
if (self->mPrinterTestType > 0) {
nsCOMPtr<nsIWebShell> webshell;
self->mBrowser->GetWebShell(*getter_AddRefs(webshell));
if (webshell){
nsCOMPtr<nsIDocShell> docShell;
self->mBrowser->GetDocShell(*getter_AddRefs(docShell));
if (docShell){
nsCOMPtr <nsIContentViewer> viewer;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webshell));
docShell->GetContentViewer(getter_AddRefs(viewer));
if (viewer){
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
@@ -377,9 +373,8 @@ nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress,
{
// Make sure that we're being notified for _our_ shell, and not some
// subshell that's been created e.g. for an IFRAME.
nsCOMPtr<nsIWebShell> shell;
mBrowser->GetWebShell(*getter_AddRefs(shell));
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(shell);
nsCOMPtr<nsIDocShell> docShell;
mBrowser->GetDocShell(*getter_AddRefs(docShell));
if (docShell) {
nsCOMPtr<nsIWebProgress> progress = do_GetInterface(docShell);
if (aWebProgress != progress)
@@ -433,7 +428,7 @@ nsWebCrawler::OnStateChange(nsIWebProgress* aWebProgress,
printf("+++ %s: done loading (%lld msec)\n", spec.get(), delta);
// Make sure the document bits make it to the screen at least once
nsCOMPtr<nsIPresShell> shell = dont_AddRef(GetPresShell());
nsCOMPtr<nsIPresShell> shell = GetPresShell();
if (shell) {
// Force the presentation shell to update the display
shell->FlushPendingNotifications(Flush_Display);
@@ -614,9 +609,8 @@ void
nsWebCrawler::Start()
{
// Enable observing each URL load...
nsCOMPtr<nsIWebShell> shell;
mBrowser->GetWebShell(*getter_AddRefs(shell));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(shell));
nsCOMPtr<nsIDocShell> docShell;
mBrowser->GetDocShell(*getter_AddRefs(docShell));
if (docShell) {
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(docShell));
if (progress) {
@@ -812,10 +806,9 @@ nsWebCrawler::FindURLsIn(nsIDocument* aDocument, nsIContent* aNode)
void
nsWebCrawler::FindMoreURLs()
{
nsCOMPtr<nsIWebShell> shell;
mBrowser->GetWebShell(*getter_AddRefs(shell));
nsCOMPtr<nsIDocShell> docShell;
mBrowser->GetDocShell(*getter_AddRefs(docShell));
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(shell));
if (docShell) {
nsCOMPtr<nsIContentViewer> cv;
docShell->GetContentViewer(getter_AddRefs(cv));
@@ -860,8 +853,6 @@ nsWebCrawler::LoadNextURL(PRBool aQueueLoad)
if (nsnull != url) {
if (OkToLoad(*url)) {
RecordLoadedURL(*url);
nsIWebShell* webShell;
mBrowser->GetWebShell(webShell);
if (aQueueLoad) {
// Call stop to cancel any pending URL Refreshes...
/// webShell->Stop();
@@ -870,10 +861,11 @@ nsWebCrawler::LoadNextURL(PRBool aQueueLoad)
else {
mCurrentURL = *url;
mStartLoad = PR_Now();
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(webShell));
nsCOMPtr<nsIDocShell> docShell;
mBrowser->GetDocShell(*getter_AddRefs(docShell));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
webNav->LoadURI(url->get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
}
NS_RELEASE(webShell);
if (mMaxPages > 0) {
--mMaxPages;
@@ -893,35 +885,16 @@ nsWebCrawler::LoadNextURL(PRBool aQueueLoad)
}
nsIPresShell*
nsWebCrawler::GetPresShell(nsIWebShell* aWebShell)
already_AddRefed<nsIPresShell>
nsWebCrawler::GetPresShell(nsIDocShell* aDocShell)
{
nsIWebShell* webShell = aWebShell;
if (webShell) {
NS_ADDREF(webShell);
}
else {
mBrowser->GetWebShell(webShell);
}
nsIPresShell* shell = nsnull;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webShell));
if (nsnull != webShell) {
nsIContentViewer* cv = nsnull;
docShell->GetContentViewer(&cv);
if (nsnull != cv) {
nsIDocumentViewer* docv = nsnull;
cv->QueryInterface(NS_GET_IID(nsIDocumentViewer), (void**) &docv);
if (nsnull != docv) {
nsCOMPtr<nsPresContext> cx;
docv->GetPresContext(getter_AddRefs(cx));
if (nsnull != cx) {
NS_IF_ADDREF(shell = cx->GetPresShell());
}
NS_RELEASE(docv);
}
NS_RELEASE(cv);
}
NS_RELEASE(webShell);
nsCOMPtr<nsIDocShell> docShell(aDocShell);
if (!docShell) {
mBrowser->GetDocShell(*getter_AddRefs(docShell));
}
if (docShell) {
docShell->GetPresShell(&shell);
}
return shell;
}
@@ -1103,14 +1076,13 @@ LoadEvent::DeleteMe(LoadEvent* e)
void
nsWebCrawler::GoToQueuedURL(const nsString& aURL)
{
nsIWebShell* webShell;
mBrowser->GetWebShell(webShell);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(webShell));
nsCOMPtr<nsIDocShell> docShell;
mBrowser->GetDocShell(*getter_AddRefs(docShell));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
if (webNav) {
mCurrentURL = aURL;
mStartLoad = PR_Now();
webNav->LoadURI(aURL.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
NS_RELEASE(webShell);
}
mQueuedLoadURLs--;

View File

@@ -165,7 +165,7 @@ protected:
/** generate an output name from a URL */
FILE* GetOutputFile(nsIURI *aURL, nsString& aOutputName);
nsIPresShell* GetPresShell(nsIWebShell* aWebShell = nsnull);
already_AddRefed<nsIPresShell> GetPresShell(nsIDocShell* aDocShell = nsnull);
void PerformRegressionTest(const nsString& aOutputName);

View File

@@ -80,15 +80,12 @@
//#include "nsUnitConversion.h"
//#include "nsIDeviceContext.h"
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
@@ -132,11 +129,6 @@ nsresult nsXPBaseWindow::QueryInterface(const nsIID& aIID,
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIWebShellContainerIID)) {
*aInstancePtrResult = (void*) ((nsIWebShellContainer*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDOMMouseListenerIID)) {
NS_ADDREF_THIS(); // Increase reference count for caller
*aInstancePtrResult = (void *)((nsIDOMMouseListener*)this);
@@ -222,18 +214,16 @@ nsresult nsXPBaseWindow::Init(nsXPBaseWindowType aType,
mWindow->GetBounds(r);
// Create web shell
rv = CallCreateInstance(kWebShellCID, &mWebShell);
rv = CallCreateInstance("@mozilla.org/webshell;1", &mDocShell);
if (NS_FAILED(rv)) {
return rv;
}
r.x = r.y = 0;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
docShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mWebShell));
mDocShell->SetAllowPlugins(aAllowPlugins);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
rv = docShellWin->InitWindow(nsnull, mWindow, r.x, r.y, r.width, r.height);
docShellWin->Create();
mWebShell->SetContainer((nsIWebShellContainer*) this);
docShellWin->SetVisibility(PR_TRUE);
// Now lay it all out
@@ -270,8 +260,8 @@ void nsXPBaseWindow::ForceRefresh()
void nsXPBaseWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
{
nsRect rr(0, 0, aWidth, aHeight);
nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mWebShell));
webShellWin->SetPositionAndSize(rr.x, rr.y, rr.width, rr.height, PR_FALSE);
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->SetPositionAndSize(rr.x, rr.y, rr.width, rr.height, PR_FALSE);
}
//----------------------------------------------------------------------
@@ -326,10 +316,10 @@ NS_IMETHODIMP nsXPBaseWindow::Close()
mWindowListener->Destroy(this);
}
if (nsnull != mWebShell) {
nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mWebShell));
if (mDocShell) {
nsCOMPtr<nsIBaseWindow> webShellWin(do_QueryInterface(mDocShell));
webShellWin->Destroy();
NS_RELEASE(mWebShell);
NS_RELEASE(mDocShell);
}
if (nsnull != mWindow) {
@@ -342,10 +332,9 @@ NS_IMETHODIMP nsXPBaseWindow::Close()
//----------------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::GetWebShell(nsIWebShell*& aResult)
NS_IMETHODIMP nsXPBaseWindow::GetDocShell(nsIDocShell*& aResult)
{
aResult = mWebShell;
NS_IF_ADDREF(mWebShell);
NS_IF_ADDREF(aResult = mDocShell);
return NS_OK;
}
@@ -369,92 +358,11 @@ NS_IMETHODIMP nsXPBaseWindow::GetTitle(const PRUnichar** aResult)
//---------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::LoadURL(const nsString& aURL)
{
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebShell));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
webNav->LoadURI(aURL.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
return NS_OK;
}
//---------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
{
return NS_OK;
}
//-----------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
return NS_OK;
}
//-----------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
return NS_OK;
}
//-----------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsresult aStatus)
{
// Find the Root Conent Node for this Window
nsIPresShell* shell;
GetPresShell(shell);
if (nsnull != shell) {
nsIDocument *doc = shell->GetDocument();
if (doc) {
NS_IF_ADDREF(mContentRoot = doc->GetRootContent());
mDocIsLoaded = PR_TRUE;
if (nsnull != mWindowListener) {
mWindowListener->Initialize(this);
}
}
NS_RELEASE(shell);
}
return NS_OK;
}
//-----------------------------------------------------------------
NS_IMETHODIMP
nsXPBaseWindow::FindWebShellWithName(const PRUnichar* aName,
nsIWebShell*& aResult)
{
aResult = nsnull;
nsString aNameStr(aName);
nsCOMPtr<nsIWebShell> webShell;
GetWebShell(*getter_AddRefs(webShell));
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(webShell));
if (webShell) {
nsXPIDLString name;
if (NS_SUCCEEDED(docShellAsItem->GetName(getter_Copies(name)))) {
if (aNameStr.Equals(name)) {
aResult = webShell;
NS_ADDREF(aResult);
return NS_OK;
}
}
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(webShell));
nsCOMPtr<nsIDocShellTreeItem> result;
if (NS_OK == docShellAsNode->FindChildWithName(aName, PR_TRUE, PR_FALSE,
nsnull, getter_AddRefs(result))) {
if (result) {
CallQueryInterface(result, &aResult);
return NS_OK;
}
}
}
return NS_OK;
}
NS_IMETHODIMP nsXPBaseWindow::FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken)
{
return NS_OK;
}
//-----------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::AddEventListener(nsIDOMNode * aNode)
{
@@ -518,56 +426,15 @@ NS_IMETHODIMP nsXPBaseWindow::GetDocument(nsIDOMHTMLDocument *& aDocument)
return NS_OK;
}
//-----------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell*& aNewWebShell)
{
nsresult rv = NS_OK;
// Create new window. By default, the refcnt will be 1 because of
// the registration of the browser window in gBrowsers.
nsXPBaseWindow* dialogWindow;
NS_NEWXPCOM(dialogWindow, nsXPBaseWindow);
if (nsnull != dialogWindow) {
nsRect bounds;
GetBounds(bounds);
rv = dialogWindow->Init(mWindowType, mAppShell, mDialogURL, mTitle, bounds, aChromeMask, mAllowPlugins);
if (NS_OK == rv) {
if (aVisible) {
dialogWindow->SetVisible(PR_TRUE);
}
nsIWebShell *shell;
rv = dialogWindow->GetWebShell(shell);
aNewWebShell = shell;
} else {
dialogWindow->Close();
}
} else {
rv = NS_ERROR_OUT_OF_MEMORY;
}
return rv;
}
NS_IMETHODIMP
nsXPBaseWindow::ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode)
{
return NS_OK;
}
//----------------------------------------------------------------------
NS_IMETHODIMP nsXPBaseWindow::GetPresShell(nsIPresShell*& aPresShell)
{
aPresShell = nsnull;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mWebShell));
if (docShell) {
if (mDocShell) {
nsIContentViewer* cv = nsnull;
docShell->GetContentViewer(&cv);
mDocShell->GetContentViewer(&cv);
if (nsnull != cv) {
nsIDocumentViewer* docv = nsnull;
cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);

View File

@@ -39,7 +39,6 @@
#include "nsIXPBaseWindow.h"
#include "nsIStreamListener.h"
#include "nsIWebShell.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsCRT.h"
@@ -57,7 +56,6 @@ class nsIPresShell;
*
*/
class nsXPBaseWindow : public nsIXPBaseWindow,
public nsIWebShellContainer,
public nsIDOMMouseListener
{
public:
@@ -88,25 +86,13 @@ public:
NS_IMETHOD Close();
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
NS_IMETHOD GetTitle(const PRUnichar** aResult);
NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
NS_IMETHOD GetDocShell(nsIDocShell*& aResult);
NS_IMETHOD GetPresShell(nsIPresShell*& aPresShell);
//NS_IMETHOD HandleEvent(nsGUIEvent * anEvent);
NS_IMETHOD LoadURL(const nsString &aURL);
// nsIWebShellContainer
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsresult aStatus);
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
void Layout(PRInt32 aWidth, PRInt32 aHeight);
void ForceRefresh();
@@ -147,7 +133,7 @@ protected:
nsString mDialogURL;
nsIWidget* mWindow;
nsIWebShell* mWebShell;
nsIDocShell* mDocShell;
nsIWindowListener * mWindowListener; // XXX Someday this will be a list
PRBool mDocIsLoaded;

View File

@@ -41,7 +41,7 @@
class nsIAppShell;
class nsIFactory;
class nsIWebShell;
class nsIDocShell;
class nsString;
class nsIPresShell;
class nsIDOMElement;
@@ -136,7 +136,7 @@ public:
NS_IMETHOD GetTitle(const PRUnichar** aResult) = 0;
NS_IMETHOD GetWebShell(nsIWebShell*& aResult) = 0;
NS_IMETHOD GetDocShell(nsIDocShell*& aResult) = 0;
NS_IMETHOD LoadURL(const nsString &aURL) = 0;