--NOT PART OF DEFAULT BUILD--

XMLterm changes only.
"make xpi" in xmlterm/scripts directory now creates an XPI file for XMLterm.
Removed last vestiges of WebShell!
Deleted outdated GeckoTerm files.
This commit is contained in:
svn%xmlterm.org 2000-07-17 04:11:24 +00:00
parent 7aca7f7ec5
commit ca565632b0
14 changed files with 20 additions and 1183 deletions

View File

@ -83,12 +83,6 @@ interface mozIXMLTermShell : nsISupports
*/
void IgnoreKeyPress(in boolean aIgnore, in wstring aCookie);
/** Opens new XMLterm window with specified args (not yet implemented)
* @param args argument string to be passed to XMLterm
* (at the moment this just contains any initial input data)
*/
nsIDOMWindow NewXMLTermWindow(in wstring args);
/** Exit browser, closing all windows (not yet implemented)
*/
void Exit();

View File

@ -39,15 +39,6 @@
#include "nsIPresContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIWebShell.h"
#include "nsIWebShellWindow.h"
#ifdef NEW_XMLTERM_IMP // Test C++ NewXMLTerm implementation
#include "nsIWidget.h"
#include "nsWidgetsCID.h"
#include "nsIBaseWindow.h"
#endif
#include "nsIServiceManager.h"
#include "nsIAppShellService.h"
@ -67,11 +58,6 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
// Define Class IDs
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
#ifdef NEW_XMLTERM_IMP // Test C++ NewXMLTerm implementation
static NS_DEFINE_IID(kWindowCID, NS_WINDOW_CID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
#endif
/////////////////////////////////////////////////////////////////////////
// mozXMLTermShell factory
@ -135,9 +121,6 @@ mozXMLTermShell::QueryInterface(REFNSIID aIID,void** aInstancePtr)
} else if ( aIID.Equals(NS_GET_IID(mozIXMLTermShell)) ) {
*aInstancePtr = NS_STATIC_CAST(mozIXMLTermShell*,this);
} else if ( aIID.Equals(NS_GET_IID(nsIWebShellContainer)) ) {
*aInstancePtr = NS_STATIC_CAST(nsIWebShellContainer*,this);
} else {
return NS_ERROR_NO_INTERFACE;
}
@ -354,89 +337,6 @@ NS_IMETHODIMP mozXMLTermShell::SendText(const PRUnichar* aString,
}
// Create new XMLTerm window with specified argument string
NS_IMETHODIMP
mozXMLTermShell::NewXMLTermWindow(const PRUnichar* args,
nsIDOMWindow **_retval)
{
nsresult result;
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,10,("\n"));
if (!_retval)
return NS_ERROR_NULL_POINTER;
*_retval = nsnull;
if (!mContentAreaDocShell)
return NS_ERROR_FAILURE;
// Get top window
nsCOMPtr<nsIWebShell> contentAreaWebShell( do_QueryInterface(mContentAreaDocShell) );
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, contWebShell=0x%x\n",
(int) contentAreaWebShell.get()));
nsCOMPtr<nsIWebShellContainer> topContainer = nsnull;
result = contentAreaWebShell->GetTopLevelWindow(getter_AddRefs(topContainer));
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, topContainer=0x%x\n",
(int) topContainer.get()));
nsCOMPtr<nsIWebShellWindow> topWin( do_QueryInterface(topContainer) );
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check0, topWin=0x%x\n",
(int) topWin.get()));
#ifdef NEW_XMLTERM_IMP // Test C++ NewXMLTerm implementation
PRInt32 width = 760;
PRInt32 height = 400;
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check4\n"));
// Create the Application Shell instance...
nsIAppShellService* appShellSvc = nsnull;
result = nsServiceManager::GetService(kAppShellServiceCID,
NS_GET_IID(nsIAppShellService),
(nsISupports**)&appShellSvc);
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check5\n"));
if (NS_FAILED(result) || !appShellSvc)
return NS_ERROR_FAILURE;
// Create top level window
nsCOMPtr<nsIWebShellWindow> webShellWin;
nsCOMPtr<nsIURI> uri = nsnull;
//nsCAutoString urlCString("chrome://xmlterm/content/xmlterm.html");
//result = uri->SetSpec(urlCString.GetBuffer());
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check6\n"));
if (NS_FAILED(result))
return NS_ERROR_FAILURE;
appShellSvc->CreateTopLevelWindow((nsIWebShellWindow*) nsnull,
uri,
PR_TRUE,
PR_FALSE,
(PRUint32) 0,
width, height,
getter_AddRefs(webShellWin));
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check7, webShellWin=0x%x\n",
webShellWin.get()));
if (NS_FAILED(result))
return result;
// Return new DOM window
result = webShellWin->GetDOMWindow(_retval);
XMLT_LOG(mozXMLTermShell::NewXMLTermWindow,0,("check8, *_retval=0x%x\n",
*_retval));
if (NS_FAILED(result) || !*_retval)
return NS_ERROR_FAILURE;
#endif
return NS_OK;
}
// Exit XMLTerm window
NS_IMETHODIMP
mozXMLTermShell::Exit()
@ -455,34 +355,3 @@ mozXMLTermShell::Exit()
}
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason)
{
XMLT_LOG(mozXMLTermShell::WillLoadURL,0,("\n"));
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
XMLT_LOG(mozXMLTermShell::BeginLoadURL,0,("\n"));
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::ProgressLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax)
{
XMLT_LOG(mozXMLTermShell::ProgressLoadURL,0,("\n"));
return NS_OK;
}
NS_IMETHODIMP mozXMLTermShell::EndLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsresult aStatus)
{
XMLT_LOG(mozXMLTermShell::EndLoadURL,0,("\n"));
return NS_OK;
}

View File

@ -35,8 +35,7 @@
#include "mozIXMLTermShell.h"
class mozXMLTermShell : public mozIXMLTermShell,
public nsIWebShellContainer
class mozXMLTermShell : public mozIXMLTermShell
{
public:
@ -68,30 +67,10 @@ class mozXMLTermShell : public mozIXMLTermShell,
NS_IMETHOD SendText(const PRUnichar* aString, const PRUnichar* aCookie);
NS_IMETHOD NewXMLTermWindow(const PRUnichar* args,
nsIDOMWindow **_retval);
NS_IMETHOD Exit(void);
NS_IMETHOD Finalize(void);
// nsIWebShellContainer interface
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,
nsresult aStatus);
protected:
/** object initialization flag */

View File

@ -314,10 +314,7 @@ NS_IMETHODIMP mozXMLTermStream::Open(nsIDOMWindow* aDOMWindow,
if (NS_FAILED(result))
return result;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
result = webShell->Embed(contentViewer, command, (nsISupports*) nsnull);
if (NS_FAILED(result))
return result;
// ****NOTE**** Need to embed contentViewer in docShell
result = mStreamListener->OnStartRequest(mChannel, mContext);
if (NS_FAILED(result))

View File

@ -47,44 +47,20 @@ endif
# Debug option
DEBUG = 1
DEBUG =
# Program
PROGRAM = geckoterm
PROGRAM =
# Exported header files
EXPORTS = mozISimpleContainer.h
EXPORTS =
# Defines
DEFINES = $(TK_CFLAGS)
DEFINES =
# C++ source files
CPPSRCS = nsSetupRegistry.cpp \
mozSimpleContainer.cpp \
mozGeckoTerm.cpp \
# nsTimer.cpp \
$(NULL)
CPPSRCS =
# Libraries to be linked
GTK_GLUE = -lgtksuperwin
XP_DIST_LIBS = \
-lgkgfx \
$(MOZ_JS_LIBS) \
$(XPCOM_LIBS) \
$(JSJ_LIB) \
$(NULL)
XP_NS_UNDERBAR_CRAP = \
$(MOZ_NECKO_UTIL_LIBS) \
$(MOZ_WIDGET_SUPPORT_LIBS) \
$(NULL)
XP_LIBS = \
$(XP_NS_UNDERBAR_CRAP) \
$(XP_DIST_LIBS) \
$(NSPR_LIBS) \
$(NULL)
ifdef DYNAMIC_LINK
# NOTE: a soft link needs to be created for libxmlterm.so in dist/bin
@ -94,13 +70,6 @@ else
XMLTERM_LIBS = ../base/libxmlterm.a
endif
LIBS = \
$(GTK_GLUE) \
$(XP_LIBS) \
$(TK_LIBS) \
$(XMLTERM_LIBS) \
$(NULL)
include $(topsrcdir)/config/config.mk
include ../config/xmlterm_config.mk

View File

@ -1,24 +0,0 @@
geckoterm --- Stand-alone version of XMLterm using Gecko
This directory contains the files used to create the stand-alone XMLterm
executable, which runs independent of the browser. This would be the preferred
way to use XMLterm, so that it runs as a separate process and will not
crash if the browser does.
28 Nov 1999
FILES
=====
mozGeckoTerm.cpp Main program for stand-alone "xmlterm" executable
Uses GTK to create window
Uses mozIXMLTerminal to create XMLterm
Uses mozISimpleContainer for web shell container
mozISimpleContainer.h Simple WebShell container interface
mozSimpleContainer.cpp Implementation of mozISimpleContainer
nsSetupRegistry.cpp Just a copy of viewer's nSetupRegistry
nsTimer.cpp Implementation of timers using Gtk timer facility
--

View File

@ -1,310 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is XMLterm.
*
* The Initial Developer of the Original Code is Ramalingam Saravanan.
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
* Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved.
*
* Contributor(s):
*/
// mozGeckoTerm.cpp: Stand-alone implementation of XMLterm using GTK
// and the Mozilla Layout engine
#include "stdio.h"
#include <gtk/gtk.h>
#include "gtkmozarea.h"
#include "gdksuperwin.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsRepository.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsIPref.h"
#include "mozXMLTermUtils.h"
#include "mozISimpleContainer.h"
#include "mozIXMLTerminal.h"
#include "mozIXMLTermStream.h"
#define XMLTERM_DLL "libxmlterm"MOZ_DLL_SUFFIX
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_IID(kLineTermCID, MOZLINETERM_CID);
static NS_DEFINE_IID(kXMLTermShellCID, MOZXMLTERMSHELL_CID);
extern "C" void NS_SetupRegistry();
nsCOMPtr<mozISimpleContainer> gSimpleContainer = nsnull;
nsCOMPtr<mozIXMLTerminal> gXMLTerminal = nsnull;
/** Processes thread events */
static void event_processor_callback(gpointer data,
gint source,
GdkInputCondition condition)
{
nsIEventQueue *eventQueue = (nsIEventQueue*)data;
eventQueue->ProcessPendingEvents();
//fprintf(stderr, "event_processor_callback:\n");
return;
}
static void event_processor_configure(GtkWidget *window,
GdkEvent *event,
GtkWidget *termWidget)
{
GtkAllocation *alloc = &GTK_WIDGET(termWidget)->allocation;
//fprintf(stderr, "event_processor_configure:\n");
// Resize doc shell window
gSimpleContainer->Resize(alloc->width, alloc->height);
if (gXMLTerminal) {
// Resize XMLTerm
gXMLTerminal->Resize();
}
return;
}
/** Cleans up and exits */
static gint event_processor_quit(gpointer data,
gint source,
GdkInputCondition condition)
{
fprintf(stderr, "event_processor_quit:\n");
if (gXMLTerminal) {
// Finalize XMLTerm and release owning reference to it
gXMLTerminal->Finalize();
gXMLTerminal = nsnull;
}
// Delete reference to container
gSimpleContainer = nsnull;
gtk_main_quit();
return TRUE;
}
int main( int argc, char *argv[] )
{
GtkWidget *mainWin = NULL;
GtkWidget *mozArea = NULL;
GdkSuperWin *superWin = NULL;
nsIEventQueue *mEventQueue = nsnull;
nsresult result = NS_OK;
// Set up registry
NS_SetupRegistry();
// Register XMLTermShell and LineTerm interfaces
result = nsComponentManager::RegisterComponentLib(kLineTermCID,NULL,NULL,
XMLTERM_DLL, PR_FALSE, PR_FALSE);
printf("mozGeckoTerm: registered LineTerm, result=0x%x\n", result);
result = nsComponentManager::RegisterComponentLib(kXMLTermShellCID,NULL,NULL,
XMLTERM_DLL, PR_FALSE, PR_FALSE);
printf("mozGeckoTerm: registered XMLTermShell, result=0x%x\n", result);
// Get the event queue service
NS_WITH_SERVICE(nsIEventQueueService, eventQService,
kEventQueueServiceCID, &result);
if (NS_FAILED(result)) {
NS_ASSERTION("Could not obtain event queue service", PR_FALSE);
return result;
}
// Get the event queue for the thread.
result = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
&mEventQueue);
if (!mEventQueue) {
// Create the event queue for the thread
result = eventQService->CreateThreadEventQueue();
if (NS_FAILED(result)) {
NS_ASSERTION("Could not create the thread event queue", PR_FALSE);
return result;
}
// Get the event queue for the thread
result = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &mEventQueue);
if (NS_FAILED(result)) {
NS_ASSERTION("Could not obtain the thread event queue", PR_FALSE);
return result;
}
}
// Create pref object
nsCOMPtr<nsIPref> mPref = nsnull;
result = nsComponentManager::CreateInstance(kPrefCID, NULL,
kIPrefIID, getter_AddRefs(mPref));
if (NS_FAILED(result)) {
NS_ASSERTION("Failed to create nsIPref object", PR_FALSE);
return result;
}
mPref->StartUp();
mPref->ReadUserPrefs();
// Initialize GTK library
gtk_set_locale();
gtk_init(&argc, &argv);
gdk_rgb_init();
mainWin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size( GTK_WINDOW(mainWin), 740, 484);
gtk_window_set_title(GTK_WINDOW(mainWin), "XMLterm");
mozArea = gtk_mozarea_new();
gtk_container_add(GTK_CONTAINER(mainWin), mozArea);
gtk_widget_realize(mozArea);
gtk_widget_show(mozArea);
superWin = GTK_MOZAREA(mozArea)->superwin;
gdk_window_show(superWin->bin_window);
gdk_window_show(superWin->shell_window);
gtk_widget_show(mainWin);
// Configure event handler
gtk_signal_connect_after( GTK_OBJECT(mainWin), "configure_event",
GTK_SIGNAL_FUNC(event_processor_configure),
mainWin);
// Cleanup and exit when window is deleted
gtk_signal_connect( GTK_OBJECT(mainWin), "delete_event",
GTK_SIGNAL_FUNC(event_processor_quit),
NULL);
// Check for input in the events queue file descriptor
gdk_input_add(mEventQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
mEventQueue);
// Create simple container
result = NS_NewSimpleContainer(getter_AddRefs(gSimpleContainer));
if (NS_FAILED(result) || !gSimpleContainer) {
return result; // Exit main program
}
// Determine window dimensions
GtkAllocation *alloc = &GTK_WIDGET(mainWin)->allocation;
// Initialize container it to hold a doc shell
result = gSimpleContainer->Init((nsNativeWidget *) superWin,
alloc->width, alloc->height, mPref);
if (NS_FAILED(result)) {
return result; // Exit main program
}
// Get reference to doc shell embedded in a simple container
nsCOMPtr<nsIDocShell> docShell;
result = gSimpleContainer->GetDocShell(*getter_AddRefs(docShell));
if (NS_FAILED(result) || !docShell) {
return result; // Exit main program
}
#if 0
// TEMPORARY: Testing mozIXMLTermStream
nsAutoString streamData = "<HTML><HEAD><TITLE>Stream Title</TITLE>"
"<SCRIPT language='JavaScript'>"
"function clik(){ dump('click\\n');return(false);}"
"</SCRIPT></HEAD>"
"<BODY><B>Stream Body "
"<SPAN STYLE='color: blue' onClick='return clik();'>Clik</SPAN></B>"
"</BODY></HTML>";
nsCOMPtr<mozIXMLTermStream> stream;
result = NS_NewXMLTermStream(getter_AddRefs(stream));
if (NS_FAILED(result)) {
fprintf(stderr, "mozGeckoTerm: Failed to create stream\n");
return result;
}
nsCOMPtr<nsIDOMWindow> outerDOMWindow;
result = mozXMLTermUtils::ConvertDocShellToDOMWindow(docShell,
getter_AddRefs(outerDOMWindow));
if (NS_FAILED(result) || !outerDOMWindow)
return NS_ERROR_FAILURE;
result = stream->Open(outerDOMWindow, nsnull, "chrome://dummy", "text/html",
0);
if (NS_FAILED(result)) {
fprintf(stderr, "mozGeckoTerm: Failed to open stream\n");
return result;
}
result = stream->Write(streamData.GetUnicode());
if (NS_FAILED(result)) {
fprintf(stderr, "mozGeckoTerm: Failed to write to stream\n");
return result;
}
result = stream->Close();
if (NS_FAILED(result)) {
fprintf(stderr, "mozGeckoTerm: Failed to close stream\n");
return result;
}
#else
// Load initial XMLterm document
result = gSimpleContainer->LoadURL(
"chrome://xmlterm/content/xmlterm.html");
if (NS_FAILED(result))
return result;
#endif
#if 0
// Create an XMLTERM and attach to web shell
result = NS_NewXMLTerminal(getter_AddRefs(gXMLTerminal));
if(!gXMLTerminal)
result = NS_ERROR_OUT_OF_MEMORY;
if (NS_SUCCEEDED(result)) {
result = gXMLTerminal->Init(docShell, nsnull, nsnull);
}
#endif
// Discard reference to web shell
docShell = nsnull;
// GTK event loop
gtk_main();
NS_IF_RELEASE(mEventQueue);
return 0;
}

View File

@ -1,85 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is XMLterm.
*
* The Initial Developer of the Original Code is Ramalingam Saravanan.
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
* Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved.
*
* Contributor(s):
*/
// mozISimpleContainer.h: a simple DocShell container interface
// for use in simple programs using the layout engine
// (unregistered interface)
#ifndef mozISimpleContainer_h___
#define mozISimpleContainer_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsIDocShell.h"
#include "nsIPref.h"
#include "nsIPresShell.h"
#include "nsIDOMDocument.h"
/* starting interface: mozISimpleContainer */
/* {0eb82bF0-43a2-11d3-8e76-006008948af5} */
#define MOZISIMPLE_CONTAINER_IID_STR "0eb82bF0-43a2-11d3-8e76-006008948af5"
#define MOZISIMPLE_CONTAINER_IID \
{0x0eb82bF0, 0x43a2, 0x11d3, \
{ 0x8e, 0x76, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5 }}
class mozISimpleContainer : public nsIDocumentLoaderObserver {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(MOZISIMPLE_CONTAINER_IID)
// other
/** Initializes simple container for native window widget
* @param aNativeWidget native window widget (e.g., GtkWidget)
* @param width window width (pixels)
* @param height window height (pixels)
* @param aPref preferences object
*/
NS_IMETHOD Init(nsNativeWidget aNativeWidget,
PRInt32 width, PRInt32 height,
nsIPref* aPref) = 0;
/** Resizes container to new dimensions
* @param width new window width (pixels)
* @param height new window height (pixels)
*/
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight) = 0;
/** Loads specified URL into container
* @param aURL URL string
*/
NS_IMETHOD LoadURL(const char* aURL) = 0;
/** Gets web shell in container
* @param aDocShell (output) web shell object
*/
NS_IMETHOD GetDocShell(nsIDocShell*& aDocShell) = 0;
};
#define MOZSIMPLE_CONTAINER_CID \
{ /* 0eb82bF1-43a2-11d3-8e76-006008948af5 */ \
0x0eb82bF1, 0x43a2, 0x11d3, \
{0x8e, 0x76, 0x00, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
extern nsresult
NS_NewSimpleContainer(mozISimpleContainer** aSimpleContainer);
#endif /* mozISimpleContainer_h___ */

View File

@ -1,283 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is XMLterm.
*
* The Initial Developer of the Original Code is Ramalingam Saravanan.
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
* Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*/
// mozSimpleContainer.cpp: Implements mozISimpleContainer
// which provides a DocShell container for use in simple programs
// using the layout engine
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsRepository.h"
#include "nsIURI.h"
#include "nsIDocShell.h"
#include "nsIDOMDocument.h"
#include "nsIDocumentViewer.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
#include "nsIWebShell.h"
#include "nsIBaseWindow.h"
#include "mozSimpleContainer.h"
// Define Class IDs
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
// Define Interface IDs
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
/////////////////////////////////////////////////////////////////////////
// mozSimpleContainer factory
/////////////////////////////////////////////////////////////////////////
nsresult
NS_NewSimpleContainer(mozISimpleContainer** aSimpleContainer)
{
NS_PRECONDITION(aSimpleContainer != nsnull, "null ptr");
if (!aSimpleContainer)
return NS_ERROR_NULL_POINTER;
*aSimpleContainer = new mozSimpleContainer();
if (! *aSimpleContainer)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aSimpleContainer);
return NS_OK;
}
/////////////////////////////////////////////////////////////////////////
// mozSimpleContainer implementation
/////////////////////////////////////////////////////////////////////////
mozSimpleContainer::mozSimpleContainer() :
mDocShell(nsnull)
{
NS_INIT_REFCNT();
}
mozSimpleContainer::~mozSimpleContainer()
{
mDocShell = nsnull;
}
#define NS_IMPL_ADDREF_TRACE(_class) \
NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
{ \
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); \
++mRefCnt; \
fprintf(stderr, "mozSimpleContainer:AddRef, mRefCnt=%d\n", mRefCnt); \
return mRefCnt; \
}
#define NS_IMPL_RELEASE_TRACE(_class) \
NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
{ \
NS_PRECONDITION(0 != mRefCnt, "dup release"); \
--mRefCnt; \
fprintf(stderr, "mozSimpleContainer:Release, mRefCnt=%d\n", mRefCnt); \
if (mRefCnt == 0) { \
NS_DELETEXPCOM(this); \
return 0; \
} \
return mRefCnt; \
}
// Implement AddRef and Release
NS_IMPL_ADDREF(mozSimpleContainer)
NS_IMPL_RELEASE(mozSimpleContainer)
NS_IMETHODIMP
mozSimpleContainer::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (aInstancePtr == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kISupportsIID)) {
*aInstancePtr = NS_STATIC_CAST(nsISupports*,
NS_STATIC_CAST(mozISimpleContainer*,this));
} else if ( aIID.Equals(NS_GET_IID(mozISimpleContainer)) ) {
*aInstancePtr = NS_STATIC_CAST(mozISimpleContainer*,this);
} else if ( aIID.Equals(NS_GET_IID(nsIDocumentLoaderObserver)) ) {
*aInstancePtr = NS_STATIC_CAST(nsIDocumentLoaderObserver*,this);
} else {
return NS_ERROR_NO_INTERFACE;
}
NS_ADDREF_THIS();
fprintf(stderr, "mozSimpleContainer::QueryInterface, mRefCnt = %d\n", mRefCnt);
return NS_OK;
}
/** Initializes simple container for native window widget
* @param aNativeWidget native window widget (e.g., GtkWidget)
* @param width window width (pixels)
* @param height window height (pixels)
* @param aPref preferences object
*/
NS_IMETHODIMP mozSimpleContainer::Init(nsNativeWidget aNativeWidget,
PRInt32 width, PRInt32 height,
nsIPref* aPref)
{
nsresult result;
// Create doc shell and show it
result = nsComponentManager::CreateInstance(kWebShellCID, nsnull,
NS_GET_IID(nsIDocShell),
getter_AddRefs(mDocShell));
if (NS_FAILED(result) || !mDocShell) {
fprintf(stderr, "Failed to create create doc shell\n");
return NS_ERROR_FAILURE;
}
// We are the document loader observer for the doc shell
mDocShell->SetDocLoaderObserver(this);
// Initialize web shell and show it
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
webShell->Init(aNativeWidget, 0, 0, width, height);
if (aPref) {
//mDocShell->SetPrefs(aPref);
}
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->SetVisibility(PR_TRUE);
return NS_OK;
}
// nsIDocumentLoaderObserver interface
NS_IMETHODIMP mozSimpleContainer::OnStartDocumentLoad(
nsIDocumentLoader *aLoader,
nsIURI *aURL,
const char *aCommand)
{
return NS_OK;
}
NS_IMETHODIMP mozSimpleContainer::OnEndDocumentLoad(nsIDocumentLoader *loader,
nsIChannel *aChannel,
PRUint32 aStatus)
{
fprintf(stderr, "mozSimpleContainer::OnEndDocumentLoad\n");
return NS_OK;
}
NS_IMETHODIMP mozSimpleContainer::OnStartURLLoad(nsIDocumentLoader *aLoader,
nsIChannel *channel)
{
return NS_OK;
}
NS_IMETHODIMP mozSimpleContainer::OnProgressURLLoad(nsIDocumentLoader *aLoader,
nsIChannel *aChannel,
PRUint32 aProgress,
PRUint32 aProgressMax)
{
return NS_OK;
}
NS_IMETHODIMP mozSimpleContainer::OnStatusURLLoad(nsIDocumentLoader *loader,
nsIChannel *channel,
nsString & aMsg)
{
return NS_OK;
}
NS_IMETHODIMP mozSimpleContainer::OnEndURLLoad(nsIDocumentLoader *aLoader,
nsIChannel *aChannel,
PRUint32 aStatus)
{
return NS_OK;
}
/** Resizes container to new dimensions
* @param width new window width (pixels)
* @param height new window height (pixels)
*/
NS_IMETHODIMP mozSimpleContainer::Resize(PRInt32 aWidth, PRInt32 aHeight)
{
fprintf(stderr, "mozSimpleContainer::Resize\n");
if (!mDocShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIBaseWindow> docShellWin(do_QueryInterface(mDocShell));
docShellWin->SetPositionAndSize(0, 0, aWidth, aHeight, PR_FALSE);
return NS_OK;
}
/** Loads specified URL into container
* @param aURL URL string
*/
NS_IMETHODIMP mozSimpleContainer::LoadURL(const char* aURL)
{
nsresult result;
if (!mDocShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(mDocShell));
nsString aStr(aURL);
result = webShell->LoadURL(aStr.GetUnicode());
return result;
}
/** Gets doc shell in container
* @param aDocShell (output) doc shell object
*/
NS_IMETHODIMP mozSimpleContainer::GetDocShell(nsIDocShell*& aDocShell)
{
aDocShell = mDocShell.get();
NS_IF_ADDREF(aDocShell); // Add ref'ed; needs to be released
return NS_OK;
}

View File

@ -1,60 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "MPL"); you may not use this file
* except in compliance with the MPL. You may obtain a copy of
* the MPL at http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the MPL for the specific language governing
* rights and limitations under the MPL.
*
* The Original Code is XMLterm.
*
* The Initial Developer of the Original Code is Ramalingam Saravanan.
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
* Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved.
*
* Contributor(s):
*/
// mozSimpleContainer.h: declaration of mozSimpleContainer class
// implementing mozISimpleContainer,
// which provides a DocShell container for use in simple programs
// using the layout engine
#include "nscore.h"
#include "nsCOMPtr.h"
#include "mozISimpleContainer.h"
class mozSimpleContainer : public mozISimpleContainer {
public:
mozSimpleContainer();
virtual ~mozSimpleContainer();
// nsISupports
NS_DECL_ISUPPORTS
// nsIDocumentLoaderObserver interface
NS_DECL_NSIDOCUMENTLOADEROBSERVER \
// other
NS_IMETHOD Init(nsNativeWidget aNativeWidget,
PRInt32 width, PRInt32 height,
nsIPref* aPref);
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD LoadURL(const char* aURL);
NS_IMETHOD GetDocShell(nsIDocShell*& aDocShell);
protected:
/** owning reference to doc shell created by us */
nsCOMPtr<nsIDocShell> mDocShell;
};

View File

@ -1,23 +0,0 @@
/* -*- 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.
*/
// nsSetupRegistry.cpp: Just a copy of viewer's nSetupRegistry
#include "../../../webshell/tests/viewer/nsSetupRegistry.cpp"

View File

@ -1,198 +0,0 @@
/* -*- 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.
*/
#include "nsITimer.h"
#include "nsITimerCallback.h"
#include "nsCRT.h"
#include "prlog.h"
#include <stdio.h>
#include <limits.h>
#include <gtk/gtk.h>
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
extern "C" gint nsTimerExpired(gpointer aCallData);
/*
* Implementation of timers using Gtk timer facility
*/
class TimerImpl : public nsITimer {
public:
public:
TimerImpl();
virtual ~TimerImpl();
virtual nsresult Init(nsTimerCallbackFunc aFunc,
void *aClosure,
// PRBool aRepeat,
PRUint32 aDelay);
virtual nsresult Init(nsITimerCallback *aCallback,
// PRBool aRepeat,
PRUint32 aDelay);
NS_DECL_ISUPPORTS
virtual void Cancel();
virtual PRUint32 GetDelay() { return mDelay; }
virtual void SetDelay(PRUint32 aDelay) { mDelay=aDelay; };
virtual void* GetClosure() { return mClosure; }
void FireTimeout();
private:
nsresult Init(PRUint32 aDelay);
PRUint32 mDelay;
nsTimerCallbackFunc mFunc;
void *mClosure;
nsITimerCallback *mCallback;
// PRBool mRepeat;
TimerImpl *mNext;
guint mTimerId;
};
void TimerImpl::FireTimeout()
{
if (mFunc != NULL) {
(*mFunc)(this, mClosure);
}
else if (mCallback != NULL) {
mCallback->Notify(this); // Fire the timer
}
// Always repeating here
// if (mRepeat)
// mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
}
TimerImpl::TimerImpl()
{
// printf("TimerImple::TimerImpl called for %p\n", this);
NS_INIT_REFCNT();
mFunc = NULL;
mCallback = NULL;
mNext = NULL;
mTimerId = 0;
mDelay = 0;
mClosure = NULL;
}
TimerImpl::~TimerImpl()
{
//printf("TimerImpl::~TimerImpl called for %p\n", this);
Cancel();
NS_IF_RELEASE(mCallback);
}
nsresult
TimerImpl::Init(nsTimerCallbackFunc aFunc,
void *aClosure,
// PRBool aRepeat,
PRUint32 aDelay)
{
//printf("TimerImpl::Init called with func + closure for %p\n", this);
mFunc = aFunc;
mClosure = aClosure;
// mRepeat = aRepeat;
// This is ancient debug code that is making it impossible to have timeouts
// greater than 10 seconds. -re
// if ((aDelay > 10000) || (aDelay < 0)) {
// printf("Timer::Init() called with bogus value \"%d\"! Not enabling timer.\n",
// aDelay);
// return Init(aDelay);
// }
mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
return Init(aDelay);
}
nsresult
TimerImpl::Init(nsITimerCallback *aCallback,
// PRBool aRepeat,
PRUint32 aDelay)
{
//printf("TimerImpl::Init called with callback only for %p\n", this);
mCallback = aCallback;
NS_ADDREF(mCallback);
// mRepeat = aRepeat;
// This is ancient debug code that is making it impossible to have timeouts
// greater than 10 seconds. -re
// if ((aDelay > 10000) || (aDelay < 0)) {
// printf("Timer::Init() called with bogus value \"%d\"! Not enabling timer.\n",
// aDelay);
// return Init(aDelay);
// }
mTimerId = gtk_timeout_add(aDelay, nsTimerExpired, this);
return Init(aDelay);
}
nsresult
TimerImpl::Init(PRUint32 aDelay)
{
//printf("TimerImpl::Init called with delay %d only for %p\n", aDelay, this);
mDelay = aDelay;
// NS_ADDREF(this);
return NS_OK;
}
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
void
TimerImpl::Cancel()
{
//printf("TimerImpl::Cancel called for %p\n", this);
TimerImpl *me = this;
if (mTimerId)
gtk_timeout_remove(mTimerId);
}
NS_GFXNONXP nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
{
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
TimerImpl *timer = new TimerImpl();
if (nsnull == timer) {
return NS_ERROR_OUT_OF_MEMORY;
}
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
}
gint nsTimerExpired(gpointer aCallData)
{
//printf("nsTimerExpired for %p\n", aCallData);
TimerImpl* timer = (TimerImpl *)aCallData;
timer->FireTimeout();
return 0;
}

View File

@ -54,7 +54,6 @@ include $(srcdir)/../config/xmlterm_config.mk
include $(topsrcdir)/config/rules.mk
XMLTERM_SCRIPTS = \
$(srcdir)/menuhack \
$(srcdir)/xmlterm \
$(srcdir)/xls \
$(srcdir)/xcat \
@ -62,3 +61,16 @@ XMLTERM_SCRIPTS = \
install::
$(INSTALL) -m 555 $(XMLTERM_SCRIPTS) $(DIST)/bin
xpi::
zip $(DIST)/bin/xmlterm.xpi install.js
cd $(DIST); zip -g bin/xmlterm.xpi \
bin/xcat \
bin/xls \
bin/xmlterm
cd $(DIST)/bin; zip -g xmlterm.xpi \
components/libxmlterm.so \
components/xmlterm.xpt \
components/xmlterm-service.js
cd $(DIST)/bin; zip -g -r xmlterm.xpi chrome/packages/xmlterm
echo Created $(DIST)/bin/xmlterm.xpi