diff --git a/java/dom/README b/java/dom/README index 94a15651bb4..8a97f169c3c 100644 --- a/java/dom/README +++ b/java/dom/README @@ -51,11 +51,37 @@ $MOZILLA_FIVE_HOME/classes *.java in the java/dom/jni directory. I chose to put my class files in $MOZILLA_FIVE_HOME/classes, you can put them elsewhere, just make sure it is in the CLASSPATH. -You will also need to get the w3c DOM interfaces from -http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/java-binding.zip +You will also need to get the w3c DOM level 2 interfaces from +http://www.w3.org/TR/1999/WD-DOM-Level-2-19990923/java-binding.zip and put the class files in your CLASSPATH. +DOM2 events +------------ + +At the moment all DOM2 event-related interfaces are present +however they are not fully implemented yet +because Mozilla's core DOM does not support DOM2 events fully. +Consequences: + - some methods throws OperationUnsupportedException() + - Some of key codes defined at DOM2 specs are never returned + (they are not supported by core DOM) + +The basic implementation architecture is following: + - NodeImpl is extended to support EventTarget interface + - for every addEventListener call special NativeDOMProxyListener object is + created and is registered with Mozilla's DOM + It's task is to propagate event notifications from Mozilla's DOM + to target Java EventListener + - In order to sucessfully unregister EventListeners we need to + save association between java EventListener and corresponding + NativeDOMProxyListener object. This is done by storing such + associations Vector at NodeImpl + - javaDOMEventsGlobals class is used much like javaDOMGlobals for caching + (this code may be moved to javaDOMGlobals) + + + NSPR Logging ------------ @@ -102,4 +128,4 @@ Java2-specific, and it works with JDK1.1.x too (I have been using JDK References ---------- -I highly recommend reading Sheng Liang's new JNI book. \ No newline at end of file +I highly recommend reading Sheng Liang's new JNI book. diff --git a/java/dom/jni/AttrImpl.java b/java/dom/jni/AttrImpl.java index 8a43dd251f2..abbbd9889b0 100644 --- a/java/dom/jni/AttrImpl.java +++ b/java/dom/jni/AttrImpl.java @@ -17,6 +17,7 @@ Inc. All Rights Reserved. package org.mozilla.dom; import org.w3c.dom.Attr; +import org.w3c.dom.Element; public class AttrImpl extends NodeImpl implements Attr { @@ -27,4 +28,13 @@ public class AttrImpl extends NodeImpl implements Attr { public native boolean getSpecified(); public native String getValue(); public native void setValue(String value); + + /** + * The Element node this attribute is attached to or + * null if this attribute is not in use. + * @since DOM Level 2 + */ + public Element getOwnerElement() { + throw new UnsupportedOperationException(); + } } diff --git a/java/dom/jni/DOMImplementationImpl.java b/java/dom/jni/DOMImplementationImpl.java index 509994239ed..a57f53056ef 100644 --- a/java/dom/jni/DOMImplementationImpl.java +++ b/java/dom/jni/DOMImplementationImpl.java @@ -17,6 +17,9 @@ Inc. All Rights Reserved. package org.mozilla.dom; import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.DocumentType; +import org.w3c.dom.DOMException; public class DOMImplementationImpl implements DOMImplementation { @@ -42,4 +45,17 @@ public class DOMImplementationImpl implements DOMImplementation { private native boolean XPCOM_equals(Object o); private native int XPCOM_hashCode(); + + //since DOM2 + public DocumentType createDocumentType(String qualifiedName, String publicID, String systemID) { + throw new UnsupportedOperationException(); + } + + public Document createDocument(String namespaceURI, + String qualifiedName, + DocumentType doctype) throws DOMException { + throw new UnsupportedOperationException(); + } + + } diff --git a/java/dom/jni/DocumentImpl.java b/java/dom/jni/DocumentImpl.java index 8eb29c25cf7..e8eb56fbaae 100644 --- a/java/dom/jni/DocumentImpl.java +++ b/java/dom/jni/DocumentImpl.java @@ -26,10 +26,14 @@ import org.w3c.dom.EntityReference; import org.w3c.dom.ProcessingInstruction; import org.w3c.dom.Text; import org.w3c.dom.DocumentType; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.DOMImplementation; +import org.w3c.dom.events.DocumentEvent; +import org.w3c.dom.events.Event; +import org.w3c.dom.DOMException; -public class DocumentImpl extends NodeImpl implements Document { +public class DocumentImpl extends NodeImpl implements Document, DocumentEvent { // instantiated from JNI only private DocumentImpl() {} @@ -52,8 +56,31 @@ public class DocumentImpl extends NodeImpl implements Document { private static native void initialize(); + + public Event createEvent(String type) throws DOMException { + throw new UnsupportedOperationException(); + } + static { System.loadLibrary("javadomjni"); initialize(); } + + public Node importNode(Node importedNode, boolean deep) throws DOMException { + throw new UnsupportedOperationException(); + } + + public Element createElementNS(String namespaceURI, String qualifiedName) + throws DOMException { + throw new UnsupportedOperationException(); + } + + public Attr createAttributeNS(String namespaceURI, String qualifiedName) + throws DOMException { + throw new UnsupportedOperationException(); + } + + public NodeList getElementsByTagNameNS(String namespaceURI, String localName) { + throw new UnsupportedOperationException(); + } } diff --git a/java/dom/jni/DocumentTypeImpl.java b/java/dom/jni/DocumentTypeImpl.java index 5cb50cd56ec..6b7dfd79291 100644 --- a/java/dom/jni/DocumentTypeImpl.java +++ b/java/dom/jni/DocumentTypeImpl.java @@ -27,4 +27,13 @@ public class DocumentTypeImpl extends NodeImpl implements DocumentType { public native String getName(); public native NamedNodeMap getEntities(); public native NamedNodeMap getNotations(); + + //since DOM level 2 + public String getPublicID() { + throw new UnsupportedOperationException(); + } + + public String getSystemID() { + throw new UnsupportedOperationException(); + } } diff --git a/java/dom/jni/ElementImpl.java b/java/dom/jni/ElementImpl.java index c81b14268b6..a6c2d8ee140 100644 --- a/java/dom/jni/ElementImpl.java +++ b/java/dom/jni/ElementImpl.java @@ -19,6 +19,7 @@ package org.mozilla.dom; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import org.w3c.dom.DOMException; public class ElementImpl extends NodeImpl implements Element { @@ -34,4 +35,32 @@ public class ElementImpl extends NodeImpl implements Element { public native Attr removeAttributeNode(Attr oldAttr); public native void setAttribute(String name, String value); public native Attr setAttributeNode(Attr newAttr); + + //since DOM2 + public String getAttributeNS(String namespaceURI, String localName) { + throw new UnsupportedOperationException(); + } + + public void setAttributeNS(String namespaceURI, String localName, + String value) throws DOMException { + throw new UnsupportedOperationException(); + } + + public void removeAttributeNS(String namespacURI, String localName) + throws DOMException { + throw new UnsupportedOperationException(); + } + + public Attr getAttributeNodeNS(String namespaceURI, String localName) { + throw new UnsupportedOperationException(); + } + + public Attr setAttributeNodeNS(Attr newAttr) throws DOMException { + throw new UnsupportedOperationException(); + } + + public NodeList getElementsByTagNameNS(String namespaceURI, String localName) { + throw new UnsupportedOperationException(); + } + } diff --git a/java/dom/jni/EventImpl.java b/java/dom/jni/EventImpl.java new file mode 100644 index 00000000000..517e9b99505 --- /dev/null +++ b/java/dom/jni/EventImpl.java @@ -0,0 +1,141 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +package org.mozilla.dom.events; + +import org.w3c.dom.Node; +import org.w3c.dom.events.Event; +import org.w3c.dom.events.EventTarget; + +/** + * The Event interface is used to provide contextual information + * about an event to the handler processing the event. An object which + * implements the Event interface is generally passed as the + * first parameter to an event handler. More specific context information + * is passed to event handlers by deriving additional interfaces from + * Event which contain information directly relating to the type + * of event they accompany. These derived interfaces are also implemented by + * the object passed to the event listener. + * @since DOM Level 2 + */ +public class EventImpl implements Event { + + protected long p_nsIDOMEvent = 0; + + // instantiated from JNI only + protected EventImpl() {} + + public String toString() { + return ""; + } + + /** + * The type property represents the event name as a string + * property. + */ + public native String getType(); + + /** + * The target property indicates the EventTarget + * to which the event was originally dispatched. + */ + public native EventTarget getTarget(); + + /** + * The currentNode property indicates the Node + * whose EventListeners are currently being processed. This + * is particularly useful during capturing and bubbling. + */ + public native Node getCurrentNode(); + + /** + * The eventPhase property indicates which phase of event flow + * is currently being evaluated. + */ + public native short getEventPhase(); + + /** + * The bubbles property indicates whether or not an event is a + * bubbling event. If the event can bubble the value is true, else the + * value is false. + */ + public boolean getBubbles() { + throw new UnsupportedOperationException(); + } + + /** + * The cancelable property indicates whether or not an event + * can have its default action prevented. If the default action can be + * prevented the value is true, else the value is false. + */ + public boolean getCancelable() { + throw new UnsupportedOperationException(); + } + + /** + * The preventBubble method is used to end the bubbling phase + * of event flow. If this method is called by any + * EventListeners registered on the same + * EventTarget during bubbling, the bubbling phase will cease + * at that level and the event will not be propagated upward within the + * tree. + */ + public native void preventBubble(); + + /** + * The preventCapture method is used to end the capturing phase + * of event flow. If this method is called by any + * EventListeners registered on the same + * EventTarget during capturing, the capturing phase will + * cease at that level and the event will not be propagated any further + * down. + */ + public native void preventCapture(); + + /** + * If an event is cancelable, the preventCapture method is used + * to signify that the event is to be canceled, meaning any default action + * normally taken by the implementation as a result of the event will not + * occur. If, during any stage of event flow, the + * preventDefault method is called the event is canceled. Any + * default action associated with the event will not occur. Calling this + * method for a non-cancelable event has no effect. Once + * preventDefault has been called it will remain in effect + * throughout the remainder of the event's propagation. + */ + public native void preventDefault(); + + /** + * + * @param eventTypeArg Specifies the event type. This type may be any event + * type currently defined in this specification or a new event type. Any + * new event type must not begin with any upper, lower, or mixed case + * version of the string "DOM". This prefix is reserved for future DOM + * event sets. + * @param canBubbleArg Specifies whether or not the event can bubble. + * @param cancelableArg Specifies whether or not the event's default action + * can be prevented. + */ + public void initEvent(String eventTypeArg, + boolean canBubbleArg, + boolean cancelableArg) { + throw new UnsupportedOperationException(); + } +} + diff --git a/java/dom/jni/KeyEventImpl.java b/java/dom/jni/KeyEventImpl.java new file mode 100644 index 00000000000..dbb5123f7ce --- /dev/null +++ b/java/dom/jni/KeyEventImpl.java @@ -0,0 +1,116 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +package org.mozilla.dom.events; + +import org.w3c.dom.events.KeyEvent; +import org.w3c.dom.views.AbstractView; +import org.mozilla.dom.events.UIEventImpl; + +/** + * The KeyEvent interface provides specific contextual + * information associated with Key events. + * @since DOM Level 2 + */ +public class KeyEventImpl extends UIEventImpl implements KeyEvent { + + // instantiated from JNI only + protected KeyEventImpl() {} + + public String toString() { + return ""; + } + + /** + * ctrlKey indicates whether the 'ctrl' key was depressed + * during the firing of the event. + */ + public native boolean getCtrlKey(); + + /** + * shiftKey indicates whether the 'shift' key was depressed + * during the firing of the event. + */ + public native boolean getShiftKey(); + + /** + * altKey indicates whether the 'alt' key was depressed during + * the firing of the event. On some platforms this key may map to an + * alternative key name. + */ + public native boolean getAltKey(); + + /** + * metaKey indicates whether the 'meta' key was depressed + * during the firing of the event. On some platforms this key may map to + * an alternative key name. + */ + public native boolean getMetaKey(); + + /** + * The value of keyCode holds the virtual key code value of + * the key which was depressed if the event is a key event. Otherwise, the + * value is zero. + */ + public native int getKeyCode(); + + /** + * charCode holds the value of the Unicode character + * associated with the depressed key if the event is a key event. + * Otherwise, the value is zero. + */ + public native int getCharCode(); + + /** + * + * @param typeArg Specifies the event type. + * @param canBubbleArg Specifies whether or not the event can bubble. + * @param cancelableArg Specifies whether or not the event's default action + * can be prevent. + * @param ctrlKeyArg Specifies whether or not control key was depressed + * during the Event. + * @param altKeyArg Specifies whether or not alt key was depressed during + * the Event. + * @param shiftKeyArg Specifies whether or not shift key was depressed + * during the Event. + * @param metaKeyArg Specifies whether or not meta key was depressed during + * the Event. + * @param keyCodeArg Specifies the Event's keyCode + * @param charCodeArg Specifies the Event's + * charCode + * @param viewArg Specifies the Event's + * AbstractView. + */ + + public void initKeyEvent(String typeArg, + boolean canBubbleArg, + boolean cancelableArg, + boolean ctrlKeyArg, + boolean altKeyArg, + boolean shiftKeyArg, + boolean metaKeyArg, + int keyCodeArg, + int charCodeArg, + AbstractView viewArg) { + throw new UnsupportedOperationException(); + } +} + diff --git a/java/dom/jni/Makefile b/java/dom/jni/Makefile index d8b52510572..81836e97d95 100644 --- a/java/dom/jni/Makefile +++ b/java/dom/jni/Makefile @@ -15,8 +15,8 @@ DEPTH = ../../.. topsrcdir = $(DEPTH) -srcdir = . -VPATH = . +srcdir = $(topsrcdir)/java/dom/jni +VPATH = $(topsrcdir)/java/dom/jni include $(DEPTH)/config/autoconf.mk @@ -24,6 +24,8 @@ LIBRARY_NAME = javadomjni CPPSRCS = \ javaDOMGlobals.cpp \ + javaDOMEventsGlobals.cpp \ + nativeDOMProxyListener.cpp \ org_mozilla_dom_DOMGarbageCollector.cpp \ org_mozilla_dom_DOMAccessorImpl.cpp \ org_mozilla_dom_AttrImpl.cpp \ @@ -38,8 +40,15 @@ CPPSRCS = \ org_mozilla_dom_NodeListImpl.cpp \ org_mozilla_dom_NotationImpl.cpp \ org_mozilla_dom_ProcessingInstructionImpl.cpp \ - org_mozilla_dom_TextImpl.cpp + org_mozilla_dom_TextImpl.cpp \ + org_mozilla_dom_events_EventImpl.cpp \ + org_mozilla_dom_events_UIEventImpl.cpp \ + org_mozilla_dom_events_MouseEventImpl.cpp \ + org_mozilla_dom_events_KeyEventImpl.cpp include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/rules.mk + +classes: + javac -d $(topsrcdir)/dist/classes *.java diff --git a/java/dom/jni/MouseEventImpl.java b/java/dom/jni/MouseEventImpl.java new file mode 100644 index 00000000000..ed24f092fa8 --- /dev/null +++ b/java/dom/jni/MouseEventImpl.java @@ -0,0 +1,158 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +package org.mozilla.dom.events; + +import org.w3c.dom.Node; +import org.w3c.dom.views.AbstractView; +import org.w3c.dom.events.MouseEvent; + +/** + * The MouseEvent interface provides specific contextual + * information associated with Mouse events. + *

The detail attribute inherited from UIEvent + * indicates the number of times a mouse button has been pressed and released + * over the same screen location during a user action. The attribute value + * is 1 when the user begins this action and increments by 1 for each full + * sequence of pressing and releasing. If the user moves the mouse between + * the mousedown and mouseup the value will be set to 0, indicating that no + * click is occurring. + * @since DOM Level 2 + */ +public class MouseEventImpl extends UIEventImpl implements MouseEvent { + + // instantiated from JNI only + private MouseEventImpl() {} + + public String toString() { + return ""; + } + + /** + * screenX indicates the horizontal coordinate at which the + * event occurred in relative to the origin of the screen coordinate system. + */ + public native int getScreenX(); + + /** + * screenY indicates the vertical coordinate at which the event + * occurred relative to the origin of the screen coordinate system. + */ + public native int getScreenY(); + + /** + * clientX indicates the horizontal coordinate at which the + * event occurred relative to the DOM implementation's client area. + */ + public native int getClientX(); + + /** + * clientY indicates the vertical coordinate at which the event + * occurred relative to the DOM implementation's client area. + */ + public native int getClientY(); + + /** + * ctrlKey indicates whether the 'ctrl' key was depressed + * during the firing of the event. + */ + public native boolean getCtrlKey(); + + /** + * shiftKey indicates whether the 'shift' key was depressed + * during the firing of the event. + */ + public native boolean getShiftKey(); + + /** + * altKey indicates whether the 'alt' key was depressed during + * the firing of the event. On some platforms this key may map to an + * alternative key name. + */ + public native boolean getAltKey(); + + /** + * metaKey indicates whether the 'meta' key was depressed + * during the firing of the event. On some platforms this key may map to + * an alternative key name. + */ + public native boolean getMetaKey(); + + /** + * During mouse events caused by the depression or release of a mouse + * button, button is used to indicate which mouse button + * changed state. + */ + public native short getButton(); + + /** + * relatedNode is used to identify a secondary node related to + * a UI event. + */ + public Node getRelatedNode() { + throw new UnsupportedOperationException(); + } + + /** + * + * @param typeArg Specifies the event type. + * @param canBubbleArg Specifies whether or not the event can bubble. + * @param cancelableArg Specifies whether or not the event's default action + * can be prevent. + * @param viewArg Specifies the Event's + * AbstractView. + * @param detailArg Specifies the Event's mouse click count. + * @param screenXArg Specifies the Event's screen x coordinate + * @param screenYArg Specifies the Event's screen y coordinate + * @param clientXArg Specifies the Event's client x coordinate + * @param clientYArg Specifies the Event's client y coordinate + * @param ctrlKeyArg Specifies whether or not control key was depressed + * during the Event. + * @param altKeyArg Specifies whether or not alt key was depressed during + * the Event. + * @param shiftKeyArg Specifies whether or not shift key was depressed + * during the Event. + * @param metaKeyArg Specifies whether or not meta key was depressed during + * the Event. + * @param buttonArg Specifies the Event's mouse button. + * @param relatedNodeArg Specifies the Event's related Node. + */ + public void initMouseEvent(String typeArg, + boolean canBubbleArg, + boolean cancelableArg, + AbstractView viewArg, + short detailArg, + int screenXArg, + int screenYArg, + int clientXArg, + int clientYArg, + boolean ctrlKeyArg, + boolean altKeyArg, + boolean shiftKeyArg, + boolean metaKeyArg, + short buttonArg, + Node relatedNodeArg) { + throw new UnsupportedOperationException(); + } +} + diff --git a/java/dom/jni/MutationEventImpl.java b/java/dom/jni/MutationEventImpl.java new file mode 100644 index 00000000000..9df0868f5a5 --- /dev/null +++ b/java/dom/jni/MutationEventImpl.java @@ -0,0 +1,84 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +package org.mozilla.dom.events; + +import org.w3c.dom.Node; +import org.w3c.dom.events.MutationEvent; +import org.mozilla.dom.events.EventImpl; + +public class MutationEventImpl extends EventImpl implements MutationEvent { + /** + * relatedNode is used to identify a secondary node related to + * a mutation event. For example, if a mutation event is dispatched to a + * node indicating that its parent has changed, the relatedNode + * is the changed parent. If an event is instead dispatch to a subtree + * indicating a node was changed within it, the relatedNode is + * the changed node. + */ + public Node getRelatedNode() { + throw new UnsupportedOperationException(); + } + + /** + * prevValue indicates the previous value of text nodes and + * attributes in attrModified and charDataModified events. + */ + public String getPrevValue() { + throw new UnsupportedOperationException(); + } + + /** + * newValue indicates the new value of text nodes and + * attributes in attrModified and charDataModified events. + */ + public String getNewValue() { + throw new UnsupportedOperationException(); + } + + /** + * attrName indicates the changed attr in the attrModified + * event. + */ + public String getAttrName() { + throw new UnsupportedOperationException(); + } + + /** + * + * @param typeArg Specifies the event type. + * @param canBubbleArg Specifies whether or not the event can bubble. + * @param cancelableArg Specifies whether or not the event's default action + * can be prevent. + * @param relatedNodeArg Specifies the Event's related Node + * @param prevValueArg Specifies the Event's + * prevValue property + * @param newValueArg Specifies the Event's + * newValue property + * @param attrNameArg Specifies the Event's + * attrName property + */ + public void initMutationEvent(String typeArg, + boolean canBubbleArg, + boolean cancelableArg, + Node relatedNodeArg, + String prevValueArg, + String newValueArg, + String attrNameArg) { + throw new UnsupportedOperationException(); + } +} + diff --git a/java/dom/jni/NamedNodeMapImpl.java b/java/dom/jni/NamedNodeMapImpl.java index 1ded3d18619..aa7061d57d7 100644 --- a/java/dom/jni/NamedNodeMapImpl.java +++ b/java/dom/jni/NamedNodeMapImpl.java @@ -18,6 +18,7 @@ package org.mozilla.dom; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; +import org.w3c.dom.DOMException; public class NamedNodeMapImpl extends NodeImpl implements NamedNodeMap { @@ -29,4 +30,14 @@ public class NamedNodeMapImpl extends NodeImpl implements NamedNodeMap { public native Node item(int index); public native Node removeNamedItem(String name); public native Node setNamedItem(Node arg); + + + public Node getNamedItemNS(String namespaceURI, String localName) { + throw new UnsupportedOperationException(); + } + + public Node removeNamedItemNS(String namespaceURI, String name) + throws DOMException { + throw new UnsupportedOperationException(); + } } diff --git a/java/dom/jni/NodeImpl.java b/java/dom/jni/NodeImpl.java index 6b3a5105df4..b2e1729580d 100644 --- a/java/dom/jni/NodeImpl.java +++ b/java/dom/jni/NodeImpl.java @@ -20,8 +20,42 @@ import org.w3c.dom.Node; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NodeList; import org.w3c.dom.Document; +import org.w3c.dom.DOMException; +import org.w3c.dom.events.Event; +import org.w3c.dom.events.EventTarget; +import org.w3c.dom.events.EventListener; +import java.util.Vector; -public class NodeImpl implements Node { +class NodeEventListener { + EventListener listener = null; + String type = null; + boolean useCapture = false; + long nativeListener = 0; + + NodeEventListener(String aType, EventListener aListener, + boolean aUseCapture, long aNativeListener) { + type = aType; + listener = aListener; + useCapture = aUseCapture; + nativeListener = aNativeListener; + } + + public boolean equals(Object o) { + if (!(o instanceof NodeEventListener)) + return false; + else { + NodeEventListener n = (NodeEventListener) o; + if ((useCapture != n.useCapture) + || (type == null) || !type.equals(n.type) + || (listener == null) || !listener.equals(n.listener)) + return false; + else + return true; + } + } +} + +public class NodeImpl implements Node, EventTarget { /* The derived classes (Attr, CharacterData, DocumentFragment, Document, Element, EntityReference, NamedNodeMap, @@ -30,6 +64,9 @@ public class NodeImpl implements Node { private long p_nsIDOMNode = 0; + // associated DOMEventListeners + private Vector listeners = null; + // instantiated from JNI only protected NodeImpl() {} @@ -69,7 +106,7 @@ public class NodeImpl implements Node { return "ERROR"; } - public native Node appendChild(Node newChild); + public native Node appendChild(Node newChild) throws DOMException; public native Node cloneNode(boolean deep); public native NamedNodeMap getAttributes(); public native NodeList getChildNodes(); @@ -83,13 +120,84 @@ public class NodeImpl implements Node { public native Node getParentNode(); public native Node getPreviousSibling(); public native boolean hasChildNodes(); - public native Node insertBefore(Node newChild, Node refChild); - public native Node removeChild(Node oldChild); - public native Node replaceChild(Node newChild, Node oldChild); + public native Node insertBefore(Node newChild, Node refChild) throws DOMException; + public native Node removeChild(Node oldChild) throws DOMException; + public native Node replaceChild(Node newChild, Node oldChild) throws DOMException; public native void setNodeValue(String nodeValue); protected native void finalize(); private native boolean XPCOM_equals(Object o); private native int XPCOM_hashCode(); + + //since DOM level 2 + public boolean supports(String feature, String version) { + throw new UnsupportedOperationException(); + } + + public String getNamespaceURI() { + throw new UnsupportedOperationException(); + } + + public String getPrefix() { + throw new UnsupportedOperationException(); + } + + public void setPrefix(String prefix) throws DOMException { + throw new UnsupportedOperationException(); + } + + public String getLocalName() { + throw new UnsupportedOperationException(); + } + + public void addEventListener(String type, + EventListener listener, + boolean useCapture) { + + long nativeListener = addNativeEventListener(type, listener, useCapture); + + if (nativeListener != 0) { + if (listeners == null) + listeners = new Vector(); + + NodeEventListener l = new NodeEventListener(type, + listener, + useCapture, + nativeListener); + listeners.add(l); + } + } + + public void removeEventListener(String type, + EventListener listener, + boolean useCapture) { + if (listeners == null) + return; + + NodeEventListener l = new NodeEventListener(type, + listener, useCapture, 0); + + int idx = listeners.indexOf(l); + + //if trying to remove non-existing listener then return + if (idx == -1) + return; + + l = (NodeEventListener) listeners.remove(idx); + + removeNativeEventListener(type, l.nativeListener, useCapture); + } + + public boolean dispatchEvent(Event evt) throws DOMException { + throw new UnsupportedOperationException(); + } + + private native long addNativeEventListener(String type, + EventListener listener, + boolean useCapture); + + private native void removeNativeEventListener(String type, + long nativeListener, + boolean useCapture); } diff --git a/java/dom/jni/UIEventImpl.java b/java/dom/jni/UIEventImpl.java new file mode 100644 index 00000000000..b9b878012d8 --- /dev/null +++ b/java/dom/jni/UIEventImpl.java @@ -0,0 +1,75 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +package org.mozilla.dom.events; + +import org.w3c.dom.events.UIEvent; +import org.w3c.dom.views.AbstractView; +import org.mozilla.dom.events.EventImpl; + +/** + * The UIEvent interface provides specific contextual + * information associated with User Interface events. + * @since DOM Level 2 + */ +public class UIEventImpl extends EventImpl implements UIEvent { + + // instantiated from JNI only + protected UIEventImpl() {} + + public String toString() { + return ""; + } + + + /** + * The view attribute identifies the AbstractView + * from which the event was generated. + */ + public AbstractView getView() { + throw new UnsupportedOperationException(); + } + + /** + * Specifies some detail information about the Event, depending + * on the type of event. + */ + public short getDetail() { + throw new UnsupportedOperationException(); + } + + /** + * + * @param typeArg Specifies the event type. + * @param canBubbleArg Specifies whether or not the event can bubble. + * @param cancelableArg Specifies whether or not the event's default action + * can be prevent. + * @param viewArg Specifies the Event's + * AbstractView. + * @param detailArg Specifies the Event's detail. + */ + public void initUIEvent(String typeArg, + boolean canBubbleArg, + boolean cancelableArg, + AbstractView viewArg, + short detailArg) { + throw new UnsupportedOperationException(); + } +} + diff --git a/java/dom/jni/event-test/DOMFactory.java.patch b/java/dom/jni/event-test/DOMFactory.java.patch new file mode 100644 index 00000000000..e69de29bb2d diff --git a/java/dom/jni/event-test/TestEventListener.java b/java/dom/jni/event-test/TestEventListener.java new file mode 100644 index 00000000000..e69de29bb2d diff --git a/java/dom/jni/javaDOMEventsGlobals.cpp b/java/dom/jni/javaDOMEventsGlobals.cpp new file mode 100644 index 00000000000..101c8ece8d2 --- /dev/null +++ b/java/dom/jni/javaDOMEventsGlobals.cpp @@ -0,0 +1,1929 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#include "prlog.h" +#include "prmon.h" +#include "nsAutoLock.h" +#include "javaDOMEventsGlobals.h" +#include "nsIDOMEvent.h" +#include "nsIDOMUIEvent.h" + +jclass JavaDOMEventsGlobals::eventClass = NULL; +jclass JavaDOMEventsGlobals::uiEventClass = NULL; +jclass JavaDOMEventsGlobals::eventListenerClass = NULL; +jclass JavaDOMEventsGlobals::eventTargetClass = NULL; +jclass JavaDOMEventsGlobals::keyEventClass = NULL; +jclass JavaDOMEventsGlobals::mouseEventClass = NULL; +jclass JavaDOMEventsGlobals::mutationEventClass = NULL; + +jfieldID JavaDOMEventsGlobals::eventPtrFID = NULL; +jfieldID JavaDOMEventsGlobals::eventTargetPtrFID = NULL; + +jfieldID JavaDOMEventsGlobals::eventPhaseBubblingFID = NULL; +jfieldID JavaDOMEventsGlobals::eventPhaseCapturingFID = NULL; +jfieldID JavaDOMEventsGlobals::eventPhaseAtTargetFID = NULL; + +jfieldID JavaDOMEventsGlobals::keyEvent_CHAR_UNDEFINED_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_0_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_1_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_2_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_3_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_4_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_5_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_6_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_7_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_8_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_9_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_A_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ACCEPT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ADD_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_AGAIN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ALL_CANDIDATES_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ALPHANUMERIC_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ALT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ALT_GRAPH_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_AMPERSAND_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ASTERISK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_AT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_B_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_BACK_QUOTE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_BACK_SLASH_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_BACK_SPACE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_BRACELEFT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_BRACERIGHT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_C_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CANCEL_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CAPS_LOCK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CIRCUMFLEX_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CLEAR_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CLOSE_BRACKET_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CODE_INPUT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_COLON_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_COMMA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_COMPOSE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CONTROL_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CONVERT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_COPY_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_CUT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_D_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_ABOVEDOT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_ABOVERING_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_ACUTE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_BREVE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_CARON_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_CEDILLA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_CIRCUMFLEX_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_DIAERESIS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_DOUBLEACUTE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_GRAVE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_IOTA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_MACRON_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_OGONEK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_SEMIVOICED_SOUND_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_TILDE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DEAD_VOICED_SOUND_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DECIMAL_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DELETE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DIVIDE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DOLLAR_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_DOWN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_E_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_END_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ENTER_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_EQUALS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ESCAPE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_EURO_SIGN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_EXCLAMATION_MARK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F1_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F10_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F11_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F12_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F13_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F14_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F15_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F16_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F17_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F18_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F19_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F2_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F20_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F21_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F22_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F23_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F24_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F3_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F4_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F5_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F6_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F7_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F8_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_F9_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_FINAL_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_FIND_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_FULL_WIDTH_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_G_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_GREATER_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_H_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_HALF_WIDTH_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_HELP_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_HIRAGANA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_HOME_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_I_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_INSERT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_INVERTED_EXCLAMATION_MARK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_J_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_JAPANESE_HIRAGANA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_JAPANESE_KATAKANA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_JAPANESE_ROMAN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_K_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KANA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KANJI_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KATAKANA_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KP_DOWN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KP_LEFT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KP_RIGHT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_KP_UP_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_L_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_LEFT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_LEFT_PARENTHESIS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_LESS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_M_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_META_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_MINUS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_MODECHANGE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_MULTIPLY_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_N_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NONCONVERT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMBER_SIGN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD0_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD1_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD2_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD3_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD4_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD5_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD6_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD7_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD8_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD9_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_NUM_LOCK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_O_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_OPEN_BRACKET_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_P_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PAGE_DOWN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PAGE_UP_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PASTE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PAUSE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PERIOD_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PLUS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PREVIOUS_CANDIDATE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PRINTSCREEN_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_PROPS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_Q_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_QUOTE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_QUOTEDBL_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_R_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_RIGHT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_RIGHT_PARENTHESIS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_ROMAN_CHARACTERS_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_S_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SCROLL_LOCK_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SEMICOLON_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SEPARATER_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SHIFT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SLASH_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SPACE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_STOP_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_SUBTRACT_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_T_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_TAB_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_U_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_UNDEFINED_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_UNDERSCORE_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_UNDO_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_UP_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_V_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_W_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_X_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_Y_FID = NULL; +jfieldID JavaDOMEventsGlobals::keyEvent_DOM_VK_Z_FID = NULL; + + +jmethodID JavaDOMEventsGlobals::eventListenerHandleEventMID = NULL; + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIDOMUIEventIID, NS_IDOMUIEVENT_IID); + +void JavaDOMEventsGlobals::Initialize(JNIEnv *env) +{ + eventClass = env->FindClass("org/mozilla/dom/events/EventImpl"); + if (!eventClass) { + JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.EventImpl not found"); + return; + } + eventClass = (jclass) env->NewGlobalRef(eventClass); + if (!eventClass) + return; + eventPtrFID = + env->GetFieldID(eventClass, "p_nsIDOMEvent", "J"); + if (!eventPtrFID) { + JavaDOMGlobals::ThrowException(env, "There is no field p_nsIDOMEvent in org.mozilla.dom.events.EventImpl"); + return; + } + + eventListenerClass = env->FindClass("org/w3c/dom/events/EventListener"); + if (!eventListenerClass) { + JavaDOMGlobals::ThrowException(env, "Class org.w3c.dom.events.EventListener not found"); + return; + } + eventListenerClass = (jclass) env->NewGlobalRef(eventListenerClass); + if (!eventListenerClass) + return; + + eventListenerHandleEventMID = env->GetMethodID( + eventListenerClass, "handleEvent", "(Lorg/w3c/dom/events/Event;)V"); + if (!eventListenerHandleEventMID) { + JavaDOMGlobals::ThrowException(env, "There is no method handleEvent in org.w3c.dom.events.EventListener"); + return; + } + + uiEventClass = env->FindClass("org/mozilla/dom/events/UIEventImpl"); + if (!uiEventClass) { + JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.UIEventImpl not found"); + return; + } + uiEventClass = (jclass) env->NewGlobalRef(uiEventClass); + if (!uiEventClass) + return; + + eventPhaseBubblingFID = + env->GetStaticFieldID(eventClass, "BUBBLING_PHASE", "S"); + if (!eventPhaseBubblingFID) { + JavaDOMGlobals::ThrowException(env, "There is no static field BUBBLING_PHASE in org.w3c.dom.events.Event"); + return; + } + + eventPhaseCapturingFID = + env->GetStaticFieldID(eventClass, "CAPTURING_PHASE", "S"); + if (!eventPhaseCapturingFID) { + JavaDOMGlobals::ThrowException(env, "There is no static field CAPTURING_PHASE in org.w3c.dom.events.Event"); + return; + } + + eventPhaseAtTargetFID = + env->GetStaticFieldID(eventClass, "AT_TARGET", "S"); + if (!eventPhaseAtTargetFID) { + JavaDOMGlobals::ThrowException(env, "There is no static field AT_TARGET in org.w3c.dom.events.Event"); + return; + } + + keyEventClass = env->FindClass("org/mozilla/dom/events/KeyEventImpl"); + if (!keyEventClass) { + JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.KeyEventImpl not found"); + return; + } + keyEventClass = (jclass) env->NewGlobalRef(keyEventClass); + if (!keyEventClass) + return; + + mouseEventClass = env->FindClass("org/mozilla/dom/events/MouseEventImpl"); + if (!mouseEventClass) { + JavaDOMGlobals::ThrowException(env, "Class org.mozilla.dom.events.MouseEventImpl not found"); + return; + } + mouseEventClass = (jclass) env->NewGlobalRef(mouseEventClass); + if (!mouseEventClass) + return; + + keyEvent_CHAR_UNDEFINED_FID = + env->GetStaticFieldID(keyEventClass, "CHAR_UNDEFINED", "I"); + if (!keyEvent_CHAR_UNDEFINED_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field CHAR_UNDEFINED at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_0_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_0", "I"); + if (!keyEvent_DOM_VK_0_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_0 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_1_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_1", "I"); + if (!keyEvent_DOM_VK_1_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_1 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_2_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_2", "I"); + if (!keyEvent_DOM_VK_2_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_2 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_3_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_3", "I"); + if (!keyEvent_DOM_VK_3_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_3 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_4_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_4", "I"); + if (!keyEvent_DOM_VK_4_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_4 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_5_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_5", "I"); + if (!keyEvent_DOM_VK_5_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_5 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_6_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_6", "I"); + if (!keyEvent_DOM_VK_6_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_6 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_7_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_7", "I"); + if (!keyEvent_DOM_VK_7_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_7 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_8_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_8", "I"); + if (!keyEvent_DOM_VK_8_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_8 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_9_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_9", "I"); + if (!keyEvent_DOM_VK_9_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_9 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_A_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_A", "I"); + if (!keyEvent_DOM_VK_A_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_A at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ACCEPT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ACCEPT", "I"); + if (!keyEvent_DOM_VK_ACCEPT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ACCEPT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ADD_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ADD", "I"); + if (!keyEvent_DOM_VK_ADD_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ADD at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_AGAIN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_AGAIN", "I"); + if (!keyEvent_DOM_VK_AGAIN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_AGAIN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ALL_CANDIDATES_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ALL_CANDIDATES", "I"); + if (!keyEvent_DOM_VK_ALL_CANDIDATES_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ALL_CANDIDATES at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ALPHANUMERIC_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ALPHANUMERIC", "I"); + if (!keyEvent_DOM_VK_ALPHANUMERIC_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ALPHANUMERIC at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ALT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ALT", "I"); + if (!keyEvent_DOM_VK_ALT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ALT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ALT_GRAPH_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ALT_GRAPH", "I"); + if (!keyEvent_DOM_VK_ALT_GRAPH_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ALT_GRAPH at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_AMPERSAND_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_AMPERSAND", "I"); + if (!keyEvent_DOM_VK_AMPERSAND_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_AMPERSAND at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ASTERISK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ASTERISK", "I"); + if (!keyEvent_DOM_VK_ASTERISK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ASTERISK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_AT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_AT", "I"); + if (!keyEvent_DOM_VK_AT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_AT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_B_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_B", "I"); + if (!keyEvent_DOM_VK_B_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_B at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_BACK_QUOTE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_BACK_QUOTE", "I"); + if (!keyEvent_DOM_VK_BACK_QUOTE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_BACK_QUOTE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_BACK_SLASH_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_BACK_SLASH", "I"); + if (!keyEvent_DOM_VK_BACK_SLASH_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_BACK_SLASH at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_BACK_SPACE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_BACK_SPACE", "I"); + if (!keyEvent_DOM_VK_BACK_SPACE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_BACK_SPACE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_BRACELEFT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_BRACELEFT", "I"); + if (!keyEvent_DOM_VK_BRACELEFT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_BRACELEFT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_BRACERIGHT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_BRACERIGHT", "I"); + if (!keyEvent_DOM_VK_BRACERIGHT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_BRACERIGHT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_C_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_C", "I"); + if (!keyEvent_DOM_VK_C_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_C at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CANCEL_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CANCEL", "I"); + if (!keyEvent_DOM_VK_CANCEL_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CANCEL at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CAPS_LOCK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CAPS_LOCK", "I"); + if (!keyEvent_DOM_VK_CAPS_LOCK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CAPS_LOCK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CIRCUMFLEX_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CIRCUMFLEX", "I"); + if (!keyEvent_DOM_VK_CIRCUMFLEX_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CIRCUMFLEX at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CLEAR_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CLEAR", "I"); + if (!keyEvent_DOM_VK_CLEAR_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CLEAR at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CLOSE_BRACKET_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CLOSE_BRACKET", "I"); + if (!keyEvent_DOM_VK_CLOSE_BRACKET_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CLOSE_BRACKET at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CODE_INPUT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CODE_INPUT", "I"); + if (!keyEvent_DOM_VK_CODE_INPUT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CODE_INPUT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_COLON_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_COLON", "I"); + if (!keyEvent_DOM_VK_COLON_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_COLON at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_COMMA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_COMMA", "I"); + if (!keyEvent_DOM_VK_COMMA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_COMMA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_COMPOSE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_COMPOSE", "I"); + if (!keyEvent_DOM_VK_COMPOSE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_COMPOSE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CONTROL_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CONTROL", "I"); + if (!keyEvent_DOM_VK_CONTROL_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CONTROL at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CONVERT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CONVERT", "I"); + if (!keyEvent_DOM_VK_CONVERT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CONVERT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_COPY_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_COPY", "I"); + if (!keyEvent_DOM_VK_COPY_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_COPY at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_CUT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_CUT", "I"); + if (!keyEvent_DOM_VK_CUT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_CUT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_D_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_D", "I"); + if (!keyEvent_DOM_VK_D_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_D at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_ABOVEDOT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_ABOVEDOT", "I"); + if (!keyEvent_DOM_VK_DEAD_ABOVEDOT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_ABOVEDOT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_ABOVERING_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_ABOVERING", "I"); + if (!keyEvent_DOM_VK_DEAD_ABOVERING_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_ABOVERING at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_ACUTE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_ACUTE", "I"); + if (!keyEvent_DOM_VK_DEAD_ACUTE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_ACUTE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_BREVE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_BREVE", "I"); + if (!keyEvent_DOM_VK_DEAD_BREVE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_BREVE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_CARON_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_CARON", "I"); + if (!keyEvent_DOM_VK_DEAD_CARON_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_CARON at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_CEDILLA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_CEDILLA", "I"); + if (!keyEvent_DOM_VK_DEAD_CEDILLA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_CEDILLA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_CIRCUMFLEX_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_CIRCUMFLEX", "I"); + if (!keyEvent_DOM_VK_DEAD_CIRCUMFLEX_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_CIRCUMFLEX at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_DIAERESIS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_DIAERESIS", "I"); + if (!keyEvent_DOM_VK_DEAD_DIAERESIS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_DIAERESIS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_DOUBLEACUTE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_DOUBLEACUTE", "I"); + if (!keyEvent_DOM_VK_DEAD_DOUBLEACUTE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_DOUBLEACUTE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_GRAVE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_GRAVE", "I"); + if (!keyEvent_DOM_VK_DEAD_GRAVE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_GRAVE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_IOTA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_IOTA", "I"); + if (!keyEvent_DOM_VK_DEAD_IOTA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_IOTA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_MACRON_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_MACRON", "I"); + if (!keyEvent_DOM_VK_DEAD_MACRON_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_MACRON at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_OGONEK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_OGONEK", "I"); + if (!keyEvent_DOM_VK_DEAD_OGONEK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_OGONEK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_SEMIVOICED_SOUND_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_SEMIVOICED_SOUND", "I"); + if (!keyEvent_DOM_VK_DEAD_SEMIVOICED_SOUND_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_SEMIVOICED_SOUND at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_TILDE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_TILDE", "I"); + if (!keyEvent_DOM_VK_DEAD_TILDE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_TILDE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DEAD_VOICED_SOUND_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DEAD_VOICED_SOUND", "I"); + if (!keyEvent_DOM_VK_DEAD_VOICED_SOUND_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DEAD_VOICED_SOUND at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DECIMAL_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DECIMAL", "I"); + if (!keyEvent_DOM_VK_DECIMAL_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DECIMAL at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DELETE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DELETE", "I"); + if (!keyEvent_DOM_VK_DELETE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DELETE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DIVIDE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DIVIDE", "I"); + if (!keyEvent_DOM_VK_DIVIDE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DIVIDE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DOLLAR_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DOLLAR", "I"); + if (!keyEvent_DOM_VK_DOLLAR_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DOLLAR at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_DOWN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_DOWN", "I"); + if (!keyEvent_DOM_VK_DOWN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_DOWN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_E_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_E", "I"); + if (!keyEvent_DOM_VK_E_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_E at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_END_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_END", "I"); + if (!keyEvent_DOM_VK_END_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_END at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ENTER_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ENTER", "I"); + if (!keyEvent_DOM_VK_ENTER_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ENTER at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_EQUALS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_EQUALS", "I"); + if (!keyEvent_DOM_VK_EQUALS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_EQUALS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ESCAPE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ESCAPE", "I"); + if (!keyEvent_DOM_VK_ESCAPE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ESCAPE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_EURO_SIGN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_EURO_SIGN", "I"); + if (!keyEvent_DOM_VK_EURO_SIGN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_EURO_SIGN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_EXCLAMATION_MARK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_EXCLAMATION_MARK", "I"); + if (!keyEvent_DOM_VK_EXCLAMATION_MARK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_EXCLAMATION_MARK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F", "I"); + if (!keyEvent_DOM_VK_F_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F1_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F1", "I"); + if (!keyEvent_DOM_VK_F1_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F1 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F10_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F10", "I"); + if (!keyEvent_DOM_VK_F10_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F10 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F11_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F11", "I"); + if (!keyEvent_DOM_VK_F11_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F11 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F12_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F12", "I"); + if (!keyEvent_DOM_VK_F12_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F12 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F13_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F13", "I"); + if (!keyEvent_DOM_VK_F13_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F13 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F14_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F14", "I"); + if (!keyEvent_DOM_VK_F14_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F14 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F15_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F15", "I"); + if (!keyEvent_DOM_VK_F15_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F15 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F16_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F16", "I"); + if (!keyEvent_DOM_VK_F16_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F16 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F17_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F17", "I"); + if (!keyEvent_DOM_VK_F17_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F17 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F18_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F18", "I"); + if (!keyEvent_DOM_VK_F18_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F18 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F19_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F19", "I"); + if (!keyEvent_DOM_VK_F19_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F19 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F2_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F2", "I"); + if (!keyEvent_DOM_VK_F2_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F2 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F20_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F20", "I"); + if (!keyEvent_DOM_VK_F20_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F20 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F21_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F21", "I"); + if (!keyEvent_DOM_VK_F21_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F21 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F22_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F22", "I"); + if (!keyEvent_DOM_VK_F22_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F22 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F23_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F23", "I"); + if (!keyEvent_DOM_VK_F23_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F23 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F24_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F24", "I"); + if (!keyEvent_DOM_VK_F24_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F24 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F3_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F3", "I"); + if (!keyEvent_DOM_VK_F3_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F3 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F4_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F4", "I"); + if (!keyEvent_DOM_VK_F4_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F4 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F5_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F5", "I"); + if (!keyEvent_DOM_VK_F5_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F5 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F6_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F6", "I"); + if (!keyEvent_DOM_VK_F6_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F6 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F7_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F7", "I"); + if (!keyEvent_DOM_VK_F7_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F7 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F8_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F8", "I"); + if (!keyEvent_DOM_VK_F8_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F8 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_F9_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_F9", "I"); + if (!keyEvent_DOM_VK_F9_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_F9 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_FINAL_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_FINAL", "I"); + if (!keyEvent_DOM_VK_FINAL_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_FINAL at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_FIND_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_FIND", "I"); + if (!keyEvent_DOM_VK_FIND_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_FIND at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_FULL_WIDTH_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_FULL_WIDTH", "I"); + if (!keyEvent_DOM_VK_FULL_WIDTH_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_FULL_WIDTH at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_G_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_G", "I"); + if (!keyEvent_DOM_VK_G_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_G at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_GREATER_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_GREATER", "I"); + if (!keyEvent_DOM_VK_GREATER_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_GREATER at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_H_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_H", "I"); + if (!keyEvent_DOM_VK_H_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_H at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_HALF_WIDTH_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_HALF_WIDTH", "I"); + if (!keyEvent_DOM_VK_HALF_WIDTH_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_HALF_WIDTH at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_HELP_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_HELP", "I"); + if (!keyEvent_DOM_VK_HELP_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_HELP at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_HIRAGANA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_HIRAGANA", "I"); + if (!keyEvent_DOM_VK_HIRAGANA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_HIRAGANA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_HOME_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_HOME", "I"); + if (!keyEvent_DOM_VK_HOME_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_HOME at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_I_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_I", "I"); + if (!keyEvent_DOM_VK_I_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_I at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_INSERT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_INSERT", "I"); + if (!keyEvent_DOM_VK_INSERT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_INSERT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_INVERTED_EXCLAMATION_MARK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_INVERTED_EXCLAMATION_MARK", "I"); + if (!keyEvent_DOM_VK_INVERTED_EXCLAMATION_MARK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_INVERTED_EXCLAMATION_MARK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_J_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_J", "I"); + if (!keyEvent_DOM_VK_J_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_J at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_JAPANESE_HIRAGANA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_JAPANESE_HIRAGANA", "I"); + if (!keyEvent_DOM_VK_JAPANESE_HIRAGANA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_JAPANESE_HIRAGANA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_JAPANESE_KATAKANA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_JAPANESE_KATAKANA", "I"); + if (!keyEvent_DOM_VK_JAPANESE_KATAKANA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_JAPANESE_KATAKANA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_JAPANESE_ROMAN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_JAPANESE_ROMAN", "I"); + if (!keyEvent_DOM_VK_JAPANESE_ROMAN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_JAPANESE_ROMAN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_K_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_K", "I"); + if (!keyEvent_DOM_VK_K_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_K at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KANA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KANA", "I"); + if (!keyEvent_DOM_VK_KANA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KANA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KANJI_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KANJI", "I"); + if (!keyEvent_DOM_VK_KANJI_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KANJI at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KATAKANA_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KATAKANA", "I"); + if (!keyEvent_DOM_VK_KATAKANA_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KATAKANA at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KP_DOWN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KP_DOWN", "I"); + if (!keyEvent_DOM_VK_KP_DOWN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KP_DOWN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KP_LEFT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KP_LEFT", "I"); + if (!keyEvent_DOM_VK_KP_LEFT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KP_LEFT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KP_RIGHT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KP_RIGHT", "I"); + if (!keyEvent_DOM_VK_KP_RIGHT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KP_RIGHT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_KP_UP_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_KP_UP", "I"); + if (!keyEvent_DOM_VK_KP_UP_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_KP_UP at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_L_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_L", "I"); + if (!keyEvent_DOM_VK_L_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_L at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_LEFT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_LEFT", "I"); + if (!keyEvent_DOM_VK_LEFT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_LEFT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_LEFT_PARENTHESIS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_LEFT_PARENTHESIS", "I"); + if (!keyEvent_DOM_VK_LEFT_PARENTHESIS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_LEFT_PARENTHESIS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_LESS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_LESS", "I"); + if (!keyEvent_DOM_VK_LESS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_LESS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_M_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_M", "I"); + if (!keyEvent_DOM_VK_M_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_M at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_META_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_META", "I"); + if (!keyEvent_DOM_VK_META_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_META at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_MINUS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_MINUS", "I"); + if (!keyEvent_DOM_VK_MINUS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_MINUS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_MODECHANGE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_MODECHANGE", "I"); + if (!keyEvent_DOM_VK_MODECHANGE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_MODECHANGE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_MULTIPLY_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_MULTIPLY", "I"); + if (!keyEvent_DOM_VK_MULTIPLY_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_MULTIPLY at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_N_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_N", "I"); + if (!keyEvent_DOM_VK_N_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_N at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NONCONVERT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NONCONVERT", "I"); + if (!keyEvent_DOM_VK_NONCONVERT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NONCONVERT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMBER_SIGN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMBER_SIGN", "I"); + if (!keyEvent_DOM_VK_NUMBER_SIGN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMBER_SIGN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD0_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD0", "I"); + if (!keyEvent_DOM_VK_NUMPAD0_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD0 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD1_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD1", "I"); + if (!keyEvent_DOM_VK_NUMPAD1_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD1 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD2_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD2", "I"); + if (!keyEvent_DOM_VK_NUMPAD2_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD2 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD3_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD3", "I"); + if (!keyEvent_DOM_VK_NUMPAD3_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD3 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD4_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD4", "I"); + if (!keyEvent_DOM_VK_NUMPAD4_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD4 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD5_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD5", "I"); + if (!keyEvent_DOM_VK_NUMPAD5_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD5 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD6_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD6", "I"); + if (!keyEvent_DOM_VK_NUMPAD6_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD6 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD7_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD7", "I"); + if (!keyEvent_DOM_VK_NUMPAD7_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD7 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD8_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD8", "I"); + if (!keyEvent_DOM_VK_NUMPAD8_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD8 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUMPAD9_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUMPAD9", "I"); + if (!keyEvent_DOM_VK_NUMPAD9_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUMPAD9 at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_NUM_LOCK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_NUM_LOCK", "I"); + if (!keyEvent_DOM_VK_NUM_LOCK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_NUM_LOCK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_O_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_O", "I"); + if (!keyEvent_DOM_VK_O_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_O at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_OPEN_BRACKET_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_OPEN_BRACKET", "I"); + if (!keyEvent_DOM_VK_OPEN_BRACKET_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_OPEN_BRACKET at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_P_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_P", "I"); + if (!keyEvent_DOM_VK_P_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_P at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PAGE_DOWN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PAGE_DOWN", "I"); + if (!keyEvent_DOM_VK_PAGE_DOWN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PAGE_DOWN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PAGE_UP_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PAGE_UP", "I"); + if (!keyEvent_DOM_VK_PAGE_UP_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PAGE_UP at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PASTE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PASTE", "I"); + if (!keyEvent_DOM_VK_PASTE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PASTE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PAUSE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PAUSE", "I"); + if (!keyEvent_DOM_VK_PAUSE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PAUSE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PERIOD_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PERIOD", "I"); + if (!keyEvent_DOM_VK_PERIOD_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PERIOD at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PLUS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PLUS", "I"); + if (!keyEvent_DOM_VK_PLUS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PLUS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PREVIOUS_CANDIDATE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PREVIOUS_CANDIDATE", "I"); + if (!keyEvent_DOM_VK_PREVIOUS_CANDIDATE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PREVIOUS_CANDIDATE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PRINTSCREEN_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PRINTSCREEN", "I"); + if (!keyEvent_DOM_VK_PRINTSCREEN_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PRINTSCREEN at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_PROPS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_PROPS", "I"); + if (!keyEvent_DOM_VK_PROPS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_PROPS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_Q_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_Q", "I"); + if (!keyEvent_DOM_VK_Q_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_Q at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_QUOTE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_QUOTE", "I"); + if (!keyEvent_DOM_VK_QUOTE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_QUOTE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_QUOTEDBL_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_QUOTEDBL", "I"); + if (!keyEvent_DOM_VK_QUOTEDBL_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_QUOTEDBL at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_R_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_R", "I"); + if (!keyEvent_DOM_VK_R_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_R at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_RIGHT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_RIGHT", "I"); + if (!keyEvent_DOM_VK_RIGHT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_RIGHT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_RIGHT_PARENTHESIS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_RIGHT_PARENTHESIS", "I"); + if (!keyEvent_DOM_VK_RIGHT_PARENTHESIS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_RIGHT_PARENTHESIS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_ROMAN_CHARACTERS_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_ROMAN_CHARACTERS", "I"); + if (!keyEvent_DOM_VK_ROMAN_CHARACTERS_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_ROMAN_CHARACTERS at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_S_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_S", "I"); + if (!keyEvent_DOM_VK_S_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_S at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SCROLL_LOCK_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SCROLL_LOCK", "I"); + if (!keyEvent_DOM_VK_SCROLL_LOCK_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SCROLL_LOCK at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SEMICOLON_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SEMICOLON", "I"); + if (!keyEvent_DOM_VK_SEMICOLON_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SEMICOLON at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SEPARATER_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SEPARATER", "I"); + if (!keyEvent_DOM_VK_SEPARATER_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SEPARATER at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SHIFT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SHIFT", "I"); + if (!keyEvent_DOM_VK_SHIFT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SHIFT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SLASH_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SLASH", "I"); + if (!keyEvent_DOM_VK_SLASH_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SLASH at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SPACE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SPACE", "I"); + if (!keyEvent_DOM_VK_SPACE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SPACE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_STOP_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_STOP", "I"); + if (!keyEvent_DOM_VK_STOP_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_STOP at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_SUBTRACT_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_SUBTRACT", "I"); + if (!keyEvent_DOM_VK_SUBTRACT_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_SUBTRACT at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_T_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_T", "I"); + if (!keyEvent_DOM_VK_T_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_T at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_TAB_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_TAB", "I"); + if (!keyEvent_DOM_VK_TAB_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_TAB at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_U_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_U", "I"); + if (!keyEvent_DOM_VK_U_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_U at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_UNDEFINED_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_UNDEFINED", "I"); + if (!keyEvent_DOM_VK_UNDEFINED_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_UNDEFINED at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_UNDERSCORE_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_UNDERSCORE", "I"); + if (!keyEvent_DOM_VK_UNDERSCORE_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_UNDERSCORE at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_UNDO_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_UNDO", "I"); + if (!keyEvent_DOM_VK_UNDO_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_UNDO at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_UP_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_UP", "I"); + if (!keyEvent_DOM_VK_UP_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_UP at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_V_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_V", "I"); + if (!keyEvent_DOM_VK_V_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_V at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_W_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_W", "I"); + if (!keyEvent_DOM_VK_W_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_W at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_X_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_X", "I"); + if (!keyEvent_DOM_VK_X_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_X at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_Y_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_Y", "I"); + if (!keyEvent_DOM_VK_Y_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_Y at class org.w3c.mozilla.KeyEvent")); + return; + } + + keyEvent_DOM_VK_Z_FID = + env->GetStaticFieldID(keyEventClass, "DOM_VK_Z", "I"); + if (!keyEvent_DOM_VK_Z_FID) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Can't get FID of field DOM_VK_Z at class org.w3c.mozilla.KeyEvent")); + return; + } + + + +} + +void JavaDOMEventsGlobals::Destroy(JNIEnv *env) +{ + env->DeleteGlobalRef(eventClass); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("JavaDOMEventsGlobals::Destroy: failed to delete Event global ref %x\n", + eventClass)); + return; + } + eventClass = NULL; + + env->DeleteGlobalRef(eventListenerClass); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("JavaDOMEventsGlobals::Destroy: failed to delete EventListener global ref %x\n", + eventListenerClass)); + return; + } + eventListenerClass = NULL; + + env->DeleteGlobalRef(uiEventClass); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("JavaDOMEventsGlobals::Destroy: failed to delete UIEvent global ref %x\n", + uiEventClass)); + return; + } + uiEventClass = NULL; + + env->DeleteGlobalRef(keyEventClass); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("JavaDOMEventsGlobals::Destroy: failed to delete keyEvent global ref %x\n", + keyEventClass)); + return; + } + keyEventClass = NULL; + + env->DeleteGlobalRef(mouseEventClass); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("JavaDOMEventsGlobals::Destroy: failed to delete mouseEvent global ref %x\n", + mouseEventClass)); + return; + } + mouseEventClass = NULL; + +} + +//returns true if specified event "type" exists in the given list of types +// NOTE: it is assumed that "types" list is enden with NULL +static jboolean isEventOfType(char **types, char *type) +{ + int i=0; + + if (type) + while (types[i]) { + if (strcmp(type, types[i]) == 0) + return JNI_TRUE; + i++; + } + + return JNI_FALSE; +} + +jobject JavaDOMEventsGlobals::CreateEventSubtype(JNIEnv *env, + nsIDOMEvent *event) +{ + jobject jevent; + jclass clazz = eventClass; + nsISupports *isupports; + void *target; + + isupports = (nsISupports *) event; + + //check whenever our Event is UIEvent + isupports->QueryInterface(kIDOMUIEventIID, (void **) &target); + if (target) { + // At the moment DOM2 draft specifies set of UIEvent subclasses + // However Mozilla still presents these events as nsUIEvent + // So we need a cludge to determine proper java class to be created + + static char *uiEventTypes[] = { "resize", "scroll", "focusin", + "focusout", "gainselection", + "loseselection", "activate", NULL}; + + static char *mouseEventTypes[] = { "click", "mousedown", + "mouseup", "mouseover", + "mousemove", "mouseout", NULL}; + + static char *keyEventTypes[] = { "keypress", "keydown", "keyup", NULL}; + + + nsString nsType; + nsresult rv = event->GetType(nsType); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "Event.getType at JavaDOMEventsGlobals: failed"); + return NULL; + } + char *type = nsType.ToNewCString(); + + if (isEventOfType(mouseEventTypes, type) == JNI_TRUE) { + clazz = mouseEventClass; + } else if (isEventOfType(keyEventTypes, type) == JNI_TRUE) { + clazz = keyEventClass; + } else if (isEventOfType(uiEventTypes, type) == JNI_TRUE) { + clazz = uiEventClass; + } else { + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("Unknown type of UI event (%s)", type)); + clazz = uiEventClass; + } + + delete [] type; + + event->Release(); + event = (nsIDOMEvent *) target; + } + + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("JavaDOMEventsGlobals::CreateEventSubtype: allocating Node of clazz=%x\n", + clazz)); + + jevent = env->AllocObject(clazz); + if (!jevent) { + JavaDOMGlobals::ThrowException(env, + "JavaDOMEventsGlobals::CreateEventSubtype: failed to allocate Event object"); + return NULL; + } + + env->SetLongField(jevent, eventPtrFID, (jlong) event); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("JavaDOMEventGlobals::CreateEventSubtype: failed to set native ptr %x\n", + (jlong) event)); + return NULL; + } + event->AddRef(); + + return jevent; +} + diff --git a/java/dom/jni/javaDOMEventsGlobals.h b/java/dom/jni/javaDOMEventsGlobals.h new file mode 100644 index 00000000000..20ae295324e --- /dev/null +++ b/java/dom/jni/javaDOMEventsGlobals.h @@ -0,0 +1,237 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#ifndef __JavaDOMEventsGlobals_h__ +#define __JavaDOMEventsGlobals_h__ + +#include"javaDOMGlobals.h" +#include"nsIDOMEvent.h" + +class JavaDOMEventsGlobals { + + public: + static jclass eventClass; + static jclass eventListenerClass; + static jclass eventTargetClass; + static jclass uiEventClass; + static jclass mutationEventClass; + static jclass keyEventClass; + static jclass mouseEventClass; + + static jfieldID eventPtrFID; + static jfieldID eventTargetPtrFID; + + static jfieldID eventPhaseBubblingFID; + static jfieldID eventPhaseCapturingFID; + static jfieldID eventPhaseAtTargetFID; + + static jfieldID keyEvent_CHAR_UNDEFINED_FID; + static jfieldID keyEvent_DOM_VK_0_FID; + static jfieldID keyEvent_DOM_VK_1_FID; + static jfieldID keyEvent_DOM_VK_2_FID; + static jfieldID keyEvent_DOM_VK_3_FID; + static jfieldID keyEvent_DOM_VK_4_FID; + static jfieldID keyEvent_DOM_VK_5_FID; + static jfieldID keyEvent_DOM_VK_6_FID; + static jfieldID keyEvent_DOM_VK_7_FID; + static jfieldID keyEvent_DOM_VK_8_FID; + static jfieldID keyEvent_DOM_VK_9_FID; + static jfieldID keyEvent_DOM_VK_A_FID; + static jfieldID keyEvent_DOM_VK_ACCEPT_FID; + static jfieldID keyEvent_DOM_VK_ADD_FID; + static jfieldID keyEvent_DOM_VK_AGAIN_FID; + static jfieldID keyEvent_DOM_VK_ALL_CANDIDATES_FID; + static jfieldID keyEvent_DOM_VK_ALPHANUMERIC_FID; + static jfieldID keyEvent_DOM_VK_ALT_FID; + static jfieldID keyEvent_DOM_VK_ALT_GRAPH_FID; + static jfieldID keyEvent_DOM_VK_AMPERSAND_FID; + static jfieldID keyEvent_DOM_VK_ASTERISK_FID; + static jfieldID keyEvent_DOM_VK_AT_FID; + static jfieldID keyEvent_DOM_VK_B_FID; + static jfieldID keyEvent_DOM_VK_BACK_QUOTE_FID; + static jfieldID keyEvent_DOM_VK_BACK_SLASH_FID; + static jfieldID keyEvent_DOM_VK_BACK_SPACE_FID; + static jfieldID keyEvent_DOM_VK_BRACELEFT_FID; + static jfieldID keyEvent_DOM_VK_BRACERIGHT_FID; + static jfieldID keyEvent_DOM_VK_C_FID; + static jfieldID keyEvent_DOM_VK_CANCEL_FID; + static jfieldID keyEvent_DOM_VK_CAPS_LOCK_FID; + static jfieldID keyEvent_DOM_VK_CIRCUMFLEX_FID; + static jfieldID keyEvent_DOM_VK_CLEAR_FID; + static jfieldID keyEvent_DOM_VK_CLOSE_BRACKET_FID; + static jfieldID keyEvent_DOM_VK_CODE_INPUT_FID; + static jfieldID keyEvent_DOM_VK_COLON_FID; + static jfieldID keyEvent_DOM_VK_COMMA_FID; + static jfieldID keyEvent_DOM_VK_COMPOSE_FID; + static jfieldID keyEvent_DOM_VK_CONTROL_FID; + static jfieldID keyEvent_DOM_VK_CONVERT_FID; + static jfieldID keyEvent_DOM_VK_COPY_FID; + static jfieldID keyEvent_DOM_VK_CUT_FID; + static jfieldID keyEvent_DOM_VK_D_FID; + static jfieldID keyEvent_DOM_VK_DEAD_ABOVEDOT_FID; + static jfieldID keyEvent_DOM_VK_DEAD_ABOVERING_FID; + static jfieldID keyEvent_DOM_VK_DEAD_ACUTE_FID; + static jfieldID keyEvent_DOM_VK_DEAD_BREVE_FID; + static jfieldID keyEvent_DOM_VK_DEAD_CARON_FID; + static jfieldID keyEvent_DOM_VK_DEAD_CEDILLA_FID; + static jfieldID keyEvent_DOM_VK_DEAD_CIRCUMFLEX_FID; + static jfieldID keyEvent_DOM_VK_DEAD_DIAERESIS_FID; + static jfieldID keyEvent_DOM_VK_DEAD_DOUBLEACUTE_FID; + static jfieldID keyEvent_DOM_VK_DEAD_GRAVE_FID; + static jfieldID keyEvent_DOM_VK_DEAD_IOTA_FID; + static jfieldID keyEvent_DOM_VK_DEAD_MACRON_FID; + static jfieldID keyEvent_DOM_VK_DEAD_OGONEK_FID; + static jfieldID keyEvent_DOM_VK_DEAD_SEMIVOICED_SOUND_FID; + static jfieldID keyEvent_DOM_VK_DEAD_TILDE_FID; + static jfieldID keyEvent_DOM_VK_DEAD_VOICED_SOUND_FID; + static jfieldID keyEvent_DOM_VK_DECIMAL_FID; + static jfieldID keyEvent_DOM_VK_DELETE_FID; + static jfieldID keyEvent_DOM_VK_DIVIDE_FID; + static jfieldID keyEvent_DOM_VK_DOLLAR_FID; + static jfieldID keyEvent_DOM_VK_DOWN_FID; + static jfieldID keyEvent_DOM_VK_E_FID; + static jfieldID keyEvent_DOM_VK_END_FID; + static jfieldID keyEvent_DOM_VK_ENTER_FID; + static jfieldID keyEvent_DOM_VK_EQUALS_FID; + static jfieldID keyEvent_DOM_VK_ESCAPE_FID; + static jfieldID keyEvent_DOM_VK_EURO_SIGN_FID; + static jfieldID keyEvent_DOM_VK_EXCLAMATION_MARK_FID; + static jfieldID keyEvent_DOM_VK_F_FID; + static jfieldID keyEvent_DOM_VK_F1_FID; + static jfieldID keyEvent_DOM_VK_F10_FID; + static jfieldID keyEvent_DOM_VK_F11_FID; + static jfieldID keyEvent_DOM_VK_F12_FID; + static jfieldID keyEvent_DOM_VK_F13_FID; + static jfieldID keyEvent_DOM_VK_F14_FID; + static jfieldID keyEvent_DOM_VK_F15_FID; + static jfieldID keyEvent_DOM_VK_F16_FID; + static jfieldID keyEvent_DOM_VK_F17_FID; + static jfieldID keyEvent_DOM_VK_F18_FID; + static jfieldID keyEvent_DOM_VK_F19_FID; + static jfieldID keyEvent_DOM_VK_F2_FID; + static jfieldID keyEvent_DOM_VK_F20_FID; + static jfieldID keyEvent_DOM_VK_F21_FID; + static jfieldID keyEvent_DOM_VK_F22_FID; + static jfieldID keyEvent_DOM_VK_F23_FID; + static jfieldID keyEvent_DOM_VK_F24_FID; + static jfieldID keyEvent_DOM_VK_F3_FID; + static jfieldID keyEvent_DOM_VK_F4_FID; + static jfieldID keyEvent_DOM_VK_F5_FID; + static jfieldID keyEvent_DOM_VK_F6_FID; + static jfieldID keyEvent_DOM_VK_F7_FID; + static jfieldID keyEvent_DOM_VK_F8_FID; + static jfieldID keyEvent_DOM_VK_F9_FID; + static jfieldID keyEvent_DOM_VK_FINAL_FID; + static jfieldID keyEvent_DOM_VK_FIND_FID; + static jfieldID keyEvent_DOM_VK_FULL_WIDTH_FID; + static jfieldID keyEvent_DOM_VK_G_FID; + static jfieldID keyEvent_DOM_VK_GREATER_FID; + static jfieldID keyEvent_DOM_VK_H_FID; + static jfieldID keyEvent_DOM_VK_HALF_WIDTH_FID; + static jfieldID keyEvent_DOM_VK_HELP_FID; + static jfieldID keyEvent_DOM_VK_HIRAGANA_FID; + static jfieldID keyEvent_DOM_VK_HOME_FID; + static jfieldID keyEvent_DOM_VK_I_FID; + static jfieldID keyEvent_DOM_VK_INSERT_FID; + static jfieldID keyEvent_DOM_VK_INVERTED_EXCLAMATION_MARK_FID; + static jfieldID keyEvent_DOM_VK_J_FID; + static jfieldID keyEvent_DOM_VK_JAPANESE_HIRAGANA_FID; + static jfieldID keyEvent_DOM_VK_JAPANESE_KATAKANA_FID; + static jfieldID keyEvent_DOM_VK_JAPANESE_ROMAN_FID; + static jfieldID keyEvent_DOM_VK_K_FID; + static jfieldID keyEvent_DOM_VK_KANA_FID; + static jfieldID keyEvent_DOM_VK_KANJI_FID; + static jfieldID keyEvent_DOM_VK_KATAKANA_FID; + static jfieldID keyEvent_DOM_VK_KP_DOWN_FID; + static jfieldID keyEvent_DOM_VK_KP_LEFT_FID; + static jfieldID keyEvent_DOM_VK_KP_RIGHT_FID; + static jfieldID keyEvent_DOM_VK_KP_UP_FID; + static jfieldID keyEvent_DOM_VK_L_FID; + static jfieldID keyEvent_DOM_VK_LEFT_FID; + static jfieldID keyEvent_DOM_VK_LEFT_PARENTHESIS_FID; + static jfieldID keyEvent_DOM_VK_LESS_FID; + static jfieldID keyEvent_DOM_VK_M_FID; + static jfieldID keyEvent_DOM_VK_META_FID; + static jfieldID keyEvent_DOM_VK_MINUS_FID; + static jfieldID keyEvent_DOM_VK_MODECHANGE_FID; + static jfieldID keyEvent_DOM_VK_MULTIPLY_FID; + static jfieldID keyEvent_DOM_VK_N_FID; + static jfieldID keyEvent_DOM_VK_NONCONVERT_FID; + static jfieldID keyEvent_DOM_VK_NUMBER_SIGN_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD0_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD1_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD2_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD3_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD4_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD5_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD6_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD7_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD8_FID; + static jfieldID keyEvent_DOM_VK_NUMPAD9_FID; + static jfieldID keyEvent_DOM_VK_NUM_LOCK_FID; + static jfieldID keyEvent_DOM_VK_O_FID; + static jfieldID keyEvent_DOM_VK_OPEN_BRACKET_FID; + static jfieldID keyEvent_DOM_VK_P_FID; + static jfieldID keyEvent_DOM_VK_PAGE_DOWN_FID; + static jfieldID keyEvent_DOM_VK_PAGE_UP_FID; + static jfieldID keyEvent_DOM_VK_PASTE_FID; + static jfieldID keyEvent_DOM_VK_PAUSE_FID; + static jfieldID keyEvent_DOM_VK_PERIOD_FID; + static jfieldID keyEvent_DOM_VK_PLUS_FID; + static jfieldID keyEvent_DOM_VK_PREVIOUS_CANDIDATE_FID; + static jfieldID keyEvent_DOM_VK_PRINTSCREEN_FID; + static jfieldID keyEvent_DOM_VK_PROPS_FID; + static jfieldID keyEvent_DOM_VK_Q_FID; + static jfieldID keyEvent_DOM_VK_QUOTE_FID; + static jfieldID keyEvent_DOM_VK_QUOTEDBL_FID; + static jfieldID keyEvent_DOM_VK_R_FID; + static jfieldID keyEvent_DOM_VK_RIGHT_FID; + static jfieldID keyEvent_DOM_VK_RIGHT_PARENTHESIS_FID; + static jfieldID keyEvent_DOM_VK_ROMAN_CHARACTERS_FID; + static jfieldID keyEvent_DOM_VK_S_FID; + static jfieldID keyEvent_DOM_VK_SCROLL_LOCK_FID; + static jfieldID keyEvent_DOM_VK_SEMICOLON_FID; + static jfieldID keyEvent_DOM_VK_SEPARATER_FID; + static jfieldID keyEvent_DOM_VK_SHIFT_FID; + static jfieldID keyEvent_DOM_VK_SLASH_FID; + static jfieldID keyEvent_DOM_VK_SPACE_FID; + static jfieldID keyEvent_DOM_VK_STOP_FID; + static jfieldID keyEvent_DOM_VK_SUBTRACT_FID; + static jfieldID keyEvent_DOM_VK_T_FID; + static jfieldID keyEvent_DOM_VK_TAB_FID; + static jfieldID keyEvent_DOM_VK_U_FID; + static jfieldID keyEvent_DOM_VK_UNDEFINED_FID; + static jfieldID keyEvent_DOM_VK_UNDERSCORE_FID; + static jfieldID keyEvent_DOM_VK_UNDO_FID; + static jfieldID keyEvent_DOM_VK_UP_FID; + static jfieldID keyEvent_DOM_VK_V_FID; + static jfieldID keyEvent_DOM_VK_W_FID; + static jfieldID keyEvent_DOM_VK_X_FID; + static jfieldID keyEvent_DOM_VK_Y_FID; + static jfieldID keyEvent_DOM_VK_Z_FID; + + static jmethodID eventListenerHandleEventMID; + + static void Initialize(JNIEnv *env); + static void Destroy(JNIEnv *env); + static jobject CreateEventSubtype(JNIEnv *env, + nsIDOMEvent *event); + + static jlong RegisterNativeEventListener(); + static jlong UnregisterNativeEventListener(); +}; + +#endif /* __JavaDOMEventsGlobals_h__ */ diff --git a/java/dom/jni/javaDOMGlobals.cpp b/java/dom/jni/javaDOMGlobals.cpp index 62c4ade3d42..ddabb688a8f 100644 --- a/java/dom/jni/javaDOMGlobals.cpp +++ b/java/dom/jni/javaDOMGlobals.cpp @@ -19,6 +19,7 @@ Inc. All Rights Reserved. #include "nsAutoLock.h" #include "nsIDOMNode.h" #include "javaDOMGlobals.h" +#include "javaDOMEventsGlobals.h" jclass JavaDOMGlobals::attrClass = NULL; jclass JavaDOMGlobals::cDataSectionClass = NULL; @@ -237,14 +238,21 @@ void JavaDOMGlobals::Initialize(JNIEnv *env) env->GetMethodID(runtimeExceptionClass, "", "(Ljava/lang/String;)V"); if (!runtimeExceptionInitMID) return; + jclass integerClass = env->FindClass("java/lang/Integer"); jfieldID javaMaxIntFID = env->GetStaticFieldID(integerClass, "MAX_VALUE", "I"); javaMaxInt = env->GetStaticIntField(integerClass, javaMaxIntFID); + + //init events globals + JavaDOMEventsGlobals::Initialize(env); } void JavaDOMGlobals::Destroy(JNIEnv *env) { + //destroy events stuff + JavaDOMEventsGlobals::Destroy(env); + env->DeleteGlobalRef(attrClass); if (env->ExceptionOccurred()) { PR_LOG(log, PR_LOG_ERROR, diff --git a/java/dom/jni/makefile.win b/java/dom/jni/makefile.win index 3da23849687..a604cb285e3 100755 --- a/java/dom/jni/makefile.win +++ b/java/dom/jni/makefile.win @@ -22,6 +22,8 @@ MODULE=javadomjni CPPSRCS= \ javaDOMGlobals.cpp \ + javaDOMEventsGlobals.cpp \ + nativeDOMProxyListener.cpp \ org_mozilla_dom_DOMAccessorImpl.cpp \ org_mozilla_dom_DOMGarbageCollector.cpp \ org_mozilla_dom_AttrImpl.cpp \ @@ -37,10 +39,16 @@ CPPSRCS= \ org_mozilla_dom_NotationImpl.cpp \ org_mozilla_dom_ProcessingInstructionImpl.cpp \ org_mozilla_dom_TextImpl.cpp \ + org_mozilla_dom_events_EventImpl.cpp \ + org_mozilla_dom_events_MouseEventImpl.cpp \ + org_mozilla_dom_events_KeyEventImpl.cpp \ + org_mozilla_dom_events_UIEventImpl.cpp \ $(NULL) CPP_OBJS= \ .\$(OBJDIR)\javaDOMGlobals.obj \ + .\$(OBJDIR)\javaDOMEventsGlobals.obj \ + .\$(OBJDIR)\nativeDOMProxyListener.obj \ .\$(OBJDIR)\org_mozilla_dom_DOMAccessorImpl.obj \ .\$(OBJDIR)\org_mozilla_dom_DOMGarbageCollector.obj \ .\$(OBJDIR)\org_mozilla_dom_AttrImpl.obj \ @@ -56,7 +64,11 @@ CPP_OBJS= \ .\$(OBJDIR)\org_mozilla_dom_NotationImpl.obj \ .\$(OBJDIR)\org_mozilla_dom_ProcessingInstructionImpl.obj \ .\$(OBJDIR)\org_mozilla_dom_TextImpl.obj \ - $(NULL) + .\$(OBJDIR)\org_mozilla_dom_events_EventImpl.obj \ + .\$(OBJDIR)\org_mozilla_dom_events_UIEventImpl.obj \ + .\$(OBJDIR)\org_mozilla_dom_events_MouseEventImpl.obj \ + .\$(OBJDIR)\org_mozilla_dom_events_KeyEventImpl.obj \ +$(NULL) LINCS= diff --git a/java/dom/jni/nativeDOMProxyListener.cpp b/java/dom/jni/nativeDOMProxyListener.cpp new file mode 100644 index 00000000000..7e6713bba0d --- /dev/null +++ b/java/dom/jni/nativeDOMProxyListener.cpp @@ -0,0 +1,125 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#include +#include"prlog.h" +#include"nativeDOMProxyListener.h" +#include"nsIDOMNode.h" +#include"nsIDOMEventTarget.h" +#include"nsIDOMEventListener.h" +#include"javaDOMEventsGlobals.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIDOMEventListener, NS_IDOMEVENTLISTENER_IID); + +NativeDOMProxyListener::NativeDOMProxyListener(JNIEnv *env, jobject jlistener) +{ + mRefCnt = 0; + listener = env->NewGlobalRef(jlistener); + + if (env->GetJavaVM(&vm) != 0) + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("NativeDOMProxyListener: Can't objant jvm\n")); +} + + +//should be called oly from NativeDOMProxyListener::Release +NativeDOMProxyListener::~NativeDOMProxyListener() +{ + JNIEnv *env; + + if (vm->AttachCurrentThread( &env, NULL) != 0) + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("NativeDOMProxyListener: Can't attach current thread to JVM\n")); + + env->DeleteGlobalRef(listener); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("NativeDOMProxyListener::Destroy: failed to delete EventListener global ref %x\n", + listener)); + return; + } +} + +nsresult NativeDOMProxyListener::HandleEvent(nsIDOMEvent* aEvent) +{ + jobject jevent; + JNIEnv *env; + + if (vm->AttachCurrentThread( &env, NULL) != 0) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("NativeDOMProxyListener:HandleEvent Can't attach current thread to JVM\n")); + return NS_ERROR_FAILURE; + } + + jevent = JavaDOMEventsGlobals::CreateEventSubtype(env, aEvent); + + if (!jevent) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("NativeDOMProxyListener::HandleEvent Can't create java event object")); + return NS_ERROR_FAILURE; + } + + env->CallVoidMethod(listener, + JavaDOMEventsGlobals::eventListenerHandleEventMID, + jevent); + + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("NativeDOMProxyListener::HandleEvent: failed to call EventListener %x\n", + listener)); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + +nsresult NativeDOMProxyListener::QueryInterface(const nsIID &aIID, void **aResult) +{ + if (aResult == NULL) { + return NS_ERROR_NULL_POINTER; + } + + // Always NULL result, in case of failure + *aResult = NULL; + + if (aIID.Equals(kISupportsIID)) { + *aResult = (void *) this; + } else if (aIID.Equals(kIDOMEventListener)) { + *aResult = (void *) this; + } + + if (aResult != NULL) { + return NS_ERROR_NO_INTERFACE; + } + + AddRef(); + return NS_OK; +} + +nsrefcnt NativeDOMProxyListener::AddRef() +{ + return mRefCnt++; +} + +nsrefcnt NativeDOMProxyListener::Release() +{ + if (--mRefCnt == 0) { + delete this; + return 0; // Don't access mRefCnt after deleting! + } + return mRefCnt; +} diff --git a/java/dom/jni/nativeDOMProxyListener.h b/java/dom/jni/nativeDOMProxyListener.h new file mode 100644 index 00000000000..8584c2e0b47 --- /dev/null +++ b/java/dom/jni/nativeDOMProxyListener.h @@ -0,0 +1,29 @@ +#ifndef __JAVA_DOM_NATIVE_PROXY_LISTENER__ +#define __JAVA_DOM_NATIVE_PROXY_LISTENER__ + +#include"nsIDOMEventListener.h" +#include"jni.h" + +class NativeDOMProxyListener: public nsIDOMEventListener{ + + private: + JavaVM *vm; + jobject listener; + nsrefcnt mRefCnt; + + //to be used only by Release() + virtual ~NativeDOMProxyListener(); + public: + + NativeDOMProxyListener(JNIEnv *env, jobject jlistener); + + virtual nsresult HandleEvent(nsIDOMEvent* aEvent); + + NS_IMETHOD QueryInterface(const nsIID &aIID, void **aResult); + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + +}; + +#endif + diff --git a/java/dom/jni/org_mozilla_dom_NodeImpl.cpp b/java/dom/jni/org_mozilla_dom_NodeImpl.cpp index 48b51cafa84..3be114e9dee 100644 --- a/java/dom/jni/org_mozilla_dom_NodeImpl.cpp +++ b/java/dom/jni/org_mozilla_dom_NodeImpl.cpp @@ -22,8 +22,12 @@ Inc. All Rights Reserved. #include "nsDOMError.h" #include "javaDOMGlobals.h" #include "org_mozilla_dom_NodeImpl.h" +#include "nativeDOMProxyListener.h" +#include "nsIDOMEventTarget.h" +#include "javaDOMEventsGlobals.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIDOMEventTargetIID, NS_IDOMEVENTTARGET_IID); JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1equals (JNIEnv *env, jobject jthis, jobject nodeArg) @@ -825,3 +829,110 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_setNodeValue return; } } + +/* + * Class: org_mozilla_dom_NodeImpl + * Method: addNativeEventListener + * Signature: (Ljava/lang/String;Lorg/w3c/dom/events/EventListener;Z)J + */ +JNIEXPORT jlong JNICALL Java_org_mozilla_dom_NodeImpl_addNativeEventListener +(JNIEnv *env, jobject jthis, jstring jtype, jobject jlistener, jboolean juseCapture) +{ + nsIDOMEventListener *listener = NULL; + PRBool useCapture; + nsISupports *isupports; + nsIDOMEventTarget* target; + + isupports = (nsISupports *) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID); + if(!isupports) { + JavaDOMGlobals::ThrowException(env, + "EventTarget.addEventListener: NULL pointer"); + return 0; + } + + isupports->QueryInterface(kIDOMEventTargetIID, (void **) &target); + if(!target) { + JavaDOMGlobals::ThrowException(env, + "EventTarget.addEventListener: NULL DOMEventTarget pointer"); + return 0; + } + + jboolean iscopy = JNI_FALSE; + + const char* type = env->GetStringUTFChars(jtype, &iscopy); + if (!type) { + JavaDOMGlobals::ThrowException(env, + "EventTarget.addEventListener: GetStringUTFChars failed\n"); + return 0; + } + + useCapture = juseCapture == JNI_TRUE ? PR_TRUE : PR_FALSE; + + listener = new NativeDOMProxyListener(env, jlistener); + + nsresult rv = target->AddEventListener(type, listener, useCapture); + + target->Release(); + + if (iscopy == JNI_TRUE) + env->ReleaseStringUTFChars(jtype, type); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "EventTarget.addEventListener: error"); + return 0; + } + + return (jlong) listener; +} + +/* + * Class: org_mozilla_dom_NodeImpl + * Method: removeNativeEventListener + * Signature: (Ljava/lang/String;JZ)V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_removeNativeEventListener + (JNIEnv *env, jobject jthis, jstring jtype, jlong jlistener, jboolean juseCapture) +{ + PRBool useCapture; + nsISupports *isupports; + nsIDOMEventTarget* target; + + isupports = (nsISupports *) env->GetLongField(jthis, JavaDOMGlobals::nodePtrFID); + if (!isupports) { + JavaDOMGlobals::ThrowException(env, + "NodeImpl.removeEventListener: NULL pointer\n"); + return; + } + + isupports->QueryInterface(kIDOMEventTargetIID, (void **) &target); + if (!target) { + JavaDOMGlobals::ThrowException(env, + "NodeImpl.removeEventListener: NULL DOMEventTarget pointer\n"); + return; + } + + jboolean iscopy = JNI_FALSE; + const char* type = env->GetStringUTFChars(jtype, &iscopy); + if (!type) { + JavaDOMGlobals::ThrowException(env, + "NodeImpl.removeEventListener: GetStringUTFChars failed\n"); + return; + } + + useCapture = juseCapture == JNI_TRUE ? PR_TRUE : PR_FALSE; + + nsresult rv = target->RemoveEventListener(type, + (nsIDOMEventListener*) jlistener, useCapture); + + target->Release(); + + if (iscopy == JNI_TRUE) + env->ReleaseStringUTFChars(jtype, type); + + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "EventTarget.addEventListener: error"); + return; + } +} + diff --git a/java/dom/jni/org_mozilla_dom_NodeImpl.h b/java/dom/jni/org_mozilla_dom_NodeImpl.h index f32861d4d65..3a8546379e8 100644 --- a/java/dom/jni/org_mozilla_dom_NodeImpl.h +++ b/java/dom/jni/org_mozilla_dom_NodeImpl.h @@ -23,6 +23,14 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1equals JNIEXPORT jint JNICALL Java_org_mozilla_dom_NodeImpl_XPCOM_1hashCode (JNIEnv *, jobject); +/* + * Class: org_mozilla_dom_NodeImpl + * Method: addNativeEventListener + * Signature: (Ljava/lang/String;Lorg/w3c/dom/events/EventListener;Z)J + */ +JNIEXPORT jlong JNICALL Java_org_mozilla_dom_NodeImpl_addNativeEventListener + (JNIEnv *, jobject, jstring, jobject, jboolean); + /* * Class: org_mozilla_dom_NodeImpl * Method: appendChild @@ -159,6 +167,14 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_insertBefore JNIEXPORT jobject JNICALL Java_org_mozilla_dom_NodeImpl_removeChild (JNIEnv *, jobject, jobject); +/* + * Class: org_mozilla_dom_NodeImpl + * Method: removeNativeEventListener + * Signature: (Ljava/lang/String;JZ)V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_NodeImpl_removeNativeEventListener + (JNIEnv *, jobject, jstring, jlong, jboolean); + /* * Class: org_mozilla_dom_NodeImpl * Method: replaceChild diff --git a/java/dom/jni/org_mozilla_dom_events_EventImpl.cpp b/java/dom/jni/org_mozilla_dom_events_EventImpl.cpp new file mode 100644 index 00000000000..87a5bcc55b0 --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_EventImpl.cpp @@ -0,0 +1,238 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#include "prlog.h" +#include"nsIDOMEvent.h" +#include"javaDOMEventsGlobals.h" +#include "org_mozilla_dom_events_EventImpl.h" + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getCurrentNode + * Signature: ()Lorg/w3c/dom/Node; + */ +JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getCurrentNode + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.getCurrentNode: NULL pointer\n"); + return NULL; + } + + nsIDOMNode* ret = nsnull; + nsresult rv = event->GetCurrentNode(&ret); + if (NS_FAILED(rv) || !ret) { + JavaDOMGlobals::ThrowException(env, + "Event.getCurrentNode: failed"); + return NULL; + } + + return JavaDOMGlobals::CreateNodeSubtype(env, ret); +} + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getEventPhase + * Signature: ()S + */ +JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.getEventPhase: NULL native pointer\n"); + return 0; + } + + PRUint16 eventPhase = 0; + nsresult rv = event->GetEventPhase(&eventPhase); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "Event.getEventPhase: failed"); + return 0; + } + + jfieldID phaseFID = NULL; + switch(eventPhase) { + case nsIDOMEvent::BUBBLING_PHASE: + phaseFID = JavaDOMEventsGlobals::eventPhaseBubblingFID; + break; + case nsIDOMEvent::CAPTURING_PHASE: + phaseFID = JavaDOMEventsGlobals::eventPhaseCapturingFID; + break; + case nsIDOMEvent::AT_TARGET: + phaseFID = JavaDOMEventsGlobals::eventPhaseAtTargetFID; + break; + } + + jshort ret = 0; + if (phaseFID) { + ret = env->GetStaticShortField(JavaDOMEventsGlobals::eventClass, phaseFID); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("Event.getEventPhase: slection of phaseFID failed\n")); + return ret; + } + + } else { + JavaDOMGlobals::ThrowException(env, + "Event.getEventPhase: illegal phase"); + } + + return ret; +} + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getTarget + * Signature: ()Lorg/w3c/dom/events/EventTarget; + */ +JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getTarget + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.getTarget: NULL pointer"); + return NULL; + } + + nsIDOMNode* ret = nsnull; + nsresult rv = event->GetTarget(&ret); + if (NS_FAILED(rv) || !ret) { + JavaDOMGlobals::ThrowException(env, + "Event.getTarget: failed"); + return NULL; + } + + return JavaDOMGlobals::CreateNodeSubtype(env, ret); +} + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getType + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_mozilla_dom_events_EventImpl_getType + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.getType: NULL pointer"); + return NULL; + } + + nsString ret; + nsresult rv = event->GetType(ret); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "Event.getType: failed"); + return NULL; + } + + char* cret = ret.ToNewCString(); + jstring jret = env->NewStringUTF(cret); + if (!jret) { + JavaDOMGlobals::ThrowException(env, + "Event.getType: NewStringUTF failed"); + return NULL; + } + + delete[] cret; + + return jret; +} + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: preventBubble + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventBubble + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.preventBubble: NULL pointer"); + return; + } + + nsIDOMNode* ret = nsnull; + nsresult rv = event->PreventBubble(); + if (NS_FAILED(rv) || !ret) { + JavaDOMGlobals::ThrowException(env, + "Event.preventBubble: failed"); + } +} + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: preventCapture + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventCapture + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.preventCapture: NULL pointer"); + return; + } + + nsIDOMNode* ret = nsnull; + nsresult rv = event->PreventCapture(); + if (NS_FAILED(rv) || !ret) { + JavaDOMGlobals::ThrowException(env, + "Event.preventCapture: failed"); + } +} + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: preventDefault + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventDefault + (JNIEnv *env, jobject jthis) +{ + nsIDOMEvent* event = (nsIDOMEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "Event.preventDefault: NULL pointer"); + return; + } + + nsIDOMNode* ret = nsnull; + nsresult rv = event->PreventDefault(); + if (NS_FAILED(rv) || !ret) { + JavaDOMGlobals::ThrowException(env, + "Event.preventDefault: failed"); + } +} + diff --git a/java/dom/jni/org_mozilla_dom_events_EventImpl.h b/java/dom/jni/org_mozilla_dom_events_EventImpl.h new file mode 100644 index 00000000000..41c7f9fd70a --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_EventImpl.h @@ -0,0 +1,69 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_mozilla_dom_events_EventImpl */ + +#ifndef _Included_org_mozilla_dom_events_EventImpl +#define _Included_org_mozilla_dom_events_EventImpl +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getCurrentNode + * Signature: ()Lorg/w3c/dom/Node; + */ +JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getCurrentNode + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getEventPhase + * Signature: ()S + */ +JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getTarget + * Signature: ()Lorg/w3c/dom/events/EventTarget; + */ +JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getTarget + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: getType + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_org_mozilla_dom_events_EventImpl_getType + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: preventBubble + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventBubble + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: preventCapture + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventCapture + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_EventImpl + * Method: preventDefault + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventDefault + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/dom/jni/org_mozilla_dom_events_KeyEventImpl.cpp b/java/dom/jni/org_mozilla_dom_events_KeyEventImpl.cpp new file mode 100644 index 00000000000..73e8ddb98eb --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_KeyEventImpl.cpp @@ -0,0 +1,545 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#include "prlog.h" +#include "nsIDOMUIEvent.h" +#include "javaDOMEventsGlobals.h" +#include "org_mozilla_dom_events_KeyEventImpl.h" + +/* + * Class: org_mozilla_dom_events_KeyEventImpl + * Method: getAltKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_KeyEventImpl_getAltKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getAltKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool altKey = PR_FALSE; + nsresult rv = event->GetAltKey(&altKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getAltKey: failed"); + return JNI_FALSE; + } + + return (altKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + +/* + * Class: org_mozilla_dom_events_KeyEventImpl + * Method: getCharCode + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_KeyEventImpl_getCharCode + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getCharCode: NULL pointer"); + return 0; + } + + PRUint32 code = 0; + nsresult rv = event->GetCharCode(&code); + if (NS_FAILED(rv)) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("KeyEvent.getCharCode: failed (%x)\n", rv)); + return 0; + } + + return (jint) code; +} + + +/* + * Class: org_mozilla_dom_events_KeyEventImpl + * Method: getCtrlKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_KeyEventImpl_getCtrlKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getCtrlKey: NULL pointer\n"); + return JNI_FALSE; + } + + PRBool ctrlKey = PR_FALSE; + nsresult rv = event->GetCtrlKey(&ctrlKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getCtrlKey: failed", rv); + return JNI_FALSE; + } + + return (ctrlKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + + +/* + * Class: org_mozilla_dom_events_KeyEventImpl + * Method: getKeyCode + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_KeyEventImpl_getKeyCode + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getKeyCode: NULL pointer\n"); + return 0; + } + + PRUint32 code = 0; + nsresult rv = event->GetKeyCode(&code); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getKeyCode: failed"); + return 0; + } + + jfieldID keyCodeFID = NULL; + switch(code) { + case nsIDOMUIEvent::DOM_VK_0: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_0_FID; + break; + case nsIDOMUIEvent::DOM_VK_1: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_1_FID; + break; + case nsIDOMUIEvent::DOM_VK_2: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_2_FID; + break; + case nsIDOMUIEvent::DOM_VK_3: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_3_FID; + break; + case nsIDOMUIEvent::DOM_VK_4: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_4_FID; + break; + case nsIDOMUIEvent::DOM_VK_5: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_5_FID; + break; + case nsIDOMUIEvent::DOM_VK_6: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_6_FID; + break; + case nsIDOMUIEvent::DOM_VK_7: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_7_FID; + break; + case nsIDOMUIEvent::DOM_VK_8: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_8_FID; + break; + case nsIDOMUIEvent::DOM_VK_9: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_9_FID; + break; + case nsIDOMUIEvent::DOM_VK_A: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_A_FID; + break; + case nsIDOMUIEvent::DOM_VK_ADD: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_ADD_FID; + break; + case nsIDOMUIEvent::DOM_VK_ALT: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_ALT_FID; + break; + case nsIDOMUIEvent::DOM_VK_B: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_B_FID; + break; + case nsIDOMUIEvent::DOM_VK_BACK: +// renamed in Mozilla's implementation of DOM2 events + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_BACK_SPACE_FID; + break; + case nsIDOMUIEvent::DOM_VK_BACK_QUOTE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_BACK_QUOTE_FID; + break; + case nsIDOMUIEvent::DOM_VK_BACK_SLASH: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_BACK_SLASH_FID; + break; + case nsIDOMUIEvent::DOM_VK_C: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_C_FID; + break; + case nsIDOMUIEvent::DOM_VK_CANCEL: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_CANCEL_FID; + break; + case nsIDOMUIEvent::DOM_VK_CAPS_LOCK: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_CAPS_LOCK_FID; + break; + case nsIDOMUIEvent::DOM_VK_CLEAR: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_CLEAR_FID; + break; + case nsIDOMUIEvent::DOM_VK_CLOSE_BRACKET: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_CLOSE_BRACKET_FID; + break; + case nsIDOMUIEvent::DOM_VK_COMMA: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_COMMA_FID; + break; + case nsIDOMUIEvent::DOM_VK_CONTROL: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_CONTROL_FID; + break; + case nsIDOMUIEvent::DOM_VK_D: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_D_FID; + break; + case nsIDOMUIEvent::DOM_VK_DECIMAL: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_DECIMAL_FID; + break; + case nsIDOMUIEvent::DOM_VK_DELETE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_DELETE_FID; + break; + case nsIDOMUIEvent::DOM_VK_DIVIDE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_DIVIDE_FID; + break; + case nsIDOMUIEvent::DOM_VK_DOWN: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_DOWN_FID; + break; + case nsIDOMUIEvent::DOM_VK_E: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_E_FID; + break; + case nsIDOMUIEvent::DOM_VK_END: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_END_FID; + break; + case nsIDOMUIEvent::DOM_VK_ENTER: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_ENTER_FID; + break; + case nsIDOMUIEvent::DOM_VK_EQUALS: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_EQUALS_FID; + break; + case nsIDOMUIEvent::DOM_VK_ESCAPE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_ESCAPE_FID; + break; + case nsIDOMUIEvent::DOM_VK_F: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F_FID; + break; + case nsIDOMUIEvent::DOM_VK_F1: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F1_FID; + break; + case nsIDOMUIEvent::DOM_VK_F10: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F10_FID; + break; + case nsIDOMUIEvent::DOM_VK_F11: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F11_FID; + break; + case nsIDOMUIEvent::DOM_VK_F12: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F12_FID; + break; + case nsIDOMUIEvent::DOM_VK_F13: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F13_FID; + break; + case nsIDOMUIEvent::DOM_VK_F14: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F14_FID; + break; + case nsIDOMUIEvent::DOM_VK_F15: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F15_FID; + break; + case nsIDOMUIEvent::DOM_VK_F16: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F16_FID; + break; + case nsIDOMUIEvent::DOM_VK_F17: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F17_FID; + break; + case nsIDOMUIEvent::DOM_VK_F18: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F18_FID; + break; + case nsIDOMUIEvent::DOM_VK_F19: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F19_FID; + break; + case nsIDOMUIEvent::DOM_VK_F2: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F2_FID; + break; + case nsIDOMUIEvent::DOM_VK_F20: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F20_FID; + break; + case nsIDOMUIEvent::DOM_VK_F21: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F21_FID; + break; + case nsIDOMUIEvent::DOM_VK_F22: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F22_FID; + break; + case nsIDOMUIEvent::DOM_VK_F23: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F23_FID; + break; + case nsIDOMUIEvent::DOM_VK_F24: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F24_FID; + break; + case nsIDOMUIEvent::DOM_VK_F3: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F3_FID; + break; + case nsIDOMUIEvent::DOM_VK_F4: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F4_FID; + break; + case nsIDOMUIEvent::DOM_VK_F5: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F5_FID; + break; + case nsIDOMUIEvent::DOM_VK_F6: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F6_FID; + break; + case nsIDOMUIEvent::DOM_VK_F7: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F7_FID; + break; + case nsIDOMUIEvent::DOM_VK_F8: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F8_FID; + break; + case nsIDOMUIEvent::DOM_VK_F9: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_F9_FID; + break; + case nsIDOMUIEvent::DOM_VK_G: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_G_FID; + break; + case nsIDOMUIEvent::DOM_VK_H: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_H_FID; + break; + case nsIDOMUIEvent::DOM_VK_HOME: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_HOME_FID; + break; + case nsIDOMUIEvent::DOM_VK_I: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_I_FID; + break; + case nsIDOMUIEvent::DOM_VK_INSERT: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_INSERT_FID; + break; + case nsIDOMUIEvent::DOM_VK_J: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_J_FID; + break; + case nsIDOMUIEvent::DOM_VK_K: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_K_FID; + break; + case nsIDOMUIEvent::DOM_VK_L: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_L_FID; + break; + case nsIDOMUIEvent::DOM_VK_LEFT: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_LEFT_FID; + break; + case nsIDOMUIEvent::DOM_VK_M: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_M_FID; + break; + case nsIDOMUIEvent::DOM_VK_MULTIPLY: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_MULTIPLY_FID; + break; + case nsIDOMUIEvent::DOM_VK_N: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_N_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD0: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD0_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD1: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD1_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD2: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD2_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD3: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD3_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD4: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD4_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD5: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD5_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD6: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD6_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD7: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD7_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD8: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD8_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUMPAD9: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUMPAD9_FID; + break; + case nsIDOMUIEvent::DOM_VK_NUM_LOCK: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_NUM_LOCK_FID; + break; + case nsIDOMUIEvent::DOM_VK_O: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_O_FID; + break; + case nsIDOMUIEvent::DOM_VK_OPEN_BRACKET: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_OPEN_BRACKET_FID; + break; + case nsIDOMUIEvent::DOM_VK_P: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_P_FID; + break; + case nsIDOMUIEvent::DOM_VK_PAGE_DOWN: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_PAGE_DOWN_FID; + break; + case nsIDOMUIEvent::DOM_VK_PAGE_UP: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_PAGE_UP_FID; + break; + case nsIDOMUIEvent::DOM_VK_PAUSE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_PAUSE_FID; + break; + case nsIDOMUIEvent::DOM_VK_PERIOD: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_PERIOD_FID; + break; + case nsIDOMUIEvent::DOM_VK_PRINTSCREEN: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_PRINTSCREEN_FID; + break; + case nsIDOMUIEvent::DOM_VK_Q: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_Q_FID; + break; + case nsIDOMUIEvent::DOM_VK_QUOTE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_QUOTE_FID; + break; + case nsIDOMUIEvent::DOM_VK_R: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_R_FID; + break; + case nsIDOMUIEvent::DOM_VK_RETURN: +// does not exists in DOM2 specs +// keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_RETURN_FID; + PR_LOG(JavaDOMGlobals::log, PR_LOG_WARNING, + ("UIEvent.getKeyCode: RETURN is pressed. But there is no corresponding constant in Java DOM specs.")); + break; + case nsIDOMUIEvent::DOM_VK_RIGHT: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_RIGHT_FID; + break; + case nsIDOMUIEvent::DOM_VK_S: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_S_FID; + break; + case nsIDOMUIEvent::DOM_VK_SCROLL_LOCK: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SCROLL_LOCK_FID; + break; + case nsIDOMUIEvent::DOM_VK_SEMICOLON: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SEMICOLON_FID; + break; + case nsIDOMUIEvent::DOM_VK_SEPARATOR: +// misspelling is fixed in Mozilla but not in DOM2 specs ... + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SEPARATER_FID; + break; + case nsIDOMUIEvent::DOM_VK_SHIFT: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SHIFT_FID; + break; + case nsIDOMUIEvent::DOM_VK_SLASH: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SLASH_FID; + break; + case nsIDOMUIEvent::DOM_VK_SPACE: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SPACE_FID; + break; + case nsIDOMUIEvent::DOM_VK_SUBTRACT: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_SUBTRACT_FID; + break; + case nsIDOMUIEvent::DOM_VK_T: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_T_FID; + break; + case nsIDOMUIEvent::DOM_VK_TAB: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_TAB_FID; + break; + case nsIDOMUIEvent::DOM_VK_U: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_U_FID; + break; + case nsIDOMUIEvent::DOM_VK_UP: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_UP_FID; + break; + case nsIDOMUIEvent::DOM_VK_V: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_V_FID; + break; + case nsIDOMUIEvent::DOM_VK_W: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_W_FID; + break; + case nsIDOMUIEvent::DOM_VK_X: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_X_FID; + break; + case nsIDOMUIEvent::DOM_VK_Y: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_Y_FID; + break; + case nsIDOMUIEvent::DOM_VK_Z: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_DOM_VK_Z_FID; + break; + default: + keyCodeFID = JavaDOMEventsGlobals::keyEvent_CHAR_UNDEFINED_FID; + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("UIEvent.getKeyCode: illegal code %d\n", code)); + break; + } + + jint ret; + if (keyCodeFID) { + ret = env->GetStaticIntField(JavaDOMEventsGlobals::keyEventClass, keyCodeFID); + if (env->ExceptionOccurred()) { + PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR, + ("KeyEvent.getKeyCode: keyCodeFID failed\n")); + ret = 0; + } + } + + return ret; +} + +/* + * Class: org_mozilla_dom_events_KeyEventImpl + * Method: getMetaKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_KeyEventImpl_getMetaKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getMetaKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool metaKey = PR_FALSE; + nsresult rv = event->GetMetaKey(&metaKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getMetaKey: failed"); + return JNI_FALSE; + } + + return (metaKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + +/* + * Class: org_mozilla_dom_events_KeyEventImpl + * Method: getShiftKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_KeyEventImpl_getShiftKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getShiftKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool shiftKey = PR_FALSE; + nsresult rv = event->GetShiftKey(&shiftKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "KeyEvent.getShiftKey: failed"); + return JNI_FALSE; + } + + return (shiftKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + diff --git a/java/dom/jni/org_mozilla_dom_events_KeyEventImpl.h b/java/dom/jni/org_mozilla_dom_events_KeyEventImpl.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/java/dom/jni/org_mozilla_dom_events_MouseEventImpl.cpp b/java/dom/jni/org_mozilla_dom_events_MouseEventImpl.cpp new file mode 100644 index 00000000000..1041cb5ebf9 --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_MouseEventImpl.cpp @@ -0,0 +1,271 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#include "prlog.h" +#include "nsIDOMUIEvent.h" +#include "javaDOMEventsGlobals.h" +#include "org_mozilla_dom_events_MouseEventImpl.h" + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getAltKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getAltKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getAltKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool altKey = PR_FALSE; + nsresult rv = event->GetAltKey(&altKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getAltKey: failed"); + return JNI_FALSE; + } + + return (altKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; + +} + + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getButton + * Signature: ()S + */ +JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getButton: NULL pointer"); + return 0; + } + + PRUint16 code = 0; + nsresult rv = event->GetButton(&code); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getButton: failed"); + return 0; + } + + return (jshort) code; +} + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getClientX + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientX + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getClientX: NULL pointer"); + return 0; + } + + PRInt32 clientX = 0; + nsresult rv = event->GetClientX(&clientX); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getClientX: failed"); + return 0; + } + + return (jint) clientX; +} + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getClientY + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientY + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getClientY: NULL pointer"); + return 0; + } + + PRInt32 clientY = 0; + nsresult rv = event->GetClientY(&clientY); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getClientY: failed"); + return 0; + } + + return (jint) clientY; +} + + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getCtrlKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getCtrlKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getCtrlKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool ctrlKey = PR_FALSE; + nsresult rv = event->GetCtrlKey(&ctrlKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getCtrlKey: failed"); + return JNI_FALSE; + } + + return (ctrlKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getMetaKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getMetaKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getMetaKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool metaKey = PR_FALSE; + nsresult rv = event->GetMetaKey(&metaKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getMetaKey: failed"); + return JNI_FALSE; + } + + return (metaKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getScreenX + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getScreenX: NULL pointer\n"); + return 0; + } + + PRInt32 screenX = 0; + nsresult rv = event->GetScreenX(&screenX); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getScreenX: failed"); + return 0; + } + + return (jint) screenX; +} + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getScreenY + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getScreenY: NULL pointer"); + return 0; + } + + PRInt32 screenY = 0; + nsresult rv = event->GetScreenY(&screenY); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getScreenY: failed"); + return 0; + } + + return (jint) screenY; +} + + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getShiftKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKey + (JNIEnv *env, jobject jthis) +{ + nsIDOMUIEvent* event = (nsIDOMUIEvent*) + env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID); + if (!event) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getShiftKey: NULL pointer"); + return JNI_FALSE; + } + + PRBool shiftKey = PR_FALSE; + nsresult rv = event->GetShiftKey(&shiftKey); + if (NS_FAILED(rv)) { + JavaDOMGlobals::ThrowException(env, + "MouseEvent.getShiftKey: failed"); + return JNI_FALSE; + } + + return (shiftKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE; +} + + diff --git a/java/dom/jni/org_mozilla_dom_events_MouseEventImpl.h b/java/dom/jni/org_mozilla_dom_events_MouseEventImpl.h new file mode 100644 index 00000000000..fcadc05770d --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_MouseEventImpl.h @@ -0,0 +1,85 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_mozilla_dom_events_MouseEventImpl */ + +#ifndef _Included_org_mozilla_dom_events_MouseEventImpl +#define _Included_org_mozilla_dom_events_MouseEventImpl +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getAltKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getAltKey + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getButton + * Signature: ()S + */ +JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getClientX + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientX + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getClientY + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientY + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getCtrlKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getCtrlKey + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getMetaKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getMetaKey + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getScreenX + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getScreenY + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY + (JNIEnv *, jobject); + +/* + * Class: org_mozilla_dom_events_MouseEventImpl + * Method: getShiftKey + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKey + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/java/dom/jni/org_mozilla_dom_events_UIEventImpl.cpp b/java/dom/jni/org_mozilla_dom_events_UIEventImpl.cpp new file mode 100644 index 00000000000..9e3c71b4ca7 --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_UIEventImpl.cpp @@ -0,0 +1,20 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.0 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Initial Developer of the Original Code is Sun Microsystems, +Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems, +Inc. All Rights Reserved. +*/ + +#include "prlog.h" +#include "org_mozilla_dom_events_UIEventImpl.h" + +/* Can't be implemented at the moment */ diff --git a/java/dom/jni/org_mozilla_dom_events_UIEventImpl.h b/java/dom/jni/org_mozilla_dom_events_UIEventImpl.h new file mode 100644 index 00000000000..fe2effbffb3 --- /dev/null +++ b/java/dom/jni/org_mozilla_dom_events_UIEventImpl.h @@ -0,0 +1,13 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_mozilla_dom_events_UIEventImpl */ + +#ifndef _Included_org_mozilla_dom_events_UIEventImpl +#define _Included_org_mozilla_dom_events_UIEventImpl +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif