1998-07-20 16:19:22 +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-07-20 16:19:22 +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-07-20 16:19:22 +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>
|
2001-08-14 05:21:54 +00:00
|
|
|
* Brian Ryner <bryner@netscape.com>
|
2000-05-02 23:16:41 +00:00
|
|
|
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
|
|
|
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
|
|
|
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
|
1998-07-20 16:19:22 +00:00
|
|
|
*/
|
1999-09-26 05:52:24 +00:00
|
|
|
|
1999-02-16 07:38:27 +00:00
|
|
|
#include "nsIPref.h"
|
1998-11-03 08:07:24 +00:00
|
|
|
#include "prmem.h"
|
1998-09-23 23:02:54 +00:00
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
#include "nsBrowserWindow.h"
|
1998-07-20 16:19:22 +00:00
|
|
|
#include "nsIAppShell.h"
|
|
|
|
#include "nsIWidget.h"
|
|
|
|
#include "nsITextWidget.h"
|
|
|
|
#include "nsIButton.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIURL.h"
|
2001-04-10 06:01:08 +00:00
|
|
|
#include "nsIChannel.h"
|
2002-10-06 02:20:35 +00:00
|
|
|
#include "nsNetUtil.h"
|
2001-08-14 05:21:54 +00:00
|
|
|
#include "nsIDOMWindowInternal.h"
|
|
|
|
#include "nsIFilePicker.h"
|
1998-09-01 21:08:32 +00:00
|
|
|
#include "nsILookAndFeel.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-07-20 16:19:22 +00:00
|
|
|
#include "nsIFactory.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
1998-07-20 21:16:38 +00:00
|
|
|
#include "nsViewerApp.h"
|
1998-07-21 16:45:21 +00:00
|
|
|
#include "prprf.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-07-30 22:42:27 +00:00
|
|
|
#include "nsParserCIID.h"
|
1998-12-03 10:12:30 +00:00
|
|
|
#include "nsIEnumerator.h"
|
1999-01-05 22:59:02 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1999-02-09 20:01:44 +00:00
|
|
|
#include "nsIServiceManager.h"
|
1999-02-09 19:29:03 +00:00
|
|
|
#include "nsIStringBundle.h"
|
1999-05-06 19:32:42 +00:00
|
|
|
#include "nsLayoutCID.h"
|
1998-07-31 16:53:45 +00:00
|
|
|
#include "nsIDocumentViewer.h"
|
|
|
|
#include "nsIContentViewer.h"
|
1999-11-19 07:35:27 +00:00
|
|
|
#include "nsIContentViewerFile.h"
|
1998-07-31 16:53:45 +00:00
|
|
|
#include "nsIPresShell.h"
|
1999-05-06 19:32:42 +00:00
|
|
|
#include "nsIPresContext.h"
|
1998-07-31 16:53:45 +00:00
|
|
|
#include "nsIDocument.h"
|
1999-05-06 19:32:42 +00:00
|
|
|
#include "nsILayoutDebugger.h"
|
1999-09-25 20:10:29 +00:00
|
|
|
#include "nsThrobber.h"
|
1999-12-17 08:13:54 +00:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeNode.h"
|
2000-03-11 11:59:55 +00:00
|
|
|
#include "nsIWebNavigation.h"
|
2001-07-10 00:26:37 +00:00
|
|
|
#include "nsIWebBrowserFocus.h"
|
1999-12-17 08:13:54 +00:00
|
|
|
#include "nsIBaseWindow.h"
|
|
|
|
#include "nsXPIDLString.h"
|
2001-09-29 08:28:41 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2001-01-27 16:58:15 +00:00
|
|
|
#include "nsIViewManager.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsGUIEvent.h"
|
2001-05-04 20:15:38 +00:00
|
|
|
#include "nsIWebProgress.h"
|
2001-05-19 18:31:20 +00:00
|
|
|
#include "nsIWebBrowserSetup.h"
|
2002-04-24 11:00:39 +00:00
|
|
|
#include "nsIWebBrowserPrint.h"
|
1999-05-06 19:32:42 +00:00
|
|
|
|
2000-03-11 01:31:28 +00:00
|
|
|
#include "nsCWebBrowser.h"
|
2002-02-19 22:49:12 +00:00
|
|
|
#include "nsUnicharUtils.h"
|
2000-03-11 01:31:28 +00:00
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
#include "nsIParser.h"
|
1998-08-07 04:45:03 +00:00
|
|
|
#include "nsEditorMode.h"
|
1998-07-31 16:53:45 +00:00
|
|
|
|
1998-08-28 16:14:37 +00:00
|
|
|
// Needed for "Find" GUI
|
|
|
|
#include "nsICheckButton.h"
|
|
|
|
#include "nsILabel.h"
|
1998-09-14 20:46:42 +00:00
|
|
|
#include "nsWidgetSupport.h"
|
|
|
|
|
1998-12-17 15:52:48 +00:00
|
|
|
#include "nsXPBaseWindow.h"
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
#include "resources.h"
|
1998-07-27 21:10:02 +00:00
|
|
|
|
1999-02-25 07:25:36 +00:00
|
|
|
#if defined(WIN32)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-05 20:48:43 +00:00
|
|
|
#include <ctype.h> // tolower
|
|
|
|
|
1999-01-21 21:51:21 +00:00
|
|
|
// For Copy
|
2000-09-14 11:45:01 +00:00
|
|
|
#include "nsISelection.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsISelectionController.h"
|
1999-04-07 04:10:04 +00:00
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
// XXX For font setting below
|
|
|
|
#include "nsFont.h"
|
|
|
|
#include "nsUnitConversion.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
|
1999-03-10 21:42:45 +00:00
|
|
|
#if defined(CookieManagement) || defined(SingleSignon) || defined(ClientWallet)
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#endif
|
|
|
|
|
1999-04-17 05:29:05 +00:00
|
|
|
#ifdef CookieManagement
|
1999-06-18 17:34:08 +00:00
|
|
|
|
1999-06-23 03:29:44 +00:00
|
|
|
#include "nsIURL.h"
|
1999-06-18 17:34:08 +00:00
|
|
|
|
1999-03-10 21:42:45 +00:00
|
|
|
#endif
|
1999-09-29 05:39:18 +00:00
|
|
|
#include "nsIIOService.h"
|
2001-04-10 06:01:08 +00:00
|
|
|
#include "nsNetCID.h"
|
1999-09-29 05:39:18 +00:00
|
|
|
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
1999-03-10 21:42:45 +00:00
|
|
|
|
1999-04-17 05:29:05 +00:00
|
|
|
#if defined(ClientWallet) || defined(SingleSignon)
|
1999-03-10 21:42:45 +00:00
|
|
|
#include "nsIWalletService.h"
|
|
|
|
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
|
1999-08-06 07:44:37 +00:00
|
|
|
static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
1999-03-10 21:42:45 +00:00
|
|
|
#endif
|
|
|
|
|
1999-09-26 05:52:24 +00:00
|
|
|
#ifdef PURIFY
|
|
|
|
#include "pure.h"
|
|
|
|
#endif
|
1999-03-10 21:42:45 +00:00
|
|
|
|
1999-01-26 19:09:22 +00:00
|
|
|
#define THROBBING_N
|
|
|
|
|
2000-03-22 15:26:50 +00:00
|
|
|
#define CLEANUP_WIDGET(_widget, _txt) \
|
2000-04-12 09:25:46 +00:00
|
|
|
if(_widget) { \
|
2000-03-22 15:26:50 +00:00
|
|
|
DestroyWidget((_widget)); \
|
|
|
|
refCnt = (_widget)->Release(); \
|
|
|
|
(_widget) = nsnull; \
|
2000-04-12 09:25:46 +00:00
|
|
|
NS_ASSERTION(refCnt == 0, (_txt)); \
|
|
|
|
}
|
2000-03-22 15:26:50 +00:00
|
|
|
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
// XXX greasy constants
|
1998-11-23 03:30:24 +00:00
|
|
|
#ifdef THROBBING_N
|
1998-07-20 16:19:22 +00:00
|
|
|
#define THROBBER_WIDTH 32
|
|
|
|
#define THROBBER_HEIGHT 32
|
1998-11-23 03:30:24 +00:00
|
|
|
#define THROBBER_AT "resource:/res/throbber/anims%02d.gif"
|
1999-04-07 03:55:22 +00:00
|
|
|
#define THROB_NUM 29
|
1998-11-23 03:30:24 +00:00
|
|
|
#else
|
|
|
|
#define THROBBER_WIDTH 42
|
|
|
|
#define THROBBER_HEIGHT 42
|
|
|
|
#define THROBBER_AT "resource:/res/throbber/LargeAnimation%02d.gif"
|
|
|
|
#define THROB_NUM 38
|
|
|
|
#endif
|
1998-07-20 16:19:22 +00:00
|
|
|
#define BUTTON_WIDTH 90
|
|
|
|
#define BUTTON_HEIGHT THROBBER_HEIGHT
|
1998-09-01 22:49:16 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
#ifdef INSET_WEBSHELL
|
|
|
|
#define WEBSHELL_LEFT_INSET 5
|
|
|
|
#define WEBSHELL_RIGHT_INSET 5
|
|
|
|
#define WEBSHELL_TOP_INSET 5
|
|
|
|
#define WEBSHELL_BOTTOM_INSET 5
|
|
|
|
#else
|
|
|
|
#define WEBSHELL_LEFT_INSET 0
|
|
|
|
#define WEBSHELL_RIGHT_INSET 0
|
|
|
|
#define WEBSHELL_TOP_INSET 0
|
|
|
|
#define WEBSHELL_BOTTOM_INSET 0
|
|
|
|
#endif
|
|
|
|
|
1999-08-06 07:44:37 +00:00
|
|
|
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
|
|
|
static NS_DEFINE_CID(kButtonCID, NS_BUTTON_CID);
|
|
|
|
static NS_DEFINE_CID(kTextFieldCID, NS_TEXTFIELD_CID);
|
|
|
|
static NS_DEFINE_CID(kWebShellCID, NS_WEB_SHELL_CID);
|
|
|
|
static NS_DEFINE_CID(kWindowCID, NS_WINDOW_CID);
|
|
|
|
static NS_DEFINE_CID(kDialogCID, NS_DIALOG_CID);
|
|
|
|
static NS_DEFINE_CID(kCheckButtonCID, NS_CHECKBUTTON_CID);
|
|
|
|
static NS_DEFINE_CID(kLabelCID, NS_LABEL_CID);
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1999-08-06 07:44:37 +00:00
|
|
|
static NS_DEFINE_IID(kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID);
|
1998-09-01 21:08:32 +00:00
|
|
|
static NS_DEFINE_IID(kILookAndFeelIID, NS_ILOOKANDFEEL_IID);
|
1998-07-20 16:19:22 +00:00
|
|
|
static NS_DEFINE_IID(kIButtonIID, NS_IBUTTON_IID);
|
|
|
|
static NS_DEFINE_IID(kIDOMDocumentIID, NS_IDOMDOCUMENT_IID);
|
|
|
|
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
static NS_DEFINE_IID(kITextWidgetIID, NS_ITEXTWIDGET_IID);
|
|
|
|
static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID);
|
|
|
|
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
|
1998-08-28 16:14:37 +00:00
|
|
|
static NS_DEFINE_IID(kICheckButtonIID, NS_ICHECKBUTTON_IID);
|
|
|
|
static NS_DEFINE_IID(kILabelIID, NS_ILABEL_IID);
|
1998-11-11 22:22:18 +00:00
|
|
|
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
|
1999-08-06 07:44:37 +00:00
|
|
|
static NS_DEFINE_CID(kXPBaseWindowCID, NS_XPBASE_WINDOW_CID);
|
1999-02-09 19:29:03 +00:00
|
|
|
static NS_DEFINE_IID(kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID);
|
|
|
|
|
|
|
|
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1999-05-06 19:32:42 +00:00
|
|
|
static NS_DEFINE_IID(kILayoutDebuggerIID, NS_ILAYOUT_DEBUGGER_IID);
|
|
|
|
static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
|
|
|
|
|
1999-03-09 23:51:29 +00:00
|
|
|
#define FILE_PROTOCOL "file://"
|
1998-08-21 18:28:48 +00:00
|
|
|
|
2000-02-04 15:58:35 +00:00
|
|
|
#ifdef USE_LOCAL_WIDGETS
|
|
|
|
extern nsresult NS_NewButton(nsIButton** aControl);
|
|
|
|
extern nsresult NS_NewLabel(nsILabel** aControl);
|
|
|
|
extern nsresult NS_NewTextWidget(nsITextWidget** aControl);
|
|
|
|
extern nsresult NS_NewCheckButton(nsICheckButton** aControl);
|
|
|
|
#endif
|
|
|
|
|
1998-09-14 20:46:42 +00:00
|
|
|
// prototypes
|
1999-02-12 17:45:58 +00:00
|
|
|
#if 0
|
1998-08-31 19:09:55 +00:00
|
|
|
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
|
1999-02-12 17:45:58 +00:00
|
|
|
#endif
|
1998-09-14 20:46:42 +00:00
|
|
|
static void* GetItemsNativeData(nsISupports* aObject);
|
1998-08-31 19:09:55 +00:00
|
|
|
|
2000-03-14 11:08:43 +00:00
|
|
|
//******* Cleanup Above here***********/
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsBrowserWindow::nsIBaseWindow
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::InitWindow(nativeWindow aParentNativeWindow,
|
|
|
|
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
|
|
|
{
|
|
|
|
// Ignore wigdet parents for now. Don't think those are a vaild thing to call.
|
|
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, cx, cy, PR_FALSE), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::Create()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(PR_FALSE, "You can't call this");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::Destroy()
|
|
|
|
{
|
2000-03-21 21:56:59 +00:00
|
|
|
RemoveBrowser(this);
|
|
|
|
|
2001-05-02 23:58:42 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
|
|
|
|
docShellWin->Destroy();
|
|
|
|
mDocShell = nsnull;
|
2000-03-14 11:08:43 +00:00
|
|
|
|
2000-03-22 15:26:50 +00:00
|
|
|
nsrefcnt refCnt;
|
2000-03-14 11:08:43 +00:00
|
|
|
|
2000-03-22 15:26:50 +00:00
|
|
|
CLEANUP_WIDGET(mBack, "nsBrowserWindow::Destroy - mBack is being leaked.");
|
|
|
|
CLEANUP_WIDGET(mForward, "nsBrowserWindow::Destroy - mForward is being leaked.");
|
|
|
|
CLEANUP_WIDGET(mLocation, "nsBrowserWindow::Destroy - mLocation is being leaked.");
|
|
|
|
CLEANUP_WIDGET(mStatus, "nsBrowserWindow::Destroy - mStatus is being leaked.");
|
2000-03-21 21:56:59 +00:00
|
|
|
|
|
|
|
if (mThrobber) {
|
|
|
|
mThrobber->Destroy();
|
2000-03-22 15:26:50 +00:00
|
|
|
refCnt = mThrobber->Release();
|
|
|
|
mThrobber = nsnull;
|
|
|
|
NS_ASSERTION(refCnt == 0, "nsBrowserWindow::Destroy - mThrobber is being leaked.");
|
2000-03-21 21:56:59 +00:00
|
|
|
mThrobber = nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Others are holding refs to this,
|
|
|
|
// but it gets released OK.
|
|
|
|
DestroyWidget(mWindow);
|
2000-08-31 02:26:44 +00:00
|
|
|
mWindow = nsnull;
|
|
|
|
// NS_RELEASE(mWindow);
|
2000-03-21 21:56:59 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-03-14 11:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetPosition(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
PRInt32 cx=0;
|
|
|
|
PRInt32 cy=0;
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(GetSize(&cx, &cy), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(aX, aY, cx, cy, PR_FALSE),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetPosition(PRInt32* aX, PRInt32* aY)
|
|
|
|
{
|
|
|
|
return GetPositionAndSize(aX, aY, nsnull, nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetSize(PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
|
|
|
|
{
|
|
|
|
PRInt32 x=0;
|
|
|
|
PRInt32 y=0;
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(GetPosition(&x, &y), NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_SUCCESS(SetPositionAndSize(x, y, aCX, aCY, aRepaint),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetSize(PRInt32* aCX, PRInt32* aCY)
|
|
|
|
{
|
|
|
|
return GetPositionAndSize(nsnull, nsnull, aCX, aCY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetPositionAndSize(PRInt32 aX, PRInt32 aY,
|
|
|
|
PRInt32 aCX, PRInt32 aCY, PRBool aRepaint)
|
|
|
|
{
|
|
|
|
NS_ENSURE_SUCCESS(mWindow->Resize(aX, aY, aCX, aCY, aRepaint),
|
|
|
|
NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetPositionAndSize(PRInt32* aX, PRInt32* aY,
|
|
|
|
PRInt32* aCX, PRInt32* aCY)
|
|
|
|
{
|
|
|
|
nsRect bounds;
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(mWindow->GetBounds(bounds), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
if(aX)
|
|
|
|
*aX = bounds.x;
|
|
|
|
if(aY)
|
|
|
|
*aY = bounds.y;
|
|
|
|
if(aCX)
|
|
|
|
*aCX = bounds.width;
|
|
|
|
if(aCY)
|
|
|
|
*aCY = bounds.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::Repaint(PRBool aForce)
|
|
|
|
{
|
|
|
|
//XXX First Check In
|
|
|
|
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetParentWidget(nsIWidget** aParentWidget)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParentWidget);
|
|
|
|
//XXX First Check In
|
|
|
|
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetParentWidget(nsIWidget* aParentWidget)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(PR_FALSE, "You can't call this");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetParentNativeWindow(nativeWindow* aParentNativeWindow)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aParentNativeWindow);
|
|
|
|
|
|
|
|
//XXX First Check In
|
|
|
|
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetParentNativeWindow(nativeWindow aParentNativeWindow)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(PR_FALSE, "You can't call this");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetVisibility(PRBool* aVisibility)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aVisibility);
|
|
|
|
|
|
|
|
//XXX First Check In
|
|
|
|
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetVisibility(PRBool aVisibility)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mWindow);
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(mWindow->Show(aVisibility), NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-02-28 23:22:55 +00:00
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetEnabled(PRBool *aEnabled)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aEnabled);
|
|
|
|
*aEnabled = PR_TRUE;
|
|
|
|
if (mWindow)
|
|
|
|
mWindow->IsEnabled(aEnabled);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetEnabled(PRBool aEnabled)
|
|
|
|
{
|
|
|
|
if (mWindow)
|
|
|
|
mWindow->Enable(aEnabled);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-14 11:08:43 +00:00
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetMainWidget(nsIWidget** aMainWidget)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aMainWidget);
|
|
|
|
|
|
|
|
//XXX First Check In
|
|
|
|
NS_ASSERTION(PR_FALSE, "Not Yet Implemented");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetFocus()
|
|
|
|
{
|
|
|
|
//XXX First Check In
|
2002-03-15 15:26:56 +00:00
|
|
|
NS_WARNING("Not Yet Implemented");
|
2000-03-14 11:08:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::GetTitle(PRUnichar** aTitle)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aTitle);
|
|
|
|
|
2001-09-29 08:28:41 +00:00
|
|
|
*aTitle = ToNewUnicode(mTitle);
|
2000-03-14 11:08:43 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::SetTitle(const PRUnichar* aTitle)
|
|
|
|
{
|
|
|
|
NS_ENSURE_STATE(mWindow);
|
|
|
|
|
|
|
|
mTitle = aTitle;
|
|
|
|
|
2000-08-20 00:45:05 +00:00
|
|
|
NS_ENSURE_SUCCESS(mWindow->SetTitle(nsAutoString(aTitle)), NS_ERROR_FAILURE);
|
2000-03-14 11:08:43 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
// nsBrowserWindow: Helper Function
|
|
|
|
//*****************************************************************************
|
|
|
|
|
|
|
|
void nsBrowserWindow::DestroyWidget(nsISupports* aWidget)
|
|
|
|
{
|
2000-03-21 21:56:59 +00:00
|
|
|
if(aWidget) {
|
|
|
|
nsCOMPtr<nsIWidget> w(do_QueryInterface(aWidget));
|
|
|
|
if (w) {
|
|
|
|
w->Destroy();
|
|
|
|
}
|
|
|
|
}
|
2000-03-14 11:08:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//******* Cleanup below here *************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-03-03 14:35:06 +00:00
|
|
|
static
|
1998-11-11 22:22:18 +00:00
|
|
|
nsIPresShell*
|
1999-12-17 08:13:54 +00:00
|
|
|
GetPresShellFor(nsIDocShell* aDocShell)
|
1998-11-11 22:22:18 +00:00
|
|
|
{
|
|
|
|
nsIPresShell* shell = nsnull;
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
1998-11-11 22:22:18 +00:00
|
|
|
nsIContentViewer* cv = nsnull;
|
1999-12-17 08:13:54 +00:00
|
|
|
aDocShell->GetContentViewer(&cv);
|
1998-11-11 22:22:18 +00:00
|
|
|
if (nsnull != cv) {
|
|
|
|
nsIDocumentViewer* docv = nsnull;
|
|
|
|
cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);
|
|
|
|
if (nsnull != docv) {
|
|
|
|
nsIPresContext* cx;
|
|
|
|
docv->GetPresContext(cx);
|
1999-10-05 23:59:59 +00:00
|
|
|
if (nsnull != cx) {
|
|
|
|
cx->GetShell(&shell);
|
|
|
|
NS_RELEASE(cx);
|
|
|
|
}
|
1998-11-11 22:22:18 +00:00
|
|
|
NS_RELEASE(docv);
|
|
|
|
}
|
|
|
|
NS_RELEASE(cv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return shell;
|
|
|
|
}
|
|
|
|
|
2001-02-24 17:15:50 +00:00
|
|
|
nsVoidArray* nsBrowserWindow::gBrowsers = nsnull;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow*
|
|
|
|
nsBrowserWindow::FindBrowserFor(nsIWidget* aWidget, PRIntn aWhich)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1998-08-06 02:21:23 +00:00
|
|
|
nsIWidget* widget;
|
|
|
|
nsBrowserWindow* result = nsnull;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
2001-02-24 17:15:50 +00:00
|
|
|
if (!gBrowsers)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
PRInt32 i, n = gBrowsers->Count();
|
1998-07-20 16:19:22 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
2001-02-24 17:15:50 +00:00
|
|
|
nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers->ElementAt(i);
|
1998-07-20 16:19:22 +00:00
|
|
|
if (nsnull != bw) {
|
|
|
|
switch (aWhich) {
|
|
|
|
case FIND_WINDOW:
|
1999-06-11 02:20:54 +00:00
|
|
|
if (bw->mWindow) {
|
|
|
|
bw->mWindow->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
1998-12-08 01:57:40 +00:00
|
|
|
}
|
|
|
|
break;
|
1998-07-20 16:19:22 +00:00
|
|
|
case FIND_BACK:
|
1998-12-08 01:57:40 +00:00
|
|
|
if (bw->mBack) {
|
|
|
|
bw->mBack->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
|
|
|
}
|
|
|
|
break;
|
1998-07-20 16:19:22 +00:00
|
|
|
case FIND_FORWARD:
|
1998-12-08 01:57:40 +00:00
|
|
|
if (bw->mForward) {
|
|
|
|
bw->mForward->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
|
|
|
}
|
|
|
|
break;
|
1998-07-20 16:19:22 +00:00
|
|
|
case FIND_LOCATION:
|
1998-12-08 01:57:40 +00:00
|
|
|
if (bw->mLocation) {
|
|
|
|
bw->mLocation->QueryInterface(kIWidgetIID, (void**) &widget);
|
|
|
|
if (widget == aWidget) {
|
|
|
|
result = bw;
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(widget);
|
|
|
|
}
|
|
|
|
break;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
if (nsnull != result) {
|
|
|
|
NS_ADDREF(result);
|
|
|
|
}
|
1998-08-06 02:21:23 +00:00
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::AddBrowser(nsBrowserWindow* aBrowser)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
2001-02-24 17:15:50 +00:00
|
|
|
if (!gBrowsers) {
|
|
|
|
gBrowsers = new nsVoidArray();
|
|
|
|
if (!gBrowsers)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gBrowsers->AppendElement(aBrowser);
|
1998-09-15 00:16:12 +00:00
|
|
|
NS_ADDREF(aBrowser);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::RemoveBrowser(nsBrowserWindow* aBrowser)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1999-02-10 00:06:19 +00:00
|
|
|
//nsViewerApp* app = aBrowser->mApp;
|
2001-02-24 17:15:50 +00:00
|
|
|
if (!gBrowsers)
|
|
|
|
return;
|
|
|
|
gBrowsers->RemoveElement(aBrowser);
|
|
|
|
if (!gBrowsers->Count()) {
|
|
|
|
delete gBrowsers;
|
|
|
|
gBrowsers = nsnull;
|
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
NS_RELEASE(aBrowser);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::CloseAllWindows()
|
|
|
|
{
|
2001-02-27 03:46:54 +00:00
|
|
|
while (gBrowsers && gBrowsers->Count()) {
|
2001-02-24 17:15:50 +00:00
|
|
|
nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers->ElementAt(0);
|
1998-09-15 00:16:12 +00:00
|
|
|
NS_ADDREF(bw);
|
2000-03-14 11:08:43 +00:00
|
|
|
bw->Destroy();
|
1998-09-15 00:16:12 +00:00
|
|
|
NS_RELEASE(bw);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
2001-02-27 03:46:54 +00:00
|
|
|
if (gBrowsers) {
|
|
|
|
delete gBrowsers;
|
|
|
|
gBrowsers = nsnull;
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleBrowserEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-09-15 00:16:12 +00:00
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_WINDOW);
|
1998-09-15 00:16:12 +00:00
|
|
|
if (nsnull != bw) {
|
|
|
|
nsSizeEvent* sizeEvent;
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_SIZE:
|
|
|
|
sizeEvent = (nsSizeEvent*)aEvent;
|
|
|
|
bw->Layout(sizeEvent->windowSize->width,
|
1999-09-26 05:52:24 +00:00
|
|
|
sizeEvent->windowSize->height);
|
1998-09-15 00:16:12 +00:00
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
1999-12-09 00:47:46 +00:00
|
|
|
case NS_XUL_CLOSE:
|
1998-09-15 00:16:12 +00:00
|
|
|
case NS_DESTROY:
|
1999-09-26 05:52:24 +00:00
|
|
|
{
|
|
|
|
nsViewerApp* app = bw->mApp;
|
|
|
|
app->CloseWindow(bw);
|
|
|
|
result = nsEventStatus_eConsumeDoDefault;
|
1998-10-26 18:07:14 +00:00
|
|
|
|
1998-10-29 14:06:26 +00:00
|
|
|
#ifndef XP_MAC
|
1999-09-26 05:52:24 +00:00
|
|
|
// XXX Really shouldn't just exit, we should just notify somebody...
|
2001-02-24 17:15:50 +00:00
|
|
|
if (!nsBrowserWindow::gBrowsers || !nsBrowserWindow::gBrowsers->Count()) {
|
1999-09-26 05:52:24 +00:00
|
|
|
app->Exit();
|
1998-09-15 00:16:12 +00:00
|
|
|
}
|
1999-09-26 05:52:24 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1998-09-15 00:16:12 +00:00
|
|
|
case NS_MENU_SELECTED:
|
1998-10-07 20:17:14 +00:00
|
|
|
result = bw->DispatchMenuItem(((nsMenuEvent*)aEvent)->mCommand);
|
1998-09-15 00:16:12 +00:00
|
|
|
break;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
2001-07-10 00:26:37 +00:00
|
|
|
case NS_ACTIVATE:
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebBrowserFocus> focus = do_GetInterface(bw->mWebBrowser);
|
|
|
|
if (focus)
|
|
|
|
focus->Activate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_DEACTIVATE:
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIWebBrowserFocus> focus = do_GetInterface(bw->mWebBrowser);
|
|
|
|
if (focus)
|
|
|
|
focus->Deactivate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-09-15 00:16:12 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1998-08-10 18:20:20 +00:00
|
|
|
NS_RELEASE(bw);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleBackEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-09-15 00:16:12 +00:00
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_BACK);
|
1998-09-15 00:16:12 +00:00
|
|
|
if (nsnull != bw) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
bw->Back();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
NS_RELEASE(bw);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleForwardEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-09-15 00:16:12 +00:00
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_FORWARD);
|
1998-09-15 00:16:12 +00:00
|
|
|
if (nsnull != bw) {
|
|
|
|
switch(aEvent->message) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
|
|
|
bw->Forward();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
NS_RELEASE(bw);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsEventStatus PR_CALLBACK
|
|
|
|
HandleLocationEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
1998-09-15 00:16:12 +00:00
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
1998-07-20 21:16:38 +00:00
|
|
|
nsBrowserWindow* bw =
|
|
|
|
nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_LOCATION);
|
1998-09-15 00:16:12 +00:00
|
|
|
if (nsnull != bw) {
|
|
|
|
switch (aEvent->message) {
|
|
|
|
case NS_KEY_UP:
|
|
|
|
if (NS_VK_RETURN == ((nsKeyEvent*)aEvent)->keyCode) {
|
1999-03-09 23:51:29 +00:00
|
|
|
nsAutoString text;
|
|
|
|
PRUint32 size;
|
|
|
|
bw->mLocation->GetText(text, 1000, size);
|
2001-06-30 11:02:25 +00:00
|
|
|
bw->GoTo(text.get());
|
1998-09-15 00:16:12 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-03-09 23:51:29 +00:00
|
|
|
|
|
|
|
case NS_DRAGDROP_EVENT: {
|
1999-04-06 21:10:08 +00:00
|
|
|
/*printf("Drag & Drop Event\n");
|
1999-03-09 23:51:29 +00:00
|
|
|
nsDragDropEvent * ev = (nsDragDropEvent *)aEvent;
|
|
|
|
nsAutoString fileURL;
|
|
|
|
BuildFileURL(ev->mURL, fileURL);
|
1999-04-06 21:10:08 +00:00
|
|
|
nsAutoString fileName(ev->mURL);
|
2001-09-29 08:28:41 +00:00
|
|
|
char * str = ToNewCString(fileName);
|
1999-03-09 23:51:29 +00:00
|
|
|
|
|
|
|
PRInt32 len = strlen(str);
|
|
|
|
PRInt32 sum = len + sizeof(FILE_PROTOCOL);
|
|
|
|
char* lpszFileURL = new char[sum];
|
|
|
|
|
|
|
|
// Translate '\' to '/'
|
|
|
|
for (PRInt32 i = 0; i < len; i++) {
|
|
|
|
if (str[i] == '\\') {
|
1999-10-05 23:59:59 +00:00
|
|
|
str[i] = '/';
|
1999-03-09 23:51:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build the file URL
|
|
|
|
PR_snprintf(lpszFileURL, sum, "%s%s", FILE_PROTOCOL, str);
|
|
|
|
|
|
|
|
// Ask the Web widget to load the file URL
|
1999-04-06 21:10:08 +00:00
|
|
|
nsString urlStr(lpszFileURL);
|
2001-06-30 11:02:25 +00:00
|
|
|
const PRUnichar * uniStr = fileURL.get();
|
1999-03-09 23:51:29 +00:00
|
|
|
bw->GoTo(uniStr);
|
|
|
|
//delete [] lpszFileURL;
|
1999-04-06 21:10:08 +00:00
|
|
|
//delete [] str;*/
|
1999-03-09 23:51:29 +00:00
|
|
|
} break;
|
|
|
|
|
1998-09-15 00:16:12 +00:00
|
|
|
default:
|
|
|
|
break;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
NS_RELEASE(bw);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 00:16:12 +00:00
|
|
|
return result;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1999-09-26 05:52:24 +00:00
|
|
|
#ifdef PURIFY
|
|
|
|
static void
|
|
|
|
DispatchPurifyEvent(PRInt32 aID)
|
|
|
|
{
|
|
|
|
if (!PurifyIsRunning()) {
|
|
|
|
printf("!!! Re-run viewer under Purify to use this menu item.\n");
|
1999-10-29 03:28:22 +00:00
|
|
|
fflush(stdout);
|
1999-09-26 05:52:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aID) {
|
|
|
|
case VIEWER_PURIFY_SHOW_NEW_LEAKS:
|
|
|
|
PurifyPrintf("viewer: new leaks");
|
|
|
|
PurifyNewLeaks();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_SHOW_ALL_LEAKS:
|
|
|
|
PurifyPrintf("viewer: all leaks");
|
|
|
|
PurifyAllLeaks();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_CLEAR_ALL_LEAKS:
|
|
|
|
PurifyPrintf("viewer: clear leaks");
|
|
|
|
PurifyClearLeaks();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_SHOW_ALL_HANDLES_IN_USE:
|
|
|
|
PurifyPrintf("viewer: all handles");
|
|
|
|
PurifyAllHandlesInuse();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_SHOW_NEW_IN_USE:
|
|
|
|
PurifyPrintf("viewer: new in-use");
|
|
|
|
PurifyNewInuse();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_SHOW_ALL_IN_USE:
|
|
|
|
PurifyPrintf("viewer: all in-use");
|
|
|
|
PurifyAllInuse();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_CLEAR_ALL_IN_USE:
|
|
|
|
PurifyPrintf("viewer: clear in-use");
|
|
|
|
PurifyClearInuse();
|
|
|
|
break;
|
|
|
|
case VIEWER_PURIFY_HEAP_VALIDATE:
|
|
|
|
PurifyPrintf("viewer: heap validate");
|
|
|
|
PurifyHeapValidate(PURIFY_HEAP_ALL, PURIFY_HEAP_BLOCKS_ALL, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsEventStatus
|
1998-07-20 22:13:11 +00:00
|
|
|
nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1999-03-10 21:42:45 +00:00
|
|
|
#if defined(CookieManagement) || defined(SingleSignon) || defined(ClientWallet)
|
|
|
|
nsresult res;
|
1999-04-17 05:29:05 +00:00
|
|
|
#if defined(ClientWallet) || defined(SingleSignon)
|
|
|
|
nsIWalletService *walletservice;
|
|
|
|
#endif
|
1999-03-10 21:42:45 +00:00
|
|
|
#ifdef ClientWallet
|
|
|
|
#define WALLET_EDITOR_URL "file:///y|/walleted.html"
|
2000-04-18 10:22:00 +00:00
|
|
|
nsAutoString urlString; urlString.AssignWithConversion(WALLET_EDITOR_URL);
|
1999-03-10 21:42:45 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
1999-01-23 07:10:37 +00:00
|
|
|
nsEventStatus result;
|
1998-07-20 22:45:35 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-01-23 07:10:37 +00:00
|
|
|
result = DispatchDebugMenu(aID);
|
1998-07-20 22:13:11 +00:00
|
|
|
if (nsEventStatus_eIgnore != result) {
|
|
|
|
return result;
|
|
|
|
}
|
1998-07-20 22:45:35 +00:00
|
|
|
#endif
|
1999-01-23 07:10:37 +00:00
|
|
|
result = DispatchStyleMenu(aID);
|
|
|
|
if (nsEventStatus_eIgnore != result) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-07-20 22:13:11 +00:00
|
|
|
switch (aID) {
|
|
|
|
case VIEWER_EXIT:
|
|
|
|
mApp->Exit();
|
|
|
|
return nsEventStatus_eConsumeNoDefault;
|
|
|
|
|
1998-09-04 00:47:15 +00:00
|
|
|
case VIEWER_WINDOW_OPEN:
|
|
|
|
mApp->OpenWindow();
|
|
|
|
break;
|
|
|
|
|
1998-07-21 16:45:21 +00:00
|
|
|
case VIEWER_FILE_OPEN:
|
|
|
|
DoFileOpen();
|
|
|
|
break;
|
1998-11-11 20:31:45 +00:00
|
|
|
|
|
|
|
case VIEW_SOURCE:
|
|
|
|
{
|
2002-01-08 13:01:38 +00:00
|
|
|
// PRInt32 theIndex;
|
|
|
|
// nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
|
|
|
// webShell->GetHistoryIndex(theIndex);
|
|
|
|
// nsXPIDLString theURL;
|
|
|
|
// webShell->GetURL(theIndex, getter_Copies(theURL));
|
|
|
|
// nsAutoString theString(theURL);
|
|
|
|
// mApp->ViewSource(theString);
|
1998-11-11 20:31:45 +00:00
|
|
|
//XXX Find out how the string is allocated, and perhaps delete it...
|
|
|
|
}
|
|
|
|
break;
|
1998-07-27 18:17:07 +00:00
|
|
|
|
|
|
|
case VIEWER_EDIT_COPY:
|
|
|
|
DoCopy();
|
|
|
|
break;
|
1998-07-21 16:45:21 +00:00
|
|
|
|
1999-03-08 22:45:56 +00:00
|
|
|
case VIEWER_EDIT_PASTE:
|
|
|
|
DoPaste();
|
|
|
|
break;
|
|
|
|
|
1998-08-28 16:14:37 +00:00
|
|
|
case VIEWER_EDIT_FINDINPAGE:
|
|
|
|
DoFind();
|
|
|
|
break;
|
|
|
|
|
1998-07-20 22:13:11 +00:00
|
|
|
case VIEWER_DEMO0:
|
|
|
|
case VIEWER_DEMO1:
|
|
|
|
case VIEWER_DEMO2:
|
|
|
|
case VIEWER_DEMO3:
|
|
|
|
case VIEWER_DEMO4:
|
|
|
|
case VIEWER_DEMO5:
|
|
|
|
case VIEWER_DEMO6:
|
|
|
|
case VIEWER_DEMO7:
|
|
|
|
case VIEWER_DEMO8:
|
|
|
|
case VIEWER_DEMO9:
|
1998-10-26 18:07:14 +00:00
|
|
|
case VIEWER_DEMO10:
|
1999-02-03 17:16:11 +00:00
|
|
|
case VIEWER_DEMO11:
|
|
|
|
case VIEWER_DEMO12:
|
1999-04-13 00:10:00 +00:00
|
|
|
case VIEWER_DEMO13:
|
|
|
|
case VIEWER_DEMO14:
|
|
|
|
case VIEWER_DEMO15:
|
1999-05-27 21:17:10 +00:00
|
|
|
case VIEWER_DEMO16:
|
|
|
|
case VIEWER_DEMO17:
|
1998-07-20 22:13:11 +00:00
|
|
|
{
|
|
|
|
PRIntn ix = aID - VIEWER_DEMO0;
|
2000-04-18 10:22:00 +00:00
|
|
|
nsAutoString url; url.AssignWithConversion(SAMPLES_BASE_URL);
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING("/test"));
|
2000-04-18 10:22:00 +00:00
|
|
|
url.AppendInt(ix, 10);
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING(".html"));
|
2000-03-29 10:27:08 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
2001-11-30 22:35:33 +00:00
|
|
|
webNav->LoadURI(url.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
1998-07-20 22:13:11 +00:00
|
|
|
break;
|
1999-03-05 20:21:14 +00:00
|
|
|
|
|
|
|
case VIEWER_XPTOOLKITTOOLBAR1:
|
|
|
|
{
|
2000-04-18 10:22:00 +00:00
|
|
|
nsAutoString url; url.AssignWithConversion(SAMPLES_BASE_URL);
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING("/toolbarTest1.xul"));
|
2000-03-29 10:27:08 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
2001-11-30 22:35:33 +00:00
|
|
|
webNav->LoadURI(url.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
|
1999-03-09 22:03:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIEWER_XPTOOLKITTREE1:
|
|
|
|
{
|
2000-04-18 10:22:00 +00:00
|
|
|
nsAutoString url; url.AssignWithConversion(SAMPLES_BASE_URL);
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING("/treeTest1.xul"));
|
2000-03-29 10:27:08 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
2001-11-30 22:35:33 +00:00
|
|
|
webNav->LoadURI(url.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
|
1999-03-09 22:03:18 +00:00
|
|
|
break;
|
1999-03-05 20:21:14 +00:00
|
|
|
}
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
case JS_CONSOLE:
|
|
|
|
DoJSConsole();
|
|
|
|
break;
|
|
|
|
|
1998-09-22 00:57:54 +00:00
|
|
|
case VIEWER_PREFS:
|
|
|
|
DoPrefs();
|
|
|
|
break;
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
case EDITOR_MODE:
|
1999-12-17 08:13:54 +00:00
|
|
|
DoEditorMode(mDocShell);
|
1998-08-07 04:45:03 +00:00
|
|
|
break;
|
1998-10-15 23:23:04 +00:00
|
|
|
|
|
|
|
case VIEWER_ONE_COLUMN:
|
|
|
|
case VIEWER_TWO_COLUMN:
|
|
|
|
case VIEWER_THREE_COLUMN:
|
|
|
|
ShowPrintPreview(aID);
|
|
|
|
break;
|
1998-11-14 01:58:34 +00:00
|
|
|
|
|
|
|
case VIEWER_PRINT:
|
|
|
|
DoPrint();
|
|
|
|
break;
|
1998-12-17 15:52:48 +00:00
|
|
|
|
1999-01-06 21:59:17 +00:00
|
|
|
case VIEWER_TABLE_INSPECTOR:
|
|
|
|
DoTableInspector();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_IMAGE_INSPECTOR:
|
|
|
|
DoImageInspector();
|
|
|
|
break;
|
|
|
|
|
2000-03-14 14:19:56 +00:00
|
|
|
case VIEWER_GFX_SCROLLBARS_ON: {
|
|
|
|
SetBoolPref("nglayout.widget.gfxscrollbars", PR_TRUE);
|
|
|
|
nsAutoString text;
|
|
|
|
PRUint32 size;
|
|
|
|
mLocation->GetText(text, 1000, size);
|
2001-06-30 11:02:25 +00:00
|
|
|
GoTo(text.get());
|
2000-03-14 14:19:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_GFX_SCROLLBARS_OFF: {
|
|
|
|
SetBoolPref("nglayout.widget.gfxscrollbars", PR_FALSE);
|
|
|
|
nsAutoString text;
|
|
|
|
PRUint32 size;
|
|
|
|
mLocation->GetText(text, 1000, size);
|
2001-06-30 11:02:25 +00:00
|
|
|
GoTo(text.get());
|
2000-03-14 14:19:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_GOTO_TEST_URL1:
|
|
|
|
case VIEWER_GOTO_TEST_URL2: {
|
|
|
|
nsAutoString urlStr;
|
2000-03-15 01:19:43 +00:00
|
|
|
const char * pref = (aID == VIEWER_GOTO_TEST_URL1) ? "nglayout.widget.testurl1" : "nglayout.widget.testurl2";
|
2000-03-14 14:19:56 +00:00
|
|
|
GetStringPref(pref, urlStr);
|
|
|
|
PRUint32 size;
|
|
|
|
mLocation->SetText(urlStr, size);
|
2001-06-30 11:02:25 +00:00
|
|
|
GoTo(urlStr.get());
|
2000-03-14 15:51:27 +00:00
|
|
|
|
2000-03-14 14:19:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SAVE_TEST_URL1:
|
|
|
|
case VIEWER_SAVE_TEST_URL2: {
|
|
|
|
nsAutoString text;
|
|
|
|
PRUint32 size;
|
|
|
|
mLocation->GetText(text, 1000, size);
|
2000-03-15 01:19:43 +00:00
|
|
|
const char * pref = (aID == VIEWER_SAVE_TEST_URL1) ? "nglayout.widget.testurl1" : "nglayout.widget.testurl2";
|
2000-03-14 14:19:56 +00:00
|
|
|
SetStringPref(pref, text);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-09-26 05:52:24 +00:00
|
|
|
#ifdef PURIFY
|
|
|
|
case VIEWER_PURIFY_SHOW_NEW_LEAKS:
|
|
|
|
case VIEWER_PURIFY_SHOW_ALL_LEAKS:
|
|
|
|
case VIEWER_PURIFY_CLEAR_ALL_LEAKS:
|
|
|
|
case VIEWER_PURIFY_SHOW_ALL_HANDLES_IN_USE:
|
|
|
|
case VIEWER_PURIFY_SHOW_NEW_IN_USE:
|
|
|
|
case VIEWER_PURIFY_SHOW_ALL_IN_USE:
|
|
|
|
case VIEWER_PURIFY_CLEAR_ALL_IN_USE:
|
|
|
|
case VIEWER_PURIFY_HEAP_VALIDATE:
|
|
|
|
DispatchPurifyEvent(aID);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
1999-04-16 04:25:17 +00:00
|
|
|
case VIEWER_ZOOM_500:
|
|
|
|
case VIEWER_ZOOM_300:
|
|
|
|
case VIEWER_ZOOM_200:
|
|
|
|
case VIEWER_ZOOM_100:
|
|
|
|
case VIEWER_ZOOM_070:
|
|
|
|
case VIEWER_ZOOM_050:
|
|
|
|
case VIEWER_ZOOM_030:
|
|
|
|
case VIEWER_ZOOM_020:
|
1999-12-17 08:13:54 +00:00
|
|
|
mDocShell->SetZoom((aID - VIEWER_ZOOM_BASE) / 10.0f);
|
1999-04-16 04:25:17 +00:00
|
|
|
break;
|
|
|
|
|
1999-03-10 21:42:45 +00:00
|
|
|
#ifdef ClientWallet
|
|
|
|
case PRVCY_PREFILL:
|
|
|
|
case PRVCY_QPREFILL:
|
|
|
|
nsIPresShell* shell;
|
|
|
|
shell = nsnull;
|
|
|
|
shell = GetPresShell();
|
|
|
|
res = nsServiceManager::GetService(kWalletServiceCID,
|
|
|
|
kIWalletServiceIID,
|
|
|
|
(nsISupports **)&walletservice);
|
|
|
|
if ((NS_OK == res) && (nsnull != walletservice)) {
|
2000-04-18 10:22:00 +00:00
|
|
|
nsString urlString2;
|
2000-07-12 02:29:53 +00:00
|
|
|
// res = walletservice->WALLET_Prefill(shell, (PRVCY_QPREFILL == aID));
|
1999-03-10 21:42:45 +00:00
|
|
|
NS_RELEASE(walletservice);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef HTMLDialogs
|
|
|
|
if (aID == PRVCY_PREFILL) {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString url(NS_LITERAL_STRING("file:///y|/htmldlgs.htm"));
|
2000-03-14 11:08:43 +00:00
|
|
|
nsBrowserWindow* bw = nsnull;
|
1999-03-10 21:42:45 +00:00
|
|
|
mApp->OpenWindow(PRUint32(~0), bw);
|
2000-03-14 11:08:43 +00:00
|
|
|
bw->SetVisibility(PR_TRUE);
|
2001-06-30 11:02:25 +00:00
|
|
|
bw->GoTo(url.get());
|
1999-03-10 21:42:45 +00:00
|
|
|
NS_RELEASE(bw);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PRVCY_DISPLAY_WALLET:
|
1999-12-17 08:13:54 +00:00
|
|
|
{
|
1999-03-10 21:42:45 +00:00
|
|
|
|
1999-06-08 21:06:22 +00:00
|
|
|
|
1999-03-10 21:42:45 +00:00
|
|
|
/* set a cookie for the javascript wallet editor */
|
|
|
|
res = nsServiceManager::GetService(kWalletServiceCID,
|
|
|
|
kIWalletServiceIID,
|
|
|
|
(nsISupports **)&walletservice);
|
|
|
|
if ((NS_OK == res) && (nsnull != walletservice)) {
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI * url;
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsIIOService> service(do_GetService(kIOServiceCID, &res));
|
1999-06-18 17:34:08 +00:00
|
|
|
if (NS_FAILED(res)) return nsEventStatus_eIgnore;
|
|
|
|
|
|
|
|
nsIURI *uri = nsnull;
|
2002-03-06 07:48:55 +00:00
|
|
|
res = service->NewURI(NS_LITERAL_CSTRING(WALLET_EDITOR_URL), nsnull, nsnull, &uri);
|
1999-06-18 17:34:08 +00:00
|
|
|
if (NS_FAILED(res)) return nsEventStatus_eIgnore;
|
|
|
|
|
2000-01-11 20:49:15 +00:00
|
|
|
res = uri->QueryInterface(NS_GET_IID(nsIURI), (void**)&url);
|
1999-06-18 17:34:08 +00:00
|
|
|
NS_RELEASE(uri);
|
2001-11-19 06:45:00 +00:00
|
|
|
if (NS_SUCCEEDED(res)) {
|
1999-06-08 21:06:22 +00:00
|
|
|
// res = walletservice->WALLET_PreEdit(url);
|
1999-03-10 21:42:45 +00:00
|
|
|
NS_RELEASE(walletservice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* invoke the javascript wallet editor */
|
2000-03-29 10:27:08 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
2001-11-30 22:35:33 +00:00
|
|
|
webNav->LoadURI(urlString.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
|
1999-12-17 08:13:54 +00:00
|
|
|
}
|
1999-03-10 21:42:45 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CookieManagement)
|
|
|
|
case PRVCY_DISPLAY_COOKIES:
|
1999-06-18 17:34:08 +00:00
|
|
|
{
|
|
|
|
break;
|
1999-03-10 21:42:45 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SingleSignon)
|
|
|
|
case PRVCY_DISPLAY_SIGNONS:
|
1999-04-17 05:29:05 +00:00
|
|
|
res = nsServiceManager::GetService(kWalletServiceCID,
|
|
|
|
kIWalletServiceIID,
|
|
|
|
(nsISupports **)&walletservice);
|
|
|
|
if ((NS_OK == res) && (nsnull != walletservice)) {
|
1999-08-07 14:14:31 +00:00
|
|
|
// res = walletservice->SI_DisplaySignonInfoAsHTML();
|
1999-04-17 05:29:05 +00:00
|
|
|
NS_RELEASE(walletservice);
|
1999-03-10 21:42:45 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
1998-08-07 04:45:03 +00:00
|
|
|
|
1999-03-02 05:31:41 +00:00
|
|
|
// Any menu IDs that the editor uses will be processed here
|
1999-12-17 08:13:54 +00:00
|
|
|
DoEditorTest(mDocShell, aID);
|
1999-03-02 05:31:41 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
return nsEventStatus_eIgnore;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Back()
|
|
|
|
{
|
2000-03-11 11:59:55 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
|
|
|
webNav->GoBack();
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Forward()
|
|
|
|
{
|
2000-03-11 11:59:55 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
|
|
|
webNav->GoForward();
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-03-29 10:27:08 +00:00
|
|
|
nsBrowserWindow::GoTo(const PRUnichar* aURL)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
2000-03-29 10:27:08 +00:00
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
2001-11-30 22:35:33 +00:00
|
|
|
webNav->LoadURI(aURL, nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-21 16:45:21 +00:00
|
|
|
|
2001-08-14 05:21:54 +00:00
|
|
|
static PRBool GetFileFromFileSelector(nsIDOMWindowInternal* aParentWindow,
|
|
|
|
nsILocalFile **aFile,
|
|
|
|
nsILocalFile **aDisplayDirectory)
|
1998-07-21 16:45:21 +00:00
|
|
|
{
|
2001-08-14 05:21:54 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1");
|
|
|
|
|
|
|
|
if (filePicker) {
|
|
|
|
rv = filePicker->Init(aParentWindow, NS_LITERAL_STRING("Open HTML").get(),
|
|
|
|
nsIFilePicker::modeOpen);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
filePicker->AppendFilters(nsIFilePicker::filterAll | nsIFilePicker::filterHTML |
|
|
|
|
nsIFilePicker::filterXML | nsIFilePicker::filterImages);
|
|
|
|
if (*aDisplayDirectory)
|
|
|
|
filePicker->SetDisplayDirectory(*aDisplayDirectory);
|
|
|
|
|
|
|
|
PRInt16 dialogResult;
|
|
|
|
rv = filePicker->Show(&dialogResult);
|
|
|
|
if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
filePicker->GetFile(aFile);
|
|
|
|
if (*aFile) {
|
|
|
|
NS_IF_RELEASE(*aDisplayDirectory);
|
|
|
|
filePicker->GetDisplayDirectory(aDisplayDirectory);
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1998-07-21 16:45:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-14 05:21:54 +00:00
|
|
|
return PR_FALSE;
|
1998-07-21 16:45:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DoFileOpen()
|
|
|
|
{
|
2001-08-14 05:21:54 +00:00
|
|
|
nsCOMPtr<nsILocalFile> file;
|
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow;
|
|
|
|
nsCOMPtr<nsIDOMWindowInternal> parentWindow;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// get nsIDOMWindowInternal interface for nsIFilePicker
|
|
|
|
rv = mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
parentWindow = do_QueryInterface(domWindow);
|
|
|
|
|
|
|
|
if (GetFileFromFileSelector(parentWindow, getter_AddRefs(file),
|
|
|
|
getter_AddRefs(mOpenFileDirectory))) {
|
2002-10-06 02:20:35 +00:00
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
NS_NewFileURI(getter_AddRefs(uri), file);
|
|
|
|
if (uri) {
|
|
|
|
nsCAutoString spec;
|
|
|
|
uri->GetSpec(spec);
|
2001-08-14 05:21:54 +00:00
|
|
|
|
|
|
|
// Ask the Web widget to load the file URL
|
|
|
|
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
2002-10-06 02:20:35 +00:00
|
|
|
webNav->LoadURI(NS_ConvertUTF8toUCS2(spec).get(),
|
2001-11-30 22:35:33 +00:00
|
|
|
nsIWebNavigation::LOAD_FLAGS_NONE,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
nsnull);
|
2001-08-14 05:21:54 +00:00
|
|
|
SetVisibility(PR_TRUE);
|
|
|
|
}
|
1998-07-21 16:45:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-28 16:14:37 +00:00
|
|
|
#define DIALOG_FONT "Helvetica"
|
|
|
|
#define DIALOG_FONT_SIZE 10
|
|
|
|
|
|
|
|
/**--------------------------------------------------------------------------------
|
|
|
|
* Main Handler
|
|
|
|
*--------------------------------------------------------------------------------
|
|
|
|
*/
|
1999-02-12 17:45:58 +00:00
|
|
|
#if 0
|
1998-08-28 16:14:37 +00:00
|
|
|
nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
|
|
|
//printf("HandleEvent aEvent->message %d\n", aEvent->message);
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
if (aEvent == nsnull || aEvent->widget == nsnull) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aEvent->message == 301 || aEvent->message == 302) {
|
1999-02-10 00:06:19 +00:00
|
|
|
//int x = 0;
|
1998-08-28 16:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void * data;
|
|
|
|
aEvent->widget->GetClientData(data);
|
|
|
|
|
|
|
|
if (data == nsnull) {
|
|
|
|
nsIWidget * parent = aEvent->widget->GetParent();
|
|
|
|
if (parent != nsnull) {
|
|
|
|
parent->GetClientData(data);
|
|
|
|
NS_RELEASE(parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data != nsnull) {
|
|
|
|
nsBrowserWindow * browserWindow = (nsBrowserWindow *)data;
|
|
|
|
result = browserWindow->ProcessDialogEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
1999-02-12 17:45:58 +00:00
|
|
|
#endif
|
1998-09-14 20:46:42 +00:00
|
|
|
|
|
|
|
static void* GetItemsNativeData(nsISupports* aObject)
|
|
|
|
{
|
1999-10-05 23:59:59 +00:00
|
|
|
void* result = nsnull;
|
|
|
|
nsIWidget* widget;
|
|
|
|
if (NS_OK == aObject->QueryInterface(kIWidgetIID,(void**)&widget))
|
|
|
|
{
|
|
|
|
result = widget->GetNativeData(NS_NATIVE_WIDGET);
|
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
|
|
|
return result;
|
1998-09-14 20:46:42 +00:00
|
|
|
}
|
|
|
|
|
1998-11-02 19:11:43 +00:00
|
|
|
//---------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)
|
|
|
|
{
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 17:42:36 +00:00
|
|
|
// Insert find code here.
|
|
|
|
|
1998-11-02 19:11:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP nsBrowserWindow::ForceRefresh()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
shell->GetViewManager(getter_AddRefs(vm));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (vm) {
|
1998-11-02 19:11:43 +00:00
|
|
|
nsIView* root;
|
|
|
|
vm->GetRootView(root);
|
|
|
|
if (nsnull != root) {
|
1999-11-14 02:51:25 +00:00
|
|
|
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
|
1998-11-02 19:11:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-08-28 16:14:37 +00:00
|
|
|
/**--------------------------------------------------------------------------------
|
|
|
|
* Main Handler
|
|
|
|
*--------------------------------------------------------------------------------
|
|
|
|
*/
|
1998-09-14 20:46:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-08-28 16:14:37 +00:00
|
|
|
nsEventStatus nsBrowserWindow::ProcessDialogEvent(nsGUIEvent *aEvent)
|
|
|
|
{
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
//printf("aEvent->message %d\n", aEvent->message);
|
|
|
|
switch(aEvent->message) {
|
|
|
|
|
|
|
|
case NS_KEY_DOWN: {
|
|
|
|
} break;
|
1998-08-28 16:14:37 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP: {
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case NS_PAINT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
result = nsEventStatus_eIgnore;
|
|
|
|
}
|
1998-08-28 16:14:37 +00:00
|
|
|
//printf("result: %d = %d\n", result, PR_FALSE);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DoFind()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-08-04 20:04:55 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
#define VIEWER_BUNDLE_URL NS_LITERAL_CSTRING("resource:/res/viewer.properties")
|
1999-02-09 19:29:03 +00:00
|
|
|
|
|
|
|
static nsString* gTitleSuffix = nsnull;
|
|
|
|
|
1999-04-30 00:11:18 +00:00
|
|
|
#if XXX
|
1999-02-09 19:29:03 +00:00
|
|
|
static nsString*
|
|
|
|
GetTitleSuffix(void)
|
|
|
|
{
|
|
|
|
nsString* suffix = new nsString(" - Failed");
|
|
|
|
nsIStringBundleService* service = nsnull;
|
|
|
|
nsresult ret = nsServiceManager::GetService(kStringBundleServiceCID,
|
|
|
|
kIStringBundleServiceIID, (nsISupports**) &service);
|
|
|
|
if (NS_FAILED(ret)) {
|
|
|
|
return suffix;
|
|
|
|
}
|
1999-06-23 03:29:44 +00:00
|
|
|
nsIURI* url = nsnull;
|
2001-07-25 07:54:28 +00:00
|
|
|
nsCOMPtr<nsIIOService> service(do_GetService(kIOServiceCID, &ret));
|
1999-06-18 17:34:08 +00:00
|
|
|
if (NS_FAILED(ret)) return ret;
|
|
|
|
|
|
|
|
nsIURI *uri = nsnull;
|
2002-03-06 07:48:55 +00:00
|
|
|
ret = service->NewURI(VIEWER_BUNDLE_URL, nsnull, nsnull, &uri);
|
1999-06-18 17:34:08 +00:00
|
|
|
if (NS_FAILED(ret)) return ret;
|
|
|
|
|
2000-01-11 20:49:15 +00:00
|
|
|
ret = uri->QueryInterface(NS_GET_IID(nsIURI), (void**)&url);
|
1999-06-18 17:34:08 +00:00
|
|
|
NS_RELEASE(uri);
|
1999-02-09 19:29:03 +00:00
|
|
|
if (NS_FAILED(ret)) {
|
|
|
|
NS_RELEASE(service);
|
|
|
|
return suffix;
|
|
|
|
}
|
|
|
|
nsIStringBundle* bundle = nsnull;
|
2001-04-27 21:30:24 +00:00
|
|
|
ret = service->CreateBundle(url, &bundle);
|
1999-02-14 04:58:10 +00:00
|
|
|
NS_RELEASE(url);
|
1999-02-09 19:29:03 +00:00
|
|
|
if (NS_FAILED(ret)) {
|
|
|
|
NS_RELEASE(service);
|
|
|
|
return suffix;
|
|
|
|
}
|
|
|
|
ret = bundle->GetStringFromID(1, *suffix);
|
|
|
|
NS_RELEASE(bundle);
|
|
|
|
NS_RELEASE(service);
|
|
|
|
|
|
|
|
return suffix;
|
|
|
|
}
|
1999-04-30 00:11:18 +00:00
|
|
|
#endif
|
1999-02-09 19:29:03 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
// Note: operator new zeros our memory
|
|
|
|
nsBrowserWindow::nsBrowserWindow()
|
|
|
|
{
|
1999-02-09 19:29:03 +00:00
|
|
|
if (!gTitleSuffix) {
|
1999-04-30 00:11:18 +00:00
|
|
|
#if XXX
|
|
|
|
gTitleSuffix = GetTitleSuffix();
|
|
|
|
#endif
|
2000-04-27 21:24:29 +00:00
|
|
|
if ( (gTitleSuffix = new nsString) != 0 )
|
2001-12-16 11:58:03 +00:00
|
|
|
gTitleSuffix->Assign(NS_LITERAL_STRING(" - Raptor"));
|
1999-02-09 19:29:03 +00:00
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
AddBrowser(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBrowserWindow::~nsBrowserWindow()
|
|
|
|
{
|
1998-10-15 23:23:04 +00:00
|
|
|
NS_IF_RELEASE(mAppShell);
|
1999-01-06 21:59:17 +00:00
|
|
|
NS_IF_RELEASE(mTableInspectorDialog);
|
|
|
|
NS_IF_RELEASE(mImageInspectorDialog);
|
1999-09-20 20:53:40 +00:00
|
|
|
NS_IF_RELEASE(mWebCrawler);
|
1999-01-06 21:59:17 +00:00
|
|
|
|
|
|
|
if (nsnull != mTableInspector) {
|
|
|
|
delete mTableInspector;
|
|
|
|
}
|
|
|
|
if (nsnull != mImageInspector) {
|
|
|
|
delete mImageInspector;
|
|
|
|
}
|
2001-02-14 05:33:57 +00:00
|
|
|
if (mWebBrowserChrome) {
|
|
|
|
mWebBrowserChrome->BrowserWindow(nsnull);
|
|
|
|
NS_RELEASE(mWebBrowserChrome);
|
|
|
|
}
|
|
|
|
if (nsnull != gTitleSuffix) {
|
|
|
|
delete gTitleSuffix;
|
|
|
|
gTitleSuffix = nsnull;
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
2001-11-06 01:19:39 +00:00
|
|
|
NS_IMPL_ISUPPORTS4(nsBrowserWindow, nsIBaseWindow, nsIInterfaceRequestor, nsIProgressEventSink, nsIWebShellContainer);
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
nsresult
|
2001-11-06 01:19:39 +00:00
|
|
|
nsBrowserWindow::GetInterface(const nsIID& aIID,
|
|
|
|
void** aInstancePtrResult)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
2001-11-06 01:19:39 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
NS_PRECONDITION(aInstancePtrResult, "null pointer");
|
|
|
|
if (!aInstancePtrResult)
|
1998-07-20 16:19:22 +00:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
1998-07-22 00:26:23 +00:00
|
|
|
|
|
|
|
*aInstancePtrResult = NULL;
|
|
|
|
|
2001-11-06 01:19:39 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) {
|
|
|
|
rv = EnsureWebBrowserChrome();
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
return mWebBrowserChrome->QueryInterface(aIID, aInstancePtrResult);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
2001-11-06 01:19:39 +00:00
|
|
|
|
|
|
|
return QueryInterface(aIID, aInstancePtrResult);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::Init(nsIAppShell* aAppShell,
|
1999-04-30 00:11:18 +00:00
|
|
|
const nsRect& aBounds,
|
|
|
|
PRUint32 aChromeMask,
|
|
|
|
PRBool aAllowPlugins)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
mChromeMask = aChromeMask;
|
1998-08-19 21:00:51 +00:00
|
|
|
mAppShell = aAppShell;
|
1998-10-15 23:23:04 +00:00
|
|
|
NS_IF_ADDREF(mAppShell);
|
1998-11-18 05:31:03 +00:00
|
|
|
mAllowPlugins = aAllowPlugins;
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
// Create top level window
|
1999-04-30 00:11:18 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kWindowCID, nsnull,
|
|
|
|
kIWidgetIID,
|
2000-08-31 02:26:44 +00:00
|
|
|
getter_AddRefs(mWindow));
|
1998-07-20 16:19:22 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-11-02 19:11:43 +00:00
|
|
|
nsWidgetInitData initData;
|
1999-07-27 04:27:17 +00:00
|
|
|
initData.mWindowType = eWindowType_toplevel;
|
|
|
|
initData.mBorderStyle = eBorderStyle_default;
|
1998-11-02 19:11:43 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsRect r(0, 0, aBounds.width, aBounds.height);
|
|
|
|
mWindow->Create((nsIWidget*)NULL, r, HandleBrowserEvent,
|
1999-10-05 23:59:59 +00:00
|
|
|
nsnull, aAppShell, nsnull, &initData);
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(r);
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
// Create web shell
|
2000-09-13 23:57:52 +00:00
|
|
|
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
2000-03-29 10:27:08 +00:00
|
|
|
NS_ENSURE_TRUE(mWebBrowser, NS_ERROR_FAILURE);
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
r.x = r.y = 0;
|
2000-03-11 01:31:28 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser));
|
|
|
|
rv = webBrowserWin->InitWindow(mWindow->GetNativeData(NS_NATIVE_WIDGET), nsnull, r.x, r.y, r.width, r.height);
|
2000-03-29 10:27:08 +00:00
|
|
|
NS_ENSURE_SUCCESS(EnsureWebBrowserChrome(), NS_ERROR_FAILURE);
|
2000-08-25 18:39:46 +00:00
|
|
|
mWebBrowser->SetContainerWindow(mWebBrowserChrome);
|
2001-02-14 03:12:33 +00:00
|
|
|
nsWeakPtr weakling(
|
|
|
|
dont_AddRef(NS_GetWeakReference((nsIWebProgressListener*)mWebBrowserChrome)));
|
|
|
|
mWebBrowser->AddWebBrowserListener(weakling, NS_GET_IID(nsIWebProgressListener));
|
2000-03-29 10:27:08 +00:00
|
|
|
|
2000-03-11 01:31:28 +00:00
|
|
|
webBrowserWin->Create();
|
2001-05-19 18:31:20 +00:00
|
|
|
|
2001-12-15 02:22:51 +00:00
|
|
|
// Give the embedding app a chance to do platforms-specific window setup
|
|
|
|
InitNativeWindow();
|
|
|
|
|
2001-05-19 18:31:20 +00:00
|
|
|
// Disable global history because we don't have profile-relative file locations
|
|
|
|
nsCOMPtr<nsIWebBrowserSetup> setup(do_QueryInterface(mWebBrowser));
|
|
|
|
if (setup)
|
|
|
|
setup->SetProperty(nsIWebBrowserSetup::SETUP_USE_GLOBAL_HISTORY, PR_FALSE);
|
|
|
|
|
2000-08-31 02:26:44 +00:00
|
|
|
mDocShell = do_GetInterface(mWebBrowser);
|
2000-03-11 01:31:28 +00:00
|
|
|
mDocShell->SetAllowPlugins(aAllowPlugins);
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
|
|
|
webShell->SetContainer((nsIWebShellContainer*) this);
|
2000-03-11 01:31:28 +00:00
|
|
|
webBrowserWin->SetVisibility(PR_TRUE);
|
1998-07-20 16:19:22 +00:00
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
|
1998-07-20 21:16:38 +00:00
|
|
|
rv = CreateMenuBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-08-14 05:21:54 +00:00
|
|
|
mHaveMenuBar = PR_TRUE;
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(r);
|
1998-07-20 21:16:38 +00:00
|
|
|
r.x = r.y = 0;
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_TOOLBAR & aChromeMask) {
|
1998-07-20 21:16:38 +00:00
|
|
|
rv = CreateToolBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_STATUSBAR & aChromeMask) {
|
1998-07-20 21:16:38 +00:00
|
|
|
rv = CreateStatusBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
// Now lay it all out
|
1998-07-20 16:19:22 +00:00
|
|
|
Layout(r.width, r.height);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-15 23:23:04 +00:00
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::Init(nsIAppShell* aAppShell,
|
1998-12-08 01:57:40 +00:00
|
|
|
const nsRect& aBounds,
|
|
|
|
PRUint32 aChromeMask,
|
|
|
|
PRBool aAllowPlugins,
|
|
|
|
nsIDocumentViewer* aDocumentViewer,
|
|
|
|
nsIPresContext* aPresContext)
|
1998-10-15 23:23:04 +00:00
|
|
|
{
|
|
|
|
mChromeMask = aChromeMask;
|
|
|
|
mAppShell = aAppShell;
|
1998-11-18 05:31:03 +00:00
|
|
|
NS_IF_ADDREF(mAppShell);
|
1998-10-15 23:23:04 +00:00
|
|
|
mAllowPlugins = aAllowPlugins;
|
|
|
|
// Create top level window
|
2001-03-20 14:40:59 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kWindowCID,
|
|
|
|
nsnull,
|
|
|
|
|
|
|
|
kIWidgetIID,
|
|
|
|
|
|
|
|
getter_AddRefs(mWindow));
|
1998-10-15 23:23:04 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-03-20 14:40:59 +00:00
|
|
|
nsWidgetInitData initData;
|
|
|
|
initData.mWindowType = eWindowType_toplevel;
|
|
|
|
initData.mBorderStyle = eBorderStyle_default;
|
1998-10-15 23:23:04 +00:00
|
|
|
nsRect r(0, 0, aBounds.width, aBounds.height);
|
|
|
|
mWindow->Create((nsIWidget*)NULL, r, HandleBrowserEvent,
|
2001-03-20 14:40:59 +00:00
|
|
|
|
|
|
|
nsnull, aAppShell, nsnull, &initData);
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(r);
|
1998-10-15 23:23:04 +00:00
|
|
|
// Create web shell
|
2001-03-20 14:40:59 +00:00
|
|
|
mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID);
|
|
|
|
NS_ENSURE_TRUE(mWebBrowser, NS_ERROR_FAILURE);
|
1998-10-15 23:23:04 +00:00
|
|
|
r.x = r.y = 0;
|
2000-03-11 01:31:28 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser));
|
2001-03-20 14:40:59 +00:00
|
|
|
rv = webBrowserWin->InitWindow(mWindow->GetNativeData(NS_NATIVE_WIDGET),
|
|
|
|
nsnull, r.x, r.y, r.width, r.height);
|
|
|
|
NS_ENSURE_SUCCESS(EnsureWebBrowserChrome(), NS_ERROR_FAILURE);
|
|
|
|
mWebBrowser->SetContainerWindow(mWebBrowserChrome);
|
2000-03-11 01:31:28 +00:00
|
|
|
webBrowserWin->Create();
|
2001-03-20 14:40:59 +00:00
|
|
|
mDocShell = do_GetInterface(mWebBrowser);
|
|
|
|
mDocShell->SetAllowPlugins(aAllowPlugins);
|
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
1999-12-17 08:13:54 +00:00
|
|
|
webShell->SetContainer((nsIWebShellContainer*) this);
|
2001-03-20 14:40:59 +00:00
|
|
|
webBrowserWin->SetVisibility(PR_TRUE);
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_MENUBAR & aChromeMask) {
|
1998-10-15 23:23:04 +00:00
|
|
|
rv = CreateMenuBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(r);
|
1998-10-15 23:23:04 +00:00
|
|
|
r.x = r.y = 0;
|
|
|
|
}
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_TOOLBAR & aChromeMask) {
|
1998-10-15 23:23:04 +00:00
|
|
|
rv = CreateToolBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
2001-03-20 14:40:59 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_STATUSBAR & aChromeMask)
|
|
|
|
{
|
1998-10-15 23:23:04 +00:00
|
|
|
rv = CreateStatusBar(r.width);
|
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
1999-01-27 05:20:43 +00:00
|
|
|
// Give the embedding app a chance to do platforms-specific window setup
|
|
|
|
InitNativeWindow();
|
2001-03-20 14:40:59 +00:00
|
|
|
|
1998-10-15 23:23:04 +00:00
|
|
|
// Now lay it all out
|
|
|
|
Layout(r.width, r.height);
|
|
|
|
|
2001-03-20 14:40:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-10-15 23:23:04 +00:00
|
|
|
// Create a document viewer and bind it to the webshell
|
|
|
|
nsIDocumentViewer* docv;
|
|
|
|
aDocumentViewer->CreateDocumentViewerUsing(aPresContext, docv);
|
2001-03-20 14:40:59 +00:00
|
|
|
docv->SetContainer(mWebBrowser);
|
2002-01-08 13:01:38 +00:00
|
|
|
nsCOMPtr<nsIContentViewerContainer> cvContainer = do_QueryInterface(mDocShell);
|
|
|
|
cvContainer->Embed(docv, "duh", nsnull);
|
2001-03-20 14:40:59 +00:00
|
|
|
|
|
|
|
|
2000-03-11 01:31:28 +00:00
|
|
|
webBrowserWin->SetVisibility(PR_TRUE);
|
1998-10-15 23:23:04 +00:00
|
|
|
NS_RELEASE(docv);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-30 00:11:18 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::SetWebCrawler(nsWebCrawler* aCrawler)
|
|
|
|
{
|
|
|
|
if (mWebCrawler) {
|
1999-12-17 08:13:54 +00:00
|
|
|
if (mDocShell) {
|
2001-05-04 20:15:38 +00:00
|
|
|
nsCOMPtr<nsIWebProgress> progress(do_GetInterface(mDocShell));
|
|
|
|
NS_ASSERTION(progress, "no web progress avail");
|
|
|
|
|
|
|
|
(void) progress->RemoveProgressListener(
|
|
|
|
(nsIWebProgressListener*)mWebCrawler);
|
1999-04-30 00:11:18 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(mWebCrawler);
|
|
|
|
}
|
|
|
|
if (aCrawler) {
|
|
|
|
mWebCrawler = aCrawler;
|
|
|
|
NS_ADDREF(aCrawler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
// XXX This sort of thing should be in a resource
|
|
|
|
#define TOOL_BAR_FONT "Helvetica"
|
1998-07-31 06:01:45 +00:00
|
|
|
#define TOOL_BAR_FONT_SIZE 12
|
1998-07-24 16:03:11 +00:00
|
|
|
#define STATUS_BAR_FONT "Helvetica"
|
1998-07-31 06:01:45 +00:00
|
|
|
#define STATUS_BAR_FONT_SIZE 10
|
1998-07-24 16:03:11 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::CreateToolBar(PRInt32 aWidth)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
nsIDeviceContext* dc = mWindow->GetDeviceContext();
|
1998-08-27 05:05:03 +00:00
|
|
|
float t2d;
|
|
|
|
dc->GetTwipsToDevUnits(t2d);
|
1999-03-31 22:51:25 +00:00
|
|
|
float d2a;
|
|
|
|
dc->GetDevUnitsToAppUnits(d2a);
|
1998-07-24 16:03:11 +00:00
|
|
|
nsFont font(TOOL_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0,
|
|
|
|
nscoord(NSIntPointsToTwips(TOOL_BAR_FONT_SIZE) * t2d * d2a));
|
1998-07-24 16:03:11 +00:00
|
|
|
NS_RELEASE(dc);
|
|
|
|
|
2000-02-04 15:58:35 +00:00
|
|
|
#ifdef USE_LOCAL_WIDGETS
|
|
|
|
rv = NS_NewButton(&mBack);
|
|
|
|
#else
|
1998-07-20 16:19:22 +00:00
|
|
|
// Create and place back button
|
1999-03-09 09:44:27 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID,
|
1999-10-05 23:59:59 +00:00
|
|
|
(void**)&mBack);
|
2000-02-04 15:58:35 +00:00
|
|
|
#endif
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
nsRect r(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
1998-09-14 20:46:42 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
nsIWidget* widget = nsnull;
|
1998-09-14 20:46:42 +00:00
|
|
|
NS_CreateButton(mWindow,mBack,r,HandleBackEvent,&font);
|
|
|
|
if (NS_OK == mBack->QueryInterface(kIWidgetIID,(void**)&widget))
|
1999-10-05 23:59:59 +00:00
|
|
|
{
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString back(NS_LITERAL_STRING("Back"));
|
1999-09-02 18:13:07 +00:00
|
|
|
mBack->SetLabel(back);
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
1998-09-14 20:46:42 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
// Create and place forward button
|
2000-02-04 15:58:35 +00:00
|
|
|
r.SetRect(BUTTON_WIDTH, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
|
|
|
|
|
|
|
#ifdef USE_LOCAL_WIDGETS
|
|
|
|
rv = NS_NewButton(&mForward);
|
|
|
|
#else
|
1999-03-09 09:44:27 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kButtonCID, nsnull, kIButtonIID,
|
1999-10-05 23:59:59 +00:00
|
|
|
(void**)&mForward);
|
2000-02-04 15:58:35 +00:00
|
|
|
#endif
|
1998-07-20 16:19:22 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1999-10-05 23:59:59 +00:00
|
|
|
if (NS_OK == mForward->QueryInterface(kIWidgetIID,(void**)&widget))
|
|
|
|
{
|
2000-08-31 13:40:17 +00:00
|
|
|
widget->Create(mWindow.get(), r, HandleForwardEvent, NULL);
|
1998-09-14 20:46:42 +00:00
|
|
|
widget->SetFont(font);
|
|
|
|
widget->Show(PR_TRUE);
|
2001-12-16 11:58:03 +00:00
|
|
|
nsAutoString forward(NS_LITERAL_STRING("Forward"));
|
1999-09-02 18:13:07 +00:00
|
|
|
mForward->SetLabel(forward);
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
1998-09-14 20:46:42 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
// Create and place location bar
|
|
|
|
r.SetRect(2*BUTTON_WIDTH, 0,
|
1999-10-05 23:59:59 +00:00
|
|
|
aWidth - 2*BUTTON_WIDTH - THROBBER_WIDTH,
|
|
|
|
BUTTON_HEIGHT);
|
2000-02-04 15:58:35 +00:00
|
|
|
|
|
|
|
#ifdef USE_LOCAL_WIDGETS
|
|
|
|
rv = NS_NewTextWidget(&mLocation);
|
|
|
|
#else
|
1999-03-09 09:44:27 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID,
|
1999-10-05 23:59:59 +00:00
|
|
|
(void**)&mLocation);
|
2000-02-04 15:58:35 +00:00
|
|
|
#endif
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-14 20:46:42 +00:00
|
|
|
|
|
|
|
NS_CreateTextWidget(mWindow,mLocation,r,HandleLocationEvent,&font);
|
1999-10-05 23:59:59 +00:00
|
|
|
if (NS_OK == mLocation->QueryInterface(kIWidgetIID,(void**)&widget))
|
1998-09-14 20:46:42 +00:00
|
|
|
{
|
|
|
|
widget->SetForegroundColor(NS_RGB(0, 0, 0));
|
|
|
|
widget->SetBackgroundColor(NS_RGB(255, 255, 255));
|
|
|
|
PRUint32 size;
|
1999-09-02 18:13:07 +00:00
|
|
|
nsAutoString empty;
|
|
|
|
mLocation->SetText(empty, size);
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_RELEASE(widget);
|
1998-09-14 20:46:42 +00:00
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
// Create and place throbber
|
|
|
|
r.SetRect(aWidth - THROBBER_WIDTH, 0,
|
1999-10-05 23:59:59 +00:00
|
|
|
THROBBER_WIDTH, THROBBER_HEIGHT);
|
1999-09-25 20:10:29 +00:00
|
|
|
mThrobber = nsThrobber::NewThrobber();
|
2000-04-18 10:22:00 +00:00
|
|
|
nsString throbberURL; throbberURL.AssignWithConversion(THROBBER_AT);
|
1998-11-23 03:30:24 +00:00
|
|
|
mThrobber->Init(mWindow, r, throbberURL, THROB_NUM);
|
1998-07-20 16:19:22 +00:00
|
|
|
mThrobber->Show();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-01 10:48:28 +00:00
|
|
|
// Overload this method in your nsNativeBrowserWindow if you need to
|
|
|
|
// have the logic in nsBrowserWindow::Layout() offset the menu within
|
|
|
|
// the parent window.
|
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::GetMenuBarHeight(PRInt32 * aHeightOut)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aHeightOut,"null out param.");
|
|
|
|
|
|
|
|
*aHeightOut = 0;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsresult
|
|
|
|
nsBrowserWindow::CreateStatusBar(PRInt32 aWidth)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
1998-07-24 16:03:11 +00:00
|
|
|
nsIDeviceContext* dc = mWindow->GetDeviceContext();
|
1998-08-27 05:05:03 +00:00
|
|
|
float t2d;
|
|
|
|
dc->GetTwipsToDevUnits(t2d);
|
1998-07-24 16:03:11 +00:00
|
|
|
nsFont font(STATUS_BAR_FONT, NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_FONT_WEIGHT_NORMAL, 0,
|
|
|
|
nscoord(t2d * NSIntPointsToTwips(STATUS_BAR_FONT_SIZE)));
|
1998-07-24 16:03:11 +00:00
|
|
|
NS_RELEASE(dc);
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
nsRect r(0, 0, aWidth, THROBBER_HEIGHT);
|
2000-02-04 15:58:35 +00:00
|
|
|
|
|
|
|
#ifdef USE_LOCAL_WIDGETS
|
|
|
|
rv = NS_NewTextWidget(&mStatus);
|
|
|
|
#else
|
1999-03-09 09:44:27 +00:00
|
|
|
rv = nsComponentManager::CreateInstance(kTextFieldCID, nsnull, kITextWidgetIID,
|
1999-10-05 23:59:59 +00:00
|
|
|
(void**)&mStatus);
|
2000-02-04 15:58:35 +00:00
|
|
|
#endif
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
if (NS_OK != rv) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-14 20:46:42 +00:00
|
|
|
|
|
|
|
nsIWidget* widget = nsnull;
|
|
|
|
NS_CreateTextWidget(mWindow,mStatus,r,HandleLocationEvent,&font);
|
1999-10-05 23:59:59 +00:00
|
|
|
if (NS_OK == mStatus->QueryInterface(kIWidgetIID,(void**)&widget))
|
|
|
|
{
|
1998-09-14 20:46:42 +00:00
|
|
|
widget->SetForegroundColor(NS_RGB(0, 0, 0));
|
|
|
|
PRUint32 size;
|
2000-04-18 10:22:00 +00:00
|
|
|
mStatus->SetText(nsAutoString(),size);
|
1999-01-16 00:29:07 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
nsITextWidget* textWidget = nsnull;
|
|
|
|
if (NS_OK == mStatus->QueryInterface(kITextWidgetIID,(void**)&textWidget))
|
|
|
|
{
|
|
|
|
PRBool wasReadOnly;
|
|
|
|
textWidget->SetReadOnly(PR_TRUE, wasReadOnly);
|
|
|
|
NS_RELEASE(textWidget);
|
|
|
|
}
|
1999-01-16 00:29:07 +00:00
|
|
|
|
1998-09-14 20:46:42 +00:00
|
|
|
NS_RELEASE(widget);
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::Layout(PRInt32 aWidth, PRInt32 aHeight)
|
|
|
|
{
|
1998-09-01 22:49:16 +00:00
|
|
|
nscoord txtHeight;
|
1999-09-01 10:48:28 +00:00
|
|
|
nscoord menuBarHeight;
|
1998-09-01 22:49:16 +00:00
|
|
|
nsILookAndFeel * lookAndFeel;
|
1999-03-09 09:44:27 +00:00
|
|
|
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) {
|
1998-09-01 22:49:16 +00:00
|
|
|
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldHeight, txtHeight);
|
1998-09-12 19:30:09 +00:00
|
|
|
NS_RELEASE(lookAndFeel);
|
1998-09-01 22:49:16 +00:00
|
|
|
} else {
|
|
|
|
txtHeight = 24;
|
|
|
|
}
|
|
|
|
|
1999-09-01 10:48:28 +00:00
|
|
|
// Find out the menubar height
|
|
|
|
GetMenuBarHeight(&menuBarHeight);
|
|
|
|
|
1998-09-15 21:31:58 +00:00
|
|
|
nsRect rr(0, 0, aWidth, aHeight);
|
1998-09-01 22:49:16 +00:00
|
|
|
|
1998-09-16 23:16:37 +00:00
|
|
|
// position location bar (it's stretchy)
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_TOOLBAR & mChromeMask) {
|
1998-12-08 01:57:40 +00:00
|
|
|
nsIWidget* locationWidget = nsnull;
|
|
|
|
if (mLocation &&
|
|
|
|
NS_SUCCEEDED(mLocation->QueryInterface(kIWidgetIID,
|
|
|
|
(void**)&locationWidget))) {
|
1998-09-16 23:16:37 +00:00
|
|
|
if (mThrobber) {
|
1999-10-05 23:59:59 +00:00
|
|
|
PRInt32 width = PR_MAX(aWidth - (2*BUTTON_WIDTH + THROBBER_WIDTH), 0);
|
1999-08-10 22:31:59 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
locationWidget->Resize(2*BUTTON_WIDTH, menuBarHeight,
|
1999-08-10 22:31:59 +00:00
|
|
|
width,
|
1998-12-08 01:57:40 +00:00
|
|
|
BUTTON_HEIGHT,
|
|
|
|
PR_TRUE);
|
1999-10-05 23:59:59 +00:00
|
|
|
mThrobber->MoveTo(aWidth - THROBBER_WIDTH, menuBarHeight);
|
1998-09-14 20:46:42 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-10-05 23:59:59 +00:00
|
|
|
PRInt32 width = PR_MAX(aWidth - 2*BUTTON_WIDTH, 0);
|
|
|
|
locationWidget->Resize(2*BUTTON_WIDTH, menuBarHeight,
|
1999-08-10 22:31:59 +00:00
|
|
|
width,
|
1998-12-08 01:57:40 +00:00
|
|
|
BUTTON_HEIGHT,
|
|
|
|
PR_TRUE);
|
1998-09-14 20:46:42 +00:00
|
|
|
}
|
1998-12-03 10:12:30 +00:00
|
|
|
|
1998-09-16 23:16:37 +00:00
|
|
|
locationWidget->Show(PR_TRUE);
|
1998-12-08 01:57:40 +00:00
|
|
|
NS_RELEASE(locationWidget);
|
1999-09-01 10:48:28 +00:00
|
|
|
|
|
|
|
nsIWidget* w = nsnull;
|
|
|
|
if (mBack &&
|
|
|
|
NS_SUCCEEDED(mBack->QueryInterface(kIWidgetIID, (void**)&w))) {
|
|
|
|
w->Move(0, menuBarHeight);
|
|
|
|
w->Show(PR_TRUE);
|
|
|
|
NS_RELEASE(w);
|
|
|
|
}
|
|
|
|
if (mForward &&
|
|
|
|
NS_SUCCEEDED(mForward->QueryInterface(kIWidgetIID, (void**)&w))) {
|
|
|
|
w->Move(BUTTON_WIDTH, menuBarHeight);
|
|
|
|
w->Show(PR_TRUE);
|
|
|
|
NS_RELEASE(w);
|
|
|
|
}
|
1998-09-16 23:16:37 +00:00
|
|
|
}
|
1998-12-08 01:57:40 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsIWidget* w = nsnull;
|
|
|
|
if (mLocation &&
|
|
|
|
NS_SUCCEEDED(mLocation->QueryInterface(kIWidgetIID, (void**)&w))) {
|
|
|
|
w->Show(PR_FALSE);
|
|
|
|
NS_RELEASE(w);
|
|
|
|
}
|
|
|
|
if (mBack &&
|
|
|
|
NS_SUCCEEDED(mBack->QueryInterface(kIWidgetIID, (void**)&w))) {
|
1999-09-01 10:48:28 +00:00
|
|
|
w->Move(0, menuBarHeight);
|
1998-12-08 01:57:40 +00:00
|
|
|
w->Show(PR_FALSE);
|
|
|
|
NS_RELEASE(w);
|
|
|
|
}
|
|
|
|
if (mForward &&
|
|
|
|
NS_SUCCEEDED(mForward->QueryInterface(kIWidgetIID, (void**)&w))) {
|
1999-10-05 23:59:59 +00:00
|
|
|
w->Move(BUTTON_WIDTH, menuBarHeight);
|
1998-12-08 01:57:40 +00:00
|
|
|
w->Show(PR_FALSE);
|
|
|
|
NS_RELEASE(w);
|
|
|
|
}
|
|
|
|
if (mThrobber) {
|
|
|
|
mThrobber->Hide();
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 21:31:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIWidget* statusWidget = nsnull;
|
1998-09-14 20:46:42 +00:00
|
|
|
|
1998-09-16 23:16:37 +00:00
|
|
|
if (mStatus && NS_OK == mStatus->QueryInterface(kIWidgetIID,(void**)&statusWidget)) {
|
2000-08-25 18:39:46 +00:00
|
|
|
if (mChromeMask & nsIWebBrowserChrome::CHROME_STATUSBAR) {
|
1998-09-16 23:16:37 +00:00
|
|
|
statusWidget->Resize(0, aHeight - txtHeight,
|
1999-10-05 23:59:59 +00:00
|
|
|
aWidth, txtHeight,
|
|
|
|
PR_TRUE);
|
1999-08-25 03:27:37 +00:00
|
|
|
|
|
|
|
//Since allowing a negative height is a bad idea, let's condition this...
|
|
|
|
rr.height = PR_MAX(0,rr.height-txtHeight);
|
1998-09-16 23:16:37 +00:00
|
|
|
statusWidget->Show(PR_TRUE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
statusWidget->Show(PR_FALSE);
|
1998-09-14 20:46:42 +00:00
|
|
|
}
|
1998-10-06 02:00:54 +00:00
|
|
|
NS_RELEASE(statusWidget);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
1998-09-15 21:31:58 +00:00
|
|
|
|
|
|
|
// inset the web widget
|
1998-12-03 10:12:30 +00:00
|
|
|
|
2000-08-25 18:39:46 +00:00
|
|
|
if (nsIWebBrowserChrome::CHROME_TOOLBAR & mChromeMask) {
|
1998-12-08 01:57:40 +00:00
|
|
|
rr.height -= BUTTON_HEIGHT;
|
|
|
|
rr.y += BUTTON_HEIGHT;
|
|
|
|
}
|
1998-12-03 10:12:30 +00:00
|
|
|
|
1998-09-15 21:31:58 +00:00
|
|
|
rr.x += WEBSHELL_LEFT_INSET;
|
1999-09-01 10:48:28 +00:00
|
|
|
rr.y += WEBSHELL_TOP_INSET + menuBarHeight;
|
1998-09-15 21:31:58 +00:00
|
|
|
rr.width -= WEBSHELL_LEFT_INSET + WEBSHELL_RIGHT_INSET;
|
1999-09-01 10:48:28 +00:00
|
|
|
rr.height -= WEBSHELL_TOP_INSET + WEBSHELL_BOTTOM_INSET + menuBarHeight;
|
1999-08-25 03:27:37 +00:00
|
|
|
|
|
|
|
//Since allowing a negative height is a bad idea, let's condition this...
|
|
|
|
if(rr.height<0)
|
|
|
|
rr.height=0;
|
|
|
|
|
2000-03-11 01:31:28 +00:00
|
|
|
nsCOMPtr<nsIBaseWindow> webBrowserWin(do_QueryInterface(mWebBrowser));
|
|
|
|
if (webBrowserWin) {
|
|
|
|
webBrowserWin->SetPositionAndSize(rr.x, rr.y, rr.width, rr.height, PR_FALSE);
|
1999-08-17 07:09:44 +00:00
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::MoveTo(PRInt32 aX, PRInt32 aY)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
mWindow->Move(aX, aY);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-07-04 04:09:54 +00:00
|
|
|
nsBrowserWindow::SizeContentTo(PRInt32 aWidth, PRInt32 aHeight)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
|
|
|
|
|
|
|
// XXX We want to do this in one shot
|
|
|
|
mWindow->Resize(aWidth, aHeight, PR_FALSE);
|
|
|
|
Layout(aWidth, aHeight);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-15 02:30:34 +00:00
|
|
|
nsBrowserWindow::SizeWindowTo(PRInt32 aWidth, PRInt32 aHeight,
|
|
|
|
PRBool /*aWidthTransient*/,
|
|
|
|
PRBool /*aHeightTransient*/)
|
1999-07-04 04:09:54 +00:00
|
|
|
{
|
|
|
|
return SizeContentTo(aWidth, aHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetContentBounds(nsRect& aBounds)
|
1998-07-21 00:48:35 +00:00
|
|
|
{
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(aBounds);
|
1998-07-21 00:48:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-01 22:23:48 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetWindowBounds(nsRect& aBounds)
|
|
|
|
{
|
|
|
|
mWindow->GetBounds(aBounds);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
NS_IMETHODIMP
|
1998-09-09 01:19:11 +00:00
|
|
|
nsBrowserWindow::SetChrome(PRUint32 aChromeMask)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
mChromeMask = aChromeMask;
|
1998-09-15 21:31:58 +00:00
|
|
|
nsRect r;
|
1998-11-04 21:46:00 +00:00
|
|
|
mWindow->GetClientBounds(r);
|
1998-09-15 21:31:58 +00:00
|
|
|
Layout(r.width, r.height);
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetChrome(PRUint32& aChromeMaskResult)
|
|
|
|
{
|
|
|
|
aChromeMaskResult = mChromeMask;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetWebShell(nsIWebShell*& aResult)
|
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
|
|
|
aResult = webShell;
|
|
|
|
NS_IF_ADDREF(aResult);
|
1998-07-21 00:48:35 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-26 21:48:29 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::GetContentWebShell(nsIWebShell **aResult)
|
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
|
|
|
|
*aResult = webShell;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
1999-06-26 21:48:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------
|
1998-09-12 00:22:27 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgressMax)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-09 19:03:24 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::ShowMenuBar(PRBool aShow)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
NS_IMETHODIMP
|
1999-04-30 00:11:18 +00:00
|
|
|
nsBrowserWindow::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL,
|
|
|
|
nsLoadType aReason)
|
|
|
|
{
|
1998-07-20 16:19:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-08-14 23:08:54 +00:00
|
|
|
nsBrowserWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-20 18:25:29 +00:00
|
|
|
nsBrowserWindow::ProgressLoadURL(nsIWebShell* aShell,
|
|
|
|
const PRUnichar* aURL,
|
|
|
|
PRInt32 aProgress,
|
|
|
|
PRInt32 aProgressMax)
|
1998-08-14 23:08:54 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1998-11-20 18:25:29 +00:00
|
|
|
nsBrowserWindow::EndLoadURL(nsIWebShell* aShell,
|
|
|
|
const PRUnichar* aURL,
|
1999-08-05 01:28:30 +00:00
|
|
|
nsresult aStatus)
|
2000-04-04 02:46:17 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
1998-08-14 23:08:54 +00:00
|
|
|
}
|
|
|
|
|
1998-09-14 20:46:42 +00:00
|
|
|
|
1998-08-19 21:00:51 +00:00
|
|
|
NS_IMETHODIMP
|
1998-12-08 01:57:40 +00:00
|
|
|
nsBrowserWindow::NewWebShell(PRUint32 aChromeMask,
|
|
|
|
PRBool aVisible,
|
|
|
|
nsIWebShell*& aNewWebShell)
|
1998-08-19 21:00:51 +00:00
|
|
|
{
|
1998-09-15 00:16:12 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-10-29 02:05:16 +00:00
|
|
|
if (mWebCrawler) {
|
|
|
|
if (mWebCrawler->Crawling() || mWebCrawler->LoadingURLList()) {
|
|
|
|
// Do not fly javascript popups when we are crawling
|
|
|
|
aNewWebShell = nsnull;
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-15 00:16:12 +00:00
|
|
|
// Create new window. By default, the refcnt will be 1 because of
|
|
|
|
// the registration of the browser window in gBrowsers.
|
|
|
|
nsNativeBrowserWindow* browser;
|
|
|
|
NS_NEWXPCOM(browser, nsNativeBrowserWindow);
|
1998-08-19 21:00:51 +00:00
|
|
|
|
|
|
|
if (nsnull != browser)
|
|
|
|
{
|
|
|
|
nsRect bounds;
|
1999-07-04 04:09:54 +00:00
|
|
|
GetContentBounds(bounds);
|
1998-08-19 21:00:51 +00:00
|
|
|
|
|
|
|
browser->SetApp(mApp);
|
1998-12-08 01:57:40 +00:00
|
|
|
|
|
|
|
// Assume no controls for now
|
2000-03-02 07:13:02 +00:00
|
|
|
rv = browser->Init(mAppShell, bounds, aChromeMask, mAllowPlugins);
|
1998-08-19 21:00:51 +00:00
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
1998-12-08 01:57:40 +00:00
|
|
|
// Default is to startup hidden
|
|
|
|
if (aVisible) {
|
2000-03-14 11:08:43 +00:00
|
|
|
browser->SetVisibility(PR_TRUE);
|
1998-12-08 01:57:40 +00:00
|
|
|
}
|
1998-08-19 21:00:51 +00:00
|
|
|
nsIWebShell *shell;
|
|
|
|
rv = browser->GetWebShell(shell);
|
|
|
|
aNewWebShell = shell;
|
|
|
|
}
|
|
|
|
else
|
1998-09-15 00:16:12 +00:00
|
|
|
{
|
2000-03-14 11:08:43 +00:00
|
|
|
browser->Destroy();
|
1998-09-15 00:16:12 +00:00
|
|
|
}
|
1998-08-19 21:00:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-19 21:08:44 +00:00
|
|
|
|
1999-04-20 01:50:03 +00:00
|
|
|
NS_IMETHODIMP
|
1999-05-04 23:33:55 +00:00
|
|
|
nsBrowserWindow::ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode)
|
1999-04-20 01:50:03 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-18 00:35:55 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBrowserWindow::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult)
|
|
|
|
{
|
2001-02-24 17:15:50 +00:00
|
|
|
PRInt32 i, n = gBrowsers ? gBrowsers->Count() : 0;
|
1998-09-18 00:35:55 +00:00
|
|
|
|
|
|
|
aResult = nsnull;
|
|
|
|
nsString aNameStr(aName);
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2001-02-24 17:15:50 +00:00
|
|
|
nsBrowserWindow* bw = (nsBrowserWindow*) gBrowsers->ElementAt(i);
|
1999-10-15 14:08:14 +00:00
|
|
|
nsCOMPtr<nsIWebShell> webShell;
|
1998-09-18 00:35:55 +00:00
|
|
|
|
1999-10-15 14:08:14 +00:00
|
|
|
if (NS_OK == bw->GetWebShell(*getter_AddRefs(webShell))) {
|
2000-03-11 01:31:28 +00:00
|
|
|
nsXPIDLString name;
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
if (NS_OK == docShellAsItem->GetName(getter_Copies(name))) {
|
2001-06-29 18:28:39 +00:00
|
|
|
if (aNameStr.Equals(name)) {
|
1999-10-15 14:08:14 +00:00
|
|
|
aResult = webShell;
|
1999-06-15 03:15:37 +00:00
|
|
|
NS_ADDREF(aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-18 00:35:55 +00:00
|
|
|
}
|
1999-06-15 03:15:37 +00:00
|
|
|
|
2000-03-11 01:31:28 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(mDocShell));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> result;
|
|
|
|
if (NS_OK == docShellAsNode->FindChildWithName(aName, PR_TRUE, PR_FALSE, nsnull,
|
|
|
|
getter_AddRefs(result))) {
|
|
|
|
if (result) {
|
|
|
|
CallQueryInterface(result, &aResult);
|
1999-06-15 03:15:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-18 00:35:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-09 19:03:24 +00:00
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsBrowserWindow::OnProgress(nsIRequest* request, nsISupports *ctxt,
|
1999-10-05 04:04:16 +00:00
|
|
|
PRUint32 aProgress, PRUint32 aProgressMax)
|
1998-07-20 16:19:22 +00:00
|
|
|
{
|
1999-06-28 10:35:57 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> aURL;
|
2001-02-21 20:38:08 +00:00
|
|
|
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
|
1999-06-28 10:35:57 +00:00
|
|
|
rv = channel->GetURI(getter_AddRefs(aURL));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
if (mStatus) {
|
|
|
|
nsAutoString url;
|
|
|
|
if (nsnull != aURL) {
|
2002-03-06 07:48:55 +00:00
|
|
|
nsCAutoString str;
|
|
|
|
aURL->GetSpec(str);
|
|
|
|
url = NS_ConvertUTF8toUCS2(str);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING(": progress "));
|
2000-04-18 10:22:00 +00:00
|
|
|
url.AppendInt(aProgress, 10);
|
1999-10-05 04:04:16 +00:00
|
|
|
if (0 != aProgressMax) {
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING(" (out of "));
|
2000-04-18 10:22:00 +00:00
|
|
|
url.AppendInt(aProgressMax, 10);
|
2001-12-16 11:58:03 +00:00
|
|
|
url.Append(NS_LITERAL_STRING(")"));
|
1999-10-05 04:04:16 +00:00
|
|
|
}
|
1998-09-14 20:46:42 +00:00
|
|
|
PRUint32 size;
|
|
|
|
mStatus->SetText(url,size);
|
1998-07-20 16:19:22 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-21 00:04:31 +00:00
|
|
|
NS_IMETHODIMP
|
2001-02-21 20:38:08 +00:00
|
|
|
nsBrowserWindow::OnStatus(nsIRequest* request, nsISupports *ctxt,
|
2000-07-25 05:45:56 +00:00
|
|
|
nsresult aStatus, const PRUnichar *aStatusArg)
|
1999-10-05 04:04:16 +00:00
|
|
|
{
|
|
|
|
if (mStatus) {
|
2000-07-25 05:45:56 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIStringBundleService> sbs = do_GetService(kStringBundleServiceCID, &rv);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
nsXPIDLString msg;
|
|
|
|
rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(msg));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-10-05 04:04:16 +00:00
|
|
|
PRUint32 size;
|
2000-08-20 00:45:05 +00:00
|
|
|
nsAutoString msg2( NS_STATIC_CAST(const PRUnichar*, msg));
|
2000-07-25 05:45:56 +00:00
|
|
|
mStatus->SetText(msg2, size);
|
1999-10-05 04:04:16 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-20 16:19:22 +00:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// Toolbar support
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::StartThrobber()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::StopThrobber()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::LoadThrobberImages()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DestroyThrobberImages()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell*
|
|
|
|
nsBrowserWindow::GetPresShell()
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
return GetPresShellFor(mDocShell);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
|
1998-08-21 18:28:48 +00:00
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoCopy()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
1999-04-07 04:10:04 +00:00
|
|
|
shell->DoCopy();
|
1998-07-31 16:53:45 +00:00
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-08 22:45:56 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoPaste()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
1999-04-07 04:31:03 +00:00
|
|
|
|
|
|
|
printf("nsBrowserWindow::DoPaste()\n");
|
|
|
|
|
1999-03-08 22:45:56 +00:00
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-10-15 23:23:04 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::ShowPrintPreview(PRInt32 aID)
|
|
|
|
{
|
2001-11-03 14:59:39 +00:00
|
|
|
nsCOMPtr <nsIContentViewer> viewer;
|
|
|
|
|
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(viewer));
|
|
|
|
|
|
|
|
if (viewer)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContentViewerFile> viewerFile = do_QueryInterface(viewer);
|
|
|
|
if (viewerFile) {
|
2002-02-01 14:52:11 +00:00
|
|
|
//viewerFile->PrintPreview(nsnull);
|
1998-10-15 23:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-14 01:58:34 +00:00
|
|
|
void nsBrowserWindow::DoPrint(void)
|
|
|
|
{
|
1999-08-06 07:44:37 +00:00
|
|
|
nsCOMPtr <nsIContentViewer> viewer;
|
1998-11-14 01:58:34 +00:00
|
|
|
|
1999-12-17 08:13:54 +00:00
|
|
|
mDocShell->GetContentViewer(getter_AddRefs(viewer));
|
1998-11-14 01:58:34 +00:00
|
|
|
|
2002-04-24 11:00:39 +00:00
|
|
|
if (viewer) {
|
|
|
|
nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint = do_QueryInterface(viewer);
|
|
|
|
if (webBrowserPrint) {
|
|
|
|
if (!mPrintSettings) {
|
2002-05-14 12:05:00 +00:00
|
|
|
webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(mPrintSettings));
|
2002-04-24 11:00:39 +00:00
|
|
|
}
|
|
|
|
webBrowserPrint->Print(mPrintSettings, (nsIWebProgressListener*)nsnull);
|
1998-12-17 15:52:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-01-06 21:59:17 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
1999-12-17 08:13:54 +00:00
|
|
|
nsIDOMDocument* nsBrowserWindow::GetDOMDocument(nsIDocShell *aDocShell)
|
1999-01-06 21:59:17 +00:00
|
|
|
{
|
|
|
|
nsIDOMDocument* domDoc = nsnull;
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
1999-01-06 21:59:17 +00:00
|
|
|
nsIContentViewer* mCViewer;
|
1999-12-17 08:13:54 +00:00
|
|
|
aDocShell->GetContentViewer(&mCViewer);
|
1999-01-06 21:59:17 +00:00
|
|
|
if (nsnull != mCViewer) {
|
|
|
|
nsIDocumentViewer* mDViewer;
|
|
|
|
if (NS_OK == mCViewer->QueryInterface(kIDocumentViewerIID, (void**) &mDViewer)) {
|
1999-10-05 23:59:59 +00:00
|
|
|
nsIDocument* mDoc;
|
|
|
|
mDViewer->GetDocument(mDoc);
|
|
|
|
if (nsnull != mDoc) {
|
|
|
|
if (NS_OK == mDoc->QueryInterface(kIDOMDocumentIID, (void**) &domDoc)) {
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDViewer);
|
1999-01-06 21:59:17 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(mCViewer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return domDoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------
|
1999-10-05 23:59:59 +00:00
|
|
|
|
1999-01-06 21:59:17 +00:00
|
|
|
void nsBrowserWindow::DoTableInspector()
|
|
|
|
{
|
|
|
|
if (mTableInspectorDialog) {
|
|
|
|
mTableInspectorDialog->SetVisible(PR_TRUE);
|
|
|
|
return;
|
|
|
|
}
|
1999-12-17 08:13:54 +00:00
|
|
|
nsIDOMDocument* domDoc = GetDOMDocument(mDocShell);
|
1999-01-06 21:59:17 +00:00
|
|
|
|
|
|
|
if (nsnull != domDoc) {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsString printHTML(NS_LITERAL_STRING("resource:/res/samples/printsetup.html"));
|
1999-01-06 21:59:17 +00:00
|
|
|
nsRect rect(0, 0, 375, 510);
|
2001-12-16 11:58:03 +00:00
|
|
|
nsString title(NS_LITERAL_STRING("Table Inspector"));
|
1999-01-06 21:59:17 +00:00
|
|
|
|
|
|
|
nsXPBaseWindow * xpWin = nsnull;
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull,
|
1999-10-05 23:59:59 +00:00
|
|
|
kIXPBaseWindowIID,
|
|
|
|
(void**) &xpWin);
|
1999-01-06 21:59:17 +00:00
|
|
|
if (rv == NS_OK) {
|
2000-03-02 07:13:02 +00:00
|
|
|
xpWin->Init(eXPBaseWindowType_dialog, mAppShell, printHTML, title, rect, PRUint32(~0), PR_FALSE);
|
1999-01-06 21:59:17 +00:00
|
|
|
xpWin->SetVisible(PR_TRUE);
|
1999-10-05 23:59:59 +00:00
|
|
|
if (NS_OK == xpWin->QueryInterface(kIXPBaseWindowIID, (void**) &mTableInspectorDialog)) {
|
1999-01-06 21:59:17 +00:00
|
|
|
mTableInspector = new nsTableInspectorDialog(this, domDoc); // ref counts domDoc
|
|
|
|
if (nsnull != mTableInspector) {
|
|
|
|
xpWin->AddWindowListener(mTableInspector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(xpWin);
|
|
|
|
}
|
|
|
|
NS_RELEASE(domDoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void nsBrowserWindow::DoImageInspector()
|
|
|
|
{
|
|
|
|
if (mImageInspectorDialog) {
|
|
|
|
mImageInspectorDialog->SetVisible(PR_TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-17 08:13:54 +00:00
|
|
|
nsIDOMDocument* domDoc = GetDOMDocument(mDocShell);
|
1999-01-06 21:59:17 +00:00
|
|
|
|
|
|
|
if (nsnull != domDoc) {
|
2001-12-16 11:58:03 +00:00
|
|
|
nsString printHTML(NS_LITERAL_STRING("resource:/res/samples/image_props.html"));
|
1999-01-06 21:59:17 +00:00
|
|
|
nsRect rect(0, 0, 485, 124);
|
2001-12-16 11:58:03 +00:00
|
|
|
nsString title(NS_LITERAL_STRING("Image Inspector"));
|
1999-01-06 21:59:17 +00:00
|
|
|
|
|
|
|
nsXPBaseWindow * xpWin = nsnull;
|
1999-03-09 09:44:27 +00:00
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kXPBaseWindowCID, nsnull, kIXPBaseWindowIID, (void**) &xpWin);
|
1999-01-06 21:59:17 +00:00
|
|
|
if (rv == NS_OK) {
|
2000-03-02 07:13:02 +00:00
|
|
|
xpWin->Init(eXPBaseWindowType_dialog, mAppShell, printHTML, title, rect, PRUint32(~0), PR_FALSE);
|
1999-01-06 21:59:17 +00:00
|
|
|
xpWin->SetVisible(PR_TRUE);
|
1999-10-05 23:59:59 +00:00
|
|
|
if (NS_OK == xpWin->QueryInterface(kIXPBaseWindowIID, (void**) &mImageInspectorDialog)) {
|
1999-01-06 21:59:17 +00:00
|
|
|
mImageInspector = new nsImageInspectorDialog(this, domDoc); // ref counts domDoc
|
|
|
|
if (nsnull != mImageInspector) {
|
|
|
|
xpWin->AddWindowListener(mImageInspector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(xpWin);
|
|
|
|
}
|
|
|
|
NS_RELEASE(domDoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-10-15 23:23:04 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoJSConsole()
|
|
|
|
{
|
|
|
|
mApp->CreateJSConsole(this);
|
|
|
|
}
|
|
|
|
|
1998-09-22 00:57:54 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoPrefs()
|
|
|
|
{
|
|
|
|
mApp->DoPrefs(this);
|
|
|
|
}
|
|
|
|
|
1998-08-07 04:45:03 +00:00
|
|
|
void
|
1999-12-17 08:13:54 +00:00
|
|
|
nsBrowserWindow::DoEditorMode(nsIDocShell *aDocShell)
|
1998-08-07 04:45:03 +00:00
|
|
|
{
|
1998-08-14 01:51:00 +00:00
|
|
|
PRInt32 i, n;
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
1998-08-14 01:51:00 +00:00
|
|
|
nsIContentViewer* mCViewer;
|
1999-12-17 08:13:54 +00:00
|
|
|
aDocShell->GetContentViewer(&mCViewer);
|
1998-08-14 01:51:00 +00:00
|
|
|
if (nsnull != mCViewer) {
|
|
|
|
nsIDocumentViewer* mDViewer;
|
1999-01-14 18:52:16 +00:00
|
|
|
if (NS_OK == mCViewer->QueryInterface(kIDocumentViewerIID, (void**) &mDViewer))
|
|
|
|
{
|
1999-10-05 23:59:59 +00:00
|
|
|
nsIDocument* mDoc;
|
|
|
|
mDViewer->GetDocument(mDoc);
|
|
|
|
if (nsnull != mDoc) {
|
|
|
|
nsIDOMDocument* mDOMDoc;
|
|
|
|
if (NS_OK == mDoc->QueryInterface(kIDOMDocumentIID, (void**) &mDOMDoc))
|
1999-01-14 18:52:16 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
nsIPresShell* shell = GetPresShellFor(aDocShell);
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_InitEditorMode(mDOMDoc, shell);
|
|
|
|
NS_RELEASE(mDOMDoc);
|
1999-01-14 18:52:16 +00:00
|
|
|
NS_IF_RELEASE(shell);
|
1999-10-05 23:59:59 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(mDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDViewer);
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
1998-08-14 01:51:00 +00:00
|
|
|
NS_RELEASE(mCViewer);
|
|
|
|
}
|
|
|
|
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
|
|
|
|
docShellAsNode->GetChildCount(&n);
|
1998-08-14 01:51:00 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> child;
|
|
|
|
docShellAsNode->GetChildAt(i, getter_AddRefs(child));
|
|
|
|
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
|
|
|
|
DoEditorMode(childAsShell);
|
1998-08-07 04:45:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-02 05:31:41 +00:00
|
|
|
// Same as above, but calls NS_DoEditorTest instead of starting an editor
|
|
|
|
void
|
1999-12-17 08:13:54 +00:00
|
|
|
nsBrowserWindow::DoEditorTest(nsIDocShell *aDocShell, PRInt32 aCommandID)
|
1999-03-02 05:31:41 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
1999-03-02 05:31:41 +00:00
|
|
|
nsIContentViewer* mCViewer;
|
1999-12-17 08:13:54 +00:00
|
|
|
aDocShell->GetContentViewer(&mCViewer);
|
1999-03-02 05:31:41 +00:00
|
|
|
if (nsnull != mCViewer) {
|
|
|
|
nsIDocumentViewer* mDViewer;
|
|
|
|
if (NS_OK == mCViewer->QueryInterface(kIDocumentViewerIID, (void**) &mDViewer))
|
|
|
|
{
|
1999-10-05 23:59:59 +00:00
|
|
|
nsIDocument* mDoc;
|
|
|
|
mDViewer->GetDocument(mDoc);
|
|
|
|
if (nsnull != mDoc) {
|
|
|
|
nsIDOMDocument* mDOMDoc;
|
|
|
|
if (NS_OK == mDoc->QueryInterface(kIDOMDocumentIID, (void**) &mDOMDoc))
|
1999-03-02 05:31:41 +00:00
|
|
|
{
|
|
|
|
NS_DoEditorTest(aCommandID);
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_RELEASE(mDOMDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDoc);
|
|
|
|
}
|
|
|
|
NS_RELEASE(mDViewer);
|
1999-03-02 05:31:41 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(mCViewer);
|
|
|
|
}
|
|
|
|
// Do we need to do all the children as in DoEditorMode?
|
|
|
|
// Its seems to work if we don't do that
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-07-31 16:53:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIFrame.h"
|
1999-11-01 23:29:05 +00:00
|
|
|
#include "nsIFrameDebug.h"
|
1998-07-31 16:53:45 +00:00
|
|
|
#include "nsIStyleSet.h"
|
|
|
|
|
|
|
|
|
1999-12-17 08:13:54 +00:00
|
|
|
static void DumpAWebShell(nsIDocShellTreeItem* aShellItem, FILE* out, PRInt32 aIndent)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
nsXPIDLString name;
|
1998-11-11 22:22:18 +00:00
|
|
|
nsAutoString str;
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> parent;
|
1998-11-11 22:22:18 +00:00
|
|
|
PRInt32 i, n;
|
|
|
|
|
|
|
|
for (i = aIndent; --i >= 0; ) fprintf(out, " ");
|
|
|
|
|
1999-12-17 08:13:54 +00:00
|
|
|
fprintf(out, "%p '", aShellItem);
|
|
|
|
aShellItem->GetName(getter_Copies(name));
|
|
|
|
aShellItem->GetSameTypeParent(getter_AddRefs(parent));
|
2000-03-26 11:39:08 +00:00
|
|
|
str.Assign(name);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(str).get(), out);
|
1999-12-17 08:13:54 +00:00
|
|
|
fprintf(out, "' parent=%p <\n", parent.get());
|
1998-11-11 22:22:18 +00:00
|
|
|
|
|
|
|
aIndent++;
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> shellAsNode(do_QueryInterface(aShellItem));
|
|
|
|
shellAsNode->GetChildCount(&n);
|
1998-11-11 22:22:18 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> child;
|
|
|
|
shellAsNode->GetChildAt(i, getter_AddRefs(child));
|
|
|
|
if (child) {
|
1998-11-11 22:22:18 +00:00
|
|
|
DumpAWebShell(child, out, aIndent);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
1998-11-11 22:22:18 +00:00
|
|
|
aIndent--;
|
|
|
|
for (i = aIndent; --i >= 0; ) fprintf(out, " ");
|
|
|
|
fputs(">\n", out);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-11-11 22:22:18 +00:00
|
|
|
nsBrowserWindow::DumpWebShells(FILE* out)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> shellAsItem(do_QueryInterface(mDocShell));
|
|
|
|
DumpAWebShell(shellAsItem, out, 0);
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
|
|
|
|
1999-03-03 14:35:06 +00:00
|
|
|
static
|
1998-11-11 22:22:18 +00:00
|
|
|
void
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpMultipleWebShells(nsBrowserWindow& aBrowserWindow, nsIDocShell* aDocShell, FILE* aOut)
|
1998-11-11 22:22:18 +00:00
|
|
|
{
|
|
|
|
PRInt32 count;
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
|
|
|
|
if (docShellAsNode) {
|
|
|
|
docShellAsNode->GetChildCount(&count);
|
1998-11-11 22:22:18 +00:00
|
|
|
if (count > 0) {
|
|
|
|
fprintf(aOut, "webshells= \n");
|
|
|
|
aBrowserWindow.DumpWebShells(aOut);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-03 14:35:06 +00:00
|
|
|
static
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpContentRecurse(nsIDocShell* aDocShell, FILE* out)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
|
|
|
fprintf(out, "docshell=%p \n", aDocShell);
|
|
|
|
nsIPresShell* shell = GetPresShellFor(aDocShell);
|
1998-07-27 05:59:37 +00:00
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
shell->GetDocument(getter_AddRefs(doc));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (doc) {
|
2001-06-20 03:27:48 +00:00
|
|
|
nsIContent* root = nsnull;
|
|
|
|
doc->GetRootContent(&root);
|
1998-11-11 22:22:18 +00:00
|
|
|
if (nsnull != root) {
|
1999-10-05 23:59:59 +00:00
|
|
|
root->List(out);
|
|
|
|
NS_RELEASE(root);
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
1998-11-11 22:22:18 +00:00
|
|
|
// dump the frames of the sub documents
|
1998-07-27 05:59:37 +00:00
|
|
|
PRInt32 i, n;
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
|
|
|
|
docShellAsNode->GetChildCount(&n);
|
1998-07-27 05:59:37 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> child;
|
|
|
|
docShellAsNode->GetChildAt(i, getter_AddRefs(child));
|
|
|
|
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
|
1998-07-27 05:59:37 +00:00
|
|
|
if (nsnull != child) {
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpContentRecurse(childAsShell, out);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
void
|
1998-11-11 22:22:18 +00:00
|
|
|
nsBrowserWindow::DumpContent(FILE* out)
|
1998-07-27 05:59:37 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpContentRecurse(mDocShell, out);
|
|
|
|
DumpMultipleWebShells(*this, mDocShell, out);
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
1999-08-31 03:18:03 +00:00
|
|
|
static void
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpFramesRecurse(nsIDocShell* aDocShell, FILE* out, nsString *aFilterName)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
|
|
|
fprintf(out, "webshell=%p \n", aDocShell);
|
|
|
|
nsIPresShell* shell = GetPresShellFor(aDocShell);
|
1998-11-11 22:22:18 +00:00
|
|
|
if (nsnull != shell) {
|
1998-12-29 04:45:18 +00:00
|
|
|
nsIFrame* root;
|
1999-02-12 17:45:58 +00:00
|
|
|
shell->GetRootFrame(&root);
|
1998-11-11 22:22:18 +00:00
|
|
|
if (nsnull != root) {
|
1999-10-26 04:44:41 +00:00
|
|
|
nsIPresContext* presContext;
|
|
|
|
shell->GetPresContext(&presContext);
|
|
|
|
|
1999-11-01 23:29:05 +00:00
|
|
|
nsIFrameDebug* fdbg;
|
2003-01-09 06:49:07 +00:00
|
|
|
if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) {
|
1999-11-01 23:29:05 +00:00
|
|
|
fdbg->List(presContext, out, 0);
|
|
|
|
}
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IF_RELEASE(presContext);
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
1999-08-31 03:18:03 +00:00
|
|
|
|
1998-11-11 22:22:18 +00:00
|
|
|
// dump the frames of the sub documents
|
|
|
|
PRInt32 i, n;
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
|
|
|
|
docShellAsNode->GetChildCount(&n);
|
1998-11-11 22:22:18 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> child;
|
|
|
|
docShellAsNode->GetChildAt(i, getter_AddRefs(child));
|
|
|
|
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
|
|
|
|
if (childAsShell) {
|
|
|
|
DumpFramesRecurse(childAsShell, out, aFilterName);
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1998-11-11 22:22:18 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpFrames(FILE* out, nsString *aFilterName)
|
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpFramesRecurse(mDocShell, out, aFilterName);
|
|
|
|
DumpMultipleWebShells(*this, mDocShell, out);
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-08-31 03:18:03 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-03-03 14:35:06 +00:00
|
|
|
static
|
1998-11-11 22:22:18 +00:00
|
|
|
void
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpViewsRecurse(nsIDocShell* aDocShell, FILE* out)
|
1998-11-11 22:22:18 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != aDocShell) {
|
|
|
|
fprintf(out, "docshell=%p \n", aDocShell);
|
|
|
|
nsIPresShell* shell = GetPresShellFor(aDocShell);
|
1998-11-11 22:22:18 +00:00
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
shell->GetViewManager(getter_AddRefs(vm));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (vm) {
|
1999-10-05 23:59:59 +00:00
|
|
|
nsIView* root;
|
|
|
|
vm->GetRootView(root);
|
|
|
|
if (nsnull != root) {
|
|
|
|
root->List(out);
|
|
|
|
}
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
1999-04-30 00:11:18 +00:00
|
|
|
|
1998-11-11 22:22:18 +00:00
|
|
|
// dump the views of the sub documents
|
|
|
|
PRInt32 i, n;
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeNode> docShellAsNode(do_QueryInterface(aDocShell));
|
|
|
|
docShellAsNode->GetChildCount(&n);
|
1998-11-11 22:22:18 +00:00
|
|
|
for (i = 0; i < n; i++) {
|
1999-12-17 08:13:54 +00:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> child;
|
|
|
|
docShellAsNode->GetChildAt(i, getter_AddRefs(child));
|
|
|
|
nsCOMPtr<nsIDocShell> childAsShell(do_QueryInterface(child));
|
|
|
|
if (childAsShell) {
|
|
|
|
DumpViewsRecurse(childAsShell, out);
|
1998-11-11 22:22:18 +00:00
|
|
|
}
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-11-11 22:22:18 +00:00
|
|
|
nsBrowserWindow::DumpViews(FILE* out)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
1999-12-17 08:13:54 +00:00
|
|
|
DumpViewsRecurse(mDocShell, out);
|
|
|
|
DumpMultipleWebShells(*this, mDocShell, out);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpStyleSheets(FILE* out)
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIStyleSet> styleSet;
|
|
|
|
shell->GetStyleSet(getter_AddRefs(styleSet));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (!styleSet) {
|
1998-07-20 21:16:38 +00:00
|
|
|
fputs("null style set\n", out);
|
|
|
|
} else {
|
|
|
|
styleSet->List(out);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpStyleContexts(FILE* out)
|
|
|
|
{
|
1998-07-21 00:48:35 +00:00
|
|
|
nsIPresShell* shell = GetPresShell();
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIStyleSet> styleSet;
|
|
|
|
shell->GetStyleSet(getter_AddRefs(styleSet));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (!styleSet) {
|
1998-07-20 21:16:38 +00:00
|
|
|
fputs("null style set\n", out);
|
|
|
|
} else {
|
1998-12-29 04:45:18 +00:00
|
|
|
nsIFrame* root;
|
1999-02-12 17:45:58 +00:00
|
|
|
shell->GetRootFrame(&root);
|
1998-07-20 21:16:38 +00:00
|
|
|
if (nsnull == root) {
|
1999-10-05 23:59:59 +00:00
|
|
|
fputs("null root frame\n", out);
|
|
|
|
} else {
|
2003-01-09 06:49:07 +00:00
|
|
|
styleSet->ListContexts(root, out);
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
} else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-28 23:38:19 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DumpReflowStats(FILE* out)
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
shell->DumpReflows();
|
|
|
|
#else
|
|
|
|
fprintf(out,"***********************************\n");
|
|
|
|
fprintf(out, "Sorry, you have built with MOZ_REFLOW_PERF=1\n");
|
|
|
|
fprintf(out,"***********************************\n");
|
|
|
|
#endif
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
} else {
|
|
|
|
fputs("null pres shell\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 01:53:45 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DisplayReflowStats(PRBool aIsOn)
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
#ifdef MOZ_REFLOW_PERF
|
|
|
|
shell->SetPaintFrameCount(aIsOn);
|
|
|
|
SetBoolPref("layout.reflow.showframecounts",aIsOn);
|
|
|
|
ForceRefresh();
|
|
|
|
#else
|
2001-03-13 04:21:31 +00:00
|
|
|
printf("***********************************\n");
|
|
|
|
printf("Sorry, you have built with MOZ_REFLOW_PERF=1\n");
|
|
|
|
printf("***********************************\n");
|
2001-03-13 01:53:45 +00:00
|
|
|
#endif
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::ToggleFrameBorders()
|
|
|
|
{
|
1999-05-06 19:32:42 +00:00
|
|
|
nsILayoutDebugger* ld;
|
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kLayoutDebuggerCID,
|
|
|
|
nsnull,
|
|
|
|
kILayoutDebuggerIID,
|
|
|
|
(void **)&ld);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
PRBool showing;
|
|
|
|
ld->GetShowFrameBorders(&showing);
|
|
|
|
ld->SetShowFrameBorders(!showing);
|
|
|
|
ForceRefresh();
|
|
|
|
NS_RELEASE(ld);
|
|
|
|
}
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
|
2000-02-15 04:33:43 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::ToggleVisualEventDebugging()
|
|
|
|
{
|
|
|
|
nsILayoutDebugger* ld;
|
|
|
|
nsresult rv = nsComponentManager::CreateInstance(kLayoutDebuggerCID,
|
|
|
|
nsnull,
|
|
|
|
kILayoutDebuggerIID,
|
|
|
|
(void **)&ld);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
PRBool showing;
|
|
|
|
ld->GetShowEventTargetFrameBorder(&showing);
|
|
|
|
ld->SetShowEventTargetFrameBorder(!showing);
|
|
|
|
ForceRefresh();
|
|
|
|
NS_RELEASE(ld);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-07 19:36:45 +00:00
|
|
|
void
|
1999-09-09 02:32:54 +00:00
|
|
|
nsBrowserWindow::ToggleBoolPrefAndRefresh(const char * aPrefName)
|
1999-09-07 19:36:45 +00:00
|
|
|
{
|
1999-09-09 02:32:54 +00:00
|
|
|
NS_ASSERTION(nsnull != aPrefName,"null pref name");
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
2000-03-02 07:13:02 +00:00
|
|
|
if (prefs && nsnull != aPrefName)
|
1999-09-07 19:36:45 +00:00
|
|
|
{
|
1999-09-09 02:32:54 +00:00
|
|
|
PRBool value;
|
2000-03-02 07:13:02 +00:00
|
|
|
prefs->GetBoolPref(aPrefName,&value);
|
|
|
|
prefs->SetBoolPref(aPrefName,!value);
|
2001-04-26 18:41:11 +00:00
|
|
|
prefs->SavePrefFile(nsnull);
|
1999-09-07 19:36:45 +00:00
|
|
|
|
|
|
|
ForceRefresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-14 16:24:34 +00:00
|
|
|
#endif
|
|
|
|
|
2000-03-14 14:19:56 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::SetBoolPref(const char * aPrefName, PRBool aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aPrefName,"null pref name");
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
2000-03-14 14:19:56 +00:00
|
|
|
if (prefs && nsnull != aPrefName)
|
|
|
|
{
|
|
|
|
prefs->SetBoolPref(aPrefName, aValue);
|
2001-04-26 18:41:11 +00:00
|
|
|
prefs->SavePrefFile(nsnull);
|
2000-03-14 14:19:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::SetStringPref(const char * aPrefName, const nsString& aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aPrefName, "null pref name");
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
2000-03-14 14:19:56 +00:00
|
|
|
if (nsnull != prefs && nsnull != aPrefName)
|
|
|
|
{
|
2001-09-29 08:28:41 +00:00
|
|
|
char * prefStr = ToNewCString(aValue);
|
2000-03-14 14:19:56 +00:00
|
|
|
prefs->SetCharPref(aPrefName, prefStr);
|
2001-04-26 18:41:11 +00:00
|
|
|
prefs->SavePrefFile(nsnull);
|
2000-03-14 14:19:56 +00:00
|
|
|
delete [] prefStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::GetStringPref(const char * aPrefName, nsString& aValue)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aPrefName, "null pref name");
|
|
|
|
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
|
2000-03-14 14:19:56 +00:00
|
|
|
if (nsnull != prefs && nsnull != aPrefName)
|
|
|
|
{
|
|
|
|
char* prefCharVal;
|
|
|
|
nsresult result = prefs->CopyCharPref(aPrefName, &prefCharVal);
|
|
|
|
if (NS_SUCCEEDED(result)) {
|
2000-04-18 10:22:00 +00:00
|
|
|
aValue.AssignWithConversion(prefCharVal);
|
2000-03-14 14:19:56 +00:00
|
|
|
PL_strfree(prefCharVal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-14 16:24:34 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-07-20 22:22:13 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoDebugSave()
|
|
|
|
{
|
1999-05-03 18:50:48 +00:00
|
|
|
/* Removed 04/01/99 -- gpk */
|
1998-07-20 22:22:13 +00:00
|
|
|
}
|
|
|
|
|
1998-07-27 18:17:07 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoToggleSelection()
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
2000-04-28 06:22:07 +00:00
|
|
|
nsCOMPtr<nsISelectionController> selCon;
|
|
|
|
selCon = do_QueryInterface(shell);
|
|
|
|
if (selCon) {
|
|
|
|
PRInt16 current;
|
|
|
|
selCon->GetDisplaySelection(¤t);
|
|
|
|
selCon->SetDisplaySelection(!current);
|
1998-07-27 18:17:07 +00:00
|
|
|
ForceRefresh();
|
|
|
|
}
|
1998-07-29 17:39:28 +00:00
|
|
|
NS_RELEASE(shell);
|
1998-07-27 18:17:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-21 00:48:35 +00:00
|
|
|
void
|
|
|
|
nsBrowserWindow::DoDebugRobot()
|
|
|
|
{
|
|
|
|
mApp->CreateRobot(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBrowserWindow::DoSiteWalker()
|
|
|
|
{
|
|
|
|
mApp->CreateSiteWalker(this);
|
|
|
|
}
|
|
|
|
|
1998-07-20 21:16:38 +00:00
|
|
|
nsEventStatus
|
1998-07-20 22:13:11 +00:00
|
|
|
nsBrowserWindow::DispatchDebugMenu(PRInt32 aID)
|
1998-07-20 21:16:38 +00:00
|
|
|
{
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
|
1998-07-20 22:13:11 +00:00
|
|
|
switch(aID) {
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_VISUAL_DEBUGGING:
|
|
|
|
ToggleFrameBorders();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
2000-02-15 04:33:43 +00:00
|
|
|
case VIEWER_VISUAL_EVENT_DEBUGGING:
|
|
|
|
ToggleVisualEventDebugging();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_PAINT_FLASHING:
|
|
|
|
ToggleBoolPrefAndRefresh("nglayout.debug.paint_flashing");
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_PAINT_DUMPING:
|
|
|
|
ToggleBoolPrefAndRefresh("nglayout.debug.paint_dumping");
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_INVALIDATE_DUMPING:
|
|
|
|
ToggleBoolPrefAndRefresh("nglayout.debug.invalidate_dumping");
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_EVENT_DUMPING:
|
|
|
|
ToggleBoolPrefAndRefresh("nglayout.debug.event_dumping");
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_MOTION_EVENT_DUMPING:
|
|
|
|
ToggleBoolPrefAndRefresh("nglayout.debug.motion_event_dumping");
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1999-09-09 02:32:54 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_CROSSING_EVENT_DUMPING:
|
|
|
|
ToggleBoolPrefAndRefresh("nglayout.debug.crossing_event_dumping");
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1999-09-07 19:36:45 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DUMP_CONTENT:
|
|
|
|
DumpContent();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DUMP_FRAMES:
|
|
|
|
DumpFrames();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DUMP_VIEWS:
|
|
|
|
DumpViews();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DUMP_STYLE_SHEETS:
|
|
|
|
DumpStyleSheets();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DUMP_STYLE_CONTEXTS:
|
|
|
|
DumpStyleContexts();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
2000-04-28 23:38:19 +00:00
|
|
|
case VIEWER_DEBUG_DUMP_REFLOW_TOTS:
|
|
|
|
DumpReflowStats();
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
2001-03-13 01:53:45 +00:00
|
|
|
case VIEWER_DSP_REFLOW_CNTS_ON:
|
|
|
|
DisplayReflowStats(PR_TRUE);
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_DSP_REFLOW_CNTS_OFF:
|
|
|
|
DisplayReflowStats(PR_FALSE);
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_SHOW_CONTENT_QUALITY:
|
1999-12-17 08:13:54 +00:00
|
|
|
if (nsnull != mDocShell) {
|
|
|
|
nsIPresShell *ps = GetPresShellFor(mDocShell);
|
1999-10-05 23:59:59 +00:00
|
|
|
nsIViewManager *vm = nsnull;
|
|
|
|
PRBool qual;
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
if (ps) {
|
|
|
|
ps->GetViewManager(&vm);
|
1998-07-20 21:16:38 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
if (vm) {
|
|
|
|
vm->GetShowQuality(qual);
|
|
|
|
vm->ShowQuality(!qual);
|
1999-02-16 00:55:15 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_RELEASE(vm);
|
|
|
|
}
|
1999-02-16 00:55:15 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
NS_RELEASE(ps);
|
|
|
|
}
|
1999-02-16 00:55:15 +00:00
|
|
|
}
|
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-07-20 22:22:13 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DEBUGSAVE:
|
|
|
|
DoDebugSave();
|
|
|
|
break;
|
1998-07-21 00:48:35 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOGGLE_SELECTION:
|
|
|
|
DoToggleSelection();
|
|
|
|
break;
|
1998-07-27 18:17:07 +00:00
|
|
|
|
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_DEBUGROBOT:
|
|
|
|
DoDebugRobot();
|
|
|
|
break;
|
1998-07-21 00:48:35 +00:00
|
|
|
|
1999-10-05 23:59:59 +00:00
|
|
|
case VIEWER_TOP100:
|
|
|
|
DoSiteWalker();
|
|
|
|
break;
|
1999-01-23 07:10:37 +00:00
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // NS_DEBUG
|
|
|
|
|
2000-03-20 23:39:22 +00:00
|
|
|
#define USE_DTD 0
|
|
|
|
#define STANDARD 1
|
|
|
|
#define QUIRKS 2
|
1999-01-23 07:10:37 +00:00
|
|
|
void
|
2000-03-20 23:39:22 +00:00
|
|
|
nsBrowserWindow::SetCompatibilityMode(PRUint32 aMode)
|
1999-01-23 07:10:37 +00:00
|
|
|
{
|
2000-09-13 23:57:52 +00:00
|
|
|
nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID));
|
2000-03-02 07:13:02 +00:00
|
|
|
if (pref) {
|
2000-03-20 23:39:22 +00:00
|
|
|
int32 prefInt = USE_DTD;
|
|
|
|
if (STANDARD == aMode) {
|
2002-06-25 21:16:17 +00:00
|
|
|
prefInt = eCompatibility_FullStandards;
|
2000-03-20 23:39:22 +00:00
|
|
|
}
|
|
|
|
else if (QUIRKS == aMode) {
|
|
|
|
prefInt = eCompatibility_NavQuirks;
|
|
|
|
}
|
2000-03-02 07:13:02 +00:00
|
|
|
pref->SetIntPref("nglayout.compatibility.mode", prefInt);
|
2001-04-26 18:41:11 +00:00
|
|
|
pref->SavePrefFile(nsnull);
|
1999-01-23 07:10:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsEventStatus
|
|
|
|
nsBrowserWindow::DispatchStyleMenu(PRInt32 aID)
|
|
|
|
{
|
|
|
|
nsEventStatus result = nsEventStatus_eIgnore;
|
|
|
|
|
|
|
|
switch(aID) {
|
|
|
|
case VIEWER_SELECT_STYLE_LIST:
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsAutoString defaultStyle;
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
shell->GetDocument(getter_AddRefs(doc));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (doc) {
|
1999-02-12 06:19:07 +00:00
|
|
|
nsIAtom* defStyleAtom = NS_NewAtom("default-style");
|
1999-01-23 07:10:37 +00:00
|
|
|
doc->GetHeaderData(defStyleAtom, defaultStyle);
|
|
|
|
NS_RELEASE(defStyleAtom);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsStringArray titles;
|
|
|
|
shell->ListAlternateStyleSheets(titles);
|
|
|
|
nsAutoString current;
|
|
|
|
shell->GetActiveAlternateStyleSheet(current);
|
|
|
|
|
|
|
|
PRInt32 count = titles.Count();
|
|
|
|
fprintf(stdout, "There %s %d alternate style sheet%s\n",
|
|
|
|
((1 == count) ? "is" : "are"),
|
|
|
|
count,
|
|
|
|
((1 == count) ? "" : "s"));
|
|
|
|
PRInt32 index;
|
|
|
|
for (index = 0; index < count; index++) {
|
|
|
|
fprintf(stdout, "%d: \"", index + 1);
|
|
|
|
nsAutoString title;
|
|
|
|
titles.StringAt(index, title);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(title).get(), stdout);
|
1999-01-23 07:10:37 +00:00
|
|
|
fprintf(stdout, "\" %s%s\n",
|
2002-02-19 22:49:12 +00:00
|
|
|
((title.Equals(current, nsCaseInsensitiveStringComparator())) ? "<< current " : ""),
|
|
|
|
((title.Equals(defaultStyle, nsCaseInsensitiveStringComparator())) ? "** default" : ""));
|
1999-01-23 07:10:37 +00:00
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SELECT_STYLE_DEFAULT:
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
shell->GetDocument(getter_AddRefs(doc));
|
1999-02-12 18:41:26 +00:00
|
|
|
if (doc) {
|
1999-01-23 07:10:37 +00:00
|
|
|
nsAutoString defaultStyle;
|
1999-02-12 06:19:07 +00:00
|
|
|
nsIAtom* defStyleAtom = NS_NewAtom("default-style");
|
1999-01-23 07:10:37 +00:00
|
|
|
doc->GetHeaderData(defStyleAtom, defaultStyle);
|
|
|
|
NS_RELEASE(defStyleAtom);
|
|
|
|
fputs("Selecting default style sheet \"", stdout);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(defaultStyle).get(), stdout);
|
1999-01-23 07:10:37 +00:00
|
|
|
fputs("\"\n", stdout);
|
|
|
|
shell->SelectAlternateStyleSheet(defaultStyle);
|
|
|
|
}
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIEWER_SELECT_STYLE_ONE:
|
|
|
|
case VIEWER_SELECT_STYLE_TWO:
|
|
|
|
case VIEWER_SELECT_STYLE_THREE:
|
|
|
|
case VIEWER_SELECT_STYLE_FOUR:
|
|
|
|
{
|
|
|
|
nsIPresShell* shell = GetPresShell();
|
|
|
|
if (nsnull != shell) {
|
|
|
|
nsStringArray titles;
|
|
|
|
shell->ListAlternateStyleSheets(titles);
|
|
|
|
nsAutoString title;
|
|
|
|
titles.StringAt(aID - VIEWER_SELECT_STYLE_ONE, title);
|
|
|
|
fputs("Selecting alternate style sheet \"", stdout);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(title).get(), stdout);
|
1999-01-23 07:10:37 +00:00
|
|
|
fputs("\"\n", stdout);
|
|
|
|
shell->SelectAlternateStyleSheet(title);
|
|
|
|
NS_RELEASE(shell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
|
|
|
break;
|
1998-09-23 23:02:54 +00:00
|
|
|
|
2000-03-20 23:39:22 +00:00
|
|
|
case VIEWER_USE_DTD_MODE:
|
1998-09-23 23:02:54 +00:00
|
|
|
case VIEWER_NAV_QUIRKS_MODE:
|
|
|
|
case VIEWER_STANDARD_MODE:
|
2000-03-20 23:39:22 +00:00
|
|
|
SetCompatibilityMode(aID - VIEWER_USE_DTD_MODE);
|
1999-01-23 07:10:37 +00:00
|
|
|
result = nsEventStatus_eConsumeNoDefault;
|
1998-09-23 23:02:54 +00:00
|
|
|
break;
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
1999-01-23 07:10:37 +00:00
|
|
|
return result;
|
1998-07-20 21:16:38 +00:00
|
|
|
}
|
|
|
|
|
2000-02-02 02:51:36 +00:00
|
|
|
NS_IMETHODIMP nsBrowserWindow::EnsureWebBrowserChrome()
|
|
|
|
{
|
|
|
|
if(mWebBrowserChrome)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
mWebBrowserChrome = new nsWebBrowserChrome();
|
|
|
|
NS_ENSURE_TRUE(mWebBrowserChrome, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
NS_ADDREF(mWebBrowserChrome);
|
|
|
|
mWebBrowserChrome->BrowserWindow(this);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-20 21:16:38 +00:00
|
|
|
|
2002-05-07 12:03:37 +00:00
|
|
|
nsresult nsBrowserWindow::GetWindow(nsIWidget** aWindow)
|
|
|
|
{
|
|
|
|
if (aWindow && mWindow) {
|
|
|
|
*aWindow = mWindow.get();
|
|
|
|
NS_IF_ADDREF(*aWindow);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-07-20 16:19:22 +00:00
|
|
|
|