adding C XUL window construction callback
git-svn-id: svn://10.0.0.236/trunk@22029 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -65,14 +65,18 @@ public:
|
||||
NS_IMETHOD GetNativeEvent(void *& aEvent, nsIWidget* aWidget, PRBool &aIsInWindow, PRBool &aIsMouseEvent);
|
||||
NS_IMETHOD DispatchNativeEvent(void * aEvent);
|
||||
NS_IMETHOD Shutdown(void);
|
||||
NS_IMETHOD CreateTopLevelWindow(nsIURL* aUrl, nsString& aControllerIID,
|
||||
NS_IMETHOD CreateTopLevelWindow(nsIWidget * aParent,
|
||||
nsIURL* aUrl,
|
||||
nsString& aControllerIID,
|
||||
nsIWidget*& aResult, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
||||
NS_IMETHOD CreateDialogWindow( nsIWidget * aParent,
|
||||
nsIURL* aUrl,
|
||||
nsString& aControllerIID,
|
||||
nsIWidget*& aResult, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
||||
NS_IMETHOD CreateDialogWindow(nsIWidget * aParent,
|
||||
nsIURL* aUrl,
|
||||
nsString& aControllerIID,
|
||||
nsIWidget*& aResult, nsIStreamObserver* anObserver,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
||||
NS_IMETHOD CloseTopLevelWindow(nsIWidget* aWindow);
|
||||
NS_IMETHOD RegisterTopLevelWindow(nsIWidget* aWindow);
|
||||
NS_IMETHOD UnregisterTopLevelWindow(nsIWidget* aWindow);
|
||||
@@ -82,7 +86,6 @@ protected:
|
||||
virtual ~nsAppShellService();
|
||||
|
||||
nsIAppShell* mAppShell;
|
||||
|
||||
nsISupportsArray* mWindowList;
|
||||
};
|
||||
|
||||
@@ -197,14 +200,25 @@ nsAppShellService::Shutdown(void)
|
||||
/*
|
||||
* Create a new top level window and display the given URL within it...
|
||||
*
|
||||
* XXX:
|
||||
* Currently, the IID of the Controller object for the URL is provided as an
|
||||
* argument. In the future, this argument will be specified by the XUL document
|
||||
* itself.
|
||||
* @param aParent - parent for the window to be created (generally null;
|
||||
* included for compatibility with dialogs).
|
||||
* (currently unused).
|
||||
* @param aURL - location of XUL window contents description
|
||||
* @param aControllerIID - currently provided as an argument. in the future,
|
||||
* this will be specified by the XUL document itself.
|
||||
* (currently unused, but please specify the same
|
||||
* hardwired IID as others are using).
|
||||
* @param anObserver - a stream observer to give to the new window
|
||||
* @param aConstructionCallbacks - methods which will be called during
|
||||
* window construction. can be null.
|
||||
* @param aInitialWidth - width of window, in pixels (currently unused)
|
||||
* @param aInitialHeight - height of window, in pixels (currently unused)
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::CreateTopLevelWindow(nsIURL* aUrl, nsString& aControllerIID,
|
||||
nsAppShellService::CreateTopLevelWindow(nsIWidget *aParent,
|
||||
nsIURL* aUrl, nsString& aControllerIID,
|
||||
nsIWidget*& aResult, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
||||
{
|
||||
nsresult rv;
|
||||
@@ -214,7 +228,9 @@ nsAppShellService::CreateTopLevelWindow(nsIURL* aUrl, nsString& aControllerIID,
|
||||
if (nsnull == window) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
rv = window->Initialize(mAppShell, aUrl, aControllerIID, anObserver, aInitialWidth, aInitialHeight);
|
||||
rv = window->Initialize(aParent, mAppShell, aUrl, aControllerIID,
|
||||
anObserver, aCallbacks,
|
||||
aInitialWidth, aInitialHeight);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aResult = window->GetWidget();
|
||||
RegisterTopLevelWindow(aResult);
|
||||
@@ -240,17 +256,16 @@ nsAppShellService::CloseTopLevelWindow(nsIWidget* aWindow)
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a new top level window and display the given URL within it...
|
||||
*
|
||||
* XXX:
|
||||
* Currently, the IID of the Controller object for the URL is provided as an
|
||||
* argument. In the future, this argument will be specified by the XUL document
|
||||
* itself.
|
||||
* Like CreateTopLevelWindow, but with dialog window borders. This
|
||||
* method is necessary because of the current misfortune that the window
|
||||
* is created before its XUL description has been parsed, so the description
|
||||
* can't affect attributes like window type.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsAppShellService::CreateDialogWindow(nsIWidget * aParent,
|
||||
nsIURL* aUrl, nsString& aControllerIID,
|
||||
nsIWidget*& aResult, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
||||
{
|
||||
nsresult rv;
|
||||
@@ -260,11 +275,13 @@ nsAppShellService::CreateDialogWindow(nsIWidget * aParent,
|
||||
if (nsnull == window) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
rv = window->Initialize(nsnull, mAppShell, aUrl, aControllerIID, anObserver,
|
||||
rv = window->Initialize(aParent, mAppShell, aUrl, aControllerIID,
|
||||
anObserver, aCallbacks,
|
||||
aInitialWidth, aInitialHeight);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mWindowList->AppendElement((nsIWebShellContainer*)window);
|
||||
aResult = window->GetWidget();
|
||||
RegisterTopLevelWindow(aResult);
|
||||
window->Show(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,21 +303,11 @@ nsAppShellService::RegisterTopLevelWindow(nsIWidget* aWindow)
|
||||
if (data == nsnull)
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
else {
|
||||
#if 0
|
||||
nsWebShellWindow* window = (nsWebShellWindow *) data;
|
||||
nsIWebShellWindow * webShellWin;
|
||||
rv = window->QueryInterface(kIWebShellWindowIID, (void **) &webShellWin);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mWindowList->AppendElement(webShellWin);
|
||||
}
|
||||
#else
|
||||
nsWebShellWindow* window = (nsWebShellWindow *) data;
|
||||
// nsCOMPtr<nsIWebShellContainer> wsc(window); DRaM
|
||||
nsIWebShellContainer* wsc;
|
||||
rv = window->QueryInterface(kIWebShellContainerIID, (void **) &wsc);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mWindowList->AppendElement(wsc);
|
||||
#endif
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@@ -317,7 +324,6 @@ nsAppShellService::UnregisterTopLevelWindow(nsIWidget* aWindow)
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
else {
|
||||
nsWebShellWindow* window = (nsWebShellWindow *) data;
|
||||
// nsCOMPtr<nsIWebShellContainer> wsc(window); DRaM
|
||||
nsIWebShellContainer* wsc;
|
||||
rv = window->QueryInterface(kIWebShellContainerIID, (void **) &wsc);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIXULWindowCallbacks.h"
|
||||
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIWidgetController.h"
|
||||
@@ -109,6 +110,7 @@ nsWebShellWindow::nsWebShellWindow()
|
||||
mWebShell = nsnull;
|
||||
mWindow = nsnull;
|
||||
mController = nsnull;
|
||||
mCallbacks = nsnull;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +123,7 @@ nsWebShellWindow::~nsWebShellWindow()
|
||||
|
||||
NS_IF_RELEASE(mWindow);
|
||||
NS_IF_RELEASE(mController);
|
||||
NS_IF_RELEASE(mCallbacks);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,17 +162,10 @@ nsWebShellWindow::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
}
|
||||
|
||||
|
||||
nsresult nsWebShellWindow::Initialize(nsIAppShell* aShell, nsIURL* aUrl,
|
||||
nsString& aControllerIID, nsIStreamObserver* anObserver,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
||||
{
|
||||
return Initialize(nsnull, aShell, aUrl, aControllerIID, anObserver,
|
||||
aInitialWidth, aInitialHeight);
|
||||
}
|
||||
|
||||
nsresult nsWebShellWindow::Initialize(nsIWidget* aParent,
|
||||
nsIAppShell* aShell, nsIURL* aUrl,
|
||||
nsString& aControllerIID, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight)
|
||||
{
|
||||
nsresult rv;
|
||||
@@ -239,6 +235,10 @@ nsresult nsWebShellWindow::Initialize(nsIWidget* aParent,
|
||||
}
|
||||
/// webShell->SetPrefs(aPrefs);
|
||||
|
||||
NS_IF_RELEASE(mCallbacks);
|
||||
mCallbacks = aCallbacks;
|
||||
NS_IF_ADDREF(mCallbacks);
|
||||
|
||||
if (nsnull != aUrl) {
|
||||
mWebShell->LoadURL(urlString);
|
||||
}
|
||||
@@ -813,7 +813,7 @@ NS_IMETHODIMP nsWebShellWindow::OnConnectionsComplete()
|
||||
|
||||
|
||||
/**
|
||||
* Get nsIDOMElement corresponding to a given webshell
|
||||
* Get nsIDOMNode corresponding to a given webshell
|
||||
* @param aShell the given webshell
|
||||
* @return the corresponding DOM element, null if for some reason there is none
|
||||
*/
|
||||
@@ -874,20 +874,23 @@ void nsWebShellWindow::ExecuteJavaScriptString(nsString& aJavaScript)
|
||||
*/
|
||||
void nsWebShellWindow::ExecuteStartupCode()
|
||||
{
|
||||
// NS_PRECONDITION(aNode, "null argument to LoadCommandsInElement");
|
||||
|
||||
nsCOMPtr<nsIDOMNode> webshellNode = GetDOMNodeFromWebShell(mWebShell);
|
||||
if (!webshellNode)
|
||||
return;
|
||||
nsCOMPtr<nsIDOMElement> webshellElement;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> webshellElement(do_QueryInterface(webshellNode));
|
||||
if (!webshellElement)
|
||||
return;
|
||||
if (webshellNode)
|
||||
webshellElement = do_QueryInterface(webshellNode);
|
||||
|
||||
// Get the onConstruction attribute of the webshellElement.
|
||||
if (mCallbacks)
|
||||
mCallbacks->ConstructBeforeJavaScript(mWebShell);
|
||||
|
||||
// Execute the string in the onConstruction attribute of the webshellElement.
|
||||
nsString startupCode;
|
||||
if (NS_SUCCEEDED(webshellElement->GetAttribute("onConstruction", startupCode)))
|
||||
if (webshellElement && NS_SUCCEEDED(webshellElement->GetAttribute("onConstruction", startupCode)))
|
||||
ExecuteJavaScriptString(startupCode);
|
||||
|
||||
if (mCallbacks)
|
||||
mCallbacks->ConstructAfterJavaScript(mWebShell);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class nsIDOMHTMLImageElement;
|
||||
class nsIDOMElement;
|
||||
class nsIStreamObserver;
|
||||
class nsIDocument;
|
||||
class nsIXULWindowCallbacks;
|
||||
|
||||
class nsIContent;
|
||||
|
||||
@@ -93,9 +94,9 @@ public:
|
||||
NS_IMETHOD GetWidget(nsIWidget *& aWidget);
|
||||
|
||||
// nsWebShellWindow methods...
|
||||
nsresult Initialize(nsIAppShell* aShell, nsIURL* aUrl, nsString& aControllerIID, nsIStreamObserver* anObserver,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
||||
nsresult Initialize(nsIWidget * aParent, nsIAppShell* aShell, nsIURL* aUrl, nsString& aControllerIID, nsIStreamObserver* anObserver,
|
||||
nsresult Initialize(nsIWidget * aParent, nsIAppShell* aShell, nsIURL* aUrl,
|
||||
nsString& aControllerIID, nsIStreamObserver* anObserver,
|
||||
nsIXULWindowCallbacks *aCallbacks,
|
||||
PRInt32 aInitialWidth, PRInt32 aInitialHeight);
|
||||
nsIWidget* GetWidget(void) { return mWindow; }
|
||||
|
||||
@@ -177,6 +178,7 @@ protected:
|
||||
nsIWidget* mWindow;
|
||||
nsIWebShell* mWebShell;
|
||||
nsIWidgetController* mController;
|
||||
nsIXULWindowCallbacks* mCallbacks;
|
||||
|
||||
nsVoidArray mMenuDelegates;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user