This commit is contained in:
rods%netscape.com 1998-09-28 16:57:48 +00:00
Родитель a243ab3425
Коммит 03fd04ab9b
11 изменённых файлов: 6944 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,970 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
//is case this is defined from the outside... MMP
#ifdef WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif
#include "JSConsole.h"
#include "jsconsres.h"
#include "nsIScriptContext.h"
#include <stdio.h>
#include "jsapi.h"
HINSTANCE JSConsole::sAppInstance = 0;
HACCEL JSConsole::sAccelTable = 0;
CHAR JSConsole::sDefaultCaption[] = "JavaScript Console";
BOOL JSConsole::mRegistered = FALSE;
// display an error string along with the error returned from
// the GetLastError functions
#define MESSAGE_LENGTH 256
void DisplayError(LPSTR lpMessage)
{
CHAR lpMsgBuf[MESSAGE_LENGTH * 2];
CHAR lpLastError[MESSAGE_LENGTH];
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
0,
(LPTSTR)&lpLastError,
MESSAGE_LENGTH,
NULL);
strcpy(lpMsgBuf, lpMessage);
strcat(lpMsgBuf, "\nThe WWS (Worthless Windows System) reports:\n");
strcat(lpMsgBuf, lpLastError);
// Display the string.
::MessageBox(NULL, lpMsgBuf, "JSConsole Error", MB_OK | MB_ICONSTOP);
}
#if defined(_DEBUG)
#define VERIFY(value, errorCondition, message) \
if((value) == (errorCondition)) DisplayError(message);
#else // !_DEBUG
#define VERIFY(value, errorCondition, message) (value)
#endif // _DEBUG
//
// Register the window class
//
BOOL JSConsole::RegisterWidget()
{
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = JSConsole::WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = JSConsole::sAppInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = MAKEINTRESOURCE(JSCONSOLE_MENU);
wc.lpszClassName = "JavaScript Console";
return (BOOL)::RegisterClass(&wc);
}
//
// Create the main application window
//
JSConsole* JSConsole::CreateConsole()
{
if (!JSConsole::mRegistered){
JSConsole::mRegistered = RegisterWidget();
}
HWND hWnd = ::CreateWindowEx(WS_EX_ACCEPTFILES |
WS_EX_CLIENTEDGE |
WS_EX_CONTROLPARENT,
"JavaScript Console",
JSConsole::sDefaultCaption,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
450,
500,
NULL,
NULL,
JSConsole::sAppInstance,
NULL);
if (hWnd) {
::ShowWindow(hWnd, SW_SHOW);
::UpdateWindow(hWnd);
JSConsole *console = (JSConsole*)::GetWindowLong(hWnd, GWL_USERDATA);
return console;
}
return NULL;
}
//
// Window Procedure
//
LRESULT CALLBACK JSConsole::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
JSConsole *console = (JSConsole*)::GetWindowLong(hWnd, GWL_USERDATA);
// just ignore the message unless is WM_NCCREATE
if (!console) {
if (uMsg == WM_NCCREATE) {
HWND hWndEdit = ::CreateWindow("EDIT",
NULL,
WS_CHILDWINDOW | WS_VISIBLE | ES_MULTILINE |
ES_AUTOHSCROLL | ES_AUTOVSCROLL |
WS_HSCROLL | WS_VSCROLL,
0, 0, 0, 0,
hWnd,
NULL,
JSConsole::sAppInstance,
NULL);
if (!hWndEdit) {
::DisplayError("Cannot Create Edit Window");
return FALSE;
}
::SendMessage(hWndEdit, EM_SETLIMITTEXT, (WPARAM)0, (LPARAM)0);
console = new JSConsole(hWnd, hWndEdit);
::SetWindowLong(hWnd, GWL_USERDATA, (DWORD)console);
::SetFocus(hWndEdit);
}
#if defined(STRICT)
return ::CallWindowProc((WNDPROC)::DefWindowProc, hWnd, uMsg,
wParam, lParam);
#else
return ::CallWindowProc((FARPROC)::DefWindowProc, hWnd, uMsg,
wParam, lParam);
#endif /* STRICT */
}
switch(uMsg) {
// make sure the edit window covers the whole client area
case WM_SIZE:
return console->OnSize(wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam));
// exit the application
case WM_DESTROY:
console->OnDestroy();
#if defined(STRICT)
return ::CallWindowProc((WNDPROC)::DefWindowProc, hWnd, uMsg,
wParam, lParam);
#else
return ::CallWindowProc((FARPROC)::DefWindowProc, hWnd, uMsg,
wParam, lParam);
#endif /* STRICT */
// enable/disable menu items
case WM_INITMENUPOPUP:
return console->OnInitMenu((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam));
case WM_COMMAND:
// menu or accelerator
if (HIWORD(wParam) == 0 || HIWORD(wParam) == 1) {
switch(LOWORD(wParam)) {
case ID_FILENEW:
console->OnFileNew();
break;
case ID_FILEOPEN:
if (console->OpenFileDialog(OPEN_DIALOG)) {
console->LoadFile();
}
break;
case ID_FILESAVE:
if (console->CanSave()) {
console->SaveFile();
break;
}
// fall through so it can "Save As..."
case ID_FILESAVEAS:
if (console->OpenFileDialog(SAVE_DIALOG)) {
console->SaveFile();
}
break;
case ID_FILEEXIT:
::DestroyWindow(hWnd);
break;
case ID_EDITUNDO:
console->OnEditUndo();
break;
case ID_EDITCUT:
console->OnEditCut();
break;
case ID_EDITCOPY:
console->OnEditCopy();
break;
case ID_EDITPASTE:
console->OnEditPaste();
break;
case ID_EDITDELETE:
console->OnEditDelete();
break;
case ID_EDITSELECTALL:
console->OnEditSelectAll();
break;
case ID_COMMANDSEVALALL:
console->OnCommandEvaluateAll();
break;
case ID_COMMANDSEVALSEL:
console->OnCommandEvaluateSelection();
break;
case ID_COMMANDSINSPECTOR:
console->OnCommandInspector();
break;
}
}
break;
case WM_DROPFILES:
{
HDROP hDropInfo = (HDROP)wParam;
if (::DragQueryFile(hDropInfo, (UINT)-1L, NULL, 0) != 1) {
::MessageBox(hWnd, "Just One File Please...", "JSConsole Error", MB_OK | MB_ICONINFORMATION);
}
else {
CHAR fileName[MAX_PATH];
::DragQueryFile(hDropInfo, 0, fileName, MAX_PATH);
console->SetFileName(fileName);
console->LoadFile();
}
break;
}
case WM_SETFOCUS:
return console->OnSetFocus((HWND)wParam);
default:
#if defined(STRICT)
return ::CallWindowProc((WNDPROC)::DefWindowProc, hWnd, uMsg,
wParam, lParam);
#else
return ::CallWindowProc((FARPROC)::DefWindowProc, hWnd, uMsg,
wParam, lParam);
#endif /* STRICT */
}
return 0;
}
//
// Constructor
// The main window and the edit control must have been created already
//
JSConsole::JSConsole(HWND aMainWindow, HWND aEditControl) :
mMainWindow(aMainWindow),
mEditWindow(aEditControl),
mContext(NULL)
{
mFileInfo.Init();
}
//
// Destructor
//
JSConsole::~JSConsole()
{
}
//
// Load a file into the edit field
//
BOOL JSConsole::LoadFile()
{
BOOL result = FALSE;
if (mMainWindow) {
// open the file
HANDLE file = ::CreateFile(mFileInfo.mCurrentFileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if (file != INVALID_HANDLE_VALUE) {
// check the file size. Max is 64k
DWORD sizeHiWord;
DWORD sizeLoWord = ::GetFileSize(file, &sizeHiWord);
if (sizeLoWord < 0x10000 && sizeHiWord == 0) {
// alloc a buffer big enough to contain the file (account for '\0'
CHAR *buffer = new CHAR[sizeLoWord + 1];
if (buffer) {
// read the file in memory
if (::ReadFile(file,
buffer,
sizeLoWord,
&sizeHiWord,
NULL)) {
NS_ASSERTION(sizeLoWord == sizeHiWord, "ReadFile inconsistency");
buffer[sizeLoWord] = '\0'; // terminate the buffer
// write the file to the edit field
::SendMessage(mEditWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
// update the caption
CHAR caption[80];
::wsprintf(caption,
"%s - %s",
mFileInfo.mCurrentFileName + mFileInfo.mFileOffset,
sDefaultCaption);
::SendMessage(mMainWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)caption);
result = TRUE;
}
else {
::DisplayError("Error Reading the File");
}
// free the allocated buffer
delete[] buffer;
}
else {
::MessageBox(mMainWindow,
"Cannot Allocate Enough Memory to Copy the File in Memory",
"JSConsole Error",
MB_OK | MB_ICONSTOP);
}
}
else {
::MessageBox(mMainWindow,
"File too big. Max is 64k",
"JSConsole Error",
MB_OK | MB_ICONSTOP);
}
// close the file handle
::CloseHandle(file);
}
#ifdef _DEBUG
else {
CHAR message[MAX_PATH + 20];
wsprintf(message, "Cannot Open File: %s", mFileInfo.mCurrentFileName);
::DisplayError(message);
}
#endif
}
return result;
}
//
// Save the current text into a file
//
BOOL JSConsole::SaveFile()
{
BOOL result = FALSE;
if (mMainWindow && mFileInfo.mCurrentFileName[0] != '\0') {
// create the new file
HANDLE file = ::CreateFile(mFileInfo.mCurrentFileName,
GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if (file != INVALID_HANDLE_VALUE) {
DWORD size;
// get the text size
size = ::SendMessage(mEditWindow, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0);
// alloc a buffer big enough to contain the file
CHAR *buffer = new CHAR[++size];
if (buffer) {
DWORD byteRead;
// read the text area content
::SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)size, (LPARAM)buffer);
// write the buffer to disk
if (::WriteFile(file,
buffer,
size,
&byteRead,
NULL)) {
NS_ASSERTION(byteRead == size, "WriteFile inconsistency");
// update the caption
CHAR caption[80];
::wsprintf(caption,
"%s - %s",
mFileInfo.mCurrentFileName + mFileInfo.mFileOffset,
sDefaultCaption);
::SendMessage(mMainWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)caption);
result = TRUE;
}
else {
::DisplayError("Error Writing the File");
}
// free the allocated buffer
delete[] buffer;
}
else {
::MessageBox(mMainWindow,
"Cannot Allocate Enough Memory to Copy the Edit Text in Memory",
"JSConsole Error",
MB_OK | MB_ICONSTOP);
}
// close the file handle
::CloseHandle(file);
}
#ifdef _DEBUG
else {
CHAR message[MAX_PATH + 20];
wsprintf(message, "Cannot Open File: %s", mFileInfo.mCurrentFileName);
::DisplayError(message);
}
#endif
}
return result;
}
//
// Open a FileOpen or FileSave dialog
//
BOOL JSConsole::OpenFileDialog(UINT aWhichDialog)
{
BOOL result = FALSE;
OPENFILENAME ofn;
if (mMainWindow) {
// *.js is the standard File Name on the Save/Open Dialog
if (mFileInfo.mCurrentFileName[0] == '\0')
::strcpy(mFileInfo.mCurrentFileName, "*.js");
// fill the OPENFILENAME sruct
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = mMainWindow;
ofn.hInstance = JSConsole::sAppInstance;
ofn.lpstrFilter = "JavaScript Files (*.js)\0*.js\0Text Files (*.txt)\0*.txt\0All Files\0*.*\0\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1; // the first one in lpstrFilter
ofn.lpstrFile = mFileInfo.mCurrentFileName; // contains the file path name on return
ofn.nMaxFile = sizeof(mFileInfo.mCurrentFileName);
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL; // use default
ofn.lpstrTitle = NULL; // use default
ofn.Flags = OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = "js"; // default extension is .js
ofn.lCustData = NULL;
ofn.lpfnHook = NULL;
ofn.lpTemplateName = NULL;
// call the open file dialog or the save file dialog according to aIsOpenDialog
if (aWhichDialog == OPEN_DIALOG) {
result = ::GetOpenFileName(&ofn);
}
else if (aWhichDialog == SAVE_DIALOG) {
result = ::GetSaveFileName(&ofn);
}
if (!result) {
mFileInfo.mCurrentFileName[0] = '\0';
::CommDlgExtendedError();
}
else {
mFileInfo.mFileOffset = ofn.nFileOffset;
mFileInfo.mFileExtension = ofn.nFileExtension;
}
}
return result;
}
//
// set the mFileInfo structure with the proper value given a generic path
//
void JSConsole::SetFileName(LPSTR aFileName)
{
strcpy(mFileInfo.mCurrentFileName, aFileName);
for (int i = strlen(aFileName); i >= 0; i--) {
if (mFileInfo.mCurrentFileName[i] == '.') {
mFileInfo.mFileExtension = i;
}
if (mFileInfo.mCurrentFileName[i] == '\\') {
mFileInfo.mFileOffset = i + 1;
break;
}
}
}
//
// Move the edit window to cover the all client area
//
LRESULT JSConsole::OnSize(DWORD aResizeFlags, UINT aWidth, UINT aHeight)
{
::MoveWindow(mEditWindow, 0, 0, aWidth, aHeight, TRUE);
RECT textArea;
textArea.left = 3;
textArea.top = 1;
textArea.right = aWidth - 20;
textArea.bottom = aHeight - 17;
::SendMessage(mEditWindow, EM_SETRECTNP, (WPARAM)0, (LPARAM)&textArea);
return 0L;
}
//
// Initialize properly menu items
//
LRESULT JSConsole::OnInitMenu(HMENU aMenu, UINT aPos, BOOL aIsSystem)
{
if (!aIsSystem) {
if (aPos == EDITMENUPOS) {
InitEditMenu(aMenu);
}
else if (aPos == COMMANDSMENUPOS) {
InitCommandMenu(aMenu);
}
}
return 0L;
}
//
// Pass the focus to the edit window
//
LRESULT JSConsole::OnSetFocus(HWND aWnd)
{
::SetFocus(mEditWindow);
return 0L;
}
//
// Destroy message
//
void JSConsole::OnDestroy()
{
if (mDestroyNotification)
(*mDestroyNotification)();
}
//
// File/New. Reset caption, text area and file info
//
void JSConsole::OnFileNew()
{
SendMessage(mEditWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)0);
SendMessage(mMainWindow, WM_SETTEXT, (WPARAM)0, (LPARAM)JSConsole::sDefaultCaption);
mFileInfo.Init();
}
//
// Edit/Undo. Undo the last operation on the edit field
//
void JSConsole::OnEditUndo()
{
SendMessage(mEditWindow, WM_UNDO, (WPARAM)0, (LPARAM)0);
}
//
// Edit/Cut. Cut the current selection
//
void JSConsole::OnEditCut()
{
SendMessage(mEditWindow, WM_CUT, (WPARAM)0, (LPARAM)0);
}
//
// Edit/Copy. Copy the current selection
//
void JSConsole::OnEditCopy()
{
SendMessage(mEditWindow, WM_COPY, (WPARAM)0, (LPARAM)0);
}
//
// Edit/Paste. Paste from the clipboard
//
void JSConsole::OnEditPaste()
{
SendMessage(mEditWindow, WM_PASTE, (WPARAM)0, (LPARAM)0);
}
//
// Edit/Delete. Delete the current selection
//
void JSConsole::OnEditDelete()
{
SendMessage(mEditWindow, WM_CLEAR, (WPARAM)0, (LPARAM)0);
}
//
// Edit/Select All. Select the whole text in the text area
//
void JSConsole::OnEditSelectAll()
{
SendMessage(mEditWindow, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
}
//
// Command/Evaluate All. Take the text area content and evaluate in the js context
//
void JSConsole::OnCommandEvaluateAll()
{
EvaluateText(0, (UINT)-1);
}
//
// Command/Evaluate Selection. Take the current text area selection and evaluate in the js context
//
void JSConsole::OnCommandEvaluateSelection()
{
//
// get the selection and evaluate it
//
DWORD startSel, endSel;
// get selection range
::SendMessage(mEditWindow, EM_GETSEL, (WPARAM)&startSel, (LPARAM)&endSel);
EvaluateText(startSel, endSel);
}
//
// Command/Inspector. Run the js inspector on the global object
//
void JSConsole::OnCommandInspector()
{
::MessageBox(mMainWindow, "Inspector not yet available", "JSConsole Error", MB_OK | MB_ICONINFORMATION);
}
//
// Help
//
void JSConsole::OnHelp()
{
}
//
// private method. Deal with the "Edit" menu
//
void JSConsole::InitEditMenu(HMENU aMenu)
{
CHAR someText[2] = {'\0', '\0'}; // some buffer
// set flags to "disable"
UINT undoFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
UINT cutFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
UINT copyFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
UINT pasteFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
UINT deleteFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
UINT selectAllFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
// check if the edit area has any text
SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)2, (LPARAM)someText);
if (someText[0] != '\0') {
// enable the "Select All"
selectAllFlags = MF_BYPOSITION | MF_ENABLED;
// enable "Copy/Cut/Paste" if there is any selection
UINT startPos, endPos;
SendMessage(mEditWindow, EM_GETSEL, (WPARAM)&startPos, (LPARAM)&endPos);
if (startPos != endPos) {
cutFlags = MF_BYPOSITION | MF_ENABLED;
copyFlags = MF_BYPOSITION | MF_ENABLED;
deleteFlags = MF_BYPOSITION | MF_ENABLED;
}
}
// undo is available if the edit control says so
if (SendMessage(mEditWindow, EM_CANUNDO, (WPARAM)0, (LPARAM)0)) {
undoFlags = MF_BYPOSITION | MF_ENABLED;
}
// check whether or not the clipboard contains text data
if (IsClipboardFormatAvailable(CF_TEXT)) {
pasteFlags = MF_BYPOSITION | MF_ENABLED;
}
// do enable/disable
VERIFY(EnableMenuItem(aMenu,
ID_EDITUNDO - ID_EDITMENU - 1,
undoFlags),
-1L,
"Disable/Enable \"Undo\" Failed");
VERIFY(EnableMenuItem(aMenu,
ID_EDITCUT - ID_EDITMENU - 1,
cutFlags),
-1L,
"Disable/Enable \"Cut\" Failed");
VERIFY(EnableMenuItem(aMenu,
ID_EDITCOPY - ID_EDITMENU - 1,
copyFlags),
-1L,
"Disable/Enable \"Copy\" Failed");
VERIFY(EnableMenuItem(aMenu,
ID_EDITPASTE - ID_EDITMENU - 1,
pasteFlags),
-1L,
"Disable/Enable \"Paste\" Failed");
VERIFY(EnableMenuItem(aMenu,
ID_EDITDELETE - ID_EDITMENU - 1,
deleteFlags),
-1L,
"Disable/Enable \"Delete\" Failed");
VERIFY(EnableMenuItem(aMenu,
ID_EDITSELECTALL - ID_EDITMENU - 1,
selectAllFlags),
-1L,
"Disable/Enable \"Select All\" Failed");
}
//
// private method. Deal with the "Command" menu
//
void JSConsole::InitCommandMenu(HMENU aMenu)
{
CHAR someText[2] = {'\0', '\0'}; // some buffer
// set flags to "disable"
UINT evaluateAllFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
UINT evaluateSelectionFlags = MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
// check if the edit area has any text
SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)2, (LPARAM)someText);
if (someText[0] != 0) {
// if there is some text enable "Evaluate All"
evaluateAllFlags = MF_BYPOSITION | MF_ENABLED;
// enable "Evaluate Selection" if there is any selection
UINT startPos, endPos;
SendMessage(mEditWindow, EM_GETSEL, (WPARAM)&startPos, (LPARAM)&endPos);
if (startPos != endPos) {
evaluateSelectionFlags = MF_BYPOSITION | MF_ENABLED;
}
}
// disable/enable commands
VERIFY(EnableMenuItem(aMenu,
ID_COMMANDSEVALALL - ID_COMMANDSMENU - 1,
evaluateAllFlags),
-1L,
"Disable/Enable \"Evaluate All\" Failed");
VERIFY(EnableMenuItem(aMenu,
ID_COMMANDSEVALSEL - ID_COMMANDSMENU - 1,
evaluateSelectionFlags),
-1L,
"Disable/Enable \"Evaluate Selection\" Failed");
}
//
// normailize a buffer of char coming from a text area.
// Basically get rid of the 0x0D char
//
LPSTR NormalizeBuffer(LPSTR aBuffer)
{
// trim all the 0x0D at the beginning (should be 1 at most, but hey...)
while (*aBuffer == 0x0D) {
aBuffer++;
}
LPSTR readPointer = aBuffer;
LPSTR writePointer = aBuffer;
do {
// compact the buffer if needed
*writePointer = *readPointer;
// skip the 0x0D
if (*readPointer != 0x0D) {
writePointer++;
}
} while (*readPointer++ != '\0');
return aBuffer;
}
LPSTR PrepareForTextArea(LPSTR aBuffer, PRInt32 aSize)
{
PRInt32 count = 0;
LPSTR newBuffer = aBuffer;
LPSTR readPointer = aBuffer;
// count the '\n'
while (*readPointer != '\0' && (*readPointer++ != '\n' || ++count));
if (0 != count) {
readPointer = aBuffer;
newBuffer = new CHAR[aSize + count + 1];
LPSTR writePointer = newBuffer;
while (*readPointer != '\0') {
if (*readPointer == '\n') {
*writePointer++ = 0x0D;
}
*writePointer++ = *readPointer++;
}
*writePointer = '\0';
}
return newBuffer;
}
//
// Evaluate the text enclosed between startSel and endSel
//
void JSConsole::EvaluateText(UINT aStartSel, UINT aEndSel)
{
if (mContext) {
// get the text size
UINT size = ::SendMessage(mEditWindow, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0);
// alloc a buffer big enough to contain the file
CHAR *buffer = new CHAR[++size];
if (buffer) {
// get the whole text
::SendMessage(mEditWindow, WM_GETTEXT, (WPARAM)size, (LPARAM)buffer);
// get the portion of the text to be evaluated
if (aEndSel != (UINT)-1) {
size = aEndSel - aStartSel;
strncpy(buffer, buffer + aStartSel, size);
buffer[size] = '\0';
}
else {
aEndSel = size;
}
// change the 0x0D0x0A couple in 0x0A ('\n')
// no new buffer allocation, the pointer may be in the middle
// of the old buffer though, so keep buffer to call delete
LPSTR cleanBuffer = ::NormalizeBuffer(buffer);
// evaluate the string
jsval returnValue;
if (mContext->EvaluateString(cleanBuffer,
strlen(cleanBuffer),
nsnull,
0,
&returnValue)) {
// output the result on the console and on the edit area
CHAR result[128];
LPSTR res = result;
int bDelete = 0;
JSContext *cx = (JSContext *)mContext->GetNativeContext();
JSString *jsstring = JS_ValueToString(cx, returnValue);
char *str = JS_GetStringBytes(jsstring);
::printf("The return value is ");
if (JSVAL_IS_OBJECT(returnValue)) {
::printf("an object\n");
}
else if (JSVAL_IS_INT(returnValue)) {
::printf("an int [%d]\n", JSVAL_TO_INT(returnValue));
}
else if (JSVAL_IS_DOUBLE(returnValue)) {
::printf("a double [%f]\n", *JSVAL_TO_DOUBLE(returnValue));
}
else if (JSVAL_IS_STRING(returnValue)) {
::printf("a string [%s]\n", JS_GetStringBytes(JSVAL_TO_STRING(returnValue)));
}
else if (JSVAL_IS_BOOLEAN(returnValue)) {
::printf("a boolean [%d]\n", JSVAL_TO_BOOLEAN(returnValue));
}
else if (JSVAL_IS_NULL(returnValue)) {
printf("null\n");
}
else if (JSVAL_IS_VOID(returnValue)) {
printf("void\n");
}
else {
printf("error: unknow return type!\n");
}
// make a string with 0xA changed to 0xD0xA
res = PrepareForTextArea(str, JS_GetStringLength(jsstring));
if (res != str) {
bDelete = 1; // if the buffer was new'ed
}
// set the position at the end of the selection
::SendMessage(mEditWindow, EM_SETSEL, (WPARAM)aEndSel, (LPARAM)aEndSel);
// write the result
::SendMessage(mEditWindow, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)res);
// highlight the result
::SendMessage(mEditWindow, EM_SETSEL, (WPARAM)aEndSel - 1, (LPARAM)(aEndSel + strlen(res)));
// deal with the "big string" case
if (bDelete > 0) {
delete[] res;
}
// clean up a bit
JS_GC((JSContext *)mContext->GetNativeContext());
}
else {
::MessageBox(mMainWindow,
"Error evaluating the Script",
"JSConsole Error",
MB_OK | MB_ICONERROR);
}
delete[] buffer;
}
else {
::MessageBox(mMainWindow,
"Not Enough Memory to Allocate a Buffer to Evaluate the Script",
"JSConsole Error",
MB_OK | MB_ICONSTOP);
}
}
else {
::MessageBox(mMainWindow,
"Java Script Context not initialized",
"JSConsole Error",
MB_OK | MB_ICONSTOP);
}
}

Просмотреть файл

@ -0,0 +1,106 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef jsconsole_h__
#define jsconsole_h__
#include <windows.h>
class nsIScriptContext;
#define OPEN_DIALOG 0
#define SAVE_DIALOG 1
typedef void (*DESTROY_NOTIFICATION) ();
class JSConsole {
private:
HWND mMainWindow;
HWND mEditWindow;
DESTROY_NOTIFICATION mDestroyNotification;
// keep info from the OPENFILENAME struct
struct FileInfo {
CHAR mCurrentFileName[MAX_PATH];
WORD mFileOffset;
WORD mFileExtension;
void Init() {mCurrentFileName[0] = '\0'; mFileOffset = 0; mFileExtension = 0;}
} mFileInfo;
// one context per window
nsIScriptContext *mContext;
public:
static HINSTANCE sAppInstance;
static HACCEL sAccelTable;
static CHAR sDefaultCaption[];
static BOOL RegisterWidget();
static JSConsole* CreateConsole();
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
static BOOL mRegistered;
public:
JSConsole(HWND aMainWindow, HWND aEditControl);
~JSConsole();
BOOL LoadFile();
BOOL SaveFile();
BOOL OpenFileDialog(UINT aOpenOrSave);
inline BOOL CanSave() { return mFileInfo.mCurrentFileName[0] != '\0'; }
void SetFileName(LPSTR aFileName);
HWND GetMainWindow() { return mMainWindow; }
void SetNotification(DESTROY_NOTIFICATION aNotification) { mDestroyNotification = aNotification; }
void SetContext(nsIScriptContext *aContext) { mContext = aContext; }
void EvaluateText(UINT aStartSel, UINT aEndSel);
// windows messages
LRESULT OnSize(DWORD aResizeFlags, UINT aWidth, UINT aHeight);
LRESULT OnInitMenu(HMENU aMenu, UINT aPos, BOOL aIsSystem);
LRESULT OnSetFocus(HWND aWnd);
void OnDestroy();
// menu items
void OnFileNew();
void OnEditUndo();
void OnEditCut();
void OnEditCopy();
void OnEditPaste();
void OnEditDelete();
void OnEditSelectAll();
void OnCommandEvaluateAll();
void OnCommandEvaluateSelection();
void OnCommandInspector();
void OnHelp();
private:
void InitEditMenu(HMENU aMenu);
void InitCommandMenu(HMENU aMenu);
};
#endif // jsconsole_h__

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef jsconsres_h___
#define jsconsres_h___
// Main menu id
#define JSCONSOLE_MENU 20100
#define FILEMENUPOS 0
#define ID_FILEMENU 20200
// File menu items ids
#define ID_FILENEW 20201
#define ID_FILEOPEN 20202
#define ID_FILESAVE 20203
#define ID_FILESAVEAS 20204
// separator
#define ID_FILEEXIT 20206
#define EDITMENUPOS 1
#define ID_EDITMENU 20300
// Edit menu items ids
#define ID_EDITUNDO 20301
// separator
#define ID_EDITCUT 20303
#define ID_EDITCOPY 20304
#define ID_EDITPASTE 20305
#define ID_EDITDELETE 20306
// separator
#define ID_EDITSELECTALL 20308
#define COMMANDSMENUPOS 2
#define ID_COMMANDSMENU 20400
// Commands menu items ids
#define ID_COMMANDSEVALALL 20401
#define ID_COMMANDSEVALSEL 20402
// separator
#define ID_COMMANDSINSPECTOR 20404
#define HELPMENUPOS 3
#define ID_HELPMENU 20500
// Help menu items
#define ID_NOHELP 20501
//
// Accelerators table ids
//
#define ACCELERATOR_TABLE 1000
#endif // jsconsres_h___

Просмотреть файл

@ -0,0 +1,215 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
IGNORE_MANIFEST=1
MAKE_OBJ_TYPE = EXE
PROGRAM = .\$(OBJDIR)\xpviewer.exe
RESFILE = xpviewer.res
MISCDEP= \
$(DIST)\lib\raptorweb.lib \
$(DIST)\lib\xpcom32.lib \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib
OBJS = \
.\$(OBJDIR)\nsBrowserWindow.obj \
.\$(OBJDIR)\nsSetupRegistry.obj \
.\$(OBJDIR)\nsViewerApp.obj \
.\$(OBJDIR)\nsBrowserMain.obj \
.\$(OBJDIR)\JSConsole.obj \
$(NULL)
LINCS= \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\dom \
-I$(PUBLIC)\js \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\java \
-I$(PUBLIC)\plugin \
-I$(PUBLIC)\pref
MYLIBS= \
$(DIST)\lib\raptorbase.lib \
$(DIST)\lib\raptorgfxwin.lib \
$(DIST)\lib\raptorhtml.lib \
$(DIST)\lib\raptorweb.lib \
$(DIST)\lib\raptorwidget.lib \
$(DIST)\lib\raptorhtmlpars.lib \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\js32$(VERSION_NUMBER).lib \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
$(DIST)\lib\netlib.lib \
$(DIST)\lib\jsdom.lib \
comdlg32.lib \
$(NULL)
LLIBS= $(MYLIBS) \
shell32.lib \
-SUBSYSTEM:CONSOLE
include <$(DEPTH)\config\rules.mak>
!ifdef MOZ_NO_DEBUG_RTL
OS_CFLAGS = $(OS_CFLAGS) -DMOZ_NO_DEBUG_RTL
!endif
install:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
$(MAKE_INSTALL) resources\throbber\LargeAnimation00.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation01.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation02.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation03.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation04.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation05.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation06.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation07.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation08.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation09.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation10.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation11.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation12.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation13.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation14.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation15.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation16.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation17.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation18.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation19.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation20.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation21.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation22.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation23.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation24.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation25.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation26.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation27.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation28.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation29.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation30.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation31.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation32.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation33.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation34.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation35.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation36.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation37.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\throbber\LargeAnimation38.gif $(DIST)\bin\res\throbber
$(MAKE_INSTALL) resources\toolbar\DialogAddrIcon.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogAddrIcon_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogCompIcon.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogCompIcon_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogMailIcon.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogMailIcon_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogNavIcon.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\DialogNavIcon_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Back.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Back_dis.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Back_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Bookmarks.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Bookmarks_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Edit.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Forward.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Forward_dis.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Forward_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Home.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Home_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_HTab.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_HTab_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_LoadImages.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_LoadImages.mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Location.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Location_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MiniAddr.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MiniComp.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MiniMail.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MiniNav.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MiniTab.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MixSecurity.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_MixSecurity.mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Netscape.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Netscape_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_PersonalIcon.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Places.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Places_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Print.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Print_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Reload.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Reload_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Search.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Search_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Secure.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Secure_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Stop.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Stop.mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Stop_dis.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Stop_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Tab.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_TabSmall.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_TabSmall_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Tab_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Unsecure.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_Unsecure.mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_WhatsRelated.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\TB_WhatsRelated_mo.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\StatusBar-insecure.gif $(DIST)\bin\res\toolbar
$(MAKE_INSTALL) resources\toolbar\StatusBar-secure.gif $(DIST)\bin\res\toolbar
clobber::
rm -f $(DIST)\bin\xpviewer.exe
rm -f $(DIST)\bin\res\samples\test0.html
rm -f $(DIST)\bin\res\samples\test1.html
rm -f $(DIST)\bin\res\samples\test2.html
rm -f $(DIST)\bin\res\samples\test3.html
rm -f $(DIST)\bin\res\samples\test4.html
rm -f $(DIST)\bin\res\samples\test5.html
rm -f $(DIST)\bin\res\samples\test6.html
rm -f $(DIST)\bin\res\samples\test7.html
rm -f $(DIST)\bin\res\samples\test8.html
rm -f $(DIST)\bin\res\samples\test8siz.html
rm -f $(DIST)\bin\res\samples\test8sca.html
rm -f $(DIST)\bin\res\samples\test8tab.html
rm -f $(DIST)\bin\res\samples\test_ed.html
rm -f $(DIST)\bin\res\samples\test9.html
rm -f $(DIST)\bin\res\samples\test9a.html
rm -f $(DIST)\bin\res\samples\test9b.html
rm -f $(DIST)\bin\res\samples\raptor.jpg
rm -f $(DIST)\bin\res\samples\Anieyes.gif
rm -f $(DIST)\bin\res\samples\gear1.gif
rm -f $(DIST)\bin\res\samples\rock_gra.gif
rm -f $(DIST)\bin\res\samples\bg.jpg
rm -f $(DIST)\bin\res\throbber\anims00.gif
rm -f $(DIST)\bin\res\throbber\anims01.gif
rm -f $(DIST)\bin\res\throbber\anims02.gif
rm -f $(DIST)\bin\res\throbber\anims03.gif
rm -f $(DIST)\bin\res\throbber\anims04.gif
rm -f $(DIST)\bin\res\throbber\anims05.gif
rm -f $(DIST)\bin\res\throbber\anims06.gif
rm -f $(DIST)\bin\res\throbber\anims07.gif
rm -f $(DIST)\bin\res\throbber\anims08.gif
rm -f $(DIST)\bin\res\throbber\anims09.gif
rm -f $(DIST)\bin\res\throbber\anims10.gif
rm -f $(DIST)\bin\res\throbber\anims11.gif
rm -f $(DIST)\bin\res\throbber\anims12.gif
rm -f $(DIST)\bin\res\throbber\anims13.gif

