2000-08-22 03:51:17 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
1998-07-16 01:16:47 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-07-16 01:16:47 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* 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.
|
1998-07-16 01:16:47 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-07-16 01:16:47 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-02-08 13:40:10 +00:00
|
|
|
* Travis Bogard <travis@netscape.com>
|
2000-08-09 03:30:46 +00:00
|
|
|
* Brendan Eich <brendan@mozilla.org>
|
2000-09-07 01:07:29 +00:00
|
|
|
* David Hyatt (hyatt@netscape.com)
|
1998-07-16 01:16:47 +00:00
|
|
|
*/
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
// Local Includes
|
1998-07-24 05:05:42 +00:00
|
|
|
#include "nsGlobalWindow.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsScreen.h"
|
|
|
|
#include "nsHistory.h"
|
|
|
|
#include "nsBarProps.h"
|
|
|
|
|
|
|
|
// Helper Classes
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsXPIDLString.h"
|
|
|
|
#include "nsJSUtils.h"
|
1998-07-16 01:16:47 +00:00
|
|
|
#include "prmem.h"
|
2000-08-22 03:51:17 +00:00
|
|
|
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
|
2000-08-23 17:27:06 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
// Other Classes
|
1998-07-24 05:05:42 +00:00
|
|
|
#include "nsEventListenerManager.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsEscape.h"
|
|
|
|
#include "nsDOMPropEnums.h"
|
|
|
|
#include "nsStyleCoord.h"
|
|
|
|
#include "nsHTMLReflowState.h"
|
|
|
|
#include "nsMimeTypeArray.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsPluginArray.h"
|
|
|
|
#include "nsRDFCID.h"
|
|
|
|
|
|
|
|
// Interfaces Needed
|
|
|
|
#include "nsIBaseWindow.h"
|
|
|
|
#include "nsICharsetConverterManager.h"
|
2000-02-10 04:56:56 +00:00
|
|
|
#include "nsICodebasePrincipal.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIContentViewerFile.h"
|
|
|
|
#include "nsIContentViewerEdit.h"
|
|
|
|
#include "nsICookieService.h"
|
|
|
|
#include "nsIDocShell.h"
|
2000-03-30 22:38:32 +00:00
|
|
|
#include "nsIDocShellLoadInfo.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeNode.h"
|
|
|
|
#include "nsIDocument.h"
|
2000-05-11 19:17:07 +00:00
|
|
|
#include "nsIDOMCrypto.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
2000-04-26 13:58:56 +00:00
|
|
|
#include "nsIDOMDocumentView.h"
|
2000-05-17 00:31:36 +00:00
|
|
|
#include "nsIDOMDragListener.h"
|
1998-08-13 23:37:54 +00:00
|
|
|
#include "nsIDOMFocusListener.h"
|
|
|
|
#include "nsIDOMFormListener.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDOMKeyListener.h"
|
1998-08-13 23:37:54 +00:00
|
|
|
#include "nsIDOMLoadListener.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIDOMMouseMotionListener.h"
|
|
|
|
#include "nsIDOMMouseListener.h"
|
1998-10-06 20:59:39 +00:00
|
|
|
#include "nsIDOMPaintListener.h"
|
2000-05-11 19:17:07 +00:00
|
|
|
#include "nsIDOMPkcs11.h"
|
1999-10-18 15:06:38 +00:00
|
|
|
#include "nsIEventQueueService.h"
|
2000-04-24 04:41:27 +00:00
|
|
|
#include "nsIEventStateManager.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIHTTPProtocolHandler.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2000-03-31 03:33:49 +00:00
|
|
|
#include "nsIJSContextStack.h"
|
2000-02-08 22:45:45 +00:00
|
|
|
#include "nsIMarkupDocumentViewer.h"
|
2000-03-29 09:48:41 +00:00
|
|
|
#include "nsIPref.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIPresShell.h"
|
1998-07-24 05:05:42 +00:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
1999-07-01 19:38:49 +00:00
|
|
|
#include "nsIPrompt.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIScriptGlobalObjectOwner.h"
|
1999-07-07 07:50:03 +00:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsISelectionController.h"
|
2000-09-14 11:45:01 +00:00
|
|
|
#include "nsISelection.h"
|
2000-04-28 14:02:29 +00:00
|
|
|
#include "nsIFrameSelection.h"
|
2000-08-22 03:51:17 +00:00
|
|
|
#include "nsISidebar.h" // XXX for sidebar HACK, see bug 20721
|
2000-08-07 20:55:36 +00:00
|
|
|
#include "nsIPrompt.h"
|
2000-04-24 04:41:27 +00:00
|
|
|
#include "nsIStyleContext.h"
|
2000-02-08 13:40:10 +00:00
|
|
|
#include "nsIWebNavigation.h"
|
|
|
|
#include "nsIWebBrowser.h"
|
|
|
|
#include "nsIWebBrowserChrome.h"
|
|
|
|
#include "nsIWebShell.h"
|
2000-05-17 06:38:43 +00:00
|
|
|
#include "nsIComputedDOMStyle.h"
|
2000-05-11 19:17:07 +00:00
|
|
|
#include "nsDOMCID.h"
|
2000-05-03 13:03:17 +00:00
|
|
|
#include "nsDOMError.h"
|
1999-04-20 19:41:17 +00:00
|
|
|
|
2000-09-22 05:02:20 +00:00
|
|
|
// XXX An unfortunate dependency exists here (two XUL files).
|
2000-02-11 00:57:54 +00:00
|
|
|
#include "nsIDOMXULDocument.h"
|
|
|
|
#include "nsIDOMXULCommandDispatcher.h"
|
2000-09-22 05:02:20 +00:00
|
|
|
|
2000-09-08 06:59:14 +00:00
|
|
|
#include "nsIBindingManager.h"
|
2000-09-22 05:02:20 +00:00
|
|
|
#include "nsIXBLService.h"
|
|
|
|
|
2000-02-11 00:57:54 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
// CIDs
|
1999-10-18 15:06:38 +00:00
|
|
|
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
1999-04-28 20:33:43 +00:00
|
|
|
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
1999-12-22 22:42:06 +00:00
|
|
|
static NS_DEFINE_IID(kCookieServiceCID, NS_COOKIESERVICE_CID);
|
2000-02-08 13:40:10 +00:00
|
|
|
static NS_DEFINE_CID(kHTTPHandlerCID, NS_IHTTPHANDLER_CID);
|
|
|
|
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
|
2000-08-22 03:51:17 +00:00
|
|
|
static NS_DEFINE_CID(kCharsetConverterManagerCID,
|
|
|
|
NS_ICHARSETCONVERTERMANAGER_CID);
|
2000-05-11 19:17:07 +00:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
static const char *kCryptoContractID = NS_CRYPTO_CONTRACTID;
|
|
|
|
static const char *kPkcs11ContractID = NS_PKCS11_CONTRACTID;
|
1999-10-14 10:58:25 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** GlobalWindowImpl: Object Management
|
|
|
|
//*****************************************************************************
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
GlobalWindowImpl::GlobalWindowImpl() :
|
|
|
|
mScriptObject(nsnull),
|
|
|
|
mNavigator(nsnull), mScreen(nsnull), mHistory(nsnull), mFrames(nsnull),
|
|
|
|
mLocation(nsnull), mMenubar(nsnull), mToolbar(nsnull), mLocationbar(nsnull),
|
|
|
|
mPersonalbar(nsnull), mStatusbar(nsnull), mScrollbars(nsnull),
|
2000-09-15 19:22:03 +00:00
|
|
|
mTimeouts(nsnull), mTimeoutInsertionPoint(&mTimeouts), mRunningTimeout(nsnull),
|
2000-08-22 03:51:17 +00:00
|
|
|
mTimeoutPublicIdCounter(1), mTimeoutFiringDepth(0),
|
|
|
|
mFirstDocumentLoad(PR_TRUE), mGlobalObjectOwner(nsnull), mDocShell(nsnull),
|
|
|
|
mChromeEventHandler(nsnull)
|
1999-12-17 00:50:17 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INIT_REFCNT();
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
GlobalWindowImpl::~GlobalWindowImpl()
|
|
|
|
{
|
|
|
|
CleanUp();
|
1999-12-17 00:50:17 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
void GlobalWindowImpl::CleanUp()
|
|
|
|
{
|
2000-06-06 08:07:23 +00:00
|
|
|
if (mContext)
|
|
|
|
mContext->RemoveReference(&mScriptObject, mScriptObject);
|
2000-08-22 03:51:17 +00:00
|
|
|
mContext = nsnull; // Forces Release
|
|
|
|
mDocument = nsnull; // Forces Release
|
|
|
|
NS_IF_RELEASE(mNavigator);
|
|
|
|
NS_IF_RELEASE(mScreen);
|
|
|
|
NS_IF_RELEASE(mHistory);
|
|
|
|
NS_IF_RELEASE(mMenubar);
|
|
|
|
NS_IF_RELEASE(mToolbar);
|
|
|
|
NS_IF_RELEASE(mLocationbar);
|
|
|
|
NS_IF_RELEASE(mPersonalbar);
|
|
|
|
NS_IF_RELEASE(mStatusbar);
|
|
|
|
NS_IF_RELEASE(mScrollbars);
|
|
|
|
NS_IF_RELEASE(mLocation);
|
|
|
|
NS_IF_RELEASE(mFrames);
|
|
|
|
mOpener = nsnull; // Forces Release
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsISupports
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
2000-02-08 13:40:10 +00:00
|
|
|
|
1998-07-16 01:16:47 +00:00
|
|
|
NS_IMPL_ADDREF(GlobalWindowImpl)
|
|
|
|
NS_IMPL_RELEASE(GlobalWindowImpl)
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(GlobalWindowImpl)
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptGlobalObject)
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowInternal)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMWindow)
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIJSScriptObject)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventReceiver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsPIDOMWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2000-08-29 23:45:47 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowEventOwner)
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIScriptObjectOwner
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScriptObject(nsIScriptContext* aContext,
|
|
|
|
void **aScriptObject)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aScriptObject);
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
if (!mScriptObject) {
|
|
|
|
res = NS_NewScriptWindow(aContext, NS_STATIC_CAST(nsIDOMWindow *, this),
|
1998-07-21 16:41:42 +00:00
|
|
|
nsnull, &mScriptObject);
|
2000-08-22 03:51:17 +00:00
|
|
|
aContext->AddNamedReference(&mScriptObject, mScriptObject,
|
1998-08-20 22:25:21 +00:00
|
|
|
"window_object");
|
2000-07-28 12:18:29 +00:00
|
|
|
#if 0
|
2000-08-22 03:51:17 +00:00
|
|
|
// This code is useful for debugging leaks of global window objects
|
|
|
|
// that are caused by leaked GC roots. To use it, #define
|
|
|
|
// GC_MARK_DEBUG at the top of js/src/jsgc.c and uncomment this
|
|
|
|
// block. The JS engine will then show why a global window is
|
|
|
|
// not being garbage collected.
|
|
|
|
extern void *js_LiveThingToFind;
|
|
|
|
static int count = 0;
|
|
|
|
if (++count == 2) {
|
|
|
|
js_LiveThingToFind = mScriptObject;
|
|
|
|
}
|
2000-07-28 12:18:29 +00:00
|
|
|
#endif
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
*aScriptObject = mScriptObject;
|
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetScriptObject(void *aScriptObject)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mScriptObject = aScriptObject;
|
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIScriptGlobalObject
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetContext(nsIScriptContext* aContext)
|
1999-05-14 03:10:51 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
// if setting the context to null, then we won't get to clean up the
|
|
|
|
// named reference, so do it now
|
|
|
|
if (!aContext) {
|
|
|
|
NS_WARNING("Possibly early removal of script object, see bug #41608");
|
|
|
|
mContext->RemoveReference(&mScriptObject, mScriptObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
mContext = aContext;
|
|
|
|
return NS_OK;
|
1999-05-14 03:10:51 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetContext(nsIScriptContext ** aContext)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
*aContext = mContext;
|
|
|
|
NS_IF_ADDREF(*aContext);
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-07-27 20:51:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetNewDocument(nsIDOMDocument* aDocument)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-09-20 23:38:28 +00:00
|
|
|
if (!aDocument) {
|
|
|
|
if (mDocument) {
|
|
|
|
// Cache the old principal now that the document is being removed.
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
doc->GetPrincipal(getter_AddRefs(mDocumentPrincipal));
|
2000-09-20 23:38:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// let go of the old cached principal
|
|
|
|
mDocumentPrincipal = nsnull;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Always clear watchpoints, to deal with two cases:
|
|
|
|
// 1. The first document for this window is loading, and a miscreant has
|
|
|
|
// preset watchpoints on the window object in order to attack the new
|
|
|
|
// document's privileged information.
|
|
|
|
// 2. A document loaded and used watchpoints on its own window, leaving
|
|
|
|
// them set until the next document loads. We must clean up window
|
|
|
|
// watchpoints here.
|
|
|
|
// Watchpoints set on document and subordinate objects are all cleared
|
|
|
|
// when those sub-window objects are finalized, after JS_ClearScope and
|
|
|
|
// a GC run that finds them to be garbage.
|
|
|
|
|
2000-08-31 03:10:52 +00:00
|
|
|
if (mContext && mScriptObject)
|
|
|
|
::JS_ClearWatchPointsForObject((JSContext *) mContext->GetNativeContext(),
|
|
|
|
(JSObject *) mScriptObject);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
if (mFirstDocumentLoad) {
|
2000-09-22 05:02:20 +00:00
|
|
|
if (aDocument) {
|
2000-09-14 06:18:09 +00:00
|
|
|
mFirstDocumentLoad = PR_FALSE;
|
2000-09-22 05:02:20 +00:00
|
|
|
}
|
2000-09-14 06:18:09 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
mDocument = aDocument;
|
2000-09-22 05:02:20 +00:00
|
|
|
|
|
|
|
if (mDocument) {
|
|
|
|
// Get our private root. If it is equal to us, then we
|
|
|
|
// need to attach our global key bindings that handle
|
|
|
|
// browser scrolling and other browser commands.
|
|
|
|
nsCOMPtr<nsIDOMWindowInternal> internal;
|
|
|
|
GetPrivateRoot(getter_AddRefs(internal));
|
|
|
|
nsCOMPtr<nsIDOMWindowInternal> us(do_QueryInterface((nsIDOMWindow*)this));
|
|
|
|
if (internal == us) {
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsIXBLService, xblService, "@mozilla.org/xbl;1", &rv);
|
|
|
|
if (xblService) {
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(internal));
|
|
|
|
xblService->AttachGlobalKeyHandler(rec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-10-06 00:22:56 +00:00
|
|
|
/* No mDocShell means we've already been partially closed down.
|
|
|
|
When that happens, setting status isn't a big requirement,
|
|
|
|
so don't. (Doesn't happen under normal circumstances, but
|
|
|
|
bug 49615 describes a case.) */
|
|
|
|
if (mDocShell) {
|
|
|
|
SetStatus(nsString());
|
|
|
|
SetDefaultStatus(nsString());
|
|
|
|
}
|
2000-08-29 02:04:44 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mDocument) {
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
nsCOMPtr<nsIURI> docURL;
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (doc) {
|
|
|
|
docURL = dont_AddRef(doc->GetDocumentURL());
|
|
|
|
doc = nsnull; // Forces release now
|
|
|
|
}
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (docURL) {
|
|
|
|
char *str;
|
|
|
|
docURL->GetSpec(&str);
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsAutoString url;
|
|
|
|
url.AssignWithConversion(str);
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
//about:blank URL's do not have ClearScope called on page change.
|
|
|
|
if (!url.EqualsWithConversion("about:blank")) {
|
|
|
|
ClearAllTimeouts();
|
2000-08-09 03:30:46 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mSidebar) {
|
|
|
|
mSidebar->SetWindow(nsnull);
|
|
|
|
mSidebar = nsnull;
|
2000-08-09 03:30:46 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mListenerManager)
|
|
|
|
mListenerManager->RemoveAllListeners(PR_FALSE);
|
|
|
|
|
2000-08-26 23:35:50 +00:00
|
|
|
if (mContext && mScriptObject) {
|
|
|
|
// if (mContext && mScriptObject && aDocument) {
|
|
|
|
// not doing this unless there's a new document prevents a closed window's
|
|
|
|
// JS properties from going away (that's good) and causes everything,
|
|
|
|
// and I mean everything, to be leaked (that's bad)
|
2000-08-22 03:51:17 +00:00
|
|
|
::JS_ClearScope((JSContext *) mContext->GetNativeContext(),
|
|
|
|
(JSObject *) mScriptObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsCRT::free(str);
|
2000-08-09 03:30:46 +00:00
|
|
|
}
|
1999-06-15 03:17:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
//XXX Should this be outside the about:blank clearscope exception?
|
|
|
|
mDocument = nsnull; // Forces Release
|
|
|
|
}
|
|
|
|
|
2000-09-14 06:18:09 +00:00
|
|
|
if (mContext && aDocument) {
|
2000-08-22 03:51:17 +00:00
|
|
|
// Add an extra ref in case we release mContext during GC.
|
|
|
|
nsCOMPtr<nsIScriptContext> kungFuDeathGrip = mContext;
|
|
|
|
kungFuDeathGrip->GC();
|
|
|
|
}
|
1999-11-16 23:11:50 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
mDocument = aDocument;
|
1999-05-27 21:06:51 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mDocument && mContext)
|
|
|
|
mContext->InitContext(this);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-06-09 19:04:18 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetDocShell(nsIDocShell* aDocShell)
|
|
|
|
{
|
2000-09-22 05:02:20 +00:00
|
|
|
if (aDocShell == mDocShell)
|
|
|
|
return NS_OK;
|
|
|
|
|
2000-08-26 23:35:50 +00:00
|
|
|
/* SetDocShell(nsnull) means the window is being torn down. Set the
|
|
|
|
"closed" JS property, Drop our reference to the script context,
|
|
|
|
allowing it to be deleted later, and hand off our reference
|
|
|
|
to the script object (held via a named JS root) to the context
|
|
|
|
so it will be unrooted later. Meanwhile, keep our weak reference
|
|
|
|
to the script object so it can be retrieved later, as the JS glue
|
|
|
|
is wont to do. */
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!aDocShell && mContext) {
|
|
|
|
if (mScriptObject) {
|
|
|
|
// Indicate that the window is now closed. Since we've
|
|
|
|
// cleared scope, we have to explicitly set a property.
|
|
|
|
jsval val = BOOLEAN_TO_JSVAL(JS_TRUE);
|
|
|
|
::JS_SetProperty((JSContext *) mContext->GetNativeContext(),
|
|
|
|
(JSObject *) mScriptObject, "closed", &val);
|
2000-08-26 23:35:50 +00:00
|
|
|
// hand off our reference to mContext
|
|
|
|
mContext->SetRootedScriptObject(mScriptObject);
|
2000-08-22 03:51:17 +00:00
|
|
|
mContext->RemoveReference(&mScriptObject, mScriptObject);
|
|
|
|
}
|
|
|
|
mContext = nsnull; // force release now
|
|
|
|
}
|
|
|
|
mDocShell = aDocShell; // Weak Reference
|
|
|
|
|
|
|
|
if (mLocation)
|
|
|
|
mLocation->SetDocShell(aDocShell);
|
|
|
|
if (mHistory)
|
|
|
|
mHistory->SetDocShell(aDocShell);
|
|
|
|
if (mFrames)
|
|
|
|
mFrames->SetDocShell(aDocShell);
|
|
|
|
if (mScreen)
|
|
|
|
mScreen->SetDocShell(aDocShell);
|
|
|
|
|
|
|
|
if (mDocShell) {
|
|
|
|
// tell our member elements about the new browserwindow
|
|
|
|
if (mMenubar) {
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
GetWebBrowserChrome(getter_AddRefs(browserChrome));
|
|
|
|
mMenubar->SetWebBrowserChrome(browserChrome);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get our enclosing chrome shell and retrieve its global window impl, so
|
|
|
|
// that we can do some forwarding to the chrome document.
|
|
|
|
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
|
|
|
|
mDocShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
|
|
|
|
if (chromeEventHandler)
|
|
|
|
mChromeEventHandler = chromeEventHandler.get(); // ref
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetDocShell(nsIDocShell ** aDocShell)
|
1999-02-10 16:25:11 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
*aDocShell = mDocShell;
|
|
|
|
NS_IF_ADDREF(*aDocShell);
|
|
|
|
return NS_OK;
|
1999-02-10 16:25:11 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetOpenerWindow(nsIDOMWindowInternal* aOpener)
|
1998-09-03 01:19:58 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mOpener = aOpener;
|
|
|
|
return NS_OK;
|
1999-12-03 09:24:22 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetGlobalObjectOwner(nsIScriptGlobalObjectOwner* aOwner)
|
1999-12-03 09:24:22 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mGlobalObjectOwner = aOwner; // Note this is supposed to be a weak ref.
|
|
|
|
return NS_OK;
|
1999-12-03 09:24:22 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetGlobalObjectOwner(nsIScriptGlobalObjectOwner ** aOwner)
|
1999-12-03 09:24:22 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aOwner);
|
1999-12-03 09:24:22 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aOwner = mGlobalObjectOwner;
|
|
|
|
NS_IF_ADDREF(*aOwner);
|
|
|
|
return NS_OK;
|
1998-09-03 01:19:58 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::HandleDOMEvent(nsIPresContext* aPresContext,
|
|
|
|
nsEvent* aEvent,
|
|
|
|
nsIDOMEvent** aDOMEvent,
|
|
|
|
PRUint32 aFlags,
|
|
|
|
nsEventStatus* aEventStatus)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult ret = NS_OK;
|
|
|
|
nsIDOMEvent *domEvent = nsnull;
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
/* mChromeEventHandler and mContext go dangling in the middle of this
|
2000-02-08 13:40:10 +00:00
|
|
|
function under some circumstances (events that destroy the window)
|
|
|
|
without this addref. */
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIChromeEventHandler> kungFuDeathGrip1(mChromeEventHandler);
|
|
|
|
nsCOMPtr<nsIScriptContext> kungFuDeathGrip2(mContext);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_EVENT_FLAG_INIT & aFlags) {
|
|
|
|
if (!aDOMEvent) {
|
|
|
|
aDOMEvent = &domEvent;
|
|
|
|
}
|
|
|
|
aEvent->flags = aFlags;
|
|
|
|
aFlags &= ~(NS_EVENT_FLAG_CANT_BUBBLE | NS_EVENT_FLAG_CANT_CANCEL);
|
2000-09-08 06:59:14 +00:00
|
|
|
|
|
|
|
// Execute bindingdetached handlers before we tear ourselves
|
|
|
|
// down.
|
|
|
|
if (aEvent->message == NS_PAGE_UNLOAD && mDocument) {
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
nsCOMPtr<nsIBindingManager> bindingManager;
|
|
|
|
doc->GetBindingManager(getter_AddRefs(bindingManager));
|
|
|
|
if (bindingManager)
|
|
|
|
bindingManager->ExecuteDetachedHandlers();
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Capturing stage
|
|
|
|
if ((NS_EVENT_FLAG_BUBBLE != aFlags) && mChromeEventHandler) {
|
|
|
|
// Check chrome document capture here.
|
2000-10-05 21:40:13 +00:00
|
|
|
// XXX The chrome can not handle this, see bug 51211
|
|
|
|
if (aEvent->message != NS_IMAGE_LOAD) {
|
|
|
|
mChromeEventHandler->HandleChromeEvent(aPresContext, aEvent, aDOMEvent,
|
|
|
|
NS_EVENT_FLAG_CAPTURE,
|
|
|
|
aEventStatus);
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Local handling stage
|
|
|
|
if (mListenerManager && !(aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) &&
|
|
|
|
!((NS_EVENT_FLAG_BUBBLE & aFlags) &&
|
|
|
|
(NS_EVENT_FLAG_CANT_BUBBLE & aEvent->flags))) {
|
|
|
|
aEvent->flags |= aFlags;
|
|
|
|
mListenerManager->HandleEvent(aPresContext, aEvent, aDOMEvent, this,
|
|
|
|
aFlags, aEventStatus);
|
|
|
|
aEvent->flags &= ~aFlags;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Bubbling stage
|
|
|
|
if ((NS_EVENT_FLAG_CAPTURE != aFlags) && mChromeEventHandler) {
|
|
|
|
// Bubble to a chrome document if it exists
|
|
|
|
// XXX Need a way to know if an event should really bubble or not.
|
|
|
|
// For now filter out load and unload, since they cause problems.
|
|
|
|
if ((aEvent->message != NS_PAGE_LOAD) &&
|
|
|
|
(aEvent->message != NS_PAGE_UNLOAD) &&
|
2000-09-07 20:37:01 +00:00
|
|
|
(aEvent->message != NS_IMAGE_LOAD) &&
|
2000-08-22 03:51:17 +00:00
|
|
|
(aEvent->message != NS_FOCUS_CONTENT) &&
|
|
|
|
(aEvent->message != NS_BLUR_CONTENT)) {
|
|
|
|
mChromeEventHandler->HandleChromeEvent(aPresContext, aEvent,
|
|
|
|
aDOMEvent, NS_EVENT_FLAG_BUBBLE,
|
|
|
|
aEventStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_EVENT_FLAG_INIT & aFlags) {
|
|
|
|
// We're leaving the DOM event loop so if we created an event, release here.
|
|
|
|
if (*aDOMEvent) {
|
|
|
|
nsrefcnt rc;
|
|
|
|
NS_RELEASE2(*aDOMEvent, rc);
|
|
|
|
if (rc) {
|
|
|
|
// Okay, so someone in the DOM loop (a listener, JS object) still has
|
|
|
|
// a ref to the DOM Event but the internal data hasn't been malloc'd.
|
|
|
|
// Force a copy of the data here so the DOM Event is still valid.
|
|
|
|
nsCOMPtr<nsIPrivateDOMEvent>
|
|
|
|
privateEvent(do_QueryInterface(*aDOMEvent));
|
|
|
|
if (privateEvent)
|
|
|
|
privateEvent->DuplicatePrivateData();
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
aDOMEvent = nsnull;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return ret;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIScriptObjectPrincipal
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPrincipal(nsIPrincipal** result)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-09-20 23:38:28 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(result);
|
2000-09-19 05:21:00 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
if (mDocument) {
|
|
|
|
// If we have a document, get the principal from the document
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
2000-09-19 05:21:00 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
return doc->GetPrincipal(result);
|
|
|
|
}
|
2000-09-19 05:21:00 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
if (mDocumentPrincipal) {
|
|
|
|
*result = mDocumentPrincipal;
|
|
|
|
NS_ADDREF(*result);
|
2000-09-19 05:21:00 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
return NS_OK;
|
2000-09-19 05:21:00 +00:00
|
|
|
}
|
2000-07-13 21:48:25 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
// If we don't have a principal and we don't have a document we
|
|
|
|
// ask the parent window for the principal. This can happen when
|
|
|
|
// loading a frameset that has a <frame src="javascript:xxx">, in
|
|
|
|
// that case the global window is used in JS before we've loaded
|
|
|
|
// a document into the window.
|
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
GetParent(getter_AddRefs(parent));
|
2000-07-13 21:48:25 +00:00
|
|
|
|
2000-09-20 23:38:28 +00:00
|
|
|
if (parent && (parent.get() != NS_STATIC_CAST(nsIDOMWindow *, this))) {
|
|
|
|
nsCOMPtr<nsIScriptObjectPrincipal> objPrincipal(do_QueryInterface(parent));
|
|
|
|
|
|
|
|
if (objPrincipal) {
|
|
|
|
return objPrincipal->GetPrincipal(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIDOMWindow
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetDocument(nsIDOMDocument** aDocument)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-09-01 01:54:35 +00:00
|
|
|
*aDocument = mDocument;
|
|
|
|
NS_IF_ADDREF(*aDocument);
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIDOMWindowInternal
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetWindow(nsIDOMWindowInternal** aWindow)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-09-01 01:54:35 +00:00
|
|
|
*aWindow = NS_STATIC_CAST(nsIDOMWindowInternal *, this);
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ADDREF(*aWindow);
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetSelf(nsIDOMWindowInternal** aWindow)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-09-01 01:54:35 +00:00
|
|
|
*aWindow = NS_STATIC_CAST(nsIDOMWindowInternal *, this);
|
|
|
|
NS_ADDREF(*aWindow);
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetNavigator(nsIDOMNavigator** aNavigator)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mNavigator) {
|
|
|
|
mNavigator = new NavigatorImpl();
|
|
|
|
NS_ENSURE_TRUE(mNavigator, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ADDREF(mNavigator);
|
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aNavigator = mNavigator;
|
|
|
|
NS_ADDREF(*aNavigator);
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScreen(nsIDOMScreen** aScreen)
|
1999-01-28 23:12:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mScreen && mDocShell) {
|
|
|
|
mScreen = new ScreenImpl(mDocShell);
|
|
|
|
NS_ENSURE_TRUE(mScreen, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ADDREF(mScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aScreen = mScreen;
|
|
|
|
NS_ADDREF(*aScreen);
|
|
|
|
return NS_OK;
|
1999-01-28 23:12:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetHistory(nsIDOMHistory** aHistory)
|
1999-01-28 23:12:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mHistory && mDocShell) {
|
|
|
|
mHistory = new HistoryImpl(mDocShell);
|
|
|
|
NS_ENSURE_TRUE(mHistory, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ADDREF(mHistory);
|
|
|
|
}
|
|
|
|
*aHistory = mHistory;
|
|
|
|
NS_ADDREF(*aHistory);
|
|
|
|
return NS_OK;
|
1999-01-28 23:12:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetParent(nsIDOMWindow** aParent)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aParent);
|
|
|
|
*aParent = nsnull;
|
|
|
|
if (!mDocShell)
|
|
|
|
return NS_OK;
|
1999-06-09 19:04:18 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parent;
|
|
|
|
docShellAsItem->GetSameTypeParent(getter_AddRefs(parent));
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (parent) {
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(parent));
|
|
|
|
NS_ENSURE_SUCCESS(CallQueryInterface(globalObject.get(), aParent),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
else {
|
2000-09-01 01:54:35 +00:00
|
|
|
*aParent = NS_STATIC_CAST(nsIDOMWindowInternal *, this);
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ADDREF(*aParent);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-06-09 19:04:18 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetTop(nsIDOMWindow** aTop)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult ret = NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aTop = nsnull;
|
|
|
|
if (mDocShell) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> root;
|
|
|
|
docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(root));
|
|
|
|
|
|
|
|
if (root) {
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(root));
|
|
|
|
CallQueryInterface(globalObject.get(), aTop);
|
|
|
|
}
|
|
|
|
}
|
1999-06-09 19:04:18 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
return ret;
|
1999-06-09 19:04:18 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Get_content(nsIDOMWindowInternal** aContent)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
*aContent = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> primaryContent;
|
|
|
|
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> domWindow(do_GetInterface(primaryContent));
|
2000-02-08 13:40:10 +00:00
|
|
|
*aContent = domWindow;
|
|
|
|
NS_IF_ADDREF(*aContent);
|
1999-06-09 19:04:18 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-16 07:13:59 +00:00
|
|
|
// XXX for sidebar HACK, see bug 20721
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetSidebar(nsISidebar** aSidebar)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mSidebar) {
|
2000-09-13 23:57:52 +00:00
|
|
|
mSidebar = do_CreateInstance(NS_SIDEBAR_CONTRACTID, &rv);
|
2000-02-16 07:13:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mSidebar) {
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIDOMWindowInternal *win = NS_STATIC_CAST(nsIDOMWindowInternal *, this);
|
2000-02-16 07:13:59 +00:00
|
|
|
/* no addref */
|
|
|
|
mSidebar->SetWindow(win);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aSidebar = mSidebar;
|
|
|
|
NS_IF_ADDREF(*aSidebar);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-08-09 21:12:21 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPrompter(nsIPrompt** aPrompt)
|
2000-08-07 20:55:36 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mDocShell)
|
2000-08-07 20:55:36 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(prompter, NS_ERROR_NO_INTERFACE);
|
|
|
|
|
|
|
|
NS_ADDREF(*aPrompt = prompter);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetMenubar(nsIDOMBarProp** aMenubar)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mMenubar) {
|
|
|
|
mMenubar = new MenubarPropImpl();
|
|
|
|
if (mMenubar) {
|
|
|
|
NS_ADDREF(mMenubar);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
if (mDocShell &&
|
|
|
|
NS_SUCCEEDED(GetWebBrowserChrome(getter_AddRefs(browserChrome)))) {
|
|
|
|
mMenubar-> SetWebBrowserChrome(browserChrome);
|
1999-06-19 22:15:14 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
1999-06-09 19:04:18 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aMenubar = mMenubar;
|
|
|
|
NS_IF_ADDREF(mMenubar);
|
|
|
|
return NS_OK;
|
1999-06-09 19:04:18 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetToolbar(nsIDOMBarProp** aToolbar)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mToolbar) {
|
|
|
|
mToolbar = new ToolbarPropImpl();
|
|
|
|
if (mToolbar) {
|
|
|
|
NS_ADDREF(mToolbar);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
if (mDocShell &&
|
|
|
|
NS_SUCCEEDED(GetWebBrowserChrome(getter_AddRefs(browserChrome)))) {
|
|
|
|
mToolbar->SetWebBrowserChrome(browserChrome);
|
1999-06-19 22:15:14 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
1999-06-09 19:04:18 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aToolbar = mToolbar;
|
|
|
|
NS_IF_ADDREF(mToolbar);
|
|
|
|
return NS_OK;
|
1999-06-09 19:04:18 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetLocationbar(nsIDOMBarProp** aLocationbar)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mLocationbar) {
|
|
|
|
mLocationbar = new LocationbarPropImpl();
|
|
|
|
if (mLocationbar) {
|
|
|
|
NS_ADDREF(mLocationbar);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
if (mDocShell &&
|
|
|
|
NS_SUCCEEDED(GetWebBrowserChrome(getter_AddRefs(browserChrome)))) {
|
|
|
|
mLocationbar->SetWebBrowserChrome(browserChrome);
|
1999-06-19 22:15:14 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
1999-06-09 19:04:18 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aLocationbar = mLocationbar;
|
|
|
|
NS_IF_ADDREF(mLocationbar);
|
|
|
|
return NS_OK;
|
1999-06-09 19:04:18 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPersonalbar(nsIDOMBarProp** aPersonalbar)
|
1999-06-09 19:04:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mPersonalbar) {
|
|
|
|
mPersonalbar = new PersonalbarPropImpl();
|
|
|
|
if (mPersonalbar) {
|
|
|
|
NS_ADDREF(mPersonalbar);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
if (mDocShell &&
|
|
|
|
NS_SUCCEEDED(GetWebBrowserChrome(getter_AddRefs(browserChrome)))) {
|
|
|
|
mPersonalbar->SetWebBrowserChrome(browserChrome);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aPersonalbar = mPersonalbar;
|
|
|
|
NS_IF_ADDREF(mPersonalbar);
|
|
|
|
return NS_OK;
|
1999-06-09 19:04:18 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetStatusbar(nsIDOMBarProp** aStatusbar)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mStatusbar) {
|
|
|
|
mStatusbar = new StatusbarPropImpl();
|
|
|
|
if (mStatusbar) {
|
|
|
|
NS_ADDREF(mStatusbar);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
if (mDocShell &&
|
|
|
|
NS_SUCCEEDED(GetWebBrowserChrome(getter_AddRefs(browserChrome)))) {
|
|
|
|
mStatusbar->SetWebBrowserChrome(browserChrome);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
1998-08-13 23:37:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aStatusbar = mStatusbar;
|
|
|
|
NS_IF_ADDREF(mStatusbar);
|
|
|
|
return NS_OK;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScrollbars(nsIDOMBarProp** aScrollbars)
|
1998-09-03 01:19:58 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mScrollbars) {
|
|
|
|
mScrollbars = new ScrollbarsPropImpl();
|
|
|
|
if (mScrollbars) {
|
|
|
|
NS_ADDREF(mScrollbars);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
if (mDocShell &&
|
|
|
|
NS_SUCCEEDED(GetWebBrowserChrome(getter_AddRefs(browserChrome)))) {
|
|
|
|
mScrollbars->SetWebBrowserChrome(browserChrome);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aScrollbars = mScrollbars;
|
|
|
|
NS_IF_ADDREF(mScrollbars);
|
|
|
|
return NS_OK;
|
1998-09-03 01:19:58 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetDirectories(nsIDOMBarProp** aDirectories)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return GetPersonalbar(aDirectories);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-08-15 00:13:51 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetClosed(PRBool* aClosed)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
*aClosed = !mDocShell;
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-12-17 22:25:22 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetFrames(nsIDOMWindowCollection** aFrames)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mFrames && mDocShell) {
|
|
|
|
mFrames = new nsDOMWindowList(mDocShell);
|
|
|
|
NS_ENSURE_TRUE(mFrames, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ADDREF(mFrames);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aFrames = NS_STATIC_CAST(nsIDOMWindowCollection *, mFrames);
|
|
|
|
NS_IF_ADDREF(mFrames);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
|
|
|
|
2000-05-11 19:17:07 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetCrypto(nsIDOMCrypto** aCrypto)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mCrypto) {
|
2000-09-13 23:57:52 +00:00
|
|
|
mCrypto = do_CreateInstance(kCryptoContractID, &rv);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-05-11 19:17:07 +00:00
|
|
|
*aCrypto = mCrypto;
|
2000-05-16 23:52:42 +00:00
|
|
|
NS_IF_ADDREF(*aCrypto);
|
|
|
|
return NS_OK;
|
2000-05-11 19:17:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPkcs11(nsIDOMPkcs11** aPkcs11)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mPkcs11) {
|
2000-09-13 23:57:52 +00:00
|
|
|
mPkcs11 = do_CreateInstance(kPkcs11ContractID, &rv);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-05-11 19:17:07 +00:00
|
|
|
*aPkcs11 = mPkcs11;
|
2000-05-16 23:52:42 +00:00
|
|
|
NS_IF_ADDREF(*aPkcs11);
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-05-11 19:17:07 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetControllers(nsIControllers** aResult)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mControllers) {
|
|
|
|
mControllers = do_CreateInstance(kXULControllersCID);
|
|
|
|
NS_ENSURE_TRUE(mControllers, NS_ERROR_FAILURE);
|
2000-02-15 01:08:04 +00:00
|
|
|
#ifdef DOM_CONTROLLER
|
2000-08-22 03:51:17 +00:00
|
|
|
// Add in the default controller
|
|
|
|
nsDOMWindowController *domController = new nsDOMWindowController(this);
|
|
|
|
if (domController) {
|
|
|
|
nsCOMPtr<nsIController> controller(domController);
|
|
|
|
mControllers->AppendController(controller);
|
|
|
|
}
|
2000-02-15 01:08:04 +00:00
|
|
|
#endif // DOM_CONTROLLER
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
*aResult = mControllers;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetOpener(nsIDOMWindowInternal** aOpener)
|
1998-08-13 04:34:53 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
*aOpener = mOpener;
|
|
|
|
NS_IF_ADDREF(*aOpener);
|
|
|
|
return NS_OK;
|
1998-08-13 04:34:53 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetOpener(nsIDOMWindowInternal* aOpener)
|
1998-08-07 04:45:03 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mOpener = aOpener;
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-06-15 03:17:11 +00:00
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetStatus(nsAWritableString& aStatus)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
aStatus = mStatus;
|
|
|
|
return NS_OK;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
1998-08-07 04:45:03 +00:00
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetStatus(const nsAReadableString& aStatus)
|
1999-06-26 21:48:29 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mStatus = aStatus;
|
1999-06-26 21:48:29 +00:00
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
GetWebBrowserChrome(getter_AddRefs(browserChrome));
|
|
|
|
if(browserChrome)
|
2000-09-13 03:24:57 +00:00
|
|
|
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT, nsPromiseFlatString(aStatus).get());
|
1999-06-26 21:48:29 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-06-26 21:48:29 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetDefaultStatus(nsAWritableString& aDefaultStatus)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
aDefaultStatus = mDefaultStatus;
|
|
|
|
return NS_OK;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetDefaultStatus(const nsAReadableString& aDefaultStatus)
|
1998-08-21 21:39:27 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mDefaultStatus = aDefaultStatus;
|
1998-08-21 21:39:27 +00:00
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome;
|
|
|
|
GetWebBrowserChrome(getter_AddRefs(browserChrome));
|
|
|
|
if(browserChrome)
|
2000-09-13 03:24:57 +00:00
|
|
|
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT_DEFAULT, nsPromiseFlatString(aDefaultStatus).get());
|
1998-08-21 21:39:27 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-08-21 21:39:27 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetName(nsAWritableString& aName)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsXPIDLString name;
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
if (docShellAsItem)
|
|
|
|
docShellAsItem->GetName(getter_Copies(name));
|
1998-08-13 23:37:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
aName.Assign(name);
|
|
|
|
return NS_OK;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetName(const nsAReadableString& aName)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
if (docShellAsItem)
|
2000-09-13 03:24:57 +00:00
|
|
|
result = docShellAsItem->SetName(nsPromiseFlatString(aName).get());
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetLocation(jsval* aLocation)
|
|
|
|
{
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
2000-08-29 00:14:23 +00:00
|
|
|
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
JSContext* cx;
|
|
|
|
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMLocation> location;
|
|
|
|
|
|
|
|
*aLocation = JSVAL_NULL;
|
|
|
|
GetLocation(getter_AddRefs(location));
|
|
|
|
if(location) {
|
|
|
|
nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(location));
|
|
|
|
if(owner) {
|
|
|
|
JSObject *object = nsnull;
|
|
|
|
nsCOMPtr<nsIScriptContext> scriptCX;
|
|
|
|
nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(scriptCX));
|
|
|
|
if(scriptCX &&
|
|
|
|
(NS_SUCCEEDED(owner->GetScriptObject(scriptCX, (void**)&object)))) {
|
|
|
|
// set the return value
|
|
|
|
*aLocation = OBJECT_TO_JSVAL(object);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetLocation(jsval aLocation)
|
|
|
|
{
|
|
|
|
nsresult result;
|
2000-09-08 04:21:29 +00:00
|
|
|
|
|
|
|
if (!mLocation && mDocShell) {
|
|
|
|
mLocation = new LocationImpl(mDocShell);
|
|
|
|
NS_IF_ADDREF(mLocation);
|
|
|
|
}
|
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
if (mLocation) {
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
2000-08-29 00:14:23 +00:00
|
|
|
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
JSContext* cx;
|
|
|
|
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
result = mLocation->SetHrefWithContext(cx, aLocation);
|
|
|
|
if (NS_FAILED(result)) return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetTitle(nsAWritableString& aTitle)
|
|
|
|
{
|
2000-10-03 13:35:30 +00:00
|
|
|
aTitle = mTitle;
|
2000-08-29 00:14:23 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle)
|
|
|
|
{
|
2000-10-03 13:35:30 +00:00
|
|
|
mTitle = aTitle;
|
|
|
|
if(mDocShell) {
|
2000-08-29 00:14:23 +00:00
|
|
|
// See if we're a chrome shell.
|
|
|
|
PRInt32 type;
|
2000-10-03 13:35:30 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
2000-08-29 00:14:23 +00:00
|
|
|
docShellAsItem->GetItemType(&type);
|
|
|
|
if(type == nsIDocShellTreeItem::typeChrome) {
|
2000-10-03 13:35:30 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
|
|
|
|
if(docShellAsWin) {
|
|
|
|
docShellAsWin->SetTitle(nsPromiseFlatString(mTitle));
|
2000-08-29 00:14:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetInnerWidth(PRInt32* aInnerWidth)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> parent;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
|
|
|
|
*aInnerWidth = 0;
|
|
|
|
if (docShellWin)
|
|
|
|
docShellWin->GetSize(aInnerWidth, nsnull);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-08-13 23:37:54 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetInnerWidth(PRInt32 aInnerWidth)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellParent;
|
|
|
|
docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent));
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// It's only valid to access this from a top window. Doesn't work from
|
|
|
|
// sub-frames.
|
|
|
|
if (docShellParent)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&aInnerWidth, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
|
|
|
|
PRInt32 cy = 0;
|
|
|
|
docShellAsWin->GetSize(nsnull, &cy);
|
|
|
|
NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, aInnerWidth, cy),
|
|
|
|
NS_ERROR_FAILURE);
|
1998-08-13 23:37:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetInnerHeight(PRInt32* aInnerHeight)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> parent;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
FlushPendingNotifications();
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
|
|
|
|
*aInnerHeight = 0;
|
|
|
|
if (docShellWin)
|
|
|
|
docShellWin->GetSize(nsnull, aInnerHeight);
|
1999-07-16 01:14:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetInnerHeight(PRInt32 aInnerHeight)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellParent;
|
|
|
|
docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent));
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// It's only valid to access this from a top window. Doesn't work from
|
|
|
|
// sub-frames.
|
|
|
|
if (docShellParent)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(nsnull, &aInnerHeight),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
|
|
|
|
PRInt32 cx = 0;
|
|
|
|
docShellAsWin->GetSize(&cx, nsnull);
|
|
|
|
NS_ENSURE_SUCCESS(treeOwner->
|
|
|
|
SizeShellTo(docShellAsItem, cx, aInnerHeight),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetOuterWidth(PRInt32* aOuterWidth)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1999-03-29 23:48:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
FlushPendingNotifications();
|
2000-02-11 07:14:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(aOuterWidth, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetOuterWidth(PRInt32 aOuterWidth)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&aOuterWidth, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 cy;
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(nsnull, &cy), NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetSize(aOuterWidth, cy, PR_TRUE),
|
|
|
|
NS_ERROR_FAILURE);
|
1999-07-28 07:03:29 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetOuterHeight(PRInt32* aOuterHeight)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
FlushPendingNotifications();
|
2000-02-11 07:14:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(nsnull, aOuterHeight),
|
|
|
|
NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetOuterHeight(PRInt32 aOuterHeight)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(nsnull, &aOuterHeight),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 cx;
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&cx, nsnull), NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetSize(cx, aOuterHeight, PR_TRUE),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScreenX(PRInt32* aScreenX)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
FlushPendingNotifications();
|
2000-02-11 07:14:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(aScreenX, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetScreenX(PRInt32 aScreenX)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(&aScreenX, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 y;
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(nsnull, &y),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(aScreenX, y),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScreenY(PRInt32* aScreenY)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
FlushPendingNotifications();
|
2000-02-11 07:14:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(nsnull, aScreenY),
|
|
|
|
NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetScreenY(PRInt32 aScreenY)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(nsnull, &aScreenY),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 x;
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, nsnull),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(x, aScreenY),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-06-21 00:20:39 +00:00
|
|
|
nsresult
|
2000-08-22 03:51:17 +00:00
|
|
|
GlobalWindowImpl::CheckSecurityWidthAndHeight(PRInt32* aWidth,
|
|
|
|
PRInt32* aHeight)
|
2000-06-21 00:20:39 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
// This one is easy. Just ensure the variable is greater than 100;
|
2000-06-21 00:20:39 +00:00
|
|
|
if ((aWidth && *aWidth < 100) || (aHeight && *aHeight < 100)) {
|
2000-08-22 03:51:17 +00:00
|
|
|
// Check security state for use in determing window dimensions
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager>
|
2000-09-13 23:57:52 +00:00
|
|
|
securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
|
2000-06-21 00:20:39 +00:00
|
|
|
NS_ENSURE_TRUE(securityManager, NS_ERROR_FAILURE);
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool enabled;
|
|
|
|
nsresult res =
|
|
|
|
securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(res) || !enabled) {
|
|
|
|
//sec check failed
|
|
|
|
if (aWidth && *aWidth < 100) {
|
|
|
|
*aWidth = 100;
|
|
|
|
}
|
|
|
|
if (aHeight && *aHeight < 100) {
|
|
|
|
*aHeight = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
GlobalWindowImpl::CheckSecurityLeftAndTop(PRInt32* aLeft, PRInt32* aTop)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
// This one is harder. We have to get the screen size and window dimensions.
|
2000-06-21 00:20:39 +00:00
|
|
|
PRInt32 screenWidth = 0, screenHeight = 0;
|
|
|
|
PRInt32 winWidth, winHeight;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Check security state for use in determing window dimensions
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager>
|
2000-09-13 23:57:52 +00:00
|
|
|
securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
|
2000-06-21 00:20:39 +00:00
|
|
|
NS_ENSURE_TRUE(securityManager, NS_ERROR_FAILURE);
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool enabled;
|
|
|
|
nsresult res =
|
|
|
|
securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
2000-06-21 00:20:39 +00:00
|
|
|
if (NS_FAILED(res)) {
|
2000-08-22 03:51:17 +00:00
|
|
|
enabled = PR_FALSE;
|
2000-06-21 00:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!enabled) {
|
2000-08-22 03:51:17 +00:00
|
|
|
// Get the screen dimensions
|
|
|
|
// XXX This should use nsIScreenManager once its fully fleshed out.
|
2000-06-21 00:20:39 +00:00
|
|
|
nsCOMPtr<nsIDOMScreen> screen;
|
|
|
|
if (NS_SUCCEEDED(GetScreen(getter_AddRefs(screen)))) {
|
2000-08-22 03:51:17 +00:00
|
|
|
screen->GetAvailWidth(&screenWidth);
|
|
|
|
screen->GetAvailHeight(&screenHeight);
|
2000-06-21 00:20:39 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Get the window size
|
2000-06-21 00:20:39 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
FlushPendingNotifications();
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&winWidth, &winHeight),
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
|
|
|
if (aLeft) {
|
2000-08-22 03:51:17 +00:00
|
|
|
*aLeft =
|
|
|
|
screenWidth < *aLeft + winWidth ? screenWidth - winWidth : *aLeft;
|
2000-06-21 00:20:39 +00:00
|
|
|
*aLeft = *aLeft < 0 ? 0 : *aLeft;
|
|
|
|
}
|
|
|
|
if (aTop) {
|
2000-08-22 03:51:17 +00:00
|
|
|
*aTop =
|
|
|
|
screenHeight < *aTop + winHeight ? screenHeight - winHeight : *aTop;
|
2000-06-21 00:20:39 +00:00
|
|
|
*aTop = *aTop < 0 ? 0 : *aTop;
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-06-21 00:20:39 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPageXOffset(PRInt32* aPageXOffset)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return GetScrollX(aPageXOffset);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetPageXOffset(PRInt32 aPageXOffset)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPageYOffset(PRInt32* aPageYOffset)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return GetScrollY(aPageYOffset);
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetPageYOffset(PRInt32 aPageYOffset)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScrollX(PRInt32* aScrollX)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aScrollX);
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsIScrollableView *view; // no addref/release for views
|
|
|
|
float p2t, t2p;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aScrollX = 0;
|
2000-04-02 13:50:36 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
FlushPendingNotifications();
|
2000-02-11 07:14:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
GetScrollInfo(&view, &p2t, &t2p);
|
|
|
|
if (view) {
|
|
|
|
nscoord xPos, yPos;
|
|
|
|
result = view->GetScrollPosition(xPos, yPos);
|
|
|
|
*aScrollX = NSTwipsToIntPixels(xPos, t2p);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetScrollY(PRInt32* aScrollY)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aScrollY);
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsIScrollableView *view; // no addref/release for views
|
|
|
|
float p2t, t2p;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aScrollY = 0;
|
2000-04-02 13:50:36 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
FlushPendingNotifications();
|
2000-02-11 07:14:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
GetScrollInfo(&view, &p2t, &t2p);
|
|
|
|
if (view) {
|
|
|
|
nscoord xPos, yPos;
|
|
|
|
result = view->GetScrollPosition(xPos, yPos);
|
|
|
|
*aScrollY = NSTwipsToIntPixels(yPos, t2p);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
Beginnings of massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:19:03 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetLength(PRUint32* aLength)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowCollection> frames;
|
|
|
|
if (NS_SUCCEEDED(GetFrames(getter_AddRefs(frames))) && frames) {
|
|
|
|
return frames->GetLength(aLength);
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
Beginnings of massive landing of joki changes.
Relevant nsbeta3+ bugs 43309, 44503, 2634, 2504,5981, 24698, 25758, 33577,
36062, 36217, 41191, 41491, 42356, 42829, 43016
r=saari (joki code). also been tested by heikki and bryner
2000-08-08 21:19:03 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Dump(const nsAReadableString& aStr)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-23 17:27:06 +00:00
|
|
|
char *cstr = ToNewUTF8String(aStr);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
1999-08-03 12:43:06 +00:00
|
|
|
#ifdef XP_MAC
|
2000-08-22 03:51:17 +00:00
|
|
|
// have to convert \r to \n so that printing to the console works
|
|
|
|
char *c = cstr, *cEnd = cstr + aStr.Length();
|
|
|
|
while (c < cEnd) {
|
|
|
|
if (*c == '\r')
|
|
|
|
*c = '\n';
|
|
|
|
c++;
|
|
|
|
}
|
1999-08-03 12:43:06 +00:00
|
|
|
#endif
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (cstr) {
|
|
|
|
printf("%s", cstr);
|
|
|
|
nsCRT::free(cstr);
|
|
|
|
}
|
|
|
|
|
1998-07-16 01:16:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Alert(JSContext* cx, jsval* argv, PRUint32 argc)
|
2000-08-22 03:51:17 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mDocShell);
|
1999-06-18 17:34:08 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsAutoString str;
|
1999-06-11 23:57:25 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (argc > 0)
|
|
|
|
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
1999-11-16 20:05:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return prompter->Alert(nsnull, str.GetUnicode());
|
1999-06-11 23:57:25 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Confirm(JSContext* cx, jsval* argv,
|
2000-08-22 03:51:17 +00:00
|
|
|
PRUint32 argc, PRBool* aReturn)
|
1999-06-11 23:57:25 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_STATE(mDocShell);
|
|
|
|
|
|
|
|
nsAutoString str;
|
1999-06-11 23:57:25 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aReturn = PR_FALSE;
|
|
|
|
if (argc > 0)
|
|
|
|
nsJSUtils::nsConvertJSValToString(str, cx, argv[0]);
|
1999-11-16 20:05:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return prompter->Confirm(nsnull, str.GetUnicode(), aReturn);
|
1999-06-11 23:57:25 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Prompt(JSContext* cx, jsval* argv,
|
|
|
|
PRUint32 argc, jsval* aReturn)
|
1999-06-11 23:57:25 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_STATE(mDocShell);
|
1999-06-11 23:57:25 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult ret = NS_OK;
|
|
|
|
nsAutoString message, initial, title;
|
|
|
|
PRUint32 savePassword = nsIPrompt::SAVE_PASSWORD_NEVER;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (argc > 0) {
|
|
|
|
nsJSUtils::nsConvertJSValToString(message, cx, argv[0]);
|
2000-06-17 01:57:36 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (argc > 1) {
|
|
|
|
nsJSUtils::nsConvertJSValToString(initial, cx, argv[1]);
|
2000-06-17 01:57:36 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (argc > 2) {
|
|
|
|
nsJSUtils::nsConvertJSValToString(title, cx, argv[2]);
|
|
|
|
|
|
|
|
if (argc > 3) {
|
|
|
|
nsJSUtils::nsConvertJSValToUint32(&savePassword, cx, argv[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-16 20:05:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPrompt> prompter(do_GetInterface(mDocShell));
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_TRUE(prompter, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool b;
|
|
|
|
PRUnichar *uniResult = nsnull;
|
|
|
|
ret = prompter->Prompt(title.GetUnicode(), message.GetUnicode(), nsnull,
|
|
|
|
savePassword, initial.GetUnicode(), &uniResult, &b);
|
2000-06-09 00:14:44 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_SUCCEEDED(ret) && uniResult && b) {
|
|
|
|
JSString *jsret =
|
|
|
|
::JS_NewUCStringCopyZ(cx, NS_REINTERPRET_CAST(const jschar *, uniResult));
|
|
|
|
*aReturn = STRING_TO_JSVAL(jsret);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aReturn = JSVAL_NULL;
|
|
|
|
}
|
2000-06-09 00:14:44 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (uniResult)
|
|
|
|
nsMemory::Free(uniResult);
|
1999-11-16 20:05:21 +00:00
|
|
|
|
1998-11-24 07:44:39 +00:00
|
|
|
return ret;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Focus()
|
1998-09-03 01:19:58 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
if (treeOwnerAsWin)
|
|
|
|
treeOwnerAsWin->SetVisibility(PR_TRUE);
|
1999-07-02 19:43:26 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
if (mDocShell)
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
if (presShell) {
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
if (vm) {
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
vm->GetWidget(getter_AddRefs(widget));
|
|
|
|
if (widget)
|
|
|
|
result = widget->SetFocus();
|
|
|
|
}
|
|
|
|
}
|
1998-09-03 01:19:58 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1998-09-03 01:19:58 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Blur()
|
2000-01-26 22:48:16 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem>
|
|
|
|
docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
if (docShellAsItem) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parent;
|
|
|
|
// Parent regardless of chrome or content boundary
|
|
|
|
docShellAsItem->GetParent(getter_AddRefs(parent));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> newFocusWin;
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
newFocusWin = do_QueryInterface(parent);
|
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
newFocusWin = do_QueryInterface(treeOwner);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newFocusWin)
|
|
|
|
newFocusWin->SetFocus();
|
|
|
|
}
|
2000-01-26 22:48:16 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-01-26 22:48:16 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Back()
|
1998-09-04 00:46:06 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
1999-12-17 00:50:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return webNav->GoBack();
|
1998-09-04 00:46:06 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Forward()
|
1999-10-28 14:12:56 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
1999-10-28 14:12:56 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return webNav->GoForward();
|
1999-10-28 14:12:56 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Home()
|
1999-10-28 14:12:56 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mDocShell)
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefServiceCID));
|
|
|
|
NS_ENSURE_TRUE(prefs, NS_ERROR_FAILURE);
|
1999-10-28 14:12:56 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// if we get here, we know prefs is not null
|
|
|
|
nsXPIDLString url;
|
|
|
|
prefs->GetLocalizedUnicharPref(PREF_BROWSER_STARTUP_HOMEPAGE,
|
|
|
|
getter_Copies(url));
|
|
|
|
nsString homeURL;
|
|
|
|
if (!url) {
|
|
|
|
// if all else fails, use this
|
2000-02-08 13:40:10 +00:00
|
|
|
#ifdef DEBUG_seth
|
2000-08-22 03:51:17 +00:00
|
|
|
printf("all else failed. using %s as the home page\n", DEFAULT_HOME_PAGE);
|
2000-02-08 13:40:10 +00:00
|
|
|
#endif
|
2000-08-22 03:51:17 +00:00
|
|
|
homeURL.AssignWithConversion(DEFAULT_HOME_PAGE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
homeURL = url;
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE);
|
2000-09-20 12:23:53 +00:00
|
|
|
NS_ENSURE_SUCCESS(webNav->LoadURI(homeURL.GetUnicode(), nsIWebNavigation::LOAD_FLAGS_NONE), NS_ERROR_FAILURE);
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-10-28 14:12:56 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Stop()
|
2000-01-15 02:26:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mDocShell));
|
|
|
|
return webNav->Stop();
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Print()
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mDocShell) {
|
|
|
|
nsCOMPtr<nsIContentViewer> viewer;
|
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(viewer));
|
|
|
|
if (viewer) {
|
|
|
|
nsCOMPtr<nsIContentViewerFile> viewerFile(do_QueryInterface(viewer));
|
|
|
|
if (viewerFile)
|
|
|
|
return viewerFile->Print(PR_FALSE, nsnull);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::MoveTo(PRInt32 aXPos, PRInt32 aYPos)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(&aXPos, &aYPos),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(aXPos, aYPos),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::MoveBy(PRInt32 aXDif, PRInt32 aYDif)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 x, y;
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetPosition(&x, &y), NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 newX = x + aXDif;
|
|
|
|
PRInt32 newY = y + aYDif;
|
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityLeftAndTop(&newX, &newY), NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetPosition(newX, newY),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ResizeTo(PRInt32 aWidth, PRInt32 aHeight)
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&aWidth, &aHeight),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetSize(aWidth, aHeight, PR_TRUE),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-01-15 02:26:10 +00:00
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ResizeBy(PRInt32 aWidthDif, PRInt32 aHeightDif)
|
2000-01-15 02:26:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 cx, cy;
|
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->GetSize(&cx, &cy), NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 newCX = cx + aWidthDif;
|
|
|
|
PRInt32 newCY = cy + aHeightDif;
|
|
|
|
NS_ENSURE_SUCCESS(CheckSecurityWidthAndHeight(&newCX, &newCY),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(treeOwnerAsWin->SetSize(newCX, newCY,
|
|
|
|
PR_TRUE), NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SizeToContent()
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellParent;
|
|
|
|
docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent));
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// It's only valid to access this from a top window. Doesn't work from
|
|
|
|
// sub-frames.
|
|
|
|
if (docShellParent)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-01-15 02:26:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
nsCOMPtr<nsIMarkupDocumentViewer> markupViewer(do_QueryInterface(cv));
|
|
|
|
NS_ENSURE_TRUE(markupViewer, NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(markupViewer->SizeToContent(), NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-01-15 02:26:10 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetAttention()
|
1998-10-07 18:06:23 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
1998-10-07 18:06:23 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
|
|
|
|
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(widget->GetAttention(), NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-10-07 18:06:23 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Scroll(PRInt32 aXScroll, PRInt32 aYScroll)
|
1998-10-07 18:06:23 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return ScrollTo(aXScroll, aYScroll);
|
1998-10-07 18:06:23 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll)
|
1998-10-07 18:06:23 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result;
|
|
|
|
nsIScrollableView *view; // no addref/release for views
|
|
|
|
float p2t, t2p;
|
1999-04-28 20:33:43 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
result = GetScrollInfo(&view, &p2t, &t2p);
|
|
|
|
|
|
|
|
if (view) {
|
|
|
|
result = view->ScrollTo(NSIntPixelsToTwips(aXScroll, p2t),
|
|
|
|
NSIntPixelsToTwips(aYScroll, p2t),
|
|
|
|
NS_VMREFRESH_IMMEDIATE);
|
|
|
|
}
|
2000-06-03 01:01:48 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-06-15 03:17:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ScrollBy(PRInt32 aXScrollDif,
|
|
|
|
PRInt32 aYScrollDif)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result;
|
|
|
|
nsIScrollableView *view; // no addref/release for views
|
|
|
|
float p2t, t2p;
|
|
|
|
|
|
|
|
result = GetScrollInfo(&view, &p2t, &t2p);
|
|
|
|
|
|
|
|
if (view) {
|
|
|
|
nscoord xPos, yPos;
|
|
|
|
result = view->GetScrollPosition(xPos, yPos);
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
result = view->ScrollTo(xPos + NSIntPixelsToTwips(aXScrollDif, p2t),
|
|
|
|
yPos + NSIntPixelsToTwips(aYScrollDif, p2t),
|
|
|
|
NS_VMREFRESH_IMMEDIATE);
|
|
|
|
}
|
|
|
|
}
|
1999-04-28 20:33:43 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1998-10-07 18:06:23 +00:00
|
|
|
}
|
|
|
|
|
2000-09-13 13:06:07 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ScrollByLines(PRInt32 numLines)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIScrollableView *view = nsnull; // no addref/release for views
|
|
|
|
float p2t, t2p;
|
|
|
|
|
|
|
|
result = GetScrollInfo(&view, &p2t, &t2p);
|
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
result = view->ScrollByLines(0, numLines);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ScrollByPages(PRInt32 numPages)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIScrollableView *view = nsnull; // no addref/release for views
|
|
|
|
float p2t, t2p;
|
|
|
|
|
|
|
|
result = GetScrollInfo(&view, &p2t, &t2p);
|
|
|
|
if (view)
|
|
|
|
{
|
|
|
|
result = view->ScrollByPages(numPages);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ClearTimeout(PRInt32 aTimerID)
|
1998-10-07 18:06:23 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return ClearTimeoutOrInterval(aTimerID);
|
1998-10-07 18:06:23 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ClearInterval(PRInt32 aTimerID)
|
1999-01-27 04:15:19 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return ClearTimeoutOrInterval(aTimerID);
|
1999-01-27 04:15:19 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetTimeout(JSContext* cx, jsval* argv,
|
|
|
|
PRUint32 argc, PRInt32* aReturn)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return SetTimeoutOrInterval(cx, argv, argc, aReturn, PR_FALSE);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetInterval(JSContext* cx, jsval* argv,
|
|
|
|
PRUint32 argc, PRInt32* aReturn)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return SetTimeoutOrInterval(cx, argv, argc, aReturn, PR_TRUE);
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::CaptureEvents(PRInt32 aEventFlags)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
|
|
|
manager->CaptureEvent(aEventFlags);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ReleaseEvents(PRInt32 aEventFlags)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
2000-02-16 06:59:07 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
|
|
|
manager->ReleaseEvent(aEventFlags);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-16 06:59:07 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::RouteEvent(nsIDOMEvent* aEvt)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
//XXX Not the best solution -joki
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::EnableExternalCapture()
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::DisableExternalCapture()
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-10-01 22:21:59 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 04:41:27 +00:00
|
|
|
//Note: This call will lock the cursor, it will not change as it moves.
|
|
|
|
//To unlock, the cursor must be set back to CURSOR_AUTO.
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetCursor(const nsAReadableString& aCursor)
|
2000-04-24 04:41:27 +00:00
|
|
|
{
|
|
|
|
nsresult ret = NS_OK;
|
|
|
|
PRInt32 cursor;
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
if (aCursor.Equals(NS_LITERAL_STRING("auto")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_AUTO;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("default")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_DEFAULT;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("pointer")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_POINTER;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("crosshair")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_CROSSHAIR;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("move")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_MOVE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("text")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_TEXT;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("wait")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_WAIT;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("help")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_HELP;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("n-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_N_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("s-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_S_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("w-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_W_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("e-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_E_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("ne-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_NE_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("nw-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_NW_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("se-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_SE_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("sw-resize")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_SW_RESIZE;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("copy")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_COPY; // CSS3
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("alias")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_ALIAS;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("context-menu")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_CONTEXT_MENU;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("cell")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_CELL;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("grab")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_GRAB;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("grabbing")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_GRABBING;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("spinning")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_SPINNING;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("count-up")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_COUNT_UP;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("count-down")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_COUNT_DOWN;
|
2000-08-23 17:27:06 +00:00
|
|
|
else if (aCursor.Equals(NS_LITERAL_STRING("count-up-down")))
|
2000-08-22 03:51:17 +00:00
|
|
|
cursor = NS_STYLE_CURSOR_COUNT_UP_DOWN;
|
|
|
|
else
|
|
|
|
return NS_OK;
|
2000-04-24 04:41:27 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
mDocShell->GetPresContext(getter_AddRefs(presContext));
|
2000-08-22 03:51:17 +00:00
|
|
|
if (presContext) {
|
2000-04-24 04:41:27 +00:00
|
|
|
nsCOMPtr<nsIEventStateManager> esm;
|
|
|
|
if (NS_SUCCEEDED(presContext->GetEventStateManager(getter_AddRefs(esm)))) {
|
2000-08-22 03:51:17 +00:00
|
|
|
// Need root widget.
|
2000-04-24 04:41:27 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-04-24 04:41:27 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIView *rootView;
|
2000-04-24 04:41:27 +00:00
|
|
|
vm->GetRootView(rootView);
|
|
|
|
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-04-24 04:41:27 +00:00
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
rootView->GetWidget(*getter_AddRefs(widget));
|
|
|
|
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
// Call esm and set cursor.
|
2000-04-24 04:41:27 +00:00
|
|
|
ret = esm->SetCursor(cursor, widget, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Open(JSContext* cx, jsval* argv, PRUint32 argc,
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIDOMWindowInternal** aReturn)
|
1999-09-03 22:41:56 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return OpenInternal(cx, argv, argc, PR_FALSE, aReturn);
|
1999-09-03 22:41:56 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
// like Open, but attaches to the new window any extra parameters past
|
|
|
|
// [features] as a JS property named "arguments"
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::OpenDialog(JSContext* cx,
|
|
|
|
jsval* argv, PRUint32 argc,
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIDOMWindowInternal** aReturn)
|
1999-12-17 06:11:45 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return OpenInternal(cx, argv, argc, PR_TRUE, aReturn);
|
1999-12-17 06:11:45 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Close()
|
|
|
|
{
|
|
|
|
// Note: the basic security check, rejecting windows not opened through JS,
|
|
|
|
// has been removed. This was approved long ago by ...you're going to call me
|
|
|
|
// on this, aren't you... well it was. And anyway, a better means is coming.
|
|
|
|
// In the new world of application-level interfaces being written in JS, this
|
|
|
|
// security check was causing problems.
|
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
treeOwnerAsWin->Destroy();
|
|
|
|
CleanUp();
|
1999-10-06 22:07:42 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
return NS_OK;
|
1999-10-06 22:07:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Close(JSContext* cx, jsval* argv, PRUint32 argc)
|
1999-11-25 00:00:21 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsCOMPtr<nsIScriptContext> callingContext;
|
|
|
|
|
|
|
|
nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(callingContext));
|
|
|
|
if (callingContext) {
|
|
|
|
nsCOMPtr<nsIScriptContext> winContext;
|
|
|
|
result = GetContext(getter_AddRefs(winContext));
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
if (winContext == callingContext) {
|
|
|
|
result =
|
|
|
|
callingContext->SetTerminationFunction(CloseWindow,
|
|
|
|
NS_STATIC_CAST
|
|
|
|
(nsIScriptGlobalObject *,
|
|
|
|
this));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
result = Close();
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
1999-11-25 00:00:21 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::UpdateCommands(const nsAReadableString& anAction)
|
2000-02-11 00:57:54 +00:00
|
|
|
{
|
|
|
|
if (mChromeEventHandler) {
|
|
|
|
// Just jump out to the chrome event handler.
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(mChromeEventHandler);
|
|
|
|
if (content) {
|
|
|
|
// Cross the chrome/content boundary and get the nearest enclosing
|
|
|
|
// chrome window.
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
content->GetDocument(*getter_AddRefs(doc));
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> global;
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!doc)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-02-11 00:57:54 +00:00
|
|
|
doc->GetScriptGlobalObject(getter_AddRefs(global));
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> domWindow = do_QueryInterface(global);
|
2000-02-11 00:57:54 +00:00
|
|
|
return domWindow->UpdateCommands(anAction);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// XXX Handle the embedding case. The chrome handler could be told
|
|
|
|
// to poke menu items/update commands etc. This can be used by
|
|
|
|
// embedders if we set it up right and lets them know all sorts of
|
|
|
|
// interesting things about Ender text fields.
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else {
|
2000-02-11 00:57:54 +00:00
|
|
|
// See if we contain a XUL document.
|
2000-04-26 13:58:56 +00:00
|
|
|
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(mDocument);
|
2000-02-11 00:57:54 +00:00
|
|
|
if (xulDoc) {
|
|
|
|
// Retrieve the command dispatcher and call updateCommands on it.
|
|
|
|
nsCOMPtr<nsIDOMXULCommandDispatcher> xulCommandDispatcher;
|
|
|
|
xulDoc->GetCommandDispatcher(getter_AddRefs(xulCommandDispatcher));
|
|
|
|
xulCommandDispatcher->UpdateCommands(anAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now call UpdateCommands on our parent window.
|
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
|
|
|
GetParent(getter_AddRefs(parent));
|
2000-02-15 01:08:04 +00:00
|
|
|
// GetParent returns self at the top
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_STATIC_CAST(nsIDOMWindow *, this) == parent.get())
|
2000-02-15 01:08:04 +00:00
|
|
|
return NS_OK;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> parentInternal = do_QueryInterface(parent);
|
|
|
|
return parentInternal->UpdateCommands(anAction);
|
2000-02-11 00:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Escape(const nsAReadableString& aStr, nsAWritableString& aReturn)
|
1998-10-01 22:21:59 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsCOMPtr<nsIUnicodeEncoder> encoder;
|
|
|
|
nsAutoString charset;
|
1999-10-06 22:07:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsICharsetConverterManager>
|
|
|
|
ccm(do_GetService(kCharsetConverterManagerCID));
|
|
|
|
NS_ENSURE_TRUE(ccm, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Get the document character set
|
|
|
|
charset.AssignWithConversion("UTF-8"); // default to utf-8
|
|
|
|
if (mDocument) {
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (doc)
|
|
|
|
result = doc->GetDocumentCharacterSet(charset);
|
|
|
|
}
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
// Get an encoder for the character set
|
|
|
|
result = ccm->GetUnicodeEncoder(&charset, getter_AddRefs(encoder));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
result = encoder->Reset();
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
PRInt32 maxByteLen, srcLen;
|
|
|
|
srcLen = aStr.Length();
|
2000-09-13 03:24:57 +00:00
|
|
|
|
|
|
|
nsPromiseFlatString flatSrc(aStr);
|
|
|
|
const PRUnichar* src = flatSrc.get();
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
// Get the expected length of result string
|
|
|
|
result = encoder->GetMaxLength(src, srcLen, &maxByteLen);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
// Allocate a buffer of the maximum length
|
2000-08-23 17:27:06 +00:00
|
|
|
char* dest = (char *) nsMemory::Alloc(maxByteLen + 1);
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 destLen2, destLen = maxByteLen;
|
|
|
|
if (!dest)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-08-23 17:27:06 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Convert from unicode to the character set
|
|
|
|
result = encoder->Convert(src, &srcLen, dest, &destLen);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
nsMemory::Free(dest);
|
|
|
|
return result;
|
|
|
|
}
|
1998-10-01 22:21:59 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Allow the encoder to finish the conversion
|
|
|
|
destLen2 = maxByteLen - destLen;
|
|
|
|
encoder->Finish(dest + destLen, &destLen2);
|
|
|
|
dest[destLen + destLen2] = '\0';
|
1999-10-06 22:07:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Escape the string
|
|
|
|
char *outBuf =
|
|
|
|
nsEscape(dest, nsEscapeMask(url_XAlphas | url_XPAlphas | url_Path));
|
2000-08-23 17:27:06 +00:00
|
|
|
CopyASCIItoUCS2(nsLiteralCString(outBuf), aReturn);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsMemory::Free(outBuf);
|
|
|
|
nsMemory::Free(dest);
|
1999-10-06 22:07:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1999-10-06 22:07:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Unescape(const nsAReadableString& aStr,
|
|
|
|
nsAWritableString& aReturn)
|
1999-10-06 22:07:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result = NS_OK;
|
|
|
|
nsCOMPtr<nsIUnicodeDecoder> decoder;
|
|
|
|
nsAutoString charset;
|
1999-10-06 22:07:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsICharsetConverterManager>
|
|
|
|
ccm(do_GetService(kCharsetConverterManagerCID));
|
|
|
|
NS_ENSURE_TRUE(ccm, NS_ERROR_FAILURE);
|
1999-10-06 22:07:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Get the document character set
|
|
|
|
charset.AssignWithConversion("UTF-8"); // default to utf-8
|
|
|
|
if (mDocument) {
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (doc)
|
|
|
|
result = doc->GetDocumentCharacterSet(charset);
|
|
|
|
}
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
// Get an decoder for the character set
|
|
|
|
result = ccm->GetUnicodeDecoder(&charset, getter_AddRefs(decoder));
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
result = decoder->Reset();
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
// Need to copy to do the two-byte to one-byte deflation
|
2000-08-23 17:27:06 +00:00
|
|
|
char *inBuf = ToNewCString(aStr );
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!inBuf)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
// Unescape the string
|
|
|
|
char *src = nsUnescape(inBuf);
|
|
|
|
|
|
|
|
PRInt32 maxLength, srcLen;
|
|
|
|
srcLen = nsCRT::strlen(src);
|
|
|
|
|
|
|
|
// Get the expected length of the result string
|
|
|
|
result = decoder->GetMaxLength(src, srcLen, &maxLength);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
nsMemory::Free(src);
|
|
|
|
return result;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Allocate a buffer of the maximum length
|
|
|
|
PRUnichar *dest = (PRUnichar*) nsMemory::Alloc(sizeof(PRUnichar) * maxLength);
|
|
|
|
PRInt32 destLen = maxLength;
|
|
|
|
if (!dest) {
|
|
|
|
nsMemory::Free(src);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// Convert from character set to unicode
|
|
|
|
result = decoder->Convert(src, &srcLen, dest, &destLen);
|
|
|
|
nsMemory::Free(src);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
nsMemory::Free(dest);
|
|
|
|
return result;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
aReturn.Assign(dest, destLen);
|
|
|
|
nsMemory::Free(dest);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-09-14 11:45:01 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetSelection(nsISelection** aSelection)
|
2000-04-28 14:02:29 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSelection);
|
|
|
|
*aSelection = nsnull;
|
|
|
|
|
|
|
|
if (!mDocShell)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
|
|
|
|
if (!presShell)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFrameSelection> selection;
|
2000-08-22 03:51:17 +00:00
|
|
|
presShell->GetFrameSelection(getter_AddRefs(selection));
|
2000-04-28 14:02:29 +00:00
|
|
|
|
|
|
|
if (!selection)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return selection->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
|
|
|
aSelection);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIJSScriptObject
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool GlobalWindowImpl::AddProperty(JSContext* aContext, JSObject* aObj,
|
|
|
|
jsval aID, jsval* aVp)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return PR_TRUE;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool GlobalWindowImpl::DeleteProperty(JSContext* aContext, JSObject* aObj,
|
|
|
|
jsval aID, jsval* aVp)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return PR_TRUE;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
PRBool GlobalWindowImpl::GetProperty(JSContext* aContext, JSObject* aObj,
|
2000-08-22 03:51:17 +00:00
|
|
|
jsval aID, jsval* aVp)
|
|
|
|
{
|
|
|
|
return PR_TRUE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool GlobalWindowImpl::SetProperty(JSContext* aContext, JSObject* aObj,
|
|
|
|
jsval aID, jsval* aVp)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-29 00:14:23 +00:00
|
|
|
return PR_TRUE;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
PRBool GlobalWindowImpl::EnumerateProperty(JSContext* aContext, JSObject* aObj)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return ::JS_EnumerateStandardClasses(aContext, aObj);
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-09-22 10:18:07 +00:00
|
|
|
PRBool GlobalWindowImpl::Resolve(JSContext* aContext, JSObject* aObj,
|
|
|
|
jsval aID, PRBool* aDidDefineProperty)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-09-22 10:18:07 +00:00
|
|
|
*aDidDefineProperty = PR_FALSE;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (JSVAL_IS_STRING(aID)) {
|
|
|
|
JSBool resolved;
|
|
|
|
JSString *str;
|
|
|
|
|
|
|
|
if (!::JS_ResolveStandardClass(aContext, aObj, aID, &resolved))
|
|
|
|
return PR_FALSE;
|
2000-09-22 10:18:07 +00:00
|
|
|
|
|
|
|
if (resolved) {
|
|
|
|
*aDidDefineProperty = PR_TRUE;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return PR_TRUE;
|
2000-09-22 10:18:07 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
str = JSVAL_TO_STRING(aID);
|
2000-08-29 00:14:23 +00:00
|
|
|
if (mDocShell) {
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode>
|
|
|
|
docShellAsNode(do_QueryInterface(mDocShell));
|
|
|
|
PRInt32 count;
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(docShellAsNode->GetChildCount(&count)) && count) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> child;
|
|
|
|
|
|
|
|
const jschar *chars = ::JS_GetStringChars(str);
|
|
|
|
const PRUnichar *unichars = NS_REINTERPRET_CAST(const PRUnichar*, chars);
|
|
|
|
nsresult rv =
|
|
|
|
docShellAsNode->FindChildWithName(unichars,
|
|
|
|
PR_FALSE,
|
|
|
|
PR_FALSE,
|
|
|
|
nsnull,
|
|
|
|
getter_AddRefs(child));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
if (child) {
|
|
|
|
JSObject *childObj;
|
|
|
|
|
|
|
|
// We found a subframe of the right name. The rest of this code
|
|
|
|
// is to get its script object.
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject>
|
|
|
|
childGlobalObject(do_GetInterface(child));
|
|
|
|
if (childGlobalObject) {
|
|
|
|
nsCOMPtr<nsIScriptObjectOwner>
|
|
|
|
objOwner(do_QueryInterface(childGlobalObject));
|
|
|
|
if (objOwner) {
|
|
|
|
nsCOMPtr<nsIScriptContext> scriptContext;
|
|
|
|
|
|
|
|
childGlobalObject->GetContext(getter_AddRefs(scriptContext));
|
|
|
|
if (scriptContext) {
|
|
|
|
objOwner->GetScriptObject(scriptContext,
|
|
|
|
(void **) &childObj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Okay, if we now have a childObj, we can define it and proceed.
|
|
|
|
if (childObj) {
|
2000-09-22 10:18:07 +00:00
|
|
|
if (!::JS_DefineUCProperty(aContext, (JSObject *) mScriptObject,
|
|
|
|
chars, ::JS_GetStringLength(str),
|
|
|
|
OBJECT_TO_JSVAL(childObj), nsnull,
|
|
|
|
nsnull, 0)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aDidDefineProperty = PR_TRUE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
1999-12-15 02:14:53 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
return PR_TRUE;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
PRBool GlobalWindowImpl::Convert(JSContext* aContext, JSObject* aObj, jsval aID)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return PR_TRUE;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
void GlobalWindowImpl::Finalize(JSContext* aContext, JSObject* aObj)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIDOMEventTarget
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 17:27:06 +00:00
|
|
|
GlobalWindowImpl::AddEventListener(const nsAReadableString& aType,
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
PRBool aUseCapture)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_SUCCEEDED(GetListenerManager(getter_AddRefs(manager)))) {
|
|
|
|
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
1999-08-19 20:36:31 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
manager->AddEventListenerByType(aListener, aType, flags);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-09-17 20:13:52 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
2000-08-23 17:27:06 +00:00
|
|
|
GlobalWindowImpl::RemoveEventListener(const nsAReadableString& aType,
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIDOMEventListener* aListener,
|
|
|
|
PRBool aUseCapture)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mListenerManager) {
|
|
|
|
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
mListenerManager->RemoveEventListenerByType(aListener, aType, flags);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-05-16 11:35:12 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::DispatchEvent(nsIDOMEvent* aEvent)
|
|
|
|
{
|
|
|
|
if (mDocument) {
|
|
|
|
nsCOMPtr<nsIDocument> idoc(do_QueryInterface(mDocument));
|
|
|
|
if (idoc) {
|
|
|
|
// Obtain a presentation context
|
|
|
|
PRInt32 count = idoc->GetNumberOfShells();
|
|
|
|
if (count == 0)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(idoc->GetShellAt(0));
|
|
|
|
|
|
|
|
// Retrieve the context
|
|
|
|
nsCOMPtr<nsIPresContext> aPresContext;
|
|
|
|
shell->GetPresContext(getter_AddRefs(aPresContext));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIEventStateManager> esm;
|
|
|
|
if (NS_SUCCEEDED(aPresContext->GetEventStateManager(getter_AddRefs(esm)))) {
|
2000-08-22 03:51:17 +00:00
|
|
|
return esm->DispatchNewEvent(NS_STATIC_CAST(nsIScriptGlobalObject *, this),
|
|
|
|
aEvent);
|
2000-05-16 11:35:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIDOMEventReceiver
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::AddEventListenerByIID(nsIDOMEventListener* aListener,
|
|
|
|
const nsIID& aIID)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
1999-06-11 21:49:41 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
|
|
|
|
manager->AddEventListenerByIID(aListener, aIID, NS_EVENT_FLAG_BUBBLE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::RemoveEventListenerByIID(nsIDOMEventListener* aListener,
|
|
|
|
const nsIID& aIID)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mListenerManager) {
|
|
|
|
mListenerManager->RemoveEventListenerByIID(aListener, aIID,
|
|
|
|
NS_EVENT_FLAG_BUBBLE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetListenerManager(nsIEventListenerManager **aInstancePtrResult)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mListenerManager)
|
|
|
|
return CallQueryInterface(mListenerManager, aInstancePtrResult);
|
1999-07-12 23:40:01 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// This is gonna get ugly. Can't use NS_NewEventListenerManager because of
|
|
|
|
// a circular link problem.
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> doc(do_QueryInterface(mDocument));
|
|
|
|
|
|
|
|
if (doc) {
|
|
|
|
if (NS_OK == doc->GetNewListenerManager(aInstancePtrResult)) {
|
|
|
|
mListenerManager = *aInstancePtrResult;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1999-07-12 23:40:01 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//XXX I need another way around the circular link problem.
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetNewListenerManager(nsIEventListenerManager **aInstancePtrResult)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-02-16 06:59:07 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::HandleEvent(nsIDOMEvent *aEvent)
|
|
|
|
{
|
2000-05-16 11:35:12 +00:00
|
|
|
return DispatchEvent(aEvent);
|
2000-02-16 06:59:07 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsPIDOMWindow
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPrivateParent(nsPIDOMWindow ** aParent)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
|
|
|
*aParent = nsnull; // Set to null so we can bail out later
|
1999-10-15 21:52:37 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
GetParent(getter_AddRefs(parent));
|
(13163, r=alecf, scc, waterson, others; names available on request)
- Fix most of bug 13163 (see TODO for rest). This entails adding a version-string argument to nsIScriptContext::EvaluateString and passing it around lots of places in content sinks.
- Fix leaks and confusion about mSecurityManager and mNameSpaceManager in nsJSEnvironment.cpp. These still need to move from nsJSContext to nsGlobalWindow or thereabouts, jband and vidur are looking at that.
- Added comments and expanded tabs in nsJSEnvironment.cpp, esp. to EvaluateString. Also changed various nsresult vars to be named rv. Also restored brace/style conformity to nsJSProtocolHandler.cpp.
- Factored CompileFunction from AddScriptEventListener to pave the way for brutal sharing of compiled JS event handlers via JS_CloneFunctionObject.
- Lots of nsCOMPtr uses added. I'm using one for mNameSpaceManager. Hold mSecurityManager as a service explicitly, on the other hand (awaiting scc's fix to allow comptrs for services), and release in nsJSContext's dtor (fixing a leak). These two managers should be moved to the window object -- TODO item below.
- Hold JSRuntimeService along with JSRuntime for live of nsJSEnvironment, fix for shaver.
- Fix window.setTimeout etc. so the filename and line number of the timeout expr is propagated. This meant factoring nsJSUtils.cpp code.
- Fix all content sinks to use the same, and up-to-date JavaScript version parsing (whether for script type or for old language attribute); also fix SplitMimeType clones to strip whitespace.
- With waterson, fix bug in brutal-sharing version of XUL content sink: script src= should not evaluate the inline content of its tag.
1999-10-31 00:43:30 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_STATIC_CAST(nsIDOMWindow *, this) == parent.get()) {
|
|
|
|
nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
|
|
|
|
if (!chromeElement)
|
|
|
|
return NS_OK; // This is ok, just means a null parent.
|
1999-07-12 23:40:01 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
chromeElement->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (!doc)
|
|
|
|
return NS_OK; // This is ok, just means a null parent.
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
|
|
|
doc->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
|
|
|
if (!globalObject)
|
|
|
|
return NS_OK; // This is ok, just means a null parent.
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
parent = do_QueryInterface(globalObject);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (parent)
|
|
|
|
CallQueryInterface(parent.get(), aParent);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetPrivateRoot(nsIDOMWindowInternal ** aParent)
|
2000-02-11 00:57:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
*aParent = nsnull; // Set to null so we can bail out later
|
2000-02-11 00:57:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> parent;
|
|
|
|
GetTop(getter_AddRefs(parent));
|
2000-02-11 00:57:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> parentTop = do_QueryInterface(parent);
|
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
|
|
|
parentTop->GetDocShell(getter_AddRefs(docShell));
|
|
|
|
nsCOMPtr<nsIChromeEventHandler> chromeEventHandler;
|
|
|
|
docShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
|
2000-02-11 00:57:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIContent> chromeElement(do_QueryInterface(mChromeEventHandler));
|
|
|
|
if (chromeElement) {
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
chromeElement->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (doc) {
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
|
|
|
doc->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
|
|
|
|
|
|
|
parent = do_QueryInterface(globalObject);
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> tempParent;
|
|
|
|
parent->GetTop(getter_AddRefs(tempParent));
|
|
|
|
CallQueryInterface(tempParent, aParent);
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2000-02-11 00:57:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (parent) {
|
2000-09-01 01:54:35 +00:00
|
|
|
CallQueryInterface(parent, aParent);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-02-11 00:57:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-02-11 00:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetLocation(nsIDOMLocation ** aLocation)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mLocation && mDocShell) {
|
|
|
|
mLocation = new LocationImpl(mDocShell);
|
|
|
|
NS_IF_ADDREF(mLocation);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aLocation = mLocation;
|
|
|
|
NS_IF_ADDREF(mLocation);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetObjectProperty(const PRUnichar *aProperty,
|
|
|
|
nsISupports *aObject)
|
2000-03-31 03:33:49 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
// Get JSContext from stack.
|
|
|
|
nsCOMPtr<nsIThreadJSContextStack>
|
2000-09-13 23:57:52 +00:00
|
|
|
stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
JSContext *cx;
|
|
|
|
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!cx) {
|
|
|
|
stack->GetSafeJSContext(&cx);
|
|
|
|
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
|
|
|
}
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
jsval propertyVal = nsnull;
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IF_ADDREF(aObject); // Convert Releases it (I know it's bad)
|
|
|
|
nsJSUtils::nsConvertXPCObjectToJSVal(aObject, NS_GET_IID(nsISupports),
|
|
|
|
cx, (JSObject *) mScriptObject,
|
|
|
|
&propertyVal);
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(::JS_SetUCProperty(cx, (JSObject *) mScriptObject,
|
|
|
|
NS_REINTERPRET_CAST(const jschar *,
|
|
|
|
aProperty),
|
|
|
|
nsCRT::strlen(aProperty),
|
|
|
|
&propertyVal),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-03-31 03:33:49 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetObjectProperty(const PRUnichar *aProperty,
|
|
|
|
nsISupports ** aObject)
|
2000-03-31 03:33:49 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
// Get JSContext from stack.
|
|
|
|
nsCOMPtr<nsIThreadJSContextStack>
|
2000-09-13 23:57:52 +00:00
|
|
|
stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
JSContext *cx;
|
|
|
|
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!cx) {
|
|
|
|
stack->GetSafeJSContext(&cx);
|
|
|
|
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
|
|
|
}
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
jsval propertyVal;
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!::JS_LookupUCProperty(cx, (JSObject *) mScriptObject,
|
|
|
|
NS_REINTERPRET_CAST(const jschar *, aProperty),
|
|
|
|
nsCRT::strlen(aProperty), &propertyVal)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!nsJSUtils::nsConvertJSValToXPCObject(aObject, NS_GET_IID(nsISupports),
|
|
|
|
cx, propertyVal)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-03-31 03:33:49 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
2000-03-31 03:33:49 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Activate()
|
1998-08-07 04:45:03 +00:00
|
|
|
{
|
2000-02-11 23:42:11 +00:00
|
|
|
/*
|
2000-02-08 13:40:10 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
if(treeOwnerAsWin)
|
|
|
|
treeOwnerAsWin->SetVisibility(PR_TRUE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsIView* rootView;
|
|
|
|
vm->GetRootView(rootView);
|
|
|
|
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
rootView->GetWidget(*getter_AddRefs(widget));
|
|
|
|
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return widget->SetFocus();
|
2000-02-11 23:42:11 +00:00
|
|
|
|
|
|
|
*/
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
if (treeOwnerAsWin)
|
|
|
|
treeOwnerAsWin->SetVisibility(PR_TRUE);
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIView *rootView;
|
|
|
|
vm->GetRootView(rootView);
|
|
|
|
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
rootView->GetWidget(*getter_AddRefs(widget));
|
|
|
|
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsEventStatus status;
|
|
|
|
nsGUIEvent guiEvent;
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
guiEvent.eventStructType = NS_GUI_EVENT;
|
|
|
|
guiEvent.point.x = 0;
|
|
|
|
guiEvent.point.y = 0;
|
|
|
|
guiEvent.time = PR_IntervalNow();
|
|
|
|
guiEvent.nativeMsg = nsnull;
|
2000-09-19 03:14:31 +00:00
|
|
|
guiEvent.message = NS_ACTIVATE;
|
2000-08-22 03:51:17 +00:00
|
|
|
guiEvent.widget = widget;
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
vm->DispatchEvent(&guiEvent, &status);
|
2000-02-11 23:42:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-05-17 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::Deactivate()
|
1999-05-17 18:52:21 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
if (treeOwnerAsWin)
|
|
|
|
treeOwnerAsWin->SetVisibility(PR_TRUE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIView *rootView;
|
|
|
|
vm->GetRootView(rootView);
|
|
|
|
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
rootView->GetWidget(*getter_AddRefs(widget));
|
|
|
|
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsEventStatus status;
|
|
|
|
nsGUIEvent guiEvent;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
guiEvent.eventStructType = NS_GUI_EVENT;
|
|
|
|
guiEvent.point.x = 0;
|
|
|
|
guiEvent.point.y = 0;
|
|
|
|
guiEvent.time = PR_IntervalNow();
|
|
|
|
guiEvent.nativeMsg = nsnull;
|
|
|
|
guiEvent.message = NS_DEACTIVATE;
|
|
|
|
guiEvent.widget = widget;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
vm->DispatchEvent(&guiEvent, &status);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-05-17 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
2000-09-22 05:02:20 +00:00
|
|
|
GlobalWindowImpl::GetRootCommandDispatcher(nsIDOMXULCommandDispatcher **
|
2000-08-22 03:51:17 +00:00
|
|
|
aDispatcher)
|
2000-06-23 00:42:21 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!aDispatcher)
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-06-23 00:42:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aDispatcher = nsnull;
|
2000-06-23 00:42:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDOMXULCommandDispatcher> commandDispatcher;
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> rootWindow;
|
2000-09-22 05:02:20 +00:00
|
|
|
|
|
|
|
GetPrivateRoot(getter_AddRefs(rootWindow));
|
|
|
|
if (rootWindow) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> rootDocument;
|
|
|
|
rootWindow->GetDocument(getter_AddRefs(rootDocument));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULDocument> xulDoc = do_QueryInterface(rootDocument);
|
|
|
|
if (xulDoc) {
|
|
|
|
xulDoc->GetCommandDispatcher(aDispatcher);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2000-06-23 00:42:21 +00:00
|
|
|
}
|
|
|
|
|
2000-07-11 23:34:44 +00:00
|
|
|
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx,
|
|
|
|
PRInt32 cy, PRBool fRepaint)
|
2000-07-11 23:34:44 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-07-11 23:34:44 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return treeOwnerAsWin->SetPositionAndSize(x, y, cx, cy, fRepaint);
|
2000-07-11 23:34:44 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetPositionAndSize(PRInt32 *x, PRInt32 *y, PRInt32 *cx,
|
|
|
|
PRInt32 *cy)
|
2000-07-11 23:34:44 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-07-11 23:34:44 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return treeOwnerAsWin->GetPositionAndSize(x, y, cx, cy);
|
2000-07-11 23:34:44 +00:00
|
|
|
}
|
|
|
|
|
2000-05-03 13:03:17 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIDOMViewCSS
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
2000-05-03 13:03:17 +00:00
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetComputedStyle(nsIDOMElement* aElt,
|
|
|
|
const nsAReadableString& aPseudoElt,
|
|
|
|
nsIDOMCSSStyleDeclaration** aReturn)
|
2000-05-03 13:03:17 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aReturn);
|
2000-05-17 06:38:43 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aElt);
|
2000-05-03 13:03:17 +00:00
|
|
|
*aReturn = nsnull;
|
|
|
|
|
2000-05-17 06:38:43 +00:00
|
|
|
NS_ENSURE_TRUE(mDocShell, NS_OK);
|
2000-05-03 13:03:17 +00:00
|
|
|
|
2000-05-17 06:38:43 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
|
|
|
NS_ENSURE_TRUE(presShell, NS_OK);
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsCOMPtr<nsIComputedDOMStyle> compStyle;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
compStyle =
|
2000-09-13 23:57:52 +00:00
|
|
|
do_CreateInstance("@mozilla.org/DOM/Level2/CSS/computedStyleDeclaration;1", &rv);
|
2000-05-17 06:38:43 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = compStyle->Init(aElt, aPseudoElt, presShell);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return compStyle->QueryInterface(NS_GET_IID(nsIDOMCSSStyleDeclaration),
|
2000-08-22 03:51:17 +00:00
|
|
|
(void **) aReturn);
|
2000-05-03 13:03:17 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl::nsIDOMAbstractView
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1998-08-07 04:45:03 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetDocument(nsIDOMDocumentView ** aDocumentView)
|
2000-04-26 13:58:56 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aDocumentView);
|
2000-04-26 13:58:56 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-26 13:58:56 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (mDocument) {
|
|
|
|
rv = mDocument->QueryInterface(NS_GET_IID(nsIDOMDocumentView),
|
|
|
|
(void **) aDocumentView);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*aDocumentView = nsnull;
|
|
|
|
}
|
2000-04-26 13:58:56 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return rv;
|
2000-04-26 13:58:56 +00:00
|
|
|
}
|
1998-09-03 01:19:58 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl: Window Control Functions
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP GlobalWindowImpl::OpenInternal(JSContext *cx,
|
|
|
|
jsval *argv, PRUint32 argc,
|
|
|
|
PRBool aDialog,
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIDOMWindowInternal ** aReturn)
|
2000-08-22 03:51:17 +00:00
|
|
|
{
|
|
|
|
PRUint32 chromeFlags;
|
|
|
|
nsAutoString name;
|
|
|
|
JSString *str;
|
|
|
|
char *options;
|
|
|
|
PRBool nameSpecified = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIURI> uriToLoad;
|
|
|
|
|
|
|
|
*aReturn = nsnull;
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
JSString *jsStrURL = ::JS_ValueToString(cx, argv[0]);
|
|
|
|
NS_ENSURE_TRUE(jsStrURL, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsAutoString unescapedURL;
|
|
|
|
unescapedURL.Assign(NS_REINTERPRET_CAST(const PRUnichar *,
|
|
|
|
::JS_GetStringChars(jsStrURL)));
|
|
|
|
|
|
|
|
// fix bug 35076
|
|
|
|
// if the URL contains non ASCII, then escape from the first non ASCII char
|
|
|
|
nsAutoString mURL;
|
|
|
|
if (unescapedURL.IsASCII()) {
|
|
|
|
mURL = unescapedURL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const PRUnichar *pt = unescapedURL.GetUnicode();
|
|
|
|
PRUint32 len = unescapedURL.Length();
|
|
|
|
PRUint32 i;
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (0 != (0xFF80 & (*pt++)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsAutoString right, right2;
|
|
|
|
unescapedURL.Left(mURL, i);
|
|
|
|
unescapedURL.Right(right, len - i);
|
|
|
|
if (NS_SUCCEEDED(Escape(right, right2)))
|
|
|
|
mURL.Append(right2);
|
|
|
|
else
|
2000-06-27 21:27:30 +00:00
|
|
|
mURL = unescapedURL;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
if (!mURL.IsEmpty()) {
|
|
|
|
nsAutoString mAbsURL;
|
|
|
|
if (mDocument) {
|
|
|
|
// Build absolute URL relative to this document.
|
|
|
|
nsCOMPtr<nsIURI> docURL;
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
if (doc)
|
|
|
|
docURL = dont_AddRef(doc->GetDocumentURL());
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> baseUri(do_QueryInterface(docURL));
|
|
|
|
NS_ENSURE_TRUE(baseUri, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(NS_MakeAbsoluteURI(mAbsURL, mURL, baseUri),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-06-27 21:27:30 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else {
|
|
|
|
// No document. Probably because this window's URL hasn't finished
|
|
|
|
// loading. All we can do is hope the URL we've been given is absolute.
|
|
|
|
mAbsURL.Assign(NS_REINTERPRET_CAST(const PRUnichar *,
|
|
|
|
::JS_GetStringChars(jsStrURL)));
|
|
|
|
// Make URI; if mAbsURL is relative (or otherwise bogus) this will fail.
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(uriToLoad), mAbsURL),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sanity-check the optional window_name argument. */
|
|
|
|
if (argc > 1) {
|
|
|
|
JSString *jsStrName = ::JS_ValueToString(cx, argv[1]);
|
|
|
|
NS_ENSURE_TRUE(jsStrName, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
name.Assign(NS_REINTERPRET_CAST(const PRUnichar *,
|
|
|
|
::JS_GetStringChars(jsStrName)));
|
|
|
|
nameSpecified = PR_TRUE;
|
|
|
|
|
|
|
|
// Check for an illegal name e.g. frame3.1
|
|
|
|
// This prints a warning message and returns NS_ERROR_FAILURE.
|
|
|
|
// Don't use NS_ENSURE_SUCCESS - go ahead and open up the window
|
|
|
|
// even if the name contains an illegal character. See bug 32898.
|
|
|
|
CheckWindowName(cx, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
options = nsnull;
|
|
|
|
if (argc > 2) {
|
|
|
|
NS_ENSURE_TRUE((str = ::JS_ValueToString(cx, argv[2])), NS_ERROR_FAILURE);
|
|
|
|
options = ::JS_GetStringBytes(str);
|
|
|
|
}
|
|
|
|
chromeFlags = CalculateChromeFlags(options, aDialog);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> newDocShellItem;
|
|
|
|
|
|
|
|
// special handling for certain targets
|
|
|
|
if (nameSpecified) {
|
|
|
|
/* Oh good. special target names are now handled in multiple places:
|
|
|
|
Here and within FindItemWithName, just below. I put _top here because
|
|
|
|
here it's able to do what it should: get the topmost shell of the same
|
|
|
|
(content/chrome) type as the docshell. treeOwner is always chrome, so
|
|
|
|
this scheme doesn't work there, where a lot of other special case
|
|
|
|
targets are handled. (treeOwner is, however, a good place to look
|
|
|
|
for browser windows by name, as it does.)
|
2000-08-16 02:16:11 +00:00
|
|
|
*/
|
2000-08-22 03:51:17 +00:00
|
|
|
if (name.EqualsIgnoreCase("_top")) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> shelltree(do_QueryInterface(mDocShell));
|
|
|
|
if (shelltree)
|
|
|
|
shelltree->GetSameTypeRootTreeItem(getter_AddRefs(newDocShellItem));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
treeOwner->FindItemWithName(name.GetUnicode(), nsnull,
|
|
|
|
getter_AddRefs(newDocShellItem));
|
|
|
|
}
|
2000-06-22 01:39:40 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIEventQueue> modalEventQueue; // This has an odd ownership model
|
|
|
|
nsCOMPtr<nsIEventQueueService> eventQService;
|
1998-09-09 01:19:11 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool windowIsNew = PR_FALSE;
|
|
|
|
PRBool windowIsModal = PR_FALSE;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!newDocShellItem) {
|
|
|
|
windowIsNew = PR_TRUE;
|
2000-08-25 18:39:46 +00:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL) {
|
2000-08-22 03:51:17 +00:00
|
|
|
eventQService = do_GetService(kEventQueueServiceCID);
|
|
|
|
if (eventQService &&
|
|
|
|
NS_SUCCEEDED(eventQService->
|
|
|
|
PushThreadEventQueue(getter_AddRefs(modalEventQueue))))
|
|
|
|
windowIsModal = PR_TRUE;
|
|
|
|
}
|
|
|
|
treeOwner->GetNewWindow(chromeFlags, getter_AddRefs(newDocShellItem));
|
|
|
|
NS_ENSURE_TRUE(newDocShellItem, NS_ERROR_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(ReadyOpenedDocShellItem(newDocShellItem, aReturn),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
if (windowIsNew) {
|
|
|
|
PRBool present = PR_FALSE;
|
|
|
|
PRInt32 temp;
|
|
|
|
|
|
|
|
if (!((temp = WinHasOption(options, "outerWidth", 0, &present)) ||
|
|
|
|
present) &&
|
|
|
|
!((temp = WinHasOption(options, "outerHeight", 0, &present)) ||
|
|
|
|
present))
|
|
|
|
{
|
2000-02-08 13:40:10 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> newTreeOwner;
|
|
|
|
newDocShellItem->GetTreeOwner(getter_AddRefs(newTreeOwner));
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_TRUE(newTreeOwner, NS_ERROR_FAILURE);
|
|
|
|
nsCOMPtr<nsIWebBrowserChrome> newChrome = do_GetInterface(newTreeOwner);
|
|
|
|
if (newChrome)
|
|
|
|
newChrome->SetPersistence(PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE,
|
|
|
|
PR_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDialog && argc > 3)
|
|
|
|
AttachArguments(*aReturn, argv + 3, argc - 3);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager> secMan;
|
|
|
|
if (uriToLoad) {
|
|
|
|
// Get security manager, check to see if URI is allowed.
|
|
|
|
nsCOMPtr<nsIURI> newUrl;
|
|
|
|
nsCOMPtr<nsIScriptContext> scriptCX;
|
|
|
|
nsJSUtils::nsGetStaticScriptContext(cx, (JSObject *) mScriptObject,
|
|
|
|
getter_AddRefs(scriptCX));
|
|
|
|
if (!scriptCX ||
|
|
|
|
NS_FAILED(scriptCX->GetSecurityManager(getter_AddRefs(secMan))) ||
|
|
|
|
NS_FAILED(secMan->CheckLoadURIFromScript(cx, uriToLoad)))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
newDocShellItem->SetName(nameSpecified ? name.GetUnicode() : nsnull);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShell> newDocShell(do_QueryInterface(newDocShellItem));
|
2000-08-31 05:53:32 +00:00
|
|
|
if (uriToLoad) { // Get script principal and pass to docshell
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
if (NS_FAILED(secMan->GetSubjectPrincipal(getter_AddRefs(principal))))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
|
2000-08-31 05:53:32 +00:00
|
|
|
if (principal) {
|
|
|
|
nsCOMPtr<nsISupports> owner = do_QueryInterface(principal);
|
2000-08-22 03:51:17 +00:00
|
|
|
newDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
|
|
|
|
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
|
2000-08-31 05:53:32 +00:00
|
|
|
loadInfo->SetOwner(owner);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-09-20 12:23:53 +00:00
|
|
|
newDocShell->LoadURI(uriToLoad, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (windowIsNew)
|
|
|
|
SizeOpenedDocShellItem(newDocShellItem, options, chromeFlags);
|
|
|
|
if (windowIsModal) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> newTreeOwner;
|
|
|
|
newDocShellItem->GetTreeOwner(getter_AddRefs(newTreeOwner));
|
|
|
|
|
|
|
|
if (newTreeOwner)
|
|
|
|
newTreeOwner->ShowModal();
|
|
|
|
|
|
|
|
eventQService->PopThreadEventQueue(modalEventQueue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-05-17 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// attach the given array of JS values to the given window, as a property array
|
|
|
|
// named "arguments"
|
2000-09-01 01:54:35 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::AttachArguments(nsIDOMWindowInternal *aWindow,
|
2000-08-22 03:51:17 +00:00
|
|
|
jsval *argv, PRUint32 argc)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (argc == 0)
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// copy the extra parameters into a JS Array and attach it
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> scriptGlobal(do_QueryInterface(aWindow));
|
|
|
|
if (!scriptGlobal)
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIScriptContext> scriptContext;
|
|
|
|
scriptGlobal->GetContext(getter_AddRefs(scriptContext));
|
|
|
|
if (!scriptContext)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
JSContext *jsContext;
|
|
|
|
jsContext = (JSContext *) scriptContext->GetNativeContext();
|
|
|
|
nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(aWindow));
|
|
|
|
if (!owner)
|
|
|
|
return NS_OK;
|
1998-08-07 04:45:03 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
JSObject *scriptObject;
|
|
|
|
owner->GetScriptObject(scriptContext, (void **) &scriptObject);
|
|
|
|
|
|
|
|
JSObject *args;
|
|
|
|
args = ::JS_NewArrayObject(jsContext, argc, argv);
|
|
|
|
if (!args)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
jsval argsVal = OBJECT_TO_JSVAL(args);
|
|
|
|
// ::JS_DefineProperty(jsContext, scriptObject, "arguments",
|
|
|
|
// argsVal, NULL, NULL, JSPROP_PERMANENT);
|
|
|
|
::JS_SetProperty(jsContext, scriptObject, "arguments", &argsVal);
|
|
|
|
|
|
|
|
return NS_OK;
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
1998-08-07 04:45:03 +00:00
|
|
|
|
1999-08-07 02:51:03 +00:00
|
|
|
/**
|
|
|
|
* Calculate the chrome bitmask from a string list of features.
|
|
|
|
* @param aFeatures a string containing a list of named chrome features
|
|
|
|
* @param aDialog affects the assumptions made about unnamed features
|
|
|
|
* @return the chrome bitmask
|
|
|
|
*/
|
2000-08-22 03:51:17 +00:00
|
|
|
PRUint32 GlobalWindowImpl::CalculateChromeFlags(char *aFeatures, PRBool aDialog)
|
|
|
|
{
|
2000-08-25 18:39:46 +00:00
|
|
|
if(!aFeatures) {
|
|
|
|
if(aDialog)
|
|
|
|
return nsIWebBrowserChrome::CHROME_ALL |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG |
|
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
|
|
|
|
else
|
|
|
|
return nsIWebBrowserChrome::CHROME_ALL;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
/* This function has become complicated since browser windows and
|
|
|
|
dialogs diverged. The difference is, browser windows assume all
|
|
|
|
chrome not explicitly mentioned is off, if the features string
|
|
|
|
is not null. Exceptions are some OS border chrome new with Mozilla.
|
|
|
|
Dialogs interpret a (mostly) empty features string to mean
|
|
|
|
"OS's choice," and also support an "all" flag explicitly disallowed
|
|
|
|
in the standards-compliant window.(normal)open. */
|
|
|
|
|
|
|
|
PRUint32 chromeFlags = 0;
|
|
|
|
PRBool presenceFlag = PR_FALSE;
|
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags = nsIWebBrowserChrome::CHROME_WINDOW_BORDERS;
|
2000-08-22 03:51:17 +00:00
|
|
|
if (aDialog && WinHasOption(aFeatures, "all", 0, &presenceFlag))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags = nsIWebBrowserChrome::CHROME_ALL;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
/* Next, allow explicitly named options to override the initial settings */
|
|
|
|
|
|
|
|
chromeFlags |= WinHasOption(aFeatures, "titlebar", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_TITLEBAR : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "close", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_WINDOW_CLOSE : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "toolbar", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_TOOLBAR : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "location", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_LOCATIONBAR : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= (WinHasOption(aFeatures, "directories", 0, &presenceFlag) ||
|
|
|
|
WinHasOption(aFeatures, "personalbar", 0, &presenceFlag))
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "status", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_STATUSBAR : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "menubar", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_MENUBAR : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "scrollbars", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_SCROLLBARS : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "resizable", 0, &presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
? nsIWebBrowserChrome::CHROME_WINDOW_RESIZE : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
/* OK.
|
|
|
|
Normal browser windows, in spite of a stated pattern of turning off
|
|
|
|
all chrome not mentioned explicitly, will want the new OS chrome (window
|
|
|
|
borders, titlebars, closebox) on, unless explicitly turned off.
|
|
|
|
Dialogs, on the other hand, take the absence of any explicit settings
|
|
|
|
to mean "OS' choice." */
|
|
|
|
|
|
|
|
// default titlebar and closebox to "on," if not mentioned at all
|
|
|
|
if (!PL_strcasestr(aFeatures, "titlebar"))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!PL_strcasestr(aFeatures, "close"))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
if (aDialog && !presenceFlag)
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags = nsIWebBrowserChrome::CHROME_DEFAULT;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
/* Finally, once all the above normal chrome has been divined, deal
|
|
|
|
with the features that are more operating hints than appearance
|
|
|
|
instructions. (Note modality implies dependence.) */
|
|
|
|
|
|
|
|
if (WinHasOption(aFeatures, "alwaysLowered", 0, nsnull) ||
|
|
|
|
WinHasOption(aFeatures, "z-lock", 0, nsnull))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_LOWERED;
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (WinHasOption(aFeatures, "alwaysRaised", 0, nsnull))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
chromeFlags |= WinHasOption(aFeatures, "chrome", 0, nsnull) ?
|
2000-08-25 18:39:46 +00:00
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_CHROME : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "centerscreen", 0, nsnull) ?
|
2000-08-25 18:39:46 +00:00
|
|
|
nsIWebBrowserChrome::CHROME_CENTER_SCREEN : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "dependent", 0, nsnull) ?
|
2000-08-25 18:39:46 +00:00
|
|
|
nsIWebBrowserChrome::CHROME_DEPENDENT : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "modal", 0, nsnull) ?
|
2000-08-25 18:39:46 +00:00
|
|
|
(nsIWebBrowserChrome::CHROME_MODAL | nsIWebBrowserChrome::CHROME_DEPENDENT) : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
chromeFlags |= WinHasOption(aFeatures, "dialog", 0, nsnull) ?
|
2000-08-25 18:39:46 +00:00
|
|
|
nsIWebBrowserChrome::CHROME_OPENAS_DIALOG : 0;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
/* and dialogs need to have the last word. assume dialogs are dialogs,
|
|
|
|
and opened as chrome, unless explicitly told otherwise. */
|
|
|
|
if (aDialog) {
|
|
|
|
if (!PL_strcasestr(aFeatures, "dialog"))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_DIALOG;
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!PL_strcasestr(aFeatures, "chrome"))
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_CHROME;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* missing
|
|
|
|
chromeFlags->copy_history
|
2000-02-08 13:40:10 +00:00
|
|
|
*/
|
1999-05-17 18:52:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
/* Allow disabling of commands only if there is no menubar */
|
|
|
|
/*if(!chromeFlags & NS_CHROME_MENU_BAR_ON) {
|
|
|
|
chromeFlags->disable_commands = !WinHasOption(aFeatures, "hotkeys");
|
|
|
|
if(XP_STRCASESTR(aFeatures,"hotkeys")==NULL)
|
|
|
|
chromeFlags->disable_commands = FALSE;
|
|
|
|
}
|
|
|
|
*/
|
1999-05-17 18:52:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
//Check security state for use in determing window dimensions
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager>
|
2000-09-13 23:57:52 +00:00
|
|
|
securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_TRUE(securityManager, NS_ERROR_FAILURE);
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool enabled;
|
|
|
|
nsresult res =
|
|
|
|
securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
res = securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_FAILED(res) || !enabled) {
|
|
|
|
//If priv check fails, set all elements to minimum reqs., else leave them alone.
|
2000-08-25 18:39:46 +00:00
|
|
|
chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR;
|
|
|
|
chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_LOWERED;
|
|
|
|
chromeFlags &= ~nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
|
2000-08-22 03:51:17 +00:00
|
|
|
//XXX Temporarily removing this check to allow modal dialogs to be
|
|
|
|
//raised from script. A more complete security based fix is needed.
|
2000-08-25 18:39:46 +00:00
|
|
|
//chromeFlags &= ~nsIWebBrowserChrome::CHROME_MODAL;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
1999-05-17 18:52:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return chromeFlags;
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
|
|
|
char *aFeatures,
|
|
|
|
PRUint32 aChromeFlags)
|
1999-05-14 03:10:51 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG(aDocShellItem);
|
|
|
|
|
|
|
|
// Use the current window's sizes as our default
|
|
|
|
PRInt32 chromeX = 0, chromeY = 0, chromeCX = 0, chromeCY = 0;
|
|
|
|
PRInt32 contentCX = 0, contentCY = 0;
|
1999-05-14 03:10:51 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> currentTreeOwnerAsWin;
|
|
|
|
GetTreeOwner(getter_AddRefs(currentTreeOwnerAsWin));
|
|
|
|
NS_ENSURE_TRUE(currentTreeOwnerAsWin, NS_ERROR_FAILURE);
|
1999-05-17 18:52:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
currentTreeOwnerAsWin->GetPositionAndSize(&chromeX, &chromeY, &chromeCX,
|
|
|
|
&chromeCY);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// if we are content, we may need the content sizes
|
|
|
|
nsCOMPtr<nsIBaseWindow> currentDocShellAsWin(do_QueryInterface(mDocShell));
|
|
|
|
currentDocShellAsWin->GetSize(&contentCX, &contentCY);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool present = PR_FALSE;
|
|
|
|
PRBool positionSpecified = PR_FALSE;
|
|
|
|
PRInt32 temp;
|
1999-05-14 03:10:51 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if ((temp = WinHasOption(aFeatures, "left", 0, &present)) || present)
|
|
|
|
chromeX = temp;
|
|
|
|
else if ((temp = WinHasOption(aFeatures, "screenX", 0, &present)) || present)
|
|
|
|
chromeX = temp;
|
2000-02-10 05:03:05 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (present)
|
|
|
|
positionSpecified = PR_TRUE;
|
2000-02-10 05:03:05 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
present = PR_FALSE;
|
2000-03-09 08:19:22 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if ((temp = WinHasOption(aFeatures, "top", 0, &present)) || present)
|
|
|
|
chromeY = temp;
|
|
|
|
else if ((temp = WinHasOption(aFeatures, "screenY", 0, &present)) || present)
|
|
|
|
chromeY = temp;
|
2000-02-10 05:03:05 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (present)
|
|
|
|
positionSpecified = PR_TRUE;
|
2000-02-10 05:03:05 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
present = PR_FALSE;
|
2000-03-09 08:19:22 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRBool sizeChrome = PR_FALSE;
|
|
|
|
PRBool sizeSpecified = PR_FALSE;
|
2000-02-10 05:03:05 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if ((temp = WinHasOption(aFeatures, "outerWidth", chromeCX, &present)) ||
|
|
|
|
present) {
|
|
|
|
chromeCX = temp;
|
|
|
|
sizeChrome = PR_TRUE;
|
|
|
|
sizeSpecified = PR_TRUE;
|
|
|
|
}
|
2000-03-31 07:34:32 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
present = PR_FALSE;
|
1999-05-17 18:52:21 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if ((temp = WinHasOption(aFeatures, "outerHeight", chromeCY, &present)) ||
|
|
|
|
present) {
|
|
|
|
chromeCY = temp;
|
|
|
|
sizeChrome = PR_TRUE;
|
|
|
|
sizeSpecified = PR_TRUE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// We haven't switched to chrome sizing so we need to get the content area
|
|
|
|
if (!sizeChrome) {
|
|
|
|
if ((temp = WinHasOption(aFeatures, "width", chromeCX, &present)) ||
|
|
|
|
present) {
|
|
|
|
contentCX = temp;
|
|
|
|
sizeSpecified = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if ((temp = WinHasOption(aFeatures, "innerWidth", chromeCX, &present))
|
|
|
|
|| present) {
|
|
|
|
contentCX = temp;
|
|
|
|
sizeSpecified = PR_TRUE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if ((temp = WinHasOption(aFeatures, "height", chromeCY, &present)) ||
|
|
|
|
present) {
|
|
|
|
contentCY = temp;
|
2000-02-08 22:45:45 +00:00
|
|
|
sizeSpecified = PR_TRUE;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
else if ((temp = WinHasOption(aFeatures, "innerHeight", chromeCY, &present))
|
|
|
|
|| present) {
|
|
|
|
contentCY = temp;
|
|
|
|
sizeSpecified = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult res;
|
|
|
|
PRBool enabled;
|
|
|
|
PRInt32 screenWidth = 0, screenHeight = 0;
|
|
|
|
PRInt32 winWidth, winHeight;
|
|
|
|
|
|
|
|
// Check security state for use in determing window dimensions
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager>
|
2000-09-13 23:57:52 +00:00
|
|
|
securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID));
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_TRUE(securityManager, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
res = securityManager->IsCapabilityEnabled("UniversalBrowserWrite", &enabled);
|
|
|
|
if (NS_FAILED(res)) {
|
|
|
|
enabled = PR_FALSE;
|
|
|
|
}
|
2000-08-15 20:01:20 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!enabled) {
|
|
|
|
// Security check failed. Ensure all args meet minimum reqs.
|
|
|
|
if (sizeSpecified) {
|
|
|
|
if (sizeChrome) {
|
|
|
|
chromeCX = chromeCX < 100 ? 100 : chromeCX;
|
|
|
|
chromeCY = chromeCY < 100 ? 100 : chromeCY;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
contentCX = contentCX < 100 ? 100 : contentCX;
|
|
|
|
contentCY = contentCY < 100 ? 100 : contentCY;
|
2000-08-15 20:01:20 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-03-31 07:34:32 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (positionSpecified) {
|
|
|
|
// We'll also need the screen dimensions
|
|
|
|
// XXX This should use nsIScreenManager once its fully fleshed out.
|
|
|
|
nsCOMPtr<nsIDOMScreen> screen;
|
|
|
|
if (NS_SUCCEEDED(GetScreen(getter_AddRefs(screen)))) {
|
|
|
|
screen->GetAvailWidth(&screenWidth);
|
|
|
|
screen->GetAvailHeight(&screenHeight);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// This isn't strictly true but close enough
|
|
|
|
winWidth = sizeSpecified ? (sizeChrome ? chromeCX : contentCX) : 100;
|
|
|
|
winHeight = sizeSpecified ? (sizeChrome ? chromeCY : contentCY) : 100;
|
|
|
|
|
|
|
|
chromeX =
|
|
|
|
screenWidth < chromeX + winWidth ? screenWidth - winWidth : chromeX;
|
|
|
|
chromeX = chromeX < 0 ? 0 : chromeX;
|
|
|
|
chromeY = screenHeight < chromeY + winHeight
|
|
|
|
? screenHeight - winHeight
|
|
|
|
: chromeY;
|
|
|
|
chromeY = chromeY < 0 ? 0 : chromeY;
|
|
|
|
}
|
|
|
|
}
|
2000-06-21 00:20:39 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
aDocShellItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_QueryInterface(treeOwner));
|
|
|
|
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (sizeChrome) {
|
|
|
|
if (positionSpecified && sizeSpecified)
|
|
|
|
treeOwnerAsWin->SetPositionAndSize(chromeX, chromeY, chromeCX,
|
|
|
|
chromeCY, PR_FALSE);
|
|
|
|
else {
|
|
|
|
if (sizeSpecified)
|
|
|
|
treeOwnerAsWin->SetSize(chromeCX, chromeCY, PR_FALSE);
|
|
|
|
if (positionSpecified)
|
|
|
|
treeOwnerAsWin->SetPosition(chromeX, chromeY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (positionSpecified)
|
|
|
|
treeOwnerAsWin->SetPosition(chromeX, chromeY);
|
|
|
|
if (sizeSpecified)
|
|
|
|
treeOwner->SizeShellTo(aDocShellItem, contentCX, contentCY);
|
|
|
|
}
|
|
|
|
treeOwnerAsWin->SetVisibility(PR_TRUE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-05-17 18:52:21 +00:00
|
|
|
}
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
// Return the nsIDOMWindowInternal corresponding to the given nsIWebShell.
|
2000-08-22 03:51:17 +00:00
|
|
|
// Note this forces the creation of a script context, if one has not already
|
|
|
|
// been created. Note it also sets the window's opener to this -- because
|
|
|
|
// it's just convenient, that's all.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::ReadyOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
|
2000-09-01 01:54:35 +00:00
|
|
|
nsIDOMWindowInternal **aDOMWindow)
|
1999-05-17 18:52:21 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
1999-05-17 18:52:21 +00:00
|
|
|
|
|
|
|
*aDOMWindow = nsnull;
|
2000-02-08 13:40:10 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(aDocShellItem));
|
1999-12-03 09:24:22 +00:00
|
|
|
NS_ENSURE_TRUE(globalObject, NS_ERROR_FAILURE);
|
|
|
|
res = CallQueryInterface(globalObject.get(), aDOMWindow);
|
2000-08-22 03:51:17 +00:00
|
|
|
globalObject->SetOpenerWindow(this); // damnit
|
1999-05-14 03:10:51 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-05-11 01:24:59 +00:00
|
|
|
// Print out a warning message and return NS_ERROR_FAILURE for illegal window names.
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::CheckWindowName(JSContext *cx, nsString& aName)
|
|
|
|
{
|
|
|
|
PRUint32 strIndex;
|
|
|
|
PRUnichar mChar;
|
|
|
|
|
|
|
|
for (strIndex = 0; strIndex < aName.Length(); strIndex++) {
|
|
|
|
mChar = aName.CharAt(strIndex);
|
|
|
|
if (!nsCRT::IsAsciiAlpha(mChar) && !nsCRT::IsAsciiDigit(mChar) &&
|
|
|
|
mChar != '_') {
|
|
|
|
// Don't use js_ReportError as this will cause the application
|
|
|
|
// to shut down (JS_ASSERT calls abort()) See bug 32898
|
|
|
|
nsAutoString warn;
|
|
|
|
warn.AssignWithConversion("Illegal character in window name ");
|
|
|
|
warn.Append(aName);
|
|
|
|
char *cp = warn.ToNewCString();
|
|
|
|
NS_WARNING(cp);
|
|
|
|
nsCRT::free(cp);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-06-26 21:48:29 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
PRInt32 GlobalWindowImpl::WinHasOption(char *aOptions, const char *aName,
|
|
|
|
PRInt32 aDefault, PRBool *aPresenceFlag)
|
|
|
|
{
|
|
|
|
if (!aOptions)
|
|
|
|
return 0;
|
|
|
|
char *comma, *equal;
|
|
|
|
PRInt32 found = 0;
|
|
|
|
|
|
|
|
while (PR_TRUE) {
|
|
|
|
while (nsCRT::IsAsciiSpace(*aOptions))
|
|
|
|
aOptions++;
|
|
|
|
|
|
|
|
comma = strchr(aOptions, ',');
|
|
|
|
if (comma)
|
|
|
|
*comma = '\0';
|
|
|
|
equal = strchr(aOptions, '=');
|
|
|
|
if (equal)
|
|
|
|
*equal = '\0';
|
|
|
|
if (nsCRT::strcasecmp(aOptions, aName) == 0) {
|
|
|
|
if (aPresenceFlag)
|
|
|
|
*aPresenceFlag = PR_TRUE;
|
|
|
|
if (equal)
|
|
|
|
if (*(equal + 1) == '*')
|
|
|
|
found = aDefault;
|
|
|
|
else if (nsCRT::strcasecmp(equal + 1, "yes") == 0)
|
|
|
|
found = 1;
|
|
|
|
else
|
|
|
|
found = atoi(equal + 1);
|
|
|
|
else
|
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
if (equal)
|
|
|
|
*equal = '=';
|
|
|
|
if (comma)
|
|
|
|
*comma = ',';
|
|
|
|
if (found || !comma)
|
|
|
|
break;
|
|
|
|
aOptions = comma + 1;
|
|
|
|
}
|
|
|
|
return found;
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
void GlobalWindowImpl::CloseWindow(nsISupports *aWindow)
|
1998-08-07 04:45:03 +00:00
|
|
|
{
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> win(do_QueryInterface(aWindow));
|
1998-08-07 04:45:03 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
win->Close();
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl: Timeout Functions
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1999-11-17 23:05:29 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
static const char *kSetIntervalStr = "setInterval";
|
|
|
|
static const char *kSetTimeoutStr = "setTimeout";
|
1998-08-07 04:45:03 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::SetTimeoutOrInterval(JSContext *cx,
|
|
|
|
jsval *argv, PRUint32 argc,
|
|
|
|
PRInt32 *aReturn,
|
|
|
|
PRBool aIsInterval)
|
1998-08-13 23:37:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
JSString *expr = nsnull;
|
|
|
|
JSObject *funobj = nsnull;
|
2000-09-15 19:22:03 +00:00
|
|
|
nsTimeoutImpl *timeout;
|
2000-08-22 03:51:17 +00:00
|
|
|
jsdouble interval;
|
|
|
|
PRInt64 now, delta;
|
1998-08-13 23:37:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (argc < 2) {
|
|
|
|
::JS_ReportError(cx, "Function %s requires at least 2 parameters",
|
|
|
|
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!::JS_ValueToNumber(cx, argv[1], &interval)) {
|
|
|
|
::JS_ReportError(cx,
|
|
|
|
"Second argument to %s must be a millisecond interval",
|
|
|
|
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
|
|
|
return NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
switch (::JS_TypeOfValue(cx, argv[0])) {
|
|
|
|
case JSTYPE_FUNCTION:
|
|
|
|
funobj = JSVAL_TO_OBJECT(argv[0]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case JSTYPE_STRING:
|
|
|
|
case JSTYPE_OBJECT:
|
|
|
|
if (!(expr = ::JS_ValueToString(cx, argv[0])))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
if (!expr)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
argv[0] = STRING_TO_JSVAL(expr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
::JS_ReportError(cx, "useless %s call (missing quotes around argument?)",
|
2000-02-08 13:40:10 +00:00
|
|
|
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
timeout = PR_NEWZAP(nsTimeoutImpl);
|
|
|
|
if (!timeout)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
// Initial ref_count to indicate that this timeout struct will
|
|
|
|
// be held as the closure of a timer.
|
|
|
|
timeout->ref_count = 1;
|
|
|
|
if (aIsInterval)
|
|
|
|
timeout->interval = (PRInt32) interval;
|
|
|
|
if (expr) {
|
|
|
|
if (!::JS_AddNamedRoot(cx, &timeout->expr, "timeout.expr")) {
|
|
|
|
PR_DELETE(timeout);
|
2000-02-08 13:40:10 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
timeout->expr = expr;
|
|
|
|
}
|
|
|
|
else if (funobj) {
|
|
|
|
int i;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
/* Leave an extra slot for a secret final argument that
|
|
|
|
indicates to the called function how "late" the timeout is. */
|
|
|
|
timeout->argv = (jsval *) PR_MALLOC((argc - 1) * sizeof(jsval));
|
|
|
|
if (!timeout->argv) {
|
|
|
|
DropTimeout(timeout);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!::JS_AddNamedRoot(cx, &timeout->funobj, "timeout.funobj")) {
|
|
|
|
DropTimeout(timeout);
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
timeout->funobj = funobj;
|
|
|
|
|
|
|
|
timeout->argc = 0;
|
|
|
|
for (i = 2; (PRUint32) i < argc; i++) {
|
|
|
|
timeout->argv[i - 2] = argv[i];
|
|
|
|
if (!::JS_AddNamedRoot(cx, &timeout->argv[i - 2], "timeout.argv[i]")) {
|
|
|
|
DropTimeout(timeout);
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-10-06 20:59:39 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
timeout->argc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *filename;
|
|
|
|
if (nsJSUtils::nsGetCallingLocation(cx, &filename, &timeout->lineno)) {
|
|
|
|
timeout->filename = PL_strdup(filename);
|
|
|
|
if (!timeout->filename) {
|
|
|
|
DropTimeout(timeout);
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
timeout->version = ::JS_VersionToString(::JS_GetVersion(cx));
|
|
|
|
|
|
|
|
// Get principal of currently executing code, save for execution of timeout
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager>
|
2000-09-13 23:57:52 +00:00
|
|
|
securityManager(do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv));
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
if (NS_FAILED(securityManager->GetSubjectPrincipal(&timeout->principal)))
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-08-13 23:37:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
LL_I2L(now, PR_IntervalNow());
|
|
|
|
LL_D2L(delta, PR_MillisecondsToInterval((PRUint32) interval));
|
|
|
|
LL_ADD(timeout->when, now, delta);
|
|
|
|
nsresult err;
|
2000-09-13 23:57:52 +00:00
|
|
|
timeout->timer = do_CreateInstance("@mozilla.org/timer;1", &err);
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_OK != err) {
|
|
|
|
DropTimeout(timeout);
|
|
|
|
return err;
|
|
|
|
}
|
1998-08-13 23:37:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
err = timeout->timer->Init(nsGlobalWindow_RunTimeout, timeout,
|
|
|
|
(PRInt32) interval, NS_PRIORITY_LOWEST);
|
|
|
|
if (NS_OK != err) {
|
|
|
|
DropTimeout(timeout);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
timeout->window = this;
|
|
|
|
NS_ADDREF(this);
|
1998-07-24 05:05:42 +00:00
|
|
|
|
2000-09-15 19:22:03 +00:00
|
|
|
InsertTimeoutIntoList(mTimeoutInsertionPoint, timeout);
|
2000-08-22 03:51:17 +00:00
|
|
|
timeout->public_id = ++mTimeoutPublicIdCounter;
|
|
|
|
*aReturn = timeout->public_id;
|
1998-07-24 05:05:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
PRBool GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|
|
|
{
|
2000-02-15 01:32:19 +00:00
|
|
|
nsTimeoutImpl *next, *prev, *timeout;
|
|
|
|
nsTimeoutImpl *last_expired_timeout, **last_insertion_point;
|
|
|
|
nsTimeoutImpl dummy_timeout;
|
|
|
|
JSContext *cx;
|
|
|
|
PRInt64 now;
|
2000-05-20 03:57:59 +00:00
|
|
|
nsCOMPtr<nsITimer> timer;
|
2000-02-15 01:32:19 +00:00
|
|
|
nsresult rv;
|
2000-08-22 03:51:17 +00:00
|
|
|
PRUint32 firingDepth = mTimeoutFiringDepth + 1;
|
2000-02-15 01:32:19 +00:00
|
|
|
|
2000-02-26 02:28:27 +00:00
|
|
|
if (nsnull == mContext) {
|
2000-02-26 02:56:29 +00:00
|
|
|
return PR_TRUE;
|
2000-02-26 02:28:27 +00:00
|
|
|
}
|
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Make sure that the window or the script context don't go away as
|
|
|
|
a result of running timeouts */
|
2000-08-22 03:51:17 +00:00
|
|
|
GlobalWindowImpl *temp = this;
|
2000-02-15 01:32:19 +00:00
|
|
|
NS_ADDREF(temp);
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIScriptContext *tempContext = mContext;
|
2000-02-15 01:32:19 +00:00
|
|
|
NS_ADDREF(tempContext);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
timer = aTimeout->timer;
|
2000-08-22 03:51:17 +00:00
|
|
|
cx = (JSContext *) mContext->GetNativeContext();
|
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* A native timer has gone off. See which of our timeouts need
|
|
|
|
servicing */
|
|
|
|
LL_I2L(now, PR_IntervalNow());
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* The timeout list is kept in deadline order. Discover the
|
|
|
|
latest timeout whose deadline has expired. On some platforms,
|
|
|
|
native timeout events fire "early", so we need to test the
|
|
|
|
timer as well as the deadline. */
|
|
|
|
last_expired_timeout = nsnull;
|
2000-08-22 03:51:17 +00:00
|
|
|
for (timeout = mTimeouts; timeout; timeout = timeout->next) {
|
|
|
|
if (((timeout == aTimeout) || !LL_CMP(timeout->when, >, now)) &&
|
|
|
|
(0 == timeout->firingDepth)) {
|
2000-02-15 01:32:19 +00:00
|
|
|
/*
|
|
|
|
* Mark any timeouts that are on the list to be fired with the
|
|
|
|
* firing depth so that we can reentrantly run timeouts
|
|
|
|
*/
|
|
|
|
timeout->firingDepth = firingDepth;
|
|
|
|
last_expired_timeout = timeout;
|
|
|
|
}
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Maybe the timeout that the event was fired for has been deleted
|
|
|
|
and there are no others timeouts with deadlines that make them
|
|
|
|
eligible for execution yet. Go away. */
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!last_expired_timeout) {
|
2000-02-15 01:32:19 +00:00
|
|
|
NS_RELEASE(temp);
|
|
|
|
NS_RELEASE(tempContext);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Insert a dummy timeout into the list of timeouts between the portion
|
|
|
|
of the list that we are about to process now and those timeouts that
|
|
|
|
will be processed in a future call to win_run_timeout(). This dummy
|
|
|
|
timeout serves as the head of the list for any timeouts inserted as
|
|
|
|
a result of running a timeout. */
|
|
|
|
dummy_timeout.timer = NULL;
|
|
|
|
dummy_timeout.public_id = 0;
|
|
|
|
dummy_timeout.firingDepth = firingDepth;
|
|
|
|
dummy_timeout.next = last_expired_timeout->next;
|
|
|
|
last_expired_timeout->next = &dummy_timeout;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Don't let ClearWindowTimeouts throw away our stack-allocated
|
|
|
|
dummy timeout. */
|
|
|
|
dummy_timeout.ref_count = 2;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
last_insertion_point = mTimeoutInsertionPoint;
|
|
|
|
mTimeoutInsertionPoint = &dummy_timeout.next;
|
1998-08-13 04:34:53 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
prev = nsnull;
|
2000-08-22 03:51:17 +00:00
|
|
|
for (timeout = mTimeouts; timeout != &dummy_timeout; timeout = next) {
|
2000-02-15 01:32:19 +00:00
|
|
|
next = timeout->next;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
/*
|
2000-02-15 01:32:19 +00:00
|
|
|
* Check to see if it should fire at this depth. If it shouldn't, we'll
|
|
|
|
* ignore it
|
|
|
|
*/
|
|
|
|
if (timeout->firingDepth == firingDepth) {
|
2000-08-22 03:51:17 +00:00
|
|
|
nsTimeoutImpl *last_running_timeout;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
/* Hold the timeout in case expr or funobj releases its doc. */
|
|
|
|
HoldTimeout(timeout);
|
2000-02-15 01:32:19 +00:00
|
|
|
last_running_timeout = mRunningTimeout;
|
2000-02-08 13:40:10 +00:00
|
|
|
mRunningTimeout = timeout;
|
2000-02-15 01:32:19 +00:00
|
|
|
++mTimeoutFiringDepth;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (timeout->expr) {
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Evaluate the timeout expression. */
|
2000-08-22 03:51:17 +00:00
|
|
|
nsAutoString script(NS_REINTERPRET_CAST(const PRUnichar *,
|
|
|
|
::JS_GetStringChars(timeout->expr)));
|
2000-04-03 09:03:21 +00:00
|
|
|
nsAutoString blank;
|
2000-02-15 01:32:19 +00:00
|
|
|
PRBool isUndefined;
|
|
|
|
rv = mContext->EvaluateString(script,
|
|
|
|
mScriptObject,
|
|
|
|
timeout->principal,
|
|
|
|
timeout->filename,
|
|
|
|
timeout->lineno,
|
2000-08-22 03:51:17 +00:00
|
|
|
timeout->version, blank, &isUndefined);
|
|
|
|
}
|
|
|
|
else {
|
2000-02-15 01:32:19 +00:00
|
|
|
PRInt64 lateness64;
|
|
|
|
PRInt32 lateness;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Add "secret" final argument that indicates timeout
|
|
|
|
lateness in milliseconds */
|
|
|
|
LL_SUB(lateness64, now, timeout->when);
|
|
|
|
LL_L2I(lateness, lateness64);
|
|
|
|
lateness = PR_IntervalToMilliseconds(lateness);
|
2000-08-22 03:51:17 +00:00
|
|
|
timeout->argv[timeout->argc] = INT_TO_JSVAL((jsint) lateness);
|
2000-02-15 01:32:19 +00:00
|
|
|
PRBool aBoolResult;
|
|
|
|
rv = mContext->CallEventHandler(mScriptObject, timeout->funobj,
|
|
|
|
timeout->argc + 1, timeout->argv,
|
2000-04-24 04:41:27 +00:00
|
|
|
&aBoolResult, PR_FALSE);
|
2000-02-15 01:32:19 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
--mTimeoutFiringDepth;
|
|
|
|
mRunningTimeout = last_running_timeout;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2000-02-15 01:32:19 +00:00
|
|
|
mTimeoutInsertionPoint = last_insertion_point;
|
|
|
|
NS_RELEASE(temp);
|
|
|
|
NS_RELEASE(tempContext);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
/* If the temporary reference is the only one that is keeping
|
|
|
|
the timeout around, the document was released and we should
|
|
|
|
restart this function. */
|
2000-08-22 03:51:17 +00:00
|
|
|
if (timeout->ref_count == 1) {
|
2000-02-15 01:32:19 +00:00
|
|
|
mTimeoutInsertionPoint = last_insertion_point;
|
|
|
|
DropTimeout(timeout, tempContext);
|
|
|
|
NS_RELEASE(temp);
|
|
|
|
NS_RELEASE(tempContext);
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
DropTimeout(timeout, tempContext);
|
|
|
|
|
|
|
|
/* If we have a regular interval timer, we re-fire the
|
|
|
|
* timeout, accounting for clock drift.
|
|
|
|
*/
|
2000-08-22 03:51:17 +00:00
|
|
|
if (timeout->interval) {
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Compute time to next timeout for interval timer. */
|
|
|
|
PRInt32 delay32;
|
|
|
|
PRInt64 interval, delay;
|
|
|
|
LL_I2L(interval, PR_MillisecondsToInterval(timeout->interval));
|
|
|
|
LL_ADD(timeout->when, timeout->when, interval);
|
|
|
|
LL_I2L(now, PR_IntervalNow());
|
|
|
|
LL_SUB(delay, timeout->when, now);
|
|
|
|
LL_L2I(delay32, delay);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* If the next interval timeout is already supposed to
|
|
|
|
* have happened then run the timeout immediately.
|
|
|
|
*/
|
2000-08-22 03:51:17 +00:00
|
|
|
if (delay32 < 0)
|
2000-02-15 01:32:19 +00:00
|
|
|
delay32 = 0;
|
|
|
|
delay32 = PR_IntervalToMilliseconds(delay32);
|
|
|
|
|
|
|
|
/* Reschedule timeout. Account for possible error return in
|
|
|
|
code below that checks for zero toid. */
|
2000-05-17 02:49:35 +00:00
|
|
|
nsresult err;
|
2000-08-22 03:51:17 +00:00
|
|
|
timeout->timer =
|
2000-09-13 23:57:52 +00:00
|
|
|
do_CreateInstance("@mozilla.org/timer;1", &err);
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_OK != err) {
|
2000-02-15 01:32:19 +00:00
|
|
|
mTimeoutInsertionPoint = last_insertion_point;
|
|
|
|
NS_RELEASE(temp);
|
|
|
|
NS_RELEASE(tempContext);
|
|
|
|
return PR_TRUE;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = timeout->timer->Init(nsGlobalWindow_RunTimeout, timeout,
|
2000-02-15 01:32:19 +00:00
|
|
|
delay32, NS_PRIORITY_LOWEST);
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_OK != err) {
|
2000-02-15 01:32:19 +00:00
|
|
|
NS_RELEASE(temp);
|
|
|
|
NS_RELEASE(tempContext);
|
|
|
|
return PR_TRUE;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
2000-02-15 01:32:19 +00:00
|
|
|
// Increment ref_count to indicate that this timer is holding
|
|
|
|
// on to the timeout struct.
|
|
|
|
HoldTimeout(timeout);
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
|
|
|
/* Running a timeout can cause another timeout to be deleted,
|
|
|
|
so we need to reset the pointer to the following timeout. */
|
|
|
|
next = timeout->next;
|
2000-02-15 01:32:19 +00:00
|
|
|
if (nsnull == prev) {
|
|
|
|
mTimeouts = next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prev->next = next;
|
|
|
|
}
|
2000-02-26 02:28:27 +00:00
|
|
|
|
|
|
|
PRBool isInterval = (timeout->interval && timeout->timer);
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
// Drop timeout struct since it's out of the list
|
|
|
|
DropTimeout(timeout, tempContext);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
/* Free the timeout if this is not a repeating interval
|
|
|
|
* timeout (or if it was an interval timeout, but we were
|
|
|
|
* unsuccessful at rescheduling it.)
|
|
|
|
*/
|
2000-08-22 03:51:17 +00:00
|
|
|
if (isInterval) {
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Reschedule an interval timeout */
|
|
|
|
/* Insert interval timeout onto list sorted in deadline order. */
|
|
|
|
InsertTimeoutIntoList(mTimeoutInsertionPoint, timeout);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-02-15 01:32:19 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-08-22 03:51:17 +00:00
|
|
|
/*
|
2000-02-15 01:32:19 +00:00
|
|
|
* We skip the timeout since it's on the list to run at another
|
|
|
|
* depth.
|
|
|
|
*/
|
|
|
|
prev = timeout;
|
|
|
|
}
|
|
|
|
}
|
1998-07-24 05:05:42 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
/* Take the dummy timeout off the head of the list */
|
|
|
|
if (nsnull == prev) {
|
|
|
|
mTimeouts = dummy_timeout.next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
prev->next = dummy_timeout.next;
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-02-15 01:32:19 +00:00
|
|
|
mTimeoutInsertionPoint = last_insertion_point;
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
/* Get rid of our temporary references to ourselves and the script context */
|
2000-02-15 01:32:19 +00:00
|
|
|
NS_RELEASE(temp);
|
|
|
|
NS_RELEASE(tempContext);
|
|
|
|
return PR_TRUE;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
void GlobalWindowImpl::DropTimeout(nsTimeoutImpl *aTimeout,
|
2000-08-22 03:51:17 +00:00
|
|
|
nsIScriptContext *aContext)
|
|
|
|
{
|
|
|
|
JSContext *cx;
|
|
|
|
|
|
|
|
if (--aTimeout->ref_count > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!aContext)
|
|
|
|
aContext = mContext;
|
|
|
|
if (aContext) {
|
|
|
|
cx = (JSContext *) aContext->GetNativeContext();
|
|
|
|
|
|
|
|
if (aTimeout->expr)
|
|
|
|
::JS_RemoveRoot(cx, &aTimeout->expr);
|
|
|
|
else if (aTimeout->funobj) {
|
|
|
|
::JS_RemoveRoot(cx, &aTimeout->funobj);
|
|
|
|
if (aTimeout->argv) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < aTimeout->argc; i++)
|
|
|
|
::JS_RemoveRoot(cx, &aTimeout->argv[i]);
|
|
|
|
PR_FREEIF(aTimeout->argv);
|
1999-06-09 07:38:26 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aTimeout->timer) {
|
|
|
|
aTimeout->timer->Cancel();
|
|
|
|
aTimeout->timer = nsnull;
|
|
|
|
}
|
|
|
|
PR_FREEIF(aTimeout->filename);
|
|
|
|
NS_IF_RELEASE(aTimeout->window);
|
|
|
|
NS_IF_RELEASE(aTimeout->principal);
|
|
|
|
PR_DELETE(aTimeout);
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
void GlobalWindowImpl::HoldTimeout(nsTimeoutImpl *aTimeout)
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
aTimeout->ref_count++;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::ClearTimeoutOrInterval(PRInt32 aTimerID)
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
PRUint32 public_id;
|
|
|
|
nsTimeoutImpl **top, *timeout;
|
1998-07-24 05:05:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
public_id = (PRUint32) aTimerID;
|
|
|
|
if (!public_id) { /* id of zero is reserved for internal use */
|
|
|
|
/* return silently for compatibility (see bug 30700) */
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
for (top = &mTimeouts; (timeout = *top) != NULL; top = &timeout->next) {
|
|
|
|
if (timeout->public_id == public_id) {
|
|
|
|
if (mRunningTimeout == timeout) {
|
|
|
|
/* We're running from inside the timeout. Mark this
|
|
|
|
timeout for deferred deletion by the code in
|
|
|
|
win_run_timeout() */
|
|
|
|
timeout->interval = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Delete the timeout from the pending timeout list */
|
|
|
|
*top = timeout->next;
|
|
|
|
if (timeout->timer) {
|
|
|
|
timeout->timer->Cancel();
|
|
|
|
DropTimeout(timeout);
|
|
|
|
}
|
|
|
|
DropTimeout(timeout);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
void GlobalWindowImpl::ClearAllTimeouts()
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsTimeoutImpl *timeout, *next;
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
for (timeout = mTimeouts; timeout; timeout = next) {
|
|
|
|
/* If RunTimeout() is higher up on the stack for this
|
|
|
|
window, e.g. as a result of document.write from a timeout,
|
|
|
|
then we need to reset the list insertion point for
|
|
|
|
newly-created timeouts in case the user adds a timeout,
|
|
|
|
before we pop the stack back to RunTimeout. */
|
|
|
|
if (mRunningTimeout == timeout)
|
2000-09-15 19:22:03 +00:00
|
|
|
mTimeoutInsertionPoint = &mTimeouts;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
next = timeout->next;
|
|
|
|
if (timeout->timer) {
|
|
|
|
timeout->timer->Cancel();
|
|
|
|
// Drop the count since the timer isn't going to hold on
|
|
|
|
// anymore.
|
2000-02-08 13:40:10 +00:00
|
|
|
DropTimeout(timeout);
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
// Drop the count since we're removing it from the list.
|
|
|
|
DropTimeout(timeout);
|
|
|
|
}
|
|
|
|
mTimeouts = NULL;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
void GlobalWindowImpl::InsertTimeoutIntoList(nsTimeoutImpl **aList,
|
|
|
|
nsTimeoutImpl *aTimeout)
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsTimeoutImpl *to;
|
|
|
|
|
2000-09-15 19:22:03 +00:00
|
|
|
NS_ASSERTION(aList, "GlobalWindowImpl::InsertTimeoutIntoList null timeoutList");
|
2000-08-22 03:51:17 +00:00
|
|
|
while ((to = *aList) != nsnull) {
|
|
|
|
if (LL_CMP(to->when, >, aTimeout->when))
|
|
|
|
break;
|
|
|
|
aList = &to->next;
|
|
|
|
}
|
|
|
|
aTimeout->firingDepth = 0;
|
|
|
|
aTimeout->next = to;
|
|
|
|
*aList = aTimeout;
|
|
|
|
// Increment the ref_count since we're in the list
|
|
|
|
HoldTimeout(aTimeout);
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
void nsGlobalWindow_RunTimeout(nsITimer *aTimer, void *aClosure)
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsTimeoutImpl *timeout = (nsTimeoutImpl *) aClosure;
|
1998-07-24 05:05:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
if (timeout->window->RunTimeout(timeout)) {
|
|
|
|
// Drop the ref_count since the timer won't be holding on to the
|
|
|
|
// timeout struct anymore
|
|
|
|
timeout->window->DropTimeout(timeout);
|
|
|
|
}
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl: Helper Functions
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1999-03-28 22:19:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetTreeOwner(nsIDocShellTreeOwner **aTreeOwner)
|
1999-03-28 22:19:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
1999-03-28 22:19:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return docShellAsItem->GetTreeOwner(aTreeOwner);
|
1999-03-28 22:19:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP GlobalWindowImpl::GetTreeOwner(nsIBaseWindow **aTreeOwner)
|
1999-03-28 22:19:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
1999-03-28 22:19:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
if (!treeOwner) {
|
|
|
|
*aTreeOwner = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return CallQueryInterface(treeOwner, aTreeOwner);
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetWebBrowserChrome(nsIWebBrowserChrome **aBrowserChrome)
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
GetTreeOwner(getter_AddRefs(treeOwner));
|
1998-07-24 05:05:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
|
|
|
|
*aBrowserChrome = browserChrome;
|
|
|
|
NS_IF_ADDREF(*aBrowserChrome);
|
|
|
|
return NS_OK;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView,
|
|
|
|
float *aP2T, float *aT2P)
|
1998-07-24 05:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
mDocShell->GetPresContext(getter_AddRefs(presContext));
|
|
|
|
if (presContext) {
|
|
|
|
presContext->GetPixelsToTwips(aP2T);
|
|
|
|
presContext->GetTwipsToPixels(aT2P);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
presContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
if (presShell) {
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
if (vm)
|
|
|
|
return vm->GetRootScrollableView(aScrollableView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-07-24 05:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
void GlobalWindowImpl::FlushPendingNotifications()
|
1999-09-21 14:18:52 +00:00
|
|
|
{
|
2000-08-29 00:14:23 +00:00
|
|
|
if (mDocument) {
|
|
|
|
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
|
|
|
|
if (doc)
|
|
|
|
doc->FlushPendingNotifications();
|
|
|
|
}
|
|
|
|
}
|
1999-09-21 14:18:52 +00:00
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
nsresult
|
|
|
|
GlobalWindowImpl::RegisterEventListener(const char* aEventName,
|
|
|
|
REFNSIID aIID)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAtom> eventName = dont_AddRef(NS_NewAtom(aEventName));
|
2000-08-22 03:51:17 +00:00
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
// This should only happen from JS
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIThreadJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
2000-08-29 00:14:23 +00:00
|
|
|
NS_ENSURE_TRUE(stack, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
JSContext* cx;
|
|
|
|
NS_ENSURE_SUCCESS(stack->Peek(&cx), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
|
1999-09-21 14:18:52 +00:00
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
nsCOMPtr<nsIEventListenerManager> manager;
|
2000-05-17 05:27:22 +00:00
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
if (NS_OK == GetListenerManager(getter_AddRefs(manager))) {
|
|
|
|
nsCOMPtr<nsIScriptContext> scriptCX;
|
|
|
|
nsJSUtils::nsGetDynamicScriptContext(cx, getter_AddRefs(scriptCX));
|
|
|
|
if (!scriptCX ||
|
|
|
|
NS_FAILED(manager->RegisterScriptEventListener(scriptCX, this,
|
|
|
|
eventName,
|
|
|
|
aIID))) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-17 06:53:58 +00:00
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
return NS_OK;
|
1999-09-21 14:18:52 +00:00
|
|
|
}
|
|
|
|
|
2000-08-29 00:14:23 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnmousedown(jsval* aOnmousedown)
|
2000-02-11 07:14:41 +00:00
|
|
|
{
|
2000-08-29 00:14:23 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnmousedown(jsval aOnmousedown)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onmousedown", NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnmouseup(jsval* aOnmouseup)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnmouseup(jsval aOnmouseup)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onmouseup", NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnclick(jsval* aOnclick)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnclick(jsval aOnclick)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onclick", NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnmouseover(jsval* aOnmouseover)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnmouseover(jsval aOnmouseover)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onmouseover", NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnmouseout(jsval* aOnmouseout)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnmouseout(jsval aOnmouseout)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onmouseout", NS_GET_IID(nsIDOMMouseListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnkeydown(jsval* aOnkeydown)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnkeydown(jsval aOnkeydown)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onkeydown", NS_GET_IID(nsIDOMKeyListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnkeyup(jsval* aOnkeyup)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnkeyup(jsval aOnkeyup)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onkeyup", NS_GET_IID(nsIDOMKeyListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnkeypress(jsval* aOnkeypress)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnkeypress(jsval aOnkeypress)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onkeypress", NS_GET_IID(nsIDOMKeyListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnmousemove(jsval* aOnmousemove)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnmousemove(jsval aOnmousemove)
|
|
|
|
{
|
2000-09-15 06:07:51 +00:00
|
|
|
return RegisterEventListener("onmousemove", NS_GET_IID(nsIDOMMouseMotionListener));
|
2000-08-29 00:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnfocus(jsval* aOnfocus)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnfocus(jsval aOnfocus)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onfocus", NS_GET_IID(nsIDOMFocusListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnblur(jsval* aOnblur)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnblur(jsval aOnblur)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onblur", NS_GET_IID(nsIDOMFocusListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnsubmit(jsval* aOnsubmit)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnsubmit(jsval aOnsubmit)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onsubmit", NS_GET_IID(nsIDOMFormListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnreset(jsval* aOnreset)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnreset(jsval aOnreset)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onreset", NS_GET_IID(nsIDOMFormListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnchange(jsval* aOnchange)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnchange(jsval aOnchange)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onchange", NS_GET_IID(nsIDOMFormListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnselect(jsval* aOnselect)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnselect(jsval aOnselect)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onselect", NS_GET_IID(nsIDOMFormListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnload(jsval* aOnload)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnload(jsval aOnload)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onload", NS_GET_IID(nsIDOMLoadListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnunload(jsval* aOnunload)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnunload(jsval aOnunload)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onunload", NS_GET_IID(nsIDOMLoadListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnclose(jsval* aOnclose)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnclose(jsval aOnclose)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onclose", NS_GET_IID(nsIDOMLoadListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnabort(jsval* aOnabort)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnabort(jsval aOnabort)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onabort", NS_GET_IID(nsIDOMLoadListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnerror(jsval* aOnerror)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnerror(jsval aOnerror)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onerror", NS_GET_IID(nsIDOMLoadListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnpaint(jsval* aOnpaint)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnpaint(jsval aOnpaint)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onpaint", NS_GET_IID(nsIDOMPaintListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOndragdrop(jsval* aOndragdrop)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOndragdrop(jsval aOndragdrop)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("ondragdrop", NS_GET_IID(nsIDOMDragListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnresize(jsval* aOnresize)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnresize(jsval aOnresize)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onresize", NS_GET_IID(nsIDOMPaintListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::GetOnscroll(jsval* aOnscroll)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
GlobalWindowImpl::SetOnscroll(jsval aOnscroll)
|
|
|
|
{
|
|
|
|
return RegisterEventListener("onscroll", NS_GET_IID(nsIDOMPaintListener));
|
2000-02-11 07:14:41 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// GlobalWindowImpl: Creator Function (This should go away)
|
2000-08-22 03:51:17 +00:00
|
|
|
//*****************************************************************************
|
1999-07-07 07:50:03 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
extern
|
|
|
|
"C" NS_DOM nsresult NS_NewScriptGlobalObject(nsIScriptGlobalObject **aResult)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
|
|
|
|
*aResult = nsnull;
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
GlobalWindowImpl *global =
|
|
|
|
new GlobalWindowImpl();
|
|
|
|
NS_ENSURE_TRUE(global, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
return CallQueryInterface(NS_STATIC_CAST(nsIScriptGlobalObject *, global),
|
|
|
|
aResult);
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** NavigatorImpl: Object Management
|
|
|
|
//*****************************************************************************
|
1999-07-07 07:50:03 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NavigatorImpl::NavigatorImpl():mScriptObject(nsnull), mMimeTypes(nsnull),
|
|
|
|
mPlugins(nsnull)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INIT_REFCNT();
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NavigatorImpl::~NavigatorImpl()
|
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IF_RELEASE(mMimeTypes);
|
|
|
|
NS_IF_RELEASE(mPlugins);
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// NavigatorImpl::nsISupports
|
|
|
|
//*****************************************************************************
|
|
|
|
|
1998-07-16 01:16:47 +00:00
|
|
|
NS_IMPL_ADDREF(NavigatorImpl)
|
|
|
|
NS_IMPL_RELEASE(NavigatorImpl)
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(NavigatorImpl)
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptObjectOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectOwner)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator)
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-07-16 01:16:47 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// NavigatorImpl::nsIScriptObjectOwner
|
|
|
|
//*****************************************************************************
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::SetScriptObject(void *aScriptObject)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
mScriptObject = aScriptObject;
|
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetScriptObject(nsIScriptContext *aContext,
|
|
|
|
void **aScriptObject)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
|
|
|
|
nsresult res = NS_OK;
|
|
|
|
if (!mScriptObject) {
|
|
|
|
nsIScriptGlobalObject *global = aContext->GetGlobalObject();
|
|
|
|
res =
|
|
|
|
NS_NewScriptNavigator(aContext,
|
|
|
|
(nsISupports *) (nsIDOMNavigator *) this, global,
|
|
|
|
&mScriptObject);
|
|
|
|
NS_IF_RELEASE(global);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aScriptObject = mScriptObject;
|
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
// NavigatorImpl::nsIDOMNavigator
|
|
|
|
//*****************************************************************************
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetUserAgent(nsAWritableString& aUserAgent)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *ua = nsnull;
|
|
|
|
res = service->GetUserAgent(&ua);
|
|
|
|
aUserAgent = ua;
|
|
|
|
Recycle(ua);
|
|
|
|
}
|
1999-08-03 19:00:51 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetAppCodeName(nsAWritableString& aAppCodeName)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *appName = nsnull;
|
|
|
|
res = service->GetAppName(&appName);
|
|
|
|
aAppCodeName = appName;
|
|
|
|
Recycle(appName);
|
|
|
|
}
|
1998-09-17 00:55:35 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetAppVersion(nsAWritableString& aAppVersion)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *str = nsnull;
|
|
|
|
res = service->GetAppVersion(&str);
|
|
|
|
aAppVersion = str;
|
|
|
|
Recycle(str);
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
aAppVersion.Append(NS_LITERAL_STRING(" ("));
|
2000-08-22 03:51:17 +00:00
|
|
|
res = service->GetPlatform(&str);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
aAppVersion += str;
|
|
|
|
Recycle(str);
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
aAppVersion.Append(NS_LITERAL_STRING("; "));
|
2000-08-22 03:51:17 +00:00
|
|
|
res = service->GetLanguage(&str);
|
|
|
|
if (NS_FAILED(res))
|
|
|
|
return res;
|
|
|
|
|
|
|
|
aAppVersion += str;
|
|
|
|
Recycle(str);
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
aAppVersion.Append(PRUnichar(')'));
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
1998-09-17 00:55:35 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetAppName(nsAWritableString& aAppName)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-23 17:27:06 +00:00
|
|
|
aAppName.Assign(NS_LITERAL_STRING("Netscape"));
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetLanguage(nsAWritableString& aLanguage)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *lang = nsnull;
|
|
|
|
res = service->GetLanguage(&lang);
|
|
|
|
aLanguage = lang;
|
|
|
|
Recycle(lang);
|
|
|
|
}
|
1998-09-17 00:55:35 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetPlatform(nsAWritableString& aPlatform)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
2000-09-22 04:52:22 +00:00
|
|
|
// sorry for the #if platform ugliness, but Communicator is likewise hardcoded
|
|
|
|
// and we're seeking backward compatibility here (bug 47080)
|
|
|
|
#if defined(WIN32)
|
|
|
|
aPlatform = NS_LITERAL_STRING("Win32");
|
|
|
|
#elif defined(XP_MAC)
|
|
|
|
// XXX not sure what to do about Mac OS X on non-PPC, but since Comm 4.x
|
|
|
|
// doesn't know about it this will actually be backward compatible
|
|
|
|
aPlatform = NS_LITERAL_STRING("MacPPC");
|
|
|
|
#else
|
|
|
|
// XXX Communicator uses compiled-in build-time string defines
|
|
|
|
// to indicate the platform it was compiled *for*, not what it is
|
|
|
|
// currently running *on* which is what this does.
|
2000-08-22 03:51:17 +00:00
|
|
|
PRUnichar *plat = nsnull;
|
2000-09-22 04:52:22 +00:00
|
|
|
res = service->GetOscpu(&plat);
|
2000-08-22 03:51:17 +00:00
|
|
|
aPlatform = plat;
|
|
|
|
Recycle(plat);
|
2000-09-22 04:52:22 +00:00
|
|
|
#endif
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
1998-09-17 00:55:35 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetOscpu(nsAWritableString& aOSCPU)
|
2000-03-21 22:39:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *oscpu = nsnull;
|
|
|
|
res = service->GetOscpu(&oscpu);
|
|
|
|
aOSCPU = oscpu;
|
|
|
|
Recycle(oscpu);
|
|
|
|
}
|
2000-03-21 22:39:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
2000-03-21 22:39:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetVendor(nsAWritableString& aVendor)
|
2000-03-21 22:39:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *vendor = nsnull;
|
|
|
|
res = service->GetVendor(&vendor);
|
|
|
|
aVendor = vendor;
|
|
|
|
Recycle(vendor);
|
|
|
|
}
|
2000-03-21 22:39:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
2000-03-21 22:39:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetVendorSub(nsAWritableString& aVendorSub)
|
2000-03-21 22:39:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *vendor = nsnull;
|
|
|
|
res = service->GetVendorSub(&vendor);
|
|
|
|
aVendorSub = vendor;
|
|
|
|
Recycle(vendor);
|
|
|
|
}
|
2000-03-21 22:39:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
2000-03-21 22:39:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetProduct(nsAWritableString& aProduct)
|
2000-03-21 22:39:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *product = nsnull;
|
|
|
|
res = service->GetProduct(&product);
|
|
|
|
aProduct = product;
|
|
|
|
Recycle(product);
|
|
|
|
}
|
2000-03-21 22:39:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
2000-03-21 22:39:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetProductSub(nsAWritableString& aProductSub)
|
2000-03-21 22:39:54 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult res;
|
|
|
|
nsCOMPtr<nsIHTTPProtocolHandler>
|
|
|
|
service(do_GetService(kHTTPHandlerCID, &res));
|
|
|
|
if (NS_SUCCEEDED(res) && (nsnull != service)) {
|
|
|
|
PRUnichar *productSub = nsnull;
|
|
|
|
res = service->GetProductSub(&productSub);
|
|
|
|
aProductSub = productSub;
|
|
|
|
Recycle(productSub);
|
|
|
|
}
|
2000-03-21 22:39:54 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return res;
|
2000-03-21 22:39:54 +00:00
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetSecurityPolicy(nsAWritableString& aSecurityPolicy)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetMimeTypes(nsIDOMMimeTypeArray **aMimeTypes)
|
1999-04-15 21:44:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mMimeTypes) {
|
|
|
|
mMimeTypes = new MimeTypeArrayImpl(this);
|
|
|
|
NS_IF_ADDREF(mMimeTypes);
|
|
|
|
}
|
1999-04-20 19:41:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aMimeTypes = mMimeTypes;
|
|
|
|
NS_IF_ADDREF(mMimeTypes);
|
1999-04-20 19:41:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-04-15 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetPlugins(nsIDOMPluginArray **aPlugins)
|
1999-04-15 21:44:18 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
if (!mPlugins) {
|
|
|
|
mPlugins = new PluginArrayImpl(this);
|
|
|
|
NS_IF_ADDREF(mPlugins);
|
|
|
|
}
|
1999-04-20 19:41:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aPlugins = mPlugins;
|
|
|
|
NS_IF_ADDREF(mPlugins);
|
1999-04-20 19:41:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_OK;
|
1999-04-15 21:44:18 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::GetCookieEnabled(PRBool *aCookieEnabled)
|
1999-12-22 22:42:06 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
*aCookieEnabled = PR_FALSE;
|
1999-12-22 22:42:06 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_WITH_SERVICE(nsICookieService, service, kCookieServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv) || service == nsnull)
|
|
|
|
return rv;
|
1999-12-22 22:42:06 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return service->CookieEnabled(aCookieEnabled);
|
1999-12-22 22:42:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::JavaEnabled(PRBool *aReturn)
|
1998-07-16 01:16:47 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
*aReturn = PR_FALSE;
|
|
|
|
|
|
|
|
// determine whether user has enabled java.
|
|
|
|
NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv) || prefs == nsnull)
|
|
|
|
return rv;
|
1999-05-08 16:37:53 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
// if pref doesn't exist, map result to false.
|
|
|
|
if (prefs->GetBoolPref("security.enable_java", aReturn) != NS_OK)
|
|
|
|
*aReturn = PR_FALSE;
|
1999-05-08 16:37:53 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return rv;
|
1998-07-16 01:16:47 +00:00
|
|
|
}
|
1999-08-12 22:08:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::TaintEnabled(PRBool *aReturn)
|
1999-08-27 06:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
*aReturn = PR_FALSE;
|
|
|
|
return NS_OK;
|
1999-08-27 06:05:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP NavigatorImpl::Preference(JSContext *cx, jsval *argv,
|
|
|
|
PRUint32 argc, jsval *aReturn)
|
1999-08-27 06:05:42 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult result = NS_OK;
|
1999-08-27 06:05:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
*aReturn = JSVAL_NULL;
|
1999-08-27 06:05:42 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
JSObject *self = (JSObject *) mScriptObject;
|
|
|
|
if (!self)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-12-18 20:29:29 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
|
2000-09-13 23:57:52 +00:00
|
|
|
NS_SCRIPTSECURITYMANAGER_CONTRACTID, &result);
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
result =
|
|
|
|
secMan->CheckScriptAccess(cx, self, NS_DOM_PROP_NAVIGATOR_PREFERENCE,
|
|
|
|
argc != 1);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
// Need to throw error here
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-12-17 22:25:22 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_WITH_SERVICE(nsIPref, pref, kPrefServiceCID, &result);
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
JSString *str = ::JS_ValueToString(cx, argv[0]);
|
|
|
|
if (str) {
|
|
|
|
char *prefStr = ::JS_GetStringBytes(str);
|
|
|
|
if (argc == 1) {
|
|
|
|
PRInt32 prefType;
|
|
|
|
pref->GetPrefType(prefStr, &prefType);
|
|
|
|
switch (prefType & nsIPref::ePrefValuetypeMask) {
|
|
|
|
case nsIPref::ePrefString:
|
|
|
|
{
|
|
|
|
char *prefCharVal;
|
|
|
|
result = pref->CopyCharPref(prefStr, &prefCharVal);
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
JSString *retStr = ::JS_NewStringCopyZ(cx, prefCharVal);
|
|
|
|
if (retStr)
|
|
|
|
*aReturn = STRING_TO_JSVAL(retStr);
|
|
|
|
PL_strfree(prefCharVal);
|
2000-02-08 13:40:10 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case nsIPref::ePrefInt:
|
|
|
|
{
|
|
|
|
PRInt32 prefIntVal;
|
|
|
|
result = pref->GetIntPref(prefStr, &prefIntVal);
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
*aReturn = INT_TO_JSVAL(prefIntVal);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case nsIPref::ePrefBool:
|
|
|
|
{
|
|
|
|
PRBool prefBoolVal;
|
|
|
|
result = pref->GetBoolPref(prefStr, &prefBoolVal);
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
*aReturn = BOOLEAN_TO_JSVAL(prefBoolVal);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (JSVAL_IS_STRING(argv[1])) {
|
|
|
|
JSString *valueJSStr = ::JS_ValueToString(cx, argv[1]);
|
|
|
|
if (valueJSStr)
|
|
|
|
result = pref->SetCharPref(prefStr, ::JS_GetStringBytes(valueJSStr));
|
|
|
|
}
|
|
|
|
else if (JSVAL_IS_INT(argv[1])) {
|
|
|
|
jsint valueInt = JSVAL_TO_INT(argv[1]);
|
|
|
|
result = pref->SetIntPref(prefStr, (PRInt32) valueInt);
|
|
|
|
}
|
|
|
|
else if (JSVAL_IS_BOOLEAN(argv[1])) {
|
|
|
|
JSBool valueBool = JSVAL_TO_BOOLEAN(argv[1]);
|
|
|
|
result = pref->SetBoolPref(prefStr, (PRBool) valueBool);
|
|
|
|
}
|
|
|
|
else if (JSVAL_IS_NULL(argv[1])) {
|
|
|
|
result = pref->DeleteBranch(prefStr);
|
|
|
|
}
|
1999-11-17 00:43:19 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
1999-11-17 00:43:19 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
return result;
|
1999-10-14 23:28:17 +00:00
|
|
|
}
|
|
|
|
|
2000-02-15 01:08:04 +00:00
|
|
|
#ifdef XP_MAC
|
|
|
|
#pragma mark -
|
|
|
|
#endif
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
//*****************************************************************************
|
|
|
|
//*** DOM Controller Stuff
|
|
|
|
//*****************************************************************************
|
|
|
|
|
1999-12-13 23:13:33 +00:00
|
|
|
#ifdef DOM_CONTROLLER
|
|
|
|
// nsDOMWindowController
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sCopyString = "cmd_copy";
|
|
|
|
const char *sCutString = "cmd_cut";
|
|
|
|
const char *sPasteString = "cmd_paste";
|
|
|
|
const char *sSelectAllString = "cmd_selectAll";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sBeginLineString = "cmd_beginLine";
|
|
|
|
const char *sEndLineString = "cmd_endLine";
|
|
|
|
const char *sSelectBeginLineString = "cmd_selectBeginLine";
|
|
|
|
const char *sSelectEndLineString = "cmd_selectEndLine";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sScrollTopString = "cmd_scrollTop";
|
|
|
|
const char *sScrollBottomString = "cmd_scrollBottom";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sMoveTopString = "cmd_moveTop";
|
|
|
|
const char *sMoveBottomString = "cmd_moveBottom";
|
|
|
|
const char *sSelectMoveTopString = "cmd_selectTop";
|
|
|
|
const char *sSelectMoveBottomString = "cmd_selectBottom";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sDownString = "cmd_linedown";
|
|
|
|
const char *sUpString = "cmd_lineup";
|
|
|
|
const char *sSelectDownString = "cmd_selectLineDown";
|
|
|
|
const char *sSelectUpString = "cmd_selectLineUp";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sLeftString = "cmd_charPrevious";
|
|
|
|
const char *sRightString = "cmd_charNext";
|
|
|
|
const char *sSelectLeftString = "cmd_selectCharPrevious";
|
|
|
|
const char *sSelectRightString = "cmd_selectCharNext";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sWordLeftString = "cmd_wordPrevious";
|
|
|
|
const char *sWordRightString = "cmd_wordNext";
|
|
|
|
const char *sSelectWordLeftString = "cmd_selectWordPrevious";
|
|
|
|
const char *sSelectWordRightString = "cmd_selectWordNext";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sScrollPageUp = "cmd_scrollPageUp";
|
|
|
|
const char *sScrollPageDown = "cmd_scrollPageDown";
|
1999-12-15 03:59:38 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sScrollLineUp = "cmd_scrollLineUp";
|
|
|
|
const char *sScrollLineDown = "cmd_scrollLineDown";
|
1999-12-14 01:38:17 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sMovePageUp = "cmd_scrollPageUp";
|
|
|
|
const char *sMovePageDown = "cmd_scrollPageDown";
|
|
|
|
const char *sSelectMovePageUp = "cmd_selectPageUp";
|
|
|
|
const char *sSelectMovePageDown = "cmd_selectPageDown";
|
2000-05-16 14:28:09 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
const char *sScrollLeft = "cmd_scrollLeft";
|
|
|
|
const char *sScrollRight = "cmd_scrollRight";
|
1999-12-13 23:13:33 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMPL_ADDREF(nsDOMWindowController)
|
|
|
|
NS_IMPL_RELEASE(nsDOMWindowController)
|
1999-12-13 23:13:33 +00:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMWindowController)
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIController)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIController)
|
1999-12-13 23:13:33 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1999-12-14 01:38:17 +00:00
|
|
|
//NS_IMPL_QUERY_INTERFACE1(nsDOMWindowController, nsIController)
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
nsDOMWindowController::nsDOMWindowController(nsIDOMWindowInternal *aWindow)
|
1999-12-13 23:13:33 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_INIT_REFCNT();
|
|
|
|
mWindow = aWindow;
|
1999-12-13 23:13:33 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult
|
|
|
|
nsDOMWindowController::GetEditInterface(nsIContentViewerEdit **aEditInterface)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(mWindow));
|
|
|
|
NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
|
|
|
sgo->GetDocShell(getter_AddRefs(docShell));
|
|
|
|
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIContentViewer> viewer;
|
|
|
|
docShell->GetContentViewer(getter_AddRefs(viewer));
|
|
|
|
nsCOMPtr<nsIContentViewerEdit> edit(do_QueryInterface(viewer));
|
|
|
|
NS_ENSURE_TRUE(edit, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
*aEditInterface = edit;
|
|
|
|
NS_ADDREF(*aEditInterface);
|
|
|
|
return NS_OK;
|
1999-12-13 23:13:33 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsresult
|
|
|
|
nsDOMWindowController::GetPresShell(nsIPresShell **aPresShell)
|
2000-02-08 13:40:10 +00:00
|
|
|
{
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(mWindow));
|
|
|
|
NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
|
|
|
sgo->GetDocShell(getter_AddRefs(docShell));
|
|
|
|
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
2000-02-08 13:40:10 +00:00
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(docShell->GetPresShell(aPresShell), NS_ERROR_FAILURE);
|
|
|
|
return NS_OK;
|
1999-12-14 01:38:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsDOMWindowController::GetSelectionController(nsISelectionController **aSelCon)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
nsresult result = GetPresShell(getter_AddRefs(presShell));
|
2000-08-22 03:51:17 +00:00
|
|
|
if (presShell && NS_SUCCEEDED(result)) {
|
|
|
|
nsCOMPtr<nsISelectionController> selController =
|
|
|
|
do_QueryInterface(presShell);
|
|
|
|
if (selController) {
|
1999-12-14 01:38:17 +00:00
|
|
|
*aSelCon = selController;
|
|
|
|
NS_ADDREF(*aSelCon);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
1999-12-14 01:38:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP nsDOMWindowController::IsCommandEnabled(const PRUnichar *aCommand,
|
|
|
|
PRBool *aResult)
|
1999-12-13 23:13:33 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCommand);
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
|
|
|
|
1999-12-14 01:38:17 +00:00
|
|
|
*aResult = PR_FALSE;
|
1999-12-13 23:13:33 +00:00
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-08-22 03:51:17 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContentViewerEdit> editInterface;
|
|
|
|
rv = GetEditInterface(getter_AddRefs(editInterface));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand)) {
|
|
|
|
rv = editInterface->GetCopyable(aResult);
|
|
|
|
}
|
|
|
|
else if (nsCAutoString(sCutString).EqualsWithConversion(aCommand)) {
|
|
|
|
rv = editInterface->GetCutable(aResult);
|
|
|
|
}
|
|
|
|
else if (nsCAutoString(sPasteString).EqualsWithConversion(aCommand)) {
|
|
|
|
rv = editInterface->GetPasteable(aResult);
|
|
|
|
}
|
|
|
|
else if (nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand)) {
|
1999-12-13 23:13:33 +00:00
|
|
|
*aResult = PR_TRUE;
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
return rv;
|
1999-12-14 01:38:17 +00:00
|
|
|
|
1999-12-13 23:13:33 +00:00
|
|
|
}
|
|
|
|
|
2000-08-22 03:51:17 +00:00
|
|
|
NS_IMETHODIMP nsDOMWindowController::SupportsCommand(const PRUnichar *aCommand,
|
|
|
|
PRBool *aResult)
|
1999-12-13 23:13:33 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCommand);
|
|
|
|
NS_ENSURE_ARG_POINTER(aResult);
|
2000-08-22 03:51:17 +00:00
|
|
|
|
1999-12-13 23:13:33 +00:00
|
|
|
*aResult = PR_FALSE;
|
2000-08-22 03:51:17 +00:00
|
|
|
if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sCutString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sPasteString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sBeginLineString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sEndLineString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectBeginLineString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectEndLineString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sMoveTopString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sMoveBottomString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectMoveTopString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectMoveBottomString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sDownString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sUpString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sLeftString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sRightString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectDownString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectUpString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectLeftString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectRightString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sWordLeftString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sWordRightString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectWordLeftString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectWordRightString).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollPageUp).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollPageDown).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollLineUp).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollLineDown).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sMovePageUp).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sMovePageDown).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectMovePageUp).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sSelectMovePageDown).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollLeft).EqualsWithConversion(aCommand) ||
|
|
|
|
nsCAutoString(sScrollRight).EqualsWithConversion(aCommand)) {
|
1999-12-13 23:13:33 +00:00
|
|
|
*aResult = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsDOMWindowController::DoCommand(const PRUnichar *aCommand)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCommand);
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
2000-08-22 03:51:17 +00:00
|
|
|
nsCOMPtr<nsIContentViewerEdit> editInterface;
|
1999-12-14 01:38:17 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCont;
|
2000-08-22 03:51:17 +00:00
|
|
|
rv = GetEditInterface(getter_AddRefs(editInterface));
|
1999-12-14 01:38:17 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
2000-08-22 03:51:17 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand)) {
|
2000-01-18 21:07:54 +00:00
|
|
|
rv = editInterface->CopySelection();
|
1999-12-13 23:13:33 +00:00
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sCutString).EqualsWithConversion(aCommand)) {
|
1999-12-13 23:13:33 +00:00
|
|
|
rv = editInterface->CutSelection();
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sPasteString).EqualsWithConversion(aCommand)) {
|
1999-12-13 23:13:33 +00:00
|
|
|
rv = editInterface->Paste();
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand)) {
|
1999-12-13 23:13:33 +00:00
|
|
|
rv = editInterface->SelectAll();
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sScrollPageUp).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
1999-12-14 01:38:17 +00:00
|
|
|
return selCont->ScrollPage(PR_FALSE);
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sScrollPageDown).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
1999-12-14 01:38:17 +00:00
|
|
|
return selCont->ScrollPage(PR_TRUE);
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sScrollLineUp).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
1999-12-15 03:59:38 +00:00
|
|
|
return selCont->ScrollLine(PR_FALSE);
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sScrollLineDown).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
1999-12-15 03:59:38 +00:00
|
|
|
return selCont->ScrollLine(PR_TRUE);
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sScrollLeft).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-05-16 14:28:09 +00:00
|
|
|
return selCont->ScrollHorizontal(PR_TRUE);
|
|
|
|
}
|
2000-08-22 03:51:17 +00:00
|
|
|
else if (nsCAutoString(sScrollRight).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
2000-05-16 14:28:09 +00:00
|
|
|
return selCont->ScrollHorizontal(PR_FALSE);
|
|
|
|
}
|
2000-09-22 05:31:36 +00:00
|
|
|
else if (nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
return selCont->CompleteScroll(PR_FALSE);
|
|
|
|
}
|
|
|
|
else if (nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand)) {
|
|
|
|
NS_ENSURE_SUCCESS(GetSelectionController(getter_AddRefs(selCont)),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
return selCont->CompleteScroll(PR_TRUE);
|
|
|
|
}
|
1999-12-13 23:13:33 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsDOMWindowController::OnEvent(const PRUnichar *aEventName)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-14 01:41:27 +00:00
|
|
|
#endif
|