This commit is contained in:
hyatt%netscape.com 1999-04-20 22:35:11 +00:00
Родитель 177bbc0c96
Коммит f0c29e969c
11 изменённых файлов: 173 добавлений и 58 удалений

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

@ -241,11 +241,11 @@ public:
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode);
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell);
nsIWebShell** aNewShell, nsIWebShell** anInnerShell);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
@ -1906,11 +1906,10 @@ nsWebShell::CanCreateNewWebShell(PRBool& aResult)
}
NS_IMETHODIMP
nsWebShell::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult)
nsWebShell::ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode)
{
aResult = PR_FALSE;
if (nsnull != mContainer) {
return mContainer->ChildShellAdded(aChildShell, frameNode, aResult);
return mContainer->ChildShellAdded(aChildShell, frameNode);
}
return NS_OK;
}
@ -1918,10 +1917,10 @@ nsWebShell::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRB
NS_IMETHODIMP
nsWebShell::SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell)
nsIWebShell** aNewShell, nsIWebShell** anInnerShell)
{
if (nsnull != mContainer) {
return mContainer->SetNewWebShellInfo(aName, anURL, aOpenerShell, aChromeMask, aNewShell);
return mContainer->SetNewWebShellInfo(aName, anURL, aOpenerShell, aChromeMask, aNewShell, anInnerShell);
}
return NS_OK;
}

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

@ -1476,7 +1476,8 @@ GlobalWindowImpl::Open(JSContext *cx,
nsIBrowserWindow *newWindow = nsnull;
nsIScriptGlobalObject *newGlobalObject = nsnull;
nsIWebShell *newWebShell = nsnull;
nsIWebShell *newOuterShell = nsnull;
nsIWebShell *newInnerShell = nsnull;
nsIWebShellContainer *webShellContainer, *newContainer;
/* XXX check for existing window of same name. If exists, set url and
@ -1484,8 +1485,8 @@ GlobalWindowImpl::Open(JSContext *cx,
PRBool couldCreate = PR_TRUE;
if (NS_OK == mWebShell->GetContainer(webShellContainer) && nsnull != webShellContainer) {
// Check for existing window of same name.
webShellContainer->FindWebShellWithName(name.GetUnicode(), newWebShell);
if (nsnull == newWebShell) {
webShellContainer->FindWebShellWithName(name.GetUnicode(), newOuterShell);
if (nsnull == newOuterShell) {
// The web shell container may wish to perform an asynchronous instantiation
// of the web shell and of the new container. Supply the container with
// sufficient information to perform the web shell linkage on its own,
@ -1494,7 +1495,7 @@ GlobalWindowImpl::Open(JSContext *cx,
if (couldCreate)
{
// No window of that name, and we are allowed to create a new one now.
webShellContainer->NewWebShell(mChrome, PR_FALSE, newWebShell);
webShellContainer->NewWebShell(mChrome, PR_FALSE, newOuterShell);
}
else
{
@ -1504,17 +1505,21 @@ GlobalWindowImpl::Open(JSContext *cx,
mAbsURL,
mWebShell,
mChrome,
&newWebShell);
&newOuterShell,
&newInnerShell);
}
}
if (nsnull != newWebShell) {
if (nsnull != newOuterShell) {
if (couldCreate) {
newWebShell->SetName(name.GetUnicode());
newWebShell->LoadURL(mAbsURL.GetUnicode());
newOuterShell->SetName(name.GetUnicode());
newOuterShell->LoadURL(mAbsURL.GetUnicode());
}
else {
newInnerShell->SetName(name.GetUnicode());
}
if (NS_OK == newWebShell->GetContainer(newContainer) && nsnull != newContainer) {
if (NS_OK == newOuterShell->GetContainer(newContainer) && nsnull != newContainer) {
newContainer->QueryInterface(kIBrowserWindowIID, (void**)&newWindow);
NS_RELEASE(newContainer);
}
@ -1522,9 +1527,9 @@ GlobalWindowImpl::Open(JSContext *cx,
NS_RELEASE(webShellContainer);
}
if (nsnull != newWindow && nsnull != newWebShell) {
if (nsnull != newWindow && nsnull != newOuterShell) {
// beard: don't resize/reposition the window if it is the same web shell.
if (newWebShell != mWebShell) {
if (newOuterShell != mWebShell) {
// How should we do default size/pos?
// How about inheriting from the current window?
newWindow->SizeTo(mWidth ? mWidth : mDefaultBounds.width, mHeight ? mHeight : mDefaultBounds.height);
@ -1535,17 +1540,23 @@ GlobalWindowImpl::Open(JSContext *cx,
/* Get win obj */
nsIScriptContextOwner *newContextOwner = nsnull;
if (NS_OK != newWebShell->QueryInterface(kIScriptContextOwnerIID, (void**)&newContextOwner) ||
nsIWebShell* returnShell = newOuterShell;
if (!couldCreate)
returnShell = newInnerShell;
if (NS_OK != returnShell->QueryInterface(kIScriptContextOwnerIID, (void**)&newContextOwner) ||
NS_OK != newContextOwner->GetScriptGlobalObject(&newGlobalObject)) {
NS_IF_RELEASE(newWindow);
NS_IF_RELEASE(newWebShell);
NS_IF_RELEASE(newInnerShell);
NS_IF_RELEASE(newOuterShell);
NS_IF_RELEASE(newContextOwner);
return NS_ERROR_FAILURE;
}
NS_RELEASE(newWindow);
NS_RELEASE(newWebShell);
NS_RELEASE(newInnerShell);
NS_RELEASE(newOuterShell);
NS_RELEASE(newContextOwner);
}
@ -1556,8 +1567,7 @@ GlobalWindowImpl::Open(JSContext *cx,
}
/* Set opener */
if (couldCreate)
newGlobalObject->SetOpenerWindow(this);
newGlobalObject->SetOpenerWindow(this);
}

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

@ -99,12 +99,12 @@ public:
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult) = 0;
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell) = 0;
nsIWebShell** aNewShell, nsIWebShell** anInnerShell) = 0;
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName,
nsIWebShell*& aResult) = 0;
NS_IMETHOD ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult) = 0;
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode) = 0;
/**
* Notify the WebShellContainer that a contained webshell is

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

@ -241,11 +241,11 @@ public:
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode);
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell);
nsIWebShell** aNewShell, nsIWebShell** anInnerShell);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
@ -1906,11 +1906,10 @@ nsWebShell::CanCreateNewWebShell(PRBool& aResult)
}
NS_IMETHODIMP
nsWebShell::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult)
nsWebShell::ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode)
{
aResult = PR_FALSE;
if (nsnull != mContainer) {
return mContainer->ChildShellAdded(aChildShell, frameNode, aResult);
return mContainer->ChildShellAdded(aChildShell, frameNode);
}
return NS_OK;
}
@ -1918,10 +1917,10 @@ nsWebShell::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRB
NS_IMETHODIMP
nsWebShell::SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell)
nsIWebShell** aNewShell, nsIWebShell** anInnerShell)
{
if (nsnull != mContainer) {
return mContainer->SetNewWebShellInfo(aName, anURL, aOpenerShell, aChromeMask, aNewShell);
return mContainer->SetNewWebShellInfo(aName, anURL, aOpenerShell, aChromeMask, aNewShell, anInnerShell);
}
return NS_OK;
}

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

@ -1750,9 +1750,8 @@ nsBrowserWindow::CanCreateNewWebShell(PRBool& aResult)
}
NS_IMETHODIMP
nsBrowserWindow::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult)
nsBrowserWindow::ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode)
{
aResult = PR_FALSE; // We don't ever care about handling this.
return NS_OK;
}
@ -1760,7 +1759,7 @@ nsBrowserWindow::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode
NS_IMETHODIMP
nsBrowserWindow::SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell)
nsIWebShell** aNewShell, nsIWebShell** anInnerShell)
{
return NS_OK; // We don't care about this method, since we can make new web shells immediately.
}

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

@ -107,10 +107,10 @@ public:
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode);
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell);
nsIWebShell** aNewShell, nsIWebShell** anInnerShell);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);

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

@ -569,16 +569,15 @@ nsXPBaseWindow::CanCreateNewWebShell(PRBool& aResult)
}
NS_IMETHODIMP
nsXPBaseWindow::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult)
nsXPBaseWindow::ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode)
{
aResult = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsXPBaseWindow::SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell)
nsIWebShell** aNewShell, nsIWebShell** anInnerShell)
{
return NS_OK; // We don't care about this method, since we can make new web shells immediately.
}

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

@ -98,10 +98,10 @@ public:
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode);
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell);
nsIWebShell** aNewShell, nsIWebShell** anInnerShell);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);

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

@ -26,6 +26,7 @@
/* Forward declarations.... */
class nsIWebShell;
class nsIWidget;
class nsString;
// Interface ID for nsIWebShellWindow
#define NS_IWEBSHELL_WINDOW_IID \
@ -41,6 +42,10 @@ public:
NS_IMETHOD Close() = 0;
NS_IMETHOD GetWebShell(nsIWebShell *& aWebShell) = 0;
NS_IMETHOD GetWidget(nsIWidget *& aWidget) = 0;
NS_IMETHOD AddWebShellInfo(const nsString& aID, const nsString& aName,
const nsString& aURL, nsIWebShell* aOpenerShell,
nsIWebShell* aChildShell) = 0;
};

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

