1. Keep up with interface change in nsIDocumentLoaderObserver.

2. Fix lots of bugs.
3. Implement Entities and Notations.
This commit is contained in:
akhil.arora%sun.com 1999-08-23 19:27:48 +00:00
parent 7e7bff3bf0
commit cb9bd6e536
17 changed files with 629 additions and 22 deletions

View File

@ -1,16 +1,55 @@
o Convert to using IDL and GenericFactories. Once support for
ComponentLoaders is implemented in xpcom, use that to load our
component.
[5d]
o Implement DOM exceptions.
[5d. In Progress. Denis Sharypov <sdv@sparc.spb.su>]
o Implement the equals() and hashCode() methods for all DOM
objects. The equals method is to be implemented by doing a
QueryInterface to nsISupports and them comparing pointers to the
native DOM objects.
objects. The equals method is to be implemented by doing a
QueryInterface to nsISupports and them comparing pointers to the
native DOM objects. Similarly, thye hashCode method should do a
QI to nsISupports and then return the pointer.
[2d. In progress, ttully@eng.sun.com]
o Use OJI to obtain the JVM.
[5d. Awaiting OJI availability]
o i18n the API
o Implement DOMEvents from the DOM Level 2 current working draft.
[4w. Assigned. Contact: Sergey Lunegov <lsv@sparc.spb.su>]
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 Eliminate finalize methds from classes that extend Node,
DOMImplementation and NodeList. finalize need only be defined for
these three base classes. Having it defined in the derived classes
is redundant, but not an error.
[1d]
o Go through the spec and for all methods that return null, fix the
api so that no error message is logged. The api works fine, it
just logs some bogus errors. For an example, see
Node.getAttributes.
[2d. 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).
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

@ -130,7 +130,10 @@ public class DOMFactory implements DocumentLoadListener {
/*
Node fc = node.getFirstChild();
if (fc != null)
System.out.println(fc);
System.out.println("firstchild=" + fc.toString());
Node lc = node.getLastChild();
if (lc != null)
System.out.println("lastchild=" + lc.toString());
*/
int length = children.getLength();

View File

@ -0,0 +1,31 @@
/*
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.
*/
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();
protected native void finalize();
}

View File

@ -32,12 +32,15 @@ CPPSRCS = \
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_ProcessingInstructionImpl.cpp \
org_mozilla_dom_TextImpl.cpp
# org_mozilla_dom_NotationImpl.cpp \
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

View File

@ -32,12 +32,15 @@ CPPSRCS = \
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_ProcessingInstructionImpl.cpp \
org_mozilla_dom_TextImpl.cpp
# org_mozilla_dom_NotationImpl.cpp \
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,30 @@
/*
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.
*/
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();
protected native void finalize();
}

View File

@ -33,7 +33,9 @@ jclass JavaDOMGlobals::entityReferenceClass = NULL;
jclass JavaDOMGlobals::namedNodeMapClass = NULL;
jclass JavaDOMGlobals::nodeClass = NULL;
jclass JavaDOMGlobals::nodeListClass = NULL;
#if 0
jclass JavaDOMGlobals::notationClass = NULL;
#endif
jclass JavaDOMGlobals::processingInstructionClass = NULL;
jclass JavaDOMGlobals::textClass = NULL;
@ -86,11 +88,26 @@ void JavaDOMGlobals::Initialize(JNIEnv *env)
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);
@ -109,6 +126,16 @@ void JavaDOMGlobals::Initialize(JNIEnv *env)
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);
@ -158,6 +185,23 @@ void JavaDOMGlobals::Initialize(JNIEnv *env)
nodeTypeTextFID =
env->GetStaticFieldID(nodeClass, "TEXT_NODE", "S");
if (!nodeTypeTextFID) return;
#if 0
notationClass = env->FindClass("org/mozilla/dom/NotationImpl");
if (!notationClass) return;
notationClass = (jclass) env->NewGlobalRef(notationClass);
if (!notationClass) return;
#endif
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;
}
void JavaDOMGlobals::Destroy(JNIEnv *env)
@ -171,20 +215,47 @@ void JavaDOMGlobals::Destroy(JNIEnv *env)
}
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",
attrClass));
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",
attrClass));
documentTypeClass));
return;
}
documentTypeClass = NULL;
@ -193,7 +264,7 @@ void JavaDOMGlobals::Destroy(JNIEnv *env)
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete DOMImplementation global ref %x\n",
attrClass));
domImplementationClass));
return;
}
domImplementationClass = NULL;
@ -202,16 +273,34 @@ void JavaDOMGlobals::Destroy(JNIEnv *env)
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Element global ref %x\n",
attrClass));
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",
attrClass));
namedNodeMapClass));
return;
}
namedNodeMapClass = NULL;
@ -220,7 +309,7 @@ void JavaDOMGlobals::Destroy(JNIEnv *env)
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete NodeList global ref %x\n",
attrClass));
nodeListClass));
return;
}
nodeListClass = NULL;
@ -229,11 +318,40 @@ void JavaDOMGlobals::Destroy(JNIEnv *env)
if (env->ExceptionOccurred()) {
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::Destroy: failed to delete Node global ref %x\n",
attrClass));
nodeClass));
return;
}
nodeClass = NULL;
#if 0
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;
#endif
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;
TakeOutGarbage();
PR_DestroyLock(garbageLock);
}
@ -270,6 +388,10 @@ jobject JavaDOMGlobals::CreateNodeSubtype(JNIEnv *env,
clazz = documentTypeClass;
break;
case nsIDOMNode::ELEMENT_NODE:
clazz = elementClass;
break;
case nsIDOMNode::ENTITY_NODE:
clazz = entityClass;
break;
@ -279,7 +401,11 @@ jobject JavaDOMGlobals::CreateNodeSubtype(JNIEnv *env,
break;
case nsIDOMNode::NOTATION_NODE:
PR_LOG(log, PR_LOG_ERROR,
("JavaDOMGlobals::CreateNodeSubtype: Unsupported: allocating Node of type Notation\n"));
#if 0
clazz = notationClass;
#endif
break;
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
@ -291,6 +417,9 @@ jobject JavaDOMGlobals::CreateNodeSubtype(JNIEnv *env,
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,

View File

@ -41,7 +41,9 @@ class JavaDOMGlobals {
static jclass namedNodeMapClass;
static jclass nodeClass;
static jclass nodeListClass;
#if 0
static jclass notationClass;
#endif
static jclass processingInstructionClass;
static jclass textClass;

View File

@ -30,6 +30,7 @@ CPPSRCS= \
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 \
@ -37,6 +38,8 @@ CPPSRCS= \
org_mozilla_dom_TextImpl.cpp \
$(NULL)
# org_mozilla_dom_NotationImpl.cpp \
CPP_OBJS= \
.\$(OBJDIR)\javaDOMGlobals.obj \
.\$(OBJDIR)\org_mozilla_dom_DOMAccessorImpl.obj \
@ -47,6 +50,7 @@ CPP_OBJS= \
.\$(OBJDIR)\org_mozilla_dom_DocumentTypeImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_DOMImplementationImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_ElementImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_EntityImpl.cpp \
.\$(OBJDIR)\org_mozilla_dom_NamedNodeMapImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_NodeImpl.obj \
.\$(OBJDIR)\org_mozilla_dom_NodeListImpl.obj \
@ -54,6 +58,8 @@ CPP_OBJS= \
.\$(OBJDIR)\org_mozilla_dom_TextImpl.obj \
$(NULL)
# .\$(OBJDIR)\org_mozilla_dom_NotationImpl.cpp \
LINCS=
MAKE_OBJ_TYPE = DLL

View File

@ -0,0 +1,147 @@
/*
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.
*/
#include "prlog.h"
#include "nsIDOMEntity.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_EntityImpl.h"
/*
* Class: org_mozilla_dom_EntityImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_EntityImpl_finalize
(JNIEnv *env, jobject jthis)
{
nsIDOMEntity* entity = (nsIDOMEntity*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!entity) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Entity.finalize: NULL pointer\n"));
return;
}
JavaDOMGlobals::AddToGarbage(entity);
}
/*
* 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;
}
char* cret = ret.ToNewCString();
jstring jret = env->NewStringUTF(cret);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getNotationName: NewStringUTF failed (%s)\n", cret));
return NULL;
}
delete[] cret;
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;
}
char* cret = ret.ToNewCString();
jstring jret = env->NewStringUTF(cret);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getPublicId: NewStringUTF failed (%s)\n", cret));
return NULL;
}
delete[] cret;
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;
}
char* cret = ret.ToNewCString();
jstring jret = env->NewStringUTF(cret);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Entity.getSystemId: NewStringUTF failed (%s)\n", cret));
return NULL;
}
delete[] cret;
return jret;
}

View File

@ -0,0 +1,45 @@
/* 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: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_EntityImpl_finalize
(JNIEnv *, jobject);
/*
* 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

@ -122,11 +122,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getAttributes
nsIDOMNamedNodeMap* nodeMap = nsnull;
nsresult rv = node->GetAttributes(&nodeMap);
if (NS_FAILED(rv) || !nodeMap) {
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Node.getAttributes: failed (%x)\n", 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) {
@ -206,11 +211,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getFirstChild
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetFirstChild(&ret);
if (NS_FAILED(rv) || !ret) {
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Node.getFirstChild: failed (%x)\n", 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);
}
@ -233,11 +243,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_getLastChild
nsIDOMNode* ret = nsnull;
nsresult rv = node->GetLastChild(&ret);
if (NS_FAILED(rv) || !ret) {
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Node.getLastChild: failed (%x)\n", 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);
}

View File

@ -0,0 +1,111 @@
/*
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.
*/
#include "prlog.h"
#include "nsIDOMNotation.h"
#include "javaDOMGlobals.h"
#include "org_mozilla_dom_NotationImpl.h"
/*
* Class: org_mozilla_dom_NotationImpl
* Method: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NotationImpl_finalize
(JNIEnv *env, jobject jthis)
{
nsIDOMNotation* notation = (nsIDOMNotation*)
env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID);
if (!notation) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING,
("Notation.finalize: NULL pointer\n"));
return;
}
JavaDOMGlobals::AddToGarbage(notation);
}
/*
* 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;
}
char* cret = ret.ToNewCString();
jstring jret = env->NewStringUTF(cret);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Notation.getPublicId: NewStringUTF failed (%s)\n", cret));
return NULL;
}
delete[] cret;
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;
}
char* cret = ret.ToNewCString();
jstring jret = env->NewStringUTF(cret);
if (!jret) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("Notation.getSystemId: NewStringUTF failed (%s)\n", cret));
return NULL;
}
delete[] cret;
return jret;
}

View File

@ -0,0 +1,37 @@
/* 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: finalize
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_NotationImpl_finalize
(JNIEnv *, jobject);
/*
* 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

@ -42,10 +42,11 @@ class nsIJavaDOM : public nsIDocumentLoaderObserver {
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus,
#else
nsIURI* aURL,
#endif
PRInt32 aStatus,
#endif
nsIDocumentLoaderObserver* aObserver) = 0;
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
@ -77,10 +78,11 @@ class nsIJavaDOM : public nsIDocumentLoaderObserver {
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus) = 0;
#else
nsIURI* aURL,
#endif
PRInt32 aStatus) = 0;
#endif
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
#ifdef NECKO

View File

@ -311,10 +311,11 @@ NS_IMETHODIMP nsJavaDOMImpl::OnStartDocumentLoad(nsIDocumentLoader* loader,
NS_IMETHODIMP nsJavaDOMImpl::OnEndDocumentLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus,
#else
nsIURI* aURL,
#endif
PRInt32 aStatus,
#endif
nsIDocumentLoaderObserver* aObserver)
{
char* urlSpec = "";
@ -471,10 +472,11 @@ NS_IMETHODIMP nsJavaDOMImpl::OnStatusURLLoad(nsIDocumentLoader* loader,
NS_IMETHODIMP nsJavaDOMImpl::OnEndURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus)
#else
nsIURI* aURL,
#endif
PRInt32 aStatus)
#endif
{
char* urlSpec = "";
#ifdef NECKO

View File

@ -23,10 +23,11 @@ class nsJavaDOMImpl : public nsIJavaDOM {
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus,
#else
nsIURI* aURL,
#endif
PRInt32 aStatus,
#endif
nsIDocumentLoaderObserver* aObserver);
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
@ -58,10 +59,11 @@ class nsJavaDOMImpl : public nsIJavaDOM {
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
#ifdef NECKO
nsIChannel* channel,
nsresult aStatus);
#else
nsIURI* aURL,
#endif
PRInt32 aStatus);
#endif
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
#ifdef NECKO