Просмотреть файл

@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include <windows.h>
#include "nsViewerApp.h"
#include "nsBrowserWindow.h"
#include "nsITimer.h"
#include "JSConsole.h"
#include "plevent.h"
JSConsole *gConsole;
HINSTANCE gInstance, gPrevInstance;
static nsITimer* gNetTimer;
/*nsNativeViewerApp::nsNativeViewerApp()
{
}
nsNativeViewerApp::~nsNativeViewerApp()
{
}
int
nsNativeViewerApp::Run()
{
OpenWindow();
// Process messages
MSG msg;
while (::GetMessage(&msg, NULL, 0, 0)) {
if (!JSConsole::sAccelTable ||
!gConsole ||
!gConsole->GetMainWindow() ||
!TranslateAccelerator(gConsole->GetMainWindow(),
JSConsole::sAccelTable, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
*/
//----------------------------------------------------------------------
/*nsNativeBrowserWindow::nsNativeBrowserWindow()
{
}
nsNativeBrowserWindow::~nsNativeBrowserWindow()
{
}
nsresult
nsBrowserWindow::CreateMenuBar(PRInt32 aWidth)
{
HMENU menu = ::LoadMenu(gInstance, "Viewer");
HWND hwnd = (HWND)mWindow->GetNativeData(NS_NATIVE_WIDGET);
::SetMenu(hwnd, menu);
return NS_OK;
}
nsEventStatus
nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
// Dispatch windows-only menu code goes here
// Dispatch xp menu items
return nsBrowserWindow::DispatchMenuItem(aID);
}*/
//----------------------------------------------------------------------
int main(int argc, char **argv)
{
PL_InitializeEventsLib("");
nsViewerApp* app = new nsViewerApp();
NS_ADDREF(app);
app->Initialize(argc, argv);
app->OpenWindow();
app->Run();
NS_RELEASE(app);
return 0;
}
int PASCAL
WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
int nCmdShow)
{
gInstance = instance;
gPrevInstance = prevInstance;
PL_InitializeEventsLib("");
nsViewerApp* app = new nsViewerApp();
app->Initialize(0, nsnull);
app->OpenWindow();
int result = app->Run();
delete app;
return result;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,308 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsBrowserWindow_h___
#define nsBrowserWindow_h___
#include "nsIBrowserWindow.h"
#include "nsIStreamListener.h"
#include "nsINetSupport.h"
#include "nsIWebShell.h"
#include "nsIScriptContextOwner.h"
#include "nsString.h"
#include "nsVoidArray.h"
#include "nsCRT.h"
#include "nsIToolbarManagerListener.h"
#include "nsIImageButtonListener.h"
class nsILabel;
class nsICheckButton;
class nsIRadioButton;
class nsIDialog;
class nsITextWidget;
class nsIButton;
class nsIThrobber;
class nsViewerApp;
class nsIPresShell;
class nsIPref;
class nsIImageButton;
class nsIMenuButton;
class nsIToolbar;
class nsIToolbarManager;
#define SAMPLES_BASE_URL "resource:/res/samples"
/**
* Abstract base class for our test app's browser windows
*/
class nsBrowserWindow : public nsIBrowserWindow,
public nsIStreamObserver,
public nsINetSupport,
public nsIWebShellContainer,
public nsIToolbarManagerListener,
public nsIImageButtonListener
{
public:
void* operator new(size_t sz) {
void* rv = new char[sz];
nsCRT::zero(rv, sz);
return rv;
}
nsBrowserWindow();
virtual ~nsBrowserWindow();
// nsISupports
NS_DECL_ISUPPORTS
// nsIBrowserWindow
NS_IMETHOD Init(nsIAppShell* aAppShell,
nsIPref* aPrefs,
const nsRect& aBounds,
PRUint32 aChromeMask,
PRBool aAllowPlugins = PR_TRUE);
NS_IMETHOD MoveTo(PRInt32 aX, PRInt32 aY);
NS_IMETHOD SizeTo(PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetBounds(nsRect& aBounds);
NS_IMETHOD Show();
NS_IMETHOD Hide();
NS_IMETHOD Close();
NS_IMETHOD SetChrome(PRUint32 aNewChromeMask);
NS_IMETHOD GetChrome(PRUint32& aChromeMaskResult);
NS_IMETHOD SetTitle(const PRUnichar* aTitle);
NS_IMETHOD GetTitle(PRUnichar** aResult);
NS_IMETHOD SetStatus(const PRUnichar* aStatus);
NS_IMETHOD SetStatus(const nsString &aStatus);
NS_IMETHOD GetStatus(PRUnichar** aResult);
NS_IMETHOD SetProgress(PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD GetWebShell(nsIWebShell*& aResult);
NS_IMETHOD HandleEvent(nsGUIEvent * anEvent);
// nsIStreamObserver
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType);
NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD OnStatus(nsIURL* aURL, const nsString& aMsg);
NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 status, const nsString &aMsg);
// nsIWebShellContainer
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus);
NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell);
// nsINetSupport
NS_IMETHOD_(void) Alert(const nsString &aText);
NS_IMETHOD_(PRBool) Confirm(const nsString &aText);
NS_IMETHOD_(PRBool) Prompt(const nsString &aText,
const nsString &aDefault,
nsString &aResult);
NS_IMETHOD_(PRBool) PromptUserAndPassword(const nsString &aText,
nsString &aUser,
nsString &aPassword);
NS_IMETHOD_(PRBool) PromptPassword(const nsString &aText,
nsString &aPassword);
// nsBrowserWindow
virtual nsresult CreateMenuBar(PRInt32 aWidth);
virtual nsresult CreateToolBar(PRInt32 aWidth);
virtual nsresult CreateStatusBar(PRInt32 aWidth);
void Layout(PRInt32 aWidth, PRInt32 aHeight);
void Back();
void Forward();
void GoTo(const PRUnichar* aURL);
void StartThrobber();
void StopThrobber();
void LoadThrobberImages();
void DestroyThrobberImages();
virtual nsEventStatus DispatchMenuItem(PRInt32 aID);
void DoFileOpen();
void DoCopy();
void DoJSConsole();
void DoEditorMode(nsIWebShell* aWebShell);
nsIPresShell* GetPresShell();
void DoFind();
void DoSelectAll();
void ForceRefresh();
void DoAppsDialog();
// nsIToolbarManager Listener Interface
NS_IMETHOD NotifyToolbarManagerChangedSize(nsIToolbarManager* aToolbarMgr);
// nsIImageButtonListener
NS_IMETHOD NotifyImageButtonEvent(nsIImageButton * aImgBtn, nsGUIEvent* anEvent);
#ifdef NS_DEBUG
void DumpContent(FILE *out = stdout);
void DumpFrames(FILE *out = stdout, nsString *aFilter = nsnull);
void DumpViews(FILE *out = stdout);
void DumpWebShells(FILE *out = stdout);
void DumpStyleSheets(FILE *out = stdout);
void DumpStyleContexts(FILE *out = stdout);
void ToggleFrameBorders();
void ShowContentSize();
void ShowFrameSize();
void ShowStyleSize();
void DoDebugSave();
void DoToggleSelection();
void DoDebugRobot();
void DoSiteWalker();
nsEventStatus DispatchDebugMenu(PRInt32 aID);
#endif
nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent);
void SetApp(nsViewerApp* aApp) {
mApp = aApp;
}
static void CloseAllWindows();
nsViewerApp* mApp;
PRUint32 mChromeMask;
nsString mTitle;
nsIWidget* mWindow;
nsIWebShell* mWebShell;
nsIWidget ** mAppsDialogBtns;
PRInt32 mNumAppsDialogBtns;
nsIWidget ** mMiniAppsBtns;
PRInt32 mNumMiniAppsBtns;
nsIWidget ** mToolbarBtns;
PRInt32 mNumToolbarBtns;
nsIWidget ** mPersonalToolbarBtns;
PRInt32 mNumPersonalToolbarBtns;
// "Toolbar"
nsIToolbarManager * mToolbarMgr;
nsIToolbar * mBtnToolbar;
nsIToolbar * mURLToolbar;
//nsIImageButton* mBack;
//nsIImageButton* mForward;
//nsIImageButton* mReload;
//nsIImageButton* mHome;
//nsIImageButton* mPrint;
//nsIImageButton* mStop;
nsIThrobber* mThrobber;
nsIMenuButton* mBookmarks;
nsIMenuButton* mWhatsRelated;
nsITextWidget* mLocation;
nsIImageButton* mLocationIcon;
// nsIWidget for Buttons
//nsIWidget* mBackWidget;
//nsIWidget* mForwardWidget;
//nsIWidget* mReloadWidget;
//nsIWidget* mHomeWidget;
//nsIWidget* mPrintWidget;
//nsIWidget* mStopWidget;
nsIWidget* mBookmarksWidget;
nsIWidget* mWhatsRelatedWidget;
nsIWidget* mLocationWidget;
nsIWidget* mLocationIconWidget;
// "Status bar"
nsITextWidget * mStatus;
nsIToolbar * mStatusBar;
nsIImageButton * mStatusSecurityLabel;
nsIImageButton * mStatusProcess;
nsIImageButton * mStatusText;
// Mini App Bar (in StatusBar)
nsIToolbar * mStatusAppBar;
nsIImageButton * mMiniTab;
nsIImageButton * mMiniNav;
nsIImageButton * mMiniMail;
nsIImageButton * mMiniAddr;
nsIImageButton * mMiniComp;
nsIWidget * mStatusAppBarWidget;
nsIWidget * mMiniTabWidget;
// Apps Dialog
nsIDialog * mAppsDialog;
// Find Dialog
nsIDialog * mDialog;
nsIButton * mCancelBtn;
nsIButton * mFindBtn;
nsITextWidget * mTextField;
nsICheckButton * mMatchCheckBtn;
nsIRadioButton * mUpRadioBtn;
nsIRadioButton * mDwnRadioBtn;
nsILabel * mLabel;
//for creating more instances
nsIAppShell* mAppShell; //not addref'ed!
nsIPref* mPrefs; //not addref'ed!
PRBool mAllowPlugins;
// Global window collection
static nsVoidArray gBrowsers;
static void AddBrowser(nsBrowserWindow* aBrowser);
static void RemoveBrowser(nsBrowserWindow* aBrowser);
static nsBrowserWindow* FindBrowserFor(nsIWidget* aWidget, PRIntn aWhich);
static nsBrowserWindow* FindBrowserFor(nsIWidget* aWidget);
protected:
nsresult AddToolbarItem(nsIToolbar *aToolbar,
PRInt32 aGap,
PRBool aEnable,
nsIWidget *aButtonWidget);
void UpdateToolbarBtns();
};
// XXX This is bad; because we can't hang a closure off of the event
// callback we have no way to store our This pointer; therefore we
// have to hunt to find the browswer that events belong too!!!
// aWhich for FindBrowserFor
#define FIND_WINDOW 0
#define FIND_BACK 1
#define FIND_FORWARD 2
#define FIND_LOCATION 3
//----------------------------------------------------------------------
/*class nsNativeBrowserWindow : public nsBrowserWindow {
public:
nsNativeBrowserWindow();
~nsNativeBrowserWindow();
virtual nsresult CreateMenuBar(PRInt32 aWidth);
virtual nsEventStatus DispatchMenuItem(PRInt32 aID);
};*/
#endif /* nsBrowserWindow_h___ */

