1998-07-24 21:19:44 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03: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-24 21:19:44 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03: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-24 21:19:44 +04:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-07-24 21:19:44 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-07-24 21:19:44 +04:00
|
|
|
*/
|
1998-09-12 04:06:05 +04:00
|
|
|
|
1999-10-21 04:13:07 +04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
1998-07-24 21:19:44 +04:00
|
|
|
#include "nsViewerApp.h"
|
|
|
|
#include "nsBrowserWindow.h"
|
|
|
|
#include "nsIImageManager.h"
|
1998-09-22 08:21:31 +04:00
|
|
|
#include "nsIWidget.h"
|
1999-10-09 07:01:43 +04:00
|
|
|
#include "nsIServiceManager.h"
|
1998-09-22 08:21:31 +04:00
|
|
|
#include "resources.h"
|
|
|
|
|
1998-09-23 13:23:07 +04:00
|
|
|
#include <ToolUtils.h> // MacOS includes
|
1998-09-22 08:21:31 +04:00
|
|
|
#include <Menus.h>
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <Devices.h>
|
|
|
|
#include <Resources.h>
|
|
|
|
#include <Dialogs.h>
|
|
|
|
|
1998-09-23 13:23:07 +04:00
|
|
|
#include "nsMacMessagePump.h" // for the windowless menu event handler
|
1999-10-21 04:13:07 +04:00
|
|
|
#include "nsILeakDetector.h"
|
1999-01-27 08:21:43 +03:00
|
|
|
|
1999-01-08 06:27:57 +03:00
|
|
|
#include "macstdlibextras.h"
|
|
|
|
|
2000-02-08 01:32:40 +03:00
|
|
|
typedef SInt32 MessageT;
|
|
|
|
typedef PRUint32 Uint32;
|
|
|
|
const MessageT cmd_Undo = 11; // nil
|
|
|
|
const MessageT cmd_Cut = 12; // nil
|
|
|
|
const MessageT cmd_Copy = 13; // nil
|
|
|
|
const MessageT cmd_Paste = 14; // nil
|
|
|
|
const MessageT cmd_Clear = 15; // nil
|
|
|
|
const MessageT cmd_SelectAll = 16; // nil
|
|
|
|
|
|
|
|
const MessageT cmd_About = 1; // nil
|
|
|
|
|
|
|
|
// File Menu
|
|
|
|
const MessageT cmd_New = 2; // nil
|
|
|
|
const MessageT cmd_Open = 3; // nil
|
|
|
|
const MessageT cmd_Close = 4; // nil
|
|
|
|
const MessageT cmd_Save = 5; // nil
|
|
|
|
const MessageT cmd_SaveAs = 6; // nil
|
|
|
|
const MessageT cmd_Revert = 7; // nil
|
|
|
|
const MessageT cmd_PageSetup = 8; // nil
|
|
|
|
const MessageT cmd_Print = 9; // nil
|
|
|
|
const MessageT cmd_PrintOne = 17; // nil
|
|
|
|
const MessageT cmd_Quit = 10; // nil
|
|
|
|
const MessageT cmd_Preferences = 27; // nil
|
|
|
|
|
|
|
|
|
1998-09-23 13:23:07 +04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
menu_First = 128,
|
|
|
|
menu_Apple = menu_First,
|
|
|
|
menu_File,
|
|
|
|
menu_Edit,
|
|
|
|
menu_Sample,
|
1998-12-08 05:16:42 +03:00
|
|
|
menu_Debug,
|
|
|
|
menu_Tools,
|
|
|
|
menu_Last = menu_Tools,
|
1998-09-23 13:23:07 +04:00
|
|
|
|
|
|
|
submenu_Print = 16,
|
1999-01-11 22:46:49 +03:00
|
|
|
submenu_CompatibilityMode = 32,
|
|
|
|
|
|
|
|
cmd_Sample0 = 1000,
|
1999-03-05 23:21:25 +03:00
|
|
|
cmd_FirstXPToolkitSample = 1100,
|
1998-09-23 13:23:07 +04:00
|
|
|
cmd_PrintOneColumn = 2000,
|
1999-01-11 22:46:49 +03:00
|
|
|
cmd_Find = 3000,
|
1999-01-27 08:21:43 +03:00
|
|
|
|
|
|
|
cmd_ViewSource = 2200,
|
1999-03-09 09:39:50 +03:00
|
|
|
cmd_PrintSetup,
|
1999-01-27 08:21:43 +03:00
|
|
|
|
1999-01-11 22:46:49 +03:00
|
|
|
cmd_DebugMode = 4000,
|
|
|
|
cmd_ReflowTest,
|
|
|
|
cmd_DumpContents,
|
|
|
|
cmd_DumpFrames,
|
|
|
|
cmd_DumpViews,
|
|
|
|
cmd_DumpStyleSheets,
|
|
|
|
cmd_DumpStyleContexts,
|
|
|
|
cmd_ShowContentSize,
|
|
|
|
cmd_ShowFrameSize,
|
|
|
|
cmd_ShowStyleSize,
|
|
|
|
cmd_DebugSave,
|
1999-03-06 23:54:03 +03:00
|
|
|
cmd_DebugOutputText,
|
|
|
|
cmd_DebugOutputHTML,
|
1999-01-11 22:46:49 +03:00
|
|
|
cmd_DebugToggleSelection,
|
1998-12-08 05:16:42 +03:00
|
|
|
cmd_DebugRobot,
|
1999-01-11 22:46:49 +03:00
|
|
|
cmd_ShowContentQuality,
|
1999-03-09 07:39:50 +03:00
|
|
|
cmd_GFXWidgetMode,
|
|
|
|
cmd_NativeWidgetMode,
|
1999-10-09 07:01:43 +04:00
|
|
|
cmd_DumpLeaks,
|
1999-03-09 07:39:50 +03:00
|
|
|
|
|
|
|
item_GFXWidgetMode = 24,
|
|
|
|
item_NativeWidgetMode,
|
|
|
|
|
1999-01-11 22:46:49 +03:00
|
|
|
cmd_Compatibility_NavQuirks = 4200,
|
|
|
|
cmd_Compatibility_Standard,
|
|
|
|
|
|
|
|
cmd_JSConsole = 5000,
|
1998-12-08 05:16:42 +03:00
|
|
|
cmd_EditorMode,
|
1999-01-11 22:46:49 +03:00
|
|
|
cmd_Top100,
|
|
|
|
cmd_TableInspector,
|
|
|
|
cmd_ImageInspector
|
1998-09-23 13:23:07 +04:00
|
|
|
};
|
1998-07-24 21:19:44 +04:00
|
|
|
|
|
|
|
static nsNativeViewerApp* gTheApp;
|
|
|
|
|
1998-10-29 17:06:26 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1998-07-24 21:19:44 +04:00
|
|
|
nsNativeViewerApp::nsNativeViewerApp()
|
|
|
|
{
|
1998-09-23 13:23:07 +04:00
|
|
|
nsMacMessagePump::SetWindowlessMenuEventHandler(DispatchMenuItemWithoutWindow);
|
1998-07-24 21:19:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsNativeViewerApp::~nsNativeViewerApp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
nsNativeViewerApp::Run()
|
|
|
|
{
|
|
|
|
OpenWindow();
|
|
|
|
mAppShell->Run();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-09-23 13:23:07 +04:00
|
|
|
void nsNativeViewerApp::DispatchMenuItemWithoutWindow(PRInt32 menuResult)
|
|
|
|
{
|
|
|
|
long menuID = HiWord(menuResult);
|
|
|
|
long menuItem = LoWord(menuResult);
|
|
|
|
switch (menuID)
|
|
|
|
{
|
|
|
|
case menu_Apple:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
|
|
|
case cmd_About:
|
|
|
|
::Alert(128, nil);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Str255 daName;
|
|
|
|
GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName);
|
1999-05-12 10:44:03 +04:00
|
|
|
#if !TARGET_CARBON
|
1998-09-23 13:23:07 +04:00
|
|
|
OpenDeskAcc(daName);
|
1999-05-12 01:32:51 +04:00
|
|
|
#endif
|
1998-09-23 13:23:07 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case menu_File:
|
|
|
|
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
|
|
|
case cmd_New:
|
|
|
|
gTheApp->OpenWindow();
|
|
|
|
break;
|
|
|
|
case cmd_Open:
|
|
|
|
nsBrowserWindow * newWindow;
|
|
|
|
gTheApp->OpenWindow(0, newWindow);
|
|
|
|
newWindow->DoFileOpen();
|
|
|
|
break;
|
|
|
|
case cmd_Quit:
|
|
|
|
gTheApp->Exit();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1998-12-03 20:59:13 +03:00
|
|
|
}
|
1998-09-23 13:23:07 +04:00
|
|
|
}
|
|
|
|
|
1998-10-29 17:06:26 +03:00
|
|
|
#pragma mark -
|
1998-07-24 21:19:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsNativeBrowserWindow::nsNativeBrowserWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsNativeBrowserWindow::~nsNativeBrowserWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1999-01-27 08:21:43 +03:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsNativeBrowserWindow::InitNativeWindow()
|
|
|
|
{
|
|
|
|
// this is where we get a chance to set up the window refCon
|
|
|
|
NS_PRECONDITION(nsnull != mWindow, "Null window in InitNativeWindow");
|
|
|
|
|
1999-05-12 01:32:51 +04:00
|
|
|
WindowPtr wind = (WindowPtr)mWindow->GetNativeData(NS_NATIVE_DISPLAY);
|
1999-01-27 08:21:43 +03:00
|
|
|
if (!wind) return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
::SetWRefCon(wind, (long)this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CloseFrontWindow()
|
|
|
|
{
|
|
|
|
WindowPtr wind = ::FrontWindow();
|
|
|
|
if (!wind) return;
|
|
|
|
|
|
|
|
nsBrowserWindow *browserWindow = (nsBrowserWindow *)GetWRefCon(wind);
|
|
|
|
if (!browserWindow) return;
|
|
|
|
|
|
|
|
browserWindow->Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-24 21:19:44 +04:00
|
|
|
nsresult
|
|
|
|
nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth)
|
|
|
|
{
|
1998-09-22 08:21:31 +04:00
|
|
|
for (int i = menu_First; i <= menu_Last; i++)
|
|
|
|
{
|
|
|
|
InsertMenu(GetMenu(i), 0);
|
|
|
|
}
|
|
|
|
InsertMenu(GetMenu(submenu_Print), -1);
|
1999-01-11 22:46:49 +03:00
|
|
|
InsertMenu(GetMenu(submenu_CompatibilityMode), -1);
|
1998-09-22 08:21:31 +04:00
|
|
|
AppendResMenu(GetMenuHandle(menu_Apple), 'DRVR');
|
|
|
|
DrawMenuBar();
|
|
|
|
return NS_OK;
|
1998-07-24 21:19:44 +04:00
|
|
|
}
|
|
|
|
|
1999-09-01 14:48:28 +04:00
|
|
|
nsresult
|
|
|
|
nsNativeBrowserWindow::GetMenuBarHeight(PRInt32 * aHeightOut)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(nsnull != aHeightOut,"null out param.");
|
|
|
|
|
|
|
|
*aHeightOut = 0;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-24 21:19:44 +04:00
|
|
|
nsEventStatus
|
|
|
|
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
|
|
|
|
{
|
1999-02-21 05:01:16 +03:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
1998-09-22 08:21:31 +04:00
|
|
|
PRInt32 xpID = 0;
|
|
|
|
long menuID = HiWord(aID);
|
|
|
|
long menuItem = LoWord(aID);
|
|
|
|
|
|
|
|
switch (menuID)
|
|
|
|
{
|
|
|
|
case menu_Apple:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
|
|
|
case cmd_About:
|
|
|
|
::Alert(128, nil);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Str255 daName;
|
|
|
|
GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName);
|
1999-05-12 10:44:03 +04:00
|
|
|
#if !TARGET_CARBON
|
1998-09-22 08:21:31 +04:00
|
|
|
OpenDeskAcc(daName);
|
1999-05-12 01:32:51 +04:00
|
|
|
#endif
|
1998-09-22 08:21:31 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case menu_File:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
1999-01-27 08:21:43 +03:00
|
|
|
case cmd_New: xpID = VIEWER_WINDOW_OPEN; break;
|
|
|
|
case cmd_Open: xpID = VIEWER_FILE_OPEN; break;
|
1998-09-22 08:21:31 +04:00
|
|
|
case cmd_Close:
|
1999-01-27 08:21:43 +03:00
|
|
|
CloseFrontWindow();
|
1999-02-21 05:01:16 +03:00
|
|
|
status = nsEventStatus_eConsumeNoDefault;
|
1998-09-22 08:21:31 +04:00
|
|
|
break;
|
1999-01-27 08:21:43 +03:00
|
|
|
|
1999-03-09 09:39:50 +03:00
|
|
|
case cmd_ViewSource: xpID = VIEW_SOURCE; break;
|
1999-01-27 08:21:43 +03:00
|
|
|
case cmd_Save: /*n.a.*/ break;
|
|
|
|
case cmd_SaveAs: /*n.a.*/ break;
|
|
|
|
case cmd_Revert: /*n.a.*/ break;
|
1998-09-22 08:21:31 +04:00
|
|
|
case cmd_PageSetup: /*n.a.*/ break;
|
1999-03-09 09:39:50 +03:00
|
|
|
case cmd_Print: xpID = VIEWER_PRINT; break;
|
|
|
|
case cmd_PrintSetup: xpID = VIEWER_PRINT_SETUP; break;
|
|
|
|
case cmd_Quit: xpID = VIEWER_EXIT; break;
|
1998-09-22 08:21:31 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case menu_Edit:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
1999-01-27 08:21:43 +03:00
|
|
|
case cmd_Undo: /*n.a.*/ break;
|
|
|
|
case cmd_Cut: xpID = VIEWER_EDIT_CUT; break;
|
|
|
|
case cmd_Copy: xpID = VIEWER_EDIT_COPY; break;
|
|
|
|
case cmd_Paste: xpID = VIEWER_EDIT_PASTE; break;
|
|
|
|
case cmd_Clear: /*n.a.*/ break;
|
|
|
|
case cmd_SelectAll: xpID = VIEWER_EDIT_SELECTALL; break;
|
|
|
|
case cmd_Find: xpID = VIEWER_EDIT_FINDINPAGE; break;
|
|
|
|
case cmd_Preferences: xpID = VIEWER_PREFS; break;
|
1998-09-22 08:21:31 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case menu_Sample:
|
1999-03-05 23:21:25 +03:00
|
|
|
if ( menuItem < cmd_FirstXPToolkitSample )
|
|
|
|
xpID = VIEWER_DEMO0 + menuItem - cmd_Sample0;
|
|
|
|
else
|
|
|
|
xpID = VIEWER_XPTOOLKITDEMOBASE + (menuItem - cmd_FirstXPToolkitSample);
|
1998-09-22 08:21:31 +04:00
|
|
|
break;
|
|
|
|
|
1998-12-08 05:16:42 +03:00
|
|
|
case menu_Debug:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
1999-01-11 22:46:49 +03:00
|
|
|
case cmd_DebugMode: xpID = VIEWER_VISUAL_DEBUGGING; break;
|
|
|
|
case cmd_ReflowTest: xpID = VIEWER_REFLOW_TEST; break;
|
|
|
|
|
|
|
|
case cmd_DumpContents: xpID = VIEWER_DUMP_CONTENT; break;
|
|
|
|
case cmd_DumpFrames: xpID = VIEWER_DUMP_FRAMES; break;
|
|
|
|
case cmd_DumpViews: xpID = VIEWER_DUMP_VIEWS; break;
|
|
|
|
|
|
|
|
case cmd_DumpStyleSheets: xpID = VIEWER_DUMP_STYLE_SHEETS; break;
|
|
|
|
case cmd_DumpStyleContexts: xpID = VIEWER_DUMP_STYLE_CONTEXTS; break;
|
|
|
|
|
|
|
|
case cmd_ShowContentSize: xpID = VIEWER_SHOW_CONTENT_SIZE; break;
|
|
|
|
case cmd_ShowFrameSize: xpID = VIEWER_SHOW_FRAME_SIZE; break;
|
|
|
|
case cmd_ShowStyleSize: xpID = VIEWER_SHOW_STYLE_SIZE; break;
|
|
|
|
|
1999-03-06 23:54:03 +03:00
|
|
|
case cmd_DebugSave: xpID = VIEWER_DEBUGSAVE; break;
|
|
|
|
case cmd_DebugOutputText: xpID = VIEWER_DISPLAYTEXT; break;
|
|
|
|
case cmd_DebugOutputHTML: xpID = VIEWER_DISPLAYHTML; break;
|
1999-01-11 22:46:49 +03:00
|
|
|
case cmd_DebugToggleSelection: xpID = VIEWER_TOGGLE_SELECTION; break;
|
|
|
|
case cmd_DebugRobot: xpID = VIEWER_DEBUGROBOT; break;
|
|
|
|
case cmd_ShowContentQuality: xpID =VIEWER_SHOW_CONTENT_QUALITY; break;
|
1999-10-09 07:01:43 +04:00
|
|
|
case cmd_DumpLeaks:
|
1999-10-21 04:13:07 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
NS_WITH_SERVICE(nsILeakDetector, leakDetector, "component://netscape/xpcom/leakdetector", &rv)
|
|
|
|
if (NS_SUCCEEDED(rv))
|
|
|
|
leakDetector->DumpLeaks();
|
|
|
|
}
|
1999-10-09 07:01:43 +04:00
|
|
|
break;
|
1998-12-08 05:16:42 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case menu_Tools:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
1999-01-11 22:46:49 +03:00
|
|
|
case cmd_JSConsole: xpID = JS_CONSOLE; break;
|
|
|
|
case cmd_EditorMode: xpID = EDITOR_MODE; break;
|
|
|
|
case cmd_Top100: xpID = VIEWER_TOP100; break;
|
|
|
|
case cmd_TableInspector: xpID = VIEWER_TABLE_INSPECTOR; break;
|
|
|
|
case cmd_ImageInspector: xpID = VIEWER_IMAGE_INSPECTOR; break;
|
1998-12-08 05:16:42 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1998-09-22 08:21:31 +04:00
|
|
|
case submenu_Print:
|
|
|
|
xpID = VIEWER_ONE_COLUMN + menuItem - cmd_PrintOneColumn;
|
|
|
|
break;
|
1999-01-11 22:46:49 +03:00
|
|
|
|
|
|
|
case submenu_CompatibilityMode:
|
|
|
|
switch (menuItem)
|
|
|
|
{
|
|
|
|
case cmd_Compatibility_NavQuirks: xpID = VIEWER_NAV_QUIRKS_MODE; break;
|
|
|
|
case cmd_Compatibility_Standard: xpID = VIEWER_STANDARD_MODE; break;
|
|
|
|
}
|
|
|
|
break;
|
1998-09-22 08:21:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Dispatch xp menu items
|
1999-03-03 01:30:02 +03:00
|
|
|
if (xpID != 0) {
|
|
|
|
// beard: nsBrowserWindow::DispatchMenuItem almost always returns nsEventStatus_eIgnore.
|
|
|
|
// this causes double menu item dispatching for most items except for VIEWER_EXIT!
|
|
|
|
nsBrowserWindow::DispatchMenuItem(xpID);
|
|
|
|
status = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
|
|
|
return status;
|
1998-07-24 21:19:44 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 04:49:52 +03:00
|
|
|
/**
|
|
|
|
* Quit AppleEvent handler.
|
|
|
|
*/
|
|
|
|
static pascal OSErr handleQuitApplication(const AppleEvent*, AppleEvent*, long)
|
|
|
|
{
|
|
|
|
if (gTheApp != nsnull) {
|
|
|
|
gTheApp->Exit();
|
|
|
|
} else {
|
|
|
|
ExitToShell();
|
|
|
|
}
|
|
|
|
return noErr;
|
|
|
|
}
|
|
|
|
|
1998-10-29 17:06:26 +03:00
|
|
|
#pragma mark -
|
1998-07-24 21:19:44 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
1999-10-09 07:01:43 +04:00
|
|
|
// Set up the toolbox and (if DEBUG) the console
|
|
|
|
InitializeMacToolbox();
|
|
|
|
|
1999-11-02 04:49:52 +03:00
|
|
|
// Install an a Quit AppleEvent handler.
|
|
|
|
OSErr err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
|
|
|
|
NewAEEventHandlerProc(handleQuitApplication), 0, false);
|
|
|
|
NS_ASSERTION((err==noErr), "AEInstallEventHandler failed");
|
|
|
|
|
1999-10-09 07:01:43 +04:00
|
|
|
// Start up XPCOM?
|
2000-01-06 04:05:13 +03:00
|
|
|
nsresult rv = NS_InitXPCOM(nsnull, nsnull);
|
1999-10-09 07:01:43 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
|
|
|
|
|
|
|
|
// Hack to get il_ss set so it doesn't fail in xpcompat.c
|
1999-11-24 06:40:05 +03:00
|
|
|
// looks like we don't need this any more.
|
|
|
|
// nsCOMPtr<nsIImageManager> manager = do_GetService(kImageManagerCID, &rv);
|
|
|
|
// NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get image manager service");
|
|
|
|
|
1999-10-09 07:01:43 +04:00
|
|
|
gTheApp = new nsNativeViewerApp();
|
|
|
|
if (gTheApp != nsnull) {
|
|
|
|
NS_ADDREF(gTheApp);
|
|
|
|
if (gTheApp->Initialize(argc, argv) == NS_OK)
|
|
|
|
gTheApp->Run();
|
|
|
|
NS_RELEASE(gTheApp);
|
|
|
|
}
|
1998-07-24 21:19:44 +04:00
|
|
|
|
1999-11-02 04:49:52 +03:00
|
|
|
#ifdef DETECT_WEBSHELL_LEAKS
|
|
|
|
if ( unsigned long count = NS_TotalWebShellsInExistence() ) {
|
|
|
|
printf("XXX WARNING: Number of webshells being leaked: %d \n", count);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-10-09 07:01:43 +04:00
|
|
|
// Shutdown XPCOM?
|
|
|
|
rv = NS_ShutdownXPCOM(nsnull);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
1998-07-24 21:19:44 +04:00
|
|
|
|
1999-10-09 07:01:43 +04:00
|
|
|
return 0;
|
1998-07-24 21:19:44 +04:00
|
|
|
}
|