зеркало из https://github.com/mozilla/gecko-dev.git
hooking up windowwatcher. bug 65229 code=ccarlen,me. r=brendan
This commit is contained in:
Родитель
ca8d7c678f
Коммит
4225baf682
|
@ -193,6 +193,7 @@ CBrowserApp::CBrowserApp()
|
|||
|
||||
rv = NS_InitEmbedding(appDir, fileLocProvider);
|
||||
|
||||
InitializeWindowCreator();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIDOMHTMLLinkElement.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#include "CBrowserWindow.h"
|
||||
#include "CBrowserShell.h"
|
||||
|
@ -531,6 +533,17 @@ NS_METHOD CBrowserWindow::GetWidget(nsIWidget** aWidget)
|
|||
}
|
||||
|
||||
|
||||
NS_METHOD CBrowserWindow::GetIWebBrowserChrome(nsIWebBrowserChrome **aChrome)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aChrome);
|
||||
|
||||
*aChrome = static_cast<nsIWebBrowserChrome *> (mBrowserChrome);
|
||||
NS_IF_ADDREF(*aChrome);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD CBrowserWindow::SizeToContent()
|
||||
{
|
||||
nsCOMPtr<nsIContentViewer> aContentViewer;
|
||||
|
@ -747,3 +760,73 @@ NS_METHOD CBrowserWindow::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Window Creator
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class CWindowCreator : public nsIWindowCreator
|
||||
{
|
||||
public:
|
||||
CWindowCreator();
|
||||
virtual ~CWindowCreator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWCREATOR
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(CWindowCreator, nsIWindowCreator);
|
||||
|
||||
CWindowCreator::CWindowCreator()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
CWindowCreator::~CWindowCreator()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CWindowCreator::CreateChromeWindow(nsIWebBrowserChrome *aParent,
|
||||
PRUint32 aChromeFlags,
|
||||
nsIWebBrowserChrome **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = 0;
|
||||
|
||||
CBrowserWindow *theWindow;
|
||||
|
||||
// we're ignoring aParent,
|
||||
// but since windows on the Mac don't have parents anyway...
|
||||
try {
|
||||
theWindow = CBrowserWindow::CreateWindow(aChromeFlags, -1, -1);
|
||||
theWindow->SetSizeToContent(false);
|
||||
theWindow->Show();
|
||||
theWindow->GetIWebBrowserChrome(_retval);
|
||||
} catch(...) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
InitializeWindowCreator creates and hands off an object with a callback
|
||||
to a window creation function. This will be used by Gecko C++ code
|
||||
(never JS) to create new windows when no previous window is handy
|
||||
to begin with. This is done in a few exceptional cases, like PSM code.
|
||||
Failure to set this callback will only disable the ability to create
|
||||
new windows under these circumstances.
|
||||
*/
|
||||
|
||||
nsresult InitializeWindowCreator()
|
||||
{
|
||||
// Create a CWindowCreator and give it to the WindowWatcher service
|
||||
// The WindowWatcher service will own it so we don't keep a ref.
|
||||
CWindowCreator *windowCreator = new CWindowCreator;
|
||||
if (!windowCreator) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!wwatch) return NS_ERROR_FAILURE;
|
||||
return wwatch->SetWindowCreator(windowCreator);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
typedef LWindow Inherited;
|
||||
|
||||
friend class CWebBrowserChrome;
|
||||
friend class CWindowCreator;
|
||||
|
||||
public:
|
||||
enum { class_ID = FOUR_CHAR_CODE('BroW') };
|
||||
|
@ -150,7 +151,9 @@ protected:
|
|||
NS_METHOD SetVisibility(PRBool aVisibility);
|
||||
|
||||
NS_METHOD OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode);
|
||||
|
||||
|
||||
NS_METHOD GetIWebBrowserChrome(nsIWebBrowserChrome **aChrome);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWidget> mWindow;
|
||||
|
||||
|
@ -169,4 +172,10 @@ protected:
|
|||
nsIDOMNode* mContextMenuDOMNode; // weak ref - only kept during call of OnShowContextMenu
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Global Functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Must be called at initialization time - after NS_InitEmbedding
|
||||
nsresult InitializeWindowCreator();
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIWalletService.h"
|
||||
|
||||
#include "UMacUnicode.h"
|
||||
|
@ -146,8 +147,17 @@ NS_IMETHODIMP CWebBrowserChrome::GetInterface(const nsIID &aIID, void** aInstanc
|
|||
NS_ENSURE_TRUE(mPrompter, NS_ERROR_FAILURE);
|
||||
return mPrompter->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
else
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMWindow)))
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowser> browser;
|
||||
GetWebBrowser(getter_AddRefs(browser));
|
||||
if (browser)
|
||||
return browser->GetContentDOMWindow((nsIDOMWindow **) aInstancePtr);
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -207,6 +217,13 @@ NS_IMETHODIMP CWebBrowserChrome::CreateBrowserWindow(PRUint32 chromeMask, PRInt3
|
|||
{
|
||||
// CreateWindow can throw an we're being called from mozilla, so we need to catch
|
||||
theWindow = CBrowserWindow::CreateWindow(chromeMask, aCX, aCY);
|
||||
|
||||
// HACK Alert: Because nsIWebBrowserSiteWindow does not have a visibility attribute,
|
||||
// our window will never be told to show itself. If we want it ever to show, we have
|
||||
// to do it here. Once <http://bugzilla.mozilla.org/show_bug.cgi?id=68581> is fixed,
|
||||
// remove this.
|
||||
|
||||
theWindow->SetVisibility(PR_TRUE);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче