From 26937e21bfbdedb1544d01c36b780d5a36eafe6f Mon Sep 17 00:00:00 2001 From: "sdv%sparc.spb.su" Date: Thu, 30 Mar 2000 23:52:19 +0000 Subject: [PATCH] A major update: - reduces a number of c++<--> java calls - added NULL checks - made DOMAccessor to be secure - added util and tests packages - wrote test applets - updated README --- java/dom/DocumentImpl.java.patch | 12 - java/dom/README | 124 ++++--- java/dom/classes/Makefile | 2 + java/dom/classes/Makefile.in | 2 + java/dom/classes/makefile.win | 2 + .../classes/org/mozilla/dom/DOMAccessor.java | 129 ++++++- .../org/mozilla/dom/DOMAccessorImpl.java | 136 ------- .../classes/org/mozilla/dom/DocumentImpl.java | 3 - ...eCollector.java => JavaDOMPermission.java} | 14 +- .../dom/tests/DOMTreeDumperApplet.java | 50 +++ .../dom/tests}/TestDOMAccessorApplet.java | 14 +- .../dom/tests/TestDOMEventsApplet.java | 92 +++++ .../mozilla/dom/tests/TestRunnerApplet.java | 58 +++ .../org/mozilla/dom/util/DOMTreeDumper.java | 231 ++++++++++++ .../dom/util/GenericDocLoadListener.java | 105 ++++++ .../dom/util/GenericEventListener.java | 68 ++++ java/dom/jni/Makefile | 3 +- java/dom/jni/Makefile.in | 3 +- java/dom/jni/event-test/DOMFactory.java.patch | 60 ---- .../dom/jni/event-test/TestEventListener.java | 28 -- java/dom/jni/makefile.win | 6 +- ...pl.cpp => org_mozilla_dom_DOMAccessor.cpp} | 27 +- java/dom/jni/org_mozilla_dom_DOMAccessor.h | 47 +++ .../dom/jni/org_mozilla_dom_DOMAccessorImpl.h | 38 -- .../org_mozilla_dom_DOMGarbageCollector.cpp | 34 -- .../jni/org_mozilla_dom_DOMGarbageCollector.h | 21 -- java/dom/nsWebShell.cpp.patch | 19 +- java/dom/src/nsJavaDOMImpl.cpp | 332 +++++++----------- java/dom/src/nsJavaDOMImpl.h | 17 +- .../dom/tests/src/TestDOMAccessorApplet1.java | 219 ------------ java/dom/tests/src/TestDocLoadListener.java | 211 ----------- java/dom/tests/src/applets/index.html | 21 ++ java/dom/tests/src/{ => applets}/testa.html | 7 +- java/dom/tests/src/applets/testb.html | 22 ++ .../src/{testb.html => applets/testc.html} | 17 +- java/dom/tests/src/applets/testd.html | 23 ++ 36 files changed, 1109 insertions(+), 1088 deletions(-) delete mode 100644 java/dom/DocumentImpl.java.patch delete mode 100644 java/dom/classes/org/mozilla/dom/DOMAccessorImpl.java rename java/dom/classes/org/mozilla/dom/{DOMGarbageCollector.java => JavaDOMPermission.java} (74%) create mode 100644 java/dom/classes/org/mozilla/dom/tests/DOMTreeDumperApplet.java rename java/dom/{tests/src => classes/org/mozilla/dom/tests}/TestDOMAccessorApplet.java (71%) create mode 100644 java/dom/classes/org/mozilla/dom/tests/TestDOMEventsApplet.java create mode 100644 java/dom/classes/org/mozilla/dom/tests/TestRunnerApplet.java create mode 100644 java/dom/classes/org/mozilla/dom/util/DOMTreeDumper.java create mode 100644 java/dom/classes/org/mozilla/dom/util/GenericDocLoadListener.java create mode 100644 java/dom/classes/org/mozilla/dom/util/GenericEventListener.java delete mode 100644 java/dom/jni/event-test/DOMFactory.java.patch delete mode 100644 java/dom/jni/event-test/TestEventListener.java rename java/dom/jni/{org_mozilla_dom_DOMAccessorImpl.cpp => org_mozilla_dom_DOMAccessor.cpp} (81%) create mode 100644 java/dom/jni/org_mozilla_dom_DOMAccessor.h delete mode 100644 java/dom/jni/org_mozilla_dom_DOMAccessorImpl.h delete mode 100644 java/dom/jni/org_mozilla_dom_DOMGarbageCollector.cpp delete mode 100644 java/dom/jni/org_mozilla_dom_DOMGarbageCollector.h delete mode 100644 java/dom/tests/src/TestDOMAccessorApplet1.java delete mode 100644 java/dom/tests/src/TestDocLoadListener.java create mode 100644 java/dom/tests/src/applets/index.html rename java/dom/tests/src/{ => applets}/testa.html (88%) create mode 100644 java/dom/tests/src/applets/testb.html rename java/dom/tests/src/{testb.html => applets/testc.html} (54%) create mode 100644 java/dom/tests/src/applets/testd.html diff --git a/java/dom/DocumentImpl.java.patch b/java/dom/DocumentImpl.java.patch deleted file mode 100644 index 02d2c84d31dc..000000000000 --- a/java/dom/DocumentImpl.java.patch +++ /dev/null @@ -1,12 +0,0 @@ -Index: DocumentImpl.java -=================================================================== -RCS file: /cvsroot/mozilla/java/dom/jni/DocumentImpl.java,v -retrieving revision 1.4 -diff -r1.4 DocumentImpl.java -40a41,42 -> import org.mozilla.dom.tests.TestDocLoadListener; -> -64d65 -< -71a73 -> DOMAccessorImpl.getInstance().addDocumentLoadListener(new TestDocLoadListener()); diff --git a/java/dom/README b/java/dom/README index e3db680d22e3..b057eaf69f48 100644 --- a/java/dom/README +++ b/java/dom/README @@ -1,57 +1,90 @@ + +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/WD-DOM-Level-2/java-binding.zip + + 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 if OJI is not use to obtain JNIEnv one has to apply -two patches +Document load notifications is to register via the DOMAccessor class. - webshell/src/nsWebShell.cpp.patch - java/dom/jni/DocumentImpl.java.patch +However, this is possible only if OJI usage is enabled. This works +on Windows NT platform. -The first one inits nsJavaDOM component and starts jvm. The second one -registers a document load listener via DOMAccessor. +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 TestDocLoadListener. -See the section on Building for instructions on how to apply the patches. + stand for GenericDocLoadListener. -To enable OJI usage on win nt add -DJAVA_DOM_OJI_ENABLE to the -DEFINES variable in makefile.win and also set an environment -variable JAVA_DOM_OJI_ENABLE=true +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. -Makefiles ---------- +You can find examples of Java DOM API usage in -You may have to set DEPTH to point to the mozilla CVS workspace root -in Makefile and jni/Makefile. Since this stuff is not part of the -regular SeaMonkeyBuild, Makefiles are not generated from Makefile.in, -so just go ahead and hack the Makefile. - -Building --------- - -After having done a configure at the top level of SeaMonkey, do a make -in the dom and the dom/jni directories. This will copy over a few -header files that are needed by the patch to nsWebShell. You can then -apply the patch to nsWebShell.cpp by executing - -`patch nsWebShell.cpp JDIRS = org\mozilla\dom \ org\mozilla\dom\events \ + org\mozilla\dom\util \ + org\mozilla\dom\tests \ $(NULL) JAVAC_PROG=$(JDKHOME)\bin\javac diff --git a/java/dom/classes/org/mozilla/dom/DOMAccessor.java b/java/dom/classes/org/mozilla/dom/DOMAccessor.java index 482a9f7d433f..7cb189b890a3 100644 --- a/java/dom/classes/org/mozilla/dom/DOMAccessor.java +++ b/java/dom/classes/org/mozilla/dom/DOMAccessor.java @@ -21,15 +21,124 @@ package org.mozilla.dom; -public interface DOMAccessor { - public void addDocumentLoadListener(DocumentLoadListener listener); - public void removeDocumentLoadListener(DocumentLoadListener listener); +import java.util.Vector; +import java.util.Enumeration; - /** - * The getInstance method is available, it is not declared because - * it is a static method and the Java Language Spec does not allow - * us to declare a static method in an interface. - * - * public static synchronized DOMAccessor getInstance(); - */ +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 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(); + } } diff --git a/java/dom/classes/org/mozilla/dom/DOMAccessorImpl.java b/java/dom/classes/org/mozilla/dom/DOMAccessorImpl.java deleted file mode 100644 index 786585051ce5..000000000000 --- a/java/dom/classes/org/mozilla/dom/DOMAccessorImpl.java +++ /dev/null @@ -1,136 +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.Element; - -public class DOMAccessorImpl implements DOMAccessor, DocumentLoadListener { - - private static DOMAccessor instance = null; - private Vector documentLoadListeners = new Vector(); - - static { - System.loadLibrary("javadomjni"); - } - - private void DOMAccessorImpl() {} - - private static native void register(); - private static native void unregister(); - private static native Element getElementByHandle(long p); - - public static synchronized DOMAccessor getInstance() { - if (instance == null) { - instance = new DOMAccessorImpl(); - } - return instance; - } - - public synchronized void - addDocumentLoadListener(DocumentLoadListener listener) { - if (documentLoadListeners.size() == 0) { - register(); - } - documentLoadListeners.addElement(listener); - } - - public synchronized void - removeDocumentLoadListener(DocumentLoadListener listener) { - - documentLoadListeners.removeElement(listener); - if (documentLoadListeners.size() == 0) { - unregister(); - } - } - - public synchronized void - startURLLoad(String url, String contentType, Document doc) { - - for (Enumeration e = documentLoadListeners.elements(); - e.hasMoreElements();) { - DocumentLoadListener listener = - (DocumentLoadListener) e.nextElement(); - listener.startURLLoad(url, contentType, doc); - } - } - - public synchronized void - endURLLoad(String url, int status, Document doc) { - - for (Enumeration e = documentLoadListeners.elements(); - e.hasMoreElements();) { - DocumentLoadListener listener = - (DocumentLoadListener) e.nextElement(); - listener.endURLLoad(url, status, doc); - } - } - - public synchronized void - progressURLLoad(String url, int progress, int progressMax, - Document doc) { - - for (Enumeration e = documentLoadListeners.elements(); - e.hasMoreElements();) { - DocumentLoadListener listener = - (DocumentLoadListener) e.nextElement(); - listener.progressURLLoad(url, progress, progressMax, doc); - } - } - - public synchronized void - statusURLLoad(String url, String message, Document doc) { - - for (Enumeration e = documentLoadListeners.elements(); - e.hasMoreElements();) { - DocumentLoadListener listener = - (DocumentLoadListener) e.nextElement(); - listener.statusURLLoad(url, message, doc); - } - } - - - public synchronized void - startDocumentLoad(String url) { - - for (Enumeration e = documentLoadListeners.elements(); - e.hasMoreElements();) { - DocumentLoadListener listener = - (DocumentLoadListener) e.nextElement(); - listener.startDocumentLoad(url); - } - } - - public synchronized void - endDocumentLoad(String url, int status, Document doc) { - - for (Enumeration e = documentLoadListeners.elements(); - e.hasMoreElements();) { - DocumentLoadListener listener = - (DocumentLoadListener) e.nextElement(); - listener.endDocumentLoad(url, status, doc); - } - } -} diff --git a/java/dom/classes/org/mozilla/dom/DocumentImpl.java b/java/dom/classes/org/mozilla/dom/DocumentImpl.java index e6e7aa43d096..b44471d3f952 100644 --- a/java/dom/classes/org/mozilla/dom/DocumentImpl.java +++ b/java/dom/classes/org/mozilla/dom/DocumentImpl.java @@ -42,9 +42,6 @@ public class DocumentImpl extends NodeImpl implements Document, DocumentEvent { // instantiated from JNI only private DocumentImpl() {} - public DocumentImpl(long p) { - super(p); - } public native Attr createAttribute(String name); public native CDATASection createCDATASection(String data); diff --git a/java/dom/classes/org/mozilla/dom/DOMGarbageCollector.java b/java/dom/classes/org/mozilla/dom/JavaDOMPermission.java similarity index 74% rename from java/dom/classes/org/mozilla/dom/DOMGarbageCollector.java rename to java/dom/classes/org/mozilla/dom/JavaDOMPermission.java index 2c3a0b0349f1..cab2ed9253d7 100644 --- a/java/dom/classes/org/mozilla/dom/DOMGarbageCollector.java +++ b/java/dom/classes/org/mozilla/dom/JavaDOMPermission.java @@ -21,8 +21,16 @@ package org.mozilla.dom; -public class DOMGarbageCollector { +import java.security.BasicPermission; - // private static native void doGC(); - public static native void doGC(); +public final class JavaDOMPermission extends BasicPermission { + public JavaDOMPermission(String name) + { + super(name); + } + + public JavaDOMPermission(String name, String actions) + { + super(name); + } } diff --git a/java/dom/classes/org/mozilla/dom/tests/DOMTreeDumperApplet.java b/java/dom/classes/org/mozilla/dom/tests/DOMTreeDumperApplet.java new file mode 100644 index 000000000000..66d4ed4a277d --- /dev/null +++ b/java/dom/classes/org/mozilla/dom/tests/DOMTreeDumperApplet.java @@ -0,0 +1,50 @@ +/* + 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.tests; + +import java.applet.Applet; +import org.w3c.dom.Document; +import org.mozilla.dom.DOMAccessor; +import org.mozilla.dom.util.DOMTreeDumper; +import org.mozilla.dom.util.GenericDocLoadListener; + +public class DOMTreeDumperApplet extends Applet +{ + private DOMAccessor accessor; + private final String name = "DOMTreeDumperApplet"; + + public void init() + { + DOMAccessor.addDocumentLoadListener(new DOMTreeDumperListener(name)); + System.out.println(name + " init..."); + } + + class DOMTreeDumperListener extends GenericDocLoadListener { + public DOMTreeDumperListener(String name) { + super(name); + } + public void endDocumentLoad(String url, int status, Document doc) { + new DOMTreeDumper(name).dumpToStream(System.out, doc); + } + } +} + diff --git a/java/dom/tests/src/TestDOMAccessorApplet.java b/java/dom/classes/org/mozilla/dom/tests/TestDOMAccessorApplet.java similarity index 71% rename from java/dom/tests/src/TestDOMAccessorApplet.java rename to java/dom/classes/org/mozilla/dom/tests/TestDOMAccessorApplet.java index 4d21c41fe77f..82f216676aed 100644 --- a/java/dom/tests/src/TestDOMAccessorApplet.java +++ b/java/dom/classes/org/mozilla/dom/tests/TestDOMAccessorApplet.java @@ -23,20 +23,16 @@ package org.mozilla.dom.tests; import java.applet.Applet; import org.mozilla.dom.DOMAccessor; -import org.mozilla.dom.DOMAccessorImpl; -import org.mozilla.dom.tests.TestDocLoadListener; +import org.mozilla.dom.util.GenericDocLoadListener; public class TestDOMAccessorApplet extends java.applet.Applet { - private DOMAccessor accessor; - + private final String name = "TestDOMAccessorApplet"; + public void init() { - accessor = DOMAccessorImpl.getInstance(); - accessor.addDocumentLoadListener( - new TestDocLoadListener("TestDOMAccessorApplet")); - System.out.println("inited......"); - System.out.println("accsessor: " + accessor); + DOMAccessor.addDocumentLoadListener(new GenericDocLoadListener(name)); + System.out.println(name + " init..."); } } diff --git a/java/dom/classes/org/mozilla/dom/tests/TestDOMEventsApplet.java b/java/dom/classes/org/mozilla/dom/tests/TestDOMEventsApplet.java new file mode 100644 index 000000000000..df18fc716881 --- /dev/null +++ b/java/dom/classes/org/mozilla/dom/tests/TestDOMEventsApplet.java @@ -0,0 +1,92 @@ +/* + 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.tests; + +import java.util.Vector; +import java.applet.Applet; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.w3c.dom.Document; +import org.w3c.dom.events.EventListener; +import org.w3c.dom.events.EventTarget; +import org.mozilla.dom.DOMAccessor; +import org.mozilla.dom.NodeImpl; +import org.mozilla.dom.util.GenericEventListener; +import org.mozilla.dom.util.GenericDocLoadListener; + +public class TestDOMEventsApplet extends Applet { + + private final String name = "TestDOMEventsApplet"; + + public void init() + { + DOMAccessor.addDocumentLoadListener(new TestDOMEventsListener(name)); + System.out.println(name + " init..."); + } + + class TestDOMEventsListener extends GenericDocLoadListener { + public TestDOMEventsListener(String name) { + super(name); + } + + public void endDocumentLoad(String url, int status, Document doc) { + if (url.endsWith(".html")){ + Vector v; + Object o; + Node n; + NodeList l; + int i; + EventListener listener; + NodeImpl target; + String [] types = {"mouseover", "dblclick", "mouseout", "keydown", "keyup", + "mousedown", "mouseup", "click", "keypress", + "mousemove", "focus", "blur", "submit", "reset", + "change", "select", "input", "load", "unload", + "abort", "error", "paint", "create", "destroy", + "command", "broadcast", "commandupdate", + "dragenter", "dragover", "dragexit", "dragdrop", + "draggesture"}; + + listener = new GenericEventListener("name"); + v = new Vector (20, 10); + v.add(doc); + + while(!v.isEmpty()) { + o = v.elementAt(0); + if (o instanceof Node) { + n = (Node) o; + if (n instanceof NodeImpl) + for(i=0; i < types.length; i++) { + target = (NodeImpl) n; + target.addEventListener(types[i], listener, false); + } + + l = n.getChildNodes(); + for(i=0; i + * + */ + +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(""); + } + 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"); + 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"); + 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("&"); + break; + case '<': + out.append("<"); + break; + case '>': + out.append(">"); + break; + case '\u00A0': + out.append(" "); + 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); + } + } +} diff --git a/java/dom/classes/org/mozilla/dom/util/GenericDocLoadListener.java b/java/dom/classes/org/mozilla/dom/util/GenericDocLoadListener.java new file mode 100644 index 000000000000..70fddfcf7bfc --- /dev/null +++ b/java/dom/classes/org/mozilla/dom/util/GenericDocLoadListener.java @@ -0,0 +1,105 @@ +/* + 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)); + } + } +} diff --git a/java/dom/classes/org/mozilla/dom/util/GenericEventListener.java b/java/dom/classes/org/mozilla/dom/util/GenericEventListener.java new file mode 100644 index 000000000000..6a22afda3459 --- /dev/null +++ b/java/dom/classes/org/mozilla/dom/util/GenericEventListener.java @@ -0,0 +1,68 @@ +/* + * 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 + * EventListener interface was registered. + * @param event The Event contains contextual information about + * the event. It also contains the returnValue and + * cancelBubble 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); + } + } + } +} + diff --git a/java/dom/jni/Makefile b/java/dom/jni/Makefile index bbe67c5fb294..754ef6343235 100644 --- a/java/dom/jni/Makefile +++ b/java/dom/jni/Makefile @@ -32,8 +32,7 @@ CPPSRCS = \ javaDOMGlobals.cpp \ javaDOMEventsGlobals.cpp \ nativeDOMProxyListener.cpp \ - org_mozilla_dom_DOMGarbageCollector.cpp \ - org_mozilla_dom_DOMAccessorImpl.cpp \ + org_mozilla_dom_DOMAccessor.cpp \ org_mozilla_dom_AttrImpl.cpp \ org_mozilla_dom_CharacterDataImpl.cpp \ org_mozilla_dom_DocumentImpl.cpp \ diff --git a/java/dom/jni/Makefile.in b/java/dom/jni/Makefile.in index 844bde2c6d30..a4b1fcd2b31e 100644 --- a/java/dom/jni/Makefile.in +++ b/java/dom/jni/Makefile.in @@ -32,8 +32,7 @@ CPPSRCS = \ javaDOMGlobals.cpp \ javaDOMEventsGlobals.cpp \ nativeDOMProxyListener.cpp \ - org_mozilla_dom_DOMGarbageCollector.cpp \ - org_mozilla_dom_DOMAccessorImpl.cpp \ + org_mozilla_dom_DOMAccessor.cpp \ org_mozilla_dom_AttrImpl.cpp \ org_mozilla_dom_CharacterDataImpl.cpp \ org_mozilla_dom_DocumentImpl.cpp \ diff --git a/java/dom/jni/event-test/DOMFactory.java.patch b/java/dom/jni/event-test/DOMFactory.java.patch deleted file mode 100644 index 4a2cd43c5761..000000000000 --- a/java/dom/jni/event-test/DOMFactory.java.patch +++ /dev/null @@ -1,60 +0,0 @@ -Index: DOMFactory.java -=================================================================== -RCS file: /cvsroot/mozilla/java/dom/jni/DOMFactory.java,v -retrieving revision 1.2 -diff -r1.2 DOMFactory.java -23a24,25 -> import java.util.Vector; -> -30a33,37 -> import org.w3c.dom.events.TestEventListener; -> import org.w3c.dom.events.EventListener; -> import org.w3c.dom.events.EventTarget; -> import org.mozilla.dom.NodeImpl; -> -76c83,84 -< ---- -> -> -108a117,156 -> if (url.endsWith("test.html")){ -> System.out.println("TestCases Tuned to run with test.html..."); -> Vector v; -> Object o; -> Node n; -> NodeList l; -> int i; -> EventListener listener; -> NodeImpl target; -> String [] types = {"mouseover", "dblclick", "mouseout", "keydown", "keyup", -> "mousedown", "mouseup", "click", "keypress", -> "mousemove", "focus", "blur", "submit", "reset", -> "change", "select", "input", "load", "unload", -> "abort", "error", "paint", "create", "destroy", -> "command", "broadcast", "commandupdate", -> "dragenter", "dragover", "dragexit", "dragdrop", -> "draggesture"}; -> -> listener = new TestEventListener(); -> v = new Vector (20, 10); -> v.add(doc); -> -> while(!v.isEmpty()) { -> o = v.elementAt(0); -> if (o instanceof Node) { -> n = (Node) o; -> if (n instanceof NodeImpl) -> for(i=0; i < types.length; i++) { -> target = (NodeImpl) n; -> target.addEventListener(types[i], listener, false); -> // target.removeEventListener(types[i], listener, false); -> } -> -> l = n.getChildNodes(); -> for(i=0; i v.add(l.item(i)); -> } -> v.remove(0); -> } -> } diff --git a/java/dom/jni/event-test/TestEventListener.java b/java/dom/jni/event-test/TestEventListener.java deleted file mode 100644 index 604a3e4be842..000000000000 --- a/java/dom/jni/event-test/TestEventListener.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.w3c.dom.events; - -import org.w3c.dom.events.EventListener; -import org.w3c.dom.events.Event; - -public class TestEventListener implements EventListener { - - - public TestEventListener() {}; - - /** - * This method is called whenever an event occurs of the type for which the - * EventListener interface was registered. - * @param event The Event contains contextual information about - * the event. It also contains the returnValue and - * cancelBubble properties which are used in determining - * proper event flow. - */ - public void handleEvent(Event event) { - try { - System.out.println("In JAVA: Got event" + event); - } catch (Exception e) { - System.out.println("Got exception in handleEvent "+e); - } - } - -} - diff --git a/java/dom/jni/makefile.win b/java/dom/jni/makefile.win index a7968b13365a..037e32973206 100755 --- a/java/dom/jni/makefile.win +++ b/java/dom/jni/makefile.win @@ -29,8 +29,7 @@ CPPSRCS= \ javaDOMGlobals.cpp \ javaDOMEventsGlobals.cpp \ nativeDOMProxyListener.cpp \ - org_mozilla_dom_DOMAccessorImpl.cpp \ - org_mozilla_dom_DOMGarbageCollector.cpp \ + org_mozilla_dom_DOMAccessor.cpp \ org_mozilla_dom_AttrImpl.cpp \ org_mozilla_dom_CharacterDataImpl.cpp \ org_mozilla_dom_DocumentImpl.cpp \ @@ -53,8 +52,7 @@ CPP_OBJS= \ .\$(OBJDIR)\javaDOMGlobals.obj \ .\$(OBJDIR)\javaDOMEventsGlobals.obj \ .\$(OBJDIR)\nativeDOMProxyListener.obj \ - .\$(OBJDIR)\org_mozilla_dom_DOMAccessorImpl.obj \ - .\$(OBJDIR)\org_mozilla_dom_DOMGarbageCollector.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 \ diff --git a/java/dom/jni/org_mozilla_dom_DOMAccessorImpl.cpp b/java/dom/jni/org_mozilla_dom_DOMAccessor.cpp similarity index 81% rename from java/dom/jni/org_mozilla_dom_DOMAccessorImpl.cpp rename to java/dom/jni/org_mozilla_dom_DOMAccessor.cpp index 60a31ddce8d0..d7f17fdc57ae 100644 --- a/java/dom/jni/org_mozilla_dom_DOMAccessorImpl.cpp +++ b/java/dom/jni/org_mozilla_dom_DOMAccessor.cpp @@ -7,17 +7,17 @@ #include "nsCURILoader.h" #include "nsIJavaDOM.h" -#include "org_mozilla_dom_DOMAccessorImpl.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_DOMAccessorImpl + * Class: org_mozilla_dom_DOMAccessor * Method: register * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_register +JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_register (JNIEnv *env, jclass jthis) { if (!JavaDOMGlobals::log) { @@ -47,11 +47,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_register } /* - * Class: org_mozilla_dom_DOMAccessorImpl + * Class: org_mozilla_dom_DOMAccessor * Method: unregister * Signature: ()V */ -JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_unregister +JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_unregister (JNIEnv *, jclass jthis) { PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG, @@ -81,11 +81,11 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_unregister } /* - * Class: org_mozilla_dom_DOMAccessorImpl + * Class: org_mozilla_dom_DOMAccessor * Method: createElement * Signature: (J)Lorg/w3c/dom/Element; */ -JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessorImpl_getElementByHandle +JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessor_getNodeByHandle (JNIEnv *env, jclass jthis, jlong p) { if (!JavaDOMGlobals::log) { @@ -94,3 +94,16 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessorImpl_getElementByHandl 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(); +} + + diff --git a/java/dom/jni/org_mozilla_dom_DOMAccessor.h b/java/dom/jni/org_mozilla_dom_DOMAccessor.h new file mode 100644 index 000000000000..1484233941c4 --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_DOMAccessor.h @@ -0,0 +1,47 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* 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: 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); + +/* + * 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: doGC + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_doGC + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/dom/jni/org_mozilla_dom_DOMAccessorImpl.h b/java/dom/jni/org_mozilla_dom_DOMAccessorImpl.h deleted file mode 100644 index 13ed1c765b0c..000000000000 --- a/java/dom/jni/org_mozilla_dom_DOMAccessorImpl.h +++ /dev/null @@ -1,38 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_mozilla_dom_DOMAccessorImpl */ - -#ifndef _Included_org_mozilla_dom_DOMAccessorImpl -#define _Included_org_mozilla_dom_DOMAccessorImpl -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: instance */ -/* - * Class: org_mozilla_dom_DOMAccessorImpl - * Method: register - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_register - (JNIEnv *, jclass); - -/* - * Class: org_mozilla_dom_DOMAccessorImpl - * Method: unregister - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessorImpl_unregister - (JNIEnv *, jclass); - -/* - * Class: org_mozilla_dom_DOMAccessorImpl - * Method: getElementByHandle - * Signature: (J)Lorg/w3c/dom/Element; - */ -JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessorImpl_getElementByHandle - (JNIEnv *, jclass, jlong); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/java/dom/jni/org_mozilla_dom_DOMGarbageCollector.cpp b/java/dom/jni/org_mozilla_dom_DOMGarbageCollector.cpp deleted file mode 100644 index 3b387587d46e..000000000000 --- a/java/dom/jni/org_mozilla_dom_DOMGarbageCollector.cpp +++ /dev/null @@ -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): -*/ - -#include "org_mozilla_dom_DOMGarbageCollector.h" -#include "javaDOMGlobals.h" - -/* - * Class: org_mozilla_dom_DOMGarbageCollector - * Method: doGC - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMGarbageCollector_doGC - (JNIEnv *, jclass) -{ - JavaDOMGlobals::TakeOutGarbage(); -} diff --git a/java/dom/jni/org_mozilla_dom_DOMGarbageCollector.h b/java/dom/jni/org_mozilla_dom_DOMGarbageCollector.h deleted file mode 100644 index cba1e6a4735d..000000000000 --- a/java/dom/jni/org_mozilla_dom_DOMGarbageCollector.h +++ /dev/null @@ -1,21 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_mozilla_dom_DOMGarbageCollector */ - -#ifndef _Included_org_mozilla_dom_DOMGarbageCollector -#define _Included_org_mozilla_dom_DOMGarbageCollector -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: org_mozilla_dom_DOMGarbageCollector - * Method: doGC - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMGarbageCollector_doGC - (JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/java/dom/nsWebShell.cpp.patch b/java/dom/nsWebShell.cpp.patch index e5bc828ae2e7..fa4126577c20 100644 --- a/java/dom/nsWebShell.cpp.patch +++ b/java/dom/nsWebShell.cpp.patch @@ -1,28 +1,25 @@ Index: nsWebShell.cpp =================================================================== RCS file: /cvsroot/mozilla/webshell/src/nsWebShell.cpp,v -retrieving revision 1.377 -diff -r1.377 nsWebShell.cpp -70a71 -> -97a99,106 +retrieving revision 1.429 +diff -r1.429 nsWebShell.cpp +111a112,116 > #ifdef JAVA_DOM > #include "nsIJavaDOM.h" > static NS_DEFINE_IID(kJavaDOMCID, NS_JAVADOM_CID); > static NS_DEFINE_IID(kIJavaDOMIID, NS_IJAVADOM_IID); > #endif // JAVA_DOM +3107a3113,3125 > -> -> -566a576 -> -984a995,1003 > #ifdef JAVA_DOM > nsresult jrv = NS_OK; -> NS_WITH_SERVICE(nsISupports, javaDOM, kJavaDOMCID, &jrv); +> NS_WITH_SERVICE(nsIDocumentLoaderObserver, javaDOM, kJavaDOMCID, &jrv); > if (NS_FAILED(jrv) || !javaDOM) { > fprintf(stderr, > "nsWebShell::Init: GetService of JavaDOM failed (error %x)\n", > jrv); +> } else { +> printf("\n webshell: added JAVADOM as observer...\n"); +> mDocLoader->AddObserver(javaDOM); > } > #endif // JAVA_DOM diff --git a/java/dom/src/nsJavaDOMImpl.cpp b/java/dom/src/nsJavaDOMImpl.cpp index 6631f4858b7b..4eaf33248cc3 100644 --- a/java/dom/src/nsJavaDOMImpl.cpp +++ b/java/dom/src/nsJavaDOMImpl.cpp @@ -34,11 +34,6 @@ #include "nsIModule.h" #include "nsIGenericFactory.h" -#ifdef JAVA_DOM_OJI_ENABLE -#include "ProxyJNI.h" -#include "nsIServiceManager.h" -#endif - #if defined(DEBUG) #include #include "nsIDOMElement.h" @@ -53,8 +48,15 @@ static const char* describe_type(int type); #endif #ifdef JAVA_DOM_OJI_ENABLE +#include "ProxyJNI.h" +#include "nsIServiceManager.h" +nsJVMManager* nsJavaDOMImpl::jvmManager = NULL; +JavaDOMSecurityContext* nsJavaDOMImpl::securityContext = NULL; static NS_DEFINE_CID(kJVMManagerCID,NS_JVMMANAGER_CID); +#else +JavaVM* nsJavaDOMImpl::jvm = NULL; #endif + static NS_DEFINE_IID(kIDocShellIID, NS_IDOCSHELL_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIJavaDOMIID, NS_IJAVADOM_IID); @@ -65,6 +67,14 @@ static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_I NS_IMPL_ADDREF(nsJavaDOMImpl); NS_IMPL_RELEASE(nsJavaDOMImpl); +jclass nsJavaDOMImpl::domAccessorClass = NULL; + +jmethodID nsJavaDOMImpl::startURLLoadMID = NULL; +jmethodID nsJavaDOMImpl::endURLLoadMID = NULL; +jmethodID nsJavaDOMImpl::progressURLLoadMID = NULL; +jmethodID nsJavaDOMImpl::statusURLLoadMID = NULL; +jmethodID nsJavaDOMImpl::startDocumentLoadMID = NULL; +jmethodID nsJavaDOMImpl::endDocumentLoadMID = NULL; #define NS_JAVADOM_PROGID \ "component://netscape/blackwood/java-dom" @@ -83,8 +93,6 @@ static nsModuleComponentInfo components[] = NS_IMPL_NSGETMODULE("JavaDOMModule",components); - - NS_IMETHODIMP nsJavaDOMImpl::QueryInterface(REFNSIID aIID, void** aInstance) { if (NULL == aInstance) @@ -111,126 +119,77 @@ NS_IMETHODIMP nsJavaDOMImpl::QueryInterface(REFNSIID aIID, void** aInstance) return NS_NOINTERFACE; } -#ifdef JAVA_DOM_OJI_ENABLE -nsJVMManager* nsJavaDOMImpl::jvmManager = NULL; -JavaDOMSecurityContext* nsJavaDOMImpl::securityContext = NULL; -#else -JavaVM* nsJavaDOMImpl::jvm = NULL; -#endif - -jclass nsJavaDOMImpl::domAccessorClass = NULL; -jclass nsJavaDOMImpl::documentClass = NULL; -jclass nsJavaDOMImpl::listenerClass = NULL; -jclass nsJavaDOMImpl::gcClass = NULL; - -jobject nsJavaDOMImpl::docListener = NULL; - -jfieldID nsJavaDOMImpl::documentPtrFID = NULL; - -jmethodID nsJavaDOMImpl::documentInitID = NULL; -jmethodID nsJavaDOMImpl::getInstanceMID = NULL; -jmethodID nsJavaDOMImpl::startURLLoadMID = NULL; -jmethodID nsJavaDOMImpl::endURLLoadMID = NULL; -jmethodID nsJavaDOMImpl::progressURLLoadMID = NULL; -jmethodID nsJavaDOMImpl::statusURLLoadMID = NULL; -jmethodID nsJavaDOMImpl::startDocumentLoadMID = NULL; -jmethodID nsJavaDOMImpl::endDocumentLoadMID = NULL; - -jmethodID nsJavaDOMImpl::gcMID = NULL; - nsJavaDOMImpl::nsJavaDOMImpl() { NS_INIT_ISUPPORTS(); +} +PRBool nsJavaDOMImpl::Init(JNIEnv** jniEnv) { JNIEnv* env = GetJNIEnv(); + if (!env) return PR_FALSE; + *jniEnv = env; - gcClass = env->FindClass("org/mozilla/dom/DOMGarbageCollector"); - if (!gcClass) return; - gcClass = (jclass) env->NewGlobalRef(gcClass); - if (!gcClass) return; + if (!domAccessorClass) { + domAccessorClass = env->FindClass("org/mozilla/dom/DOMAccessor"); + if (!domAccessorClass) return PR_FALSE; + domAccessorClass = (jclass) env->NewGlobalRef(domAccessorClass); + if (!domAccessorClass) return PR_FALSE; - gcMID = - env->GetStaticMethodID(gcClass, - "doGC", - "()V"); - if (!gcMID) return; + startURLLoadMID = + env->GetStaticMethodID(domAccessorClass, + "startURLLoad", + "(Ljava/lang/String;Ljava/lang/String;J)V"); + if (Cleanup(env) == PR_TRUE) { + domAccessorClass = NULL; + return PR_FALSE; + } + + endURLLoadMID = + env->GetStaticMethodID(domAccessorClass, + "endURLLoad", + "(Ljava/lang/String;IJ)V"); + if (Cleanup(env) == PR_TRUE) { + domAccessorClass = NULL; + return PR_FALSE; + } - domAccessorClass = env->FindClass("org/mozilla/dom/DOMAccessorImpl"); - if (!domAccessorClass) return; - domAccessorClass = (jclass) env->NewGlobalRef(domAccessorClass); - if (!domAccessorClass) return; + progressURLLoadMID = + env->GetStaticMethodID(domAccessorClass, + "progressURLLoad", + "(Ljava/lang/String;IIJ)V"); + if (Cleanup(env) == PR_TRUE) { + domAccessorClass = NULL; + return PR_FALSE; + } - getInstanceMID = - env->GetStaticMethodID(domAccessorClass, - "getInstance", - "()Lorg/mozilla/dom/DOMAccessor;"); - if (!getInstanceMID) return; - - docListener = - env->CallStaticObjectMethod(domAccessorClass, getInstanceMID); - if (!docListener) return; - docListener = (jclass) env->NewGlobalRef(docListener); - if (!docListener) return; - - listenerClass = - env->GetObjectClass(docListener); - if (!listenerClass) return; - listenerClass = (jclass) env->NewGlobalRef(listenerClass); - if (!listenerClass) return; - - documentClass = - env->FindClass("org/mozilla/dom/DocumentImpl"); - if (!documentClass) return; - documentClass = (jclass) env->NewGlobalRef(documentClass); - if (!documentClass) return; - - documentInitID = - env->GetMethodID(documentClass, "", "(J)V"); - if (!documentInitID) return; - - documentPtrFID = - env->GetFieldID(documentClass, - "p_nsIDOMNode", - "J"); - if (!documentPtrFID) return; - - startURLLoadMID = - env->GetMethodID(listenerClass, - "startURLLoad", - "(Ljava/lang/String;Ljava/lang/String;Lorg/w3c/dom/Document;)V"); - if (!startURLLoadMID) return; - - endURLLoadMID = - env->GetMethodID(listenerClass, - "endURLLoad", - "(Ljava/lang/String;ILorg/w3c/dom/Document;)V"); - if (!endURLLoadMID) return; - - progressURLLoadMID = - env->GetMethodID(listenerClass, - "progressURLLoad", - "(Ljava/lang/String;IILorg/w3c/dom/Document;)V"); - if (!progressURLLoadMID) return; - - statusURLLoadMID = - env->GetMethodID(listenerClass, - "statusURLLoad", - "(Ljava/lang/String;Ljava/lang/String;Lorg/w3c/dom/Document;)V"); - if (!statusURLLoadMID) return; - - startDocumentLoadMID = - env->GetMethodID(listenerClass, - "startDocumentLoad", - "(Ljava/lang/String;)V"); - if (!startDocumentLoadMID) return; - - endDocumentLoadMID = - env->GetMethodID(listenerClass, - "endDocumentLoad", - "(Ljava/lang/String;ILorg/w3c/dom/Document;)V"); - if (!endDocumentLoadMID) return; - - Cleanup(env); + statusURLLoadMID = + env->GetStaticMethodID(domAccessorClass, + "statusURLLoad", + "(Ljava/lang/String;Ljava/lang/String;J)V"); + if (Cleanup(env) == PR_TRUE) { + domAccessorClass = NULL; + return PR_FALSE; + } + + startDocumentLoadMID = + env->GetStaticMethodID(domAccessorClass, + "startDocumentLoad", + "(Ljava/lang/String;)V"); + if (Cleanup(env) == PR_TRUE) { + domAccessorClass = NULL; + return PR_FALSE; + } + + endDocumentLoadMID = + env->GetStaticMethodID(domAccessorClass, + "endDocumentLoad", + "(Ljava/lang/String;IJ)V"); + if (Cleanup(env) == PR_TRUE) { + domAccessorClass = NULL; + return PR_FALSE; + } + } + return PR_TRUE; } nsJavaDOMImpl::~nsJavaDOMImpl() @@ -243,7 +202,6 @@ PRBool nsJavaDOMImpl::Cleanup(JNIEnv* env) env->ExceptionDescribe(); return PR_TRUE; } - return PR_FALSE; } @@ -290,43 +248,23 @@ nsIDOMDocument* nsJavaDOMImpl::GetDocument(nsIDocumentLoader* loader) return NULL; } -// convert nsIDOMDocument to org.mozilla.dom.DocumentImpl -jobject nsJavaDOMImpl::CaffienateDOMDocument(nsIDOMDocument* domDoc) -{ - if (!domDoc) return NULL; - JNIEnv* env = GetJNIEnv(); - -// jobject jdoc = env->AllocObject(documentClass); - jobject jdoc = env->NewObject(documentClass, - documentInitID, - (jlong) (void*) domDoc); - if (!jdoc) return NULL; -// env->SetLongField(jdoc, documentPtrFID, (jlong) (void*) domDoc); - if (Cleanup(env) == PR_TRUE) return NULL; - - return jdoc; -} - -/* nsIDocumentLoaderObserver methods */ - NS_IMETHODIMP nsJavaDOMImpl::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = NULL; + if (Init(&env) == PR_FALSE) return NS_ERROR_FAILURE; + char* urlSpec = (char*) ""; if (aURL) aURL->GetSpec(&urlSpec); jstring jURL = env->NewStringUTF(urlSpec); if (!jURL) return NS_ERROR_FAILURE; - env->CallVoidMethod(docListener, - startDocumentLoadMID, - jURL); + env->CallStaticVoidMethod(domAccessorClass, + startDocumentLoadMID, + jURL); if (Cleanup(env) == PR_TRUE) return NS_ERROR_FAILURE; - - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } @@ -334,7 +272,9 @@ NS_IMETHODIMP nsJavaDOMImpl::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = NULL; + if (Init(&env) == PR_FALSE) return NS_ERROR_FAILURE; + char* urlSpec = (char*) ""; nsIURI* url = nsnull; if (channel && NS_SUCCEEDED(channel->GetURI(&url))) @@ -343,24 +283,21 @@ NS_IMETHODIMP nsJavaDOMImpl::OnEndDocumentLoad(nsIDocumentLoader* loader, if (!jURL) return NS_ERROR_FAILURE; nsIDOMDocument* domDoc = GetDocument(loader); - jobject jdoc = CaffienateDOMDocument(domDoc); - - env->CallVoidMethod(docListener, - endDocumentLoadMID, - jURL, - (jint) aStatus, - jdoc); + env->CallStaticVoidMethod(domAccessorClass, + endDocumentLoadMID, + jURL, + (jint) aStatus, + (jlong)domDoc); if (Cleanup(env) == PR_TRUE) return NS_ERROR_FAILURE; - - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } NS_IMETHODIMP nsJavaDOMImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = NULL; + if (Init(&env) == PR_FALSE) return NS_ERROR_FAILURE; + char* urlSpec = (char*) ""; nsIURI* url = nsnull; if (channel && NS_SUCCEEDED(channel->GetURI(&url))) @@ -377,17 +314,12 @@ NS_IMETHODIMP nsJavaDOMImpl::OnStartURLLoad(nsIDocumentLoader* loader, if (!jContentType) return NS_ERROR_FAILURE; nsIDOMDocument* domDoc = GetDocument(loader); - jobject jdoc = CaffienateDOMDocument(domDoc); - - env->CallVoidMethod(docListener, - startURLLoadMID, - jURL, - jContentType, - jdoc); + env->CallStaticVoidMethod(domAccessorClass, + startURLLoadMID, + jURL, + jContentType, + (jlong)domDoc); if (Cleanup(env) == PR_TRUE) return NS_ERROR_FAILURE; - - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } @@ -396,7 +328,9 @@ NS_IMETHODIMP nsJavaDOMImpl::OnProgressURLLoad(nsIDocumentLoader* loader, PRUint32 aProgress, PRUint32 aProgressMax) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = NULL; + if (Init(&env) == PR_FALSE) return NS_ERROR_FAILURE; + char* urlSpec = (char*) ""; nsIURI* url = nsnull; if (channel && NS_SUCCEEDED(channel->GetURI(&url))) @@ -405,18 +339,13 @@ NS_IMETHODIMP nsJavaDOMImpl::OnProgressURLLoad(nsIDocumentLoader* loader, if (!jURL) return NS_ERROR_FAILURE; nsIDOMDocument* domDoc = GetDocument(loader); - jobject jdoc = CaffienateDOMDocument(domDoc); - - env->CallVoidMethod(docListener, - progressURLLoadMID, - jURL, - (jint) aProgress, - (jint) aProgressMax, - jdoc); + env->CallStaticVoidMethod(domAccessorClass, + progressURLLoadMID, + jURL, + (jint) aProgress, + (jint) aProgressMax, + (jlong)domDoc); if (Cleanup(env) == PR_TRUE) return NS_ERROR_FAILURE; - - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } @@ -424,7 +353,9 @@ NS_IMETHODIMP nsJavaDOMImpl::OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = NULL; + if (Init(&env) == PR_FALSE) return NS_ERROR_FAILURE; + char* urlSpec = (char*) ""; nsIURI* url = nsnull; if (channel && NS_SUCCEEDED(channel->GetURI(&url))) @@ -437,17 +368,12 @@ NS_IMETHODIMP nsJavaDOMImpl::OnStatusURLLoad(nsIDocumentLoader* loader, if (!jMessage) return NS_ERROR_FAILURE; nsIDOMDocument* domDoc = GetDocument(loader); - jobject jdoc = CaffienateDOMDocument(domDoc); - - env->CallVoidMethod(docListener, - statusURLLoadMID, - jURL, - jMessage, - jdoc); + env->CallStaticVoidMethod(domAccessorClass, + statusURLLoadMID, + jURL, + jMessage, + (jlong)domDoc); if (Cleanup(env) == PR_TRUE) return NS_ERROR_FAILURE; - - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } @@ -455,7 +381,9 @@ NS_IMETHODIMP nsJavaDOMImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = NULL; + if (Init(&env) == PR_FALSE) return NS_ERROR_FAILURE; + char* urlSpec = (char*) ""; nsIURI* url = nsnull; if (channel && NS_SUCCEEDED(channel->GetURI(&url))) @@ -464,21 +392,15 @@ NS_IMETHODIMP nsJavaDOMImpl::OnEndURLLoad(nsIDocumentLoader* loader, if (!jURL) return NS_ERROR_FAILURE; nsIDOMDocument* domDoc = GetDocument(loader); - jobject jdoc = CaffienateDOMDocument(domDoc); - #if defined(DEBUG) dump_document(domDoc, urlSpec); #endif - - env->CallVoidMethod(docListener, - endURLLoadMID, - jURL, - (jint) aStatus, - jdoc); + env->CallStaticVoidMethod(domAccessorClass, + endURLLoadMID, + jURL, + (jint) aStatus, + (jlong)domDoc); if (Cleanup(env) == PR_TRUE) return NS_ERROR_FAILURE; - - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } @@ -487,13 +409,9 @@ NS_IMETHODIMP nsJavaDOMImpl::HandleUnknownContentType(nsIDocumentLoader* loader, const char *aContentType, const char *aCommand) { - JNIEnv* env = GetJNIEnv(); - env->CallStaticVoidMethod(gcClass, gcMID); - Cleanup(env); return NS_OK; } - JNIEnv* nsJavaDOMImpl::GetJNIEnv() { JNIEnv* env; #ifdef JAVA_DOM_OJI_ENABLE @@ -511,7 +429,7 @@ JNIEnv* nsJavaDOMImpl::GetJNIEnv() { // if (!securityContext) { // securityContext = new JavaDOMSecurityContext(); // } - // SetSecurityContext(env,securityContext); +// SetSecurityContext(env, securityContext); SetSecurityContext(env, new JavaDOMSecurityContext()); #else /* JAVA_DOM_OJI_ENABLE */ if (!jvm) { diff --git a/java/dom/src/nsJavaDOMImpl.h b/java/dom/src/nsJavaDOMImpl.h index be49f1d42cff..90d0e078ec3b 100644 --- a/java/dom/src/nsJavaDOMImpl.h +++ b/java/dom/src/nsJavaDOMImpl.h @@ -58,16 +58,7 @@ class nsJavaDOMImpl : public nsIJavaDOM { #endif static jclass domAccessorClass; - static jclass documentClass; - static jclass listenerClass; - static jclass gcClass; - static jobject docListener; - - static jfieldID documentPtrFID; - static jmethodID documentInitID; - - static jmethodID getInstanceMID; static jmethodID startURLLoadMID; static jmethodID endURLLoadMID; static jmethodID progressURLLoadMID; @@ -75,14 +66,12 @@ class nsJavaDOMImpl : public nsIJavaDOM { static jmethodID startDocumentLoadMID; static jmethodID endDocumentLoadMID; - static jmethodID gcMID; - - // cleanup after a JNI method invocation - static PRBool Cleanup(JNIEnv* env); static JNIEnv* GetJNIEnv(void); static void StartJVM(void); + static PRBool Init(JNIEnv**); + // cleanup after a JNI method invocation + static PRBool Cleanup(JNIEnv* env); nsIDOMDocument* GetDocument(nsIDocumentLoader* loader); - jobject CaffienateDOMDocument(nsIDOMDocument* domDoc); }; #endif /* __nsJavaDOMImpl_h__ */ diff --git a/java/dom/tests/src/TestDOMAccessorApplet1.java b/java/dom/tests/src/TestDOMAccessorApplet1.java deleted file mode 100644 index 713b21135b54..000000000000 --- a/java/dom/tests/src/TestDOMAccessorApplet1.java +++ /dev/null @@ -1,219 +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.tests; - -import java.applet.Applet; -import java.io.BufferedOutputStream; -import java.io.PrintStream; -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; -import org.mozilla.dom.DOMAccessor; -import org.mozilla.dom.DOMAccessorImpl; -import org.mozilla.dom.DocumentLoadListener; -import org.mozilla.dom.tests.TestDocLoadListener; -import org.mozilla.dom.test.*; - -public class TestDOMAccessorApplet1 extends Applet implements DocumentLoadListener -{ - private DOMAccessor accessor; - private static final boolean debug = true; - private static final String prefix = "TestDOMAccessorApplet1: "; - - public void init() - { - accessor = DOMAccessorImpl.getInstance(); - accessor.addDocumentLoadListener(this); - System.out.println("inited......"); - System.out.println("accsessor: " + accessor); - } - - public void startURLLoad(String url, String contentType, Document doc) { - if (debug) - System.err.println(prefix + "start URL load - " + - url.toString() + " " + - contentType); - } - - public void endURLLoad(String url, int status, Document doc) { - if (debug) - System.err.println(prefix + "end URL load - " + - url.toString() + " " + - Integer.toHexString(status)); - } - - public void progressURLLoad(String url, int progress, int progressMax, - Document doc) { - if (debug) - System.err.println(prefix + "progress URL load - " + - url.toString() + " " + - Integer.toString(progress) + "/" + - Integer.toString(progressMax)); - } - - public void statusURLLoad(String url, String message, Document doc) { - if (debug) - System.err.println(prefix + "status URL load - " + - url.toString() + " (" + - message + ")"); - } - - public void startDocumentLoad(String url) { - if (debug) - System.err.println(prefix + "start load - " + - url.toString()); - } - - public void endDocumentLoad(String url, int status, Document doc) { - if (debug) { - System.err.println(prefix + "end load - " + - url.toString() + " " + - Integer.toHexString(status)); - } - dumpDocument(url, doc); - //runTests(doc); - } - - private void dump(PrintStream ps, Node node, int indent, boolean isMapNode) { - if (node == null) return; - - ps.println(); - for (int i=0; i 0) { - ps.println(); - for (int i=0; i 0) { - ps.println(); - for (int i=0; i + + Java DOM Tests + + +
+In order to run tests you need to have a working java plugin for
+Mozilla browser and compliled Java DOM classes in your classpath.
+
+
+
+ + + + + diff --git a/java/dom/tests/src/testa.html b/java/dom/tests/src/applets/testa.html similarity index 88% rename from java/dom/tests/src/testa.html rename to java/dom/tests/src/applets/testa.html index 552ca9925c2b..0c5a8b742e8a 100644 --- a/java/dom/tests/src/testa.html +++ b/java/dom/tests/src/applets/testa.html @@ -1,5 +1,10 @@ - + + +DOMAccessor test + + +
 This should run DOMAccessor test.
 Look into the java plugin console for
diff --git a/java/dom/tests/src/applets/testb.html b/java/dom/tests/src/applets/testb.html
new file mode 100644
index 000000000000..f9299121cc3c
--- /dev/null
+++ b/java/dom/tests/src/applets/testb.html
@@ -0,0 +1,22 @@
+
+
+
+
+DOM API test runner
+
+
+
+This should run java dom api tests.
+TestRunnerApplet registers itself
+as a DocumentLoadListener via DOMAccessor
+and runs tests on endURLLoad notification and dumps
+test results into the java plugin console.
+
+
+	Your browser is completely ignoring the <APPLET> tag!
+
+
+
diff --git a/java/dom/tests/src/testb.html b/java/dom/tests/src/applets/testc.html
similarity index 54%
rename from java/dom/tests/src/testb.html
rename to java/dom/tests/src/applets/testc.html
index f78eecb73d1b..2b088a77610d 100644
--- a/java/dom/tests/src/testb.html
+++ b/java/dom/tests/src/applets/testc.html
@@ -1,13 +1,18 @@
 
-
+
+
+
+DOM tree dumper
+
+
 
-This should run DOMAccessor test.
-TestDOMAccessorApplet1 registers itself
+This should run DOMTreeDumper test.
+DOMTreeDumperApplet registers itself
 as a DocumentLoadListener via DOMAccessor
-and dumps load notifications and document 
-source into the java plugin console.
+and dumps document source into the 
+java plugin console.
 
-
diff --git a/java/dom/tests/src/applets/testd.html b/java/dom/tests/src/applets/testd.html
new file mode 100644
index 000000000000..5b79268175ef
--- /dev/null
+++ b/java/dom/tests/src/applets/testd.html
@@ -0,0 +1,23 @@
+
+
+
+
+DOM events test
+
+
+
+This should run DOM events test.
+TestDOMEvents registers itself
+as a DocumentLoadListener via DOMAccessor
+and adds DOM events listeners do loading 
+documents. DOM events info is dumped
+into the java plugin console.
+
+
+	Your browser is completely ignoring the <APPLET> tag!
+
+
+