Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Webclient 2.0 status, ready to proceed with new development

0 views
Skip to first unread message

edburns

unread,
Aug 9, 2005, 2:53:15 AM8/9/05
to
Still trying to debug the mystery of why event listeners added via DOM
don't get fired. Posted to n.p.m.embedding. Here's a checkpoint diff.

Index: webclient/build-tests.xml
===================================================================
RCS file: /cvsroot/mozilla/java/webclient/build-tests.xml,v
retrieving revision 1.29
diff -u -r1.29 build-tests.xml
--- webclient/build-tests.xml 9 Aug 2005 04:43:00 -0000 1.29
+++ webclient/build-tests.xml 9 Aug 2005 06:52:17 -0000
@@ -161,6 +161,7 @@
<classpath refid="test.classpath"/>

<formatter type="plain" usefile="false"/>
+ <!--
<test
name="org.mozilla.webclient.BrowserControlFactoryTest"/>
<test name="org.mozilla.webclient.ProfileManagerTest"/>
<test name="org.mozilla.webclient.BookmarksTest"/>
@@ -173,8 +174,11 @@
<test name="org.mozilla.webclient.KeyListenerTest"/>
<test
name="org.mozilla.webclient.DocumentLoadListenerTest"/>
<test name="org.mozilla.webclient.WindowCreatorTest"/>
+ -->
<test name="org.mozilla.webclient.DOMTest"/>
+ <!--
<test name="org.mozilla.webclient.CurrentPageTest"/>
+ -->
<!-- non running
<test
name="org.mozilla.webclient.wrapper_native.gtk.TestGtkBrowserControlCanvas"/>
-->
Index:
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java
===================================================================
RCS file:
/cvsroot/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java,v
retrieving revision 1.14
diff -u -r1.14 EventRegistrationImpl.java
---
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java 18
Jan 2005 15:20:51 -0000 1.14
+++
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java 9
Aug 2005 06:52:17 -0000
@@ -169,6 +169,12 @@
}
}

+public void pushRunnable(Runnable runnable) {
+
+ NativeEventThread.instance.pushRunnable(runnable);
+
+}
+
public void removeDocumentLoadListener(DocumentLoadListener listener)
{
ParameterCheck.nonNull(listener);
Index:
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java
===================================================================
RCS file:
/cvsroot/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java,v
retrieving revision 1.1
diff -u -r1.1 RDFTreeNode.java
---
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java 28
Sep 2003 06:29:07 -0000 1.1
+++
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java 9
Aug 2005 06:52:18 -0000
@@ -150,11 +150,11 @@
public Enumeration children()
{
Assert.assert_it(-1 != nativeRDFNode);
- Enumeration enum = null;
+ Enumeration enumer = null;

- enum = new RDFEnumeration(nativeContext, this);
+ enumer = new RDFEnumeration(nativeContext, this);

- return enum;
+ return enumer;
}

public boolean getAllowsChildren()
Index:
webclient/test/automated/src/classes/org/mozilla/webclient/DOMTest.java
===================================================================
RCS file:
/cvsroot/mozilla/java/webclient/test/automated/src/classes/org/mozilla/webclient/DOMTest.java,v
retrieving revision 1.2
diff -u -r1.2 DOMTest.java
---
webclient/test/automated/src/classes/org/mozilla/webclient/DOMTest.java 14
Feb 2005 02:16:18 -0000 1.2
+++
webclient/test/automated/src/classes/org/mozilla/webclient/DOMTest.java 9
Aug 2005 06:52:19 -0000
@@ -29,17 +29,16 @@
import junit.framework.Test;
import junit.framework.TestSuite;

-import java.util.Enumeration;
-
import java.awt.Frame;
import java.awt.BorderLayout;
import java.awt.Robot;
-
-import java.io.File;
-import java.io.FileInputStream;
+import java.awt.event.InputEvent;

import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.w3c.dom.events.Event;
+import org.w3c.dom.events.EventListener;
+import org.w3c.dom.events.EventTarget;

// DOMTest.java

@@ -68,6 +67,12 @@
//
// Constants
//
+
+ static final int IN_X = 20;
+ static final int IN_Y = 117;
+
+ static final int OUT_X = 700;
+ static final int OUT_Y = 500;

//
// Testcases
@@ -132,6 +137,38 @@
assertEquals(1, node.getNodeType());
node = node.getFirstChild();
assertEquals("next", node.getNodeValue());
+
+ assertTrue(node instanceof EventTarget);
+ final EventTarget target = (EventTarget) node;
+ final EventListener domListener = new EventListener() {
+ public void handleEvent(Event event) {
+ System.out.println("got event:" + event.toString());
+ }
+ };
+ Runnable runnable = new Runnable() {
+ public void run() {
+ target.addEventListener("mouseover", domListener,
+ true);
+ }
+ };
+
((org.mozilla.webclient.impl.wrapper_native.EventRegistrationImpl)eventRegistration).pushRunnable(runnable);
+
+ /*********
+ Robot robot = new Robot();
+
+ robot.mouseMove(IN_X, IN_Y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+*************/
+
+ MouseListenerTest.keepWaiting = true;
+ while (MouseListenerTest.keepWaiting) {
+ Thread.currentThread().sleep(1000);
+ }
+
+ /*****
+ robot.mouseMove(OUT_X, OUT_Y);
+******/

frame.setVisible(false);
BrowserControlFactory.deleteBrowserControl(firstBrowserControl);

edburns

unread,
Aug 19, 2005, 1:14:05 AM8/19/05
to
This change-bundle solves the dom problem in a different way: by
allowing the standard java key and mouse event listeners to get access
to the dom Node that corresponds to that event. I have the Node
propagated out to the webclient level, but I need to push it all the
way
out so the client can access it.

Next step is to expose the dom Node to the standard java key and mouse
listeners, using test driven development techniques of course.

SECTION: Changes

M dom/classes/org/mozilla/dom/DOMAccessor.java

- make getNodeByHandle(long p) public so I can get the dom node for a
key or mouse event.

M dom/classes/org/mozilla/dom/NodeImpl.java

- added commented out methods for the Node in Java SE 5.0

M
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java

- Extract the dom Node that corresponds to a key or mouse event.

M
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java

- Don't use keyword enum, for Java SE 5.0

M webclient/src_moz/EmbedEventListener.cpp

- store the long into the properties.

M webclient/src_share/jni_util.cpp
M webclient/src_share/jni_util.h

- new constant, NodeLong.

SECTION: Diffs

Index: dom/classes/org/mozilla/dom/DOMAccessor.java
===================================================================
RCS file:
/cvsroot/mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java,v
retrieving revision 1.4
diff -u -r1.4 DOMAccessor.java
--- dom/classes/org/mozilla/dom/DOMAccessor.java 2 Nov 2000 23:32:06
-0000 1.4
+++ dom/classes/org/mozilla/dom/DOMAccessor.java 19 Aug 2005 05:12:17
-0000
@@ -99,7 +99,7 @@

private static native void register();
private static native void unregister();
- private static native Node getNodeByHandle(long p);
+ public static native Node getNodeByHandle(long p);
private static native void doGC();

public static native void initialize();
Index: dom/classes/org/mozilla/dom/NodeImpl.java
===================================================================
RCS file:
/cvsroot/mozilla/java/dom/classes/org/mozilla/dom/NodeImpl.java,v
retrieving revision 1.3
diff -u -r1.3 NodeImpl.java
--- dom/classes/org/mozilla/dom/NodeImpl.java 16 May 2001 21:13:33
-0000 1.3
+++ dom/classes/org/mozilla/dom/NodeImpl.java 19 Aug 2005 05:12:18
-0000
@@ -75,7 +75,7 @@
static private Hashtable javaDOMlisteners = new Hashtable();

// instantiated from JNI only
- protected NodeImpl() {}
+ protected NodeImpl() { }
protected NodeImpl(long p) {
p_nsIDOMNode = p;
}
@@ -218,4 +218,41 @@
public void normalize() {
throw new UnsupportedOperationException();
};
+
+ /**** level 3 methods
+public short compareDocumentPosition(Node other) {
+ throw new UnsupportedOperationException();
+}
+public String getBaseURI() {
+ throw new UnsupportedOperationException();
+}
+public Object getFeature(String feature, String version) {
+ throw new UnsupportedOperationException();
+}
+public Object getUserData(String key) {
+ throw new UnsupportedOperationException();
+}
+public boolean isDefaultNamespace(String namespaceURI) {
+ throw new UnsupportedOperationException();
+}
+public boolean isEqualNode(Node arg) {
+ throw new UnsupportedOperationException();
+}
+public boolean isSameNode(Node other) {
+ throw new UnsupportedOperationException();
}
+public String lookupNamespaceURI(String prefix) {
+ throw new UnsupportedOperationException();
+}
+public String lookupPrefix(String namespaceURI) {
+ throw new UnsupportedOperationException();
+}
+public void setTextContent(String textContent) {
+ throw new UnsupportedOperationException();
+}
+public Object setUserData(String key, Object data, UserDataHandler
handler) {
+ throw new UnsupportedOperationException();
+}
+****/
+}
+


