adding ability to WindowWatcher to open windows without parents. bug 67368 r=hyatt,pinkerton
git-svn-id: svn://10.0.0.236/trunk@87263 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
c22f5b073f
commit
fac88bc14a
@ -25,6 +25,7 @@ VPATH = @srcdir@
|
||||
|
||||
MODULE = embed_base
|
||||
LIBRARY_NAME = embed_base_s
|
||||
XPIDL_MODULE = embed_base
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
@ -34,6 +35,9 @@ EXPORTS = \
|
||||
nsEmbedAPI.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = nsIWindowCreator.idl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsSetupRegistry.cpp \
|
||||
nsEmbedAPI.cpp \
|
||||
|
||||
@ -31,6 +31,10 @@ XPIDLSRCS= \
|
||||
|
||||
LIBRARY_NAME=baseembed_s
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIWindowCreator.idl \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsEmbedAPI.obj \
|
||||
.\$(OBJDIR)\nsEmbedWin32.obj \
|
||||
|
||||
@ -26,7 +26,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
MODULE = embedcomponents
|
||||
LIBRARY_NAME = embedcomponents
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = xpcom windowwatcher
|
||||
REQUIRES = js xpcom windowwatcher
|
||||
|
||||
CPPSRCS = nsModule.cpp
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ CPP_OBJS = \
|
||||
|
||||
LLIBS = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\windowwatcher_s.lib \
|
||||
$(NULL)
|
||||
|
||||
@ -21,8 +21,8 @@
|
||||
|
||||
/*
|
||||
nsIWindowWatcher is the keeper of Gecko/DOM Windows. It maintains
|
||||
opens and closes windows, and maintains a traversable list of open
|
||||
windows.
|
||||
maintains a traversable list of open top-level windows, and allows
|
||||
some operations on them.
|
||||
|
||||
Usage notes:
|
||||
|
||||
@ -37,9 +37,8 @@ interface for doing so).
|
||||
claim no ownership. Since it's the nature of this service to always
|
||||
hold a ("weak") reference to an open window, this requirement removes
|
||||
a potential reference loop. It should be safe because it's a
|
||||
design requirement that clients explicitly maintain |activeWindow| and
|
||||
|currentWindow|, and that windows remove themselves from the service
|
||||
when they are closed.
|
||||
design requirement that clients explicitly maintain |activeWindow|,
|
||||
and that windows remove themselves from the service when they are closed.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
@ -47,36 +46,10 @@ when they are closed.
|
||||
interface nsIDOMWindow;
|
||||
interface nsIObserver;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIWindowCreator;
|
||||
|
||||
[scriptable, uuid(002286a8-494b-43b3-8ddd-49e3fc50622b)]
|
||||
|
||||
/*
|
||||
Subject to change without revision of CID until further notice.
|
||||
|
||||
Assumptions:
|
||||
|
||||
For now I'm assuming we'll use this component to track the current
|
||||
"networking context." That is, the window currently being serviced by
|
||||
the network libraries, and therefore the proper parent of any alerts
|
||||
those libraries may need to pose. I'm not yet convinced that this will
|
||||
actually work or be necessary.
|
||||
The "networking context" must provide two things: an nsIDOMWindow
|
||||
to provide a script context and a native window to act as a parent
|
||||
for a networking dialog. This implies the nsIDOMWindow will be able
|
||||
to walk up some chain to find its container native embedding window.
|
||||
In fact, I believe I can always pull a JS context off that stack
|
||||
of the things that people keep around when they're switching back and forth
|
||||
between C++ and JS, so all I really need to create a window is a (native)
|
||||
parent.
|
||||
All windows must inform the Watcher when they're being closed (perhaps
|
||||
automatically through the DOMWindow's destructor), so the Watcher can
|
||||
trust all its windows to be real, so there's no need for the Watcher to
|
||||
addref any of its windows. This means, for instance, that setCurrentContext
|
||||
won't cause a leak if you don't unset it. It would be an error to fail
|
||||
to set the current context before getting into a situation where one
|
||||
might be necessary.
|
||||
*/
|
||||
|
||||
interface nsIWindowWatcher : nsISupports {
|
||||
|
||||
/** Create a new window. It will automatically be added to our list
|
||||
@ -87,8 +60,8 @@ interface nsIWindowWatcher : nsISupports {
|
||||
@param aFeatures window features from JS window.open
|
||||
@return the new window
|
||||
*/
|
||||
nsIDOMWindow openWindow(in nsIDOMWindow aParent, in string aUrl,
|
||||
in string aName, in string aFeatures);
|
||||
nsIDOMWindow openWindow(in nsIDOMWindow aParent, in wstring aUrl,
|
||||
in wstring aName, in wstring aFeatures);
|
||||
|
||||
/** Clients of this service can register themselves to be notified
|
||||
when a window is opened or closed (added to or removed from this
|
||||
@ -114,14 +87,22 @@ interface nsIWindowWatcher : nsISupports {
|
||||
*/
|
||||
void unregisterNotification(in nsIObserver aObserver);
|
||||
|
||||
/** iterates over currently open windows in the order they were opened,
|
||||
/** Get an iterator for currently open windows in the order they were opened,
|
||||
guaranteeing that each will be visited exactly once.
|
||||
@return an enumerator which will itself return an nsISupports which
|
||||
@return an enumerator which will itself return nsISupports objects which
|
||||
can be QIed to an nsIDOMWindow
|
||||
*/
|
||||
|
||||
nsISimpleEnumerator getWindowEnumerator();
|
||||
|
||||
/** Set the window creator callback. It must be filled in by the app.
|
||||
openWindow will use it to create new windows.
|
||||
@param creator the callback. if null, the callback will be cleared
|
||||
and window creation capabilities lost.
|
||||
*/
|
||||
void setWindowCreator(in nsIWindowCreator creator);
|
||||
|
||||
|
||||
/** The Watcher serves as a global storage facility for the current active
|
||||
(frontmost non-floating-palette-type) window, storing and returning
|
||||
it on demand. Users must keep this attribute current, including after
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
interface nsIDOMWindow;
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
[ptr] native jsvalptr(jsval);
|
||||
|
||||
[uuid(d535806e-afaf-47d1-8d89-783ad088c62a)]
|
||||
|
||||
interface nsPIWindowWatcher : nsISupports
|
||||
@ -38,6 +40,23 @@ interface nsPIWindowWatcher : nsISupports
|
||||
*/
|
||||
void removeWindow(in nsIDOMWindow aWindow);
|
||||
|
||||
/** Like the public interface's open(), but can deal with openDialog
|
||||
style arguments. The exact definition of this method is temporary
|
||||
pending the XPIDL rewrite of the DOM.
|
||||
@param aParent parent window, if any. null if not.
|
||||
@param aURL window URL from JS window.open
|
||||
@param aName window name from JS window.open
|
||||
@param aFeatures window features from JS window.open
|
||||
@param aDialog use dialog defaults (see nsIDOMWindowInternal::openDialog)
|
||||
@param argc count of argv arguments
|
||||
@param argv extra JS arguments, if any
|
||||
(see nsIDOMWindowInternal::openDialog)
|
||||
@return the new window
|
||||
*/
|
||||
nsIDOMWindow openWindowJS(in nsIDOMWindow aParent, in wstring aUrl,
|
||||
in wstring aName, in wstring aFeatures, in boolean aDialog,
|
||||
in PRUint32 argc, in jsvalptr argv);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
@ -28,7 +28,8 @@ MODULE = embedcomponents
|
||||
LIBRARY_NAME = windowwatcher_s
|
||||
REQUIRES = xpcom dom windowwatcher
|
||||
|
||||
CPPSRCS = nsWindowWatcher.cpp \
|
||||
CPPSRCS = nsWWJSUtils.cpp \
|
||||
nsWindowWatcher.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
|
||||
@ -24,6 +24,7 @@ MODULE=embedcomponents
|
||||
LIBRARY_NAME=windowwatcher_s
|
||||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsWWJSUtils.obj \
|
||||
.\$(OBJDIR)\nsWindowWatcher.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -29,11 +29,20 @@
|
||||
#define NS_WINDOWWATCHER_CONTRACTID \
|
||||
"@mozilla.org/embedcomp/window-watcher;1"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "jspubtd.h"
|
||||
#include "nsIWindowCreator.h" // for stupid compilers
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsPIWindowWatcher.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIURI;
|
||||
class nsIDocShellTreeItem;
|
||||
class nsIDocShellTreeOwner;
|
||||
class nsString;
|
||||
class nsWindowEnumerator;
|
||||
struct JSContext;
|
||||
struct JSObject;
|
||||
struct WindowInfo;
|
||||
struct PRLock;
|
||||
|
||||
@ -58,12 +67,47 @@ private:
|
||||
PRBool AddEnumerator(nsWindowEnumerator* inEnumerator);
|
||||
PRBool RemoveEnumerator(nsWindowEnumerator* inEnumerator);
|
||||
|
||||
NS_IMETHOD RemoveWindow(WindowInfo *inInfo);
|
||||
nsresult RemoveWindow(WindowInfo *inInfo);
|
||||
|
||||
nsresult FindItemWithName(const PRUnichar *aName,
|
||||
nsIDocShellTreeItem **aFoundItem);
|
||||
|
||||
static JSContext *GetJSContext(nsIDOMWindow *aWindow);
|
||||
static nsresult URIfromURL(const PRUnichar *aURL,
|
||||
nsIDOMWindow *aParent,
|
||||
nsIURI **aURI);
|
||||
static nsresult Escape(const nsAReadableString& aStr,
|
||||
nsAWritableString& aReturn,
|
||||
nsIDOMWindow *aWindow);
|
||||
static void CheckWindowName(nsString& aName);
|
||||
static PRUint32 CalculateChromeFlags(const char *aFeatures,
|
||||
PRBool aFeaturesSpecified,
|
||||
PRBool aDialog);
|
||||
static PRInt32 WinHasOption(const char *aOptions, const char *aName,
|
||||
PRInt32 aDefault, PRBool *aPresenceFlag);
|
||||
static nsresult ReadyOpenedDocShellItem(nsIDocShellTreeItem *aOpenedItem,
|
||||
nsIDOMWindow *aParent,
|
||||
nsIDOMWindow **aOpenedWindow);
|
||||
static void SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
||||
nsIDOMWindow *aParent,
|
||||
const char *aFeatures,
|
||||
PRUint32 aChromeFlags);
|
||||
static void AttachArguments(nsIDOMWindow *aWindow,
|
||||
PRUint32 argc, jsval *argv);
|
||||
static void GetWindowTreeItem(nsIDOMWindow *inWindow,
|
||||
nsIDocShellTreeItem **outTreeItem);
|
||||
static void GetWindowTreeOwner(nsIDOMWindow *inWindow,
|
||||
nsIDocShellTreeOwner **outTreeOwner);
|
||||
static void GetWindowScriptContextAndObject(nsIDOMWindow *inWindow,
|
||||
JSContext **cx,
|
||||
JSObject **outObject);
|
||||
|
||||
nsVoidArray mEnumeratorList;
|
||||
WindowInfo *mOldestWindow;
|
||||
nsIDOMWindow *mActiveWindow;
|
||||
PRLock *mListLock;
|
||||
|
||||
nsCOMPtr<nsIWindowCreator> mWindowCreator;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -30,6 +30,7 @@ RESFILE = $(MODULE).res
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\winEmbed.obj \
|
||||
.\$(OBJDIR)\WebBrowserChrome.obj \
|
||||
.\$(OBJDIR)\WindowCreator.obj \
|
||||
.\$(OBJDIR)\StdAfx.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user