1998-12-03 01:35:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:43:54 +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-12-03 01:35:53 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +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-12-03 01:35:53 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 03:43:54 +00:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2000-01-11 20:49:15 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
1998-12-03 01:35:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "nsWebShellWindow.h"
|
|
|
|
|
1999-05-16 10:02:19 +00:00
|
|
|
#include "nsLayoutCID.h"
|
2001-02-22 03:01:34 +00:00
|
|
|
#include "nsContentCID.h"
|
1999-08-12 22:08:17 +00:00
|
|
|
#include "nsIWeakReference.h"
|
1999-05-18 08:04:37 +00:00
|
|
|
#include "nsIDocumentLoader.h"
|
1999-05-16 10:02:19 +00:00
|
|
|
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-12-30 00:03:52 +00:00
|
|
|
#include "nsIServiceManager.h"
|
1998-12-03 01:35:53 +00:00
|
|
|
#include "nsIURL.h"
|
1999-06-18 17:34:08 +00:00
|
|
|
#include "nsIIOService.h"
|
1999-06-23 03:29:44 +00:00
|
|
|
#include "nsIURL.h"
|
2001-04-10 06:01:08 +00:00
|
|
|
#include "nsNetCID.h"
|
2000-09-01 05:54:59 +00:00
|
|
|
#include "nsIStringBundle.h"
|
1999-03-16 07:25:43 +00:00
|
|
|
#include "nsIPref.h"
|
1998-12-03 01:35:53 +00:00
|
|
|
|
1999-04-20 22:35:11 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
1999-05-27 20:36:15 +00:00
|
|
|
#include "nsEscape.h"
|
1999-04-19 22:05:49 +00:00
|
|
|
#include "nsVoidArray.h"
|
1999-04-20 22:35:11 +00:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
2000-09-01 01:54:35 +00:00
|
|
|
#include "nsIDOMWindowInternal.h"
|
2000-01-26 22:48:16 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
1999-05-18 09:03:26 +00:00
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIDOMFocusListener.h"
|
2000-03-16 02:20:26 +00:00
|
|
|
#include "nsIWebNavigation.h"
|
2001-04-07 03:33:56 +00:00
|
|
|
#include "nsIWindowWatcher.h"
|
1999-04-19 22:05:49 +00:00
|
|
|
|
1999-05-18 09:03:26 +00:00
|
|
|
#include "nsIXULPopupListener.h"
|
1999-05-21 02:34:03 +00:00
|
|
|
#include "nsIDOMXULElement.h"
|
1999-05-18 09:03:26 +00:00
|
|
|
#include "nsRDFCID.h"
|
1999-05-16 08:10:27 +00:00
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsIAppShell.h"
|
|
|
|
|
1998-12-30 00:03:52 +00:00
|
|
|
#include "nsIAppShellService.h"
|
1999-01-21 07:24:01 +00:00
|
|
|
#include "nsAppShellCIDs.h"
|
1998-12-30 00:03:52 +00:00
|
|
|
|
1999-01-27 04:02:33 +00:00
|
|
|
#include "nsIDOMCharacterData.h"
|
1999-02-15 05:38:15 +00:00
|
|
|
#include "nsIDOMNodeList.h"
|
1999-01-26 15:58:58 +00:00
|
|
|
|
1999-01-27 10:51:28 +00:00
|
|
|
#include "nsIMenuBar.h"
|
|
|
|
#include "nsIMenu.h"
|
|
|
|
#include "nsIMenuItem.h"
|
1999-02-04 02:42:07 +00:00
|
|
|
#include "nsIMenuListener.h"
|
1999-05-14 22:28:00 +00:00
|
|
|
#include "nsIContextMenu.h"
|
2000-02-23 20:07:31 +00:00
|
|
|
#include "nsITimer.h"
|
1999-01-27 10:51:28 +00:00
|
|
|
|
1999-02-18 05:01:03 +00:00
|
|
|
// For JS Execution
|
1999-12-03 09:24:22 +00:00
|
|
|
#include "nsIScriptGlobalObjectOwner.h"
|
1999-11-25 05:28:18 +00:00
|
|
|
#include "nsIJSContextStack.h"
|
1999-02-18 05:01:03 +00:00
|
|
|
|
1999-03-20 04:13:09 +00:00
|
|
|
#include "nsIEventQueueService.h"
|
|
|
|
#include "plevent.h"
|
|
|
|
#include "prmem.h"
|
2000-02-23 20:07:31 +00:00
|
|
|
#include "prlock.h"
|
1999-03-20 04:13:09 +00:00
|
|
|
|
2000-02-11 23:50:15 +00:00
|
|
|
#include "nsIDOMXULDocument.h"
|
2000-11-04 09:33:20 +00:00
|
|
|
|
|
|
|
#include "nsIFocusController.h"
|
2000-02-11 23:50:15 +00:00
|
|
|
|
2000-12-14 23:27:59 +00:00
|
|
|
#include "nsIWebProgress.h"
|
|
|
|
#include "nsIWebProgressListener.h"
|
|
|
|
|
1999-01-21 07:24:01 +00:00
|
|
|
#include "nsIDocumentViewer.h"
|
|
|
|
#include "nsIDocument.h"
|
1999-02-04 02:42:07 +00:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMNode.h"
|
1999-01-26 15:58:58 +00:00
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDocumentLoader.h"
|
2000-01-29 06:48:38 +00:00
|
|
|
#include "nsIDocumentLoaderFactory.h"
|
1999-06-08 20:59:41 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "prprf.h"
|
1999-02-21 21:04:21 +00:00
|
|
|
//#include "nsIDOMHTMLInputElement.h"
|
|
|
|
//#include "nsIDOMHTMLImageElement.h"
|
|
|
|
|
|
|
|
#include "nsIContent.h" // for menus
|
1998-12-30 00:03:52 +00:00
|
|
|
|
1999-02-12 15:56:54 +00:00
|
|
|
// For calculating size
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
|
1999-12-17 23:43:47 +00:00
|
|
|
#include "nsIBaseWindow.h"
|
2000-01-26 02:21:42 +00:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2000-03-11 01:25:54 +00:00
|
|
|
#include "nsIDocShellTreeNode.h"
|
2000-01-26 02:21:42 +00:00
|
|
|
|
2000-02-08 15:55:46 +00:00
|
|
|
#include "nsIMarkupDocumentViewer.h"
|
|
|
|
|
1999-12-17 23:43:47 +00:00
|
|
|
|
1999-04-08 04:29:37 +00:00
|
|
|
// HACK for M4, should be removed by M5
|
2000-03-11 03:08:04 +00:00
|
|
|
// ... its now M15
|
|
|
|
#if defined(XP_MAC) || defined(RHAPSODY)
|
1999-04-08 04:29:37 +00:00
|
|
|
#include <Menus.h>
|
|
|
|
#endif
|
1999-07-02 23:57:29 +00:00
|
|
|
#include "nsIMenuItem.h"
|
|
|
|
#include "nsIDOMXULDocument.h"
|
|
|
|
// End hack
|
|
|
|
|
2001-02-13 21:48:26 +00:00
|
|
|
#if defined(XP_MAC) || defined(RHAPSODY)
|
2000-03-11 03:08:04 +00:00
|
|
|
#define USE_NATIVE_MENUS
|
|
|
|
#endif
|
|
|
|
|
1999-08-19 22:11:12 +00:00
|
|
|
#include "nsIPopupSetFrame.h"
|
1999-07-04 23:41:32 +00:00
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
/* Define Class IDs */
|
2000-01-31 23:45:42 +00:00
|
|
|
static NS_DEFINE_CID(kWindowCID, NS_WINDOW_CID);
|
|
|
|
static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID);
|
|
|
|
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
|
|
|
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
1998-12-03 01:35:53 +00:00
|
|
|
|
1999-05-14 22:28:00 +00:00
|
|
|
#include "nsWidgetsCID.h"
|
2000-01-31 23:45:42 +00:00
|
|
|
static NS_DEFINE_CID(kMenuBarCID, NS_MENUBAR_CID);
|
|
|
|
static NS_DEFINE_CID(kMenuCID, NS_MENU_CID);
|
|
|
|
static NS_DEFINE_CID(kMenuItemCID, NS_MENUITEM_CID);
|
|
|
|
static NS_DEFINE_CID(kContextMenuCID, NS_CONTEXTMENU_CID);
|
1999-01-27 10:51:28 +00:00
|
|
|
|
1999-03-16 07:25:43 +00:00
|
|
|
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
1999-03-20 04:13:09 +00:00
|
|
|
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
1999-03-16 07:25:43 +00:00
|
|
|
|
1999-05-18 08:04:37 +00:00
|
|
|
static NS_DEFINE_CID(kLayoutDocumentLoaderFactoryCID, NS_LAYOUT_DOCUMENT_LOADER_FACTORY_CID);
|
1999-05-18 09:03:26 +00:00
|
|
|
static NS_DEFINE_CID(kXULPopupListenerCID, NS_XULPOPUPLISTENER_CID);
|
2000-01-31 23:45:42 +00:00
|
|
|
|
|
|
|
|
1999-03-26 11:34:21 +00:00
|
|
|
#ifdef DEBUG_rods
|
1999-02-21 21:04:21 +00:00
|
|
|
#define DEBUG_MENUSDEL 1
|
1999-03-26 11:34:21 +00:00
|
|
|
#endif
|
1999-11-03 05:25:21 +00:00
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
#include "nsIWebShell.h"
|
|
|
|
|
2000-09-01 05:54:59 +00:00
|
|
|
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
|
|
|
|
2000-02-23 20:07:31 +00:00
|
|
|
#define SIZE_PERSISTENCE_TIMEOUT 500 // msec
|
|
|
|
|
1999-06-26 21:48:29 +00:00
|
|
|
const char * kPrimaryContentTypeValue = "content-primary";
|
1998-12-03 01:35:53 +00:00
|
|
|
|
1999-03-20 04:13:09 +00:00
|
|
|
struct ThreadedWindowEvent {
|
|
|
|
PLEvent event;
|
|
|
|
nsWebShellWindow *window;
|
|
|
|
};
|
|
|
|
|
1999-04-19 22:05:49 +00:00
|
|
|
// The web shell info object is used to hold information about content areas that will
|
|
|
|
// subsequently be filled in when we receive a webshell added notification.
|
|
|
|
struct nsWebShellInfo {
|
|
|
|
nsString id; // The identifier of the iframe or frame node in the XUL tree.
|
1999-06-26 21:48:29 +00:00
|
|
|
PRBool primary; // whether it's considered a/the primary content
|
1999-04-20 22:35:11 +00:00
|
|
|
nsIWebShell* child; // The child web shell that will end up being used for the content area.
|
1999-04-19 22:05:49 +00:00
|
|
|
|
1999-06-26 21:48:29 +00:00
|
|
|
nsWebShellInfo(const nsString& anID, PRBool aPrimary, nsIWebShell* aChildShell)
|
1999-04-19 22:05:49 +00:00
|
|
|
{
|
1999-05-04 23:36:42 +00:00
|
|
|
id = anID;
|
1999-06-26 21:48:29 +00:00
|
|
|
primary = aPrimary;
|
1999-04-20 22:35:11 +00:00
|
|
|
child = aChildShell;
|
|
|
|
NS_IF_ADDREF(aChildShell);
|
1999-04-19 22:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~nsWebShellInfo()
|
|
|
|
{
|
1999-04-20 22:35:11 +00:00
|
|
|
NS_IF_RELEASE(child);
|
1999-04-19 22:05:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
nsWebShellWindow::nsWebShellWindow() : nsXULWindow()
|
1998-12-03 01:35:53 +00:00
|
|
|
{
|
1998-12-30 00:03:52 +00:00
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
mWebShell = nsnull;
|
|
|
|
mWindow = nsnull;
|
1999-05-19 04:11:54 +00:00
|
|
|
mLockedUntilChromeLoad = PR_FALSE;
|
1999-07-04 04:09:54 +00:00
|
|
|
mIntrinsicallySized = PR_FALSE;
|
1999-10-28 01:52:49 +00:00
|
|
|
mDebuting = PR_FALSE;
|
1999-08-16 22:23:19 +00:00
|
|
|
mLoadDefaultPage = PR_TRUE;
|
2000-02-23 20:07:31 +00:00
|
|
|
mSPTimerLock = PR_NewLock();
|
1998-12-03 01:35:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsWebShellWindow::~nsWebShellWindow()
|
|
|
|
{
|
|
|
|
if (nsnull != mWebShell) {
|
1999-12-17 23:43:47 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(mWebShell));
|
|
|
|
shellAsWin->Destroy();
|
1998-12-03 01:35:53 +00:00
|
|
|
NS_RELEASE(mWebShell);
|
|
|
|
}
|
|
|
|
|
2000-04-01 22:13:46 +00:00
|
|
|
if (mWindow)
|
|
|
|
mWindow->SetClientData(0);
|
2000-01-26 02:21:42 +00:00
|
|
|
mWindow = nsnull; // Force release here.
|
2000-02-23 20:07:31 +00:00
|
|
|
|
|
|
|
PR_Lock(mSPTimerLock);
|
|
|
|
if (mSPTimer)
|
|
|
|
mSPTimer->Cancel();
|
|
|
|
PR_Unlock(mSPTimerLock);
|
|
|
|
PR_DestroyLock(mSPTimerLock);
|
1998-12-03 01:35:53 +00:00
|
|
|
}
|
|
|
|
|
2000-04-05 00:11:56 +00:00
|
|
|
NS_IMPL_THREADSAFE_ADDREF(nsWebShellWindow);
|
|
|
|
NS_IMPL_THREADSAFE_RELEASE(nsWebShellWindow);
|
1998-12-30 00:03:52 +00:00
|
|
|
|
1999-11-24 10:04:13 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsWebShellWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebShellContainer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShellWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer)
|
2000-12-14 23:27:59 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
2000-01-26 02:21:42 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXULWindow)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
|
2000-02-08 13:40:10 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
2001-01-31 21:01:51 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
1999-11-24 10:04:13 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
1998-12-03 01:35:53 +00:00
|
|
|
|
2000-02-29 00:20:55 +00:00
|
|
|
nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIAppShell* aShell, nsIURI* aUrl,
|
1999-07-20 14:40:55 +00:00
|
|
|
PRBool aCreatedVisible,
|
1999-08-16 22:23:19 +00:00
|
|
|
PRBool aLoadDefaultPage,
|
2000-04-01 22:13:46 +00:00
|
|
|
PRUint32 aZlevel,
|
1999-07-01 02:50:53 +00:00
|
|
|
PRInt32 aInitialWidth, PRInt32 aInitialHeight,
|
2001-04-11 23:04:28 +00:00
|
|
|
PRBool aIsHiddenWindow, nsWidgetInitData& widgetInitData)
|
1998-12-03 01:35:53 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
1999-08-19 14:44:31 +00:00
|
|
|
nsCOMPtr<nsIWidget> parentWidget;
|
1999-07-20 14:40:55 +00:00
|
|
|
|
2001-04-11 23:04:28 +00:00
|
|
|
mIsHiddenWindow = aIsHiddenWindow;
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
mShowAfterLoad = aCreatedVisible;
|
1999-08-16 22:23:19 +00:00
|
|
|
mLoadDefaultPage = aLoadDefaultPage;
|
2000-04-01 22:13:46 +00:00
|
|
|
mZlevel = aZlevel;
|
1999-05-04 23:36:42 +00:00
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
// XXX: need to get the default window size from prefs...
|
1999-07-20 14:40:55 +00:00
|
|
|
// Doesn't come from prefs... will come from CSS/XUL/RDF
|
1999-02-18 21:52:27 +00:00
|
|
|
nsRect r(0, 0, aInitialWidth, aInitialHeight);
|
1998-12-03 01:35:53 +00:00
|
|
|
|
|
|
|
// Create top level window
|
2000-12-09 04:21:51 +00:00
|
|
|
mWindow = do_CreateInstance(kWindowCID, &rv);
|
1998-12-03 01:35:53 +00:00
|
|
|
if (NS_OK != rv) {
|
1999-02-21 21:04:21 +00:00
|
|
|
return rv;
|
1998-12-03 01:35:53 +00:00
|
|
|
}
|
|
|
|
|
1999-08-12 22:08:17 +00:00
|
|
|
/* This next bit is troublesome. We carry two different versions of a pointer
|
|
|
|
to our parent window. One is the parent window's widget, which is passed
|
|
|
|
to our own widget. The other is a weak reference we keep here to our
|
|
|
|
parent WebShellWindow. The former is useful to the widget, and we can't
|
|
|
|
trust its treatment of the parent reference because they're platform-
|
|
|
|
specific. The latter is useful to this class.
|
|
|
|
A better implementation would be one in which the parent keeps strong
|
|
|
|
references to its children and closes them before it allows itself
|
|
|
|
to be closed. This would mimic the behaviour of OSes that support
|
|
|
|
top-level child windows in OSes that do not. Later.
|
|
|
|
*/
|
2000-02-29 00:20:55 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> parentAsWin(do_QueryInterface(aParent));
|
|
|
|
if (parentAsWin) {
|
|
|
|
parentAsWin->GetMainWidget(getter_AddRefs(parentWidget));
|
1999-08-12 22:08:17 +00:00
|
|
|
mParentWindow = getter_AddRefs(NS_GetWeakReference(aParent));
|
|
|
|
}
|
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
mWindow->SetClientData(this);
|
1999-08-19 16:57:32 +00:00
|
|
|
mWindow->Create((nsIWidget *)parentWidget, // Parent nsIWidget
|
1998-12-03 01:35:53 +00:00
|
|
|
r, // Widget dimensions
|
|
|
|
nsWebShellWindow::HandleEvent, // Event handler function
|
|
|
|
nsnull, // Device context
|
|
|
|
aShell, // Application shell
|
|
|
|
nsnull, // nsIToolkit
|
1999-07-01 02:50:53 +00:00
|
|
|
&widgetInitData); // Widget initialization data
|
1998-12-03 01:35:53 +00:00
|
|
|
mWindow->GetClientBounds(r);
|
|
|
|
mWindow->SetBackgroundColor(NS_RGB(192,192,192));
|
|
|
|
|
|
|
|
// Create web shell
|
2000-03-11 01:25:54 +00:00
|
|
|
mDocShell = do_CreateInstance(kWebShellCID);
|
|
|
|
CallQueryInterface(mDocShell, &mWebShell);
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
|
1998-12-03 01:35:53 +00:00
|
|
|
|
|
|
|
r.x = r.y = 0;
|
2000-03-11 01:25:54 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> docShellAsWin(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nsnull, mWindow,
|
|
|
|
r.x, r.y, r.width, r.height), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(docShellAsWin->Create(), NS_ERROR_FAILURE);
|
1999-01-21 07:24:01 +00:00
|
|
|
mWebShell->SetContainer(this);
|
2000-12-14 23:27:59 +00:00
|
|
|
|
|
|
|
// Attach a WebProgress listener.during initialization...
|
|
|
|
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(mDocShell, &rv));
|
|
|
|
if (webProgress) {
|
|
|
|
webProgress->AddProgressListener(this);
|
|
|
|
}
|
1999-03-16 07:25:43 +00:00
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
docShellAsItem->SetTreeOwner(mChromeTreeOwner);
|
|
|
|
docShellAsItem->SetItemType(nsIDocShellTreeItem::typeChrome);
|
1999-04-16 08:12:44 +00:00
|
|
|
|
1999-02-10 16:32:55 +00:00
|
|
|
if (nsnull != aUrl) {
|
1999-06-28 10:35:57 +00:00
|
|
|
char *tmpStr = NULL;
|
1999-09-09 20:44:17 +00:00
|
|
|
nsAutoString urlString;
|
1999-05-27 20:36:15 +00:00
|
|
|
|
1999-11-30 04:50:42 +00:00
|
|
|
rv = aUrl->GetSpec(&tmpStr);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-04-19 00:19:06 +00:00
|
|
|
urlString.AssignWithConversion(tmpStr);
|
1999-06-28 10:35:57 +00:00
|
|
|
nsCRT::free(tmpStr);
|
2000-03-16 02:20:26 +00:00
|
|
|
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(urlString.GetUnicode(), nsIWebNavigation::LOAD_FLAGS_NONE), NS_ERROR_FAILURE);
|
1999-02-10 16:32:55 +00:00
|
|
|
}
|
1999-05-04 23:36:42 +00:00
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-18 19:08:36 +00:00
|
|
|
/*
|
|
|
|
* Close the window
|
|
|
|
*/
|
|
|
|
NS_METHOD
|
|
|
|
nsWebShellWindow::Close()
|
|
|
|
{
|
2000-04-11 23:52:50 +00:00
|
|
|
return Destroy();
|
1999-03-18 19:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
/*
|
|
|
|
* Event handler function...
|
|
|
|
*
|
|
|
|
* This function is called to process events for the nsIWidget of the
|
|
|
|
* nsWebShellWindow...
|
|
|
|
*/
|
|
|
|
nsEventStatus PR_CALLBACK
|
|
|
|
nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
nsIWebShell* webShell = nsnull;
|
2001-01-04 00:05:42 +00:00
|
|
|
nsWebShellWindow *eventWindow = nsnull;
|
1998-12-03 01:35:53 +00:00
|
|
|
|
|
|
|
// Get the WebShell instance...
|
|
|
|
if (nsnull != aEvent->widget) {
|
|
|
|
void* data;
|
|
|
|
|
|
|
|
aEvent->widget->GetClientData(data);
|
2001-01-04 00:05:42 +00:00
|
|
|
if (data != nsnull) {
|
|
|
|
eventWindow = NS_REINTERPRET_CAST(nsWebShellWindow *, data);
|
|
|
|
webShell = eventWindow->mWebShell;
|
1998-12-03 01:35:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != webShell) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
/*
|
|
|
|
* For size events, the WebShell must be resized to fill the entire
|
|
|
|
* client area of the window...
|
|
|
|
*/
|
2000-01-14 00:38:12 +00:00
|
|
|
case NS_MOVE: {
|
2000-02-23 20:07:31 +00:00
|
|
|
// persist position, but not immediately, in case this OS is firing
|
|
|
|
// repeated move events as the user drags the window
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->SetPersistenceTimer(PR_FALSE, PR_TRUE);
|
2000-01-13 23:51:01 +00:00
|
|
|
break;
|
2000-01-14 00:38:12 +00:00
|
|
|
}
|
1998-12-03 01:35:53 +00:00
|
|
|
case NS_SIZE: {
|
1999-12-17 23:43:47 +00:00
|
|
|
nsSizeEvent* sizeEvent = (nsSizeEvent*)aEvent;
|
|
|
|
nsCOMPtr<nsIBaseWindow> shellAsWin(do_QueryInterface(webShell));
|
|
|
|
shellAsWin->SetPositionAndSize(0, 0, sizeEvent->windowSize->width,
|
|
|
|
sizeEvent->windowSize->height, PR_FALSE);
|
2000-02-23 20:07:31 +00:00
|
|
|
// persist size, but not immediately, in case this OS is firing
|
|
|
|
// repeated size events as the user drags the sizing handle
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->SetPersistenceTimer(PR_TRUE, PR_FALSE);
|
1998-12-03 01:35:53 +00:00
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
}
|
2000-03-09 02:00:20 +00:00
|
|
|
case NS_SIZEMODE: {
|
|
|
|
nsSizeModeEvent* modeEvent = (nsSizeModeEvent*)aEvent;
|
|
|
|
aEvent->widget->SetSizeMode(modeEvent->mSizeMode);
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->StoreBoundsToXUL(PR_FALSE, PR_FALSE, PR_TRUE);
|
2000-03-09 02:00:20 +00:00
|
|
|
result = nsEventStatus_eConsumeDoDefault;
|
|
|
|
// Note the current implementation of SetSizeMode just stores
|
|
|
|
// the new state; it doesn't actually resize. So here we store
|
|
|
|
// the state and pass the event on to the OS. The day is coming
|
|
|
|
// when we'll handle the event here, and the return result will
|
|
|
|
// then need to be different.
|
|
|
|
break;
|
|
|
|
}
|
1999-12-01 22:38:06 +00:00
|
|
|
case NS_XUL_CLOSE: {
|
2001-03-24 00:14:10 +00:00
|
|
|
// Calling ExecuteCloseHandler may actually close the window
|
|
|
|
// (it probably shouldn't, but you never know what the users JS
|
|
|
|
// code will do). Therefore we add a death-grip to the window
|
|
|
|
// for the duration of the close handler.
|
|
|
|
nsCOMPtr<nsIWebShellWindow> kungFuDeathGrip(eventWindow);
|
2001-01-04 00:05:42 +00:00
|
|
|
if (!eventWindow->ExecuteCloseHandler())
|
|
|
|
eventWindow->Close();
|
1999-12-01 22:38:06 +00:00
|
|
|
break;
|
|
|
|
}
|
1998-12-03 01:35:53 +00:00
|
|
|
/*
|
|
|
|
* Notify the ApplicationShellService that the window is being closed...
|
|
|
|
*/
|
1998-12-30 00:03:52 +00:00
|
|
|
case NS_DESTROY: {
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->Close();
|
1998-12-03 01:35:53 +00:00
|
|
|
break;
|
1998-12-30 00:03:52 +00:00
|
|
|
}
|
1999-05-29 19:36:55 +00:00
|
|
|
|
2000-04-01 22:13:46 +00:00
|
|
|
case NS_SETZLEVEL: {
|
2001-01-04 00:05:42 +00:00
|
|
|
nsZLevelEvent *zEvent = (nsZLevelEvent *) aEvent;
|
|
|
|
|
|
|
|
zEvent->mAdjusted = eventWindow->ConstrainToZLevel(zEvent->mImmediate,
|
|
|
|
&zEvent->mPlacement,
|
|
|
|
zEvent->mReqBelow, &zEvent->mActualBelow);
|
2000-04-01 22:13:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-09-19 03:16:30 +00:00
|
|
|
case NS_MOUSE_ACTIVATE:{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-01-26 22:48:16 +00:00
|
|
|
case NS_ACTIVATE: {
|
2000-02-17 21:19:11 +00:00
|
|
|
#ifdef DEBUG_saari
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsWebShellWindow::NS_ACTIVATE\n");
|
2000-02-17 21:19:11 +00:00
|
|
|
#endif
|
2000-09-19 03:16:30 +00:00
|
|
|
// Sucky platform specific code to get around event dispatch ordering
|
|
|
|
#ifdef WIN32
|
2001-01-04 00:05:42 +00:00
|
|
|
|
2000-09-19 03:16:30 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> domWindow;
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow));
|
2000-09-19 03:16:30 +00:00
|
|
|
/*
|
|
|
|
nsCOMPtr<nsIWebShell> contentShell;
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->GetContentWebShell(getter_AddRefs(contentShell));
|
2000-09-19 03:16:30 +00:00
|
|
|
if (contentShell) {
|
|
|
|
|
2001-01-04 00:05:42 +00:00
|
|
|
if (NS_SUCCEEDED(eventWindow->
|
2000-09-19 03:16:30 +00:00
|
|
|
ConvertWebShellToDOMWindow(contentShell, getter_AddRefs(domWindow)))) {
|
|
|
|
if(domWindow){
|
|
|
|
nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(domWindow);
|
|
|
|
if(privateDOMWindow)
|
|
|
|
privateDOMWindow->Activate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else */
|
|
|
|
if (domWindow) {
|
|
|
|
nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(domWindow);
|
|
|
|
if(privateDOMWindow)
|
|
|
|
privateDOMWindow->Activate();
|
|
|
|
}
|
|
|
|
#endif
|
2000-02-11 23:50:15 +00:00
|
|
|
break;
|
2000-09-19 03:16:30 +00:00
|
|
|
|
2000-02-11 23:50:15 +00:00
|
|
|
}
|
2000-04-01 22:13:46 +00:00
|
|
|
|
2000-02-11 23:50:15 +00:00
|
|
|
case NS_DEACTIVATE: {
|
2000-02-17 21:19:11 +00:00
|
|
|
#ifdef DEBUG_saari
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsWebShellWindow::NS_DEACTIVATE\n");
|
2000-02-17 21:19:11 +00:00
|
|
|
#endif
|
2001-01-04 00:05:42 +00:00
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> domWindow;
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow));
|
2000-09-19 03:16:30 +00:00
|
|
|
/*
|
2000-02-11 23:50:15 +00:00
|
|
|
nsCOMPtr<nsIWebShell> contentShell;
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->GetContentWebShell(getter_AddRefs(contentShell));
|
2000-02-11 23:50:15 +00:00
|
|
|
if (contentShell) {
|
|
|
|
|
2001-01-04 00:05:42 +00:00
|
|
|
if (NS_SUCCEEDED(eventWindow->
|
2000-02-11 23:50:15 +00:00
|
|
|
ConvertWebShellToDOMWindow(contentShell, getter_AddRefs(domWindow)))) {
|
|
|
|
if(domWindow){
|
2000-01-26 22:48:16 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(domWindow);
|
|
|
|
if(privateDOMWindow)
|
2000-02-11 23:50:15 +00:00
|
|
|
privateDOMWindow->Deactivate();
|
2000-01-26 22:48:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-19 03:16:30 +00:00
|
|
|
else */
|
|
|
|
if (domWindow) {
|
2000-02-11 23:50:15 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(domWindow);
|
|
|
|
if(privateDOMWindow)
|
|
|
|
privateDOMWindow->Deactivate();
|
|
|
|
}
|
2000-01-26 22:48:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-07-02 19:43:26 +00:00
|
|
|
case NS_GOTFOCUS: {
|
2000-02-17 21:19:11 +00:00
|
|
|
#ifdef DEBUG_saari
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsWebShellWindow::GOTFOCUS\n");
|
2000-02-17 21:19:11 +00:00
|
|
|
#endif
|
2000-02-11 23:50:15 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> domWindow;
|
2001-01-04 00:05:42 +00:00
|
|
|
eventWindow->ConvertWebShellToDOMWindow(webShell, getter_AddRefs(domWindow));
|
2000-11-04 09:33:20 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(domWindow));
|
|
|
|
nsCOMPtr<nsIFocusController> focusController;
|
|
|
|
piWin->GetRootFocusController(getter_AddRefs(focusController));
|
|
|
|
if (focusController) {
|
2001-04-18 01:41:20 +00:00
|
|
|
// This is essentially the first stage of activation (NS_GOTFOCUS is
|
|
|
|
// followed by the DOM window getting activated (which is direct on Win32
|
|
|
|
// and done through web shell window via an NS_ACTIVATE message on the
|
|
|
|
// other platforms).
|
|
|
|
//
|
|
|
|
// Go ahead and mark the focus controller as being active. We have
|
|
|
|
// to do this even before the activate message comes in, since focus
|
|
|
|
// memory kicks in prior to the activate being processed.
|
|
|
|
focusController->SetActive(PR_TRUE);
|
|
|
|
|
2000-11-04 09:33:20 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
|
|
|
|
focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
|
|
|
if (focusedWindow) {
|
2001-04-18 01:41:20 +00:00
|
|
|
focusController->SetSuppressFocus(PR_TRUE, "Activation Suppression");
|
2000-11-04 09:33:20 +00:00
|
|
|
domWindow->Focus(); // This sets focus, but we'll ignore it.
|
|
|
|
// A subsequent activate will cause us to stop suppressing.
|
2001-01-04 00:05:42 +00:00
|
|
|
|
|
|
|
// since the window has been activated, replace persistent size data
|
|
|
|
// with the newly activated window's
|
|
|
|
if (eventWindow->mChromeLoaded)
|
|
|
|
eventWindow->StoreBoundsToXUL(PR_TRUE, PR_TRUE, PR_TRUE);
|
|
|
|
|
2000-11-04 09:33:20 +00:00
|
|
|
break;
|
1999-07-02 19:43:26 +00:00
|
|
|
}
|
|
|
|
}
|
2000-01-26 22:48:16 +00:00
|
|
|
break;
|
1999-07-02 19:43:26 +00:00
|
|
|
}
|
1999-05-29 19:36:55 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
1998-12-03 01:35:53 +00:00
|
|
|
}
|
|
|
|
}
|
2000-04-01 22:13:46 +00:00
|
|
|
return result;
|
1998-12-03 01:35:53 +00:00
|
|
|
}
|
1999-01-21 07:24:01 +00:00
|
|
|
|
2000-05-26 00:14:01 +00:00
|
|
|
#if 0
|
1999-02-21 21:04:21 +00:00
|
|
|
//----------------------------------------
|
|
|
|
NS_IMETHODIMP nsWebShellWindow::CreateMenu(nsIMenuBar * aMenuBar,
|
|
|
|
nsIDOMNode * aMenuNode,
|
|
|
|
nsString & aMenuName)
|
|
|
|
{
|
|
|
|
// Create nsMenu
|
|
|
|
nsIMenu * pnsMenu = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
1999-02-21 21:04:21 +00:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
// Call Create
|
1999-03-20 02:56:03 +00:00
|
|
|
nsISupports * supports = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
aMenuBar->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
1999-03-20 02:56:03 +00:00
|
|
|
pnsMenu->Create(supports, aMenuName);
|
|
|
|
NS_RELEASE(supports);
|
1999-02-21 21:04:21 +00:00
|
|
|
|
|
|
|
// Set nsMenu Name
|
|
|
|
pnsMenu->SetLabel(aMenuName);
|
|
|
|
// Make nsMenu a child of nsMenuBar
|
1999-02-23 07:52:14 +00:00
|
|
|
aMenuBar->AddMenu(pnsMenu);
|
1999-02-21 21:04:21 +00:00
|
|
|
|
1999-06-04 22:52:35 +00:00
|
|
|
// Open the node so that the contents are visible.
|
|
|
|
nsCOMPtr<nsIDOMElement> menuElement = do_QueryInterface(aMenuNode);
|
|
|
|
if (menuElement)
|
2000-04-19 00:19:06 +00:00
|
|
|
menuElement->SetAttribute(NS_ConvertASCIItoUCS2("open"), NS_ConvertASCIItoUCS2("true"));
|
1999-06-04 22:52:35 +00:00
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
// Begin menuitem inner loop
|
1999-07-31 07:15:20 +00:00
|
|
|
|
|
|
|
// Now get the kids. Retrieve our menupopup child.
|
|
|
|
nsCOMPtr<nsIDOMNode> menuPopupNode;
|
|
|
|
aMenuNode->GetFirstChild(getter_AddRefs(menuPopupNode));
|
|
|
|
while (menuPopupNode) {
|
|
|
|
nsCOMPtr<nsIDOMElement> menuPopupElement(do_QueryInterface(menuPopupNode));
|
|
|
|
if (menuPopupElement) {
|
|
|
|
nsString menuPopupNodeType;
|
|
|
|
menuPopupElement->GetNodeName(menuPopupNodeType);
|
2000-04-19 00:19:06 +00:00
|
|
|
if (menuPopupNodeType.EqualsWithConversion("menupopup"))
|
1999-07-31 07:15:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMNode> oldMenuPopupNode(menuPopupNode);
|
|
|
|
oldMenuPopupNode->GetNextSibling(getter_AddRefs(menuPopupNode));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!menuPopupNode)
|
|
|
|
return NS_OK;
|
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> menuitemNode;
|
1999-07-31 07:15:20 +00:00
|
|
|
menuPopupNode->GetFirstChild(getter_AddRefs(menuitemNode));
|
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
while (menuitemNode) {
|
|
|
|
nsCOMPtr<nsIDOMElement> menuitemElement(do_QueryInterface(menuitemNode));
|
|
|
|
if (menuitemElement) {
|
|
|
|
nsString menuitemNodeType;
|
|
|
|
nsString menuitemName;
|
|
|
|
menuitemElement->GetNodeName(menuitemNodeType);
|
2000-04-19 00:19:06 +00:00
|
|
|
if (menuitemNodeType.EqualsWithConversion("menuitem")) {
|
1999-02-23 07:52:14 +00:00
|
|
|
// LoadMenuItem
|
|
|
|
LoadMenuItem(pnsMenu, menuitemElement, menuitemNode);
|
2000-04-19 00:19:06 +00:00
|
|
|
} else if (menuitemNodeType.EqualsWithConversion("menuseparator")) {
|
1999-02-21 21:04:21 +00:00
|
|
|
pnsMenu->AddSeparator();
|
2000-04-19 00:19:06 +00:00
|
|
|
} else if (menuitemNodeType.EqualsWithConversion("menu")) {
|
1999-02-23 07:52:14 +00:00
|
|
|
// Load a submenu
|
|
|
|
LoadSubMenu(pnsMenu, menuitemElement, menuitemNode);
|
1999-02-21 21:04:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMNode> oldmenuitemNode(menuitemNode);
|
|
|
|
oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode));
|
|
|
|
} // end menu item innner loop
|
1999-04-27 09:09:44 +00:00
|
|
|
// The parent owns us, so we can release
|
|
|
|
NS_RELEASE(pnsMenu);
|
1999-02-21 21:04:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-23 07:52:14 +00:00
|
|
|
//----------------------------------------
|
|
|
|
NS_IMETHODIMP nsWebShellWindow::LoadMenuItem(
|
|
|
|
nsIMenu * pParentMenu,
|
|
|
|
nsIDOMElement * menuitemElement,
|
|
|
|
nsIDOMNode * menuitemNode)
|
|
|
|
{
|
|
|
|
nsString menuitemName;
|
|
|
|
nsString menuitemCmd;
|
|
|
|
|
2001-03-22 00:59:29 +00:00
|
|
|
menuitemElement->GetAttribute(NS_ConvertASCIItoUCS2("label"), menuitemName);
|
2000-04-19 00:19:06 +00:00
|
|
|
menuitemElement->GetAttribute(NS_ConvertASCIItoUCS2("cmd"), menuitemCmd);
|
1999-02-23 07:52:14 +00:00
|
|
|
// Create nsMenuItem
|
|
|
|
nsIMenuItem * pnsMenuItem = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kMenuItemCID, nsnull, NS_GET_IID(nsIMenuItem), (void**)&pnsMenuItem);
|
1999-02-23 07:52:14 +00:00
|
|
|
if (NS_OK == rv) {
|
1999-07-02 23:57:29 +00:00
|
|
|
// Create MenuDelegate - this is the intermediator inbetween
|
|
|
|
// the DOM node and the nsIMenuItem
|
|
|
|
// The nsWebShellWindow wacthes for Document changes and then notifies the
|
|
|
|
// the appropriate nsMenuDelegate object
|
|
|
|
nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(menuitemNode));
|
|
|
|
if (!domElement) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-02-26 02:50:09 +00:00
|
|
|
pnsMenuItem->Create(pParentMenu, menuitemName, 0);
|
1999-02-23 07:52:14 +00:00
|
|
|
// Set nsMenuItem Name
|
1999-02-26 02:50:09 +00:00
|
|
|
//pnsMenuItem->SetLabel(menuitemName);
|
1999-07-02 23:57:29 +00:00
|
|
|
|
|
|
|
// Set key shortcut and modifiers
|
2000-04-19 00:19:06 +00:00
|
|
|
nsAutoString keyAtom; keyAtom.AssignWithConversion("key");
|
1999-07-02 23:57:29 +00:00
|
|
|
nsString keyValue;
|
|
|
|
domElement->GetAttribute(keyAtom, keyValue);
|
|
|
|
|
|
|
|
// Try to find the key node.
|
|
|
|
nsCOMPtr<nsIDocument> document;
|
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(domElement);
|
|
|
|
if (NS_FAILED(rv = content->GetDocument(*getter_AddRefs(document)))) {
|
|
|
|
NS_ERROR("Unable to retrieve the document.");
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Turn the document into a XUL document so we can use getElementById
|
|
|
|
nsCOMPtr<nsIDOMXULDocument> xulDocument = do_QueryInterface(document);
|
|
|
|
if (xulDocument == nsnull) {
|
|
|
|
NS_ERROR("not XUL!");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-11-05 00:44:10 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> keyElement;
|
|
|
|
xulDocument->GetElementById(keyValue, getter_AddRefs(keyElement));
|
1999-07-02 23:57:29 +00:00
|
|
|
|
|
|
|
if(keyElement){
|
|
|
|
PRUint8 modifiers = knsMenuItemNoModifier;
|
2000-04-19 00:19:06 +00:00
|
|
|
nsAutoString shiftAtom; shiftAtom.AssignWithConversion("shift");
|
|
|
|
nsAutoString altAtom; altAtom.AssignWithConversion("alt");
|
|
|
|
nsAutoString commandAtom; commandAtom.AssignWithConversion("command");
|
1999-07-02 23:57:29 +00:00
|
|
|
nsString shiftValue;
|
|
|
|
nsString altValue;
|
|
|
|
nsString commandValue;
|
2000-04-19 00:19:06 +00:00
|
|
|
nsString keyChar; keyChar.AssignWithConversion(" ");
|
1999-07-02 23:57:29 +00:00
|
|
|
|
|
|
|
keyElement->GetAttribute(keyAtom, keyChar);
|
|
|
|
keyElement->GetAttribute(shiftAtom, shiftValue);
|
|
|
|
keyElement->GetAttribute(altAtom, altValue);
|
|
|
|
keyElement->GetAttribute(commandAtom, commandValue);
|
|
|
|
|
2000-04-19 00:19:06 +00:00
|
|
|
if(!keyChar.EqualsWithConversion(" "))
|
1999-07-02 23:57:29 +00:00
|
|
|
pnsMenuItem->SetShortcutChar(keyChar);
|
|
|
|
|
2000-04-19 00:19:06 +00:00
|
|
|
if(shiftValue.EqualsWithConversion("true"))
|
1999-07-03 00:31:23 +00:00
|
|
|
modifiers |= knsMenuItemShiftModifier;
|
1999-07-02 23:57:29 +00:00
|
|
|
|
2000-04-19 00:19:06 +00:00
|
|
|
if(altValue.EqualsWithConversion("true"))
|
1999-07-03 00:31:23 +00:00
|
|
|
modifiers |= knsMenuItemAltModifier;
|
1999-07-02 23:57:29 +00:00
|
|
|
|
2000-04-19 00:19:06 +00:00
|
|
|
if(commandValue.EqualsWithConversion("false"))
|
1999-07-03 00:31:23 +00:00
|
|
|
modifiers |= knsMenuItemCommandModifier;
|
1999-07-02 23:57:29 +00:00
|
|
|
|
|
|
|
pnsMenuItem->SetModifiers(modifiers);
|
|
|
|
}
|
|
|
|
|
1999-02-23 07:52:14 +00:00
|
|
|
// Make nsMenuItem a child of nsMenu
|
1999-03-20 02:56:03 +00:00
|
|
|
nsISupports * supports = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
pnsMenuItem->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
1999-03-20 02:56:03 +00:00
|
|
|
pParentMenu->AddItem(supports);
|
|
|
|
NS_RELEASE(supports);
|
1999-02-23 07:52:14 +00:00
|
|
|
|
1999-07-02 23:57:29 +00:00
|
|
|
|
1999-02-23 07:52:14 +00:00
|
|
|
|
2000-04-19 00:19:06 +00:00
|
|
|
nsAutoString cmdAtom; cmdAtom.AssignWithConversion("onaction");
|
1999-02-23 07:52:14 +00:00
|
|
|
nsString cmdName;
|
|
|
|
|
|
|
|
domElement->GetAttribute(cmdAtom, cmdName);
|
|
|
|
|
|
|
|
nsXULCommand * menuDelegate = new nsXULCommand();
|
1999-08-25 23:15:37 +00:00
|
|
|
if ( menuDelegate ) {
|
|
|
|
menuDelegate->SetCommand(cmdName);
|
2000-03-11 01:25:54 +00:00
|
|
|
menuDelegate->SetDocShell(mDocShell);
|
1999-08-25 23:15:37 +00:00
|
|
|
menuDelegate->SetDOMElement(domElement);
|
|
|
|
menuDelegate->SetMenuItem(pnsMenuItem);
|
|
|
|
} else {
|
|
|
|
NS_RELEASE( pnsMenuItem );
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-07-02 23:57:29 +00:00
|
|
|
|
1999-02-23 07:52:14 +00:00
|
|
|
nsIXULCommand * icmd;
|
2000-01-31 23:45:42 +00:00
|
|
|
if (NS_OK == menuDelegate->QueryInterface(NS_GET_IID(nsIXULCommand), (void**) &icmd)) {
|
1999-02-23 07:52:14 +00:00
|
|
|
nsCOMPtr<nsIMenuListener> listener(do_QueryInterface(menuDelegate));
|
1999-03-26 11:34:21 +00:00
|
|
|
|
|
|
|
if (listener)
|
|
|
|
{
|
1999-02-23 07:52:14 +00:00
|
|
|
pnsMenuItem->AddMenuListener(listener);
|
1999-03-26 11:34:21 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_MENUSDEL
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Adding menu listener to [%s]\n", menuitemName.ToNewCString());
|
1999-03-26 11:34:21 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#ifdef DEBUG_MENUSDEL
|
|
|
|
else
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("*** NOT Adding menu listener to [%s]\n", menuitemName.ToNewCString());
|
1999-02-23 07:52:14 +00:00
|
|
|
}
|
1999-03-26 11:34:21 +00:00
|
|
|
#endif
|
1999-04-27 09:38:56 +00:00
|
|
|
NS_RELEASE(icmd);
|
1999-02-23 07:52:14 +00:00
|
|
|
}
|
1999-04-27 09:09:44 +00:00
|
|
|
|
|
|
|
// The parent owns us, so we can release
|
|
|
|
NS_RELEASE(pnsMenuItem);
|
1999-08-25 23:15:37 +00:00
|
|
|
}
|
1999-02-23 07:52:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
void nsWebShellWindow::LoadSubMenu(
|
|
|
|
nsIMenu * pParentMenu,
|
|
|
|
nsIDOMElement * menuElement,
|
|
|
|
nsIDOMNode * menuNode)
|
|
|
|
{
|
|
|
|
nsString menuName;
|
2001-03-22 00:59:29 +00:00
|
|
|
menuElement->GetAttribute(NS_ConvertASCIItoUCS2("label"), menuName);
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks
|
1999-02-23 07:52:14 +00:00
|
|
|
|
|
|
|
// Create nsMenu
|
|
|
|
nsIMenu * pnsMenu = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, NS_GET_IID(nsIMenu), (void**)&pnsMenu);
|
1999-02-23 07:52:14 +00:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
// Call Create
|
1999-03-20 02:56:03 +00:00
|
|
|
nsISupports * supports = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
pParentMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
1999-03-20 02:56:03 +00:00
|
|
|
pnsMenu->Create(supports, menuName);
|
|
|
|
NS_RELEASE(supports); // Balance QI
|
1999-02-23 07:52:14 +00:00
|
|
|
|
1999-07-07 00:48:06 +00:00
|
|
|
// Open the node so that the contents are visible.
|
2000-04-19 00:19:06 +00:00
|
|
|
menuElement->SetAttribute(NS_ConvertASCIItoUCS2("open"), NS_ConvertASCIItoUCS2("true"));
|
1999-07-07 00:48:06 +00:00
|
|
|
|
1999-02-23 07:52:14 +00:00
|
|
|
// Set nsMenu Name
|
|
|
|
pnsMenu->SetLabel(menuName);
|
|
|
|
// Make nsMenu a child of parent nsMenu
|
1999-03-20 02:56:03 +00:00
|
|
|
//pParentMenu->AddMenu(pnsMenu);
|
|
|
|
supports = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
pnsMenu->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
1999-03-20 02:56:03 +00:00
|
|
|
pParentMenu->AddItem(supports);
|
|
|
|
NS_RELEASE(supports);
|
1999-02-23 07:52:14 +00:00
|
|
|
|
|
|
|
// Begin menuitem inner loop
|
1999-07-31 07:15:20 +00:00
|
|
|
|
|
|
|
// Now get the kids. Retrieve our menupopup child.
|
|
|
|
nsCOMPtr<nsIDOMNode> menuPopupNode;
|
|
|
|
menuNode->GetFirstChild(getter_AddRefs(menuPopupNode));
|
|
|
|
while (menuPopupNode) {
|
|
|
|
nsCOMPtr<nsIDOMElement> menuPopupElement(do_QueryInterface(menuPopupNode));
|
|
|
|
if (menuPopupElement) {
|
|
|
|
nsString menuPopupNodeType;
|
|
|
|
menuPopupElement->GetNodeName(menuPopupNodeType);
|
2000-04-19 00:19:06 +00:00
|
|
|
if (menuPopupNodeType.EqualsWithConversion("menupopup"))
|
1999-07-31 07:15:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMNode> oldMenuPopupNode(menuPopupNode);
|
|
|
|
oldMenuPopupNode->GetNextSibling(getter_AddRefs(menuPopupNode));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!menuPopupNode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> menuitemNode;
|
|
|
|
menuPopupNode->GetFirstChild(getter_AddRefs(menuitemNode));
|
|
|
|
|
1999-02-23 07:52:14 +00:00
|
|
|
while (menuitemNode) {
|
|
|
|
nsCOMPtr<nsIDOMElement> menuitemElement(do_QueryInterface(menuitemNode));
|
|
|
|
if (menuitemElement) {
|
|
|
|
nsString menuitemNodeType;
|
|
|
|
menuitemElement->GetNodeName(menuitemNodeType);
|
1999-03-26 11:34:21 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_saari
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Type [%s] %d\n", menuitemNodeType.ToNewCString(), menuitemNodeType.Equals("menuseparator"));
|
1999-03-26 11:34:21 +00:00
|
|
|
#endif
|
|
|
|
|
2000-04-19 00:19:06 +00:00
|
|
|
if (menuitemNodeType.EqualsWithConversion("menuitem")) {
|
1999-02-23 07:52:14 +00:00
|
|
|
// Load a menuitem
|
|
|
|
LoadMenuItem(pnsMenu, menuitemElement, menuitemNode);
|
2000-04-19 00:19:06 +00:00
|
|
|
} else if (menuitemNodeType.EqualsWithConversion("menuseparator")) {
|
1999-02-23 07:52:14 +00:00
|
|
|
pnsMenu->AddSeparator();
|
2000-04-19 00:19:06 +00:00
|
|
|
} else if (menuitemNodeType.EqualsWithConversion("menu")) {
|
1999-02-23 07:52:14 +00:00
|
|
|
// Add a submenu
|
|
|
|
LoadSubMenu(pnsMenu, menuitemElement, menuitemNode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMNode> oldmenuitemNode(menuitemNode);
|
|
|
|
oldmenuitemNode->GetNextSibling(getter_AddRefs(menuitemNode));
|
|
|
|
} // end menu item innner loop
|
1999-04-27 09:09:44 +00:00
|
|
|
|
|
|
|
// The parent owns us, so we can release
|
|
|
|
NS_RELEASE(pnsMenu);
|
1999-02-23 07:52:14 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-26 00:14:01 +00:00
|
|
|
#endif
|
1999-02-23 07:52:14 +00:00
|
|
|
|
1999-04-19 08:23:18 +00:00
|
|
|
//----------------------------------------
|
|
|
|
void nsWebShellWindow::DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow)
|
|
|
|
{
|
1999-07-07 22:33:26 +00:00
|
|
|
nsRect oldRect;
|
|
|
|
mWindow->GetClientBounds(oldRect);
|
|
|
|
|
1999-04-19 08:23:18 +00:00
|
|
|
// locate the window element which holds toolbars and menus and commands
|
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
|
|
|
aDOMDoc->GetDocumentElement(getter_AddRefs(element));
|
|
|
|
if (!element) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMNode> window(do_QueryInterface(element));
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
int endCount = 0;
|
2000-04-19 00:19:06 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> menubarNode(FindNamedDOMNode(NS_ConvertASCIItoUCS2("menubar"), window, endCount, 1));
|
1999-04-19 08:23:18 +00:00
|
|
|
if (menubarNode) {
|
|
|
|
nsIMenuBar * pnsMenuBar = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, NS_GET_IID(nsIMenuBar), (void**)&pnsMenuBar);
|
1999-04-19 08:23:18 +00:00
|
|
|
if (NS_OK == rv) {
|
1999-04-27 09:09:44 +00:00
|
|
|
if (nsnull != pnsMenuBar) {
|
1999-04-19 08:23:18 +00:00
|
|
|
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
|
|
|
nsCOMPtr<nsIMenuListener> menuListener;
|
2000-01-31 23:45:42 +00:00
|
|
|
pnsMenuBar->QueryInterface(NS_GET_IID(nsIMenuListener), getter_AddRefs(menuListener));
|
1999-04-19 08:23:18 +00:00
|
|
|
|
|
|
|
//fake event
|
|
|
|
nsMenuEvent fake;
|
|
|
|
menuListener->MenuConstruct(fake, aParentWindow, menubarNode, mWebShell);
|
1999-05-03 19:04:16 +00:00
|
|
|
|
2000-03-30 01:47:20 +00:00
|
|
|
// Parent should own menubar now
|
|
|
|
NS_RELEASE(pnsMenuBar);
|
|
|
|
|
2000-03-11 03:08:04 +00:00
|
|
|
#ifdef USE_NATIVE_MENUS
|
1999-08-09 19:14:38 +00:00
|
|
|
#else
|
1999-07-07 22:33:26 +00:00
|
|
|
// Resize around the menu.
|
1999-05-29 19:36:55 +00:00
|
|
|
rv = NS_ERROR_FAILURE;
|
1999-05-03 19:04:16 +00:00
|
|
|
|
1999-07-07 22:33:26 +00:00
|
|
|
// do a resize
|
1999-05-03 19:04:16 +00:00
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
2000-03-11 01:25:54 +00:00
|
|
|
if( NS_FAILED(mDocShell->GetContentViewer(getter_AddRefs(contentViewer))))
|
1999-11-15 07:29:23 +00:00
|
|
|
{
|
|
|
|
NS_WARN_IF_FALSE(PR_FALSE, "Error Getting contentViewer");
|
|
|
|
return;
|
|
|
|
}
|
1999-05-03 19:04:16 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer;
|
|
|
|
docViewer = do_QueryInterface(contentViewer);
|
|
|
|
if (!docViewer) {
|
|
|
|
NS_ERROR("Document viewer interface not supported by the content viewer.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
if (NS_FAILED(rv = docViewer->GetPresContext(*getter_AddRefs(presContext)))) {
|
|
|
|
NS_ERROR("Unable to retrieve the doc viewer's presentation context.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
if (NS_FAILED(rv = presContext->GetShell(getter_AddRefs(presShell)))) {
|
|
|
|
NS_ERROR("Unable to retrieve the shell from the presentation context.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect rect;
|
|
|
|
|
|
|
|
if (NS_FAILED(rv = mWindow->GetClientBounds(rect))) {
|
|
|
|
NS_ERROR("Failed to get web shells bounds");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-07-07 22:33:26 +00:00
|
|
|
// Resize the browser window by the difference.
|
|
|
|
PRInt32 heightDelta = oldRect.height - rect.height;
|
2000-03-11 01:25:54 +00:00
|
|
|
PRInt32 cx, cy;
|
|
|
|
GetSize(&cx, &cy);
|
|
|
|
SetSize(cx, cy + heightDelta, PR_FALSE);
|
1999-05-03 19:04:16 +00:00
|
|
|
// END REFLOW CODE
|
1999-08-09 19:14:38 +00:00
|
|
|
#endif
|
1999-04-19 08:23:18 +00:00
|
|
|
|
|
|
|
} // end if ( nsnull != pnsMenuBar )
|
|
|
|
}
|
|
|
|
} // end if (menuBar)
|
1999-07-07 00:48:06 +00:00
|
|
|
} // nsWebShellWindow::DynamicLoadMenus
|
1999-04-19 08:23:18 +00:00
|
|
|
|
2000-05-26 00:14:01 +00:00
|
|
|
#if 0
|
1999-01-30 00:39:25 +00:00
|
|
|
//----------------------------------------
|
1999-01-27 10:51:28 +00:00
|
|
|
void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWindow)
|
|
|
|
{
|
1999-01-28 00:21:12 +00:00
|
|
|
// locate the window element which holds toolbars and menus and commands
|
1999-02-12 15:56:54 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
|
|
|
aDOMDoc->GetDocumentElement(getter_AddRefs(element));
|
1999-02-21 21:04:21 +00:00
|
|
|
if (!element) {
|
1999-01-28 00:21:12 +00:00
|
|
|
return;
|
1999-02-21 21:04:21 +00:00
|
|
|
}
|
1999-02-17 02:08:00 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> window(do_QueryInterface(element));
|
1999-01-28 00:21:12 +00:00
|
|
|
|
1999-01-27 10:51:28 +00:00
|
|
|
nsresult rv;
|
1999-01-28 01:30:38 +00:00
|
|
|
int endCount = 0;
|
2000-04-19 00:19:06 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> menubarNode(FindNamedDOMNode(NS_ConvertASCIItoUCS2("menubar"), window, endCount, 1));
|
1999-01-28 02:26:27 +00:00
|
|
|
if (menubarNode) {
|
1999-01-27 10:51:28 +00:00
|
|
|
nsIMenuBar * pnsMenuBar = nsnull;
|
2000-01-31 23:45:42 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, NS_GET_IID(nsIMenuBar), (void**)&pnsMenuBar);
|
1999-02-21 21:04:21 +00:00
|
|
|
if (NS_OK == rv) {
|
|
|
|
if (nsnull != pnsMenuBar) {
|
|
|
|
pnsMenuBar->Create(aParentWindow);
|
1999-02-04 02:42:07 +00:00
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
|
|
|
nsCOMPtr<nsIMenuListener> menuListener;
|
2000-01-31 23:45:42 +00:00
|
|
|
pnsMenuBar->QueryInterface(NS_GET_IID(nsIMenuListener), getter_AddRefs(menuListener));
|
1999-02-28 11:14:34 +00:00
|
|
|
aParentWindow->AddMenuListener(menuListener);
|
1999-02-21 21:04:21 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> menuNode;
|
|
|
|
menubarNode->GetFirstChild(getter_AddRefs(menuNode));
|
|
|
|
while (menuNode) {
|
|
|
|
nsCOMPtr<nsIDOMElement> menuElement(do_QueryInterface(menuNode));
|
|
|
|
if (menuElement) {
|
|
|
|
nsString menuNodeType;
|
|
|
|
nsString menuName;
|
|
|
|
menuElement->GetNodeName(menuNodeType);
|
2000-04-19 00:19:06 +00:00
|
|
|
if (menuNodeType.EqualsWithConversion("menu")) {
|
2001-03-22 00:59:29 +00:00
|
|
|
menuElement->GetAttribute(NS_ConvertASCIItoUCS2("label"), menuName);
|
1999-03-26 11:34:21 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_rods
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks
|
1999-03-26 11:34:21 +00:00
|
|
|
#endif
|
1999-02-21 21:04:21 +00:00
|
|
|
CreateMenu(pnsMenuBar, menuNode, menuName);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMNode> oldmenuNode(menuNode);
|
|
|
|
oldmenuNode->GetNextSibling(getter_AddRefs(menuNode));
|
|
|
|
} // end while (nsnull != menuNode)
|
1999-01-30 00:39:25 +00:00
|
|
|
|
1999-04-27 09:09:44 +00:00
|
|
|
// Give the aParentWindow this nsMenuBar to own.
|
1999-02-28 11:14:34 +00:00
|
|
|
aParentWindow->SetMenuBar(pnsMenuBar);
|
1999-02-04 02:42:07 +00:00
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
// HACK: force a paint for now
|
|
|
|
pnsMenuBar->Paint();
|
1999-04-08 04:29:37 +00:00
|
|
|
|
|
|
|
// HACK for M4, should be removed by M5
|
2000-03-11 03:08:04 +00:00
|
|
|
// ... it is now M15
|
|
|
|
#ifdef USE_NATIVE_MENUS
|
1999-04-08 04:29:37 +00:00
|
|
|
Handle tempMenuBar = ::GetMenuBar(); // Get a copy of the menu list
|
|
|
|
pnsMenuBar->SetNativeData((void*)tempMenuBar);
|
1999-07-31 07:15:20 +00:00
|
|
|
#endif
|
1999-04-27 09:09:44 +00:00
|
|
|
|
|
|
|
// The parent owns the menubar, so we can release it
|
|
|
|
NS_RELEASE(pnsMenuBar);
|
1999-01-27 10:51:28 +00:00
|
|
|
} // end if ( nsnull != pnsMenuBar )
|
1999-02-21 21:04:21 +00:00
|
|
|
}
|
|
|
|
} // end if (menuBar)
|
1999-01-27 10:51:28 +00:00
|
|
|
|
1999-01-30 00:39:25 +00:00
|
|
|
} // nsWebShellWindow::LoadMenus
|
|
|
|
|
1999-05-14 22:28:00 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void nsWebShellWindow::DoContextMenu(
|
|
|
|
nsMenuEvent * aMenuEvent,
|
|
|
|
nsIDOMNode * aMenuNode,
|
|
|
|
nsIWidget * aParentWindow,
|
|
|
|
PRInt32 aX,
|
1999-06-09 09:24:10 +00:00
|
|
|
PRInt32 aY,
|
1999-06-09 10:13:46 +00:00
|
|
|
const nsString& aPopupAlignment,
|
|
|
|
const nsString& aAnchorAlignment)
|
1999-05-14 22:28:00 +00:00
|
|
|
{
|
|
|
|
if (aMenuNode) {
|
|
|
|
nsIContextMenu * pnsContextMenu;
|
2000-01-31 23:45:42 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kContextMenuCID, nsnull, NS_GET_IID(nsIContextMenu), (void**)&pnsContextMenu);
|
1999-05-14 22:28:00 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && pnsContextMenu) {
|
|
|
|
nsISupports * supports;
|
2000-01-31 23:45:42 +00:00
|
|
|
aParentWindow->QueryInterface(NS_GET_IID(nsISupports), (void**) &supports);
|
1999-06-09 10:13:46 +00:00
|
|
|
pnsContextMenu->Create(supports, aPopupAlignment, aAnchorAlignment);
|
1999-05-14 22:28:00 +00:00
|
|
|
NS_RELEASE(supports);
|
|
|
|
pnsContextMenu->SetLocation(aX,aY);
|
|
|
|
// Set webshell
|
1999-05-14 23:10:46 +00:00
|
|
|
pnsContextMenu->SetWebShell( mWebShell );
|
|
|
|
|
1999-05-14 22:28:00 +00:00
|
|
|
// Set DOM node
|
|
|
|
pnsContextMenu->SetDOMNode( aMenuNode );
|
|
|
|
|
|
|
|
// Construct and show menu
|
|
|
|
nsIMenuListener * listener;
|
2000-01-31 23:45:42 +00:00
|
|
|
pnsContextMenu->QueryInterface(NS_GET_IID(nsIMenuListener), (void**) &listener);
|
1999-05-14 22:28:00 +00:00
|
|
|
|
|
|
|
// Dynamically construct and track the menu
|
|
|
|
listener->MenuSelected(*aMenuEvent);
|
|
|
|
|
|
|
|
// Destroy the menu
|
|
|
|
listener->MenuDeselected(*aMenuEvent);
|
|
|
|
|
|
|
|
// The parent owns the context menu, so we can release it
|
|
|
|
NS_RELEASE(listener);
|
1999-05-15 02:53:43 +00:00
|
|
|
NS_RELEASE(pnsContextMenu);
|
1999-05-14 22:28:00 +00:00
|
|
|
}
|
|
|
|
} // end if (aMenuNode)
|
|
|
|
}
|
2000-05-26 00:14:01 +00:00
|
|
|
#endif
|
1999-05-14 22:28:00 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
1999-05-04 23:36:42 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::GetContentShellById(const nsString& aID, nsIWebShell** aChildShell)
|
|
|
|
{
|
|
|
|
// Set to null just to be certain
|
2000-01-26 02:21:42 +00:00
|
|
|
*aChildShell = nsnull;
|
1999-05-04 23:36:42 +00:00
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> content;
|
1999-05-04 23:36:42 +00:00
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
nsXULWindow::GetContentShellById(aID.GetUnicode(), getter_AddRefs(content));
|
|
|
|
if(!content)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
CallQueryInterface(content, aChildShell);
|
1999-05-04 23:36:42 +00:00
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
return NS_OK;
|
1999-05-04 23:36:42 +00:00
|
|
|
}
|
1999-04-20 22:35:11 +00:00
|
|
|
|
1999-05-14 22:28:00 +00:00
|
|
|
//------------------------------------------------------------------------------
|
1999-04-20 22:35:11 +00:00
|
|
|
NS_IMETHODIMP
|
2000-09-01 01:54:35 +00:00
|
|
|
nsWebShellWindow::ConvertWebShellToDOMWindow(nsIWebShell* aShell, nsIDOMWindowInternal** aDOMWindow)
|
1999-04-20 22:35:11 +00:00
|
|
|
{
|
1999-12-03 09:24:22 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObjectOwner> globalObjectOwner(do_QueryInterface(aShell));
|
|
|
|
NS_ENSURE_TRUE(globalObjectOwner, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
|
|
|
globalObjectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
|
|
|
NS_ENSURE_TRUE(globalObject, NS_ERROR_FAILURE);
|
|
|
|
|
2000-09-01 01:54:35 +00:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> newDOMWindow(do_QueryInterface(globalObject));
|
1999-12-03 09:24:22 +00:00
|
|
|
NS_ENSURE_TRUE(newDOMWindow, NS_ERROR_FAILURE);
|
1999-04-20 22:35:11 +00:00
|
|
|
|
1999-12-03 09:24:22 +00:00
|
|
|
*aDOMWindow = newDOMWindow.get();
|
|
|
|
NS_ADDREF(*aDOMWindow);
|
1999-04-20 22:35:11 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-10 16:32:55 +00:00
|
|
|
//----------------------------------------
|
|
|
|
// nsIWebShellWindow methods...
|
|
|
|
//----------------------------------------
|
1999-02-15 05:38:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::Show(PRBool aShow)
|
|
|
|
{
|
2000-02-15 05:06:08 +00:00
|
|
|
return nsXULWindow::SetVisibility(aShow);
|
1999-02-15 05:38:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-20 04:13:09 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ShowModal()
|
|
|
|
{
|
2000-02-25 03:11:13 +00:00
|
|
|
return nsXULWindow::ShowModal();
|
1999-03-20 04:13:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-12 22:08:17 +00:00
|
|
|
// yes, this one's name and ShowModal are a confusing pair. plan is to merge
|
|
|
|
// the two someday.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ShowModally(PRBool aPrepare)
|
2000-02-24 01:39:31 +00:00
|
|
|
{
|
|
|
|
NS_ERROR("Can't use this anymore");
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-08-12 22:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-26 21:48:29 +00:00
|
|
|
/* return the main, outermost webshell in this window */
|
1999-02-10 16:32:55 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::GetWebShell(nsIWebShell *& aWebShell)
|
|
|
|
{
|
|
|
|
aWebShell = mWebShell;
|
|
|
|
NS_ADDREF(mWebShell);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-26 21:48:29 +00:00
|
|
|
/* return the webshell intended to hold (html) content. In a simple
|
|
|
|
browser window, that would be the main content area. If no such
|
|
|
|
webshell was found for any reason, the outermost webshell will be
|
|
|
|
returned. (Note that is the main chrome webshell, and probably
|
|
|
|
not what you wanted, but at least it's a webshell.)
|
|
|
|
Also note that if no content webshell was marked "primary,"
|
|
|
|
we return the chrome webshell, even if (non-primary) content webshells
|
|
|
|
do exist. Thas was done intentionally. The selection would be
|
|
|
|
nondeterministic, and it seems dangerous to set a precedent like that.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::GetContentWebShell(nsIWebShell **aResult)
|
|
|
|
{
|
2000-01-26 02:21:42 +00:00
|
|
|
*aResult = nsnull;
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> content;
|
1999-06-26 21:48:29 +00:00
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
GetPrimaryContentShell(getter_AddRefs(content));
|
|
|
|
if(!content)
|
|
|
|
return NS_OK;
|
|
|
|
CallQueryInterface(content, aResult);
|
1999-06-26 21:48:29 +00:00
|
|
|
|
2000-01-26 02:21:42 +00:00
|
|
|
return NS_OK;
|
1999-06-26 21:48:29 +00:00
|
|
|
}
|
|
|
|
|
1999-02-10 16:32:55 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::GetWidget(nsIWidget *& aWidget)
|
|
|
|
{
|
|
|
|
aWidget = mWindow;
|
2000-01-26 02:21:42 +00:00
|
|
|
NS_IF_ADDREF(aWidget);
|
1999-02-10 16:32:55 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-01-26 15:58:58 +00:00
|
|
|
|
1999-11-16 20:05:21 +00:00
|
|
|
NS_IMETHODIMP
|
2000-09-01 01:54:35 +00:00
|
|
|
nsWebShellWindow::GetDOMWindow(nsIDOMWindowInternal** aDOMWindow)
|
1999-11-16 20:05:21 +00:00
|
|
|
{
|
|
|
|
return ConvertWebShellToDOMWindow(mWebShell, aDOMWindow);
|
|
|
|
}
|
|
|
|
|
1999-03-20 04:13:09 +00:00
|
|
|
void *
|
|
|
|
nsWebShellWindow::HandleModalDialogEvent(PLEvent *aEvent)
|
|
|
|
{
|
|
|
|
ThreadedWindowEvent *event = (ThreadedWindowEvent *) aEvent;
|
|
|
|
|
2000-02-15 05:06:08 +00:00
|
|
|
event->window->ShowModal();
|
1999-03-20 04:13:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWebShellWindow::DestroyModalDialogEvent(PLEvent *aEvent)
|
|
|
|
{
|
|
|
|
PR_Free(aEvent);
|
|
|
|
}
|
|
|
|
|
2000-02-23 20:07:31 +00:00
|
|
|
void
|
2000-02-24 21:16:16 +00:00
|
|
|
nsWebShellWindow::SetPersistenceTimer(PRBool aSize, PRBool aPosition)
|
2000-02-23 20:07:31 +00:00
|
|
|
{
|
|
|
|
PR_Lock(mSPTimerLock);
|
2000-02-24 21:16:16 +00:00
|
|
|
if (mSPTimer) {
|
2000-02-23 20:07:31 +00:00
|
|
|
mSPTimer->SetDelay(SIZE_PERSISTENCE_TIMEOUT);
|
2000-02-24 21:16:16 +00:00
|
|
|
mSPTimerSize |= aSize;
|
|
|
|
mSPTimerPosition |= aPosition;
|
|
|
|
} else {
|
2000-05-17 02:49:35 +00:00
|
|
|
nsresult rv;
|
2000-09-13 23:57:52 +00:00
|
|
|
mSPTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
2000-05-17 02:49:35 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2000-02-23 20:07:31 +00:00
|
|
|
mSPTimer->Init(FirePersistenceTimer, this,
|
|
|
|
SIZE_PERSISTENCE_TIMEOUT, NS_TYPE_ONE_SHOT);
|
2000-02-24 21:16:16 +00:00
|
|
|
mSPTimerSize = aSize;
|
|
|
|
mSPTimerPosition = aPosition;
|
2000-05-17 02:49:35 +00:00
|
|
|
}
|
2000-02-24 21:16:16 +00:00
|
|
|
}
|
2000-02-23 20:07:31 +00:00
|
|
|
PR_Unlock(mSPTimerLock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsWebShellWindow::FirePersistenceTimer(nsITimer *aTimer, void *aClosure)
|
|
|
|
{
|
|
|
|
nsWebShellWindow *win = NS_STATIC_CAST(nsWebShellWindow *, aClosure);
|
|
|
|
PR_Lock(win->mSPTimerLock);
|
|
|
|
win->mSPTimer = nsnull;
|
|
|
|
PR_Unlock(win->mSPTimerLock);
|
2000-03-09 02:00:20 +00:00
|
|
|
win->StoreBoundsToXUL(win->mSPTimerPosition, win->mSPTimerSize, PR_FALSE);
|
2000-02-23 20:07:31 +00:00
|
|
|
}
|
1999-03-20 04:13:09 +00:00
|
|
|
|
1999-04-06 21:01:51 +00:00
|
|
|
|
1999-01-26 15:58:58 +00:00
|
|
|
//----------------------------------------
|
2000-12-14 23:27:59 +00:00
|
|
|
// nsIWebProgessListener implementation
|
1999-01-26 15:58:58 +00:00
|
|
|
//----------------------------------------
|
1999-03-29 09:21:01 +00:00
|
|
|
NS_IMETHODIMP
|
2000-12-14 23:27:59 +00:00
|
|
|
nsWebShellWindow::OnProgressChange(nsIWebProgress *aProgress,
|
|
|
|
nsIRequest *aRequest,
|
|
|
|
PRInt32 aCurSelfProgress,
|
|
|
|
PRInt32 aMaxSelfProgress,
|
|
|
|
PRInt32 aCurTotalProgress,
|
|
|
|
PRInt32 aMaxTotalProgress)
|
1999-03-29 09:21:01 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-12-14 23:27:59 +00:00
|
|
|
nsWebShellWindow::OnStateChange(nsIWebProgress *aProgress,
|
|
|
|
nsIRequest *aRequest,
|
|
|
|
PRInt32 aStateFlags,
|
|
|
|
nsresult aStatus)
|
1999-03-29 09:21:01 +00:00
|
|
|
{
|
2000-12-14 23:27:59 +00:00
|
|
|
// If the notification is not about a document finishing, then just
|
|
|
|
// ignore it...
|
|
|
|
if (!(aStateFlags & nsIWebProgressListener::STATE_STOP) ||
|
|
|
|
!(aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-06 21:01:51 +00:00
|
|
|
#ifdef DEBUG_MENUSDEL
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("OnEndDocumentLoad\n");
|
1999-04-06 21:01:51 +00:00
|
|
|
#endif
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
if (mChromeLoaded)
|
1999-04-06 21:01:51 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
2000-12-14 23:27:59 +00:00
|
|
|
//
|
|
|
|
// If this document notification is for a frame then ignore it...
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow, topDOMWindow;
|
|
|
|
|
|
|
|
(void) aProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
|
|
|
if (domWindow) {
|
|
|
|
domWindow->GetTop(getter_AddRefs(topDOMWindow));
|
|
|
|
|
|
|
|
if (domWindow != topDOMWindow) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-11-01 01:20:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
mChromeLoaded = PR_TRUE;
|
1999-08-12 22:08:17 +00:00
|
|
|
mLockedUntilChromeLoad = PR_FALSE;
|
1999-05-04 23:36:42 +00:00
|
|
|
|
2000-03-11 03:08:04 +00:00
|
|
|
#ifdef USE_NATIVE_MENUS
|
1999-04-06 21:01:51 +00:00
|
|
|
// register as document listener
|
|
|
|
// this is needed for menus
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
2000-03-11 01:25:54 +00:00
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(cv));
|
1999-04-06 21:01:51 +00:00
|
|
|
if (cv) {
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
|
|
|
if (!docv)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
docv->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (!doc)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
doc->AddObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
|
|
|
|
}
|
1999-07-31 21:08:10 +00:00
|
|
|
#endif
|
1999-04-06 21:01:51 +00:00
|
|
|
|
2000-03-11 03:08:04 +00:00
|
|
|
#ifdef USE_NATIVE_MENUS
|
1999-04-06 21:01:51 +00:00
|
|
|
///////////////////////////////
|
|
|
|
// Find the Menubar DOM and Load the menus, hooking them up to the loaded commands
|
|
|
|
///////////////////////////////
|
2000-04-19 00:19:06 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> menubarDOMDoc(GetNamedDOMDoc(NS_ConvertASCIItoUCS2("this"))); // XXX "this" is a small kludge for code reused
|
1999-04-06 21:01:51 +00:00
|
|
|
if (menubarDOMDoc)
|
1999-04-19 08:23:18 +00:00
|
|
|
{
|
1999-08-09 19:14:38 +00:00
|
|
|
#ifdef SOME_PLATFORM // Anyone using native non-dynamic menus should add themselves here.
|
1999-04-06 21:01:51 +00:00
|
|
|
LoadMenus(menubarDOMDoc, mWindow);
|
1999-05-14 22:28:00 +00:00
|
|
|
// Context Menu test
|
1999-05-19 04:11:54 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> element;
|
|
|
|
menubarDOMDoc->GetDocumentElement(getter_AddRefs(element));
|
|
|
|
nsCOMPtr<nsIDOMNode> window(do_QueryInterface(element));
|
1999-05-14 22:28:00 +00:00
|
|
|
|
1999-05-19 04:11:54 +00:00
|
|
|
int endCount = 0;
|
|
|
|
contextMenuTest = FindNamedDOMNode(nsAutoString("contextmenu"), window, endCount, 1);
|
1999-05-14 22:28:00 +00:00
|
|
|
// End Context Menu test
|
1999-07-31 07:15:20 +00:00
|
|
|
#else
|
1999-07-23 02:37:14 +00:00
|
|
|
DynamicLoadMenus(menubarDOMDoc, mWindow);
|
1999-08-09 19:14:38 +00:00
|
|
|
#endif
|
1999-04-19 08:23:18 +00:00
|
|
|
}
|
2000-03-11 03:08:04 +00:00
|
|
|
#endif // USE_NATIVE_MENUS
|
1999-04-06 21:01:51 +00:00
|
|
|
|
2000-02-08 13:40:10 +00:00
|
|
|
OnChromeLoaded();
|
2000-02-10 07:47:24 +00:00
|
|
|
LoadContentAreas();
|
1999-04-06 21:01:51 +00:00
|
|
|
|
1999-03-29 09:21:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-12-14 23:27:59 +00:00
|
|
|
nsWebShellWindow::OnLocationChange(nsIWebProgress *aProgress,
|
|
|
|
nsIRequest *aRequest,
|
|
|
|
nsIURI *aURI)
|
1999-03-29 09:21:01 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-12-14 23:27:59 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::OnStatusChange(nsIWebProgress* aWebProgress,
|
|
|
|
nsIRequest* aRequest,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar* aMessage)
|
1999-03-29 09:21:01 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-12-14 23:27:59 +00:00
|
|
|
nsWebShellWindow::OnSecurityChange(nsIWebProgress *aWebProgress,
|
|
|
|
nsIRequest *aRequest,
|
|
|
|
PRInt32 state)
|
1999-03-29 09:21:01 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-12-14 23:27:59 +00:00
|
|
|
|
1999-01-26 15:58:58 +00:00
|
|
|
//----------------------------------------
|
1999-01-30 00:39:25 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> nsWebShellWindow::FindNamedDOMNode(const nsString &aName, nsIDOMNode * aParent, PRInt32 & aCount, PRInt32 aEndCount)
|
1999-01-26 15:58:58 +00:00
|
|
|
{
|
1999-07-04 02:43:58 +00:00
|
|
|
if(!aParent)
|
|
|
|
return nsnull;
|
|
|
|
|
1999-01-30 00:39:25 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node;
|
|
|
|
aParent->GetFirstChild(getter_AddRefs(node));
|
|
|
|
while (node) {
|
1999-01-27 04:02:33 +00:00
|
|
|
nsString name;
|
|
|
|
node->GetNodeName(name);
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("FindNamedDOMNode[%s]==[%s] %d == %d\n", aName.ToNewCString(), name.ToNewCString(), aCount+1, aEndCount); //this leaks
|
1999-01-27 04:02:33 +00:00
|
|
|
if (name.Equals(aName)) {
|
|
|
|
aCount++;
|
1999-01-30 00:39:25 +00:00
|
|
|
if (aCount == aEndCount)
|
1999-01-27 04:02:33 +00:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
PRBool hasChildren;
|
|
|
|
node->HasChildNodes(&hasChildren);
|
|
|
|
if (hasChildren) {
|
1999-01-30 00:39:25 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> found(FindNamedDOMNode(aName, node, aCount, aEndCount));
|
|
|
|
if (found)
|
1999-01-27 04:02:33 +00:00
|
|
|
return found;
|
|
|
|
}
|
1999-01-30 00:39:25 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> oldNode = node;
|
|
|
|
oldNode->GetNextSibling(getter_AddRefs(node));
|
1999-01-27 04:02:33 +00:00
|
|
|
}
|
1999-02-19 12:27:19 +00:00
|
|
|
node = do_QueryInterface(nsnull);
|
1999-01-30 00:39:25 +00:00
|
|
|
return node;
|
1999-01-26 15:58:58 +00:00
|
|
|
|
1999-01-30 00:39:25 +00:00
|
|
|
} // nsWebShellWindow::FindNamedDOMNode
|
1999-01-27 04:02:33 +00:00
|
|
|
|
|
|
|
//----------------------------------------
|
1999-01-30 00:39:25 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> nsWebShellWindow::GetNamedDOMDoc(const nsString & aWebShellName)
|
1999-01-27 04:02:33 +00:00
|
|
|
{
|
1999-01-30 00:39:25 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc; // result == nsnull;
|
1999-01-26 15:58:58 +00:00
|
|
|
|
2000-03-11 01:25:54 +00:00
|
|
|
// first get the toolbar child docShell
|
|
|
|
nsCOMPtr<nsIDocShell> childDocShell;
|
2000-04-19 00:19:06 +00:00
|
|
|
if (aWebShellName.EqualsWithConversion("this")) { // XXX small kludge for code reused
|
2000-03-11 01:25:54 +00:00
|
|
|
childDocShell = mDocShell;
|
1999-02-18 16:32:44 +00:00
|
|
|
} else {
|
2000-03-11 01:25:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem;
|
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(mDocShell));
|
|
|
|
docShellAsNode->FindChildWithName(aWebShellName.GetUnicode(),
|
|
|
|
PR_TRUE, PR_FALSE, nsnull, getter_AddRefs(docShellAsItem));
|
|
|
|
childDocShell = do_QueryInterface(docShellAsItem);
|
|
|
|
if (!childDocShell)
|
1999-02-18 16:32:44 +00:00
|
|
|
return domDoc;
|
|
|
|
}
|
1999-01-30 00:39:25 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
2000-03-11 01:25:54 +00:00
|
|
|
childDocShell->GetContentViewer(getter_AddRefs(cv));
|
1999-01-30 00:39:25 +00:00
|
|
|
if (!cv)
|
|
|
|
return domDoc;
|
|
|
|
|
1999-02-17 02:08:00 +00:00
|
|
|
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
1999-01-30 00:39:25 +00:00
|
|
|
if (!docv)
|
|
|
|
return domDoc;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
docv->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (doc)
|
1999-02-17 02:08:00 +00:00
|
|
|
return nsCOMPtr<nsIDOMDocument>(do_QueryInterface(doc));
|
1999-01-30 00:39:25 +00:00
|
|
|
|
1999-01-27 04:02:33 +00:00
|
|
|
return domDoc;
|
1999-01-30 00:39:25 +00:00
|
|
|
} // nsWebShellWindow::GetNamedDOMDoc
|
1999-01-27 04:02:33 +00:00
|
|
|
|
|
|
|
//----------------------------------------
|
1999-01-26 18:01:38 +00:00
|
|
|
|
2000-01-13 23:51:01 +00:00
|
|
|
/* copy the window's size and position to the window tag */
|
2000-03-09 02:00:20 +00:00
|
|
|
void nsWebShellWindow::StoreBoundsToXUL(PRBool aPosition, PRBool aSize, PRBool aSizeMode)
|
2000-01-13 23:51:01 +00:00
|
|
|
{
|
2000-03-09 02:00:20 +00:00
|
|
|
PersistPositionAndSize(aPosition, aSize, aSizeMode);
|
2000-01-13 23:51:01 +00:00
|
|
|
} // StoreBoundsToXUL
|
1999-02-21 21:04:21 +00:00
|
|
|
|
1999-05-27 20:36:15 +00:00
|
|
|
// if the main document URL specified URLs for any content areas, start them loading
|
|
|
|
void nsWebShellWindow::LoadContentAreas() {
|
|
|
|
|
|
|
|
nsAutoString searchSpec;
|
|
|
|
|
|
|
|
// fetch the chrome document URL
|
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
2000-10-25 23:17:44 +00:00
|
|
|
// yes, it's possible for the docshell to be null even this early
|
|
|
|
// see bug 57514.
|
|
|
|
if (mDocShell)
|
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
|
1999-05-27 20:36:15 +00:00
|
|
|
if (contentViewer) {
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer = do_QueryInterface(contentViewer);
|
|
|
|
if (docViewer) {
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
docViewer->GetDocument(*getter_AddRefs(doc));
|
1999-06-23 03:29:44 +00:00
|
|
|
nsCOMPtr<nsIURI> mainURL = getter_AddRefs(doc->GetDocumentURL());
|
1999-05-27 20:36:15 +00:00
|
|
|
if (mainURL) {
|
1999-06-28 10:35:57 +00:00
|
|
|
char *search = nsnull;
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(mainURL);
|
|
|
|
if (url)
|
|
|
|
url->GetQuery(&search);
|
2000-04-19 00:19:06 +00:00
|
|
|
searchSpec.AssignWithConversion(search);
|
1999-06-28 10:35:57 +00:00
|
|
|
nsCRT::free(search);
|
1999-05-27 20:36:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// content URLs are specified in the search part of the URL
|
|
|
|
// as <contentareaID>=<escapedURL>[;(repeat)]
|
|
|
|
if (searchSpec.Length() > 0) {
|
|
|
|
PRInt32 begPos,
|
|
|
|
eqPos,
|
|
|
|
endPos;
|
|
|
|
nsString contentAreaID,
|
|
|
|
contentURL;
|
|
|
|
char *urlChar;
|
|
|
|
nsIWebShell *contentShell;
|
|
|
|
nsresult rv;
|
2000-05-16 05:35:23 +00:00
|
|
|
for (endPos = 0; endPos < (PRInt32)searchSpec.Length(); ) {
|
1999-05-27 20:36:15 +00:00
|
|
|
// extract contentAreaID and URL substrings
|
|
|
|
begPos = endPos;
|
1999-07-26 00:51:00 +00:00
|
|
|
eqPos = searchSpec.FindChar('=', PR_FALSE,begPos);
|
1999-05-27 20:36:15 +00:00
|
|
|
if (eqPos < 0)
|
|
|
|
break;
|
|
|
|
|
1999-07-26 00:51:00 +00:00
|
|
|
endPos = searchSpec.FindChar(';', PR_FALSE,eqPos);
|
1999-05-27 20:36:15 +00:00
|
|
|
if (endPos < 0)
|
|
|
|
endPos = searchSpec.Length();
|
|
|
|
searchSpec.Mid(contentAreaID, begPos, eqPos-begPos);
|
|
|
|
searchSpec.Mid(contentURL, eqPos+1, endPos-eqPos-1);
|
|
|
|
endPos++;
|
|
|
|
|
|
|
|
// see if we have a webshell with a matching contentAreaID
|
|
|
|
rv = GetContentShellById(contentAreaID, &contentShell);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
urlChar = contentURL.ToNewCString();
|
|
|
|
if (urlChar) {
|
|
|
|
nsUnescape(urlChar);
|
2000-04-19 00:19:06 +00:00
|
|
|
contentURL.AssignWithConversion(urlChar);
|
2000-03-16 02:20:26 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(contentShell));
|
2000-09-20 12:23:53 +00:00
|
|
|
webNav->LoadURI(contentURL.GetUnicode(), nsIWebNavigation::LOAD_FLAGS_NONE);
|
1999-05-27 20:36:15 +00:00
|
|
|
delete [] urlChar;
|
|
|
|
}
|
|
|
|
NS_RELEASE(contentShell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-01 22:38:06 +00:00
|
|
|
/**
|
|
|
|
* ExecuteCloseHandler - Run the close handler, if any.
|
|
|
|
* @return PR_TRUE iff we found a close handler to run.
|
|
|
|
*/
|
|
|
|
PRBool nsWebShellWindow::ExecuteCloseHandler()
|
|
|
|
{
|
|
|
|
/* If the event handler closes this window -- a likely scenario --
|
|
|
|
things get deleted out of order without this death grip.
|
|
|
|
(The problem may be the death grip in nsWindow::windowProc,
|
|
|
|
which forces this window's widget to remain alive longer
|
|
|
|
than it otherwise would.) */
|
|
|
|
nsCOMPtr<nsIWebShellWindow> kungFuDeathGrip(this);
|
|
|
|
|
|
|
|
nsresult rv;
|
1999-12-03 09:24:22 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObjectOwner> globalObjectOwner(do_QueryInterface(mWebShell));
|
1999-12-01 22:38:06 +00:00
|
|
|
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
|
|
|
|
1999-12-03 09:24:22 +00:00
|
|
|
if (globalObjectOwner) {
|
|
|
|
if (NS_SUCCEEDED(globalObjectOwner->GetScriptGlobalObject(getter_AddRefs(globalObject))) && globalObject) {
|
1999-12-01 22:38:06 +00:00
|
|
|
nsCOMPtr<nsIContentViewer> contentViewer;
|
2000-03-11 01:25:54 +00:00
|
|
|
if (NS_SUCCEEDED(mDocShell->GetContentViewer(getter_AddRefs(contentViewer)))) {
|
1999-12-01 22:38:06 +00:00
|
|
|
nsCOMPtr<nsIDocumentViewer> docViewer;
|
|
|
|
nsCOMPtr<nsIPresContext> presContext;
|
|
|
|
docViewer = do_QueryInterface(contentViewer);
|
2000-02-04 22:37:11 +00:00
|
|
|
if (docViewer && NS_SUCCEEDED(docViewer->GetPresContext(*getter_AddRefs(presContext)))) {
|
1999-12-01 22:38:06 +00:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
|
|
nsMouseEvent event;
|
|
|
|
event.eventStructType = NS_EVENT;
|
|
|
|
event.message = NS_XUL_CLOSE;
|
|
|
|
rv = globalObject->HandleDOMEvent(presContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
|
|
|
if (NS_FAILED(rv) || status == nsEventStatus_eConsumeNoDefault)
|
|
|
|
return PR_TRUE;
|
|
|
|
// else fall through and return PR_FALSE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
} // ExecuteCloseHandler
|
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
//----------------------------------------------------------------
|
|
|
|
//-- nsIDocumentObserver
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::BeginUpdate(nsIDocument *aDocument)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::EndUpdate(nsIDocument *aDocument)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::BeginLoad(nsIDocument *aDocument)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::EndLoad(nsIDocument *aDocument)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::BeginReflow(nsIDocument *aDocument, nsIPresShell* aShell)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::EndReflow(nsIDocument *aDocument, nsIPresShell* aShell)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
// nsIDocumentObserver
|
|
|
|
// this is needed for menu changes
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ContentChanged(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsISupports* aSubContent)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-27 08:34:06 +00:00
|
|
|
NS_IMETHODIMP
|
1999-04-20 00:06:58 +00:00
|
|
|
nsWebShellWindow::ContentStatesChanged(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContent1,
|
|
|
|
nsIContent* aContent2)
|
1999-02-27 08:34:06 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-21 21:04:21 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::AttributeChanged(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContent,
|
1999-10-15 23:17:53 +00:00
|
|
|
PRInt32 aNameSpaceID,
|
1999-02-21 21:04:21 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
2000-05-26 00:14:01 +00:00
|
|
|
#if 0
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("AttributeChanged\n");
|
1999-02-21 21:04:21 +00:00
|
|
|
PRInt32 i;
|
|
|
|
for (i=0;i<mMenuDelegates.Count();i++) {
|
|
|
|
nsIXULCommand * cmd = (nsIXULCommand *)mMenuDelegates[i];
|
|
|
|
nsIDOMElement * node;
|
|
|
|
cmd->GetDOMElement(&node);
|
|
|
|
//nsCOMPtr<nsIContent> content(do_QueryInterface(node));
|
|
|
|
// Doing this for the must speed
|
|
|
|
nsIContent * content;
|
2000-01-31 23:45:42 +00:00
|
|
|
if (NS_OK == node->QueryInterface(NS_GET_IID(nsIContent), (void**) &content)) {
|
1999-02-21 21:04:21 +00:00
|
|
|
if (content == aContent) {
|
|
|
|
nsAutoString attr;
|
|
|
|
aAttribute->ToString(attr);
|
|
|
|
cmd->AttributeHasBeenSet(attr);
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
}
|
2000-05-26 00:14:01 +00:00
|
|
|
#endif
|
1999-02-21 21:04:21 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ContentAppended(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
PRInt32 aNewIndexInContainer)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ContentInserted(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aIndexInContainer)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ContentReplaced(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aOldChild,
|
|
|
|
nsIContent* aNewChild,
|
|
|
|
PRInt32 aIndexInContainer)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::ContentRemoved(nsIDocument *aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aIndexInContainer)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::StyleSheetAdded(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::StyleSheetRemoved(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
PRBool aDisabled)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::StyleRuleChanged(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule,
|
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::StyleRuleAdded(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::StyleRuleRemoved(nsIDocument *aDocument,
|
|
|
|
nsIStyleSheet* aStyleSheet,
|
|
|
|
nsIStyleRule* aStyleRule)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsWebShellWindow::DocumentWillBeDestroyed(nsIDocument *aDocument)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-04-16 18:40:27 +00:00
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
// This should rightfully be somebody's CONTRACTID?
|
1999-06-08 20:59:41 +00:00
|
|
|
// Will switch when the "app shell browser component" arrives.
|
2000-09-13 23:57:52 +00:00
|
|
|
static const char *prefix = "@mozilla.org/appshell/component/browser/window;1";
|
1999-06-08 20:59:41 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsWebShellWindow::NotifyObservers( const nsString &aTopic, const nsString &someData ) {
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
// Get observer service.
|
|
|
|
nsIObserverService *svc = 0;
|
2000-09-13 23:57:52 +00:00
|
|
|
rv = nsServiceManager::GetService( NS_OBSERVERSERVICE_CONTRACTID,
|
2000-01-11 20:49:15 +00:00
|
|
|
NS_GET_IID(nsIObserverService),
|
1999-06-08 20:59:41 +00:00
|
|
|
(nsISupports**)&svc );
|
|
|
|
if ( NS_SUCCEEDED( rv ) && svc ) {
|
|
|
|
// Notify observers as instructed; the subject is "this" web shell window.
|
2000-04-19 00:19:06 +00:00
|
|
|
nsAutoString topic; topic.AssignWithConversion(prefix);
|
|
|
|
topic.AppendWithConversion(";");
|
1999-06-08 20:59:41 +00:00
|
|
|
topic += aTopic;
|
|
|
|
rv = svc->Notify( (nsIWebShellWindow*)this, topic.GetUnicode(), someData.GetUnicode() );
|
|
|
|
// Release the service.
|
2000-09-13 23:57:52 +00:00
|
|
|
nsServiceManager::ReleaseService( NS_OBSERVERSERVICE_CONTRACTID, svc );
|
1999-06-08 20:59:41 +00:00
|
|
|
} else {
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
2000-04-11 23:52:50 +00:00
|
|
|
|
|
|
|
// nsIBaseWindow
|
|
|
|
NS_IMETHODIMP nsWebShellWindow::Destroy()
|
|
|
|
{
|
2000-12-14 23:27:59 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIWebProgress> webProgress(do_GetInterface(mDocShell, &rv));
|
|
|
|
if (webProgress) {
|
|
|
|
webProgress->RemoveProgressListener(this);
|
|
|
|
}
|
|
|
|
|
2000-04-11 23:52:50 +00:00
|
|
|
#ifdef USE_NATIVE_MENUS
|
2000-05-11 01:08:37 +00:00
|
|
|
{
|
2000-04-11 23:52:50 +00:00
|
|
|
// unregister as document listener
|
|
|
|
// this is needed for menus
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
if(mDocShell)
|
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
nsCOMPtr<nsIDocumentViewer> docv(do_QueryInterface(cv));
|
|
|
|
if(docv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
docv->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if(doc)
|
|
|
|
doc->RemoveObserver(NS_STATIC_CAST(nsIDocumentObserver*, this));
|
|
|
|
}
|
2000-05-11 01:08:37 +00:00
|
|
|
}
|
2000-04-11 23:52:50 +00:00
|
|
|
#endif
|
2000-12-14 23:27:59 +00:00
|
|
|
|
|
|
|
|
2000-04-11 23:52:50 +00:00
|
|
|
return nsXULWindow::Destroy();
|
|
|
|
}
|
2000-05-16 05:35:23 +00:00
|
|
|
|