diff --git a/mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java b/mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java index e219239e3dc..a7b3a35dfbd 100644 --- a/mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java +++ b/mozilla/java/dom/classes/org/mozilla/dom/DOMAccessor.java @@ -99,7 +99,7 @@ public final class DOMAccessor { 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(); diff --git a/mozilla/java/dom/classes/org/mozilla/dom/NodeImpl.java b/mozilla/java/dom/classes/org/mozilla/dom/NodeImpl.java index 0a5488d72fb..8c775aed588 100644 --- a/mozilla/java/dom/classes/org/mozilla/dom/NodeImpl.java +++ b/mozilla/java/dom/classes/org/mozilla/dom/NodeImpl.java @@ -75,7 +75,7 @@ public class NodeImpl implements Node, EventTarget { 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 class NodeImpl implements Node, EventTarget { 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(); +} +****/ +} + diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java index ba3aa899ead..419d42f33e7 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java @@ -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; } diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java index e4f94665d5b..2e2bb97cffb 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFTreeNode.java @@ -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() diff --git a/mozilla/java/webclient/src_moz/EmbedEventListener.cpp b/mozilla/java/webclient/src_moz/EmbedEventListener.cpp index 144307bd296..759ada7d960 100644 --- a/mozilla/java/webclient/src_moz/EmbedEventListener.cpp +++ b/mozilla/java/webclient/src_moz/EmbedEventListener.cpp @@ -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); diff --git a/mozilla/java/webclient/src_share/jni_util.cpp b/mozilla/java/webclient/src_share/jni_util.cpp index 9a88f6a0f54..6843280a6e6 100644 --- a/mozilla/java/webclient/src_share/jni_util.cpp +++ b/mozilla/java/webclient/src_share/jni_util.cpp @@ -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; } diff --git a/mozilla/java/webclient/src_share/jni_util.h b/mozilla/java/webclient/src_share/jni_util.h index 7cccdd644fa..8fdfb4f51a2 100644 --- a/mozilla/java/webclient/src_share/jni_util.h +++ b/mozilla/java/webclient/src_share/jni_util.h @@ -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; /**