15579 r=akhil.arora@sun.com Checkin by Igor Nekrestyanov <nis@sparc.spb.su>
Implementation of DOM Events from the W3c DOM Level 2 current working draft
This commit is contained in:
Родитель
3ba1f0a07c
Коммит
1f5ecb584e
|
@ -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.
|
||||
I highly recommend reading Sheng Liang's new JNI book.
|
||||
|
|
|
@ -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 <code>Element</code> node this attribute is attached to or
|
||||
* <code>null</code> if this attribute is not in use.
|
||||
* @since DOM Level 2
|
||||
*/
|
||||
public Element getOwnerElement() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 <code>Event</code> interface is used to provide contextual information
|
||||
* about an event to the handler processing the event. An object which
|
||||
* implements the <code>Event</code> 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
|
||||
* <code>Event</code> 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 "<c=org.mozilla.dom.events.Event type=" + getType() +
|
||||
" target=" + getTarget() +
|
||||
" phase=" + getEventPhase() +
|
||||
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>type</code> property represents the event name as a string
|
||||
* property.
|
||||
*/
|
||||
public native String getType();
|
||||
|
||||
/**
|
||||
* The <code>target</code> property indicates the <code>EventTarget</code>
|
||||
* to which the event was originally dispatched.
|
||||
*/
|
||||
public native EventTarget getTarget();
|
||||
|
||||
/**
|
||||
* The <code>currentNode</code> property indicates the <code>Node</code>
|
||||
* whose <code>EventListener</code>s are currently being processed. This
|
||||
* is particularly useful during capturing and bubbling.
|
||||
*/
|
||||
public native Node getCurrentNode();
|
||||
|
||||
/**
|
||||
* The <code>eventPhase</code> property indicates which phase of event flow
|
||||
* is currently being evaluated.
|
||||
*/
|
||||
public native short getEventPhase();
|
||||
|
||||
/**
|
||||
* The <code>bubbles</code> 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 <code>cancelable</code> 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 <code>preventBubble</code> method is used to end the bubbling phase
|
||||
* of event flow. If this method is called by any
|
||||
* <code>EventListener</code>s registered on the same
|
||||
* <code>EventTarget</code> 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 <code>preventCapture</code> method is used to end the capturing phase
|
||||
* of event flow. If this method is called by any
|
||||
* <code>EventListener</code>s registered on the same
|
||||
* <code>EventTarget</code> 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 <code>preventCapture</code> 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
|
||||
* <code>preventDefault</code> 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
|
||||
* <code>preventDefault</code> 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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <code>KeyEvent</code> 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 "<c=org.mozilla.dom.events.KeyUIEvent type=" + getType() +
|
||||
" mods=(" + getCtrlKey() + "," + getMetaKey() + "," + getShiftKey() + "," + getAltKey() + ")" +
|
||||
" key=" + getKeyCode() + " char=" + getCharCode() +
|
||||
" target=" + getTarget() +
|
||||
" phase=" + getEventPhase() +
|
||||
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>ctrlKey</code> indicates whether the 'ctrl' key was depressed
|
||||
* during the firing of the event.
|
||||
*/
|
||||
public native boolean getCtrlKey();
|
||||
|
||||
/**
|
||||
* <code>shiftKey</code> indicates whether the 'shift' key was depressed
|
||||
* during the firing of the event.
|
||||
*/
|
||||
public native boolean getShiftKey();
|
||||
|
||||
/**
|
||||
* <code>altKey</code> 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();
|
||||
|
||||
/**
|
||||
* <code>metaKey</code> 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 <code>keyCode</code> 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();
|
||||
|
||||
/**
|
||||
* <code>charCode</code> 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 <code>Event</code>.
|
||||
* @param altKeyArg Specifies whether or not alt key was depressed during
|
||||
* the <code>Event</code>.
|
||||
* @param shiftKeyArg Specifies whether or not shift key was depressed
|
||||
* during the <code>Event</code>.
|
||||
* @param metaKeyArg Specifies whether or not meta key was depressed during
|
||||
* the <code>Event</code>.
|
||||
* @param keyCodeArg Specifies the <code>Event</code>'s <code>keyCode</code>
|
||||
* @param charCodeArg Specifies the <code>Event</code>'s
|
||||
* <code>charCode</code>
|
||||
* @param viewArg Specifies the <code>Event</code>'s
|
||||
* <code>AbstractView</code>.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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 <code>MouseEvent</code> interface provides specific contextual
|
||||
* information associated with Mouse events.
|
||||
* <p>The <code>detail</code> attribute inherited from <code>UIEvent</code>
|
||||
* 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 "<c=org.mozilla.dom.events.mouseUIEvent type=" + getType() +
|
||||
" screen=(" + getScreenX() + "," + getScreenY() + ")" +
|
||||
" client=(" + getClientX() + "," + getClientY() + ")" +
|
||||
" mods=(" + getCtrlKey() + "," + getMetaKey() + "," + getShiftKey() + "," + getAltKey() + ")" +
|
||||
" button=" + getButton() +
|
||||
" target=" + getTarget() +
|
||||
" phase=" + getEventPhase() +
|
||||
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>screenX</code> indicates the horizontal coordinate at which the
|
||||
* event occurred in relative to the origin of the screen coordinate system.
|
||||
*/
|
||||
public native int getScreenX();
|
||||
|
||||
/**
|
||||
* <code>screenY</code> indicates the vertical coordinate at which the event
|
||||
* occurred relative to the origin of the screen coordinate system.
|
||||
*/
|
||||
public native int getScreenY();
|
||||
|
||||
/**
|
||||
* <code>clientX</code> indicates the horizontal coordinate at which the
|
||||
* event occurred relative to the DOM implementation's client area.
|
||||
*/
|
||||
public native int getClientX();
|
||||
|
||||
/**
|
||||
* <code>clientY</code> indicates the vertical coordinate at which the event
|
||||
* occurred relative to the DOM implementation's client area.
|
||||
*/
|
||||
public native int getClientY();
|
||||
|
||||
/**
|
||||
* <code>ctrlKey</code> indicates whether the 'ctrl' key was depressed
|
||||
* during the firing of the event.
|
||||
*/
|
||||
public native boolean getCtrlKey();
|
||||
|
||||
/**
|
||||
* <code>shiftKey</code> indicates whether the 'shift' key was depressed
|
||||
* during the firing of the event.
|
||||
*/
|
||||
public native boolean getShiftKey();
|
||||
|
||||
/**
|
||||
* <code>altKey</code> 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();
|
||||
|
||||
/**
|
||||
* <code>metaKey</code> 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, <code>button</code> is used to indicate which mouse button
|
||||
* changed state.
|
||||
*/
|
||||
public native short getButton();
|
||||
|
||||
/**
|
||||
* <code>relatedNode</code> 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 <code>Event</code>'s
|
||||
* <code>AbstractView</code>.
|
||||
* @param detailArg Specifies the <code>Event</code>'s mouse click count.
|
||||
* @param screenXArg Specifies the <code>Event</code>'s screen x coordinate
|
||||
* @param screenYArg Specifies the <code>Event</code>'s screen y coordinate
|
||||
* @param clientXArg Specifies the <code>Event</code>'s client x coordinate
|
||||
* @param clientYArg Specifies the <code>Event</code>'s client y coordinate
|
||||
* @param ctrlKeyArg Specifies whether or not control key was depressed
|
||||
* during the <code>Event</code>.
|
||||
* @param altKeyArg Specifies whether or not alt key was depressed during
|
||||
* the <code>Event</code>.
|
||||
* @param shiftKeyArg Specifies whether or not shift key was depressed
|
||||
* during the <code>Event</code>.
|
||||
* @param metaKeyArg Specifies whether or not meta key was depressed during
|
||||
* the <code>Event</code>.
|
||||
* @param buttonArg Specifies the <code>Event</code>'s mouse button.
|
||||
* @param relatedNodeArg Specifies the <code>Event</code>'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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
/**
|
||||
* <code>relatedNode</code> 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 <code>relatedNode</code>
|
||||
* is the changed parent. If an event is instead dispatch to a subtree
|
||||
* indicating a node was changed within it, the <code>relatedNode</code> is
|
||||
* the changed node.
|
||||
*/
|
||||
public Node getRelatedNode() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>prevValue</code> indicates the previous value of text nodes and
|
||||
* attributes in attrModified and charDataModified events.
|
||||
*/
|
||||
public String getPrevValue() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>newValue</code> indicates the new value of text nodes and
|
||||
* attributes in attrModified and charDataModified events.
|
||||
*/
|
||||
public String getNewValue() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>attrName</code> 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 <code>Event</code>'s related Node
|
||||
* @param prevValueArg Specifies the <code>Event</code>'s
|
||||
* <code>prevValue</code> property
|
||||
* @param newValueArg Specifies the <code>Event</code>'s
|
||||
* <code>newValue</code> property
|
||||
* @param attrNameArg Specifies the <code>Event</code>'s
|
||||
* <code>attrName</code> property
|
||||
*/
|
||||
public void initMutationEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
Node relatedNodeArg,
|
||||
String prevValueArg,
|
||||
String newValueArg,
|
||||
String attrNameArg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 <code>UIEvent</code> 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 "<c=org.mozilla.dom.events.UIEvent type=" + getType() +
|
||||
" target=" + getTarget() +
|
||||
" phase=" + getEventPhase() +
|
||||
" p=" + Long.toHexString(p_nsIDOMEvent) + ">";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The <code>view</code> attribute identifies the <code>AbstractView</code>
|
||||
* from which the event was generated.
|
||||
*/
|
||||
public AbstractView getView() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies some detail information about the <code>Event</code>, 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 <code>Event</code>'s
|
||||
* <code>AbstractView</code>.
|
||||
* @param detailArg Specifies the <code>Event</code>'s detail.
|
||||
*/
|
||||
public void initUIEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
AbstractView viewArg,
|
||||
short detailArg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -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__ */
|
|
@ -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, "<init>", "(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,
|
||||
|
|
|
@ -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=
|
||||
|
||||
|
|
|
@ -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<stdio.h>
|
||||
#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;
|
||||
}
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* 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
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* 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
|
|
@ -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 */
|
|
@ -0,0 +1,13 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* 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
|
Загрузка…
Ссылка в новой задаче