Compare commits

..

2 Commits

Author SHA1 Message Date
pavlov%pavlov.net
33a0a6fec0 update to use ns_quicksort so that this branch builds
git-svn-id: svn://10.0.0.236/branches/FAST-GTK-GFX@31772 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-15 21:56:51 +00:00
(no author)
58b1c92ba4 This commit was manufactured by cvs2svn to create branch 'FAST-GTK-GFX'.
git-svn-id: svn://10.0.0.236/branches/FAST-GTK-GFX@28588 18797224-902f-48f8-a5cc-f745e15eee43
1999-04-22 00:07:41 +00:00
402 changed files with 15501 additions and 50364 deletions

View File

@@ -0,0 +1,53 @@
#!gmake
#
# 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 = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
LIBRARY_NAME = gfxgtk
MODULE=raptor
REQUIRES=util img xpcom raptor netlib ps
DEFINES += -D_IMPL_NS_GFXONXP
CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
nsDrawingSurfaceGTK.cpp \
nsDeviceContextGTK.cpp \
nsDeviceContextSpecFactoryG.cpp \
nsDeviceContextSpecG.cpp \
nsFontMetricsGTK.cpp \
nsGfxFactoryGTK.cpp \
nsRenderingContextGTK.cpp \
nsImageGTK.cpp \
nsRegionGTK.cpp
CSRCS = \
nsPrintdGTK.c
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,375 @@
/* -*- 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 <math.h>
#include "nspr.h"
#include "il_util.h"
#include "nsDeviceContextGTK.h"
#include "nsGfxCIID.h"
#include "../ps/nsDeviceContextPS.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define NS_TO_GDK_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
#define GDK_COLOR_TO_NS_RGB(c) \
((nscolor) NS_RGB(c.red, c.green, c.blue))
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
nsDeviceContextGTK::nsDeviceContextGTK()
{
NS_INIT_REFCNT();
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mDepth = 0 ;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
mNumCells = 0;
}
nsDeviceContextGTK::~nsDeviceContextGTK()
{
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextGTK, kDeviceContextIID)
NS_IMPL_ADDREF(nsDeviceContextGTK)
NS_IMPL_RELEASE(nsDeviceContextGTK)
NS_IMETHODIMP nsDeviceContextGTK::Init(nsNativeWidget aNativeWidget)
{
GdkVisual *vis;
GtkRequisition req;
GtkWidget *sb;
mWidget = aNativeWidget;
// Compute dpi of display
float screenWidth = float(::gdk_screen_width());
float screenWidthIn = float(::gdk_screen_width_mm()) / 25.4f;
nscoord dpi = nscoord(screenWidth / screenWidthIn);
// Now for some wacky heuristics.
if (dpi < 84) dpi = 72;
else if (dpi < 108) dpi = 96;
else if (dpi < 132) dpi = 120;
mTwipsToPixels = float(dpi) / float(NSIntPointsToTwips(72));
mPixelsToTwips = 1.0f / mTwipsToPixels;
#if 0
mTwipsToPixels = ( ((float)::gdk_screen_width()) /
((float)::gdk_screen_width_mm()) * 25.4) /
(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f / mTwipsToPixels;
#endif
vis = gdk_rgb_get_visual();
mDepth = vis->depth;
sb = gtk_vscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarWidth = req.width;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
sb = gtk_hscrollbar_new(NULL);
gtk_widget_ref(sb);
gtk_object_sink(GTK_OBJECT(sb));
gtk_widget_size_request(sb,&req);
mScrollbarHeight = req.height;
gtk_widget_destroy(sb);
gtk_widget_unref(sb);
#ifdef DEBUG
static PRBool once = PR_TRUE;
if (once) {
printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", dpi, mTwipsToPixels, mPixelsToTwips,mDepth);
once = PR_FALSE;
}
#endif
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsresult rv;
nsDrawingSurfaceGTK *surf;
// to call init for this, we need to have a valid nsDrawingSurfaceGTK created
pContext = new nsRenderingContextGTK();
if (nsnull != pContext)
{
NS_ADDREF(pContext);
// create the nsDrawingSurfaceGTK
surf = new nsDrawingSurfaceGTK();
if (nsnull != surf)
{
GdkDrawable *win = nsnull;
// FIXME
if (GTK_IS_LAYOUT((GtkWidget*)mWidget))
win = (GdkDrawable*)gdk_window_ref(GTK_LAYOUT((GtkWidget*)mWidget)->bin_window);
else
win = (GdkDrawable*)gdk_window_ref(((GtkWidget*)mWidget)->window);
GdkGC *gc = gdk_gc_new(win);
// init the nsDrawingSurfaceGTK
rv = surf->Init(win,gc);
if (NS_OK == rv)
// Init the nsRenderingContextGTK
rv = pContext->Init(this, surf);
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv)
{
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
//XXX it is very critical that this not lie!! MMP
// read the comments in the mac code for this
aSupportsWidgets = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
aWidth = mScrollbarWidth * mPixelsToTwips;
aHeight = mScrollbarHeight * mPixelsToTwips;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const
{
nsresult status = NS_OK;
GtkStyle *style = gtk_style_new(); // get the default styles
switch (anID) {
//---------
// Colors
//---------
case eSystemAttr_Color_WindowBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WindowForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_WidgetSelectBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_WidgetSelectForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_Widget3DHighlight:
*aInfo->mColor = NS_RGB(0xa0,0xa0,0xa0);
break;
case eSystemAttr_Color_Widget3DShadow:
*aInfo->mColor = NS_RGB(0x40,0x40,0x40);
break;
case eSystemAttr_Color_TextBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_TextForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
break;
case eSystemAttr_Color_TextSelectBackground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_SELECTED]);
break;
case eSystemAttr_Color_TextSelectForeground:
*aInfo->mColor = GDK_COLOR_TO_NS_RGB(style->text[GTK_STATE_SELECTED]);
break;
//---------
// Size
//---------
case eSystemAttr_Size_ScrollbarHeight:
aInfo->mSize = mScrollbarHeight;
break;
case eSystemAttr_Size_ScrollbarWidth:
aInfo->mSize = mScrollbarWidth;
break;
case eSystemAttr_Size_WindowTitleHeight:
aInfo->mSize = 0;
break;
case eSystemAttr_Size_WindowBorderWidth:
aInfo->mSize = style->klass->xthickness;
break;
case eSystemAttr_Size_WindowBorderHeight:
aInfo->mSize = style->klass->ythickness;
break;
case eSystemAttr_Size_Widget3DBorder:
aInfo->mSize = 4;
break;
//---------
// Fonts
//---------
case eSystemAttr_Font_Caption:
case eSystemAttr_Font_Icon:
case eSystemAttr_Font_Menu:
case eSystemAttr_Font_MessageBox:
case eSystemAttr_Font_SmallCaption:
case eSystemAttr_Font_StatusBar:
case eSystemAttr_Font_Tooltips:
case eSystemAttr_Font_Widget:
status = NS_ERROR_FAILURE;
break;
} // switch
gtk_style_unref(style);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDrawingSurface(nsIRenderingContext &aContext,
nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::ConvertPixel(nscolor aColor,
PRUint32 & aPixel)
{
aPixel = ::gdk_rgb_xpixel_from_rgb (NS_TO_GDK_RGB(aColor));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::CheckFontExistence(const nsString& aFontName)
{
char **fnames = nsnull;
PRInt32 namelen = aFontName.Length() + 1;
char *wildstring = (char *)PR_Malloc(namelen + 200);
float t2d;
GetTwipsToDevUnits(t2d);
PRInt32 dpi = NSToIntRound(t2d * 1440);
int numnames = 0;
XFontStruct *fonts;
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == wildstring)
return NS_ERROR_UNEXPECTED;
if (abs(dpi - 75) < abs(dpi - 100))
dpi = 75;
else
dpi = 100;
char* fontName = aFontName.ToNewCString();
PR_snprintf(wildstring, namelen + 200,
"*-%s-*-*-normal--*-*-%d-%d-*-*-*",
fontName, dpi, dpi);
delete [] fontName;
fnames = ::XListFontsWithInfo(GDK_DISPLAY(), wildstring, 1, &numnames, &fonts);
if (numnames > 0)
{
::XFreeFontInfo(fnames, fonts, numnames);
rv = NS_OK;
}
PR_Free(wildstring);
return rv;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
{
aWidth = 1;
aHeight = 1;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
// Create a Postscript device context
aContext = new nsDeviceContextPS();
((nsDeviceContextPS *)aContext)->SetSpec(aDevice);
NS_ADDREF(aDevice);
return((nsDeviceContextPS *) aContext)->Init((nsIDeviceContext*)aContext, (nsIDeviceContext*)this);
}
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndDocument(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::BeginPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::EndPage(void)
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextGTK::GetDepth(PRUint32& aDepth)
{
GdkVisual * rgb_visual = gdk_rgb_get_visual();
gint rgb_depth = rgb_visual->depth;
aDepth = (PRUint32) rgb_depth;
return NS_OK;
}

View File

@@ -0,0 +1,79 @@
/* -*- 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 nsDeviceContextGTK_h___
#define nsDeviceContextGTK_h___
#include "nsDeviceContext.h"
#include "nsUnitConversion.h"
#include "nsIWidget.h"
#include "nsIView.h"
#include "nsIRenderingContext.h"
#include "nsRenderingContextGTK.h"
class nsDeviceContextGTK : public DeviceContextImpl
{
public:
nsDeviceContextGTK();
virtual ~nsDeviceContextGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
NS_IMETHOD GetSystemAttribute(nsSystemAttrID anID, SystemAttrStruct * aInfo) const;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(void);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
NS_IMETHOD GetDepth(PRUint32& aDepth);
private:
PRUint32 mDepth;
PRBool mWriteable;
nsPaletteInfo mPaletteInfo;
PRUint32 mNumCells;
PRInt16 mScrollbarHeight;
PRInt16 mScrollbarWidth;
};
#endif /* nsDeviceContextGTK_h___ */

View File

@@ -0,0 +1,77 @@
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsDeviceContextSpecFactoryG.h"
#include "nsDeviceContextSpecG.h"
#include "nsGfxCIID.h"
#include "plstr.h"
/** -------------------------------------------------------
* Constructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: nsDeviceContextSpecFactoryGTK()
{
}
/** -------------------------------------------------------
* Destructor
* @update dc 2/16/98
*/
nsDeviceContextSpecFactoryGTK :: ~nsDeviceContextSpecFactoryGTK()
{
}
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryGTK, kDeviceContextSpecFactoryIID)
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecFactoryGTK)
/** -------------------------------------------------------
* Initialize the device context spec factory
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
{
return NS_OK;
}
/** -------------------------------------------------------
* Get a device context specification
* @update dc 2/16/98
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
nsIDeviceContextSpec *devSpec = nsnull;
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
if (nsnull != devSpec){
if (NS_OK == ((nsDeviceContextSpecGTK *)devSpec)->Init(aQuiet)){
aNewSpec = devSpec;
rv = NS_OK;
}
}
return rv;
}

View File

@@ -0,0 +1,41 @@
/* -*- 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) 1999 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsDeviceContextSpecFactoryG_h___
#define nsDeviceContextSpecFactoryG_h___
#include "nsIDeviceContextSpecFactory.h"
#include "nsIDeviceContextSpec.h"
class nsDeviceContextSpecFactoryGTK : public nsIDeviceContextSpecFactory
{
public:
nsDeviceContextSpecFactoryGTK();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(void);
NS_IMETHOD CreateDeviceContextSpec(nsIDeviceContextSpec *aOldSpec,
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryGTK();
};
#endif

View File

@@ -0,0 +1,197 @@
/* -*- 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 "nsDeviceContextSpecG.h"
#include "prenv.h" /* for PR_GetEnv */
//#include "prmem.h"
//#include "plstr.h"
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecGTK
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK :: nsDeviceContextSpecGTK()
{
NS_INIT_REFCNT();
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecGTK
* @update dc 2/15/98
*/
nsDeviceContextSpecGTK :: ~nsDeviceContextSpecGTK()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
#if 0
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecGTK, kDeviceContextSpecIID)
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
#endif
NS_IMETHODIMP nsDeviceContextSpecGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDeviceContextSpecIID))
{
nsIDeviceContextSpec* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDeviceContextSpecPSIID))
{
nsIDeviceContextSpecPS* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDeviceContextSpec* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDeviceContextSpecGTK)
NS_IMPL_RELEASE(nsDeviceContextSpecGTK)
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecGTK
* @update dc 2/15/98
* @update syd 3/2/99
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: Init(PRBool aQuiet)
{
char *path;
// XXX these settings should eventually come out of preferences
mPrData.toPrinter = PR_TRUE;
mPrData.fpf = PR_TRUE;
mPrData.grayscale = PR_FALSE;
mPrData.size = NS_LETTER_SIZE;
sprintf( mPrData.command, "lpr" );
// PWD, HOME, or fail
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) NULL )
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) NULL )
strcpy( mPrData.path, "netscape.ps" );
if ( path != (char *) NULL )
sprintf( mPrData.path, "%s/netscape.ps", path );
else
return NS_ERROR_FAILURE;
::UnixPrDialog( &mPrData );
if ( mPrData.cancel == PR_TRUE )
return NS_ERROR_FAILURE;
else
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetToPrinter( PRBool &aToPrinter )
{
aToPrinter = mPrData.toPrinter;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetFirstPageFirst ( PRBool &aFpf )
{
aFpf = mPrData.fpf;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetGrayscale ( PRBool &aGrayscale )
{
aGrayscale = mPrData.grayscale;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetSize ( int &aSize )
{
aSize = mPrData.size;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetTopMargin ( float &value )
{
value = mPrData.top;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetBottomMargin ( float &value )
{
value = mPrData.bottom;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetRightMargin ( float &value )
{
value = mPrData.right;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetLeftMargin ( float &value )
{
value = mPrData.left;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetCommand ( char **aCommand )
{
*aCommand = &mPrData.command[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetPath ( char **aPath )
{
*aPath = &mPrData.path[0];
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecGTK :: GetUserCancelled( PRBool &aCancel )
{
aCancel = mPrData.cancel;
return NS_OK;
}
/** -------------------------------------------------------
* Closes the printmanager if it is open.
* @update dc 2/15/98
*/
NS_IMETHODIMP nsDeviceContextSpecGTK :: ClosePrintManager()
{
return NS_OK;
}

View File

@@ -0,0 +1,97 @@
/* -*- 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 nsDeviceContextSpecG_h___
#define nsDeviceContextSpecG_h___
#include "nsIDeviceContextSpec.h"
#include "nsDeviceContextSpecG.h"
#include "nsIDeviceContextSpecPS.h"
#include "nsPrintdGTK.h"
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec ,
public nsIDeviceContextSpecPS
{
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecGTK();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aQuiet if PR_TRUE, prevent the need for user intervention
* in obtaining device context spec. if nsnull is passed in for
* the aOldSpec, this will typically result in getting a device
* context spec for the default output device (i.e. default
* printer).
* @return error status
*/
NS_IMETHOD Init(PRBool aQuiet);
/**
* Closes the printmanager if it is open.
* @update dc 2/13/98
* @update syd 3/20/99
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );
NS_IMETHOD GetGrayscale( PRBool &aGrayscale );
NS_IMETHOD GetSize ( int &aSize );
NS_IMETHOD GetTopMargin ( float &value );
NS_IMETHOD GetBottomMargin ( float &value );
NS_IMETHOD GetLeftMargin ( float &value );
NS_IMETHOD GetRightMargin ( float &value );
NS_IMETHOD GetCommand ( char **aCommand );
NS_IMETHOD GetPath ( char **aPath );
NS_IMETHOD GetUserCancelled( PRBool &aCancel );
protected:
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 2/16/98
*/
virtual ~nsDeviceContextSpecGTK();
protected:
UnixPrData mPrData;
};
#endif

View File

@@ -0,0 +1,367 @@
/* -*- 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.
*/
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
#define USE_SHM
#endif
//#define USE_SHM
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#ifdef USE_SHM
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif /* USE_SHM */
#include "nsDrawingSurfaceGTK.h"
static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID);
static NS_DEFINE_IID(kIDrawingSurfaceGTKIID, NS_IDRAWING_SURFACE_GTK_IID);
nsDrawingSurfaceGTK :: nsDrawingSurfaceGTK()
{
NS_INIT_REFCNT();
GdkVisual *v;
mPixmap = nsnull;
mGC = nsnull;
mDepth = 0;
mWidth = mHeight = 0;
mFlags = 0;
mImage = nsnull;
mLockWidth = mLockHeight = 0;
mLockFlags = 0;
mLocked = PR_FALSE;
v = ::gdk_rgb_get_visual();
mPixFormat.mRedMask = v->red_mask;
mPixFormat.mGreenMask = v->green_mask;
mPixFormat.mBlueMask = v->blue_mask;
// FIXME
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedShift = v->red_shift;
mPixFormat.mGreenShift = v->green_shift;
mPixFormat.mBlueShift = v->blue_shift;
// FIXME
mPixFormat.mAlphaShift = 0;
mDepth = v->depth;
}
nsDrawingSurfaceGTK :: ~nsDrawingSurfaceGTK()
{
if (mPixmap)
::gdk_pixmap_unref(mPixmap);
if (mImage)
::gdk_image_destroy(mImage);
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kIDrawingSurfaceIID))
{
nsIDrawingSurface* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDrawingSurfaceGTKIID))
{
nsDrawingSurfaceGTK* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID))
{
nsIDrawingSurface* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
NS_IMPL_ADDREF(nsDrawingSurfaceGTK);
NS_IMPL_RELEASE(nsDrawingSurfaceGTK);
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHODIMP nsDrawingSurfaceGTK :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
#if 0
g_print("nsDrawingSurfaceGTK::Lock() called\n" \
" aX = %i, aY = %i,\n" \
" aWidth = %i, aHeight = %i,\n" \
" aBits, aStride, aWidthBytes,\n" \
" aFlags = %i\n", aX, aY, aWidth, aHeight, aFlags);
#endif
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap.
#ifdef USE_SHM
if (gdk_get_use_xshm())
{
mImage = gdk_image_new(GDK_IMAGE_FASTEST,
gdk_rgb_get_visual(),
mLockWidth,
mLockHeight);
XShmGetImage(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(mPixmap),
GDK_IMAGE_XIMAGE(mImage),
mLockX, mLockY,
0xFFFFFFFF);
gdk_flush();
}
else
{
#endif /* USE_SHM */
mImage = ::gdk_image_get(mPixmap, mLockX, mLockY, mLockWidth, mLockHeight);
#ifdef USE_SHM
}
#endif /* USE_SHM */
*aBits = GDK_IMAGE_XIMAGE(mImage)->data;
*aWidthBytes = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
*aStride = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
#if 0
int bytes_per_line = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
//
// All this code is a an attempt to set the stride width properly.
// Needs to be cleaned up alot. For now, it will only work in the
// case where aWidthBytes and aStride are the same. One is assigned to
// the other.
//
*aWidthBytes = mImage->bpl;
*aStride = mImage->bpl;
int width_in_pixels = *aWidthBytes << 8;
int bitmap_pad = GDK_IMAGE_XIMAGE(mImage)->bitmap_pad;
int depth = GDK_IMAGE_XIMAGE(mImage)->depth;
#define RASWIDTH8(width, bpp) (width)
#define RASWIDTH16(width, bpp) ((((width) * (bpp) + 15) >> 4) << 1)
#define RASWIDTH32(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
switch(bitmap_pad)
{
case 8:
*aStride = RASWIDTH8(aWidth,bitmap_pad);
break;
case 16:
*aStride = bytes_per_line;
*aStride = RASWIDTH16(aWidth,bitmap_pad);
break;
case 32:
*aStride = bytes_per_line;
*aStride = RASWIDTH32(aWidth,bitmap_pad);
break;
default:
NS_ASSERTION(nsnull,"something got screwed");
}
*aStride = (*aWidthBytes) + ((bitmap_pad >> 3) - 1);
GDK_IMAGE_XIMAGE(mImage)->bitmap_pad;
*aWidthBytes = mImage->bpl;
#endif
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Unlock(void)
{
// g_print("nsDrawingSurfaceGTK::UnLock() called\n");
if (!mLocked)
{
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
{
#if 0
g_print("gdk_draw_image(pixmap=%p,lockx=%d,locky=%d,lockw=%d,lockh=%d)\n",
mPixmap,
mLockX, mLockY,
mLockWidth, mLockHeight);
#endif
gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
}
// FIXME if we are using shared mem, we shouldn't destroy the image...
if (mImage)
::gdk_image_destroy(mImage);
mImage = nsnull;
mLocked = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: IsPixelAddressable(PRBool *aAddressable)
{
// FIXME
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkDrawable *aDrawable, GdkGC *aGC)
{
mGC = aGC;
mPixmap = aDrawable;
// this is definatly going to be on the screen, as it will be the window of a
// widget or something.
mIsOffscreen = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: Init(GdkGC *aGC, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
// ::g_return_val_if_fail (aGC != nsnull, NS_ERROR_FAILURE);
// ::g_return_val_if_fail ((aWidth > 0) && (aHeight > 0), NS_ERROR_FAILURE);
mGC = aGC;
mWidth = aWidth;
mHeight = aHeight;
mFlags = aFlags;
// we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE;
mPixmap = ::gdk_pixmap_new(nsnull, mWidth, mHeight, mDepth);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: GetGC(GdkGC *aGC)
{
aGC = ::gdk_gc_ref(mGC);
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfaceGTK :: ReleaseGC(void)
{
::gdk_gc_unref(mGC);
return NS_OK;
}
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkGC *nsDrawingSurfaceGTK::GetGC(void)
{
return mGC;
}
GdkDrawable *nsDrawingSurfaceGTK::GetDrawable(void)
{
return mPixmap;
}

View File

@@ -0,0 +1,85 @@
/* -*- 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 nsDrawingSurfaceGTK_h___
#define nsDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include "nsIDrawingSurfaceGTK.h"
#include <gtk/gtk.h>
class nsDrawingSurfaceGTK : public nsIDrawingSurface,
public nsIDrawingSurfaceGTK
{
public:
nsDrawingSurfaceGTK();
virtual ~nsDrawingSurfaceGTK();
NS_DECL_ISUPPORTS
//nsIDrawingSurface interface
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
//nsIDrawingSurfaceGTK interface
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC);
NS_IMETHOD Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags);
/* get the GC and manage the GdkGC's refcount */
NS_IMETHOD GetGC(GdkGC *aGC);
NS_IMETHOD ReleaseGC(void);
/* below are utility functions used mostly for nsRenderingContext and nsImage
* to plug into gdk_* functions for drawing. You should not set a pointer
* that might hang around with the return from these. instead use the ones
* above. pav
*/
GdkGC *GetGC(void);
GdkDrawable *GetDrawable(void);
private:
/* general */
GdkPixmap *mPixmap;
GdkGC *mGC;
gint mDepth;
nsPixelFormat mPixFormat;
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
/* for locks */
GdkImage *mImage;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,162 @@
/* -*- 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 nsFontMetricsGTK_h__
#define nsFontMetricsGTK_h__
#include "nsIFontMetrics.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsCRT.h"
#include "nsDeviceContextGTK.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define FONT_SWITCHING
#ifdef FONT_SWITCHING
#ifdef ADD_GLYPH
#undef ADD_GLYPH
#endif
#define ADD_GLYPH(map, g) (map)[(g) >> 3] |= (1 << ((g) & 7))
#ifdef FONT_HAS_GLYPH
#undef FONT_HAS_GLYPH
#endif
#define FONT_HAS_GLYPH(map, g) (((map)[(g) >> 3] >> ((g) & 7)) & 1)
typedef struct nsFontCharSetInfo nsFontCharSetInfo;
typedef gint (*nsFontCharSetConverter)(nsFontCharSetInfo* aSelf,
const PRUnichar* aSrcBuf, PRUint32 aSrcLen, PRUint8* aDestBuf,
PRUint32 aDestLen);
struct nsFontCharSet;
class nsFontMetricsGTK;
struct nsFontGTK
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void LoadFont(nsFontCharSet* aCharSet, nsFontMetricsGTK* aMetrics);
GdkFont* mFont;
PRUint8* mMap;
nsFontCharSetInfo* mCharSetInfo;
char* mName;
PRUint16 mSize;
PRUint16 mActualSize;
PRInt16 mBaselineAdjust;
};
struct nsFontStretch;
struct nsFontFamily;
typedef struct nsFontSearch nsFontSearch;
#endif /* FONT_SWITCHING */
class nsFontMetricsGTK : public nsIFontMetrics
{
public:
nsFontMetricsGTK();
virtual ~nsFontMetricsGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIDeviceContext* aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetFont(const nsFont *&aFont);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
#ifdef FONT_SWITCHING
nsFontGTK* FindFont(PRUnichar aChar);
static gint GetWidth(nsFontGTK* aFont, const PRUnichar* aString,
PRUint32 aLength);
static void DrawString(nsDrawingSurfaceGTK* aSurface, nsFontGTK* aFont,
nscoord aX, nscoord aY, const PRUnichar* aString,
PRUint32 aLength);
static void InitFonts(void);
friend void PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
nsFontCharSet* aCharSet);
friend void TryCharSet(nsFontSearch* aSearch, nsFontCharSet* aCharSet);
friend void TryFamily(nsFontSearch* aSearch, nsFontFamily* aFamily);
friend struct nsFontGTK;
nsFontGTK **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsString *mFonts;
PRUint16 mFontsAlloc;
PRUint16 mFontsCount;
PRUint16 mFontsIndex;
#endif /* FONT_SWITCHING */
protected:
char *PickAppropriateSize(char **names, XFontStruct *fonts, int cnt, nscoord desired);
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
GdkFont *mFontHandle;
nscoord mHeight;
nscoord mAscent;
nscoord mDescent;
nscoord mLeading;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
#ifdef FONT_SWITCHING
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
#endif /* FONT_SWITCHING */
};
#endif

View File

@@ -0,0 +1,205 @@
/* -*- 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 <gtk/gtk.h>
#include "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "nsGfxCIID.h"
#include "nsFontMetricsGTK.h"
#include "nsRenderingContextGTK.h"
#include "nsImageGTK.h"
#include "nsDeviceContextGTK.h"
#include "nsRegionGTK.h"
#include "nsBlender.h"
#include "nsDeviceContextSpecG.h"
#include "nsDeviceContextSpecFactoryG.h"
#include "nsIDeviceContextSpecPS.h"
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
class nsGfxFactoryGTK : public nsIFactory
{
public:
// nsISupports methods
NS_IMETHOD QueryInterface(const nsIID &aIID,
void **aResult);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
nsGfxFactoryGTK(const nsCID &aClass);
virtual ~nsGfxFactoryGTK();
private:
nsrefcnt mRefCnt;
nsCID mClassID;
};
nsGfxFactoryGTK::nsGfxFactoryGTK(const nsCID &aClass)
{
mRefCnt = 0;
mClassID = aClass;
}
nsGfxFactoryGTK::~nsGfxFactoryGTK()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryGTK::QueryInterface(const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
AddRef(); // Increase reference count for caller
return NS_OK;
}
nsrefcnt nsGfxFactoryGTK::AddRef()
{
return ++mRefCnt;
}
nsrefcnt nsGfxFactoryGTK::Release()
{
if (--mRefCnt == 0) {
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
nsresult nsGfxFactoryGTK::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
nsISupports *inst = nsnull;
if (mClassID.Equals(kCFontMetrics)) {
inst = (nsISupports *)new nsFontMetricsGTK();
}
else if (mClassID.Equals(kCDeviceContext)) {
inst = (nsISupports *)new nsDeviceContextGTK();
}
else if (mClassID.Equals(kCRenderingContext)) {
inst = (nsISupports *)new nsRenderingContextGTK();
}
else if (mClassID.Equals(kCImage)) {
inst = (nsISupports *)new nsImageGTK();
}
else if (mClassID.Equals(kCRegion)) {
inst = (nsISupports *)new nsRegionGTK();
}
else if (mClassID.Equals(kCBlender)) {
inst = (nsISupports *)new nsBlender;
}
else if (mClassID.Equals(kCDeviceContextSpec)) {
nsDeviceContextSpecGTK* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecGTK);
inst = (nsISupports *)((nsIDeviceContextSpecPS *)dcs);
}
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
nsDeviceContextSpecFactoryGTK* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryGTK);
inst = (nsISupports *)dcs;
}
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
// else {
// inst->Release();
// }
return res;
}
nsresult nsGfxFactoryGTK::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
// return the proper factory to the caller
extern "C" NS_GFXNONXP nsresult NSGetFactory(nsISupports* servMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsGfxFactoryGTK(aClass);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
}

View File

@@ -0,0 +1,77 @@
/* -*- 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 nsIDrawingSurfaceGTK_h___
#define nsIDrawingSurfaceGTK_h___
#include "nsIDrawingSurface.h"
#include <gtk/gtk.h>
// windows specific drawing surface method set
#define NS_IDRAWING_SURFACE_GTK_IID \
{ 0x1ed958b0, 0xcab6, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
class nsIDrawingSurfaceGTK : public nsISupports
{
public:
/**
* Initialize a drawing surface using a windows DC.
* aDC is "owned" by the drawing surface until the drawing
* surface is destroyed.
* @param aDC HDC to initialize drawing surface with
* @return error status
**/
NS_IMETHOD Init(GdkDrawable *aDrawable, GdkGC *aGC) = 0;
/**
* Initialize an offscreen drawing surface using a
* windows DC. aDC is not "owned" by this drawing surface, instead
* it is used to create a drawing surface compatible
* with aDC. if width or height are less than zero, aDC will
* be created with no offscreen bitmap installed.
* @param aDC HDC to initialize drawing surface with
* @param aWidth width of drawing surface
* @param aHeight height of drawing surface
* @param aFlags flags used to control type of drawing
* surface created
* @return error status
**/
NS_IMETHOD Init(GdkGC *aGC, PRUint32 aWidth, PRUint32 aHeight,
PRUint32 aFlags) = 0;
/**
* Get a windows DC that represents the drawing surface.
* GetDC() must be paired with ReleaseDC(). Getting a DC
* and Lock()ing are mutually exclusive operations.
* @param aDC out parameter for HDC
* @return error status
**/
NS_IMETHOD GetGC(GdkGC *aGC) = 0;
/**
* Release a windows DC obtained by GetDC().
* ReleaseDC() must be preceded by a call to ReleaseDC().
* @return error status
**/
NS_IMETHOD ReleaseGC(void) = 0;
};
#endif // nsIDrawingSurfaceGTK_h___

View File

@@ -0,0 +1,515 @@
/* -*- 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 <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "nsImageGTK.h"
#include "nsRenderingContextGTK.h"
#include "nspr.h"
#define IsFlagSet(a,b) (a & b)
#undef CHEAP_PERFORMANCE_MEASURMENT
// Defining this will trace the allocation of images. This includes
// ctor, dtor and update.
#undef TRACE_IMAGE_ALLOCATION
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
//------------------------------------------------------------
nsImageGTK::nsImageGTK()
{
NS_INIT_REFCNT();
mImageBits = nsnull;
mWidth = 0;
mHeight = 0;
mDepth = 0;
mAlphaBits = nsnull;
mAlphaPixmap = nsnull;
mImagePixmap = nsnull;
mGC = nsnull;
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::nsImageGTK(this=%p)\n",
this);
#endif
}
//------------------------------------------------------------
nsImageGTK::~nsImageGTK()
{
if(nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
gdk_pixmap_unref(mAlphaPixmap);
mAlphaPixmap = nsnull;
}
if (nsnull != mImagePixmap) {
gdk_pixmap_unref(mImagePixmap);
mImagePixmap = nsnull;
}
if (nsnull != mGC) {
gdk_gc_unref(mGC);
mGC = nsnull;
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::~nsImageGTK(this=%p)\n",
this);
#endif
}
NS_IMPL_ISUPPORTS(nsImageGTK, kIImageIID);
//------------------------------------------------------------
nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth, nsMaskRequirements aMaskRequirements)
{
g_return_val_if_fail ((aWidth != 0) || (aHeight != 0), NS_ERROR_FAILURE);
if (nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if (nsnull != mAlphaBits) {
delete[] (PRUint8*)mAlphaBits;
mAlphaBits = nsnull;
}
if (nsnull != mAlphaPixmap) {
gdk_pixmap_unref(mAlphaPixmap);
mAlphaPixmap = nsnull;
}
if (nsnull != mImagePixmap) {
gdk_pixmap_unref(mImagePixmap);
mImagePixmap = nsnull;
}
if (24 == aDepth) {
mNumBytesPixel = 3;
} else {
NS_ASSERTION(PR_FALSE, "unexpected image depth");
return NS_ERROR_UNEXPECTED;
}
mImageUpdated = PR_TRUE;
mWidth = aWidth;
mHeight = aHeight;
mDepth = aDepth;
mIsTopToBottom = PR_TRUE;
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Init(this=%p,%d,%d,%d,%d)\n",
this,
aWidth,
aHeight,
aDepth,
aMaskRequirements);
#endif
// create the memory for the image
ComputMetrics();
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
switch(aMaskRequirements)
{
case nsMaskRequirements_kNoMask:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
break;
case nsMaskRequirements_kNeeds1Bit:
mAlphaRowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
// 32-bit align each row
mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3;
mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight];
mAlphaWidth = aWidth;
mAlphaHeight = aHeight;
mAlphaPixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
mAlphaDepth);
break;
case nsMaskRequirements_kNeeds8Bit:
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
mAlphaDepth = 8;
g_print("TODO: want an 8bit mask for an image..\n");
mAlphaPixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
mAlphaDepth);
break;
}
mImagePixmap = gdk_pixmap_new(nsnull, aWidth, aHeight,
gdk_rgb_get_visual()->depth);
mGC = gdk_gc_new(mImagePixmap);
return NS_OK;
}
//------------------------------------------------------------
PRInt32 nsImageGTK::CalcBytesSpan(PRUint32 aWidth)
{
PRInt32 spanbytes;
spanbytes = (aWidth * mDepth) >> 5;
if (((PRUint32)aWidth * mDepth) & 0x1F)
spanbytes++;
spanbytes <<= 2;
return(spanbytes);
}
void nsImageGTK::ComputMetrics()
{
mRowBytes = CalcBytesSpan(mWidth);
mSizeImage = mRowBytes * mHeight;
}
PRInt32 nsImageGTK::GetHeight()
{
return mHeight;
}
PRInt32 nsImageGTK::GetWidth()
{
return mWidth;
}
PRUint8 *nsImageGTK::GetBits()
{
return mImageBits;
}
void *nsImageGTK::GetBitInfo()
{
return nsnull;
}
PRInt32 nsImageGTK::GetLineStride()
{
return mRowBytes;
}
nsColorMap *nsImageGTK::GetColorMap()
{
return nsnull;
}
PRBool nsImageGTK::IsOptimized()
{
return PR_TRUE;
}
PRUint8 *nsImageGTK::GetAlphaBits()
{
return mAlphaBits;
}
PRInt32 nsImageGTK::GetAlphaWidth()
{
return mAlphaWidth;
}
PRInt32 nsImageGTK::GetAlphaHeight()
{
return mAlphaHeight;
}
PRInt32 nsImageGTK::GetAlphaLineStride()
{
return mAlphaRowBytes;
}
nsIImage *nsImageGTK::DuplicateImage()
{
return nsnull;
}
void nsImageGTK::SetAlphaLevel(PRInt32 aAlphaLevel)
{
}
PRInt32 nsImageGTK::GetAlphaLevel()
{
return 0;
}
void nsImageGTK::MoveAlphaMask(PRInt32 aX, PRInt32 aY)
{
}
//------------------------------------------------------------
// set up the palette to the passed in color array, RGB only in this array
void nsImageGTK::ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags,
nsRect *aUpdateRect)
{
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::ImageUpdated(this=%p,%d)\n",
this,
aFlags);
#endif
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged, aFlags)) {
mImageUpdated = PR_TRUE;
// FIXME do something with aUpdateRect
}
}
#ifdef CHEAP_PERFORMANCE_MEASURMENT
static PRTime gConvertTime, gStartTime, gPixmapTime, gEndTime;
#endif
// Draw the bitmap, this method has a source and destination coordinates
NS_IMETHODIMP
nsImageGTK::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
nsDrawingSurfaceGTK *drawing = (nsDrawingSurfaceGTK*)aSurface;
if (mAlphaBits)
g_print("calling nsImageGTK::Draw() with alpha bits\n");
gdk_draw_rgb_image (drawing->GetDrawable(),
mGC,
aDX, aDY, aDWidth, aDHeight,
GDK_RGB_DITHER_MAX,
mImageBits + mRowBytes * aSY + 3 * aDX,
mRowBytes);
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
NS_IMETHODIMP
nsImageGTK::Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
g_return_val_if_fail ((aSurface != nsnull), NS_ERROR_FAILURE);
// XXX kipp: this is temporary code until we eliminate the
// width/height arguments from the draw method.
if ((aWidth != mWidth) || (aHeight != mHeight)) {
aWidth = mWidth;
aHeight = mHeight;
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p,x=%d,y=%d,width=%d,height=%d)\n",
this,
aX,
aY,
aWidth,
aHeight);
#endif
nsDrawingSurfaceGTK* drawing = (nsDrawingSurfaceGTK*) aSurface;
XImage *x_image = nsnull;
Pixmap pixmap = 0;
Display *dpy = nsnull;
Visual *visual = nsnull;
GC gc;
XGCValues gcv;
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gStartTime = gPixmapTime = PR_Now();
#endif
// Create gc clip-mask on demand
if ((mAlphaBits) && (mImageUpdated == PR_TRUE))
{
/* get the X primitives */
dpy = GDK_WINDOW_XDISPLAY(mAlphaPixmap);
/* this is the depth of the pixmap that we are going to draw to.
It's always a bitmap. We're doing alpha here folks. */
visual = GDK_VISUAL_XVISUAL(gdk_rgb_get_visual());
// Make an image out of the alpha-bits created by the image library
x_image = XCreateImage(dpy, visual,
1, /* visual depth...1 for bitmaps */
XYPixmap,
0, /* x offset, XXX fix this */
(char *)mAlphaBits, /* cast away our sign. */
aWidth,
aHeight,
32,/* bitmap pad */
mAlphaRowBytes); /* bytes per line */
x_image->bits_per_pixel=1;
/* Image library always places pixels left-to-right MSB to LSB */
x_image->bitmap_bit_order = MSBFirst;
/* This definition doesn't depend on client byte ordering
because the image library ensures that the bytes in
bitmask data are arranged left to right on the screen,
low to high address in memory. */
x_image->byte_order = MSBFirst;
#if defined(IS_LITTLE_ENDIAN)
// no, it's still MSB XXX check on this!!
// x_image->byte_order = LSBFirst;
#elif defined (IS_BIG_ENDIAN)
x_image->byte_order = MSBFirst;
#else
#error ERROR! Endianness is unknown;
#endif
// Write into the pixemap that is underneath gdk's mAlphaPixmap
// the image we just created.
pixmap = GDK_WINDOW_XWINDOW(mAlphaPixmap);
memset(&gcv, 0, sizeof(XGCValues));
gcv.function = GXcopy;
gc = XCreateGC(dpy, pixmap, GCFunction, &gcv);
XPutImage(dpy, pixmap, gc, x_image, 0, 0, 0, 0,
aWidth, aHeight);
XFreeGC(dpy, gc);
// Now we are done with the temporary image
x_image->data = 0; /* Don't free the IL_Pixmap's bits. */
XDestroyImage(x_image);
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gPixmapTime = PR_Now();
#endif
}
// Render unique image bits onto an off screen pixmap only once
// The image bits can change as a result of ImageUpdated() - for
// example: animated GIFs.
if (mImageUpdated == PR_TRUE)
{
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p) gdk_pixmap_new(nsnull,width=%d,height=%d,depth=%d)\n",
this,
aWidth,
aHeight,
mDepth);
#endif
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
// Render the image bits into an off screen pixmap
gdk_draw_rgb_image (mImagePixmap,
mGC,
0, 0, aWidth, aHeight,
GDK_RGB_DITHER_MAX,
mImageBits, mRowBytes);
if (mAlphaPixmap)
{
// Setup gc to use the given alpha-pixmap for clipping
gdk_gc_set_clip_mask(mGC, mAlphaPixmap);
gdk_gc_set_clip_origin(mGC, aX, aY);
}
#ifdef TRACE_IMAGE_ALLOCATION
printf("nsImageGTK::Draw(this=%p) gdk_draw_pixmap(x=%d,y=%d,width=%d,height=%d)\n",
this,
aX,
aY,
aWidth,
aHeight);
#endif
mImageUpdated = PR_FALSE;
}
// copy our offscreen pixmap onto the window.
gdk_window_copy_area(drawing->GetDrawable(), // dest window
mGC, // gc
aX, // xsrc
aY, // ysrc
mImagePixmap, // source window
0, // xdest
0, // ydest
aWidth, // width
aHeight); // height
if (mAlphaBits)
{
// Revert gc to its old clip-mask and origin
gdk_gc_set_clip_origin(mGC, 0, 0);
gdk_gc_set_clip_mask(mGC, nsnull);
}
#ifdef CHEAP_PERFORMANCE_MEASURMENT
gEndTime = PR_Now();
printf("nsImageGTK::Draw(this=%p,w=%d,h=%d) total=%lld pixmap=%lld, cvt=%lld\n",
this,
aWidth, aHeight,
gEndTime - gStartTime,
gPixmapTime - gStartTime,
gConvertTime - gPixmapTime);
#endif
mImageUpdated = PR_FALSE;
return NS_OK;
}
//------------------------------------------------------------
nsresult nsImageGTK::Optimize(nsIDeviceContext* aContext)
{
return NS_OK;
}

View File

@@ -0,0 +1,115 @@
/* -*- 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 nsImageGTK_h___
#define nsImageGTK_h___
#include "nsIImage.h"
#include "X11/Xlib.h"
#include "X11/Xutil.h"
#include <gdk/gdk.h>
#undef Bool
class nsImageGTK : public nsIImage
{
public:
nsImageGTK();
virtual ~nsImageGTK();
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
virtual PRInt32 GetHeight();
virtual PRInt32 GetWidth();
virtual PRUint8* GetBits();
virtual void* GetBitInfo();
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
virtual PRInt32 GetLineStride();
virtual nsColorMap* GetColorMap();
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual void ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized();
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRUint8* GetAlphaBits();
virtual PRInt32 GetAlphaWidth();
virtual PRInt32 GetAlphaHeight();
virtual PRInt32 GetAlphaLineStride();
virtual nsIImage* DuplicateImage();
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
PRInt32 CalcBytesSpan(PRUint32 aWidth);
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
virtual PRInt32 GetAlphaLevel();
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
private:
/**
* Calculate the amount of memory needed for the initialization of the image
*/
void ComputMetrics();
void ComputePaletteSize(PRIntn nBitCount);
private:
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // bits per pixel
PRInt32 mRowBytes;
PRUint8 *mImageBits;
PRUint8 *mConvertedBits;
PRInt32 mSizeImage;
PRBool mIsTopToBottom;
PRBool mImageUpdated;
PRInt8 mNumBytesPixel;
// alpha layer members
PRUint8 *mAlphaBits;
GdkPixmap *mAlphaPixmap;
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mAlphaRowBytes; // alpha bytes per row
PRInt16 mAlphaWidth; // alpha layer width
PRInt16 mAlphaHeight; // alpha layer height
nsPoint mLocation; // alpha mask location
GdkPixmap *mImagePixmap;
GdkGC *mGC;
};
#endif

View File

@@ -0,0 +1,452 @@
/* -*- 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.
*/
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#include <gtk/gtk.h>
#include "nspr.h"
#include "nsPrintdGTK.h"
/* A structure to hold widgets that need to be referenced in callbacks. We
declare this statically in the caller entry point (as a field of
UnixPrOps, below), and pass a pointer to the structure to Gtk+ for each
signal handler registered. This avoids use of globals. */
typedef struct prwidgets {
GtkWidget *toplevel; /* should be set to toplevel window */
GtkWidget *prDialog;
GtkWidget *cmdEntry;
GtkWidget *pathEntry;
GtkWidget *browseButton;
GtkWidget *fpfToggle;
GtkWidget *greyToggle;
GtkWidget *letterToggle;
GtkWidget *legalToggle;
GtkWidget *execToggle;
GtkWidget *topSpinner;
GtkWidget *bottomSpinner;
GtkWidget *leftSpinner;
GtkWidget *rightSpinner;
GtkFileSelection *fsWidget;
} PrWidgets;
typedef struct unixprops {
UnixPrData *prData; /* pointer to caller struct */
PrWidgets widgets;
} UnixPrOps;
/* user clicked cancel. tear things down, and set cancel field in
caller data to PR_TRUE so printing will not happen */
static void
CancelPrint (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_TRUE;
}
/* user selected the Print button. Collect any remaining data from the
widgets, and set cancel field in caller data to PR_FALSE so printing
will be performed. Also, tear down dialog and exit inner main loop */
static void
DoPrint (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->command,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.cmdEntry ) ) );
strcpy( prOps->prData->path,
gtk_entry_get_text( GTK_ENTRY( prOps->widgets.pathEntry ) ) );
if ( GTK_TOGGLE_BUTTON( prOps->widgets.fpfToggle )->active == PR_TRUE )
prOps->prData->fpf = PR_TRUE;
else
prOps->prData->fpf = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.greyToggle )->active == PR_TRUE )
prOps->prData->grayscale = PR_TRUE;
else
prOps->prData->grayscale = PR_FALSE;
if ( GTK_TOGGLE_BUTTON( prOps->widgets.letterToggle )->active == PR_TRUE )
prOps->prData->size = NS_LETTER_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.legalToggle )->active == PR_TRUE )
prOps->prData->size = NS_LEGAL_SIZE;
else if ( GTK_TOGGLE_BUTTON( prOps->widgets.execToggle )->active == PR_TRUE )
prOps->prData->size = NS_EXECUTIVE_SIZE;
else
prOps->prData->size = NS_A4_SIZE;
/* margins */
prOps->prData->top = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.topSpinner) );
prOps->prData->bottom = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.bottomSpinner) );
prOps->prData->left = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.leftSpinner) );
prOps->prData->right = gtk_spin_button_get_value_as_float(
GTK_SPIN_BUTTON(prOps->widgets.rightSpinner) );
/* we got everything... bring down the dialog and tell caller
it's o.k. to print */
gtk_main_quit();
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.prDialog) );
prOps->prData->cancel = PR_FALSE;
}
/* User hit ok in file selection widget brought up by the browse button.
snarf the selected file, stuff it in caller data */
static void
ModifyPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
strcpy( prOps->prData->path,
gtk_file_selection_get_filename(prOps->widgets.fsWidget) );
gtk_entry_set_text (GTK_ENTRY (prOps->widgets.pathEntry),
prOps->prData->path);
gtk_widget_destroy( GTK_WIDGET(prOps->widgets.fsWidget) );
}
/* user selected print to printer. de-sensitize print to file fields */
static void
SwitchToPrinter (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_FALSE );
prOps->prData->toPrinter = PR_TRUE;
}
/* user selected print to file. de-sensitize print to printer fields */
static void
SwitchToFile (GtkWidget *widget, UnixPrOps *prOps)
{
gtk_widget_set_sensitive( prOps->widgets.cmdEntry, PR_FALSE );
gtk_widget_set_sensitive( prOps->widgets.pathEntry, PR_TRUE );
gtk_widget_set_sensitive( prOps->widgets.browseButton, PR_TRUE );
prOps->prData->toPrinter = PR_FALSE;
}
/* user hit the browse button. Pop up a file selection widget and grab
result */
static void
GetPrPath (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *fs;
fs = gtk_file_selection_new("Netscape: File Browser");
gtk_file_selection_set_filename( GTK_FILE_SELECTION(fs),
prOps->prData->path );
gtk_window_set_modal (GTK_WINDOW(fs),PR_TRUE);
#if 0
/* XXX not sure what the toplevel window should be. */
gtk_window_set_transient_for (GTK_WINDOW (fs),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
prOps->widgets.fsWidget = GTK_FILE_SELECTION(fs);
gtk_signal_connect (GTK_OBJECT(GTK_FILE_SELECTION(fs)->ok_button),
"clicked", GTK_SIGNAL_FUNC(ModifyPrPath), prOps);
gtk_signal_connect_object (GTK_OBJECT(
GTK_FILE_SELECTION(fs)->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT (fs));
gtk_widget_show(fs);
}
/* create file data dialog. XXX widget should be NULL */
static void
DoPrintGTK (GtkWidget *widget, UnixPrOps *prOps)
{
GtkWidget *separator, *dialog, *label, *vbox, *entry, *hbox,
*button, *fileButton, *prButton, *table, *spinner1;
GtkAdjustment *adj;
prOps->widgets.prDialog = dialog =
gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_window_set_modal( GTK_WINDOW(dialog), PR_TRUE );
#if 0
/* not yet sure what the toplevel window should be */
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (prOps->widgets.toplevel));
#endif
gtk_window_set_title( GTK_WINDOW(dialog), "Netscape: Print" );
vbox = gtk_vbox_new (PR_FALSE, 0);
gtk_container_add (GTK_CONTAINER (dialog), vbox);
table = gtk_table_new (3, 3, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_TRUE, 5);
label = gtk_label_new( "Print To:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
0, GTK_EXPAND | GTK_FILL, 0, 0);
button = prButton = gtk_radio_button_new_with_label (NULL, "Printer");
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = fileButton = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)), "File");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
label = gtk_label_new( "Print Command:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->command);
gtk_table_attach (GTK_TABLE (table), entry, 1, 3, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
if ( prOps->prData->toPrinter == PR_FALSE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.cmdEntry = entry;
label = gtk_label_new( "File Name:" );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
0, GTK_EXPAND | GTK_FILL, 0, 0);
entry = gtk_entry_new ();
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_entry_set_text (GTK_ENTRY (entry), prOps->prData->path);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.pathEntry = entry;
button = gtk_button_new_with_label ("Browse...");
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (GetPrPath), prOps);
if ( prOps->prData->toPrinter == PR_TRUE )
gtk_widget_set_sensitive( entry, PR_FALSE );
prOps->widgets.browseButton = button;
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
table = gtk_table_new (2, 4, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "First Page First");
if ( prOps->prData->fpf == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
prOps->widgets.fpfToggle = button;
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Last Page First");
if ( prOps->prData->fpf == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Print: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL, "Greyscale");
prOps->widgets.greyToggle = button;
if ( prOps->prData->grayscale == PR_TRUE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Color");
if ( prOps->prData->grayscale == PR_FALSE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Paper Size: " );
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (NULL,
"Letter (8 1/2 x 11 in.)");
prOps->widgets.letterToggle = button;
if ( prOps->prData->size == NS_LETTER_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Legal (8 1/2 x 14 in.)");
prOps->widgets.legalToggle = button;
if ( prOps->prData->size == NS_LEGAL_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"Executive (7 1/2 x 10 in.)");
prOps->widgets.execToggle = button;
if ( prOps->prData->size == NS_EXECUTIVE_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 1, 2, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
button = gtk_radio_button_new_with_label (
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
"A4 (210 x 297 mm)");
if ( prOps->prData->size == NS_A4_SIZE )
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
PR_TRUE);
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 4, 5,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
/* margins */
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_FALSE, PR_FALSE, 5);
label = gtk_label_new( "Margins (inches):" );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_FALSE, PR_FALSE, 10);
table = gtk_table_new (1, 2, PR_FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
gtk_container_set_border_width (GTK_CONTAINER (table), 10);
gtk_box_pack_start (GTK_BOX (vbox), table, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Top: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.topSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Bottom: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.bottomSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new( "Left: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.75, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.leftSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
label = gtk_label_new( "Right: " );
gtk_box_pack_start (GTK_BOX (hbox), label, PR_TRUE, PR_FALSE, 0);
adj = (GtkAdjustment *) gtk_adjustment_new (0.75, 0.0, 999.0,
0.25, 1.0, 0.0);
prOps->widgets.rightSpinner = spinner1 =
gtk_spin_button_new (adj, 1.0, 2);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
gtk_widget_set_usize (spinner1, 60, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinner1, FALSE, TRUE, 0);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, PR_TRUE, PR_FALSE, 0);
hbox = gtk_hbox_new (PR_FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, PR_TRUE, PR_FALSE, 5);
button = gtk_button_new_with_label ("Print");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (DoPrint), prOps );
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_widget_grab_default (button);
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC ( CancelPrint ), prOps);
gtk_box_pack_start (GTK_BOX (hbox), button, PR_TRUE, PR_FALSE, 0);
/* Do this here, otherwise, upon creation the callbacks will be
triggered and the widgets these callbacks set sensitivity on
do not exist yet */
gtk_signal_connect (GTK_OBJECT (prButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToPrinter), prOps);
gtk_signal_connect (GTK_OBJECT (fileButton), "clicked",
GTK_SIGNAL_FUNC (SwitchToFile), prOps);
gtk_widget_show_all( dialog );
gtk_main ();
}
/* public interface to print dialog. Caller passes in preferences using
argument, we return any changes and indication of whether to print
or cancel. */
void
UnixPrDialog( UnixPrData *prData )
{
static UnixPrOps prOps;
prOps.prData = prData;
DoPrintGTK( (GtkWidget *) NULL, &prOps );
}

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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.
*/
/* Original Code: Syd Logan (syd@netscape.com) 3/12/99 */
#ifndef nsPrintdGTK_h___
#define nsPrintdGTK_h___
#include <limits.h>
PR_BEGIN_EXTERN_C
/* stolen from nsPostScriptObj.h. needs to be put somewhere else that
both ps and gtk can see easily */
#ifndef NS_LEGAL_SIZE
#define NS_LETTER_SIZE 0
#define NS_LEGAL_SIZE 1
#define NS_EXECUTIVE_SIZE 2
#define NS_A4_SIZE 3
#endif
#ifndef PATH_MAX
#define PATH_MAX _POSIX_PATH_MAX
#endif
typedef struct unixprdata {
PRBool toPrinter; /* If PR_TRUE, print to printer */
PRBool fpf; /* If PR_TRUE, first page first */
PRBool grayscale; /* If PR_TRUE, print grayscale */
int size; /* Paper size e.g., SizeLetter */
char command[ PATH_MAX ]; /* Print command e.g., lpr */
char path[ PATH_MAX ]; /* If toPrinter = PR_FALSE, dest file */
PRBool cancel; /* If PR_TRUE, user cancelled */
float left; /* left margin */
float right; /* right margin */
float top; /* top margin */
float bottom; /* bottom margin */
} UnixPrData;
void UnixPrDialog(UnixPrData *prData);
PR_END_EXTERN_C
#endif /* nsPrintdGTK_h___ */

View File

@@ -0,0 +1,302 @@
/* -*- 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 <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include "nsRegionGTK.h"
#include "xregion.h"
#include "prmem.h"
static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
nsRegionGTK::nsRegionGTK()
{
NS_INIT_REFCNT();
mRegion = nsnull;
mRegionType = eRegionComplexity_empty;
}
nsRegionGTK::~nsRegionGTK()
{
if (mRegion)
::gdk_region_destroy(mRegion);
mRegion = nsnull;
}
NS_IMPL_QUERY_INTERFACE(nsRegionGTK, kRegionIID)
NS_IMPL_ADDREF(nsRegionGTK)
NS_IMPL_RELEASE(nsRegionGTK)
nsresult nsRegionGTK::Init(void)
{
NS_ADDREF_THIS();
mRegion = ::gdk_region_new();
mRegionType = eRegionComplexity_empty;
return NS_OK;
}
void nsRegionGTK::SetTo(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
SetRegionEmpty();
GdkRegion *nRegion = ::gdk_regions_union(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::SetTo(const nsRegionGTK *aRegion)
{
SetRegionEmpty();
GdkRegion *nRegion = ::gdk_regions_union(mRegion, aRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
SetRegionEmpty();
GdkRectangle grect;
grect.x = aX;
grect.y = aY;
grect.width = aWidth;
grect.height = aHeight;
GdkRegion *nRegion = ::gdk_region_union_with_rect(mRegion, &grect);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Intersect(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_intersect(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_intersect(mRegion, tRegion);
::gdk_region_destroy(tRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Union(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_union(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_union(mRegion, tRegion);
::gdk_region_destroy(mRegion);
::gdk_region_destroy(tRegion);
mRegion = nRegion;
}
void nsRegionGTK::Subtract(const nsIRegion &aRegion)
{
nsRegionGTK * pRegion = (nsRegionGTK *)&aRegion;
GdkRegion *nRegion = ::gdk_regions_subtract(mRegion, pRegion->mRegion);
::gdk_region_destroy(mRegion);
mRegion = nRegion;
}
void nsRegionGTK::Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkRegion *tRegion = CreateRectRegion(aX, aY, aWidth, aHeight);
GdkRegion *nRegion = ::gdk_regions_subtract(mRegion, tRegion);
::gdk_region_destroy(mRegion);
::gdk_region_destroy(tRegion);
mRegion = nRegion;
}
PRBool nsRegionGTK::IsEmpty(void)
{
return (::gdk_region_empty(mRegion));
}
PRBool nsRegionGTK::IsEqual(const nsIRegion &aRegion)
{
nsRegionGTK *pRegion = (nsRegionGTK *)&aRegion;
return(::gdk_region_equal(mRegion, pRegion->mRegion));
}
void nsRegionGTK::GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
{
GdkRectangle rect;
::gdk_region_get_clipbox(mRegion, &rect);
*aX = rect.x;
*aY = rect.y;
*aWidth = rect.width;
*aHeight = rect.height;
}
void nsRegionGTK::Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
::gdk_region_offset(mRegion, aXOffset, aYOffset);
}
PRBool nsRegionGTK::ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
GdkOverlapType containment;
GdkRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
containment = ::gdk_region_rect_in(mRegion, &rect);
if (containment != GDK_OVERLAP_RECTANGLE_OUT)
return PR_TRUE;
else
return PR_FALSE;
}
NS_IMETHODIMP nsRegionGTK::GetRects(nsRegionRectSet **aRects)
{
nsRegionRectSet *rects;
GdkRegionPrivate *priv = (GdkRegionPrivate *)mRegion;
Region pRegion = priv->xregion;
int nbox;
BOX *pbox;
nsRegionRect *rect;
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
//code lifted from old xfe. MMP
pbox = pRegion->rects;
nbox = pRegion->numRects;
rects = *aRects;
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32)nbox))
{
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));
if (nsnull == buf)
{
if (nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet *)buf;
rects->mRectsLen = nbox;
}
rects->mNumRects = nbox;
rects->mArea = 0;
rect = &rects->mRects[0];
while (nbox--)
{
rect->x = pbox->x1;
rect->width = (pbox->x2 - pbox->x1);
rect->y = pbox->y1;
rect->height = (pbox->y2 - pbox->y1);
rects->mArea += rect->width * rect->height;
pbox++;
rect++;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::FreeRects(nsRegionRectSet *aRects)
{
if (nsnull != aRects)
PR_Free((void *)aRects);
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::GetNativeRegion(void *&aRegion) const
{
aRegion = (void *)mRegion;
return NS_OK;
}
NS_IMETHODIMP nsRegionGTK::GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
// cast to avoid const-ness problems on some compilers
if (((nsRegionGTK*)this)->IsEmpty())
aComplexity = eRegionComplexity_empty;
else
aComplexity = eRegionComplexity_complex;
return NS_OK;
}
void nsRegionGTK::SetRegionEmpty()
{
if (!IsEmpty()) {
::gdk_region_destroy(mRegion);
mRegion = ::gdk_region_new();
}
}
GdkRegion *nsRegionGTK::CreateRectRegion(PRInt32 aX,
PRInt32 aY,
PRInt32 aWidth,
PRInt32 aHeight)
{
GdkRegion *tRegion = ::gdk_region_new();
GdkRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
GdkRegion *rRegion = ::gdk_region_union_with_rect(tRegion, &rect);
::gdk_region_destroy(tRegion);
return (rRegion);
}

View File

@@ -0,0 +1,63 @@
/* -*- 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 nsRegionGTK_h___
#define nsRegionGTK_h___
#include "nsIRegion.h"
class nsRegionGTK : public nsIRegion
{
public:
nsRegionGTK();
virtual ~nsRegionGTK();
NS_DECL_ISUPPORTS
virtual nsresult Init();
virtual void SetTo(const nsIRegion &aRegion);
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void SetTo(const nsRegionGTK *aRegion);
virtual void Intersect(const nsIRegion &aRegion);
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Union(const nsIRegion &aRegion);
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual void Subtract(const nsIRegion &aRegion);
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool IsEmpty(void);
virtual PRBool IsEqual(const nsIRegion &aRegion);
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
GdkRegion *CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
private:
GdkRegion *mRegion;
nsRegionComplexity mRegionType;
virtual void SetRegionEmpty();
};
#endif // nsRegionGTK_h___

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,173 @@
/* -*- 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 nsRenderingContextGTK_h___
#define nsRenderingContextGTK_h___
#include "nsIRenderingContext.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsImageGTK.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsDrawingSurfaceGTK.h"
#include "nsRegionGTK.h"
#include <gtk/gtk.h>
class nsRenderingContextGTK : public nsIRenderingContext
{
public:
nsRenderingContextGTK();
virtual ~nsRenderingContextGTK();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
//locals
NS_IMETHOD CommonInit();
protected:
nsDrawingSurfaceGTK *mOffscreenSurface;
nsDrawingSurfaceGTK *mSurface;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
nsRegionGTK *mClipRegion;
nsTransform2D *mTMatrix;
float mP2T;
GdkWChar* mDrawStringBuf;
PRUint32 mDrawStringSize;
// graphic state stack (GraphicsState)
nsVoidArray *mStateCache;
nscolor mCurrentColor;
GdkFont *mCurrentFont;
nsLineStyle mCurrentLineStyle;
};
#endif /* nsRenderingContextGTK_h___ */

8196
mozilla/gfx/src/gtk/u2j208.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,177 @@
/* $XConsortium: region.h,v 11.13 91/09/10 08:21:49 rws Exp $ */
/************************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#ifndef _XREGION_H
#define _XREGION_H
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;
#ifdef TRUE
#undef TRUE
#endif
#define TRUE 1
#ifndef FALSE
#define FALSE 0
#endif
#ifndef MAXSHORT
#define MAXSHORT 32767
#endif
#ifndef MINSHORT
#define MINSHORT -MAXSHORT
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
* clip region
*/
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;
/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/
/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)
/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}
/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
(firstrect) = (BOX *) Xrealloc \
((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
if ((firstrect) == 0)\
return(0);\
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}
/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))
/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}
/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}
#define EMPTY_REGION(pReg) pReg->numRects = 0
#define REGION_NOT_EMPTY(pReg) pReg->numRects
#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )
/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200
/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;
#endif

View File

@@ -1,10 +0,0 @@
Index: DOMAccessor.java
===================================================================
RCS file: /cvsroot/mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java,v
retrieving revision 1.2
diff -r1.2 DOMAccessor.java
31a32,33
> import org.mozilla.dom.util.GenericDocLoadListener;
>
38a41
> addDocumentLoadListener(new GenericDocLoadListener("JavaDOM"));

View File

@@ -1,30 +0,0 @@
#!gmake
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# 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.org 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.
#
# Contributor(s):
DEPTH = ../..
topsrcdir = ../..
VPATH = .
srcdir = .
include $(DEPTH)/config/autoconf.mk
DIRS = src jni classes
include $(topsrcdir)/config/rules.mk

View File

@@ -1,30 +0,0 @@
#!gmake
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# 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.org 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.
#
# Contributor(s):
DEPTH = ../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = src jni classes
include $(topsrcdir)/config/rules.mk

View File

@@ -1,144 +0,0 @@
Sources
=======
The sources are located in mozilla/java/dom.
Subdirectories
classes
jni
src
tests
contain Java sources, Java native methods implementation,
native c++ code and Java DOM API tests respectively.
Building
========
Requirenments:
--------------
Current mozilla build
JDK1.2 or JDK1.3
Perl 5 must be in your path
JDKHOME environment variable set to your JDK dir
CLASSPATH environment cvariable set to contain
org.w3c.dom classes. The sources can be found at
http://www.w3.org/TR/2000/CR-DOM-Level-2-20000307/java-binding.html
and the binaries can be found at http://www.mozilla.org/projects/blackwood/webclient/bin/m3/files.html
Solaris specific
----------------
Add following directories to LD_LIBRARY_PATH environment variable:
$MOZILLA_FIVE_HOME
$JDKHOME/jre/lib/$HOSTTYPE/native_threads
$JDKHOME/jre/lib/$HOSTTYPE/classic
$JDKHOME/jre/lib/$HOSTTYPE/
goto mozilla/java/dom directory and type "gmake"
Windows NT specific
-------------------
To enable OJI usage set environment variable JAVA_DOM_OJI_ENABLE=1
Add following directories to PATH environment variable:
%MOZILLA_FIVE_HOME%
%JDKHOME%\jre\bin\classic (only in case you don't use OJI)
goto mozilla/java/dom directory and type "nmake /f makefile.win"
Using the Java DOM API
======================
A Java component obtains a org.w3c.dom.Document by registering for
Document load notifications. The Document is passed in along with the
notifications. The preferred way for a Java component to register for
Document load notifications is to register via the DOMAccessor class.
However, this is possible only if OJI usage is enabled. This works
on Windows NT platform.
On Solaris currently the nsJavaDOM component instantiates its own JVM.
When an OJI-compatible JVM is available, we will move over to using it.
So, one has to apply two patches to
mozilla/webshell/src/nsWebShell.cpp
mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java
They can be found at mozilla/java/dom directory.
The first one inits nsJavaDOM component and adds it as a
document load observer listener.
The second one registers a document load listener via DOMAccessor.
Note:
any class that implements the DocumentLoadListener interface may
stand for GenericDocLoadListener.
After applying a patch to nsWebShell.cpp edit
mozilla/webshell/src/Makefile.in to add -DJAVA_DOM to the list of
defines. Then do a gmake in this directory.
After applying a patch to DOMAccessor.java go to mozilla/java/dom/classes
and do a gmake. No changes in makefiles are needed.
You can find examples of Java DOM API usage in
mozilla/java/dom/classes/org/mozilla/dom/util
mozilla/java/dom/tests/src/applets
DOM2 events
------------
At the moment all DOM2 event-related interfaces are present
however they are not fully implemented yet
because Mozilla's core DOM does not support DOM2 events fully.
Consequences:
- some methods throws OperationUnsupportedException()
The basic implementation architecture is following:
- NodeImpl is extended to support EventTarget interface
- for every addEventListener call special NativeDOMProxyListener object is
created and is registered with Mozilla's DOM
It's task is to propagate event notifications from Mozilla's DOM
to target Java EventListener
- In order to sucessfully unregister EventListeners we need to
save association between java EventListener and corresponding
NativeDOMProxyListener object. This is done by storing such
associations Vector at NodeImpl
- javaDOMEventsGlobals class is used much like javaDOMGlobals for caching
(this code may be moved to javaDOMGlobals)
NSPR Logging
------------
The NSPR Log module name is javadom. For instructions on how to enable
logging, see dist/include/prlog.h
Debug output
------------
The debug build of the Java DOM API creates the JVM with the verbose
and the verboseGC options turned on, to help in debugging. It also
creates two files in the current working directory, dom-java.txt and
dom-cpp.txt, which are simple dumps of the DOM, as printed from C++
and from Java. The two should be identical. The code to write these
files is, essentially, my regression test. Feel free to add to it.
Dependencies
------------
Currently tested on Solaris 7 only with Java 2 SDK 1.2.1. egcs-2.91.66,
Sun Workshop C++ 4.2 and 5.0 have been know to compile this code
fine. gcc-2.8.1 does *not* work. I have not used anything
Java2-specific, and it works with JDK1.1.x too (I have been using JDK
1.1.6 too).
References
----------
I highly recommend reading Sheng Liang's new JNI book.

View File

@@ -1,25 +0,0 @@
o Convert to using IDL and GenericFactories. Once support for
ComponentLoaders is implemented in xpcom, use that to load our
component.
[5d]
o Use OJI to obtain the JVM.
[5d. Awaiting OJI availability]
o i18n the API
o Use nsISupportsProxies to work around thread
limitations. This will mean writing an IDL for nsIJavaDOM.h, but
that sould be trivial. Dcumentation for nsISupportsProxies is
available at
http://www.mozilla.org/projects/xpcom/Proxies.html.
[2w. Assigned. Contact: Sergey Lunegov <lsv@sparc.spb.su>]
o Investigate the possibility of writing a tool that can generate the
JNI code from idl. This is the only practical way to implement the
HTML DOM (because it is too big to hand-code).
[4w+]

View File

@@ -1,42 +0,0 @@
#!gmake
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# 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.org 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.
#
# Contributor(s):
DEPTH = ../../..
topsrcdir = ../../..
VPATH = .
srcdir = .
IGNORE_MANIFEST=1
JAVA_OR_NSJVM=1
NO_CAFE=1
JDIRS = org/mozilla/dom \
org/mozilla/dom/events \
org/mozilla/dom/util \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
JAVAC_PROG = $(JDKHOME)/bin/javac
JAVAC_FLAGS = -classpath $(CLASSPATH):$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
JAVAC = $(JAVAC_PROG) $(JAVAC_FLAGS)

View File

@@ -1,42 +0,0 @@
#!gmake
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# 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.org 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.
#
# Contributor(s):
DEPTH = ../../..
topsrcdir = @top_srcdir@
VPATH = @srcdir@
srcdir = @srcdir@
IGNORE_MANIFEST=1
JAVA_OR_NSJVM=1
NO_CAFE=1
JDIRS = org/mozilla/dom \
org/mozilla/dom/events \
org/mozilla/dom/util \
$(NULL)
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
JAVAC_PROG = $(JDKHOME)/bin/javac
JAVAC_FLAGS = -classpath $(CLASSPATH) -d $(JAVA_DESTPATH)
JAVAC = $(JAVAC_PROG) $(JAVAC_FLAGS)

View File

@@ -1,39 +0,0 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are
# Copyright (C) 1999 Sun Microsystems, Inc. All
# Rights Reserved.
#
# Contributor(s):
IGNORE_MANIFEST=1
DEPTH = ..\..\..
JAVA_OR_NSJVM=1
NO_CAFE=1
include <$(DEPTH)\config\config.mak>
# for compatibility
include <$(DEPTH)\java\config\localdefs.mak>
JDIRS = org\mozilla\dom \
org\mozilla\dom\events \
org\mozilla\dom\util \
$(NULL)
JAVAC_PROG=$(JDKHOME)\bin\javac
JAVAC_FLAGS=-classpath $(CLASSPATH);$(JAVA_DESTPATH) -d $(JAVA_DESTPATH)
include <$(DEPTH)\config\rules.mak>

View File

@@ -1,45 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
public class AttrImpl extends NodeImpl implements Attr {
// instantiated from JNI or Document.createAttribute()
private AttrImpl() {}
public native String getName();
public native boolean getSpecified();
public native String getValue();
public native void setValue(String value);
/**
* The <code>Element</code> node this attribute is attached to or
* <code>null</code> if this attribute is not in use.
* @since DOM Level 2
*/
public Element getOwnerElement() {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,31 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.CDATASection;
public class CDATASectionImpl extends TextImpl implements CDATASection {
// instantiated from JNI or Document.createCDATASection()
private CDATASectionImpl() {}
}

View File

@@ -1,39 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.CharacterData;
public class CharacterDataImpl extends NodeImpl implements CharacterData {
// instantiated from JNI only
protected CharacterDataImpl() {}
public native void appendData(String arg);
public native void deleteData(int offset, int count);
public native String getData();
public native int getLength();
public native void insertData(int offset, String arg);
public native void replaceData(int offset, int count, String arg);
public native void setData(String data);
public native String substringData(int offset, int count);
}

View File

@@ -1,30 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Comment;
public class CommentImpl extends CharacterDataImpl implements Comment {
// instantiated from JNI or Document.createComment()
private CommentImpl() {}
}

View File

@@ -1,146 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import java.util.Vector;
import java.util.Enumeration;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import java.security.AccessController;
public final class DOMAccessor {
private static Vector documentLoadListeners = new Vector();
private static JavaDOMPermission permission = new JavaDOMPermission("JavaDOM");
static {
System.loadLibrary("javadomjni");
}
private void DOMAccessorImpl() {}
private static native void register();
private static native void unregister();
private static native Node getNodeByHandle(long p);
private static native void doGC();
public static native void initialize();
public static synchronized void
addDocumentLoadListener(DocumentLoadListener listener) {
if (documentLoadListeners.size() == 0) {
register();
}
documentLoadListeners.addElement(listener);
}
public static synchronized void
removeDocumentLoadListener(DocumentLoadListener listener) {
documentLoadListeners.removeElement(listener);
if (documentLoadListeners.size() == 0) {
unregister();
}
}
public static synchronized void
startURLLoad(String url, String contentType, long p_doc) {
AccessController.checkPermission(permission);
for (Enumeration e = documentLoadListeners.elements();
e.hasMoreElements();) {
DocumentLoadListener listener =
(DocumentLoadListener) e.nextElement();
listener.startURLLoad(url, contentType, (Document)getNodeByHandle(p_doc));
}
doGC();
}
public static synchronized void
endURLLoad(String url, int status, long p_doc) {
AccessController.checkPermission(permission);
for (Enumeration e = documentLoadListeners.elements();
e.hasMoreElements();) {
DocumentLoadListener listener =
(DocumentLoadListener) e.nextElement();
listener.endURLLoad(url, status, (Document)getNodeByHandle(p_doc));
}
doGC();
}
public static synchronized void
progressURLLoad(String url, int progress, int progressMax,
long p_doc) {
AccessController.checkPermission(permission);
for (Enumeration e = documentLoadListeners.elements();
e.hasMoreElements();) {
DocumentLoadListener listener =
(DocumentLoadListener) e.nextElement();
listener.progressURLLoad(url, progress, progressMax, (Document)getNodeByHandle(p_doc));
}
doGC();
}
public static synchronized void
statusURLLoad(String url, String message, long p_doc) {
AccessController.checkPermission(permission);
for (Enumeration e = documentLoadListeners.elements();
e.hasMoreElements();) {
DocumentLoadListener listener =
(DocumentLoadListener) e.nextElement();
listener.statusURLLoad(url, message, (Document)getNodeByHandle(p_doc));
}
doGC();
}
public static synchronized void
startDocumentLoad(String url) {
AccessController.checkPermission(permission);
for (Enumeration e = documentLoadListeners.elements();
e.hasMoreElements();) {
DocumentLoadListener listener =
(DocumentLoadListener) e.nextElement();
listener.startDocumentLoad(url);
}
doGC();
}
public static synchronized void
endDocumentLoad(String url, int status, long p_doc) {
AccessController.checkPermission(permission);
for (Enumeration e = documentLoadListeners.elements();
e.hasMoreElements();) {
DocumentLoadListener listener =
(DocumentLoadListener) e.nextElement();
listener.endDocumentLoad(url, status, (Document)getNodeByHandle(p_doc));
}
doGC();
}
}

View File

@@ -1,32 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.DOMException;
public class DOMExceptionImpl extends DOMException
{
// instantiated from JNI only
private DOMExceptionImpl(short code, String message) {
super(code, message);
}
}

View File

@@ -1,71 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.DOMException;
public class DOMImplementationImpl implements DOMImplementation {
private long p_nsIDOMDOMImplementation = 0;
// instantiated from JNI only
private DOMImplementationImpl() {}
public boolean equals(Object o) {
if (!(o instanceof NodeListImpl))
return false;
else
return (XPCOM_equals(o));
}
public int hashCode(){
return XPCOM_hashCode();
}
public native boolean hasFeature(String feature, String version);
protected native void finalize();
private native boolean XPCOM_equals(Object o);
private native int XPCOM_hashCode();
//since DOM2
public DocumentType createDocumentType(String qualifiedName, String publicID, String systemID) {
throw new UnsupportedOperationException();
}
public Document createDocument(String namespaceURI,
String qualifiedName,
DocumentType doctype) throws DOMException {
throw new UnsupportedOperationException();
}
public DocumentType createDocumentType(String qualifiedName,
String publicId,
String systemId,
String internalSubset) {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,29 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.DocumentFragment;
public class DocumentFragmentImpl extends NodeImpl implements DocumentFragment {
// instantiated from JNI or Document.createDocumentFragment()
private DocumentFragmentImpl() {}
}

View File

@@ -1,86 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.EntityReference;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.events.DocumentEvent;
import org.w3c.dom.events.Event;
import org.w3c.dom.DOMException;
public class DocumentImpl extends NodeImpl implements Document, DocumentEvent {
// instantiated from JNI only
private DocumentImpl() {}
public native Attr createAttribute(String name);
public native CDATASection createCDATASection(String data);
public native Comment createComment(String data);
public native DocumentFragment createDocumentFragment();
public native Element createElement(String tagName);
public native EntityReference createEntityReference(String name);
public native ProcessingInstruction
createProcessingInstruction(String target,
String data);
public native Text createTextNode(String data);
public native DocumentType getDoctype();
public native Element getDocumentElement();
public native NodeList getElementsByTagName(String tagName);
public native DOMImplementation getImplementation();
public Event createEvent(String type) throws DOMException {
throw new UnsupportedOperationException();
}
public Node importNode(Node importedNode, boolean deep) throws DOMException {
throw new UnsupportedOperationException();
}
public Element createElementNS(String namespaceURI, String qualifiedName)
throws DOMException {
throw new UnsupportedOperationException();
}
public Attr createAttributeNS(String namespaceURI, String qualifiedName)
throws DOMException {
throw new UnsupportedOperationException();
}
public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
throw new UnsupportedOperationException();
}
public Element getElementById(String elementId) {
throw new UnsupportedOperationException();
};
}

View File

@@ -1,36 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Document;
public interface DocumentLoadListener {
public void startURLLoad(String url, String contentType, Document doc);
public void endURLLoad(String url, int status, Document doc);
public void progressURLLoad(String url, int progress, int progressMax,
Document doc);
public void statusURLLoad(String url, String message, Document doc);
public void startDocumentLoad(String url);
public void endDocumentLoad(String url, int status, Document doc);
}

View File

@@ -1,49 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.DocumentType;
import org.w3c.dom.NamedNodeMap;
public class DocumentTypeImpl extends NodeImpl implements DocumentType {
// instantiated from JNI only
private DocumentTypeImpl() {}
public native String getName();
public native NamedNodeMap getEntities();
public native NamedNodeMap getNotations();
//since DOM level 2
public String getPublicId() {
throw new UnsupportedOperationException();
}
public String getSystemId() {
throw new UnsupportedOperationException();
}
public String getInternalSubset() {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,79 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.w3c.dom.DOMException;
public class ElementImpl extends NodeImpl implements Element {
// instantiated from JNI or Document.createElement()
private ElementImpl() {}
public native String getAttribute(String name);
public native Attr getAttributeNode(String name);
public native NodeList getElementsByTagName(String name);
public native String getTagName();
public native void normalize();
public native void removeAttribute(String name);
public native Attr removeAttributeNode(Attr oldAttr);
public native void setAttribute(String name, String value);
public native Attr setAttributeNode(Attr newAttr);
//since DOM2
public String getAttributeNS(String namespaceURI, String localName) {
throw new UnsupportedOperationException();
}
public void setAttributeNS(String namespaceURI, String localName,
String value) throws DOMException {
throw new UnsupportedOperationException();
}
public void removeAttributeNS(String namespacURI, String localName)
throws DOMException {
throw new UnsupportedOperationException();
}
public Attr getAttributeNodeNS(String namespaceURI, String localName) {
throw new UnsupportedOperationException();
}
public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
throw new UnsupportedOperationException();
}
public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
throw new UnsupportedOperationException();
}
public boolean hasAttribute(String name) {
throw new UnsupportedOperationException();
}
public boolean hasAttributeNS(String namespaceURI,
String localName) {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,34 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Entity;
public class EntityImpl extends NodeImpl implements Entity {
// instantiated from JNI only
private EntityImpl() {}
public native String getPublicId();
public native String getSystemId();
public native String getNotationName();
}

View File

@@ -1,30 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.EntityReference;
public class EntityReferenceImpl extends NodeImpl implements EntityReference {
// instantiated from JNI or Document.createEntityReference()
private EntityReferenceImpl() {}
}

View File

@@ -1,36 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import java.security.BasicPermission;
public final class JavaDOMPermission extends BasicPermission {
public JavaDOMPermission(String name)
{
super(name);
}
public JavaDOMPermission(String name, String actions)
{
super(name);
}
}

View File

@@ -1,53 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.DOMException;
public class NamedNodeMapImpl extends NodeImpl implements NamedNodeMap {
// instantiated from JNI only
private NamedNodeMapImpl() {}
public native int getLength();
public native Node getNamedItem(String name);
public native Node item(int index);
public native Node removeNamedItem(String name);
public native Node setNamedItem(Node arg);
public Node getNamedItemNS(String namespaceURI, String localName) {
throw new UnsupportedOperationException();
}
public Node removeNamedItemNS(String namespaceURI, String name)
throws DOMException {
throw new UnsupportedOperationException();
}
public Node setNamedItemNS(Node arg)
throws DOMException {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,233 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import org.w3c.dom.Document;
import org.w3c.dom.DOMException;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.events.EventListener;
import java.util.Vector;
import java.util.Hashtable;
class NodeEventListener {
EventListener listener = null;
String type = null;
boolean useCapture = false;
long nativeListener = 0;
NodeEventListener(String aType, EventListener aListener,
boolean aUseCapture, long aNativeListener) {
type = aType;
listener = aListener;
useCapture = aUseCapture;
nativeListener = aNativeListener;
}
public boolean equals(Object o) {
if (!(o instanceof NodeEventListener))
return false;
else {
NodeEventListener n = (NodeEventListener) o;
if ((useCapture != n.useCapture)
|| (type == null) || !type.equals(n.type)
|| (listener == null) || !listener.equals(n.listener))
return false;
else
return true;
}
}
}
public class NodeImpl implements Node, EventTarget {
/* The derived classes (Attr, CharacterData, DocumentFragment,
Document, Element, EntityReference, NamedNodeMap,
ProcessingInstruction) will also use this native pointer, since
the nsIDOM coreDom classes follow the same hierarchy */
private long p_nsIDOMNode = 0;
// this map stores association of java DOM listeners
// with corresponding native Nodes
static private Hashtable javaDOMlisteners = new Hashtable();
// instantiated from JNI only
protected NodeImpl() {}
protected NodeImpl(long p) {
p_nsIDOMNode = p;
}
public boolean equals(Object o) {
if (!(o instanceof NodeImpl))
return false;
else
return (XPCOM_equals(o));
}
public int hashCode(){
return XPCOM_hashCode();
}
public String toString() {
return "<" + getNodeName() +
" t=" + nodeTypeString(getNodeType()) +
" c=org.mozilla.dom.NodeImpl p=" +
Long.toHexString(p_nsIDOMNode) + ">";
}
private static String nodeTypeString(int type) {
switch (type) {
case Node.ELEMENT_NODE: return "ELEMENT";
case Node.ATTRIBUTE_NODE: return "ATTRIBUTE";
case Node.TEXT_NODE: return "TEXT";
case Node.CDATA_SECTION_NODE: return "CDATA_SECTION";
case Node.ENTITY_REFERENCE_NODE: return "ENTITY_REFERENCE";
case Node.ENTITY_NODE: return "ENTITY";
case Node.PROCESSING_INSTRUCTION_NODE: return "PROCESSING_INSTRUCTION";
case Node.COMMENT_NODE: return "COMMENT";
case Node.DOCUMENT_NODE: return "DOCUMENT";
case Node.DOCUMENT_TYPE_NODE: return "DOCUMENT_TYPE";
case Node.DOCUMENT_FRAGMENT_NODE: return "DOCUMENT_FRAGMENT";
case Node.NOTATION_NODE: return "NOTATION";
}
return "ERROR";
}
public native Node appendChild(Node newChild) throws DOMException;
public native Node cloneNode(boolean deep);
public native NamedNodeMap getAttributes();
public native NodeList getChildNodes();
public native Node getFirstChild();
public native Node getLastChild();
public native Node getNextSibling();
public native String getNodeName();
public native short getNodeType();
public native String getNodeValue();
public native Document getOwnerDocument();
public native Node getParentNode();
public native Node getPreviousSibling();
public native boolean hasChildNodes();
public native Node insertBefore(Node newChild, Node refChild) throws DOMException;
public native Node removeChild(Node oldChild) throws DOMException;
public native Node replaceChild(Node newChild, Node oldChild) throws DOMException;
public native void setNodeValue(String nodeValue);
protected native void finalize();
private native boolean XPCOM_equals(Object o);
private native int XPCOM_hashCode();
//since DOM level 2
public boolean supports(String feature, String version) {
throw new UnsupportedOperationException();
}
public String getNamespaceURI() {
throw new UnsupportedOperationException();
}
public String getPrefix() {
throw new UnsupportedOperationException();
}
public void setPrefix(String prefix) throws DOMException {
throw new UnsupportedOperationException();
}
public String getLocalName() {
throw new UnsupportedOperationException();
}
public void addEventListener(String type,
EventListener listener,
boolean useCapture) {
long nativeListener = addNativeEventListener(type, listener, useCapture);
Long lnode = new Long(p_nsIDOMNode);
Vector listeners;
//in conjunction with internal synchronization of Hashtable and Vector
// this should be enough for safe concurrent access
synchronized (javaDOMlisteners) {
listeners = (Vector) javaDOMlisteners.get(lnode);
if (listeners == null) {
listeners = new Vector();
javaDOMlisteners.put(lnode, listeners);
}
}
if (nativeListener != 0) {
NodeEventListener l = new NodeEventListener(type,
listener,
useCapture,
nativeListener);
listeners.add(l);
}
}
public void removeEventListener(String type,
EventListener listener,
boolean useCapture) {
Vector listeners = (Vector) javaDOMlisteners.get(new Long(p_nsIDOMNode));
if (listeners == null)
return;
NodeEventListener l = new NodeEventListener(type,
listener, useCapture, 0);
int idx = listeners.indexOf(l);
//if trying to remove non-existing listener then return
if (idx == -1)
return;
l = (NodeEventListener) listeners.remove(idx);
removeNativeEventListener(type, l.nativeListener, useCapture);
}
public boolean dispatchEvent(Event evt) throws DOMException {
throw new UnsupportedOperationException();
}
private native long addNativeEventListener(String type,
EventListener listener,
boolean useCapture);
private native void removeNativeEventListener(String type,
long nativeListener,
boolean useCapture);
public void normalize() {
throw new UnsupportedOperationException();
};
}

View File

@@ -1,52 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class NodeListImpl implements NodeList {
private long p_nsIDOMNodeList = 0;
// instantiated from JNI or Document.createAttribute()
private NodeListImpl() {}
public boolean equals(Object o) {
if (!(o instanceof NodeListImpl))
return false;
else
return (XPCOM_equals(o));
}
public int hashCode(){
return XPCOM_hashCode();
}
public native int getLength();
public native Node item(int index);
protected native void finalize();
private native boolean XPCOM_equals(Object o);
private native int XPCOM_hashCode();
}

View File

@@ -1,33 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Notation;
public class NotationImpl extends NodeImpl implements Notation {
// instantiated from JNI only
private NotationImpl() {}
public native String getPublicId();
public native String getSystemId();
}

View File

@@ -1,34 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.ProcessingInstruction;
public class ProcessingInstructionImpl extends NodeImpl implements ProcessingInstruction {
// instantiated from JNI or Document.createProcessingInstruction()
private ProcessingInstructionImpl() {}
public native String getData();
public native String getTarget();
public native void setData(String data);
}

View File

@@ -1,33 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom;
import org.w3c.dom.Text;
public class TextImpl extends CharacterDataImpl implements Text {
// instantiated from JNI or Document.createTextNode()
protected TextImpl() {}
public native Text splitText(int offset);
}

View File

@@ -1,155 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom.events;
import org.w3c.dom.Node;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventTarget;
/**
* The <code>Event</code> interface is used to provide contextual information
* about an event to the handler processing the event. An object which
* implements the <code>Event</code> interface is generally passed as the
* first parameter to an event handler. More specific context information
* is passed to event handlers by deriving additional interfaces from
* <code>Event</code> which contain information directly relating to the type
* of event they accompany. These derived interfaces are also implemented by
* the object passed to the event listener.
* @since DOM Level 2
*/
public class EventImpl implements Event {
protected long p_nsIDOMEvent = 0;
// instantiated from JNI only
protected EventImpl() {}
public String toString() {
return "<c=org.mozilla.dom.events.Event type=" + getType() +
" target=" + getTarget() +
" phase=" + getEventPhase() +
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
}
/**
* The <code>type</code> property represents the event name as a string
* property.
*/
public native String getType();
/**
* The <code>target</code> property indicates the <code>EventTarget</code>
* to which the event was originally dispatched.
*/
public native EventTarget getTarget();
/**
* The <code>currentNode</code> property indicates the <code>Node</code>
* whose <code>EventListener</code>s are currently being processed. This
* is particularly useful during capturing and bubbling.
*/
public native Node getCurrentNode();
/**
* The <code>eventPhase</code> property indicates which phase of event flow
* is currently being evaluated.
*/
public native short getEventPhase();
/**
* The <code>bubbles</code> property indicates whether or not an event is a
* bubbling event. If the event can bubble the value is true, else the
* value is false.
*/
public native boolean getBubbles();
/**
* The <code>cancelable</code> property indicates whether or not an event
* can have its default action prevented. If the default action can be
* prevented the value is true, else the value is false.
*/
public native boolean getCancelable();
/**
* The <code>preventBubble</code> method is used to end the bubbling phase
* of event flow. If this method is called by any
* <code>EventListener</code>s registered on the same
* <code>EventTarget</code> during bubbling, the bubbling phase will cease
* at that level and the event will not be propagated upward within the
* tree.
*/
public native void preventBubble();
/**
* The <code>preventCapture</code> method is used to end the capturing phase
* of event flow. If this method is called by any
* <code>EventListener</code>s registered on the same
* <code>EventTarget</code> during capturing, the capturing phase will
* cease at that level and the event will not be propagated any further
* down.
*/
public native void preventCapture();
/**
* If an event is cancelable, the <code>preventCapture</code> method is used
* to signify that the event is to be canceled, meaning any default action
* normally taken by the implementation as a result of the event will not
* occur. If, during any stage of event flow, the
* <code>preventDefault</code> method is called the event is canceled. Any
* default action associated with the event will not occur. Calling this
* method for a non-cancelable event has no effect. Once
* <code>preventDefault</code> has been called it will remain in effect
* throughout the remainder of the event's propagation.
*/
public native void preventDefault();
/**
* The <code>stopPropagation</code> method is used prevent further
* propagation of an event during event flow. If this method is called by
* any <code>EventListener</code> the event will cease propagating
* through the tree. The event will complete dispatch to all listeners
* on the current <code>EventTarget</code> before event flow stops. This
* method may be used during any stage of event flow.
*/
public void stopPropagation() {
throw new UnsupportedOperationException();
}
/**
*
* @param eventTypeArg Specifies the event type. This type may be any event
* type currently defined in this specification or a new event type. Any
* new event type must not begin with any upper, lower, or mixed case
* version of the string "DOM". This prefix is reserved for future DOM
* event sets.
* @param canBubbleArg Specifies whether or not the event can bubble.
* @param cancelableArg Specifies whether or not the event's default action
* can be prevented.
*/
public native void initEvent(String eventTypeArg,
boolean canBubbleArg,
boolean cancelableArg);
public long getTimeStamp() {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,159 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom.events;
import org.w3c.dom.Node;
import org.w3c.dom.views.AbstractView;
import org.w3c.dom.events.MouseEvent;
/**
* The <code>MouseEvent</code> interface provides specific contextual
* information associated with Mouse events.
* <p>The <code>detail</code> attribute inherited from <code>UIEvent</code>
* indicates the number of times a mouse button has been pressed and released
* over the same screen location during a user action. The attribute value
* is 1 when the user begins this action and increments by 1 for each full
* sequence of pressing and releasing. If the user moves the mouse between
* the mousedown and mouseup the value will be set to 0, indicating that no
* click is occurring.
* @since DOM Level 2
*/
public class MouseEventImpl extends UIEventImpl implements MouseEvent {
// instantiated from JNI only
private MouseEventImpl() {}
public String toString() {
return "<c=org.mozilla.dom.events.mouseUIEvent type=" + getType() +
" screen=(" + getScreenX() + "," + getScreenY() + ")" +
" client=(" + getClientX() + "," + getClientY() + ")" +
" mods=(" + getCtrlKey() + "," + getMetaKey() + "," + getShiftKey() + "," + getAltKey() + ")" +
" button=" + getButton() +
" target=" + getTarget() +
" phase=" + getEventPhase() +
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
}
/**
* <code>screenX</code> indicates the horizontal coordinate at which the
* event occurred in relative to the origin of the screen coordinate system.
*/
public native int getScreenX();
/**
* <code>screenY</code> indicates the vertical coordinate at which the event
* occurred relative to the origin of the screen coordinate system.
*/
public native int getScreenY();
/**
* <code>clientX</code> indicates the horizontal coordinate at which the
* event occurred relative to the DOM implementation's client area.
*/
public native int getClientX();
/**
* <code>clientY</code> indicates the vertical coordinate at which the event
* occurred relative to the DOM implementation's client area.
*/
public native int getClientY();
/**
* <code>ctrlKey</code> indicates whether the 'ctrl' key was depressed
* during the firing of the event.
*/
public native boolean getCtrlKey();
/**
* <code>shiftKey</code> indicates whether the 'shift' key was depressed
* during the firing of the event.
*/
public native boolean getShiftKey();
/**
* <code>altKey</code> indicates whether the 'alt' key was depressed during
* the firing of the event. On some platforms this key may map to an
* alternative key name.
*/
public native boolean getAltKey();
/**
* <code>metaKey</code> indicates whether the 'meta' key was depressed
* during the firing of the event. On some platforms this key may map to
* an alternative key name.
*/
public native boolean getMetaKey();
/**
* During mouse events caused by the depression or release of a mouse
* button, <code>button</code> is used to indicate which mouse button
* changed state.
*/
public native short getButton();
/**
* <code>relatedNode</code> is used to identify a secondary node related to
* a UI event.
*/
public native Node getRelatedNode();
/**
*
* @param typeArg Specifies the event type.
* @param canBubbleArg Specifies whether or not the event can bubble.
* @param cancelableArg Specifies whether or not the event's default action
* can be prevent.
* @param viewArg Specifies the <code>Event</code>'s
* <code>AbstractView</code>.
* @param detailArg Specifies the <code>Event</code>'s mouse click count.
* @param screenXArg Specifies the <code>Event</code>'s screen x coordinate
* @param screenYArg Specifies the <code>Event</code>'s screen y coordinate
* @param clientXArg Specifies the <code>Event</code>'s client x coordinate
* @param clientYArg Specifies the <code>Event</code>'s client y coordinate
* @param ctrlKeyArg Specifies whether or not control key was depressed
* during the <code>Event</code>.
* @param altKeyArg Specifies whether or not alt key was depressed during
* the <code>Event</code>.
* @param shiftKeyArg Specifies whether or not shift key was depressed
* during the <code>Event</code>.
* @param metaKeyArg Specifies whether or not meta key was depressed during
* the <code>Event</code>.
* @param buttonArg Specifies the <code>Event</code>'s mouse button.
* @param relatedNodeArg Specifies the <code>Event</code>'s related Node.
*/
public native void initMouseEvent(String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
AbstractView viewArg,
int detailArg,
int screenXArg,
int screenYArg,
int clientXArg,
int clientYArg,
boolean ctrlKeyArg,
boolean altKeyArg,
boolean shiftKeyArg,
boolean metaKeyArg,
short buttonArg,
Node relatedNodeArg);
}

View File

@@ -1,89 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom.events;
import org.w3c.dom.Node;
import org.w3c.dom.events.MutationEvent;
import org.mozilla.dom.events.EventImpl;
public class MutationEventImpl extends EventImpl implements MutationEvent {
/**
* <code>relatedNode</code> is used to identify a secondary node related to
* a mutation event. For example, if a mutation event is dispatched to a
* node indicating that its parent has changed, the <code>relatedNode</code>
* is the changed parent. If an event is instead dispatch to a subtree
* indicating a node was changed within it, the <code>relatedNode</code> is
* the changed node.
*/
public Node getRelatedNode() {
throw new UnsupportedOperationException();
}
/**
* <code>prevValue</code> indicates the previous value of text nodes and
* attributes in attrModified and charDataModified events.
*/
public String getPrevValue() {
throw new UnsupportedOperationException();
}
/**
* <code>newValue</code> indicates the new value of text nodes and
* attributes in attrModified and charDataModified events.
*/
public String getNewValue() {
throw new UnsupportedOperationException();
}
/**
* <code>attrName</code> indicates the changed attr in the attrModified
* event.
*/
public String getAttrName() {
throw new UnsupportedOperationException();
}
/**
*
* @param typeArg Specifies the event type.
* @param canBubbleArg Specifies whether or not the event can bubble.
* @param cancelableArg Specifies whether or not the event's default action
* can be prevent.
* @param relatedNodeArg Specifies the <code>Event</code>'s related Node
* @param prevValueArg Specifies the <code>Event</code>'s
* <code>prevValue</code> property
* @param newValueArg Specifies the <code>Event</code>'s
* <code>newValue</code> property
* @param attrNameArg Specifies the <code>Event</code>'s
* <code>attrName</code> property
*/
public void initMutationEvent(String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
Node relatedNodeArg,
String prevValueArg,
String newValueArg,
String attrNameArg) {
throw new UnsupportedOperationException();
}
}

View File

@@ -1,74 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom.events;
import org.w3c.dom.events.UIEvent;
import org.w3c.dom.views.AbstractView;
import org.mozilla.dom.events.EventImpl;
/**
* The <code>UIEvent</code> interface provides specific contextual
* information associated with User Interface events.
* @since DOM Level 2
*/
public class UIEventImpl extends EventImpl implements UIEvent {
// instantiated from JNI only
protected UIEventImpl() {}
public String toString() {
return "<c=org.mozilla.dom.events.UIEvent type=" + getType() +
" target=" + getTarget() +
" phase=" + getEventPhase() +
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
}
/**
* The <code>view</code> attribute identifies the <code>AbstractView</code>
* from which the event was generated.
*/
public native AbstractView getView();
/**
* Specifies some detail information about the <code>Event</code>, depending
* on the type of event.
*/
public native int getDetail();
/**
*
* @param typeArg Specifies the event type.
* @param canBubbleArg Specifies whether or not the event can bubble.
* @param cancelableArg Specifies whether or not the event's default action
* can be prevent.
* @param viewArg Specifies the <code>Event</code>'s
* <code>AbstractView</code>.
* @param detailArg Specifies the <code>Event</code>'s detail.
*/
public native void initUIEvent(String typeArg,
boolean canBubbleArg,
boolean cancelableArg,
AbstractView viewArg,
int detailArg);
}

View File

@@ -1,231 +0,0 @@
/*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*
* Contributor(s): Denis Sharypov <sdv@sparc.spb.su>
*
*/
package org.mozilla.dom.util;
import java.io.BufferedOutputStream;
import java.io.PrintStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class DOMTreeDumper {
private String name;
private boolean debug;
private PrintStream ps;
private boolean inA;
private final String[] endTagForbiddenNames = {"AREA",
"BASE",
"BASEFONT",
"BR",
"COL",
"FRAME",
"HR",
"IMG",
"INPUT",
"ISINDEX",
"LINK",
"META",
"PARAM"};
public DOMTreeDumper() {
this("DOMTreeDumper", true);
}
public DOMTreeDumper(boolean debug) {
this("DOMTreeDumper", debug);
}
public DOMTreeDumper(String name) {
this(name, true);
}
public DOMTreeDumper(String name, boolean debug) {
this.name = name;
this.debug = debug;
}
private void dumpDocument(Document doc) {
if (doc == null) return;
Element element = doc.getDocumentElement();
if (element == null) return;
element.normalize();
// DocumentType dt = doc.getDoctype();
// dumpNode(dt);
dumpNode(element);
ps.println();
ps.flush();
element = null;
doc = null;
}
private void dumpNode(Node node) {
dumpNode(node, false);
}
private void dumpNode(Node node, boolean isMapNode) {
if (node == null) {
return;
}
int type = node.getNodeType();
String name = node.getNodeName();
String value = node.getNodeValue();
switch (type) {
case Node.ELEMENT_NODE:
if (name.equals("A")) inA = true;
if (!(inA || name.equals("BR"))) {
ps.println();
}
ps.print("<" + name);
dumpAttributes(node);
ps.print(">");
dumpChildren(node);
if (name.equals("A")) inA = false;
if (!endTagForbidden(name)) {
ps.print("</" + node.getNodeName() + ">");
}
break;
case Node.ATTRIBUTE_NODE:
ps.print(" " + name.toUpperCase() + "=\"" + value + "\"");
break;
case Node.TEXT_NODE:
if (!node.getParentNode().getNodeName().equals("PRE")) {
value = value.trim();
}
if (!value.equals("")) {
if (!inA) {
ps.println();
}
ps.print(canonicalize(value));
}
break;
case Node.COMMENT_NODE:
ps.print("\n<!--" + value + "-->");
break;
case Node.CDATA_SECTION_NODE:
case Node.ENTITY_REFERENCE_NODE:
case Node.ENTITY_NODE:
case Node.PROCESSING_INSTRUCTION_NODE:
case Node.DOCUMENT_NODE:
case Node.DOCUMENT_TYPE_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.NOTATION_NODE:
ps.println("\n<!-- NOT HANDLED: " + name +
" value=" + value + " -->");
break;
}
}
private void dumpAttributes(Node node) {
NamedNodeMap map = node.getAttributes();
if (map == null) return;
int length = map.getLength();
for (int i=0; i < length; i++) {
Node item = map.item(i);
dumpNode(item, true);
}
}
private void dumpChildren(Node node) {
NodeList children = node.getChildNodes();
int length = 0;
boolean hasChildren = ((children != null) && ((length = children.getLength()) > 0));
if (!hasChildren) {
return;
}
for (int i=0; i < length; i++) {
dumpNode(children.item(i), false);
}
if (!inA) {
ps.println();
}
}
private String canonicalize(String str) {
StringBuffer in = new StringBuffer(str);
int length = in.length();
StringBuffer out = new StringBuffer(length);
char c;
for (int i = 0; i < length; i++) {
switch (c = in.charAt(i)) {
case '&' :
out.append("&amp;");
break;
case '<':
out.append("&lt;");
break;
case '>':
out.append("&gt;");
break;
case '\u00A0':
out.append("&nbsp;");
break;
default:
out.append(c);
}
}
return out.toString();
}
private boolean endTagForbidden(String name) {
for (int i = 0; i < endTagForbiddenNames.length; i++) {
if (name.equals(endTagForbiddenNames[i])) {
return true;
}
}
return false;
}
public void dumpToFile(String fileName, Document doc) {
try {
FileOutputStream fos = new FileOutputStream(fileName);
ps = new PrintStream(new BufferedOutputStream(fos, 1024));
} catch (IOException ex) {
ex.printStackTrace();
return;
}
dbg("dumping to " + fileName);
dumpDocument(doc);
dbg("finished dumping...");
}
public void dumpToStream(PrintStream ps, Document doc) {
this.ps = ps;
dbg("dumping to stream...");
dumpDocument(doc);
dbg("finished dumping...");
}
private void dbg(String str) {
if (debug) {
System.out.println(name + ": " + str);
}
}
}

View File

@@ -1,105 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
package org.mozilla.dom.util;
import java.io.PrintStream;
import org.w3c.dom.Document;
import org.mozilla.dom.DocumentLoadListener;
public class GenericDocLoadListener implements DocumentLoadListener {
private String name;
private PrintStream ps;
public GenericDocLoadListener() {
this("GenericDocLoadListener",
new PrintStream(System.out));
}
public GenericDocLoadListener(String name) {
this(name,
new PrintStream(System.out));
}
public GenericDocLoadListener(PrintStream ps) {
this("GenericDocLoadListener", ps);
}
public GenericDocLoadListener(String name, PrintStream ps) {
this.name = name;
this.ps = ps;
}
public DocumentLoadListener getDocumentLoadListener() {
return this;
}
public void startURLLoad(String url, String contentType, Document doc) {
if (ps != null) {
ps.println(name + " :start URL load - " +
url.toString() + " " +
contentType);
}
}
public void endURLLoad(String url, int status, Document doc) {
if (ps != null) {
ps.println(name + " :end URL load - " +
url.toString() + " " +
Integer.toHexString(status));
}
}
public void progressURLLoad(String url, int progress, int progressMax,
Document doc) {
if (ps != null) {
ps.println(name + " :progress URL load - " +
url.toString() + " " +
Integer.toString(progress) + "/" +
Integer.toString(progressMax));
}
}
public void statusURLLoad(String url, String message, Document doc) {
if (ps != null) {
ps.println(name + " :status URL load - " +
url.toString() + " (" +
message + ")");
}
}
public void startDocumentLoad(String url) {
if (ps != null) {
ps.println(name + " :start doc load - " +
url.toString());
}
}
public void endDocumentLoad(String url, int status, Document doc) {
if (ps != null) {
ps.println(name + " :end doc load - " +
url.toString() + " " +
Integer.toHexString(status));
}
}
}

View File

@@ -1,68 +0,0 @@
/*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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 Initial Developer of the Original Code is Sun Microsystems,
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
* Inc. All Rights Reserved.
*
* Contributor(s):
*
*/
package org.mozilla.dom.util;
import java.io.PrintStream;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
public class GenericEventListener implements EventListener {
private String name;
private PrintStream ps;
public GenericEventListener() {
this("GenericEventListener",
new PrintStream(System.out));
}
public GenericEventListener(String name) {
this(name, new PrintStream(System.out));
}
public GenericEventListener(PrintStream ps) {
this("GenericEventListener", ps);
}
public GenericEventListener(String name, PrintStream ps) {
this.name = name;
this.ps = ps;
}
/**
* This method is called whenever an event occurs of the type for which the
* <code> EventListener</code> interface was registered.
* @param event The <code>Event</code> contains contextual information about
* the event. It also contains the <code>returnValue</code> and
* <code>cancelBubble</code> properties which are used in determining
* proper event flow.
*/
public void handleEvent(Event event) {
try {
if (ps != null) {
ps.println(name + ": got event " + event);
}
} catch (Exception e) {
if (ps != null) {
ps.println(name + ": exception in handleEvent " + e);
}
}
}
}

View File

@@ -1,56 +0,0 @@
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are
# Copyright (C) 1999 Sun Microsystems, Inc. All
# Rights Reserved.
#
# Contributor(s):
DEPTH = ../../..
topsrcdir = $(DEPTH)
srcdir = $(topsrcdir)/java/dom/jni
VPATH = $(topsrcdir)/java/dom/jni
JAVAHOME = $(JDKHOME)
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = javadomjni
CPPSRCS = \
javaDOMGlobals.cpp \
javaDOMEventsGlobals.cpp \
nativeDOMProxyListener.cpp \
org_mozilla_dom_DOMAccessor.cpp \
org_mozilla_dom_AttrImpl.cpp \
org_mozilla_dom_CharacterDataImpl.cpp \
org_mozilla_dom_DocumentImpl.cpp \
org_mozilla_dom_DocumentTypeImpl.cpp \
org_mozilla_dom_DOMImplementationImpl.cpp \
org_mozilla_dom_ElementImpl.cpp \
org_mozilla_dom_EntityImpl.cpp \
org_mozilla_dom_NamedNodeMapImpl.cpp \
org_mozilla_dom_NodeImpl.cpp \
org_mozilla_dom_NodeListImpl.cpp \
org_mozilla_dom_NotationImpl.cpp \
org_mozilla_dom_ProcessingInstructionImpl.cpp \
org_mozilla_dom_TextImpl.cpp \
org_mozilla_dom_events_EventImpl.cpp \
org_mozilla_dom_events_UIEventImpl.cpp \
org_mozilla_dom_events_MouseEventImpl.cpp
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

View File

@@ -1,57 +0,0 @@
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are
# Copyright (C) 1999 Sun Microsystems, Inc. All
# Rights Reserved.
#
# Contributor(s):
DEPTH = ../../..
topsrcdir = $(DEPTH)
srcdir = $(topsrcdir)/java/dom/jni
VPATH = $(topsrcdir)/java/dom/jni
JAVAHOME = $(JDKHOME)
include $(DEPTH)/config/autoconf.mk
LIBRARY_NAME = javadomjni
CPPSRCS = \
javaDOMGlobals.cpp \
javaDOMEventsGlobals.cpp \
nativeDOMProxyListener.cpp \
org_mozilla_dom_DOMAccessor.cpp \
org_mozilla_dom_AttrImpl.cpp \
org_mozilla_dom_CharacterDataImpl.cpp \
org_mozilla_dom_DocumentImpl.cpp \
org_mozilla_dom_DocumentTypeImpl.cpp \
org_mozilla_dom_DOMImplementationImpl.cpp \
org_mozilla_dom_ElementImpl.cpp \
org_mozilla_dom_EntityImpl.cpp \
org_mozilla_dom_NamedNodeMapImpl.cpp \
org_mozilla_dom_NodeImpl.cpp \
org_mozilla_dom_NodeListImpl.cpp \
org_mozilla_dom_NotationImpl.cpp \
org_mozilla_dom_ProcessingInstructionImpl.cpp \
org_mozilla_dom_TextImpl.cpp \
org_mozilla_dom_events_EventImpl.cpp \
org_mozilla_dom_events_UIEventImpl.cpp \
org_mozilla_dom_events_MouseEventImpl.cpp \
org_mozilla_dom_events_KeyEventImpl.cpp
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

View File

@@ -1,268 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "prmon.h"
#include "nsAutoLock.h"
#include "javaDOMEventsGlobals.h"
#include "nsIDOMEvent.h"
#include "nsIDOMUIEvent.h"
jclass JavaDOMEventsGlobals::eventClass = NULL;
jclass JavaDOMEventsGlobals::uiEventClass = NULL;
jclass JavaDOMEventsGlobals::eventListenerClass = NULL;
jclass JavaDOMEventsGlobals::eventTargetClass = NULL;
jclass JavaDOMEventsGlobals::mouseEventClass = NULL;
jclass JavaDOMEventsGlobals::mutationEventClass = NULL;
jfieldID JavaDOMEventsGlobals::eventPtrFID = NULL;
jfieldID JavaDOMEventsGlobals::eventTargetPtrFID = NULL;
jfieldID JavaDOMEventsGlobals::eventPhaseBubblingFID = NULL;
jfieldID JavaDOMEventsGlobals::eventPhaseCapturingFID = NULL;
jfieldID JavaDOMEventsGlobals::eventPhaseAtTargetFID = NULL;
jmethodID JavaDOMEventsGlobals::eventListenerHandleEventMID = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID);
void JavaDOMEventsGlobals::Initialize(JNIEnv *env)
{
eventClass = env->FindClass("org/mozilla/dom/events/EventImpl");
if (!eventClass) {
JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.EventImpl not found");
return;
}
eventClass = (jclass) env->NewGlobalRef(eventClass);
if (!eventClass)
return;
eventPtrFID =
env->GetFieldID(eventClass, "p_nsIDOMEvent", "J");
if (!eventPtrFID) {
JavaDOMGlobals::ThrowException(env, "There is no field p_nsIDOMEvent in org.mozilla.dom.events.EventImpl");
return;
}
eventListenerClass = env->FindClass("org/w3c/dom/events/EventListener");
if (!eventListenerClass) {
JavaDOMGlobals::ThrowException(env, "Class org.w3c.dom.events.EventListener not found");
return;
}
eventListenerClass = (jclass) env->NewGlobalRef(eventListenerClass);
if (!eventListenerClass)
return;
eventListenerHandleEventMID = env->GetMethodID(
eventListenerClass, "handleEvent", "(Lorg/w3c/dom/events/Event;)V");
if (!eventListenerHandleEventMID) {
JavaDOMGlobals::ThrowException(env, "There is no method handleEvent in org.w3c.dom.events.EventListener");
return;
}
uiEventClass = env->FindClass("org/mozilla/dom/events/UIEventImpl");
if (!uiEventClass) {
JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.UIEventImpl not found");
return;
}
uiEventClass = (jclass) env->NewGlobalRef(uiEventClass);
if (!uiEventClass)
return;
eventPhaseBubblingFID =
env->GetStaticFieldID(eventClass, "BUBBLING_PHASE", "S");
if (!eventPhaseBubblingFID) {
JavaDOMGlobals::ThrowException(env, "There is no static field BUBBLING_PHASE in org.w3c.dom.events.Event");
return;
}
eventPhaseCapturingFID =
env->GetStaticFieldID(eventClass, "CAPTURING_PHASE", "S");
if (!eventPhaseCapturingFID) {
JavaDOMGlobals::ThrowException(env, "There is no static field CAPTURING_PHASE in org.w3c.dom.events.Event");
return;
}
eventPhaseAtTargetFID =
env->GetStaticFieldID(eventClass, "AT_TARGET", "S");
if (!eventPhaseAtTargetFID) {
JavaDOMGlobals::ThrowException(env, "There is no static field AT_TARGET in org.w3c.dom.events.Event");
return;
}
mouseEventClass = env->FindClass("org/mozilla/dom/events/MouseEventImpl");
if (!mouseEventClass) {
JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.MouseEventImpl not found");
return;
}
mouseEventClass = (jclass) env->NewGlobalRef(mouseEventClass);
if (!mouseEventClass)
return;
}
void JavaDOMEventsGlobals::Destroy(JNIEnv *env)
{
env->DeleteGlobalRef(eventClass);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("JavaDOMEventsGlobals::Destroy: failed to delete Event global ref %x\n",
eventClass));
return;
}
eventClass = NULL;
env->DeleteGlobalRef(eventListenerClass);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("JavaDOMEventsGlobals::Destroy: failed to delete EventListener global ref %x\n",
eventListenerClass));
return;
}
eventListenerClass = NULL;
env->DeleteGlobalRef(uiEventClass);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("JavaDOMEventsGlobals::Destroy: failed to delete UIEvent global ref %x\n",
uiEventClass));
return;
}
uiEventClass = NULL;
env->DeleteGlobalRef(mouseEventClass);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("JavaDOMEventsGlobals::Destroy: failed to delete mouseEvent global ref %x\n",
mouseEventClass));
return;
}
mouseEventClass = NULL;
}
//returns true if specified event "type" exists in the given list of types
// NOTE: it is assumed that "types" list is enden with NULL
static jboolean isEventOfType(const char* const* types, const char* type)
{
int i=0;
while (type && types && types[i]) {
if (!strcmp(type,types[i]))
return JNI_TRUE;
i++;
}
return JNI_FALSE;
}
jobject JavaDOMEventsGlobals::CreateEventSubtype(JNIEnv *env,
nsIDOMEvent *event)
{
jobject jevent;
jclass clazz = eventClass;
nsISupports *isupports;
void *target;
nsresult rv;
isupports = (nsISupports *) event;
//check whenever our Event is UIEvent
rv = isupports->QueryInterface(kIDOMUIEventIID, (void **) &target);
if (!NS_FAILED(rv) && target) {
// At the moment DOM2 draft specifies set of UIEvent subclasses
// However Mozilla still presents these events as nsUIEvent
// So we need a cludge to determine proper java class to be created
static const char* const uiEventTypes[] = {
"resize",
"scroll",
"focusin",
"focusout",
"gainselection",
"loseselection",
"activate",
NULL
};
static const char* const mouseEventTypes[] = {
"click",
"mousedown",
"mouseup",
"mouseover",
"mousemove",
"mouseout",
NULL
};
nsString eventType;
rv = event->GetType(eventType);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.getType at JavaDOMEventsGlobals: failed");
return NULL;
}
char* buffer = nsnull;
if (eventType.IsUnicode()) {
buffer = eventType.ToNewUTF8String();
} else {
buffer = eventType.ToNewCString();
}
if (isEventOfType(mouseEventTypes, buffer) == JNI_TRUE) {
clazz = mouseEventClass;
} else if (isEventOfType(uiEventTypes, buffer) == JNI_TRUE) {
clazz = uiEventClass;
} else {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Unknown type of UI event (%s)", buffer));
clazz = uiEventClass;
}
nsString::Recycle(&eventType);
event->Release();
event = (nsIDOMEvent *) target;
}
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("JavaDOMEventsGlobals::CreateEventSubtype: allocating Node of clazz=%x\n",
clazz));
jevent = env->AllocObject(clazz);
if (!jevent) {
JavaDOMGlobals::ThrowException(env,
"JavaDOMEventsGlobals::CreateEventSubtype: failed to allocate Event object");
return NULL;
}
env->SetLongField(jevent, eventPtrFID, (jlong) event);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("JavaDOMEventGlobals::CreateEventSubtype: failed to set native ptr %x\n",
(jlong) event));
return NULL;
}
event->AddRef();
return jevent;
}

View File

@@ -1,56 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __JavaDOMEventsGlobals_h__
#define __JavaDOMEventsGlobals_h__
#include"javaDOMGlobals.h"
#include"nsIDOMEvent.h"
class JavaDOMEventsGlobals {
public:
static jclass eventClass;
static jclass eventListenerClass;
static jclass eventTargetClass;
static jclass uiEventClass;
static jclass mutationEventClass;
static jclass mouseEventClass;
static jfieldID eventPtrFID;
static jfieldID eventTargetPtrFID;
static jfieldID eventPhaseBubblingFID;
static jfieldID eventPhaseCapturingFID;
static jfieldID eventPhaseAtTargetFID;
static jmethodID eventListenerHandleEventMID;
static void Initialize(JNIEnv *env);
static void Destroy(JNIEnv *env);
static jobject CreateEventSubtype(JNIEnv *env,
nsIDOMEvent *event);
static jlong RegisterNativeEventListener();
static jlong UnregisterNativeEventListener();
};
#endif /* __JavaDOMEventsGlobals_h__ */

View File

@@ -1,599 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "prmon.h"
#include "nsAutoLock.h"
#include "nsIDOMNode.h"
#include "javaDOMGlobals.h"
#include "javaDOMEventsGlobals.h"
jclass JavaDOMGlobals::attrClass = NULL;
jclass JavaDOMGlobals::cDataSectionClass = NULL;
jclass JavaDOMGlobals::commentClass = NULL;
jclass JavaDOMGlobals::documentClass = NULL;
jclass JavaDOMGlobals::documentFragmentClass = NULL;
jclass JavaDOMGlobals::documentTypeClass = NULL;
jclass JavaDOMGlobals::domImplementationClass = NULL;
jclass JavaDOMGlobals::elementClass = NULL;
jclass JavaDOMGlobals::entityClass = NULL;
jclass JavaDOMGlobals::entityReferenceClass = NULL;
jclass JavaDOMGlobals::namedNodeMapClass = NULL;
jclass JavaDOMGlobals::nodeClass = NULL;
jclass JavaDOMGlobals::nodeListClass = NULL;
jclass JavaDOMGlobals::notationClass = NULL;
jclass JavaDOMGlobals::processingInstructionClass = NULL;
jclass JavaDOMGlobals::textClass = NULL;
jfieldID JavaDOMGlobals::nodePtrFID = NULL;
jfieldID JavaDOMGlobals::nodeListPtrFID = NULL;
jfieldID JavaDOMGlobals::domImplementationPtrFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeAttributeFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeCDataSectionFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeCommentFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeDocumentFragmentFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeDocumentFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeDocumentTypeFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeElementFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeEntityFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeEntityReferenceFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeNotationFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeProcessingInstructionFID = NULL;
jfieldID JavaDOMGlobals::nodeTypeTextFID = NULL;
jclass JavaDOMGlobals::domExceptionClass = NULL;
jmethodID JavaDOMGlobals::domExceptionInitMID = NULL;
jclass JavaDOMGlobals::runtimeExceptionClass = NULL;
jmethodID JavaDOMGlobals::runtimeExceptionInitMID = NULL;
const char* const JavaDOMGlobals::DOM_EXCEPTION_MESSAGE[] =
{"Invalid DOM error code",
"Index is out of bounds",
"Could not fit text",
"Wrong hierarchy request",
"Wrong document usage",
"Invalid character",
"Data is unsupported",
"Modification disallowed",
"Node not found",
"Type is unsupported",
"Attribute is alreay in use"};
PRLogModuleInfo* JavaDOMGlobals::log = NULL;
PRCList JavaDOMGlobals::garbage = PR_INIT_STATIC_CLIST(&garbage);
PRLock* JavaDOMGlobals::garbageLock = NULL;
PRInt32 JavaDOMGlobals::javaMaxInt = 0;
class jniDOMGarbage : public PRCList {
public:
jniDOMGarbage(nsISupports* p) { domObject = p; }
nsISupports* domObject;
};
void JavaDOMGlobals::Initialize(JNIEnv *env)
{
garbageLock = PR_NewLock();
log = PR_NewLogModule("javadom");
PR_INIT_CLIST(&garbage);
/* Node is loaded first because it is the base class of a lot of the
others */
nodeClass = env->FindClass("org/mozilla/dom/NodeImpl");
if (!nodeClass) return;
nodeClass = (jclass) env->NewGlobalRef(nodeClass);
if (!nodeClass) return;
nodePtrFID =
env->GetFieldID(nodeClass, "p_nsIDOMNode", "J");
if (!nodePtrFID) return;
attrClass = env->FindClass("org/mozilla/dom/AttrImpl");
if (!attrClass) return;
attrClass = (jclass) env->NewGlobalRef(attrClass);
if (!attrClass) return;
cDataSectionClass = env->FindClass("org/mozilla/dom/CDATASectionImpl");
if (!cDataSectionClass) return;
cDataSectionClass = (jclass) env->NewGlobalRef(cDataSectionClass);
if (!cDataSectionClass) return;
commentClass = env->FindClass("org/mozilla/dom/CommentImpl");
if (!commentClass) return;
commentClass = (jclass) env->NewGlobalRef(commentClass);
if (!commentClass) return;
documentClass = env->FindClass("org/mozilla/dom/DocumentImpl");
if (!documentClass) return;
documentClass = (jclass) env->NewGlobalRef(documentClass);
if (!documentClass) return;
documentFragmentClass = env->FindClass("org/mozilla/dom/DocumentFragmentImpl");
if (!documentFragmentClass) return;
documentFragmentClass = (jclass) env->NewGlobalRef(documentFragmentClass);
if (!documentFragmentClass) return;
documentTypeClass = env->FindClass("org/mozilla/dom/DocumentTypeImpl");
if (!documentTypeClass) return;
documentTypeClass = (jclass) env->NewGlobalRef(documentTypeClass);
if (!documentTypeClass) return;
domImplementationClass = env->FindClass("org/mozilla/dom/DOMImplementationImpl");
if (!domImplementationClass) return;
domImplementationClass = (jclass) env->NewGlobalRef(domImplementationClass);
if (!domImplementationClass) return;
domImplementationPtrFID =
env->GetFieldID(domImplementationClass, "p_nsIDOMDOMImplementation", "J");
if (!domImplementationPtrFID) return;
elementClass = env->FindClass("org/mozilla/dom/ElementImpl");
if (!elementClass) return;
elementClass = (jclass) env->NewGlobalRef(elementClass);
if (!elementClass) return;
entityClass = env->FindClass("org/mozilla/dom/EntityImpl");
if (!entityClass) return;
entityClass = (jclass) env->NewGlobalRef(entityClass);
if (!entityClass) return;
entityReferenceClass = env->FindClass("org/mozilla/dom/EntityReferenceImpl");
if (!entityReferenceClass) return;
entityReferenceClass = (jclass) env->NewGlobalRef(entityReferenceClass);
if (!entityReferenceClass) return;
namedNodeMapClass = env->FindClass("org/mozilla/dom/NamedNodeMapImpl");
if (!namedNodeMapClass) return;
namedNodeMapClass = (jclass) env->NewGlobalRef(namedNodeMapClass);
if (!namedNodeMapClass) return;
nodeListClass = env->FindClass("org/mozilla/dom/NodeListImpl");
if (!nodeListClass) return;
nodeListClass = (jclass) env->NewGlobalRef(nodeListClass);
if (!nodeListClass) return;
nodeListPtrFID =
env->GetFieldID(nodeListClass, "p_nsIDOMNodeList", "J");
if (!nodeListPtrFID) return;
nodeTypeAttributeFID =
env->GetStaticFieldID(nodeClass, "ATTRIBUTE_NODE", "S");
if (!nodeTypeAttributeFID) return;
nodeTypeCDataSectionFID =
env->GetStaticFieldID(nodeClass, "CDATA_SECTION_NODE", "S");
if (!nodeTypeCDataSectionFID) return;
nodeTypeCommentFID =
env->GetStaticFieldID(nodeClass, "COMMENT_NODE", "S");
if (!nodeTypeCommentFID) return;
nodeTypeDocumentFragmentFID =
env->GetStaticFieldID(nodeClass, "DOCUMENT_FRAGMENT_NODE", "S");
if (!nodeTypeDocumentFragmentFID) return;
nodeTypeDocumentFID =
env->GetStaticFieldID(nodeClass, "DOCUMENT_NODE", "S");
if (!nodeTypeDocumentFID) return;
nodeTypeDocumentTypeFID =
env->GetStaticFieldID(nodeClass, "DOCUMENT_TYPE_NODE", "S");
if (!nodeTypeDocumentTypeFID) return;
nodeTypeElementFID =
env->GetStaticFieldID(nodeClass, "ELEMENT_NODE", "S");
if (!nodeTypeElementFID) return;
nodeTypeEntityFID =
env->GetStaticFieldID(nodeClass, "ENTITY_NODE", "S");
if (!nodeTypeEntityFID) return;
nodeTypeEntityReferenceFID =
env->GetStaticFieldID(nodeClass, "ENTITY_REFERENCE_NODE", "S");
if (!nodeTypeEntityReferenceFID) return;
nodeTypeNotationFID =
env->GetStaticFieldID(nodeClass, "NOTATION_NODE", "S");
if (!nodeTypeNotationFID) return;
nodeTypeProcessingInstructionFID =
env->GetStaticFieldID(nodeClass, "PROCESSING_INSTRUCTION_NODE", "S");
if (!nodeTypeProcessingInstructionFID) return;
nodeTypeTextFID =
env->GetStaticFieldID(nodeClass, "TEXT_NODE", "S");
if (!nodeTypeTextFID) return;
notationClass = env->FindClass("org/mozilla/dom/NotationImpl");
if (!notationClass) return;
notationClass = (jclass) env->NewGlobalRef(notationClass);
if (!notationClass) return;
processingInstructionClass = env->FindClass("org/mozilla/dom/ProcessingInstructionImpl");
if (!processingInstructionClass) return;
processingInstructionClass = (jclass) env->NewGlobalRef(processingInstructionClass);
if (!processingInstructionClass) return;
textClass = env->FindClass("org/mozilla/dom/TextImpl");
if (!textClass) return;
textClass = (jclass) env->NewGlobalRef(textClass);
if (!textClass) return;
domExceptionClass = env->FindClass("org/mozilla/dom/DOMExceptionImpl");
if (!domExceptionClass) return;
domExceptionClass = (jclass) env->NewGlobalRef(domExceptionClass);
if (!domExceptionClass) return;
domExceptionInitMID =
env->GetMethodID(domExceptionClass, "<init>", "(SLjava/lang/String;)V");
if (!domExceptionInitMID) return;
runtimeExceptionClass = env->FindClass("java/lang/RuntimeException");
if (!runtimeExceptionClass) return;
runtimeExceptionClass = (jclass) env->NewGlobalRef(runtimeExceptionClass);
if (!runtimeExceptionClass) return;
runtimeExceptionInitMID =
env->GetMethodID(runtimeExceptionClass, "<init>", "(Ljava/lang/String;)V");
if (!runtimeExceptionInitMID) return;
jclass integerClass = env->FindClass("java/lang/Integer");
jfieldID javaMaxIntFID =
env->GetStaticFieldID(integerClass, "MAX_VALUE", "I");
javaMaxInt = env->GetStaticIntField(integerClass, javaMaxIntFID);
//init events globals
JavaDOMEventsGlobals::Initialize(env);
}
void JavaDOMGlobals::Destroy(JNIEnv *env)
{
//destroy events stuff
JavaDOMEventsGlobals::Destroy(env);
env->DeleteGlobalRef(attrClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Attr global ref %x\n",
attrClass));
return;
}
attrClass = NULL;
env->DeleteGlobalRef(cDataSectionClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete CDATASection global ref %x\n",
cDataSectionClass));
return;
}
cDataSectionClass = NULL;
env->DeleteGlobalRef(commentClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Comment global ref %x\n",
commentClass));
return;
}
commentClass = NULL;
env->DeleteGlobalRef(documentClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Document global ref %x\n",
documentClass));
return;
}
documentClass = NULL;
env->DeleteGlobalRef(documentFragmentClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete DocumentFragment global ref %x\n",
documentFragmentClass));
return;
}
documentFragmentClass = NULL;
env->DeleteGlobalRef(documentTypeClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete DocumentType global ref %x\n",
documentTypeClass));
return;
}
documentTypeClass = NULL;
env->DeleteGlobalRef(domImplementationClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete DOMImplementation global ref %x\n",
domImplementationClass));
return;
}
domImplementationClass = NULL;
env->DeleteGlobalRef(elementClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Element global ref %x\n",
elementClass));
return;
}
elementClass = NULL;
env->DeleteGlobalRef(entityClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Entity global ref %x\n",
entityClass));
return;
}
entityClass = NULL;
env->DeleteGlobalRef(entityReferenceClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete EntityReference global ref %x\n",
entityReferenceClass));
return;
}
entityReferenceClass = NULL;
env->DeleteGlobalRef(namedNodeMapClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete NamedNodeMap global ref %x\n",
namedNodeMapClass));
return;
}
namedNodeMapClass = NULL;
env->DeleteGlobalRef(nodeListClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete NodeList global ref %x\n",
nodeListClass));
return;
}
nodeListClass = NULL;
env->DeleteGlobalRef(nodeClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Node global ref %x\n",
nodeClass));
return;
}
nodeClass = NULL;
env->DeleteGlobalRef(notationClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Notation global ref %x\n",
notationClass));
return;
}
notationClass = NULL;
env->DeleteGlobalRef(processingInstructionClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete ProcessingInstruction global ref %x\n",
processingInstructionClass));
return;
}
processingInstructionClass = NULL;
env->DeleteGlobalRef(textClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Text global ref %x\n",
textClass));
return;
}
textClass = NULL;
env->DeleteGlobalRef(domExceptionClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete DOM Exception global ref %x\n",
domExceptionClass));
return;
}
domExceptionClass = NULL;
env->DeleteGlobalRef(runtimeExceptionClass);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete DOM Exception global ref %x\n",
runtimeExceptionClass));
return;
}
runtimeExceptionClass = NULL;
TakeOutGarbage();
PR_DestroyLock(garbageLock);
}
jobject JavaDOMGlobals::CreateNodeSubtype(JNIEnv *env,
nsIDOMNode *node)
{
PRUint16 nodeType = 0;
(void) node->GetNodeType(&nodeType);
jclass clazz = nodeClass;
switch (nodeType) {
case nsIDOMNode::ATTRIBUTE_NODE:
clazz = attrClass;
break;
case nsIDOMNode::CDATA_SECTION_NODE:
clazz = cDataSectionClass;
break;
case nsIDOMNode::COMMENT_NODE:
clazz = commentClass;
break;
case nsIDOMNode::DOCUMENT_NODE:
clazz = documentClass;
break;
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
clazz = documentFragmentClass;
break;
case nsIDOMNode::DOCUMENT_TYPE_NODE:
clazz = documentTypeClass;
break;
case nsIDOMNode::ELEMENT_NODE:
clazz = elementClass;
break;
case nsIDOMNode::ENTITY_NODE:
clazz = entityClass;
break;
case nsIDOMNode::ENTITY_REFERENCE_NODE:
clazz = entityReferenceClass;
break;
case nsIDOMNode::NOTATION_NODE:
clazz = notationClass;
break;
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
clazz = processingInstructionClass;
break;
case nsIDOMNode::TEXT_NODE:
clazz = textClass;
break;
}
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::CreateNodeSubtype: allocating Node of type %d, clazz=%x\n",
nodeType, clazz));
jobject jnode = env->AllocObject(clazz);
if (!jnode) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::CreateNodeSubtype: failed to allocate Node of type %d\n",
nodeType));
return NULL;
}
env->SetLongField(jnode, nodePtrFID, (jlong) node);
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::CreateNodeSubtype: failed to set native ptr %x\n",
(jlong) node));
return NULL;
}
node->AddRef();
return jnode;
}
void JavaDOMGlobals::AddToGarbage(nsISupports* domObject)
{
nsAutoLock lock(garbageLock);
jniDOMGarbage* elem = new jniDOMGarbage(domObject);
PR_INSERT_BEFORE(elem, &garbage);
PR_LOG(log, PR_LOG_DEBUG,
("JavaDOMGlobals::AddToGarbage: Scheduling %x\n", domObject));
}
void JavaDOMGlobals::TakeOutGarbage()
{
nsAutoLock lock(garbageLock);
PRUint32 count = 0;
nsISupports* domo = NULL;
PRCList* chain = NULL;
PRCList* elem = NULL;
for (chain = PR_LIST_HEAD(&garbage);
chain != &garbage;
chain = PR_NEXT_LINK(chain)) {
delete elem;
elem = chain;
domo = ((jniDOMGarbage*) elem)->domObject;
PR_LOG(log, PR_LOG_DEBUG,
("JavaDOMGlobals::TakeOutGarbage: Releasing %x\n", domo));
domo->Release();
domo = NULL;
count++;
}
delete elem;
PR_INIT_CLIST(&garbage);
if (count)
PR_LOG(log, PR_LOG_DEBUG,
("JavaDOMGlobals::TakeOutGarbage: Released %d objects\n", count));
}
// caller must return from JNI immediately after calling this function
void JavaDOMGlobals::ThrowException(JNIEnv *env,
const char * message,
nsresult rv,
ExceptionType exceptionType) {
jthrowable newException = NULL;
if (exceptionType == EXCEPTION_DOM) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::ThrowException: (%x) %s: %s\n",
NS_ERROR_GET_CODE(rv),
message ? message : "",
DOM_EXCEPTION_MESSAGE[NS_ERROR_GET_CODE(rv)]));
jstring jmessage =
env->NewStringUTF(DOM_EXCEPTION_MESSAGE[NS_ERROR_GET_CODE(rv)]);
newException =
(jthrowable)env->NewObject(domExceptionClass,
domExceptionInitMID,
NS_ERROR_GET_CODE(rv),
jmessage);
} else {
char buffer[256];
const char* msg = message;
if (rv != NS_OK) {
sprintf(buffer,
"(%x.%x) %s",
NS_ERROR_GET_MODULE(rv),
NS_ERROR_GET_CODE(rv),
message ? message : "");
msg = buffer;
}
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::ThrowException: %s\n", msg));
jstring jmessage = env->NewStringUTF(msg);
newException =
(jthrowable)env->NewObject(runtimeExceptionClass,
runtimeExceptionInitMID,
jmessage);
}
if (newException != NULL) {
env->Throw(newException);
}
// an exception is thrown in any case
}

View File

@@ -1,105 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __JavaDOMGlobals_h__
#define __JavaDOMGlobals_h__
#include "jni.h"
#include "prclist.h"
#include "nsError.h"
#ifdef ERROR
#undef ERROR
#endif
class nsISupports;
class nsIDOMNode;
struct PRLogModuleInfo;
struct PRLock;
class JavaDOMGlobals {
public:
static jclass attrClass;
static jclass cDataSectionClass;
static jclass commentClass;
static jclass documentClass;
static jclass documentFragmentClass;
static jclass documentTypeClass;
static jclass domImplementationClass;
static jclass elementClass;
static jclass entityClass;
static jclass entityReferenceClass;
static jclass namedNodeMapClass;
static jclass nodeClass;
static jclass nodeListClass;
static jclass notationClass;
static jclass processingInstructionClass;
static jclass textClass;
static jfieldID nodePtrFID;
static jfieldID nodeListPtrFID;
static jfieldID domImplementationPtrFID;
static jfieldID nodeTypeAttributeFID;
static jfieldID nodeTypeCDataSectionFID;
static jfieldID nodeTypeCommentFID;
static jfieldID nodeTypeDocumentFragmentFID;
static jfieldID nodeTypeDocumentFID;
static jfieldID nodeTypeDocumentTypeFID;
static jfieldID nodeTypeElementFID;
static jfieldID nodeTypeEntityFID;
static jfieldID nodeTypeEntityReferenceFID;
static jfieldID nodeTypeNotationFID;
static jfieldID nodeTypeProcessingInstructionFID;
static jfieldID nodeTypeTextFID;
static jclass domExceptionClass;
static jmethodID domExceptionInitMID;
static jclass runtimeExceptionClass;
static jmethodID runtimeExceptionInitMID;
static const char* const DOM_EXCEPTION_MESSAGE[];
typedef enum ExceptionType { EXCEPTION_RUNTIME,
EXCEPTION_DOM } ExceptionType;
static PRLogModuleInfo* log;
static PRCList garbage;
static PRLock* garbageLock;
static PRInt32 javaMaxInt;
static void Initialize(JNIEnv *env);
static void Destroy(JNIEnv *env);
static jobject CreateNodeSubtype(JNIEnv *env,
nsIDOMNode *node);
static void AddToGarbage(nsISupports* domObject);
static void TakeOutGarbage();
static void ThrowException(JNIEnv *env,
const char * message = NULL,
nsresult rv = NS_OK,
ExceptionType exceptionType = EXCEPTION_RUNTIME);
};
#endif /* __JavaDOMGlobals_h__ */

View File

@@ -1,100 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# 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.org code.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are
# Copyright (C) 1999 Sun Microsystems, Inc. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
IGNORE_MANIFEST=1
DEFINES=-D_IMPL_NS_WEB -DWIN32_LEAN_AND_MEAN
MODULE=javadomjni
CPPSRCS= \
javaDOMGlobals.cpp \
javaDOMEventsGlobals.cpp \
nativeDOMProxyListener.cpp \
org_mozilla_dom_DOMAccessor.cpp \
org_mozilla_dom_AttrImpl.cpp \
org_mozilla_dom_CharacterDataImpl.cpp \
org_mozilla_dom_DocumentImpl.cpp \
org_mozilla_dom_DocumentTypeImpl.cpp \
org_mozilla_dom_DOMImplementationImpl.cpp \
org_mozilla_dom_ElementImpl.cpp \
org_mozilla_dom_EntityImpl.cpp \
org_mozilla_dom_NamedNodeMapImpl.cpp \
org_mozilla_dom_NodeImpl.cpp \
org_mozilla_dom_NodeListImpl.cpp \
org_mozilla_dom_NotationImpl.cpp \
org_mozilla_dom_ProcessingInstructionImpl.cpp \
org_mozilla_dom_TextImpl.cpp \
org_mozilla_dom_events_EventImpl.cpp \
org_mozilla_dom_events_MouseEventImpl.cpp \
org_mozilla_dom_events_UIEventImpl.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\javaDOMGlobals.obj \
.\$(OBJDIR)\javaDOMEventsGlobals.obj \
.\$(OBJDIR)\nativeDOMProxyListener.obj \
.\$(OBJDIR)\org_mozilla_dom_DOMAccessor.obj \
.\$(OBJDIR)\org_mozilla_dom_AttrImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_CharacterDataImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_DocumentImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_DocumentTypeImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_DOMImplementationImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_ElementImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_EntityImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_NamedNodeMapImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_NodeImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_NodeListImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_NotationImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_ProcessingInstructionImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_TextImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_events_EventImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_events_UIEventImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_events_MouseEventImpl.obj \
$(NULL)
LINCS=
MAKE_OBJ_TYPE = DLL
DLLNAME = javadomjni
DLL=.\$(OBJDIR)\$(DLLNAME).dll
LIBRARY_NAME=javadomimpl
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
# These are the libraries we need to link with to create the dll
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR)
include <$(DEPTH)\config\config.mak>
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
rm -f $(DIST)\bin\$(DLLNAME).dll
rm -f $(DIST)\lib\$(DLLNAME).lib

View File

@@ -1,130 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include<stdio.h>
#include"prlog.h"
#include"nativeDOMProxyListener.h"
#include"nsIDOMNode.h"
#include"nsIDOMEventTarget.h"
#include"nsIDOMEventListener.h"
#include"javaDOMEventsGlobals.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDOMEventListener, NS_IDOMEVENTLISTENER_IID);
NativeDOMProxyListener::NativeDOMProxyListener(JNIEnv *env, jobject jlistener)
{
mRefCnt = 0;
listener = env->NewGlobalRef(jlistener);
if (env->GetJavaVM(&vm) != 0)
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NativeDOMProxyListener: Can't objant jvm\n"));
}
//should be called oly from NativeDOMProxyListener::Release
NativeDOMProxyListener::~NativeDOMProxyListener()
{
JNIEnv *env;
if (vm->AttachCurrentThread( &env, NULL) != 0)
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NativeDOMProxyListener: Can't attach current thread to JVM\n"));
env->DeleteGlobalRef(listener);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NativeDOMProxyListener::Destroy: failed to delete EventListener global ref %x\n",
listener));
return;
}
}
nsresult NativeDOMProxyListener::HandleEvent(nsIDOMEvent* aEvent)
{
jobject jevent;
JNIEnv *env;
if (vm->AttachCurrentThread( &env, NULL) != 0) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NativeDOMProxyListener:HandleEvent Can't attach current thread to JVM\n"));
return NS_ERROR_FAILURE;
}
jevent = JavaDOMEventsGlobals::CreateEventSubtype(env, aEvent);
if (!jevent) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NativeDOMProxyListener::HandleEvent Can't create java event object"));
return NS_ERROR_FAILURE;
}
env->CallVoidMethod(listener,
JavaDOMEventsGlobals::eventListenerHandleEventMID,
jevent);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NativeDOMProxyListener::HandleEvent: failed to call EventListener %x\n",
listener));
return NS_ERROR_FAILURE;
}
return NS_OK;
}
nsresult NativeDOMProxyListener::QueryInterface(const nsIID &aIID, void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *) this;
} else if (aIID.Equals(kIDOMEventListener)) {
*aResult = (void *) this;
}
if (aResult != NULL) {
return NS_ERROR_NO_INTERFACE;
}
AddRef();
return NS_OK;
}
nsrefcnt NativeDOMProxyListener::AddRef()
{
return mRefCnt++;
}
nsrefcnt NativeDOMProxyListener::Release()
{
if (--mRefCnt == 0) {
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}

View File

@@ -1,29 +0,0 @@
#ifndef __JAVA_DOM_NATIVE_PROXY_LISTENER__
#define __JAVA_DOM_NATIVE_PROXY_LISTENER__
#include"nsIDOMEventListener.h"
#include"jni.h"
class NativeDOMProxyListener: public nsIDOMEventListener{
private:
JavaVM *vm;
jobject listener;
nsrefcnt mRefCnt;
//to be used only by Release()
virtual ~NativeDOMProxyListener();
public:
NativeDOMProxyListener(JNIEnv *env, jobject jlistener);
virtual nsresult HandleEvent(nsIDOMEvent* aEvent);
NS_IMETHOD QueryInterface(const nsIID &aIID, void **aResult);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
};
#endif

View File

@@ -1,155 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMAttr.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_AttrImpl.h"
/*
* Class: org_mozilla_dom_AttrImpl
* Method: getName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_AttrImpl_getName
(JNIEnv *env, jobject jthis)
{
nsIDOMAttr* attr = (nsIDOMAttr*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!attr) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getName: NULL pointer\n"));
return NULL;
}
nsString name;
nsresult rv = attr->GetName(name);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getName: failed (%x)\n", rv));
return NULL;
}
jstring jname = env->NewString(name.GetUnicode(), name.Length());
if (!jname) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getName: NewString failed\n"));
}
return jname;
}
/*
* Class: org_mozilla_dom_AttrImpl
* Method: getSpecified
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_AttrImpl_getSpecified
(JNIEnv *env, jobject jthis)
{
nsIDOMAttr* attr = (nsIDOMAttr*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!attr) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getSpecified: NULL pointer\n"));
return JNI_FALSE;
}
PRBool specified = PR_FALSE;
nsresult rv = attr->GetSpecified(&specified);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getSpecified: failed (%x)\n", rv));
return JNI_FALSE;
}
return (specified == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_AttrImpl
* Method: getValue
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_AttrImpl_getValue
(JNIEnv *env, jobject jthis)
{
nsIDOMAttr* attr = (nsIDOMAttr*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!attr) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getValue: NULL pointer\n"));
return NULL;
}
nsString value;
nsresult rv = attr->GetValue(value);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getValue: failed (%x)\n", rv));
return NULL;
}
jstring jval = env->NewString(value.GetUnicode(), value.Length());
if (!jval) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.getValue: NewString failed\n"));
}
return jval;
}
/*
* Class: org_mozilla_dom_AttrImpl
* Method: setValue
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_AttrImpl_setValue
(JNIEnv *env, jobject jthis, jstring jval)
{
nsIDOMAttr* attr = (nsIDOMAttr*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!attr || !jval) {
JavaDOMGlobals::ThrowException(env,
"Attr.setValue: NULL pointer\n");
return;
}
jboolean iscopy;
const jchar* cstr = env->GetStringChars(jval, &iscopy);
if (!cstr) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.setValue: GetStringChars failed\n"));
env->ReleaseStringChars(jval, cstr);
return;
}
nsresult rv = attr->SetValue((PRUnichar*)cstr);
env->ReleaseStringChars(jval, cstr);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Attr.setValue: failed (%x)\n", rv));
return;
}
}

View File

@@ -1,45 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_AttrImpl */
#ifndef _Included_org_mozilla_dom_AttrImpl
#define _Included_org_mozilla_dom_AttrImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_AttrImpl
* Method: getName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_AttrImpl_getName
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_AttrImpl
* Method: getSpecified
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_AttrImpl_getSpecified
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_AttrImpl
* Method: getValue
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_AttrImpl_getValue
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_AttrImpl
* Method: setValue
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_AttrImpl_setValue
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,342 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMCharacterData.h"
#include "nsDOMError.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_CharacterDataImpl.h"
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: appendData
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_appendData
(JNIEnv *env, jobject jthis, jstring jvalue)
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: NULL pointer");
return;
}
jboolean iscopy;
const jchar* value = env->GetStringChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: GetStringChars failed");
env->ReleaseStringChars(jvalue, value);
return;
}
nsresult rv = data->AppendData((PRUnichar*)value);
env->ReleaseStringChars(jvalue, value);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.appendData: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: deleteData
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_deleteData
(JNIEnv *env, jobject jthis, jint offset, jint count)
{
if (offset < 0 || offset > JavaDOMGlobals::javaMaxInt ||
count < 0 || count > JavaDOMGlobals::javaMaxInt) {
JavaDOMGlobals::ThrowException(env, "CharacterData.deleteData: failed",
NS_ERROR_DOM_INDEX_SIZE_ERR,
JavaDOMGlobals::EXCEPTION_DOM);
return;
}
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.deleteData: NULL pointer");
return;
}
nsresult rv = data->DeleteData((PRUint32) offset, (PRUint32) count);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_INDEX_SIZE_ERR ||
rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.deleteData: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: getData
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_CharacterDataImpl_getData
(JNIEnv *env, jobject jthis)
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.getData: NULL pointer");
return NULL;
}
nsString ret;
nsresult rv = data->GetData(ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_DOMSTRING_SIZE_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.getData: failed", rv, exceptionType);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.getData: NewString failed");
}
return jret;
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_CharacterDataImpl_getLength
(JNIEnv *env, jobject jthis)
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.getLength: NULL pointer");
return 0;
}
PRUint32 len = 0;
nsresult rv = data->GetLength(&len);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.getLength: failed", rv);
return 0;
}
return (jint) len;
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: insertData
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_insertData
(JNIEnv *env, jobject jthis, jint offset, jstring jvalue)
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: NULL pointer");
return;
}
jboolean iscopy;
const jchar* value = env->GetStringChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: GetStringChars failed");
env->ReleaseStringChars(jvalue, value);
return;
}
nsresult rv = data->InsertData((PRUint32) offset, (PRUnichar*)value);
env->ReleaseStringChars(jvalue, value);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_INDEX_SIZE_ERR ||
rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.insertData: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: replaceData
* Signature: (IILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_replaceData
(JNIEnv *env, jobject jthis, jint offset, jint count, jstring jvalue)
{
if (offset < 0 || offset > JavaDOMGlobals::javaMaxInt ||
count < 0 || count > JavaDOMGlobals::javaMaxInt) {
JavaDOMGlobals::ThrowException(env, "CharacterData.replaceData: failed",
NS_ERROR_DOM_INDEX_SIZE_ERR,
JavaDOMGlobals::EXCEPTION_DOM);
return;
}
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: NULL pointer");
return;
}
jboolean iscopy;
const jchar* value = env->GetStringChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: GetStringChars failed");
env->ReleaseStringChars(jvalue, value);
return;
}
nsresult rv = data->ReplaceData((PRUint32) offset, (PRUint32) count, (PRUnichar*)value);
env->ReleaseStringChars(jvalue, value);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_INDEX_SIZE_ERR ||
rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.replaceData: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: setData
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_setData
(JNIEnv *env, jobject jthis, jstring jvalue)
{
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: NULL pointer");
return;
}
jboolean iscopy;
const jchar* value = env->GetStringChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: GetStringChars failed");
env->ReleaseStringChars(jvalue, value);
return;
}
nsresult rv = data->SetData((PRUnichar*)value);
env->ReleaseStringChars(jvalue, value);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.setData: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: substringData
* Signature: (II)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_CharacterDataImpl_substringData
(JNIEnv *env, jobject jthis, jint offset, jint count)
{
if (offset < 0 || offset > JavaDOMGlobals::javaMaxInt ||
count < 0 || count > JavaDOMGlobals::javaMaxInt) {
JavaDOMGlobals::ThrowException(env, "CharacterData.substringData: failed",
NS_ERROR_DOM_INDEX_SIZE_ERR,
JavaDOMGlobals::EXCEPTION_DOM);
return NULL;
}
nsIDOMCharacterData* data = (nsIDOMCharacterData*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.substringData: NULL pointer");
return NULL;
}
nsString ret;
nsresult rv = data->SubstringData((PRUint32) offset, (PRUint32) count, ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_INDEX_SIZE_ERR ||
rv == NS_ERROR_DOM_DOMSTRING_SIZE_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"CharacterData.substringData: failed", rv, exceptionType);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"CharacterData.substringData: NewString failed");
}
return jret;
}

View File

@@ -1,77 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_CharacterDataImpl */
#ifndef _Included_org_mozilla_dom_CharacterDataImpl
#define _Included_org_mozilla_dom_CharacterDataImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: appendData
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_appendData
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: deleteData
* Signature: (II)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_deleteData
(JNIEnv *, jobject, jint, jint);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: getData
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_CharacterDataImpl_getData
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_CharacterDataImpl_getLength
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: insertData
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_insertData
(JNIEnv *, jobject, jint, jstring);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: replaceData
* Signature: (IILjava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_replaceData
(JNIEnv *, jobject, jint, jint, jstring);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: setData
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_CharacterDataImpl_setData
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_CharacterDataImpl
* Method: substringData
* Signature: (II)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_CharacterDataImpl_substringData
(JNIEnv *, jobject, jint, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,118 +0,0 @@
#include "prlog.h"
#include "javaDOMGlobals.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsIServiceManager.h"
#include "nsCURILoader.h"
#include "nsIJavaDOM.h"
#include "org_mozilla_dom_DOMAccessor.h"
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
static NS_DEFINE_IID(kJavaDOMCID, NS_JAVADOM_CID);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: register
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_register
(JNIEnv *env, jclass jthis)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv);
if (NS_FAILED(rv) || !docLoaderService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
rv));
} else {
NS_WITH_SERVICE(nsIDocumentLoaderObserver, javaDOM, kJavaDOMCID, &rv);
if (NS_FAILED(rv) || !javaDOM) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
rv));
} else {
rv = docLoaderService->AddObserver((nsIDocumentLoaderObserver*)javaDOM);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: AddObserver(JavaDOM) failed x\n",
rv));
}
}
}
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: unregister
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_unregister
(JNIEnv *, jclass jthis)
{
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
("DOMAccessor::unregister: unregistering %x\n", jthis));
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv);
if (NS_FAILED(rv) || !docLoaderService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: GetService(DocLoaderService) failed %x\n",
rv));
} else {
NS_WITH_SERVICE(nsIDocumentLoaderObserver, javaDOM, kJavaDOMCID, &rv);
if (NS_FAILED(rv) || !javaDOM) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: GetService(JavaDOM) failed %x\n",
rv));
} else {
rv = docLoaderService->RemoveObserver((nsIDocumentLoaderObserver*)javaDOM);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: RemoveObserver(JavaDOM) failed x\n",
rv));
}
}
}
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: createElement
* Signature: (J)Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessor_getNodeByHandle
(JNIEnv *env, jclass jthis, jlong p)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
nsIDOMNode *node = (nsIDOMNode*)p;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: doGC
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_doGC
(JNIEnv *, jclass)
{
JavaDOMGlobals::TakeOutGarbage();
}
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_initialize
(JNIEnv *env, jclass)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
}

View File

@@ -1,55 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_DOMAccessor */
#ifndef _Included_org_mozilla_dom_DOMAccessor
#define _Included_org_mozilla_dom_DOMAccessor
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: documentLoadListeners */
/* Inaccessible static: permission */
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: doGC
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_doGC
(JNIEnv *, jclass);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: getNodeByHandle
* Signature: (J)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessor_getNodeByHandle
(JNIEnv *, jclass, jlong);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: initialize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_initialize
(JNIEnv *, jclass);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: register
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_register
(JNIEnv *, jclass);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: unregister
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_unregister
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,184 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMDOMImplementation.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_DOMImplementationImpl.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: XPCOM_equals
* Signature: (Ljava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1equals
(JNIEnv *env, jobject jthis, jobject jarg)
{
jboolean b_retFlag = JNI_FALSE;
nsIDOMDOMImplementation* p_this = (nsIDOMDOMImplementation*)
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
if (!p_this) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DOMImplementation.equals: NULL pointer\n"));
return b_retFlag;
}
nsIDOMDOMImplementation* p_arg = (nsIDOMDOMImplementation*)
env->GetLongField(jarg, JavaDOMGlobals::domImplementationPtrFID);
if (!p_arg) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DOMImplementation.equals: NULL arg pointer\n"));
return b_retFlag;
}
nsISupports* thisSupports = nsnull;
nsISupports* argSupports = nsnull;
nsresult rvThis =
p_this->QueryInterface(kISupportsIID, (void**)(&thisSupports));
if (NS_FAILED(rvThis) || !thisSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.equals: this->QueryInterface failed (%x)\n",
rvThis));
return b_retFlag;
}
nsresult rvArg =
p_arg->QueryInterface(kISupportsIID, (void**)(&argSupports));
if (NS_FAILED(rvArg) || !argSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.equals: arg->QueryInterface failed (%x)\n",
rvArg));
thisSupports->Release();
return b_retFlag;
}
if (thisSupports == argSupports)
b_retFlag = JNI_TRUE;
thisSupports->Release();
argSupports->Release();
return b_retFlag;
}
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: XPCOM_hashCode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1hashCode
(JNIEnv *env, jobject jthis)
{
nsIDOMDOMImplementation* p_this = (nsIDOMDOMImplementation*)
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
if (!p_this) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DOMImplementation.hashCode: NULL pointer\n"));
return (jint) 0;
}
nsISupports* thisSupports = nsnull;
nsresult rvThis =
p_this->QueryInterface(kISupportsIID, (void**)(&thisSupports));
if (NS_FAILED(rvThis) || !thisSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.hashCode: QueryInterface failed (%x)\n",
rvThis));
return (jint) 0;
}
thisSupports->Release();
return (jint) thisSupports;
}
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMImplementationImpl_finalize
(JNIEnv *env, jobject jthis)
{
nsIDOMDOMImplementation* dom = (nsIDOMDOMImplementation*)
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
if (!dom) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DOMImplementation.finalize: NULL pointer\n"));
return;
}
JavaDOMGlobals::AddToGarbage(dom);
}
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: hasFeature
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature
(JNIEnv *env, jobject jthis, jstring jfeature, jstring jversion)
{
nsIDOMDOMImplementation* dom = (nsIDOMDOMImplementation*)
env->GetLongField(jthis, JavaDOMGlobals::domImplementationPtrFID);
if (!dom || !jfeature) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DOMImplementation.hasFeature: NULL pointer\n"));
return JNI_FALSE;
}
jboolean iscopy;
const jchar* feature = env->GetStringChars(jfeature, &iscopy);
if (!feature) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.hasFeature: GetStringChars feature failed\n"));
env->ReleaseStringChars(jfeature, feature);
return JNI_FALSE;
}
jboolean iscopy2;
const jchar* version = NULL;
if (jversion) {
version = env->GetStringChars(jversion, &iscopy2);
if (!version) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.hasFeature: GetStringChars version failed\n"));
env->ReleaseStringChars(jversion, version);
env->ReleaseStringChars(jfeature, feature);
return JNI_FALSE;
}
}
PRBool ret = PR_FALSE;
nsresult rv = dom->HasFeature((PRUnichar*)feature, (PRUnichar*)version, &ret);
env->ReleaseStringChars(jversion, version);
env->ReleaseStringChars(jfeature, feature);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMImplementation.hasFeature: failed (%x)\n", rv));
}
return ret == PR_TRUE ? JNI_TRUE : JNI_FALSE;
}

View File

@@ -1,45 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_DOMImplementationImpl */
#ifndef _Included_org_mozilla_dom_DOMImplementationImpl
#define _Included_org_mozilla_dom_DOMImplementationImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: hasFeature
* Signature: (Ljava/lang/String;Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_hasFeature
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMImplementationImpl_finalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: XPCOM_equals
* Signature: (Ljava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1equals
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_dom_DOMImplementationImpl
* Method: XPCOM_hashCode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_DOMImplementationImpl_XPCOM_1hashCode
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,663 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMDocument.h"
#include "nsIDOMAttr.h"
#include "nsIDOMComment.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMCDATASection.h"
#include "nsIDOMEntityReference.h"
#include "nsIDOMDOMImplementation.h"
#include "nsIDOMProcessingInstruction.h"
#include "nsDOMError.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_DocumentImpl.h"
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createAttribute
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createAttribute
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jname) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: NULL pointer");
return NULL;
}
nsIDOMAttr* ret = nsnull;
jboolean iscopy = JNI_FALSE;
const jchar* name = env->GetStringChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: GetStringChars failed");
env->ReleaseStringChars(jname, name);
return NULL;
}
nsresult rv = doc->CreateAttribute((PRUnichar*)name, &ret);
env->ReleaseStringChars(jname, name);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_INVALID_CHARACTER_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: failed", rv, exceptionType);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::attrClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createAttribute: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createCDATASection
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/CDATASection;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createCDATASection
(JNIEnv *env, jobject jthis, jstring jdata)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: NULL pointer");
return NULL;
}
nsIDOMCDATASection* ret = nsnull;
jboolean iscopy;
const jchar* data = env->GetStringChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: GetStringChars failed");
env->ReleaseStringChars(jdata, data);
return NULL;
}
nsresult rv = doc->CreateCDATASection((PRUnichar*)data, &ret);
env->ReleaseStringChars(jdata, data);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NOT_SUPPORTED_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: failed", rv, exceptionType);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::cDataSectionClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createCDATASection: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createComment
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Comment;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createComment
(JNIEnv *env, jobject jthis, jstring jdata)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: NULL pointer");
return NULL;
}
nsIDOMComment* ret = nsnull;
jboolean iscopy;
const jchar* data = env->GetStringChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: GetStringChars failed");
env->ReleaseStringChars(jdata, data);
return NULL;
}
nsresult rv = doc->CreateComment((PRUnichar*)data, &ret);
env->ReleaseStringChars(jdata, data);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::commentClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createComment: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createDocumentFragment
* Signature: ()Lorg/w3c/dom/DocumentFragment;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createDocumentFragment
(JNIEnv *env, jobject jthis)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
JavaDOMGlobals::ThrowException(env,
"Document.createDocumentFragment: NULL pointer");
return NULL;
}
nsIDOMDocumentFragment* ret = nsnull;
nsresult rv = doc->CreateDocumentFragment(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Document.createDocumentFragment: failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::documentFragmentClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createDocumentFragment: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createDocumentFragment: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createElement
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createElement
(JNIEnv *env, jobject jthis, jstring jtagName)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jtagName) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: NULL pointer");
return NULL;
}
nsIDOMElement* ret = nsnull;
jboolean iscopy;
const jchar* tagName = env->GetStringChars(jtagName, &iscopy);
if (!tagName) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: GetStringChars failed");
env->ReleaseStringChars(jtagName, tagName);
return NULL;
}
nsresult rv = doc->CreateElement((PRUnichar*)tagName, &ret);
env->ReleaseStringChars(jtagName, tagName);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_INVALID_CHARACTER_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Document.createElement: failed", rv, exceptionType);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::elementClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createElement: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createEntityReference
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/EntityReference;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createEntityReference
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jname) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: NULL pointer");
return NULL;
}
nsIDOMEntityReference* ret = nsnull;
jboolean iscopy;
const jchar* name = env->GetStringChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: GetStringChars failed");
env->ReleaseStringChars(jname, name);
return NULL;
}
nsresult rv = doc->CreateEntityReference((PRUnichar*)name, &ret);
env->ReleaseStringChars(jname, name);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_INVALID_CHARACTER_ERR ||
rv == NS_ERROR_DOM_NOT_SUPPORTED_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: failed", rv, exceptionType);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::entityReferenceClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createEntityReference: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createProcessingInstruction
* Signature: (Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/ProcessingInstruction;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createProcessingInstruction
(JNIEnv *env, jobject jthis, jstring jtarget, jstring jdata)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jtarget || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: NULL pointer");
return NULL;
}
nsIDOMProcessingInstruction* ret = nsnull;
jboolean iscopy;
jboolean iscopy2;
const jchar* target = env->GetStringChars(jtarget, &iscopy);
if (!target) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringChars target failed");
return NULL;
}
const jchar* data = env->GetStringChars(jdata, &iscopy2);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: GetStringChars data failed");
env->ReleaseStringChars(jdata, data);
env->ReleaseStringChars(jtarget, target);
return NULL;
}
nsresult rv = doc->CreateProcessingInstruction((PRUnichar*)target, (PRUnichar*)data, &ret);
env->ReleaseStringChars(jdata, data);
env->ReleaseStringChars(jtarget, target);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NOT_SUPPORTED_ERR ||
rv == NS_ERROR_DOM_INVALID_CHARACTER_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction failed", rv, exceptionType);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::processingInstructionClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createProcessingInstruction: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createTextNode
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Text;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createTextNode
(JNIEnv *env, jobject jthis, jstring jdata)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jdata) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode: NULL pointer");
return NULL;
}
nsIDOMText* ret = nsnull;
jboolean iscopy;
const jchar* data = env->GetStringChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode: GetStringChars failed");
env->ReleaseStringChars(jdata, data);
return NULL;
}
nsresult rv = doc->CreateTextNode((PRUnichar*)data, &ret);
env->ReleaseStringChars(jdata, data);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::textClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.createTextNode: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getDoctype
* Signature: ()Lorg/w3c/dom/DocumentType;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getDoctype
(JNIEnv *env, jobject jthis)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc)
return NULL;
nsIDOMDocumentType* docType = nsnull;
nsresult rv = doc->GetDoctype(&docType);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Document.getDoctype: failed", rv);
return NULL;
}
if (!docType)
return NULL;
jobject jDocType = env->AllocObject(JavaDOMGlobals::documentTypeClass);
if (!jDocType) {
JavaDOMGlobals::ThrowException(env,
"Document.getDoctype: failed to allocate object");
return NULL;
}
env->SetLongField(jDocType, JavaDOMGlobals::nodePtrFID, (jlong) docType);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.getDoctype: failed to set node ptr");
return NULL;
}
docType->AddRef();
return jDocType;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getDocumentElement
* Signature: ()Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getDocumentElement
(JNIEnv *env, jobject jthis)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
JavaDOMGlobals::ThrowException(env,
"Document.getDocumentElement: NULL pointer");
return NULL;
}
nsIDOMElement* element = nsnull;
nsresult rv = doc->GetDocumentElement(&element);
if (NS_FAILED(rv) || !element) {
JavaDOMGlobals::ThrowException(env,
"Document.getDocumentElement: failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::elementClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.getDocumentElement: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) element);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.getDocumentElement: failed to set node ptr");
return NULL;
}
element->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getElementsByTagName
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/NodeList;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagName
(JNIEnv *env, jobject jthis, jstring jtagName)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc || !jtagName) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: NULL pointer");
return NULL;
}
nsIDOMNodeList* elements = nsnull;
jboolean iscopy;
const jchar* tagName = env->GetStringChars(jtagName, &iscopy);
if (!tagName) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: GetStringChars failed");
env->ReleaseStringChars(jtagName, tagName);
return NULL;
}
nsresult rv = doc->GetElementsByTagName((PRUnichar*)tagName, &elements);
env->ReleaseStringChars(jtagName, tagName);
if (NS_FAILED(rv) || !elements) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::nodeListClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) elements);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.getElementsByTagName: failed to set node ptr");
return NULL;
}
elements->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getImplementation
* Signature: ()Lorg/w3c/dom/DOMImplementation;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getImplementation
(JNIEnv *env, jobject jthis)
{
nsIDOMDocument* doc = (nsIDOMDocument*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!doc) {
JavaDOMGlobals::ThrowException(env,
"Document.getImplementation: NULL pointer");
return NULL;
}
nsIDOMDOMImplementation* impl = nsnull;
nsresult rv = doc->GetImplementation(&impl);
if (NS_FAILED(rv) || !impl) {
JavaDOMGlobals::ThrowException(env,
"Document.getImplementation: failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::domImplementationClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Document.getImplementation: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) impl);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Document.getImplementation: failed to set node ptr");
return NULL;
}
impl->AddRef();
return jret;
}

View File

@@ -1,110 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_DocumentImpl */
#ifndef _Included_org_mozilla_dom_DocumentImpl
#define _Included_org_mozilla_dom_DocumentImpl
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: javaDOMlisteners */
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createAttribute
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createAttribute
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createCDATASection
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/CDATASection;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createCDATASection
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createComment
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Comment;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createComment
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createDocumentFragment
* Signature: ()Lorg/w3c/dom/DocumentFragment;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createDocumentFragment
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createElement
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createElement
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createEntityReference
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/EntityReference;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createEntityReference
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createProcessingInstruction
* Signature: (Ljava/lang/String;Ljava/lang/String;)Lorg/w3c/dom/ProcessingInstruction;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createProcessingInstruction
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: createTextNode
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Text;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_createTextNode
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getDoctype
* Signature: ()Lorg/w3c/dom/DocumentType;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getDoctype
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getDocumentElement
* Signature: ()Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getDocumentElement
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getElementsByTagName
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/NodeList;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getElementsByTagName
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_DocumentImpl
* Method: getImplementation
* Signature: ()Lorg/w3c/dom/DOMImplementation;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentImpl_getImplementation
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,145 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMNamedNodeMap.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_DocumentImpl.h"
/*
* Class: org_mozilla_dom_DocumentTypeImpl
* Method: getEntities
* Signature: ()Lorg/w3c/dom/NamedNodeMap;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentTypeImpl_getEntities
(JNIEnv *env, jobject jthis)
{
nsIDOMDocumentType* docType = (nsIDOMDocumentType*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!docType) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DocumentType.getEntities: NULL pointer\n"));
return NULL;
}
nsIDOMNamedNodeMap* nodeMap = nsnull;
nsresult rv = docType->GetEntities(&nodeMap);
if (NS_FAILED(rv) || !nodeMap) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getEntities: failed (%x)\n", rv));
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::namedNodeMapClass);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getEntities: failed to allocate object\n"));
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) nodeMap);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getEntities: failed to set node ptr: %x\n", nodeMap));
return NULL;
}
nodeMap->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_DocumentTypeImpl
* Method: getName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_DocumentTypeImpl_getName
(JNIEnv *env, jobject jthis)
{
nsIDOMDocumentType* docType = (nsIDOMDocumentType*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!docType) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DocumentType.getName: NULL pointer\n"));
return NULL;
}
nsString ret;
nsresult rv = docType->GetName(ret);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getName: failed (%x)\n", rv));
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getName: NewString failed\n"));
}
return jret;
}
/*
* Class: org_mozilla_dom_DocumentTypeImpl
* Method: getNotations
* Signature: ()Lorg/w3c/dom/NamedNodeMap;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentTypeImpl_getNotations
(JNIEnv *env, jobject jthis)
{
nsIDOMDocumentType* docType = (nsIDOMDocumentType*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!docType) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("DocumentType.getNotations: NULL pointer\n"));
return NULL;
}
nsIDOMNamedNodeMap* nodeMap = nsnull;
nsresult rv = docType->GetNotations(&nodeMap);
if (NS_FAILED(rv) || !nodeMap) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getNotations: failed (%x)\n", rv));
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::namedNodeMapClass);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getNotations: failed to allocate object\n"));
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) nodeMap);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DocumentType.getNotations: failed to set node ptr: %x\n", nodeMap));
return NULL;
}
nodeMap->AddRef();
return jret;
}

View File

@@ -1,37 +0,0 @@
#include "nsIDOMDocumentType.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_DocumentTypeImpl.h"
/*
* Class: org_mozilla_dom_DocumentTypeImpl
* Method: getEntities
* Signature: ()Lorg/w3c/dom/NamedNodeMap;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentTypeImpl_getEntities
(JNIEnv *, jobject)
{
return NULL;
}
/*
* Class: org_mozilla_dom_DocumentTypeImpl
* Method: getName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_DocumentTypeImpl_getName
(JNIEnv *, jobject)
{
return NULL;
}
/*
* Class: org_mozilla_dom_DocumentTypeImpl
* Method: getNotations
* Signature: ()Lorg/w3c/dom/NamedNodeMap;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DocumentTypeImpl_getNotations
(JNIEnv *, jobject)
{
return NULL;
}

View File

@@ -1,447 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMElement.h"
#include "nsIDOMAttr.h"
#include "nsIDOMNodeList.h"
#include "nsDOMError.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_ElementImpl.h"
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getAttribute
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getAttribute
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: NULL pointer");
return NULL;
}
jboolean iscopy;
const jchar* cname = env->GetStringChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: GetStringChars failed");
env->ReleaseStringChars(jname, cname);
return NULL;
}
nsString attr;
nsresult rv = element->GetAttribute((PRUnichar*)cname, attr);
env->ReleaseStringChars(jname, cname);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: failed", rv);
return NULL;
}
jstring jattr = env->NewString(attr.GetUnicode(), attr.Length());
if (!jattr) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttribute: NewString failed");
return NULL;
}
return jattr;
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getAttributeNode
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getAttributeNode
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: NULL pointer");
return NULL;
}
jboolean iscopy;
const jchar* cname = env->GetStringChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: GetStringChars failed");
env->ReleaseStringChars(jname, cname);
return NULL;
}
nsIDOMAttr* attr = nsnull;
nsresult rv = element->GetAttributeNode((PRUnichar*)cname, &attr);
env->ReleaseStringChars(jname, cname);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: failed", rv);
return NULL;
}
if (!attr)
return NULL;
jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass);
if (!jattr) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: failed to allocate object");
return NULL;
}
env->SetLongField(jattr, JavaDOMGlobals::nodePtrFID, (jlong) attr);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Element.getAttributeNode: failed to set node ptr");
return NULL;
}
attr->AddRef();
return jattr;
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getElementsByTagName
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/NodeList;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getElementsByTagName
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: NULL pointer");
return NULL;
}
jboolean iscopy;
const jchar* cname = env->GetStringChars(jname, &iscopy);
if (!cname) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: GetStringChars failed");
env->ReleaseStringChars(jname, cname);
return NULL;
}
nsIDOMNodeList* nodes = nsnull;
nsresult rv = element->GetElementsByTagName((PRUnichar*)cname, &nodes);
env->ReleaseStringChars(jname, cname);
if (NS_FAILED(rv) || !nodes) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: failed", rv);
return NULL;
}
jobject jnodes = env->AllocObject(JavaDOMGlobals::nodeListClass);
if (!jnodes) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: failed to allocate object");
return NULL;
}
env->SetLongField(jnodes, JavaDOMGlobals::nodeListPtrFID, (jlong) nodes);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Element.getElementsByTagName: failed to set node ptr");
return NULL;
}
nodes->AddRef();
return jnodes;
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getTagName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getTagName
(JNIEnv *env, jobject jthis)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element) {
JavaDOMGlobals::ThrowException(env,
"Element.getTagName: NULL pointer");
return NULL;
}
nsString tagName;
nsresult rv = element->GetTagName(tagName);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Element.getTagName: failed", rv);
return NULL;
}
jstring jTagName = env->NewString(tagName.GetUnicode(), tagName.Length());
if (!jTagName) {
JavaDOMGlobals::ThrowException(env,
"Element.getTagName: NewString failed");
return NULL;
}
return jTagName;
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: normalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_normalize
(JNIEnv *env, jobject jthis)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element) {
JavaDOMGlobals::ThrowException(env,
"Element.normalize: NULL pointer");
return;
}
nsresult rv = element->Normalize();
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Element.normalize: failed", rv);
return;
}
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: removeAttribute
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_removeAttribute
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !jname) {
JavaDOMGlobals::ThrowException(env,
"Element.removeAttribute: NULL pointer");
return;
}
jboolean iscopy;
const jchar* name = env->GetStringChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Element.removeAttribute: GetStringChars failed");
env->ReleaseStringChars(jname, name);
return;
}
nsresult rv = element->RemoveAttribute((PRUnichar*)name);
env->ReleaseStringChars(jname, name);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Element.removeAttribute: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: removeAttributeNode
* Signature: (Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_removeAttributeNode
(JNIEnv *env, jobject jthis, jobject joldAttr)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !joldAttr) {
JavaDOMGlobals::ThrowException(env,
"Element.removeAttributeNode: NULL pointer");
return NULL;
}
nsIDOMAttr* oldAttr = (nsIDOMAttr*)
env->GetLongField(joldAttr, JavaDOMGlobals::nodePtrFID);
if (!oldAttr) {
JavaDOMGlobals::ThrowException(env,
"Element.removeAttributeNode: NULL arg pointer");
return NULL;
}
nsIDOMAttr* ret = nsnull;
nsresult rv = element->RemoveAttributeNode(oldAttr, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_NOT_FOUND_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Element.removeAttributeNode: failed", rv, exceptionType);
return NULL;
}
jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass);
if (!jattr) {
JavaDOMGlobals::ThrowException(env,
"Element.removeAttributeNode: failed to allocate object");
return NULL;
}
env->SetLongField(jattr, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Element.removeAttributeNode: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jattr;
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: setAttribute
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute
(JNIEnv *env, jobject jthis, jstring jname, jstring jvalue)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !jname || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: NULL pointer");
return;
}
jboolean iscopy;
const jchar* name = env->GetStringChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringChars name failed");
env->ReleaseStringChars(jname, name);
return;
}
jboolean iscopy2;
const jchar* value = env->GetStringChars(jvalue, &iscopy2);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: GetStringChars name failed");
env->ReleaseStringChars(jvalue, value);
env->ReleaseStringChars(jname, name);
return;
}
nsresult rv = element->SetAttribute((PRUnichar*)name, (PRUnichar*)value);
env->ReleaseStringChars(jvalue, value);
env->ReleaseStringChars(jname, name);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_INVALID_CHARACTER_ERR ||
rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Element.setAttribute: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_ElementImpl
* Method: setAttributeNode
* Signature: (Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_setAttributeNode
(JNIEnv *env, jobject jthis, jobject jnewAttr)
{
nsIDOMElement* element = (nsIDOMElement*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!element || !jnewAttr) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttributeNode: NULL pointer");
return NULL;
}
nsIDOMAttr* newAttr = (nsIDOMAttr*)
env->GetLongField(jnewAttr, JavaDOMGlobals::nodePtrFID);
if (!newAttr) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttributeNode: NULL arg pointer");
return NULL;
}
nsIDOMAttr* ret = nsnull;
nsresult rv = element->SetAttributeNode(newAttr, &ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_WRONG_DOCUMENT_ERR ||
rv == NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Element.setAttributeNode: failed", rv, exceptionType);
return NULL;
}
if (!ret)
return NULL;
jobject jattr = env->AllocObject(JavaDOMGlobals::attrClass);
if (!jattr) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttributeNode: failed to allocate object");
return NULL;
}
env->SetLongField(jattr, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Element.setAttributeNode: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jattr;
}

View File

@@ -1,86 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_ElementImpl */
#ifndef _Included_org_mozilla_dom_ElementImpl
#define _Included_org_mozilla_dom_ElementImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getAttribute
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getAttribute
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getAttributeNode
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getAttributeNode
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getElementsByTagName
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/NodeList;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_getElementsByTagName
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: getTagName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ElementImpl_getTagName
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: normalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_normalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: removeAttribute
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_removeAttribute
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: removeAttributeNode
* Signature: (Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_removeAttributeNode
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: setAttribute
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ElementImpl_setAttribute
(JNIEnv *, jobject, jstring, jstring);
/*
* Class: org_mozilla_dom_ElementImpl
* Method: setAttributeNode
* Signature: (Lorg/w3c/dom/Attr;)Lorg/w3c/dom/Attr;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_ElementImpl_setAttributeNode
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,128 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMEntity.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_EntityImpl.h"
/*
* Class: org_mozilla_dom_EntityImpl
* Method: getNotationName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_EntityImpl_getNotationName
(JNIEnv *env, jobject jthis)
{
nsIDOMEntity* entity = (nsIDOMEntity*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!entity) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Entity.getNotationName: NULL pointer\n"));
return NULL;
}
nsString ret;
nsresult rv = entity->GetNotationName(ret);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getNotationName: failed (%x)\n", rv));
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getNotationName: NewString failed\n"));
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_EntityImpl
* Method: getPublicId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_EntityImpl_getPublicId
(JNIEnv *env, jobject jthis)
{
nsIDOMEntity* entity = (nsIDOMEntity*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!entity) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Entity.getPublicId: NULL pointer\n"));
return NULL;
}
nsString ret;
nsresult rv = entity->GetPublicId(ret);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getPublicId: failed (%x)\n", rv));
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getPublicId: NewString failed\n"));
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_EntityImpl
* Method: getSystemId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_EntityImpl_getSystemId
(JNIEnv *env, jobject jthis)
{
nsIDOMEntity* entity = (nsIDOMEntity*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!entity) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Entity.getSystemId: NULL pointer\n"));
return NULL;
}
nsString ret;
nsresult rv = entity->GetSystemId(ret);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getSystemId: failed (%x)\n", rv));
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getSystemId: NewString failed\n"));
return NULL;
}
return jret;
}

View File

@@ -1,38 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_EntityImpl */
#ifndef _Included_org_mozilla_dom_EntityImpl
#define _Included_org_mozilla_dom_EntityImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_EntityImpl
* Method: getNotationName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_EntityImpl_getNotationName
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_EntityImpl
* Method: getPublicId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_EntityImpl_getPublicId
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_EntityImpl
* Method: getSystemId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_EntityImpl_getSystemId
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,217 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMNode.h"
#include "javaDOMGlobals.h"
#include "nsDOMError.h"
#include "org_mozilla_dom_NamedNodeMapImpl.h"
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_getLength
(JNIEnv *env, jobject jthis)
{
nsIDOMNamedNodeMap* map = (nsIDOMNamedNodeMap*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!map) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.getLength: NULL pointer");
return 0;
}
PRUint32 length = 0;
nsresult rv = map->GetLength(&length);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.getLength: failed", rv);
return 0;
}
return (jint) length;
}
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: getNamedItem
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_getNamedItem
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMNamedNodeMap* map = (nsIDOMNamedNodeMap*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!map || !jname) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.getNamedItem: NULL pointer");
return NULL;
}
nsIDOMNode* node = nsnull;
jboolean iscopy;
const jchar* name = env->GetStringChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.getNamedItem: GetStringChars failed");
env->ReleaseStringChars(jname, name);
return NULL;
}
nsresult rv = map->GetNamedItem((PRUnichar*)name, &node);
env->ReleaseStringChars(jname, name);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.getNamedItem: failed", rv);
return NULL;
}
if (!node)
return NULL;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: item
* Signature: (I)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_item
(JNIEnv *env, jobject jthis, jint jindex)
{
if (jindex < 0 || jindex > JavaDOMGlobals::javaMaxInt) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NamedNodeMap.item: invalid index value (%d)\n", jindex));
return NULL;
}
nsIDOMNamedNodeMap* map = (nsIDOMNamedNodeMap*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!map) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.item: NULL pointer");
return NULL;
}
nsIDOMNode* node = nsnull;
nsresult rv = map->Item((PRUint32) jindex, &node);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.item: failed", rv);
return NULL;
}
if (!node)
return NULL;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: removeNamedItem
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_removeNamedItem
(JNIEnv *env, jobject jthis, jstring jname)
{
nsIDOMNamedNodeMap* map = (nsIDOMNamedNodeMap*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!map || !jname) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.removeNamedItem: NULL pointer");
return NULL;
}
nsIDOMNode* node = nsnull;
jboolean iscopy;
const jchar* name = env->GetStringChars(jname, &iscopy);
if (!name) {
JavaDOMGlobals::ThrowException(env,
"NamedNodeMap.removeNamedItem: GetStringChars failed");
env->ReleaseStringChars(jname, name);
return NULL;
}
nsresult rv = map->RemoveNamedItem((PRUnichar*)name, &node);
env->ReleaseStringChars(jname, name);
if (NS_FAILED(rv) || !node) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NOT_FOUND_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"NodeMap.removeNamedItem: failed", rv, exceptionType);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: setNamedItem
* Signature: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_setNamedItem
(JNIEnv *env, jobject jthis, jobject jarg)
{
nsIDOMNamedNodeMap* map = (nsIDOMNamedNodeMap*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!map || !jarg) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.setNamedItem: NULL pointer");
return NULL;
}
nsIDOMNode* arg = (nsIDOMNode*)
env->GetLongField(jarg, JavaDOMGlobals::nodePtrFID);
if (!arg) {
JavaDOMGlobals::ThrowException(env,
"NodeMap.setNamedItem: NULL item pointer");
return NULL;
}
nsIDOMNode* node = nsnull;
nsresult rv = map->SetNamedItem(arg, &node);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_WRONG_DOCUMENT_ERR ||
rv == NS_ERROR_DOM_INUSE_ATTRIBUTE_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"NodeMap.setNamedItem: failed", rv, exceptionType);
return NULL;
}
if (!node)
return NULL;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}

View File

@@ -1,54 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_NamedNodeMapImpl */
#ifndef _Included_org_mozilla_dom_NamedNodeMapImpl
#define _Included_org_mozilla_dom_NamedNodeMapImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_getLength
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: getNamedItem
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_getNamedItem
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: item
* Signature: (I)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_item
(JNIEnv *, jobject, jint);
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: removeNamedItem
* Signature: (Ljava/lang/String;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_removeNamedItem
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_dom_NamedNodeMapImpl
* Method: setNamedItem
* Signature: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NamedNodeMapImpl_setNamedItem
(JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,950 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsIDOMDocument.h"
#include "nsDOMError.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_NodeImpl.h"
#include "nativeDOMProxyListener.h"
#include "nsIDOMEventTarget.h"
#include "javaDOMEventsGlobals.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIDOMEventTargetIID, NS_IDOMEVENTTARGET_IID);
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1equals
(JNIEnv *env, jobject jthis, jobject nodeArg)
{
jboolean b_retFlag = JNI_FALSE;
if (!nodeArg)
return b_retFlag;
nsIDOMNode* p_thisNode =
(nsIDOMNode*) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!p_thisNode) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Node.equals: NULL pointer\n"));
return b_retFlag;
}
nsIDOMNode* p_argNode =
(nsIDOMNode*) env->GetLongField(nodeArg, JavaDOMGlobals::nodePtrFID);
if (!p_argNode) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Node.equals: NULL arg pointer\n"));
return b_retFlag;
}
nsISupports* thisSupports = nsnull;
nsISupports* argNodeSupports = nsnull;
nsresult rvThis =
p_thisNode->QueryInterface(kISupportsIID, (void**)(&thisSupports));
if (NS_FAILED(rvThis) || !thisSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Node.equals: this->QueryInterface failed (%x)\n", rvThis));
return b_retFlag;
}
nsresult rvArgNode =
p_argNode->QueryInterface(kISupportsIID, (void**)(&argNodeSupports));
if (NS_FAILED(rvArgNode) || !argNodeSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Node.equals: arg->QueryInterface failed (%x)\n", rvArgNode));
thisSupports->Release();
return b_retFlag;
}
if (thisSupports == argNodeSupports)
b_retFlag = JNI_TRUE;
thisSupports->Release();
argNodeSupports->Release();
return b_retFlag;
}
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1hashCode
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* p_thisNode =
(nsIDOMNode*) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!p_thisNode) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Node.hashCode: NULL pointer\n"));
return (jint) 0;
}
nsISupports* thisSupports = nsnull;
nsresult rvThis =
p_thisNode->QueryInterface(kISupportsIID, (void**)(&thisSupports));
if (NS_FAILED(rvThis) || !thisSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Node.hashCode: QueryInterface failed (%x)\n", rvThis));
return (jint) 0;
}
thisSupports->Release();
return (jint) thisSupports;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_finalize
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Node.finalize: NULL pointer\n"));
return;
}
JavaDOMGlobals::AddToGarbage(node);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: appendChild
* Signature: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_appendChild
(JNIEnv *env, jobject jthis, jobject jchild)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node || !jchild) {
JavaDOMGlobals::ThrowException(env,
"Node.appendChild: NULL pointer");
return NULL;
}
nsIDOMNode* child = (nsIDOMNode*)
env->GetLongField(jchild, JavaDOMGlobals::nodePtrFID);
if (!child) {
JavaDOMGlobals::ThrowException(env,
"Node.appendChild: NULL child pointer");
return NULL;
}
nsIDOMNode* ret = nsnull;
nsresult rv = node->AppendChild(child, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_WRONG_DOCUMENT_ERR ||
rv == NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Node.appendChild: failed", rv, exceptionType);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: cloneNode
* Signature: (Z)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_cloneNode
(JNIEnv *env, jobject jthis, jboolean jdeep)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
JavaDOMGlobals::ThrowException(env,
"Node.cloneNode: NULL pointer");
return NULL;
}
nsIDOMNode* ret = nsnull;
PRBool deep = jdeep == JNI_TRUE ? PR_TRUE : PR_FALSE;
nsresult rv = node->CloneNode(deep, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ThrowException(env,
"Node.cloneNode: failed", rv);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getAttributes
* Signature: ()Lorg/w3c/dom/NamedNodeMap;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getAttributes
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMNamedNodeMap* nodeMap = nsnull;
nsresult rv = node->GetAttributes(&nodeMap);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getAttributes: failed", rv);
return NULL;
}
if (!nodeMap) {
/* according to the spec, getAttributes may return NULL when there
are no attributes. So this is not an error */
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::namedNodeMapClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Node.getAttributes: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) nodeMap);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Node.getAttributes: failed to set node ptr");
return NULL;
}
nodeMap->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getChildNodes
* Signature: ()Lorg/w3c/dom/NodeList;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getChildNodes
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
JavaDOMGlobals::ThrowException(env,
"Node.getChildNodes: NULL pointer");
return NULL;
}
nsIDOMNodeList* nodeList = nsnull;
nsresult rv = node->GetChildNodes(&nodeList);
if (NS_FAILED(rv) || !nodeList) {
JavaDOMGlobals::ThrowException(env,
"Node.getChildNodes: failed", rv);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::nodeListClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Node.getChildNodes: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodeListPtrFID, (jlong) nodeList);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Node.getChildNodes: failed to set node ptr");
return NULL;
}
nodeList->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getFirstChild
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getFirstChild
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetFirstChild(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getFirstChild: failed", rv);
return NULL;
}
if (!ret) {
/* according to the spec, getFirstChild may return NULL when there
are no children. So this is not an error */
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getLastChild
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getLastChild
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetLastChild(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getLastChild: failed", rv);
return NULL;
}
if (!ret) {
/* according to the spec, getLastChild may return NULL when there
are no children. So this is not an error */
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNextSibling
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getNextSibling
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetNextSibling(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getNextSibling: failed", rv);
return NULL;
}
if (!ret)
return NULL;
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNodeName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NodeImpl_getNodeName
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeName: NULL pointer");
return NULL;
}
nsString ret;
nsresult rv = node->GetNodeName(ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeName: failed", rv);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeName: NewString failed");
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNodeType
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_NodeImpl_getNodeType
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeType: NULL pointer");
return (jshort) NULL;
}
PRUint16 type;
nsresult rv = node->GetNodeType(&type);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeType: failed", rv);
return (jshort) NULL;
}
jfieldID typeFID = NULL;
switch (type) {
case nsIDOMNode::ATTRIBUTE_NODE:
typeFID = JavaDOMGlobals::nodeTypeAttributeFID;
break;
case nsIDOMNode::CDATA_SECTION_NODE:
typeFID = JavaDOMGlobals::nodeTypeCDataSectionFID;
break;
case nsIDOMNode::COMMENT_NODE:
typeFID = JavaDOMGlobals::nodeTypeCommentFID;
break;
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
typeFID = JavaDOMGlobals::nodeTypeDocumentFragmentFID;
break;
case nsIDOMNode::DOCUMENT_NODE:
typeFID = JavaDOMGlobals::nodeTypeDocumentFID;
break;
case nsIDOMNode::DOCUMENT_TYPE_NODE:
typeFID = JavaDOMGlobals::nodeTypeDocumentTypeFID;
break;
case nsIDOMNode::ELEMENT_NODE:
typeFID = JavaDOMGlobals::nodeTypeElementFID;
break;
case nsIDOMNode::ENTITY_NODE:
typeFID = JavaDOMGlobals::nodeTypeEntityFID;
break;
case nsIDOMNode::ENTITY_REFERENCE_NODE:
typeFID = JavaDOMGlobals::nodeTypeEntityReferenceFID;
break;
case nsIDOMNode::NOTATION_NODE:
typeFID = JavaDOMGlobals::nodeTypeNotationFID;
break;
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
typeFID = JavaDOMGlobals::nodeTypeProcessingInstructionFID;
break;
case nsIDOMNode::TEXT_NODE:
typeFID = JavaDOMGlobals::nodeTypeTextFID;
break;
}
jshort ret = 0;
if (typeFID) {
jclass nodeClass = env->GetObjectClass(jthis);
if (!nodeClass) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeType: GetObjectClass failed");
return ret;
}
ret = env->GetStaticShortField(nodeClass, typeFID);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeType: typeFID failed");
return ret;
}
} else {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeType: illegal type");
}
return ret;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNodeValue
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NodeImpl_getNodeValue
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsString ret;
nsresult rv = node->GetNodeValue(ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_DOMSTRING_SIZE_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Node.getNodeValue: failed", rv, exceptionType);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Node.getNodeValue: NewString failed");
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getOwnerDocument
* Signature: ()Lorg/w3c/dom/Document;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getOwnerDocument
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMDocument* ret = nsnull;
nsresult rv = node->GetOwnerDocument(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getOwnerDocument: failed", rv);
return NULL;
}
if (!ret)
return NULL;
jobject jret = env->AllocObject(JavaDOMGlobals::documentClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Node.getOwnerDocument: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Node.getOwnerDocument: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getParentNode
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getParentNode
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetParentNode(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getParentNode: failed", rv);
return NULL;
}
if (!ret)
return NULL;
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getPreviousSibling
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getPreviousSibling
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node)
return NULL;
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetPreviousSibling(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.getPreviousSibling: failed", rv);
return NULL;
}
if (!ret) {
/* according to the spec, getLastChild may return NULL when there
are no children. So this is not an error */
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: hasChildNodes
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_hasChildNodes
(JNIEnv *env, jobject jthis)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node) {
JavaDOMGlobals::ThrowException(env,
"Node.hasChildNodes: NULL pointer");
return (jboolean) NULL;
}
PRBool ret = PR_FALSE;
nsresult rv = node->HasChildNodes(&ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Node.hasChildNodes: failed", rv);
return (jboolean) NULL;
}
return ret == PR_TRUE ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: insertBefore
* Signature: (Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_insertBefore
(JNIEnv *env, jobject jthis, jobject jnewChild, jobject jrefChild)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node || !jnewChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL pointer");
return NULL;
}
nsIDOMNode* newChild = (nsIDOMNode*)
env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);
if (!newChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL newChild pointer");
return NULL;
}
nsIDOMNode* refChild = NULL;
if (jrefChild) {
refChild = (nsIDOMNode*)
env->GetLongField(jrefChild, JavaDOMGlobals::nodePtrFID);
if (!refChild) {
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: NULL refChild pointer");
return NULL;
}
}
nsIDOMNode* ret = nsnull;
nsresult rv = node->InsertBefore(newChild, refChild, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_WRONG_DOCUMENT_ERR ||
rv == NS_ERROR_DOM_NOT_FOUND_ERR ||
rv == NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Node.insertBefore: failed", rv, exceptionType);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: removeChild
* Signature: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_removeChild
(JNIEnv *env, jobject jthis, jobject joldChild)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node || !joldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.removeChild: NULL pointer");
return NULL;
}
nsIDOMNode* oldChild = (nsIDOMNode*)
env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);
if (!oldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.removeChild: NULL oldChild pointer");
return NULL;
}
nsIDOMNode* ret = nsnull;
nsresult rv = node->RemoveChild(oldChild, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_NOT_FOUND_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Node.removeChild: failed", rv, exceptionType);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: replaceChild
* Signature: (Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_replaceChild
(JNIEnv *env, jobject jthis, jobject jnewChild, jobject joldChild)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node || !jnewChild || !joldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL pointer");
return NULL;
}
nsIDOMNode* newChild = (nsIDOMNode*)
env->GetLongField(jnewChild, JavaDOMGlobals::nodePtrFID);
if (!newChild) {
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL newChild pointer");
return NULL;
}
nsIDOMNode* oldChild = (nsIDOMNode*)
env->GetLongField(joldChild, JavaDOMGlobals::nodePtrFID);
if (!oldChild) {
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: NULL oldChild pointer");
return NULL;
}
nsIDOMNode* ret = nsnull;
nsresult rv = node->ReplaceChild(newChild, oldChild, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_WRONG_DOCUMENT_ERR ||
rv == NS_ERROR_DOM_HIERARCHY_REQUEST_ERR ||
rv == NS_ERROR_DOM_NOT_FOUND_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Node.replaceChild: failed", rv, exceptionType);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: setNodeValue
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue
(JNIEnv *env, jobject jthis, jstring jvalue)
{
nsIDOMNode* node = (nsIDOMNode*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!node || !jvalue) {
JavaDOMGlobals::ThrowException(env,
"Node.setNodeValue: NULL pointer");
return;
}
jboolean iscopy;
const jchar* value = env->GetStringChars(jvalue, &iscopy);
if (!value) {
JavaDOMGlobals::ThrowException(env,
"Node.setNodeValue: GetStringChars failed");
env->ReleaseStringChars(jvalue, value);
return;
}
nsresult rv = node->SetNodeValue((PRUnichar*)value);
env->ReleaseStringChars(jvalue, value);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Node.setNodeValue: failed", rv, exceptionType);
return;
}
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: addNativeEventListener
* Signature: (Ljava/lang/String;Lorg/w3c/dom/events/EventListener;Z)J
*/
JNIEXPORT jlong JNICALL Java_org_mozilla_dom_NodeImpl_addNativeEventListener
(JNIEnv *env, jobject jthis, jstring jtype, jobject jlistener, jboolean juseCapture)
{
nsIDOMEventListener *listener = NULL;
PRBool useCapture;
nsISupports *isupports;
nsIDOMEventTarget* target;
isupports = (nsISupports *) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if(!isupports) {
JavaDOMGlobals::ThrowException(env,
"EventTarget.addEventListener: NULL pointer");
return 0;
}
isupports->QueryInterface(kIDOMEventTargetIID, (void **) &target);
if(!target) {
JavaDOMGlobals::ThrowException(env,
"EventTarget.addEventListener: NULL DOMEventTarget pointer");
return 0;
}
jboolean iscopy;
const jchar* type = env->GetStringChars(jtype, &iscopy);
if (!type) {
JavaDOMGlobals::ThrowException(env,
"EventTarget.addEventListener: GetStringChars failed\n");
env->ReleaseStringChars(jtype, type);
return 0;
}
useCapture = juseCapture == JNI_TRUE ? PR_TRUE : PR_FALSE;
listener = new NativeDOMProxyListener(env, jlistener);
nsresult rv = target->AddEventListener((PRUnichar*)type, listener, useCapture);
target->Release();
env->ReleaseStringChars(jtype, type);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"EventTarget.addEventListener: error");
return 0;
}
return (jlong) listener;
}
/*
* Class: org_mozilla_dom_NodeImpl
* Method: removeNativeEventListener
* Signature: (Ljava/lang/String;JZ)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_removeNativeEventListener
(JNIEnv *env, jobject jthis, jstring jtype, jlong jlistener, jboolean juseCapture)
{
PRBool useCapture;
nsISupports *isupports;
nsIDOMEventTarget* target;
isupports = (nsISupports *) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!isupports) {
JavaDOMGlobals::ThrowException(env,
"NodeImpl.removeEventListener: NULL pointer\n");
return;
}
isupports->QueryInterface(kIDOMEventTargetIID, (void **) &target);
if (!target) {
JavaDOMGlobals::ThrowException(env,
"NodeImpl.removeEventListener: NULL DOMEventTarget pointer\n");
return;
}
jboolean iscopy;
const jchar* type = env->GetStringChars(jtype, &iscopy);
if (!type) {
JavaDOMGlobals::ThrowException(env,
"NodeImpl.removeEventListener: GetStringChars failed\n");
env->ReleaseStringChars(jtype, type);
return;
}
useCapture = juseCapture == JNI_TRUE ? PR_TRUE : PR_FALSE;
nsresult rv = target->RemoveEventListener((PRUnichar*)type,
(nsIDOMEventListener*) jlistener, useCapture);
target->Release();
env->ReleaseStringChars(jtype, type);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"EventTarget.addEventListener: error");
return;
}
}

View File

@@ -1,197 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_NodeImpl */
#ifndef _Included_org_mozilla_dom_NodeImpl
#define _Included_org_mozilla_dom_NodeImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_NodeImpl
* Method: XPCOM_equals
* Signature: (Ljava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1equals
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: XPCOM_hashCode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1hashCode
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: addNativeEventListener
* Signature: (Ljava/lang/String;Lorg/w3c/dom/events/EventListener;Z)J
*/
JNIEXPORT jlong JNICALL Java_org_mozilla_dom_NodeImpl_addNativeEventListener
(JNIEnv *, jobject, jstring, jobject, jboolean);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: appendChild
* Signature: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_appendChild
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: cloneNode
* Signature: (Z)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_cloneNode
(JNIEnv *, jobject, jboolean);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_finalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getAttributes
* Signature: ()Lorg/w3c/dom/NamedNodeMap;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getAttributes
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getChildNodes
* Signature: ()Lorg/w3c/dom/NodeList;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getChildNodes
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getFirstChild
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getFirstChild
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getLastChild
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getLastChild
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNextSibling
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getNextSibling
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNodeName
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NodeImpl_getNodeName
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNodeType
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_NodeImpl_getNodeType
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getNodeValue
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NodeImpl_getNodeValue
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getOwnerDocument
* Signature: ()Lorg/w3c/dom/Document;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getOwnerDocument
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getParentNode
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getParentNode
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: getPreviousSibling
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getPreviousSibling
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: hasChildNodes
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_hasChildNodes
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: insertBefore
* Signature: (Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_insertBefore
(JNIEnv *, jobject, jobject, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: removeChild
* Signature: (Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_removeChild
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: removeNativeEventListener
* Signature: (Ljava/lang/String;JZ)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_removeNativeEventListener
(JNIEnv *, jobject, jstring, jlong, jboolean);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: replaceChild
* Signature: (Lorg/w3c/dom/Node;Lorg/w3c/dom/Node;)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_replaceChild
(JNIEnv *, jobject, jobject, jobject);
/*
* Class: org_mozilla_dom_NodeImpl
* Method: setNodeValue
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,192 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_NodeListImpl.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: XPCOM_equals
* Signature: (Ljava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1equals
(JNIEnv *env, jobject jthis, jobject jarg)
{
jboolean b_retFlag = JNI_FALSE;
nsIDOMNodeList* p_this =
(nsIDOMNodeList*) env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
if (!p_this) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NodeList.equals: NULL pointer\n"));
return b_retFlag;
}
nsIDOMNodeList* p_arg =
(nsIDOMNodeList*) env->GetLongField(jarg, JavaDOMGlobals::nodeListPtrFID);
if (!p_arg) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NodeList.equals: NULL arg pointer\n"));
return b_retFlag;
}
nsISupports* thisSupports = nsnull;
nsISupports* argSupports = nsnull;
nsresult rvThis =
p_this->QueryInterface(kISupportsIID, (void**)(&thisSupports));
if (NS_FAILED(rvThis) || !thisSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NodeList.equals: this->QueryInterface failed (%x)\n", rvThis));
return b_retFlag;
}
nsresult rvArg =
p_arg->QueryInterface(kISupportsIID, (void**)(&argSupports));
if (NS_FAILED(rvArg) || !argSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NodeList.equals: arg->QueryInterface failed (%x)\n", rvArg));
thisSupports->Release();
return b_retFlag;
}
if (thisSupports == argSupports)
b_retFlag = JNI_TRUE;
thisSupports->Release();
argSupports->Release();
return b_retFlag;
}
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: XPCOM_hashCode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1hashCode
(JNIEnv *env, jobject jthis)
{
nsIDOMNodeList* p_this =
(nsIDOMNodeList*) env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
if (!p_this) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NodeList.hashCode: NULL pointer\n"));
return (jint) 0;
}
nsISupports* thisSupports = nsnull;
nsresult rvThis =
p_this->QueryInterface(kISupportsIID, (void**)(&thisSupports));
if (NS_FAILED(rvThis) || !thisSupports) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NodeList.hashCode: QueryInterface failed (%x)\n", rvThis));
return (jint) 0;
}
thisSupports->Release();
return (jint) thisSupports;
}
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeListImpl_finalize
(JNIEnv *env, jobject jthis)
{
nsIDOMNodeList* nodes = (nsIDOMNodeList*)
env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
if (!nodes) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NodeList.finalize: NULL pointer\n"));
return;
}
JavaDOMGlobals::AddToGarbage(nodes);
}
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_getLength
(JNIEnv *env, jobject jthis)
{
nsIDOMNodeList* nodes = (nsIDOMNodeList*)
env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
if (!nodes) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NodeList.getLength: NULL pointer\n"));
return 0;
}
PRUint32 length = 0;
nsresult rv = nodes->GetLength(&length);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NodeList.getLength: failed (%x)\n", rv));
return 0;
}
return (jint) length;
}
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: item
* Signature: (I)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeListImpl_item
(JNIEnv *env, jobject jthis, jint jindex)
{
if (jindex < 0 || jindex > JavaDOMGlobals::javaMaxInt) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NodeList.item: invalid index value (%d)\n", jindex));
return NULL;
}
nsIDOMNodeList* nodes = (nsIDOMNodeList*)
env->GetLongField(jthis, JavaDOMGlobals::nodeListPtrFID);
if (!nodes) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("NodeList.item: NULL pointer\n"));
return NULL;
}
nsIDOMNode* node = NULL;
nsresult rv = nodes->Item((PRUint32) jindex, &node);
if (NS_FAILED(rv) || !node) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("NodeList.item: failed (%x)\n", rv));
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}

View File

@@ -1,53 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_NodeListImpl */
#ifndef _Included_org_mozilla_dom_NodeListImpl
#define _Included_org_mozilla_dom_NodeListImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: getLength
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_getLength
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: item
* Signature: (I)Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeListImpl_item
(JNIEnv *, jobject, jint);
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeListImpl_finalize
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: XPCOM_equals
* Signature: (Ljava/lang/Object;)Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1equals
(JNIEnv *, jobject, jobject);
/*
* Class: org_mozilla_dom_NodeListImpl
* Method: XPCOM_hashCode
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeListImpl_XPCOM_1hashCode
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,94 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMNotation.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_NotationImpl.h"
/*
* Class: org_mozilla_dom_NotationImpl
* Method: getPublicId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NotationImpl_getPublicId
(JNIEnv *env, jobject jthis)
{
nsIDOMNotation* notation = (nsIDOMNotation*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!notation) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Notation.getPublicId: NULL pointer\n"));
return NULL;
}
nsString ret;
nsresult rv = notation->GetPublicId(ret);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Notation.getPublicId: failed (%x)\n", rv));
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Notation.getPublicId: NewString failed\n"));
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_NotationImpl
* Method: getSystemId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NotationImpl_getSystemId
(JNIEnv *env, jobject jthis)
{
nsIDOMNotation* notation = (nsIDOMNotation*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!notation) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Notation.getSystemId: NULL pointer\n"));
return NULL;
}
nsString ret;
nsresult rv = notation->GetSystemId(ret);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Notation.getSystemId: failed (%x)\n", rv));
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Notation.getSystemId: NewString failed\n"));
return NULL;
}
return jret;
}

View File

@@ -1,30 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_NotationImpl */
#ifndef _Included_org_mozilla_dom_NotationImpl
#define _Included_org_mozilla_dom_NotationImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_NotationImpl
* Method: getPublicId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NotationImpl_getPublicId
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_NotationImpl
* Method: getSystemId
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_NotationImpl_getSystemId
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,134 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMProcessingInstruction.h"
#include "nsDOMError.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_ProcessingInstructionImpl.h"
/*
* Class: org_mozilla_dom_ProcessingInstructionImpl
* Method: getData
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_getData
(JNIEnv *env, jobject jthis)
{
nsIDOMProcessingInstruction* pi = (nsIDOMProcessingInstruction*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!pi) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getData: NULL pointer");
return NULL;
}
nsString ret;
nsresult rv = pi->GetData(ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getData: failed", rv);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getData: NewString failed");
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_ProcessingInstructionImpl
* Method: getTarget
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_getTarget
(JNIEnv *env, jobject jthis)
{
nsIDOMProcessingInstruction* pi = (nsIDOMProcessingInstruction*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!pi) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getTarget: NULL pointer");
return NULL;
}
nsString ret;
nsresult rv = pi->GetTarget(ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getTarget: failed", rv);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.getTarget: NewString failed");
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_ProcessingInstructionImpl
* Method: setData
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_setData
(JNIEnv *env, jobject jthis, jstring jdata)
{
nsIDOMProcessingInstruction* pi = (nsIDOMProcessingInstruction*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!pi || !jdata) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.setData: NULL pointer");
return;
}
jboolean iscopy;
const jchar* data = env->GetStringChars(jdata, &iscopy);
if (!data) {
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.setData: GetStringChars failed");
env->ReleaseStringChars(jdata, data);
return;
}
nsresult rv = pi->SetData((PRUnichar*)data);
env->ReleaseStringChars(jdata, data);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"ProcessingInstruction.setData: failed", rv, exceptionType);
return;
}
}

View File

@@ -1,38 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_ProcessingInstructionImpl */
#ifndef _Included_org_mozilla_dom_ProcessingInstructionImpl
#define _Included_org_mozilla_dom_ProcessingInstructionImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_ProcessingInstructionImpl
* Method: getData
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_getData
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_ProcessingInstructionImpl
* Method: getTarget
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_getTarget
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_ProcessingInstructionImpl
* Method: setData
* Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_ProcessingInstructionImpl_setData
(JNIEnv *, jobject, jstring);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,82 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMText.h"
#include "nsDOMError.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_TextImpl.h"
/*
* Class: org_mozilla_dom_TextImpl
* Method: splitText
* Signature: (I)Lorg/w3c/dom/Text;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_TextImpl_splitText
(JNIEnv *env, jobject jthis, jint joffset)
{
if (joffset < 0 || joffset > JavaDOMGlobals::javaMaxInt) {
JavaDOMGlobals::ThrowException(env, "Text.splitText: failed",
NS_ERROR_DOM_INDEX_SIZE_ERR,
JavaDOMGlobals::EXCEPTION_DOM);
return NULL;
}
nsIDOMText* text = (nsIDOMText*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!text) {
JavaDOMGlobals::ThrowException(env,
"Text.splitText: NULL pointer");
return NULL;
}
nsIDOMText* ret = nsnull;
nsresult rv = text->SplitText((PRUint32) joffset, &ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ExceptionType exceptionType = JavaDOMGlobals::EXCEPTION_RUNTIME;
if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_DOM &&
(rv == NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR ||
rv == NS_ERROR_DOM_INDEX_SIZE_ERR)) {
exceptionType = JavaDOMGlobals::EXCEPTION_DOM;
}
JavaDOMGlobals::ThrowException(env,
"Text.splitText: failed", rv, exceptionType);
return NULL;
}
jobject jret = env->AllocObject(JavaDOMGlobals::textClass);
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Text.splitText: failed to allocate object");
return NULL;
}
env->SetLongField(jret, JavaDOMGlobals::nodePtrFID, (jlong) ret);
if (env->ExceptionOccurred()) {
JavaDOMGlobals::ThrowException(env,
"Text.splitText: failed to set node ptr");
return NULL;
}
ret->AddRef();
return jret;
}

View File

@@ -1,22 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_TextImpl */
#ifndef _Included_org_mozilla_dom_TextImpl
#define _Included_org_mozilla_dom_TextImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_TextImpl
* Method: splitText
* Signature: (I)Lorg/w3c/dom/Text;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_TextImpl_splitText
(JNIEnv *, jobject, jint);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,327 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include"nsIDOMEvent.h"
#include"javaDOMEventsGlobals.h"
#include "org_mozilla_dom_events_EventImpl.h"
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getCurrentNode
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getCurrentNode
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.getCurrentNode: NULL pointer\n");
return NULL;
}
nsIDOMNode* ret = nsnull;
nsresult rv = event->GetCurrentNode(&ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ThrowException(env,
"Event.getCurrentNode: failed", rv);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getEventPhase
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.getEventPhase: NULL native pointer\n");
return 0;
}
PRUint16 eventPhase = 0;
nsresult rv = event->GetEventPhase(&eventPhase);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.getEventPhase: failed", rv);
return 0;
}
jfieldID phaseFID = NULL;
switch(eventPhase) {
case nsIDOMEvent::BUBBLING_PHASE:
phaseFID = JavaDOMEventsGlobals::eventPhaseBubblingFID;
break;
case nsIDOMEvent::CAPTURING_PHASE:
phaseFID = JavaDOMEventsGlobals::eventPhaseCapturingFID;
break;
case nsIDOMEvent::AT_TARGET:
phaseFID = JavaDOMEventsGlobals::eventPhaseAtTargetFID;
break;
}
jshort ret = 0;
if (phaseFID) {
ret = env->GetStaticShortField(JavaDOMEventsGlobals::eventClass, phaseFID);
if (env->ExceptionOccurred()) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Event.getEventPhase: slection of phaseFID failed\n"));
return ret;
}
} else {
JavaDOMGlobals::ThrowException(env,
"Event.getEventPhase: illegal phase");
}
return ret;
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getBubbles
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getBubbles
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.getBubbles: NULL pointer");
return JNI_FALSE;
}
PRBool canBubble = PR_FALSE;
nsresult rv = event->GetBubbles(&canBubble);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.getBubbles: failed", rv);
return JNI_FALSE;
}
return (canBubble == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getCancelable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getCancelable
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.getCancelable: NULL pointer");
return JNI_FALSE;
}
PRBool cancelable = PR_FALSE;
nsresult rv = event->GetCancelable(&cancelable);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.getCancelable: failed", rv);
return JNI_FALSE;
}
return (cancelable == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getTarget
* Signature: ()Lorg/w3c/dom/events/EventTarget;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getTarget
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.getTarget: NULL pointer");
return NULL;
}
nsIDOMNode* ret = nsnull;
nsresult rv = event->GetTarget(&ret);
if (NS_FAILED(rv) || !ret) {
JavaDOMGlobals::ThrowException(env,
"Event.getTarget: failed", rv);
return NULL;
}
return JavaDOMGlobals::CreateNodeSubtype(env, ret);
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_events_EventImpl_getType
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.getType: NULL pointer");
return NULL;
}
nsString ret;
nsresult rv = event->GetType(ret);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.getType: failed", rv);
return NULL;
}
jstring jret = env->NewString(ret.GetUnicode(), ret.Length());
if (!jret) {
JavaDOMGlobals::ThrowException(env,
"Event.getType: NewString failed");
return NULL;
}
return jret;
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: preventBubble
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventBubble
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.preventBubble: NULL pointer");
return;
}
nsresult rv = event->PreventBubble();
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.preventBubble: failed", rv);
}
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: preventCapture
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventCapture
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.preventCapture: NULL pointer");
return;
}
nsresult rv = event->PreventCapture();
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.preventCapture: failed", rv);
}
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: preventDefault
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventDefault
(JNIEnv *env, jobject jthis)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"Event.preventDefault: NULL pointer");
return;
}
nsresult rv = event->PreventDefault();
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"Event.preventDefault: failed", rv);
}
}
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: initEvent
* Signature: (Ljava/lang/String;ZZ)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_initEvent
(JNIEnv *env, jobject jthis, jstring jeventTypeArg, jboolean jcanBubbleArg, jboolean jcancelableArg)
{
nsIDOMEvent* event = (nsIDOMEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event || !jeventTypeArg) {
JavaDOMGlobals::ThrowException(env,
"Event.initEvent: NULL pointer");
return;
}
jboolean iscopy;
const jchar* cvalue = env->GetStringChars(jeventTypeArg, &iscopy);
if (!cvalue) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Event.initEvent: GetStringChars failed\n"));
env->ReleaseStringChars(jeventTypeArg, cvalue);
return;
}
PRBool canBubble = jcanBubbleArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
PRBool cancelable = jcancelableArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
nsresult rv = event->InitEvent((PRUnichar*)cvalue, canBubble, cancelable);
env->ReleaseStringChars(jeventTypeArg, cvalue);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Event.initEvent: failed (%x)\n", rv));
}
}

View File

@@ -1,93 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_events_EventImpl */
#ifndef _Included_org_mozilla_dom_events_EventImpl
#define _Included_org_mozilla_dom_events_EventImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getType
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_events_EventImpl_getType
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getTarget
* Signature: ()Lorg/w3c/dom/events/EventTarget;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getTarget
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getCurrentNode
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getCurrentNode
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getEventPhase
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getBubbles
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getBubbles
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: getCancelable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getCancelable
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: preventBubble
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventBubble
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: preventCapture
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventCapture
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: preventDefault
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventDefault
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_EventImpl
* Method: initEvent
* Signature: (Ljava/lang/String;ZZ)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_initEvent
(JNIEnv *, jobject, jstring, jboolean, jboolean);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,374 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
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.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#include "prlog.h"
#include "nsIDOMNode.h"
#include "nsIDOMMouseEvent.h"
#include "javaDOMEventsGlobals.h"
#include "org_mozilla_dom_events_MouseEventImpl.h"
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getAltKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getAltKey
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getAltKey: NULL pointer");
return JNI_FALSE;
}
PRBool altKey = PR_FALSE;
nsresult rv = event->GetAltKey(&altKey);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getAltKey: failed", rv);
return JNI_FALSE;
}
return (altKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getButton
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getButton: NULL pointer");
return 0;
}
PRUint16 code = 0;
nsresult rv = event->GetButton(&code);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getButton: failed", rv);
return 0;
}
return (jshort) code;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getClientX
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientX
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getClientX: NULL pointer");
return 0;
}
PRInt32 clientX = 0;
nsresult rv = event->GetClientX(&clientX);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getClientX: failed", rv);
return 0;
}
return (jint) clientX;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getClientY
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientY
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getClientY: NULL pointer");
return 0;
}
PRInt32 clientY = 0;
nsresult rv = event->GetClientY(&clientY);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getClientY: failed", rv);
return 0;
}
return (jint) clientY;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getCtrlKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getCtrlKey
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getCtrlKey: NULL pointer");
return JNI_FALSE;
}
PRBool ctrlKey = PR_FALSE;
nsresult rv = event->GetCtrlKey(&ctrlKey);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getCtrlKey: failed", rv);
return JNI_FALSE;
}
return (ctrlKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getMetaKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getMetaKey
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getMetaKey: NULL pointer");
return JNI_FALSE;
}
PRBool metaKey = PR_FALSE;
nsresult rv = event->GetMetaKey(&metaKey);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getMetaKey: failed", rv);
return JNI_FALSE;
}
return (metaKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getScreenX
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getScreenX: NULL pointer\n");
return 0;
}
PRInt32 screenX = 0;
nsresult rv = event->GetScreenX(&screenX);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getScreenX: failed", rv);
return 0;
}
return (jint) screenX;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getScreenY
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getScreenY: NULL pointer");
return 0;
}
PRInt32 screenY = 0;
nsresult rv = event->GetScreenY(&screenY);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getScreenY: failed", rv);
return 0;
}
return (jint) screenY;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getShiftKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKey
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getShiftKey: NULL pointer");
return JNI_FALSE;
}
PRBool shiftKey = PR_FALSE;
nsresult rv = event->GetShiftKey(&shiftKey);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getShiftKey: failed", rv);
return JNI_FALSE;
}
return (shiftKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getRelatedNode
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getRelatedNode
(JNIEnv *env, jobject jthis)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getRelatedNode: NULL pointer");
return NULL;
}
nsIDOMNode* node = nsnull;
nsresult rv = event->GetRelatedNode(&node);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.getRelatedNode: failed", rv);
return NULL;
}
if (!node)
return NULL;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: initMouseEvent
* Signature: (Ljava/lang/String;ZZLorg/w3c/dom/views/AbstractView;IIIIIZZZZSLorg/w3c/dom/Node;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_MouseEventImpl_initMouseEvent
(JNIEnv *env, jobject jthis,
jstring jtypeArg,
jboolean jcanBubbleArg,
jboolean jcancelableArg,
jobject jviewArg,
jint jdetailArg,
jint jscreenXArg,
jint jscreenYArg,
jint jclientXArg,
jint jclientYArg,
jboolean jctrlKeyArg,
jboolean jaltKeyArg,
jboolean jshiftKeyArg,
jboolean jmetaKeyArg,
jshort jbuttonArg,
jobject jrelatedNodeArg)
{
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
if (!event) {
JavaDOMGlobals::ThrowException(env,
"MouseEvent.initMouseEvent: NULL pointer");
return;
}
jboolean iscopy;
const jchar* cvalue = env->GetStringChars(jtypeArg, &iscopy);
if (!cvalue) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("UIEvent.initUIEvent: GetStringChars failed"));
env->ReleaseStringChars(jtypeArg, cvalue);
return;
}
PRBool canBubble = jcanBubbleArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
PRBool cancelable = jcancelableArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
PRBool ctrlKeyArg = jctrlKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
PRBool altKeyArg = jaltKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
PRBool shiftKeyArg = jshiftKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
PRBool metaKeyArg = jmetaKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
nsresult rv = event->InitMouseEvent((PRUnichar*)cvalue,
ctrlKeyArg,
altKeyArg,
shiftKeyArg,
metaKeyArg,
(PRInt32)jscreenXArg,
(PRInt32)jscreenYArg,
(PRInt32)jclientXArg,
(PRInt32)jclientYArg,
(PRUint16)jbuttonArg,
(PRUint16)jdetailArg);
env->ReleaseStringChars(jtypeArg, cvalue);
if (NS_FAILED(rv)) {
JavaDOMGlobals::ThrowException(env,
"UIEvent.initUIEvent: failed", rv);
}
}

View File

@@ -1,101 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_mozilla_dom_events_MouseEventImpl */
#ifndef _Included_org_mozilla_dom_events_MouseEventImpl
#define _Included_org_mozilla_dom_events_MouseEventImpl
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getScreenX
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getScreenY
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getClientX
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientX
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getClientY
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientY
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getCtrlKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getCtrlKey
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getShiftKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKey
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getAltKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getAltKey
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getMetaKey
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getMetaKey
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getButton
* Signature: ()S
*/
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: getRelatedNode
* Signature: ()Lorg/w3c/dom/Node;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getRelatedNode
(JNIEnv *, jobject);
/*
* Class: org_mozilla_dom_events_MouseEventImpl
* Method: initMouseEvent
* Signature: (Ljava/lang/String;ZZLorg/w3c/dom/views/AbstractView;IIIIIZZZZSLorg/w3c/dom/Node;)V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_MouseEventImpl_initMouseEvent
(JNIEnv *, jobject, jstring, jboolean, jboolean, jobject, jint, jint, jint, jint, jint, jboolean, jboolean, jboolean, jboolean, jshort, jobject);
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More