bug 40330

a=edburns

This checkin mainly does two things:

1. Correctly populates the java.awt.event.MouseEvent subclass with the
  correct modifiers, x, y, and clickCount for the mozilla mouse event.

2. Adds a performance optimization: previously, every mouse event was
  causing a new instance of java.util.Properties to be created.  Now,
  only one Properties instance is created per-page, and it is cleared on
  each mouse event.

Also, I made the DOMMouseListenerImpl constructor initialize the
refCount to 0.  This allows the object to be correctly deleted.

M classes_spec/org/mozilla/webclient/test/EMWindow.java
M classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java
M src_moz/DOMMouseListenerImpl.cpp
M src_moz/DOMMouseListenerImpl.h
M src_moz/WindowControlImpl.cpp
M src_moz/jni_util.cpp
M src_moz/jni_util.h
M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h

M classes_spec/org/mozilla/webclient/test/EMWindow.java

* Added test code for MouseListener properties: buttons, modifiers, etc.

M classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java

* Added support for mouse modifiers.  Pull values out of the hash table,
  put them in the MouseEvent constructor.

M src_moz/DOMMouseListenerImpl.cpp

* Modified constructors so they initialize all ivars.

* changed usage model of properties object to share the lifetime of the
  DOMMouseListenerImpl instance.  Needed to make use of the new function
  util_ClearPropertiesObject() to do this.  Now we have only one call to
  util_DestroyPropertiesObject(), in the DOMMouseListenerImpl
  destructor.

M src_moz/DOMMouseListenerImpl.h

>     virtual ~DOMMouseListenerImpl();
>
98a101
> protected:
100a104,105
>
> void JNICALL addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent);

M src_moz/WindowControlImpl.cpp

* Initialize new WebShellInitConext member propertiesClass to nsnull

M src_moz/jni_util.cpp

* Added util_ClearPropertiesObject() an optimization.

* Store the jclass for java/util/Properties in an element in
  WebShellInitContext.  This prevents us from having to do FindClass
  each time a mouse event occurs.

* Added a parameter to util_StoreIntoPropertiesObject.

M src_moz/jni_util.h

* Added propertiesClass to WebShellInitContext

* Added new method ClearPropertiesObject

* Added new last argument to DestroyPropertiesObject

M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h

* Added function pointer for util_ClearPropertiesObject.


git-svn-id: svn://10.0.0.236/trunk@71756 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2000-06-08 02:16:06 +00:00
parent 0c56583a85
commit 9fac87eedf
9 changed files with 422 additions and 182 deletions

View File

@@ -36,9 +36,9 @@ JavaVM *gVm = nsnull; // declared in ns_globals.h, which is included in
// Local cache variables of JNI data items
//
static jclass gPropertiesClass = nsnull;
static jmethodID gPropertiesInitMethodID = nsnull;
static jmethodID gPropertiesSetPropertyMethodID = nsnull;
static jmethodID gPropertiesClearMethodID = nsnull;
void util_ThrowExceptionToJava (JNIEnv * env, const char * message)
{
@@ -368,30 +368,37 @@ void util_SetIntValueForInstance(JNIEnv *env, jobject obj,
#endif;
}
jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed)
jobject util_CreatePropertiesObject(JNIEnv *env, jobject initContextObj)
{
jobject result = nsnull;
#ifdef BAL_INTERFACE
if (nsnull != externalCreatePropertiesObject) {
result = externalCreatePropertiesObject(env, reserved_NotUsed);
result = externalCreatePropertiesObject(env, initContextObj);
}
#else
// For some reason, we have to do FindClass each time. If we try to
// cache the class, it crashes. I think this may have something to
// do with threading issues.
if (nsnull == (gPropertiesClass
= ::util_FindClass(env, "java/util/Properties"))) {
return result;
}
if (nsnull == gPropertiesInitMethodID) {
if (nsnull == (gPropertiesInitMethodID =
env->GetMethodID(gPropertiesClass, "<init>", "()V"))) {
PR_ASSERT(initContextObj);
WebShellInitContext *initContext = (WebShellInitContext *) initContextObj;
if (nsnull == initContext->propertiesClass) {
if (nsnull == (initContext->propertiesClass =
::util_FindClass(env, "java/util/Properties"))) {
return result;
}
}
result = env->NewObject(gPropertiesClass, gPropertiesInitMethodID);
if (nsnull == gPropertiesInitMethodID) {
PR_ASSERT(initContext->propertiesClass);
if (nsnull == (gPropertiesInitMethodID =
env->GetMethodID(initContext->propertiesClass,
"<init>", "()V"))) {
return result;
}
}
PR_ASSERT(gPropertiesInitMethodID);
result = ::util_NewGlobalRef(env,
env->NewObject(initContext->propertiesClass,
gPropertiesInitMethodID));
#endif
return result;
@@ -406,21 +413,52 @@ void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject,
reserved_NotUsed);
}
#else
::util_DeleteGlobalRef(env, propertiesObject);
#endif
}
void util_ClearPropertiesObject(JNIEnv *env, jobject propertiesObject,
jobject initContextObj)
{
#ifdef BAL_INTERFACE
if (nsnull != externalClearPropertiesObject) {
externalClearPropertiesObject(env, propertiesObject, initContextObj);
}
#else
PR_ASSERT(initContextObj);
WebShellInitContext *initContext = (WebShellInitContext *) initContextObj;
if (nsnull == gPropertiesClearMethodID) {
PR_ASSERT(initContext->propertiesClass);
if (nsnull == (gPropertiesClearMethodID =
env->GetMethodID(initContext->propertiesClass, "clear", "()V"))) {
return;
}
}
PR_ASSERT(gPropertiesClearMethodID);
env->CallVoidMethod(propertiesObject, gPropertiesClearMethodID);
return;
#endif
}
void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject,
jobject name, jobject value)
jobject name, jobject value,
jobject initContextObj)
{
#ifdef BAL_INTERFACE
if (nsnull != externalStoreIntoPropertiesObject) {
externalStoreIntoPropertiesObject(env, propertiesObject, name, value);
externalStoreIntoPropertiesObject(env, propertiesObject, name, value,
initContextObj);
}
#else
PR_ASSERT(initContextObj);
WebShellInitContext *initContext = (WebShellInitContext *) initContextObj;
if (nsnull == gPropertiesSetPropertyMethodID) {
PR_ASSERT(gPropertiesClass);
PR_ASSERT(initContext->propertiesClass);
if (nsnull == (gPropertiesSetPropertyMethodID =
env->GetMethodID(gPropertiesClass,
env->GetMethodID(initContext->propertiesClass,
"setProperty",
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;"))) {
return;