Index:
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java
===================================================================
RCS file:
/cvsroot/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java,v
retrieving revision 1.14
diff -u -r1.14 EventRegistrationImpl.java
---
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java 18
Jan 2005 15:20:51 -0000 1.14
+++

webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java 19
Aug 2005 05:12:18 -0000
@@ -21,10 +21,6 @@
*/

package org.mozilla.webclient.impl.wrapper_native;
-
-
-import org.mozilla.util.Assert;
-import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;

import java.util.ArrayList;
@@ -42,6 +38,7 @@
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Component;
+import org.mozilla.dom.DOMAccessor;

import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserControlCanvas;
@@ -55,7 +52,7 @@
import org.mozilla.webclient.WebclientEvent;
import org.mozilla.webclient.WCMouseEvent;
import org.mozilla.webclient.WebclientEventListener;
-import org.mozilla.webclient.UnimplementedException;
+import org.w3c.dom.Node;

public class EventRegistrationImpl extends ImplObjectNative implements
EventRegistration2
{
@@ -169,6 +166,12 @@
}
}

+public void pushRunnable(Runnable runnable) {
+
+ NativeEventThread.instance.pushRunnable(runnable);
+
+}
+
public void removeDocumentLoadListener(DocumentLoadListener listener)
{
ParameterCheck.nonNull(listener);

@@ -316,9 +319,20 @@
WCMouseEvent mouseEvent = null;
Properties props = (Properties) eventData;
int modifiers = 0, x = -1, y = -1, clickCount = 0;
+ Node domNode = null;
String str;
boolean bool;
if (null != props) {
+ if (null != (str = props.getProperty("NodeLong"))) {
+ long nodeLong = -1;
+ try {
+ nodeLong = Long.valueOf(str).longValue();
+ }
+ catch (NumberFormatException nfe) {
+ throw new RuntimeException(nfe);
+ }
+ domNode = DOMAccessor.getNodeByHandle(nodeLong);
+ }
if (null != (str = props.getProperty("ClientX"))) {
x = Integer.valueOf(str).intValue();
}
@@ -365,7 +379,14 @@
}
}
}
- WebclientEvent event = new WebclientEvent(browserControlCanvas,
eventType,
+ Object source = null;
+ if (null != domNode) {
+ source = domNode;
+ }
+ else {
+ source = browserControlCanvas;
+ }
+ WebclientEvent event = new WebclientEvent(source, eventType,
eventData);
switch ((int) eventType) {
case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK:
@@ -409,8 +430,19 @@
int modifiers = 0, keyCode = 0;
char keyChar = 0;
String str;
+ Node domNode = null;
boolean bool;
if (null != props) {
+ if (null != (str = props.getProperty("NodeLong"))) {
+ long nodeLong = -1;
+ try {
+ nodeLong = Long.valueOf(str).longValue();
+ }
+ catch (NumberFormatException nfe) {
+ throw new RuntimeException(nfe);
+ }
+ domNode = DOMAccessor.getNodeByHandle(nodeLong);
+ }
if (null != (str = props.getProperty("Button"))) {
int button = Integer.valueOf(str).intValue();
if (1 == button) {
@@ -485,8 +517,15 @@
" keyCode: " + keyCode +
" keyChar: " + keyChar);
}
+ Object source = null;
+ if (null != domNode) {
+ source = domNode;
+ }
+ else {
+ source = browserControlCanvas;
+ }

- WebclientEvent event = new WebclientEvent(browserControlCanvas,
eventType,
+ WebclientEvent event = new WebclientEvent(source, eventType,
keyEvent);
return event;


}
Index:
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java
===================================================================
RCS file:
/cvsroot/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java,v
retrieving revision 1.1
diff -u -r1.1 RDFTreeNode.java
---
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java 28
Sep 2003 06:29:07 -0000 1.1
+++

webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java 19
Aug 2005 05:12:19 -0000


@@ -150,11 +150,11 @@
public Enumeration children()
{
Assert.assert_it(-1 != nativeRDFNode);
- Enumeration enum = null;
+ Enumeration enumer = null;

- enum = new RDFEnumeration(nativeContext, this);
+ enumer = new RDFEnumeration(nativeContext, this);

- return enum;
+ return enumer;
}

public boolean getAllowsChildren()
Index: webclient/src_moz/EmbedEventListener.cpp
===================================================================
RCS file:
/cvsroot/mozilla/java/webclient/src_moz/EmbedEventListener.cpp,v
retrieving revision 1.6
diff -u -r1.6 EmbedEventListener.cpp
--- webclient/src_moz/EmbedEventListener.cpp 13 May 2005 06:40:11
-0000 1.6
+++ webclient/src_moz/EmbedEventListener.cpp 19 Aug 2005 05:12:19 -0000
@@ -356,6 +356,8 @@
}
mInverseDepth = 0;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
+ char buf[20];
+ jstring strVal;

if (mProperties) {
util_ClearPropertiesObject(env, mProperties, (jobject)
@@ -368,6 +370,18 @@
return rv;
}
}
+
+ // Store a Long into the properties under the key: NODE_LONG_KEY
+ jlong longVal = (jlong) currentNode.get();
+ WC_ITOA(longVal, buf, 10);
+ strVal = ::util_NewStringUTF(env, buf);
+
+ ::util_StoreIntoPropertiesObject(env, mProperties, NODE_LONG_KEY,
+ (jobject) strVal,
+ (jobject)
+ &(mOwner->GetWrapperFactory()->shareContext));
+
+ // populate the properties table with information about the node
dom_iterateToRoot(currentNode,
EmbedEventListener::takeActionOnNode,
(void *)this);

Index: webclient/src_share/jni_util.cpp
===================================================================
RCS file: /cvsroot/mozilla/java/webclient/src_share/jni_util.cpp,v
retrieving revision 1.17
diff -u -r1.17 jni_util.cpp
--- webclient/src_share/jni_util.cpp 28 Feb 2005 17:15:44 -0000 1.17
+++ webclient/src_share/jni_util.cpp 19 Aug 2005 05:12:20 -0000
@@ -86,6 +86,7 @@
jobject BM_URL_VALUE;
jobject BM_DESCRIPTION_VALUE;
jobject BM_IS_FOLDER_VALUE;
+jobject NODE_LONG_KEY;


jstring DOCUMENT_LOAD_LISTENER_CLASSNAME;
@@ -359,6 +360,11 @@

NEW_WINDOW_LISTENER_CLASSNAME_VALUE)))) {
return JNI_FALSE;
}
+ if (nsnull == (NODE_LONG_KEY =
+ ::util_NewGlobalRef(env, (jobject)
+ ::util_NewStringUTF(env,
"NodeLong")))) {
+ return JNI_FALSE;
+ }

return STRING_CONSTANTS_INITED = JNI_TRUE;
}
Index: webclient/src_share/jni_util.h
===================================================================
RCS file: /cvsroot/mozilla/java/webclient/src_share/jni_util.h,v
retrieving revision 1.14
diff -u -r1.14 jni_util.h
--- webclient/src_share/jni_util.h 28 Feb 2005 17:15:44 -0000 1.14
+++ webclient/src_share/jni_util.h 19 Aug 2005 05:12:20 -0000
@@ -101,6 +101,7 @@
extern jobject BM_URL_VALUE;
extern jobject BM_DESCRIPTION_VALUE;
extern jobject BM_IS_FOLDER_VALUE;
+extern jobject NODE_LONG_KEY;


/**

edb...@yahoo.com

unread,
Aug 20, 2005, 8:06:52 PM8/20/05
to
Expose the dom Node to the standard java key and mouse
listeners.

Next step is to update the test browser to use this feature.

SECTION:

A webclient/classes_spec/org/mozilla/webclient/WCKeyEvent.java

- KeyEvent subclass to expose WebclientEvent, and allow access to the
Source property, which is a dom Node

M
webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java

- change to handle WCKeyEvent

M
webclient/test/automated/src/classes/org/mozilla/webclient/KeyListenerTest.java
M
webclient/test/automated/src/classes/org/mozilla/webclient/MouseListenerTest.java

- new test content

M webclient/test/automated/src/test/KeyListenerTest1.html

- add id attribute

0 new messages