Skip to content

Commit

Permalink
Fixing bug 194404. Adding support for window.showModalDialog() for co…
Browse files Browse the repository at this point in the history
…mpatibility with IE. [email protected]
  • Loading branch information
[email protected] committed Jul 26, 2007
1 parent d5b51a6 commit c1b1b4d
Show file tree
Hide file tree
Showing 15 changed files with 452 additions and 35 deletions.
8 changes: 8 additions & 0 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8500,7 +8500,15 @@ nsDocShell::EnsureScriptEnvironment()
do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);

nsCOMPtr<nsIDocShellTreeItem> parent;
GetParent(getter_AddRefs(parent));

nsCOMPtr<nsPIDOMWindow> pw(do_GetInterface(parent));

// If the parent (chrome or not) is a modal content window, make
// this window a modal content window as well.
factory->NewScriptGlobalObject(mItemType == typeChrome,
pw && pw->IsModalContentWindow(),
getter_AddRefs(mScriptGlobal));
NS_ENSURE_TRUE(mScriptGlobal, NS_ERROR_FAILURE);

Expand Down
20 changes: 17 additions & 3 deletions dom/public/base/nsPIDOMWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class nsPresContext;
struct nsTimeout;

#define NS_PIDOMWINDOW_IID \
{ 0xbf81c452, 0xbd39, 0x4001, \
{ 0x85, 0xf4, 0x21, 0x79, 0x36, 0xc5, 0x85, 0x7d } }
{ 0x42764ad5, 0xa196, 0x408c, \
{ 0xa4, 0x87, 0x97, 0xf4, 0xc6, 0x31, 0x57, 0x21 } }

class nsPIDOMWindow : public nsIDOMWindowInternal
{
Expand Down Expand Up @@ -361,6 +361,15 @@ class nsPIDOMWindow : public nsIDOMWindowInternal
virtual void EnterModalState() = 0;
virtual void LeaveModalState() = 0;

void SetModalContentWindow(PRBool aIsModalContentWindow)
{
mIsModalContentWindow = aIsModalContentWindow;
}

PRBool IsModalContentWindow() const
{
return mIsModalContentWindow;
}

protected:
// The nsPIDOMWindow constructor. The aOuterWindow argument should
Expand All @@ -371,7 +380,8 @@ class nsPIDOMWindow : public nsIDOMWindowInternal
: mFrameElement(nsnull), mDocShell(nsnull), mModalStateDepth(0),
mRunningTimeout(nsnull), mMutationBits(0), mIsDocumentLoaded(PR_FALSE),
mIsHandlingResizeEvent(PR_FALSE), mIsInnerWindow(aOuterWindow != nsnull),
mInnerWindow(nsnull), mOuterWindow(aOuterWindow)
mIsModalContentWindow(PR_FALSE), mInnerWindow(nsnull),
mOuterWindow(aOuterWindow)
{
}

Expand All @@ -396,6 +406,10 @@ class nsPIDOMWindow : public nsIDOMWindowInternal
PRPackedBool mIsHandlingResizeEvent;
PRPackedBool mIsInnerWindow;

// This variable is used on both inner and outer windows (and they
// should match).
PRPackedBool mIsModalContentWindow;

// And these are the references between inner and outer windows.
nsPIDOMWindow *mInnerWindow;
nsPIDOMWindow *mOuterWindow;
Expand Down
7 changes: 4 additions & 3 deletions dom/public/idl/base/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SDK_XPIDLSRCS = \

XPIDLSRCS = \
nsIBrowserDOMWindow.idl \
nsIDOMClientInformation.idl \
nsIDOMClientInformation.idl \
nsIDOMConstructor.idl \
nsIDOMCRMFObject.idl \
nsIDOMCrypto.idl \
Expand All @@ -74,10 +74,11 @@ XPIDLSRCS = \
nsIDOMScreen.idl \
nsIDOMWindowInternal.idl \
nsIDOMJSWindow.idl \
nsIDOMModalContentWindow.idl \
nsIDOMChromeWindow.idl \
nsIDOMNSFeatureFactory.idl \
nsIDOMTextRectangle.idl \
nsIDOMTextRectangleList.idl \
nsIDOMTextRectangle.idl \
nsIDOMTextRectangleList.idl \
$(NULL)

include $(topsrcdir)/config/rules.mk
58 changes: 58 additions & 0 deletions dom/public/idl/base/nsIDOMModalContentWindow.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Johnny Stenback <[email protected]> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"

interface nsIVariant;
interface nsIArray;

[scriptable, uuid(51aebd45-b979-4ec6-9d11-3a3fd3d5d59e)]
interface nsIDOMModalContentWindow : nsISupports
{
/**
* Readonly attribute containing an array of arguments that was
* passed to the code that opened this modal content window.
*/
readonly attribute nsIArray dialogArguments;

/**
* The return value that will be returned to the function that
* opened the modal content window.
*/
attribute nsIVariant returnValue;
};
7 changes: 6 additions & 1 deletion dom/public/idl/base/nsIDOMWindowInternal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
interface nsIPrompt;
interface nsIControllers;
interface nsIDOMLocation;
interface nsIVariant;

[scriptable, uuid(f914492c-0138-4123-a634-6ef8e3f126f8)]
[scriptable, uuid(0d12a345-3fe2-491e-af0d-bcfd5c4baa03)]
interface nsIDOMWindowInternal : nsIDOMWindow2
{
readonly attribute nsIDOMWindowInternal window;
Expand Down Expand Up @@ -195,4 +196,8 @@ interface nsIDOMWindowInternal : nsIDOMWindow2
DOMString btoa(in DOMString aBase64Data);

readonly attribute nsIDOMElement frameElement;

nsIVariant showModalDialog(in DOMString aURI,
[optional] in nsIVariant aArgs,
[optional] in DOMString aOptions);
};
3 changes: 3 additions & 0 deletions dom/public/nsDOMClassInfoID.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ enum nsDOMClassInfoID {
eDOMClassInfo_File_id,
eDOMClassInfo_FileException_id,

// DOM modal content window class, almost identical to Window
eDOMClassInfo_ModalContentWindow_id,

// This one better be the last one in this list
eDOMClassInfoIDCount
};
Expand Down
6 changes: 3 additions & 3 deletions dom/public/nsIDOMScriptObjectFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
#include "nsStringGlue.h"

#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
{ /* {38EC7717-6CBE-44a8-B2BB-53F2BA998B31} */ \
0x38ec7717, 0x6cbe, 0x44a8, \
{ 0xb2, 0xbb, 0x53, 0xf2, 0xba, 0x99, 0x8b, 0x31 } }
{ 0xd5a4f935, 0xe428, 0x47ec, \
{ 0x8f, 0x36, 0x44, 0x23, 0xfa, 0xa2, 0x21, 0x90 } }

class nsIScriptContext;
class nsIScriptGlobalObject;
Expand Down Expand Up @@ -74,6 +73,7 @@ class nsIDOMScriptObjectFactory : public nsISupports {
PRUint32 *aScriptTypeID) = 0;

NS_IMETHOD NewScriptGlobalObject(PRBool aIsChrome,
PRBool aIsModalContentWindow,
nsIScriptGlobalObject **aGlobal) = 0;

NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) = 0;
Expand Down
14 changes: 14 additions & 0 deletions dom/src/base/nsDOMClassInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(FileException, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)

NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
DEFAULT_SCRIPTABLE_FLAGS |
WINDOW_SCRIPTABLE_FLAGS)
};

// Objects that shuld be constructable through |new Name();|
Expand Down Expand Up @@ -3307,6 +3310,17 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIException)
DOM_CLASSINFO_MAP_END

DOM_CLASSINFO_MAP_BEGIN(ModalContentWindow, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
DOM_CLASSINFO_MAP_END

#ifdef NS_DEBUG
{
PRUint32 i = NS_ARRAY_LENGTH(sClassInfoData);
Expand Down
3 changes: 2 additions & 1 deletion dom/src/base/nsDOMScriptObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ nsDOMScriptObjectFactory::GetIDForScriptType(const nsAString &aLanguageName,

NS_IMETHODIMP
nsDOMScriptObjectFactory::NewScriptGlobalObject(PRBool aIsChrome,
PRBool aIsModalContentWindow,
nsIScriptGlobalObject **aGlobal)
{
return NS_NewScriptGlobalObject(aIsChrome, aGlobal);
return NS_NewScriptGlobalObject(aIsChrome, aIsModalContentWindow, aGlobal);
}

NS_IMETHODIMP_(nsISupports *)
Expand Down
1 change: 1 addition & 0 deletions dom/src/base/nsDOMScriptObjectFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class nsDOMScriptObjectFactory : public nsIDOMScriptObjectFactory,
PRUint32 *aLanguageID);

NS_IMETHOD NewScriptGlobalObject(PRBool aIsChrome,
PRBool aIsModalContentWindow,
nsIScriptGlobalObject **aGlobal);

NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID);
Expand Down
Loading

0 comments on commit c1b1b4d

Please sign in to comment.