зеркало из https://github.com/mozilla/gecko-dev.git
Landing modal dialogs from JS. More like a feature than stabilization. Apologies. approved: chofmann,don
This commit is contained in:
Родитель
8e5c992a92
Коммит
3da241e524
|
@ -58,6 +58,7 @@
|
|||
#else
|
||||
#include "nsINetSupport.h"
|
||||
#endif
|
||||
#include "nsIModalWindowSupport.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -2050,14 +2051,23 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
|
|||
(nsnull != webShellContainer)) {
|
||||
|
||||
PRBool windowIsNew;
|
||||
PRBool windowIsModal;
|
||||
nsCOMPtr<nsIModalWindowSupport> modalWinSupport;
|
||||
|
||||
// Check for existing window of same name.
|
||||
windowIsNew = PR_FALSE;
|
||||
windowIsModal = PR_FALSE;
|
||||
webShellContainer->FindWebShellWithName(name.GetUnicode(), newOuterShell);
|
||||
if (nsnull == newOuterShell) {
|
||||
// No window of that name, and we are allowed to create a new one now.
|
||||
webShellContainer->NewWebShell(chromeFlags, PR_FALSE, newOuterShell);
|
||||
windowIsNew = PR_TRUE;
|
||||
if (chromeFlags & NS_CHROME_MODAL) {
|
||||
GetModalWindowSupport(getter_AddRefs(modalWinSupport));
|
||||
if (modalWinSupport && NS_SUCCEEDED(modalWinSupport->PrepareModality()))
|
||||
windowIsModal = PR_TRUE;
|
||||
}
|
||||
|
||||
// No window of that name, and we are allowed to create a new one now.
|
||||
webShellContainer->NewWebShell(chromeFlags, PR_FALSE, newOuterShell);
|
||||
}
|
||||
|
||||
if (nsnull != newOuterShell) {
|
||||
|
@ -2067,6 +2077,15 @@ GlobalWindowImpl::OpenInternal(JSContext *cx,
|
|||
newOuterShell->SetName(name.GetUnicode());
|
||||
newOuterShell->LoadURL(mAbsURL.GetUnicode());
|
||||
SizeAndShowOpenedWebShell(newOuterShell, options, windowIsNew, aDialog);
|
||||
if (windowIsModal) {
|
||||
nsIBrowserWindow *newWindow;
|
||||
GetBrowserWindowInterface(newWindow, newOuterShell);
|
||||
if (nsnull != newWindow) {
|
||||
newWindow->ShowModally(PR_FALSE);
|
||||
NS_RELEASE(newWindow);
|
||||
}
|
||||
modalWinSupport->FinishModality();
|
||||
}
|
||||
}
|
||||
NS_RELEASE(newOuterShell);
|
||||
}
|
||||
|
@ -2178,10 +2197,11 @@ GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog) {
|
|||
|
||||
/* Finally, once all the above normal chrome has been divined, deal
|
||||
with the features that are more operating hints than appearance
|
||||
instructions. */
|
||||
instructions. (Note modality implies dependence.) */
|
||||
|
||||
chromeFlags |= WinHasOption(aFeatures, "chrome", presenceFlag) ? NS_CHROME_OPEN_AS_CHROME : 0;
|
||||
chromeFlags |= WinHasOption(aFeatures, "modal", presenceFlag) ? NS_CHROME_MODAL : 0;
|
||||
chromeFlags |= WinHasOption(aFeatures, "dependent", presenceFlag) ? NS_CHROME_DEPENDENT : 0;
|
||||
chromeFlags |= WinHasOption(aFeatures, "modal", presenceFlag) ? (NS_CHROME_MODAL | NS_CHROME_DEPENDENT) : 0;
|
||||
chromeFlags |= WinHasOption(aFeatures, "dialog", presenceFlag) ? NS_CHROME_OPEN_AS_DIALOG : 0;
|
||||
|
||||
/* and dialogs need to have the last word. assume dialogs are dialogs,
|
||||
|
@ -2238,18 +2258,7 @@ GlobalWindowImpl::SizeAndShowOpenedWebShell(nsIWebShell *aOuterShell,
|
|||
}
|
||||
|
||||
// get the nsIBrowserWindow corresponding to the given aOuterShell
|
||||
nsIWebShell *rootShell;
|
||||
aOuterShell->GetRootWebShellEvenIfChrome(rootShell);
|
||||
if (nsnull != rootShell) {
|
||||
nsIWebShellContainer *newContainer;
|
||||
rootShell->GetContainer(newContainer);
|
||||
if (nsnull != newContainer) {
|
||||
if (NS_FAILED(newContainer->QueryInterface(kIBrowserWindowIID, (void**)&openedWindow)))
|
||||
openedWindow = nsnull;
|
||||
NS_RELEASE(newContainer);
|
||||
}
|
||||
NS_RELEASE(rootShell);
|
||||
}
|
||||
GetBrowserWindowInterface(openedWindow, aOuterShell);
|
||||
|
||||
// set size
|
||||
if (nsnull != openedWindow) {
|
||||
|
@ -2450,21 +2459,28 @@ GlobalWindowImpl::WinHasOption(char *options, char *name, PRBool& aPresenceFlag)
|
|||
}
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::GetBrowserWindowInterface(nsIBrowserWindow*& aBrowser)
|
||||
GlobalWindowImpl::GetBrowserWindowInterface(
|
||||
nsIBrowserWindow*& aBrowser,
|
||||
nsIWebShell *aWebShell)
|
||||
{
|
||||
nsresult ret = NS_ERROR_FAILURE;
|
||||
aBrowser = nsnull;
|
||||
|
||||
if (nsnull != mWebShell) {
|
||||
nsIWebShell *mRootWebShell;
|
||||
mWebShell->GetRootWebShellEvenIfChrome(mRootWebShell);
|
||||
if (nsnull != mRootWebShell) {
|
||||
nsIWebShellContainer *mRootContainer;
|
||||
mRootWebShell->GetContainer(mRootContainer);
|
||||
if (nsnull != mRootContainer) {
|
||||
ret = mRootContainer->QueryInterface(kIBrowserWindowIID, (void**)&aBrowser);
|
||||
NS_RELEASE(mRootContainer);
|
||||
if (nsnull == aWebShell)
|
||||
aWebShell = mWebShell;
|
||||
if (nsnull != aWebShell) {
|
||||
nsIWebShell *rootWebShell;
|
||||
aWebShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
||||
if (nsnull != rootWebShell) {
|
||||
nsIWebShellContainer *rootContainer;
|
||||
rootWebShell->GetContainer(rootContainer);
|
||||
if (nsnull != rootContainer) {
|
||||
ret = rootContainer->QueryInterface(kIBrowserWindowIID, (void**)&aBrowser);
|
||||
if (NS_FAILED(ret))
|
||||
aBrowser = nsnull;
|
||||
NS_RELEASE(rootContainer);
|
||||
}
|
||||
NS_RELEASE(mRootWebShell);
|
||||
NS_RELEASE(rootWebShell);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -3324,3 +3340,24 @@ NavigatorImpl::JavaEnabled(PRBool* aReturn)
|
|||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GlobalWindowImpl::GetModalWindowSupport(nsIModalWindowSupport **msw)
|
||||
{
|
||||
NS_ASSERTION(msw, "null return param in GetModalWindowSupport");
|
||||
*msw = nsnull;
|
||||
|
||||
if (nsnull == mWebShell)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIWebShell> rootWebShell;
|
||||
mWebShell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebShell));
|
||||
if (rootWebShell) {
|
||||
nsCOMPtr<nsIWebShellContainer> rootContainer;
|
||||
rootWebShell->GetContainer(*getter_AddRefs(rootContainer));
|
||||
if (rootContainer)
|
||||
rootContainer->QueryInterface(nsIModalWindowSupport::GetIID(), (void**)msw);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ class nsIDocument;
|
|||
class nsIPresContext;
|
||||
class nsIDOMEvent;
|
||||
class nsIBrowserWindow;
|
||||
class nsIModalWindowSupport;
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
|
@ -223,7 +224,8 @@ protected:
|
|||
void DropTimeout(nsTimeoutImpl *aTimeout,
|
||||
nsIScriptContext* aContext=nsnull);
|
||||
void HoldTimeout(nsTimeoutImpl *aTimeout);
|
||||
nsresult GetBrowserWindowInterface(nsIBrowserWindow*& aBrowser);
|
||||
nsresult GetBrowserWindowInterface(nsIBrowserWindow*& aBrowser,
|
||||
nsIWebShell *aWebShell=nsnull);
|
||||
nsresult CheckWindowName(JSContext *cx, nsString& aName);
|
||||
PRInt32 WinHasOption(char *options, char *name, PRBool& aPresenceFlag);
|
||||
PRBool CheckForEventListener(JSContext *aContext, nsString& aPropName);
|
||||
|
@ -235,6 +237,7 @@ protected:
|
|||
nsresult SizeAndShowOpenedWebShell(nsIWebShell *aOuterShell,
|
||||
char *aFeatures, PRBool aNewWindow, PRBool aDialog);
|
||||
nsresult ReadyOpenedWebShell(nsIWebShell *aWebShell, nsIDOMWindow **aDOMWindow);
|
||||
nsresult GetModalWindowSupport(nsIModalWindowSupport **msw);
|
||||
|
||||
static nsresult WebShellToDOMWindow(nsIWebShell *aWebShell, nsIDOMWindow **aDOMWindow);
|
||||
|
||||
|
|
|
@ -198,6 +198,12 @@ CWebShellContainer::Close()
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP ShowModally(PRBool aPrepare)
|
||||
{
|
||||
NG_TRACE_METHOD(CWebShellContainer::ShowModally);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::SetChrome(PRUint32 aNewChromeMask)
|
||||
{
|
||||
|
|
|
@ -53,12 +53,13 @@ public:
|
|||
NS_IMETHOD GetBounds(nsRect& aResult);
|
||||
NS_IMETHOD GetWindowBounds(nsRect& aResult);
|
||||
NS_IMETHOD IsIntrinsicallySized(PRBool& aResult);
|
||||
NS_IMETHOD SizeWindowTo(PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD SizeContentTo(PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD ShowAfterCreation();
|
||||
NS_IMETHOD SizeWindowTo(PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD SizeContentTo(PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD ShowAfterCreation();
|
||||
NS_IMETHOD Show();
|
||||
NS_IMETHOD Hide();
|
||||
NS_IMETHOD Close();
|
||||
NS_IMETHOD ShowModally(PRBool aPrepare);
|
||||
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask);
|
||||
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
|
||||
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
#
|
||||
|
||||
nsIBrowserWindow.h
|
||||
nsIClipboardCommands.h
|
||||
nsIContentViewer.h
|
||||
nsIContentViewerContainer.h
|
||||
nsIDocStreamLoaderFactory.h
|
||||
nsIDocumentLoader.h
|
||||
nsIDocumentLoaderObserver.h
|
||||
nsIDocStreamLoaderFactory.h
|
||||
nsILinkHandler.h
|
||||
nsIModalWindowSupport.h
|
||||
nsIRefreshURI.h
|
||||
nsIThrobber.h
|
||||
nsIUrlDispatcher.h
|
||||
nsIWebShell.h
|
||||
nsIWebShellServices.h
|
||||
nsIClipboardCommands.h
|
||||
nsIUrlDispatcher.h
|
||||
nsweb.h
|
||||
nsIRefreshURI.h
|
||||
|
|
|
@ -26,18 +26,19 @@ MODULE = raptor
|
|||
|
||||
EXPORTS = \
|
||||
nsIBrowserWindow.h \
|
||||
nsIClipboardCommands.h \
|
||||
nsIContentViewer.h \
|
||||
nsIContentViewerContainer.h \
|
||||
nsIDocStreamLoaderFactory.h \
|
||||
nsIDocumentLoader.h \
|
||||
nsIDocumentLoaderObserver.h \
|
||||
nsILinkHandler.h \
|
||||
nsIModalWindowSupport.h \
|
||||
nsIThrobber.h \
|
||||
nsIUrlDispatcher.h \
|
||||
nsIWebShell.h \
|
||||
nsIWebShellServices.h \
|
||||
nsIClipboardCommands.h \
|
||||
nsweb.h \
|
||||
nsIDocStreamLoaderFactory.h \
|
||||
nsIUrlDispatcher.h \
|
||||
$(NULL)
|
||||
|
||||
ifdef NECKO
|
||||
|
@ -51,3 +52,4 @@ EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
|||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -25,17 +25,18 @@ include <$(DEPTH)\config\config.mak>
|
|||
|
||||
EXPORTS = \
|
||||
nsIBrowserWindow.h \
|
||||
nsIClipboardCommands.h \
|
||||
nsIContentViewer.h \
|
||||
nsIContentViewerContainer.h \
|
||||
nsIDocStreamLoaderFactory.h \
|
||||
nsIDocumentLoader.h \
|
||||
nsIDocumentLoaderObserver.h \
|
||||
nsIDocStreamLoaderFactory.h \
|
||||
nsILinkHandler.h \
|
||||
nsIModalWindowSupport.h \
|
||||
nsIThrobber.h \
|
||||
nsIUrlDispatcher.h \
|
||||
nsIWebShell.h \
|
||||
nsIWebShellServices.h \
|
||||
nsIClipboardCommands.h \
|
||||
nsIUrlDispatcher.h \
|
||||
nsweb.h \
|
||||
!ifdef NECKO
|
||||
nsIRefreshURI.h \
|
||||
|
|
|
@ -47,6 +47,7 @@ struct nsRect;
|
|||
#define NS_CHROME_PERSONAL_TOOLBAR_ON 0x00000100
|
||||
#define NS_CHROME_SCROLLBARS_ON 0x00000200
|
||||
#define NS_CHROME_TITLEBAR_ON 0x00000400
|
||||
#define NS_CHROME_DEPENDENT 0x10000000
|
||||
#define NS_CHROME_MODAL 0x20000000
|
||||
#define NS_CHROME_OPEN_AS_DIALOG 0x40000000
|
||||
#define NS_CHROME_OPEN_AS_CHROME 0x80000000
|
||||
|
@ -84,6 +85,8 @@ public:
|
|||
|
||||
NS_IMETHOD Close() = 0;
|
||||
|
||||
NS_IMETHOD ShowModally(PRBool aPrepare) = 0;
|
||||
|
||||
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask) = 0;
|
||||
|
||||
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult) = 0;
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#ifndef __nsIModalWindowSupport_h
|
||||
#define __nsIModalWindowSupport_h
|
||||
|
||||
// {FFD41B80-4F95-11d3-9584-0060083A0BCF}
|
||||
#define NS_IMODALWINDOWSUPPORT_IID \
|
||||
{ 0xffd41b80, 0x4f95, 0x11d3, \
|
||||
{0x95, 0x84, 0x0, 0x60, 0x8, 0x3a, 0xb, 0xcf } }
|
||||
|
||||
/**
|
||||
* nsIModalWindowSupport needs to do some skanky spinup and cleanup that
|
||||
* our system requires to support modal windows.
|
||||
*/
|
||||
class nsIModalWindowSupport: public nsISupports {
|
||||
public:
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMODALWINDOWSUPPORT_IID)
|
||||
|
||||
/**
|
||||
* Do preparatory work necessary for beginning a modal window. This must
|
||||
* be called before the window is actually created.
|
||||
* @return NS_OK if the spinup was successful. else, you probably won't
|
||||
* be able to have your window modal.
|
||||
*/
|
||||
NS_IMETHOD PrepareModality() = 0;
|
||||
|
||||
/**
|
||||
* Clean up after PrepareModality. Implementations can expect this to
|
||||
* always be called, and always after PrepareModality wal called.
|
||||
* @return NS_OK if cleanup was successful. failure should be rare, and
|
||||
* most likely of some bad, unexpected system kinkage.
|
||||
*/
|
||||
NS_IMETHOD FinishModality() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1603,6 +1603,13 @@ nsBrowserWindow::Close()
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserWindow::ShowModally(PRBool aPrepare)
|
||||
{
|
||||
// unsupported by viewer
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserWindow::SetChrome(PRUint32 aChromeMask)
|
||||
{
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
NS_IMETHOD Show();
|
||||
NS_IMETHOD Hide();
|
||||
NS_IMETHOD Close();
|
||||
NS_IMETHOD ShowModally(PRBool aPrepare);
|
||||
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask);
|
||||
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
|
||||
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
|
||||
|
|
|
@ -821,7 +821,11 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
|||
gtk_widget_push_colormap(gdk_rgb_get_cmap());
|
||||
gtk_widget_push_visual(gdk_rgb_get_visual());
|
||||
|
||||
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
|
||||
nsIWidget *baseParent = aInitData &&
|
||||
(aInitData->mWindowType == eWindowType_dialog ||
|
||||
aInitData->mWindowType == eWindowType_toplevel) ?
|
||||
nsnull : aParent;
|
||||
BaseCreate(baseParent, aRect, aHandleEventFunction, aContext,
|
||||
aAppShell, aToolkit, aInitData);
|
||||
mParent = aParent;
|
||||
NS_IF_ADDREF(mParent);
|
||||
|
|
|
@ -458,7 +458,8 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent,
|
|||
nsRect bounds(0, 0, aRect.width, aRect.height - bottomPinDelta);
|
||||
|
||||
// init base class
|
||||
Inherited::StandardCreate(aParent, bounds, aHandleEventFunction,
|
||||
// (note: aParent is ignored. Mac (real) windows don't want parents)
|
||||
Inherited::StandardCreate(nsnull, bounds, aHandleEventFunction,
|
||||
aContext, aAppShell, aToolkit, aInitData);
|
||||
|
||||
|
||||
|
|
|
@ -601,8 +601,11 @@ nsresult nsWindow::StandardWindowCreate(nsIWidget *aParent,
|
|||
nsWidgetInitData *aInitData,
|
||||
nsNativeWidget aNativeParent)
|
||||
{
|
||||
|
||||
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
|
||||
nsIWidget *baseParent = aInitData &&
|
||||
(aInitData->mWindowType == eWindowType_dialog ||
|
||||
aInitData->mWindowType == eWindowType_toplevel) ?
|
||||
nsnull : aParent;
|
||||
BaseCreate(baseParent, aRect, aHandleEventFunction, aContext,
|
||||
aAppShell, aToolkit, aInitData);
|
||||
|
||||
// See if the caller wants to explictly set clip children and clip siblings
|
||||
|
|
|
@ -597,7 +597,7 @@ nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *aParent,
|
|||
window->SetIntrinsicallySized(PR_TRUE);
|
||||
}
|
||||
|
||||
rv = window->Initialize((nsIWebShellWindow *) nsnull, mAppShell, aUrl,
|
||||
rv = window->Initialize(aParent, mAppShell, aUrl,
|
||||
aShowWindow, nsnull, aCallbacks,
|
||||
aInitialWidth, aInitialHeight, widgetInitData);
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "nsWebShellWindow.h"
|
||||
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
|
@ -291,22 +292,31 @@ nsWebShellWindow::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if ( aIID.Equals(kIBrowserWindowIID) ) {
|
||||
if (aIID.Equals(kIBrowserWindowIID)) {
|
||||
*aInstancePtr = (void*) (nsIBrowserWindow*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if ( aIID.Equals(kIUrlDispatcherIID) ) {
|
||||
if (aIID.Equals(kIUrlDispatcherIID)) {
|
||||
*aInstancePtr = (void*) (nsIUrlDispatcher*) this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIPromptIID )) {
|
||||
if (aIID.Equals(kIPromptIID )) {
|
||||
*aInstancePtr = (void*)(nsIPrompt*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(nsIModalWindowSupport::GetIID())) {
|
||||
*aInstancePtr = (void*)NS_STATIC_CAST(nsIModalWindowSupport*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsISupportsWeakReference::GetIID())) {
|
||||
*aInstancePtr = (void*)NS_STATIC_CAST(nsISupportsWeakReference *, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*)(nsISupports*)(nsIWebShellContainer*)this;
|
||||
NS_ADDREF_THIS();
|
||||
|
@ -325,7 +335,6 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent,
|
|||
nsWidgetInitData& widgetInitData)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsIWidget *parentWidget;
|
||||
|
||||
mCreatedVisible = aCreatedVisible;
|
||||
|
@ -344,6 +353,23 @@ nsresult nsWebShellWindow::Initialize(nsIWebShellWindow* aParent,
|
|||
if (!aParent || NS_FAILED(aParent->GetWidget(parentWidget)))
|
||||
parentWidget = nsnull;
|
||||
|
||||
/* This next bit is troublesome. We carry two different versions of a pointer
|
||||
to our parent window. One is the parent window's widget, which is passed
|
||||
to our own widget. The other is a weak reference we keep here to our
|
||||
parent WebShellWindow. The former is useful to the widget, and we can't
|
||||
trust its treatment of the parent reference because they're platform-
|
||||
specific. The latter is useful to this class.
|
||||
A better implementation would be one in which the parent keeps strong
|
||||
references to its children and closes them before it allows itself
|
||||
to be closed. This would mimic the behaviour of OSes that support
|
||||
top-level child windows in OSes that do not. Later.
|
||||
*/
|
||||
parentWidget = nsnull;
|
||||
if (aParent) {
|
||||
aParent->GetWidget(parentWidget);
|
||||
mParentWindow = getter_AddRefs(NS_GetWeakReference(aParent));
|
||||
}
|
||||
|
||||
mWindow->SetClientData(this);
|
||||
mWindow->Create(parentWidget, // Parent nsIWidget
|
||||
r, // Widget dimensions
|
||||
|
@ -1447,8 +1473,9 @@ nsWebShellWindow::NewWebShell(PRUint32 aChromeMask, PRBool aVisible,
|
|||
if ((aChromeMask & NS_CHROME_OPEN_AS_CHROME) != 0) {
|
||||
// Just do a nice normal create of a web shell and
|
||||
// return it immediately.
|
||||
|
||||
rv = appShell->CreateTopLevelWindow(nsnull, nsnull, PR_FALSE, aChromeMask,
|
||||
|
||||
nsIWebShellWindow *parent = aChromeMask & NS_CHROME_DEPENDENT ? this : nsnull;
|
||||
rv = appShell->CreateTopLevelWindow(parent, nsnull, PR_FALSE, aChromeMask,
|
||||
nsnull, NS_SIZETOCONTENT, NS_SIZETOCONTENT,
|
||||
getter_AddRefs(newWindow));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -1697,6 +1724,35 @@ nsWebShellWindow::ShowModalInternal()
|
|||
}
|
||||
|
||||
|
||||
// yes, this one's name and ShowModal are a confusing pair. plan is to merge
|
||||
// the two someday.
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::ShowModally(PRBool aPrepare)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWidget> parentWidget;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (aPrepare && NS_FAILED(appShell->PushThreadEventQueue()))
|
||||
aPrepare = PR_FALSE;
|
||||
|
||||
parentWidget = do_QueryReference(mParentWindow);
|
||||
if (parentWidget)
|
||||
parentWidget->Enable(PR_FALSE);
|
||||
rv = ShowModal();
|
||||
if (parentWidget)
|
||||
parentWidget->Enable(PR_TRUE);
|
||||
|
||||
if (aPrepare)
|
||||
appShell->PopThreadEventQueue();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/* return the main, outermost webshell in this window */
|
||||
NS_IMETHODIMP
|
||||
nsWebShellWindow::GetWebShell(nsIWebShell *& aWebShell)
|
||||
|
@ -1802,9 +1858,7 @@ nsWebShellWindow::OnEndDocumentLoad(nsIDocumentLoader* loader,
|
|||
|
||||
mChromeInitialized = PR_TRUE;
|
||||
|
||||
if (mLockedUntilChromeLoad) {
|
||||
mLockedUntilChromeLoad = PR_FALSE;
|
||||
}
|
||||
mLockedUntilChromeLoad = PR_FALSE;
|
||||
|
||||
#ifdef XP_MAC // Anyone still using native menus should add themselves here.
|
||||
// register as document listener
|
||||
|
@ -2903,3 +2957,23 @@ NS_IMETHODIMP nsWebShellWindow::ConfirmCheckYN(const PRUnichar *text, const PRUn
|
|||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// nsIModalWindowSupport interface
|
||||
nsresult nsWebShellWindow::PrepareModality()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return appShell->PushThreadEventQueue();
|
||||
}
|
||||
|
||||
nsresult nsWebShellWindow::FinishModality()
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return appShell->PopThreadEventQueue();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIBrowserWindow.h"
|
||||
#include "nsIModalWindowSupport.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
|
@ -38,6 +39,7 @@
|
|||
#include "nsIDOMNode.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
/* Forward declarations.... */
|
||||
struct PLEvent;
|
||||
|
@ -61,9 +63,10 @@ class nsWebShellWindow : public nsIWebShellWindow,
|
|||
public nsIBrowserWindow,
|
||||
public nsIDocumentLoaderObserver,
|
||||
public nsIDocumentObserver,
|
||||
public nsIUrlDispatcher
|
||||
|
||||
, public nsIPrompt
|
||||
public nsIUrlDispatcher,
|
||||
public nsIPrompt,
|
||||
public nsIModalWindowSupport,
|
||||
public nsSupportsWeakReference
|
||||
|
||||
{
|
||||
public:
|
||||
|
@ -119,6 +122,7 @@ public:
|
|||
// nsIWebShellWindow methods...
|
||||
NS_IMETHOD Show(PRBool aShow);
|
||||
NS_IMETHOD ShowModal();
|
||||
NS_IMETHOD ShowModally(PRBool aPrepare);
|
||||
NS_IMETHOD Close();
|
||||
NS_IMETHOD GetWebShell(nsIWebShell *& aWebShell);
|
||||
NS_IMETHOD GetContentWebShell(nsIWebShell **aResult);
|
||||
|
@ -226,7 +230,7 @@ public:
|
|||
nsIStyleRule* aStyleRule);
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument);
|
||||
|
||||
// nsIBrowserWindow methods not already covered elsewhere
|
||||
// nsIBrowserWindow methods not already covered elsewhere
|
||||
NS_IMETHOD Init(nsIAppShell* aAppShell,
|
||||
nsIPref* aPrefs,
|
||||
const nsRect& aBounds,
|
||||
|
@ -264,6 +268,11 @@ public:
|
|||
NS_IMETHOD PromptPassword(const PRUnichar *text, PRUnichar **pwd, PRBool *_retval);
|
||||
NS_IMETHOD ConfirmYN(const PRUnichar *text, PRBool *_retval);
|
||||
NS_IMETHOD ConfirmCheckYN(const PRUnichar *text, const PRUnichar *checkMsg, PRBool *checkValue, PRBool *_retval);
|
||||
|
||||
// nsIModalWindowSupport
|
||||
NS_IMETHOD PrepareModality();
|
||||
NS_IMETHOD FinishModality();
|
||||
|
||||
protected:
|
||||
|
||||
PRInt32 GetDocHeight(nsIDocument * aDoc);
|
||||
|
@ -294,6 +303,7 @@ protected:
|
|||
|
||||
nsIWidget* mWindow;
|
||||
nsIWebShell* mWebShell;
|
||||
nsCOMPtr<nsIWeakReference> mParentWindow;
|
||||
nsIXULWindowCallbacks* mCallbacks;
|
||||
PRBool mContinueModalLoop;
|
||||
PRBool mLockedUntilChromeLoad;
|
||||
|
|
|
@ -12,18 +12,22 @@
|
|||
<![CDATA[
|
||||
var featureList = new Array("all",
|
||||
"close", "titlebar", "resizable", "scrollbars",
|
||||
"chrome", "dialog", "modal",
|
||||
"chrome", "dialog", "modal", "dependent",
|
||||
"menubar", "toolbar", "status", "location");
|
||||
|
||||
function OpenWindow(extension) {
|
||||
var features = CalculateFeatures();
|
||||
dump("******* begin open window\n");
|
||||
window.open("resource:/res/samples/dexparamdialog."+extension,
|
||||
"New", features);
|
||||
dump("******* end open window\n");
|
||||
}
|
||||
function OpenDialog(extension) {
|
||||
var features = CalculateFeatures();
|
||||
dump("******* begin opendialog\n");
|
||||
window.openDialog("resource:/res/samples/dexparamdialog."+extension,
|
||||
"New", features, {remind:true});
|
||||
dump("******* end opendialog\n");
|
||||
}
|
||||
function CalculateFeatures() {
|
||||
var ctr;
|
||||
|
@ -42,8 +46,6 @@
|
|||
} else {
|
||||
element = document.getElementById(featureList[ctr]+"-ex");
|
||||
if (element && element.checked) { // titlebar, close, dialog
|
||||
// if (featureList[ctr] == "titlebar" || featureList[ctr] == "close" ||
|
||||
// featureList[ctr] == "dialog") {
|
||||
if (features.length > 0)
|
||||
features = features + ",";
|
||||
features = features + featureList[ctr] + "=no";
|
||||
|
@ -107,6 +109,11 @@
|
|||
<html:input type="checkbox" id="modal"/>modal
|
||||
</html:td>
|
||||
</html:tr>
|
||||
<html:tr>
|
||||
<html:td>
|
||||
<html:input type="checkbox" id="dependent"/>dependent
|
||||
</html:td>
|
||||
</html:tr>
|
||||
<html:tr>
|
||||
<html:td>
|
||||
<html:input type="checkbox" id="menubar"/>menubar
|
||||
|
@ -127,6 +134,8 @@
|
|||
<html:input type="checkbox" id="location"/>location
|
||||
</html:td>
|
||||
</html:tr>
|
||||
</html:table>
|
||||
<html:table>
|
||||
<html:tr>
|
||||
<html:td colspan="2">
|
||||
<html:center>Open</html:center>
|
||||
|
|
Загрузка…
Ссылка в новой задаче