Просмотреть файл

@ -0,0 +1,153 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifdef XP_MAC
#include "nsIPref.h"
#define NS_IMPL_IDS
#else
#define NS_IMPL_IDS
#include "nsIPref.h"
#endif
#include "nsRepository.h"
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
#include "nsViewsCID.h"
#include "nsPluginsCID.h"
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
#include "nsIDocumentLoader.h"
#include "nsIThrobber.h"
#include "nsParserCIID.h"
#include "nsDOMCID.h"
#ifdef XP_PC
#define WIDGET_DLL "raptorwidget.dll"
#define GFXWIN_DLL "raptorgfxwin.dll"
#define VIEW_DLL "raptorview.dll"
#define WEB_DLL "raptorweb.dll"
#define PLUGIN_DLL "raptorplugin.dll"
#define PREF_DLL "xppref32.dll"
#define PARSER_DLL "raptorhtmlpars.dll"
#define DOM_DLL "jsdom.dll"
#else
#ifdef XP_MAC
#include "nsMacRepository.h"
#else
#define WIDGET_DLL "libwidgetunix.so"
#define GFXWIN_DLL "libgfxunix.so"
#define VIEW_DLL "libraptorview.so"
#define WEB_DLL "libraptorwebwidget.so"
#define PLUGIN_DLL "raptorplugin.so"
#define PREF_DLL "libpref.so"
#define PARSER_DLL "libraptorhtmlpars.so"
#define DOM_DLL "libjsdom.so"
#endif
#endif
// Class ID's
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
static NS_DEFINE_IID(kCWindowCID, NS_WINDOW_CID);
static NS_DEFINE_IID(kCMenuBarCID, NS_MENUBAR_CID);
static NS_DEFINE_IID(kCMenuCID, NS_MENU_CID);
static NS_DEFINE_IID(kCMenuItemCID, NS_MENUITEM_CID);
static NS_DEFINE_IID(kCDialogCID, NS_DIALOG_CID);
static NS_DEFINE_IID(kCLabelCID, NS_LABEL_CID);
static NS_DEFINE_IID(kCAppShellCID, NS_APPSHELL_CID);
static NS_DEFINE_IID(kCWindowIID, NS_WINDOW_CID);
static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID);
static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID);
static NS_DEFINE_IID(kCButtonCID, NS_BUTTON_CID);
static NS_DEFINE_IID(kCComboBoxCID, NS_COMBOBOX_CID);
static NS_DEFINE_IID(kCListBoxCID, NS_LISTBOX_CID);
static NS_DEFINE_IID(kCRadioButtonCID, NS_RADIOBUTTON_CID);
static NS_DEFINE_IID(kCTextAreaCID, NS_TEXTAREA_CID);
static NS_DEFINE_IID(kCTextFieldCID, NS_TEXTFIELD_CID);
static NS_DEFINE_IID(kCCheckButtonIID, NS_CHECKBUTTON_CID);
static NS_DEFINE_IID(kCChildIID, NS_CHILD_CID);
static NS_DEFINE_IID(kCRenderingContextIID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCDeviceContextIID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);
static NS_DEFINE_IID(kCRegionIID, NS_REGION_CID);
static NS_DEFINE_IID(kCViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kCDocumentLoaderCID, NS_DOCUMENTLOADER_CID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID);
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
static NS_DEFINE_IID(kCDOMScriptObjectFactory, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
static NS_DEFINE_IID(kCImageButtonCID, NS_IMAGEBUTTON_CID);
static NS_DEFINE_IID(kCToolbarCID, NS_TOOLBAR_CID);
static NS_DEFINE_IID(kCToolbarManagerCID, NS_TOOLBARMANAGER_CID);
static NS_DEFINE_IID(kCToolbarItemHolderCID, NS_TOOLBARITEMHOLDER_CID);
static NS_DEFINE_IID(kCPopUpMenuCID, NS_POPUPMENU_CID);
static NS_DEFINE_IID(kCMenuButtonCID, NS_MENUBUTTON_CID);
extern "C" void
NS_SetupRegistry()
{
nsRepository::RegisterFactory(kLookAndFeelCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCWindowIID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCMenuBarCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCMenuCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCMenuItemCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCScrollbarIID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCHScrollbarIID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDialogCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCLabelCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCComboBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCFileWidgetCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCListBoxCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCRadioButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCTextAreaCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCTextFieldCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCCheckButtonIID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCChildIID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCAppShellCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCRenderingContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDeviceContextIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCFontMetricsIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCRegionIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCViewManagerCID, VIEW_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCViewCID, VIEW_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCScrollingViewCID, VIEW_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kWebShellCID, WEB_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDocumentLoaderCID, WEB_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kThrobberCID, WEB_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kPrefCID, PREF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCPluginHostCID, PLUGIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDOMScriptObjectFactory, DOM_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCImageButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCToolbarCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCToolbarManagerCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCToolbarItemHolderCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCPopUpMenuCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCMenuButtonCID, WIDGET_DLL, PR_FALSE, PR_FALSE);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,100 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsViewerApp_h___
#define nsViewerApp_h___
#include "nsINetContainerApplication.h"
#include "nsIAppShell.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsVoidArray.h"
class nsIPref;
//class nsWebCrawler;
class nsBrowserWindow;
class nsIBrowserWindow;
class nsViewerApp : public nsINetContainerApplication,
public nsDispatchListener
{
public:
void* operator new(size_t sz) {
void* rv = new char[sz];
nsCRT::zero(rv, sz);
return rv;
}
nsViewerApp();
virtual ~nsViewerApp();
// nsISupports
NS_DECL_ISUPPORTS
// nsINetContainerApplication
NS_IMETHOD GetAppCodeName(nsString& aAppCodeName);
NS_IMETHOD GetAppVersion(nsString& aAppVersion);
NS_IMETHOD GetAppName(nsString& aAppName);
NS_IMETHOD GetLanguage(nsString& aLanguage);
NS_IMETHOD GetPlatform(nsString& aPlatform);
// nsDispatchListener
virtual void AfterDispatch();
// nsViewerApp
NS_IMETHOD SetupRegistry();
NS_IMETHOD Initialize(int argc, char** argv);
NS_IMETHOD ProcessArguments(int argc, char** argv);
NS_IMETHOD OpenWindow();
NS_IMETHOD OpenWindow(PRUint32 aNewChromeMask, nsIBrowserWindow*& aNewWindow);
NS_IMETHOD CreateRobot(nsBrowserWindow* aWindow);
NS_IMETHOD CreateSiteWalker(nsBrowserWindow* aWindow);
NS_IMETHOD CreateJSConsole(nsBrowserWindow* aWindow);
NS_IMETHOD Exit();
NS_IMETHOD Run();
protected:
void Destroy();
nsIAppShell* mAppShell;
nsIPref* mPrefs;
nsString mStartURL;
PRBool mDoPurify;
PRBool mLoadTestFromFile;
PRBool mCrawl;
nsString mInputFileName;
PRInt32 mNumSamples;
PRInt32 mDelay;
PRInt32 mRepeatCount;
//nsWebCrawler* mCrawler;
PRBool mAllowPlugins;
PRBool mIsInitialized;
};
/*class nsNativeViewerApp : public nsViewerApp {
public:
nsNativeViewerApp();
~nsNativeViewerApp();
virtual int Run();
};*/
#endif /* nsViewerApp_h___ */

Просмотреть файл

@ -0,0 +1,88 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef resources_h___
#define resources_h___
#define VIEWER_OPEN 40000
#define VIEWER_EXIT 40002
#define PREVIEW_CLOSE 40003
#define VIEWER_WINDOW_OPEN 40009
#define VIEWER_FILE_OPEN 40010
// Note: must be in ascending sequential order
#define VIEWER_DEMO0 40011
#define VIEWER_DEMO1 40012
#define VIEWER_DEMO2 40013
#define VIEWER_DEMO3 40014
#define VIEWER_DEMO4 40015
#define VIEWER_DEMO5 40016
#define VIEWER_DEMO6 40017
#define VIEWER_DEMO7 40018
#define VIEWER_DEMO8 40019
#define VIEWER_DEMO9 40020
#define VIEWER_VISUAL_DEBUGGING 40021
#define VIEWER_REFLOW_TEST 40022
#define VIEWER_DUMP_CONTENT 40023
#define VIEWER_DUMP_FRAMES 40024
#define VIEWER_DUMP_VIEWS 40025
#define VIEWER_DUMP_STYLE_SHEETS 40026
#define VIEWER_DUMP_STYLE_CONTEXTS 40027
#define VIEWER_DEBUGROBOT 40028
#define VIEWER_SHOW_CONTENT_SIZE 40029
#define VIEWER_SHOW_FRAME_SIZE 40030
#define VIEWER_SHOW_STYLE_SIZE 40031
#define VIEWER_DEBUGSAVE 40032
#define VIEWER_SHOW_CONTENT_QUALITY 40033
#define VIEWER_TOGGLE_SELECTION 40034
// Note: must be in ascending sequential order
#define VIEWER_ONE_COLUMN 40040
#define VIEWER_TWO_COLUMN 40041
#define VIEWER_THREE_COLUMN 40042
#define JS_CONSOLE 40100
#define EDITOR_MODE 40120
#define VIEWER_EDIT_CUT 40201
#define VIEWER_EDIT_COPY 40202
#define VIEWER_EDIT_PASTE 40203
#define VIEWER_EDIT_SELECTALL 40204
#define VIEWER_EDIT_FINDINPAGE 40205
#define VIEWER_RL_BASE 41000
#define VIEWER_TOP100 40300
/* Debug Robot dialog setup */
#define IDD_DEBUGROBOT 101
#define IDC_UPDATE_DISPLAY 40301
#define IDC_VERIFICATION_DIRECTORY 40302
#define IDC_PAGE_LOADS 40303
#define IDC_STATIC -1
#define IDD_SITEWALKER 200
#define ID_SITE_PREVIOUS 40400
#define ID_SITE_NEXT 40401
#define IDC_SITE_NAME 40402
#define ID_EXIT 40404
#endif /* resources_h___ */