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. git-svn-id: svn://10.0.0.236/trunk@178227 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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.MouseListener;
|
||||
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.NewWindowListener;
|
||||
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 addDocumentLoadListener(DocumentLoadListener listener)
|
||||
}
|
||||
}
|
||||
|
||||
public void pushRunnable(Runnable runnable) {
|
||||
|
||||
NativeEventThread.instance.pushRunnable(runnable);
|
||||
|
||||
}
|
||||
|
||||
public void removeDocumentLoadListener(DocumentLoadListener listener)
|
||||
{
|
||||
ParameterCheck.nonNull(listener);
|
||||
@@ -316,9 +319,20 @@ private EventObject createMouseEvent(long eventType, Object eventData) {
|
||||
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 @@ private EventObject createMouseEvent(long eventType, Object eventData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
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 @@ private EventObject createKeyEvent(long eventType, Object eventData) {
|
||||
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 @@ private EventObject createKeyEvent(long eventType, Object eventData) {
|
||||
" 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;
|
||||
}
|
||||
|
||||
@@ -150,11 +150,11 @@ public String toString()
|
||||
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()
|
||||
|
||||
@@ -356,6 +356,8 @@ nsresult EmbedEventListener::PopulatePropertiesFromEvent(nsIDOMEvent *event)
|
||||
}
|
||||
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 @@ nsresult EmbedEventListener::PopulatePropertiesFromEvent(nsIDOMEvent *event)
|
||||
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);
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ jobject BM_NAME_VALUE;
|
||||
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 @@ jboolean util_InitStringConstants()
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ extern jobject BM_NAME_VALUE;
|
||||
extern jobject BM_URL_VALUE;
|
||||
extern jobject BM_DESCRIPTION_VALUE;
|
||||
extern jobject BM_IS_FOLDER_VALUE;
|
||||
extern jobject NODE_LONG_KEY;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user