mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
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.
This commit is contained in:
parent
90096e37f3
commit
19dc7352a7
@ -99,7 +99,7 @@ public final class DOMAccessor {
|
|||||||
|
|
||||||
private static native void register();
|
private static native void register();
|
||||||
private static native void unregister();
|
private static native void unregister();
|
||||||
private static native Node getNodeByHandle(long p);
|
public static native Node getNodeByHandle(long p);
|
||||||
private static native void doGC();
|
private static native void doGC();
|
||||||
|
|
||||||
public static native void initialize();
|
public static native void initialize();
|
||||||
|
@ -75,7 +75,7 @@ public class NodeImpl implements Node, EventTarget {
|
|||||||
static private Hashtable javaDOMlisteners = new Hashtable();
|
static private Hashtable javaDOMlisteners = new Hashtable();
|
||||||
|
|
||||||
// instantiated from JNI only
|
// instantiated from JNI only
|
||||||
protected NodeImpl() {}
|
protected NodeImpl() { }
|
||||||
protected NodeImpl(long p) {
|
protected NodeImpl(long p) {
|
||||||
p_nsIDOMNode = p;
|
p_nsIDOMNode = p;
|
||||||
}
|
}
|
||||||
@ -218,4 +218,41 @@ public class NodeImpl implements Node, EventTarget {
|
|||||||
public void normalize() {
|
public void normalize() {
|
||||||
throw new UnsupportedOperationException();
|
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();
|
||||||
|
}
|
||||||
|
****/
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package org.mozilla.webclient.impl.wrapper_native;
|
package org.mozilla.webclient.impl.wrapper_native;
|
||||||
|
|
||||||
|
|
||||||
import org.mozilla.util.Assert;
|
|
||||||
import org.mozilla.util.Log;
|
|
||||||
import org.mozilla.util.ParameterCheck;
|
import org.mozilla.util.ParameterCheck;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -42,6 +38,7 @@ import java.awt.event.MouseListener;
|
|||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import org.mozilla.dom.DOMAccessor;
|
||||||
|
|
||||||
import org.mozilla.webclient.BrowserControl;
|
import org.mozilla.webclient.BrowserControl;
|
||||||
import org.mozilla.webclient.BrowserControlCanvas;
|
import org.mozilla.webclient.BrowserControlCanvas;
|
||||||
@ -55,7 +52,7 @@ import org.mozilla.webclient.NewWindowListener;
|
|||||||
import org.mozilla.webclient.WebclientEvent;
|
import org.mozilla.webclient.WebclientEvent;
|
||||||
import org.mozilla.webclient.WCMouseEvent;
|
import org.mozilla.webclient.WCMouseEvent;
|
||||||
import org.mozilla.webclient.WebclientEventListener;
|
import org.mozilla.webclient.WebclientEventListener;
|
||||||
import org.mozilla.webclient.UnimplementedException;
|
import org.w3c.dom.Node;
|
||||||
|
|
||||||
public class EventRegistrationImpl extends ImplObjectNative implements EventRegistration2
|
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)
|
public void removeDocumentLoadListener(DocumentLoadListener listener)
|
||||||
{
|
{
|
||||||
ParameterCheck.nonNull(listener);
|
ParameterCheck.nonNull(listener);
|
||||||
@ -316,9 +319,20 @@ private EventObject createMouseEvent(long eventType, Object eventData) {
|
|||||||
WCMouseEvent mouseEvent = null;
|
WCMouseEvent mouseEvent = null;
|
||||||
Properties props = (Properties) eventData;
|
Properties props = (Properties) eventData;
|
||||||
int modifiers = 0, x = -1, y = -1, clickCount = 0;
|
int modifiers = 0, x = -1, y = -1, clickCount = 0;
|
||||||
|
Node domNode = null;
|
||||||
String str;
|
String str;
|
||||||
boolean bool;
|
boolean bool;
|
||||||
if (null != props) {
|
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"))) {
|
if (null != (str = props.getProperty("ClientX"))) {
|
||||||
x = Integer.valueOf(str).intValue();
|
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);
|
eventData);
|
||||||
switch ((int) eventType) {
|
switch ((int) eventType) {
|
||||||
case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK:
|
case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK:
|
||||||
@ -409,8 +430,19 @@ private EventObject createKeyEvent(long eventType, Object eventData) {
|
|||||||
int modifiers = 0, keyCode = 0;
|
int modifiers = 0, keyCode = 0;
|
||||||
char keyChar = 0;
|
char keyChar = 0;
|
||||||
String str;
|
String str;
|
||||||
|
Node domNode = null;
|
||||||
boolean bool;
|
boolean bool;
|
||||||
if (null != props) {
|
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"))) {
|
if (null != (str = props.getProperty("Button"))) {
|
||||||
int button = Integer.valueOf(str).intValue();
|
int button = Integer.valueOf(str).intValue();
|
||||||
if (1 == button) {
|
if (1 == button) {
|
||||||
@ -485,8 +517,15 @@ private EventObject createKeyEvent(long eventType, Object eventData) {
|
|||||||
" keyCode: " + keyCode +
|
" keyCode: " + keyCode +
|
||||||
" keyChar: " + keyChar);
|
" 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);
|
keyEvent);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
@ -150,11 +150,11 @@ public String toString()
|
|||||||
public Enumeration children()
|
public Enumeration children()
|
||||||
{
|
{
|
||||||
Assert.assert_it(-1 != nativeRDFNode);
|
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()
|
public boolean getAllowsChildren()
|
||||||
|
@ -356,6 +356,8 @@ nsresult EmbedEventListener::PopulatePropertiesFromEvent(nsIDOMEvent *event)
|
|||||||
}
|
}
|
||||||
mInverseDepth = 0;
|
mInverseDepth = 0;
|
||||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||||
|
char buf[20];
|
||||||
|
jstring strVal;
|
||||||
|
|
||||||
if (mProperties) {
|
if (mProperties) {
|
||||||
util_ClearPropertiesObject(env, mProperties, (jobject)
|
util_ClearPropertiesObject(env, mProperties, (jobject)
|
||||||
@ -368,6 +370,18 @@ nsresult EmbedEventListener::PopulatePropertiesFromEvent(nsIDOMEvent *event)
|
|||||||
return rv;
|
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,
|
dom_iterateToRoot(currentNode, EmbedEventListener::takeActionOnNode,
|
||||||
(void *)this);
|
(void *)this);
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ jobject BM_NAME_VALUE;
|
|||||||
jobject BM_URL_VALUE;
|
jobject BM_URL_VALUE;
|
||||||
jobject BM_DESCRIPTION_VALUE;
|
jobject BM_DESCRIPTION_VALUE;
|
||||||
jobject BM_IS_FOLDER_VALUE;
|
jobject BM_IS_FOLDER_VALUE;
|
||||||
|
jobject NODE_LONG_KEY;
|
||||||
|
|
||||||
|
|
||||||
jstring DOCUMENT_LOAD_LISTENER_CLASSNAME;
|
jstring DOCUMENT_LOAD_LISTENER_CLASSNAME;
|
||||||
@ -359,6 +360,11 @@ jboolean util_InitStringConstants()
|
|||||||
NEW_WINDOW_LISTENER_CLASSNAME_VALUE)))) {
|
NEW_WINDOW_LISTENER_CLASSNAME_VALUE)))) {
|
||||||
return JNI_FALSE;
|
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;
|
return STRING_CONSTANTS_INITED = JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,7 @@ extern jobject BM_NAME_VALUE;
|
|||||||
extern jobject BM_URL_VALUE;
|
extern jobject BM_URL_VALUE;
|
||||||
extern jobject BM_DESCRIPTION_VALUE;
|
extern jobject BM_DESCRIPTION_VALUE;
|
||||||
extern jobject BM_IS_FOLDER_VALUE;
|
extern jobject BM_IS_FOLDER_VALUE;
|
||||||
|
extern jobject NODE_LONG_KEY;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user