@ -25,7 +25,10 @@
#include "nsIURL.h"
#include "nsIPref.h"
#include "nsINameSpaceManager.h"
#include "nsVoidArray.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMWindow.h"
#include "nsGUIEvent.h"
#include "nsWidgetsCID.h"
@ -139,18 +142,22 @@ struct nsWebShellInfo {
nsString name; // The name to apply to the webshell once we create it.
nsString url; // The URL to load in the webshell once we create it.
nsIWebShell* opener; // The web shell that will be the opener of this new shell.
nsIWebShell* child; // The child web shell that will end up being used for the content area.
nsWebShellInfo(const nsString& anID, const nsString aName, const nsString& anURL,
nsIWebShell* anOpenerShell)
nsIWebShell* anOpenerShell, nsIWebShell* aChildShell)
{
id = anID; name = aName; url = anURL;
opener = anOpenerShell;
NS_IF_ADDREF(anOpenerShell);
child = aChildShell;
NS_IF_ADDREF(aChildShell);
}
~nsWebShellInfo()
{
NS_IF_RELEASE(opener);
NS_IF_RELEASE(child);
}
};
@ -767,9 +774,91 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi
} // nsWebShellWindow::LoadMenus
NS_IMETHODIMP
nsWebShellWindow::ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult)
nsWebShellWindow::AddWebShellInfo(const nsString& aID, const nsString& aName,
const nsString& anURL, nsIWebShell* aOpenerShell,
nsIWebShell* aChildShell)
{
nsWebShellInfo* webShellInfo = new nsWebShellInfo(aID,
aName, anURL, aOpenerShell, aChildShell);
if (mContentShells == nsnull)
mContentShells = new nsVoidArray();
mContentShells->AppendElement((void*)webShellInfo);
return NS_OK;
}
NS_IMETHODIMP
nsWebShellWindow::ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow)
{
nsresult rv;
nsCOMPtr<nsIScriptContextOwner> newContextOwner;
nsCOMPtr<nsIScriptGlobalObject> newGlobalObject;
nsCOMPtr<nsIDOMWindow> newDOMWindow;
newContextOwner = do_QueryInterface(aShell);
if (newContextOwner)
{
if (NS_FAILED(rv = newContextOwner->GetScriptGlobalObject(getter_AddRefs(newGlobalObject)))) {
NS_ERROR("Unable to retrieve global object.");
return rv;
}
if (newGlobalObject) {
newDOMWindow = do_QueryInterface(newGlobalObject);
*aDOMWindow = newDOMWindow.get();
NS_ADDREF(*aDOMWindow);
}
else return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
nsWebShellWindow::ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode)
{
// Set to null just to be certain
*aChildShell = nsnull;
// If we don't have a content array, we just don't care.
if (mContentShells == nsnull)
return NS_OK;
// Find out if the frameNode in question is one that we have web shell info for.
nsIAtom* idAtom = NS_NewAtom("id");
nsIAtom* srcAtom = NS_NewAtom("src");
nsAutoString value;
frameNode->GetAttribute(kNameSpaceID_None, idAtom, value);
PRInt32 count = mContentShells->Count();
for (PRInt32 i = 0; i < count; i++)
{
nsWebShellInfo* webInfo = (nsWebShellInfo*)(mContentShells->ElementAt(i));
if (webInfo->id == value)
{
// We have a match!
// Alter the frame node's source using the nsIContent method (to ensure that
// the value isn't persistently stored).
frameNode->SetAttribute(kNameSpaceID_None, srcAtom, webInfo->url, PR_FALSE);
*aChildShell = webInfo->child;
NS_ADDREF(*aChildShell);
// Remove this object from our array.
mContentShells->RemoveElementAt(i);
delete webInfo;
return NS_OK;
}
}
NS_RELEASE(idAtom);
NS_RELEASE(srcAtom);
return NS_OK;
}
@ -794,7 +883,8 @@ nsWebShellWindow::CanCreateNewWebShell(PRBool& aResult)
NS_IMETHODIMP
nsWebShellWindow::SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 chrome,
nsIWebShell** aNewWebShellResult)
nsIWebShell** anOuterResult,
nsIWebShell** anInnerResult)
{
// Create a new browser window. That's what this method is here for.
nsresult rv;
@ -819,19 +909,26 @@ nsWebShellWindow::SetNewWebShellInfo(const nsString& aName, const nsString& anUR
nsnull, nsnull, 615, 480);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
// Now return our web shell.
NS_IF_ADDREF(mWebShell);
*aNewWebShellResult = mWebShell;
// Now return the new window's web shell.
newWindow->GetWebShell(*anOuterResult);
// Create a new dummy shell that we will eventually want to reuse (when we find the
// right place for it).
// Create web shell
nsIWebShell* dummyShell;
rv = nsComponentManager::CreateInstance(kWebShellCID, nsnull,
kIWebShellIID,
(void**)&dummyShell);
if (rv != NS_OK) {
return rv;
}
// Return this inner dummy shell. Set this shell's container to point to the outer shell.
*anInnerResult = dummyShell;
dummyShell->SetContainer(this);
// Cache our webshell info.
nsWebShellInfo* webShellInfo = new nsWebShellInfo("content_frame",
aName, anURL, aOpenerShell);
if (mContentShells == nsnull)
mContentShells = new nsVoidArray();
mContentShells->AppendElement((void*)webShellInfo);
newWindow->AddWebShellInfo("content-frame", aName, anURL, aOpenerShell, dummyShell);
return NS_OK;
}

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

@ -45,6 +45,7 @@ class nsIContent;
class nsIDocument;
class nsIDOMCharacterData;
class nsIDOMElement;
class nsIDOMWindow;
class nsIDOMHTMLImageElement;
class nsIDOMHTMLInputElement;
class nsIStreamObserver;
@ -84,16 +85,20 @@ public:
PRInt32 aStatus);
NS_IMETHOD ChildShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode, PRBool& aResult);
NS_IMETHOD ChildShellAdded(nsIWebShell** aChildShell, nsIContent* frameNode);
NS_IMETHOD NewWebShell(PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell);
NS_IMETHOD AddWebShellInfo(const nsString& aID, const nsString& aName,
const nsString& aURL, nsIWebShell* aOpenerShell,
nsIWebShell* aChildShell);
NS_IMETHOD CanCreateNewWebShell(PRBool& aResult);
NS_IMETHOD SetNewWebShellInfo(const nsString& aName, const nsString& anURL,
nsIWebShell* aOpenerShell, PRUint32 aChromeMask,
nsIWebShell** aNewShell);
nsIWebShell** aNewShell, nsIWebShell** anInnerShell);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName,
nsIWebShell*& aResult);
@ -204,6 +209,8 @@ public:
protected:
void ExecuteJavaScriptString(nsString& aJavaScript);
NS_IMETHOD ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindow** aDOMWindow);
PRInt32 GetDocHeight(nsIDocument * aDoc);
void LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow);