implemented some w3c event interfaces methods
This commit is contained in:
Родитель
c1e13f4193
Коммит
4f48cbb031
|
@ -54,44 +54,40 @@ public class EventImpl implements Event {
|
|||
* The <code>type</code> property represents the event name as a string
|
||||
* property.
|
||||
*/
|
||||
public native String getType();
|
||||
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();
|
||||
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();
|
||||
public native Node getCurrentNode();
|
||||
|
||||
/**
|
||||
* The <code>eventPhase</code> property indicates which phase of event flow
|
||||
* is currently being evaluated.
|
||||
*/
|
||||
public native short getEventPhase();
|
||||
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();
|
||||
}
|
||||
public native boolean getBubbles();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
public native boolean getCancelable();
|
||||
|
||||
/**
|
||||
* The <code>preventBubble</code> method is used to end the bubbling phase
|
||||
|
@ -101,7 +97,7 @@ public class EventImpl implements Event {
|
|||
* at that level and the event will not be propagated upward within the
|
||||
* tree.
|
||||
*/
|
||||
public native void preventBubble();
|
||||
public native void preventBubble();
|
||||
|
||||
/**
|
||||
* The <code>preventCapture</code> method is used to end the capturing phase
|
||||
|
@ -111,7 +107,7 @@ public class EventImpl implements Event {
|
|||
* cease at that level and the event will not be propagated any further
|
||||
* down.
|
||||
*/
|
||||
public native void preventCapture();
|
||||
public native void preventCapture();
|
||||
|
||||
/**
|
||||
* If an event is cancelable, the <code>preventCapture</code> method is used
|
||||
|
@ -124,7 +120,7 @@ public class EventImpl implements Event {
|
|||
* <code>preventDefault</code> has been called it will remain in effect
|
||||
* throughout the remainder of the event's propagation.
|
||||
*/
|
||||
public native void preventDefault();
|
||||
public native void preventDefault();
|
||||
|
||||
/**
|
||||
* The <code>stopPropagation</code> method is used prevent further
|
||||
|
@ -134,7 +130,7 @@ public class EventImpl implements Event {
|
|||
* on the current <code>EventTarget</code> before event flow stops. This
|
||||
* method may be used during any stage of event flow.
|
||||
*/
|
||||
public void stopPropagation() {
|
||||
public void stopPropagation() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -149,14 +145,11 @@ public class EventImpl implements Event {
|
|||
* @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();
|
||||
}
|
||||
public native void initEvent(String eventTypeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg);
|
||||
|
||||
public long getTimeStamp() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,66 +57,64 @@ public class MouseEventImpl extends UIEventImpl implements MouseEvent {
|
|||
* <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();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
public native int getClientY();
|
||||
|
||||
/**
|
||||
* <code>ctrlKey</code> indicates whether the 'ctrl' key was depressed
|
||||
* during the firing of the event.
|
||||
*/
|
||||
public native boolean getCtrlKey();
|
||||
public native boolean getCtrlKey();
|
||||
|
||||
/**
|
||||
* <code>shiftKey</code> indicates whether the 'shift' key was depressed
|
||||
* during the firing of the event.
|
||||
*/
|
||||
public native boolean getShiftKey();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
}
|
||||
public native Node getRelatedNode();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -142,22 +140,20 @@ public class MouseEventImpl extends UIEventImpl implements MouseEvent {
|
|||
* @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,
|
||||
int detailArg,
|
||||
int screenXArg,
|
||||
int screenYArg,
|
||||
int clientXArg,
|
||||
int clientYArg,
|
||||
boolean ctrlKeyArg,
|
||||
boolean altKeyArg,
|
||||
boolean shiftKeyArg,
|
||||
boolean metaKeyArg,
|
||||
short buttonArg,
|
||||
Node relatedNodeArg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public native void initMouseEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
AbstractView viewArg,
|
||||
int detailArg,
|
||||
int screenXArg,
|
||||
int screenYArg,
|
||||
int clientXArg,
|
||||
int clientYArg,
|
||||
boolean ctrlKeyArg,
|
||||
boolean altKeyArg,
|
||||
boolean shiftKeyArg,
|
||||
boolean metaKeyArg,
|
||||
short buttonArg,
|
||||
Node relatedNodeArg);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,17 +47,13 @@ public class UIEventImpl extends EventImpl implements UIEvent {
|
|||
* The <code>view</code> attribute identifies the <code>AbstractView</code>
|
||||
* from which the event was generated.
|
||||
*/
|
||||
public AbstractView getView() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public native AbstractView getView();
|
||||
|
||||
/**
|
||||
* Specifies some detail information about the <code>Event</code>, depending
|
||||
* on the type of event.
|
||||
*/
|
||||
public int getDetail() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public native int getDetail();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -69,12 +65,10 @@ public class UIEventImpl extends EventImpl implements UIEvent {
|
|||
* <code>AbstractView</code>.
|
||||
* @param detailArg Specifies the <code>Event</code>'s detail.
|
||||
*/
|
||||
public void initUIEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
AbstractView viewArg,
|
||||
int detailArg) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public native void initUIEvent(String typeArg,
|
||||
boolean canBubbleArg,
|
||||
boolean cancelableArg,
|
||||
AbstractView viewArg,
|
||||
int detailArg);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getCurrentNode
|
|||
nsresult rv = event->GetCurrentNode(&ret);
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getCurrentNode: failed");
|
||||
"Event.getCurrentNode: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase
|
|||
nsresult rv = event->GetEventPhase(&eventPhase);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getEventPhase: failed");
|
||||
"Event.getEventPhase: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,60 @@ JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: getBubbles
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getBubbles
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMEvent* event = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getBubbles: NULL pointer");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRBool canBubble = PR_FALSE;
|
||||
nsresult rv = event->GetBubbles(&canBubble);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getBubbles: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
return (canBubble == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: getCancelable
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getCancelable
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMEvent* event = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getCancelable: NULL pointer");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
PRBool cancelable = PR_FALSE;
|
||||
nsresult rv = event->GetCancelable(&cancelable);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getCancelable: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
return (cancelable == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: getTarget
|
||||
|
@ -125,7 +179,7 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getTarget
|
|||
nsresult rv = event->GetTarget(&ret);
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getTarget: failed");
|
||||
"Event.getTarget: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -152,7 +206,7 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_dom_events_EventImpl_getType
|
|||
nsresult rv = event->GetType(ret);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getType: failed");
|
||||
"Event.getType: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -182,11 +236,10 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventBubble
|
|||
return;
|
||||
}
|
||||
|
||||
nsIDOMNode* ret = nsnull;
|
||||
nsresult rv = event->PreventBubble();
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.preventBubble: failed");
|
||||
"Event.preventBubble: failed", rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,11 +259,10 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventCapture
|
|||
return;
|
||||
}
|
||||
|
||||
nsIDOMNode* ret = nsnull;
|
||||
nsresult rv = event->PreventCapture();
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.preventCapture: failed");
|
||||
"Event.preventCapture: failed", rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,11 +282,45 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventDefault
|
|||
return;
|
||||
}
|
||||
|
||||
nsIDOMNode* ret = nsnull;
|
||||
nsresult rv = event->PreventDefault();
|
||||
if (NS_FAILED(rv) || !ret) {
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.preventDefault: failed");
|
||||
"Event.preventDefault: failed", rv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: initEvent
|
||||
* Signature: (Ljava/lang/String;ZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_initEvent
|
||||
(JNIEnv *env, jobject jthis, jstring jeventTypeArg, jboolean jcanBubbleArg, jboolean jcancelableArg)
|
||||
{
|
||||
nsIDOMEvent* event = (nsIDOMEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event || !jeventTypeArg) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.initEvent: NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
jboolean iscopy = JNI_FALSE;
|
||||
const char* cvalue = env->GetStringUTFChars(jeventTypeArg, &iscopy);
|
||||
if (!cvalue) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("Event.initEvent: GetStringUTFChars failed\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool canBubble = jcanBubbleArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool cancelable = jcancelableArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
|
||||
nsresult rv = event->InitEvent(cvalue, canBubble, cancelable);
|
||||
if (iscopy == JNI_TRUE)
|
||||
env->ReleaseStringUTFChars(jeventTypeArg, cvalue);
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("Event.initEvent: failed (%x)\n", rv));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,22 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* 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: 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: getCurrentNode
|
||||
|
@ -25,18 +41,18 @@ JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_EventImpl_getEventPhase
|
|||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: getTarget
|
||||
* Signature: ()Lorg/w3c/dom/events/EventTarget;
|
||||
* Method: getBubbles
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_EventImpl_getTarget
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getBubbles
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: getType
|
||||
* Signature: ()Ljava/lang/String;
|
||||
* Method: getCancelable
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_mozilla_dom_events_EventImpl_getType
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_EventImpl_getCancelable
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
|
@ -63,6 +79,14 @@ JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventCapture
|
|||
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_preventDefault
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_EventImpl
|
||||
* Method: initEvent
|
||||
* Signature: (Ljava/lang/String;ZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_EventImpl_initEvent
|
||||
(JNIEnv *, jobject, jstring, jboolean, jboolean);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "prlog.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMMouseEvent.h"
|
||||
#include "javaDOMEventsGlobals.h"
|
||||
#include "org_mozilla_dom_events_MouseEventImpl.h"
|
||||
|
@ -44,7 +45,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getAltKey
|
|||
nsresult rv = event->GetAltKey(&altKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getAltKey: failed");
|
||||
"MouseEvent.getAltKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton
|
|||
nsresult rv = event->GetButton(&code);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getButton: failed");
|
||||
"MouseEvent.getButton: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientX
|
|||
nsresult rv = event->GetClientX(&clientX);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getClientX: failed");
|
||||
"MouseEvent.getClientX: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientY
|
|||
nsresult rv = event->GetClientY(&clientY);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getClientY: failed");
|
||||
"MouseEvent.getClientY: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -155,7 +156,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getCtrlKey
|
|||
nsresult rv = event->GetCtrlKey(&ctrlKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getCtrlKey: failed");
|
||||
"MouseEvent.getCtrlKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
@ -183,7 +184,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getMetaKey
|
|||
nsresult rv = event->GetMetaKey(&metaKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getMetaKey: failed");
|
||||
"MouseEvent.getMetaKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
@ -211,7 +212,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX
|
|||
nsresult rv = event->GetScreenX(&screenX);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getScreenX: failed");
|
||||
"MouseEvent.getScreenX: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -238,7 +239,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY
|
|||
nsresult rv = event->GetScreenY(&screenY);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getScreenY: failed");
|
||||
"MouseEvent.getScreenY: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -266,11 +267,107 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKe
|
|||
nsresult rv = event->GetShiftKey(&shiftKey);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getShiftKey: failed");
|
||||
"MouseEvent.getShiftKey: failed", rv);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
return (shiftKey == PR_TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getRelatedNode
|
||||
* Signature: ()Lorg/w3c/dom/Node;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getRelatedNode
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getRelatedNode: NULL pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsIDOMNode* node = nsnull;
|
||||
nsresult rv = event->GetRelatedNode(&node);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.getRelatedNode: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
return JavaDOMGlobals::CreateNodeSubtype(env, node);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: initMouseEvent
|
||||
* Signature: (Ljava/lang/String;ZZLorg/w3c/dom/views/AbstractView;IIIIIZZZZSLorg/w3c/dom/Node;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_MouseEventImpl_initMouseEvent
|
||||
(JNIEnv *env, jobject jthis,
|
||||
jstring jtypeArg,
|
||||
jboolean jcanBubbleArg,
|
||||
jboolean jcancelableArg,
|
||||
jobject jviewArg,
|
||||
jint jdetailArg,
|
||||
jint jscreenXArg,
|
||||
jint jscreenYArg,
|
||||
jint jclientXArg,
|
||||
jint jclientYArg,
|
||||
jboolean jctrlKeyArg,
|
||||
jboolean jaltKeyArg,
|
||||
jboolean jshiftKeyArg,
|
||||
jboolean jmetaKeyArg,
|
||||
jshort jbuttonArg,
|
||||
jobject jrelatedNodeArg)
|
||||
{
|
||||
nsIDOMMouseEvent* event = (nsIDOMMouseEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"MouseEvent.initMouseEvent: NULL pointer");
|
||||
return;
|
||||
}
|
||||
|
||||
jboolean iscopy = JNI_FALSE;
|
||||
const char* cvalue = env->GetStringUTFChars(jtypeArg, &iscopy);
|
||||
if (!cvalue) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("UIEvent.initUIEvent: GetStringUTFChars failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool canBubble = jcanBubbleArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool cancelable = jcancelableArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool ctrlKeyArg = jctrlKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool altKeyArg = jaltKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool shiftKeyArg = jshiftKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool metaKeyArg = jmetaKeyArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
|
||||
nsresult rv = event->InitMouseEvent(cvalue,
|
||||
ctrlKeyArg,
|
||||
altKeyArg,
|
||||
shiftKeyArg,
|
||||
metaKeyArg,
|
||||
(PRInt32)jscreenXArg,
|
||||
(PRInt32)jscreenYArg,
|
||||
(PRInt32)jclientXArg,
|
||||
(PRInt32)jclientYArg,
|
||||
(PRUint16)jbuttonArg,
|
||||
(PRUint16)jdetailArg);
|
||||
|
||||
if (iscopy == JNI_TRUE)
|
||||
env->ReleaseStringUTFChars(jtypeArg, cvalue);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"UIEvent.initUIEvent: failed", rv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,18 +9,18 @@ extern "C" {
|
|||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getAltKey
|
||||
* Signature: ()Z
|
||||
* Method: getScreenX
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getAltKey
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getButton
|
||||
* Signature: ()S
|
||||
* Method: getScreenY
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
|
@ -47,6 +47,22 @@ JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getClientY
|
|||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getCtrlKey
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getShiftKey
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKey
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* 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: getMetaKey
|
||||
|
@ -57,27 +73,27 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getMetaKey
|
|||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getScreenX
|
||||
* Signature: ()I
|
||||
* Method: getButton
|
||||
* Signature: ()S
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenX
|
||||
JNIEXPORT jshort JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getButton
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getScreenY
|
||||
* Signature: ()I
|
||||
* Method: getRelatedNode
|
||||
* Signature: ()Lorg/w3c/dom/Node;
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getScreenY
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getRelatedNode
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_MouseEventImpl
|
||||
* Method: getShiftKey
|
||||
* Signature: ()Z
|
||||
* Method: initMouseEvent
|
||||
* Signature: (Ljava/lang/String;ZZLorg/w3c/dom/views/AbstractView;IIIIIZZZZSLorg/w3c/dom/Node;)V
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_mozilla_dom_events_MouseEventImpl_getShiftKey
|
||||
(JNIEnv *, jobject);
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_MouseEventImpl_initMouseEvent
|
||||
(JNIEnv *, jobject, jstring, jboolean, jboolean, jobject, jint, jint, jint, jint, jint, jboolean, jboolean, jboolean, jboolean, jshort, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,6 +20,108 @@
|
|||
*/
|
||||
|
||||
#include "prlog.h"
|
||||
#include"javaDOMEventsGlobals.h"
|
||||
#include "org_mozilla_dom_events_UIEventImpl.h"
|
||||
#include "nsIDOMUIEvent.h"
|
||||
#include "nsIDOMAbstractView.h"
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_UIEventImpl
|
||||
* Method: getView
|
||||
* Signature: ()Lorg/w3c/dom/views/AbstractView;
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_events_UIEventImpl_getView
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMUIEvent* event = (nsIDOMUIEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.getCurrentNode: NULL pointer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsIDOMAbstractView* aView = nsnull;
|
||||
nsresult rv = event->GetView(&aView);
|
||||
if (NS_FAILED(rv) || !aView) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"UIEvent.getView: failed", rv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// REMIND: Abstract View
|
||||
return NULL; //JavaDOMEventGlobals::CreateEventSubtype(env, ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_UIEventImpl
|
||||
* Method: getDetail
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_mozilla_dom_events_UIEventImpl_getDetail
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
nsIDOMUIEvent* event = (nsIDOMUIEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"UIEvent.getDetail: NULL pointer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRInt32 aDetail = 0;
|
||||
nsresult rv = event->GetDetail(&aDetail);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"UIEvent.getDetail: failed", rv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (jint)aDetail;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_mozilla_dom_events_UIEventImpl
|
||||
* Method: initUIEvent
|
||||
* Signature: (Ljava/lang/String;ZZLorg/w3c/dom/views/AbstractView;I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_dom_events_UIEventImpl_initUIEvent
|
||||
(JNIEnv *env, jobject jthis,
|
||||
jstring jtypeArg,
|
||||
jboolean jcanBubbleArg,
|
||||
jboolean jcancelableArg,
|
||||
jobject jviewArg,
|
||||
jint jdetailArg)
|
||||
{
|
||||
nsIDOMUIEvent* event = (nsIDOMUIEvent*)
|
||||
env->GetLongField(jthis, JavaDOMEventsGlobals::eventPtrFID);
|
||||
if (!event || !jtypeArg || !jviewArg) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"Event.initUIEvent: NULL pointer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
jboolean iscopy = JNI_FALSE;
|
||||
const char* cvalue = env->GetStringUTFChars(jtypeArg, &iscopy);
|
||||
if (!cvalue) {
|
||||
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
|
||||
("UIEvent.initUIEvent: GetStringUTFChars failed\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
PRBool canBubble = jcanBubbleArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
PRBool cancelable = jcancelableArg == JNI_TRUE ? PR_TRUE : PR_FALSE;
|
||||
|
||||
|
||||
// REMIND: need to deal with AbstractView
|
||||
// NS_IMETHOD InitUIEvent(const nsString& aTypeArg, PRBool aCanBubbleArg, PRBool aCancelableArg, nsIDOMAbstractView* aViewArg, PRInt32 aDetailArg)=0;
|
||||
nsresult rv = event->InitUIEvent(cvalue, canBubble, cancelable, NULL, (PRUint32)jdetailArg);
|
||||
|
||||
if (iscopy == JNI_TRUE)
|
||||
env->ReleaseStringUTFChars(jtypeArg, cvalue);
|
||||
if (NS_FAILED(rv)) {
|
||||
JavaDOMGlobals::ThrowException(env,
|
||||
"UIEvent.initUIEvent: failed", rv);
|
||||
}
|
||||
}
|
||||
|
||||
/* Can't be implemented at the moment */
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/* 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
|
Загрузка…
Ссылка в новой задаче