Re: Webclient 2.0 status, ready to proceed with new development
"edburns" <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
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;
/**