bug: 20659
r=gbarney
a=edburns
This checkin adds java.awt.event.MouseListener support to webclient for
mozilla. The following files are include in this checkin. "A" is new
file "M" is modified file.
A classes_spec/org/mozilla/webclient/WCMouseEvent.java
A classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java
A src_moz/DOMMouseListenerImpl.cpp
A src_moz/DOMMouseListenerImpl.h
A src_moz/dom_util.cpp
A src_moz/dom_util.h
M classes_spec/org/mozilla/webclient/EventRegistration.java
M classes_spec/org/mozilla/webclient/test/EMWindow.java
M classes_spec/org/mozilla/webclient/wrapper_native/EventRegistrationImpl.java
M classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java
M src_moz/DocumentLoaderObserverImpl.cpp
M src_moz/DocumentLoaderObserverImpl.h
M src_moz/EventRegistration.cpp
M src_moz/EventRegistration.h
M src_moz/Makefile.solaris
M src_moz/Makefile.win
M src_moz/NativeEventThread.cpp
M src_moz/NavigationImpl.cpp
M src_moz/RDFTreeNode.cpp
M src_moz/bal_util.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
A classes_spec/org/mozilla/webclient/WCMouseEvent.java
* <P> This java.awt.event.MouseEvent subclass allows the user to access the
* WebclientEvent. This eventData of this WebclientEvent, if non-null,
* is a java.util.Properties instance that contains information about
* this event. </P>
* <P>The following are some interesting keys:</P>
* <UL>
* <LI> href
* </LI>
* <LI> #text
* </LI>
* </UL>
A classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java
* This class wraps the user provided instance of
* java.awt.event.MouseListener so it can be installed as a
* WebclientEventListener. Note that we implement MouseListener so we
* can be detected by the webclient event system. We don't do anything
* with these methods here, though.
A src_moz/DOMMouseListenerImpl.cpp
A src_moz/DOMMouseListenerImpl.h
* This class is the shim between the mozilla listener event system for
* mouse events and the java MouseListener interface.
* For each of the Mouse* methods, we call the appropriate method in java.
* See the implementation of MouseOver for an example.
* For each mouseEvent, we create a Properties object containing
* information about the event. We use methods in dom_util to do this.
A src_moz/dom_util.cpp
A src_moz/dom_util.h
/**
* Methods to simplify webclient accessing the mozilla DOM.
*/
M classes_spec/org/mozilla/webclient/EventRegistration.java
Added support for java.awt.event.MouseListener
M classes_spec/org/mozilla/webclient/test/EMWindow.java
Implemented simle MouseListener
M classes_spec/org/mozilla/webclient/wrapper_native/EventRegistrationImpl.java
Added support for java.awt.event.MouseListener
M classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java
Added support for java.awt.event.MouseListener
M src_moz/DocumentLoaderObserverImpl.cpp
M src_moz/DocumentLoaderObserverImpl.h
* We define a local IID to allow the addDocumentLoadListener and
* addMouseListener functions in EventRegistration.{h,cpp} to
* interrogate the currently installed DocumentLoaderObserver instance
* in mozilla.
*/
#define NS_IDOCLOADEROBSERVERIMPL_IID_STR "fdadb2e0-3028-11d4-8a96-0080c7b9c5ba"
#define NS_IDOCLOADEROBSERVERIMPL_IID {0xfdadb2e0, 0x3028, 0x11d4, { 0x8a, 0x96, 0x00, 0x80, 0xc7, 0xb9, 0xc5, 0xba }}
/**
* This class is the shim between the mozilla listener event system for
* document load events and the java DocumentLoadListener interface.
* For each of the On* methods, we call the appropriate method in java.
* See the implementation of OnEndDocumentLoad for an example.
* A DocumentLoaderObserverImpl instance has a "jobject target", which
* is the Java object that should ultimately receive the events. This
* target will be null if the user just wants to listen for mouse
* events. It willl be non-null if the user wants to listen for
* DocumentLoad events.
* It also hosts a nsIDOMMouseListener instance, which piggybacks on the
* nsIDocumentLoaderObserver instance.
M src_moz/EventRegistration.cpp
M src_moz/EventRegistration.h
Add support for MouseListener
M src_moz/Makefile.win
Added classes for MouseListener and Dom access
M src_moz/NativeEventThread.cpp
Added support for MouseListener
M src_moz/NavigationImpl.cpp
Added call to ReleaseStringChars for bal case.
M src_moz/RDFTreeNode.cpp
Added call to ReleaseStringChars for bal case.
M src_moz/bal_util.cpp
Added #include "wchar.h" so this file compiles on Solaris.
M src_moz/jni_util.cpp
Added implementations for util_CreatePropertiesObject,
util_DestroyPropertiesObject and util_StoreIntoPropertiesObject.
M src_moz/jni_util.h
/**
* A JNI wrapper to create a java.util.Properties object, or the
* equivalent object in the BAL case.
*/
jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed);
/**
* A JNI wrapper to destroy the object from CreatePropertiesObject
*/
void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject,
jobject reserved_NotUsed);
/**
* A JNI wrapper for storing a name/value pair into the Properties
* object created by CreatePropertiesObject
*/
void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject,
jobject name, jobject value);
M src_moz/jni_util_export.cpp
M src_moz/jni_util_export.h
Added functions for allowing the BAL user to specify functions for
{creating, destroying, setting values into} properties objects.
git-svn-id: svn://10.0.0.236/trunk@70879 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
385
mozilla/java/webclient/src_moz/DOMMouseListenerImpl.cpp
Normal file
385
mozilla/java/webclient/src_moz/DOMMouseListenerImpl.cpp
Normal file
@@ -0,0 +1,385 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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 Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "DOMMouseListenerImpl.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsFileSpec.h" // for nsAutoCString
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "DOMMouseListenerImpl.h"
|
||||
#include "jni_util.h"
|
||||
#include "dom_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#include "prprf.h" // for PR_snprintf
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
#include "ns_globals.h" // for prLogModuleInfo and gComponentManager
|
||||
|
||||
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
||||
|
||||
//
|
||||
// Local functions
|
||||
//
|
||||
|
||||
jlong DOMMouseListenerImpl::maskValues[] = { -1L };
|
||||
|
||||
char *DOMMouseListenerImpl::maskNames[] = {
|
||||
"MOUSE_DOWN_EVENT_MASK",
|
||||
"MOUSE_UP_EVENT_MASK",
|
||||
"MOUSE_CLICK_EVENT_MASK",
|
||||
"MOUSE_DOUBLE_CLICK_EVENT_MASK",
|
||||
"MOUSE_OVER_EVENT_MASK",
|
||||
"MOUSE_OUT_EVENT_MASK",
|
||||
nsnull
|
||||
};
|
||||
|
||||
NS_IMPL_ADDREF(DOMMouseListenerImpl);
|
||||
NS_IMPL_RELEASE(DOMMouseListenerImpl);
|
||||
|
||||
DOMMouseListenerImpl::DOMMouseListenerImpl(){
|
||||
}
|
||||
|
||||
DOMMouseListenerImpl::DOMMouseListenerImpl(JNIEnv *env,
|
||||
WebShellInitContext *yourInitContext,
|
||||
jobject yourTarget) :
|
||||
mJNIEnv(env), mInitContext(yourInitContext), mTarget(yourTarget)
|
||||
{
|
||||
if (nsnull == gVm) { // declared in jni_util.h
|
||||
::util_GetJavaVM(env, &gVm); // save this vm reference away for the callback!
|
||||
}
|
||||
#ifndef BAL_INTERFACE
|
||||
PR_ASSERT(gVm);
|
||||
#endif
|
||||
|
||||
if (-1 == maskValues[0]) {
|
||||
util_InitializeEventMaskValuesFromClass("org/mozilla/webclient/WCMouseEvent",
|
||||
maskNames, maskValues);
|
||||
}
|
||||
mRefCnt = 1; // PENDING(edburns): not sure about how right this is to do.
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DOMMouseListenerImpl::QueryInterface(REFNSIID aIID, void** aInstance)
|
||||
{
|
||||
if (nsnull == aInstance)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstance = nsnull;
|
||||
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener))) {
|
||||
*aInstance = (void*) ((nsIDOMMouseListener*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
/* nsIDOMEventListener methods */
|
||||
|
||||
nsresult DOMMouseListenerImpl::HandleEvent(nsIDOMEvent* aEvent)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMMouseListener methods */
|
||||
nsresult DOMMouseListenerImpl::MouseDown(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("!DOMMouseListenerImpl::MouseDown\n"));
|
||||
}
|
||||
#endif
|
||||
PR_ASSERT(nsnull != aMouseEvent);
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread,
|
||||
mTarget,
|
||||
maskValues[MOUSE_DOWN_EVENT_MASK],
|
||||
properties);
|
||||
util_DestroyPropertiesObject(mInitContext->env, properties, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult DOMMouseListenerImpl::MouseUp(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("!DOMMouseListenerImpl::MouseUp\n"));
|
||||
}
|
||||
#endif
|
||||
PR_ASSERT(nsnull != aMouseEvent);
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread,
|
||||
mTarget,
|
||||
maskValues[MOUSE_UP_EVENT_MASK],
|
||||
properties);
|
||||
util_DestroyPropertiesObject(mInitContext->env, properties, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult DOMMouseListenerImpl::MouseClick(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("!DOMMouseListenerImpl::MouseClick\n"));
|
||||
}
|
||||
#endif
|
||||
PR_ASSERT(nsnull != aMouseEvent);
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread,
|
||||
mTarget,
|
||||
maskValues[MOUSE_CLICK_EVENT_MASK],
|
||||
properties);
|
||||
util_DestroyPropertiesObject(mInitContext->env, properties, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult DOMMouseListenerImpl::MouseDblClick(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("!DOMMouseListenerImpl::MouseDoubleClick\n"));
|
||||
}
|
||||
#endif
|
||||
PR_ASSERT(nsnull != aMouseEvent);
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread,
|
||||
mTarget,
|
||||
maskValues[MOUSE_DOUBLE_CLICK_EVENT_MASK],
|
||||
properties);
|
||||
util_DestroyPropertiesObject(mInitContext->env, properties, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult DOMMouseListenerImpl::MouseOver(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("!DOMMouseListenerImpl::MouseOver\n"));
|
||||
}
|
||||
#endif
|
||||
PR_ASSERT(nsnull != aMouseEvent);
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread,
|
||||
mTarget,
|
||||
maskValues[MOUSE_OVER_EVENT_MASK],
|
||||
properties);
|
||||
util_DestroyPropertiesObject(mInitContext->env, properties, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult DOMMouseListenerImpl::MouseOut(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
#if DEBUG_RAPTOR_CANVAS
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("!DOMMouseListenerImpl::MouseOut\n"));
|
||||
}
|
||||
#endif
|
||||
PR_ASSERT(nsnull != aMouseEvent);
|
||||
|
||||
getPropertiesFromEvent(aMouseEvent);
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread,
|
||||
mTarget,
|
||||
maskValues[MOUSE_OUT_EVENT_MASK],
|
||||
properties);
|
||||
util_DestroyPropertiesObject(mInitContext->env, properties, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
jobject JNICALL DOMMouseListenerImpl::getPropertiesFromEvent(nsIDOMEvent *aMouseEvent)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> currentNode;
|
||||
nsresult rv = NS_OK;;
|
||||
|
||||
rv = aMouseEvent->GetTarget(getter_AddRefs(currentNode));
|
||||
if (NS_FAILED(rv)) {
|
||||
return properties;
|
||||
}
|
||||
if (nsnull == currentNode) {
|
||||
return properties;
|
||||
}
|
||||
inverseDepth = 0;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
|
||||
properties = util_CreatePropertiesObject(env, nsnull);
|
||||
dom_iterateToRoot(currentNode, DOMMouseListenerImpl::takeActionOnNode,
|
||||
(void *)this);
|
||||
return properties;
|
||||
}
|
||||
|
||||
nsresult JNICALL DOMMouseListenerImpl::takeActionOnNode(nsCOMPtr<nsIDOMNode> currentNode,
|
||||
void *myObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsString nodeInfo, nodeName, nodeValue, nodeDepth;
|
||||
jstring jNodeName, jNodeValue;
|
||||
PRUint32 depth = -1;
|
||||
DOMMouseListenerImpl *curThis = nsnull;
|
||||
const PRUint32 depthStrLen = 20;
|
||||
char depthStr[depthStrLen];
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
|
||||
PR_ASSERT(nsnull != myObject);
|
||||
curThis = (DOMMouseListenerImpl *) myObject;
|
||||
depth = curThis->inverseDepth++;
|
||||
|
||||
if (!(curThis->properties)) {
|
||||
return rv;
|
||||
}
|
||||
// encode the depth of the node
|
||||
PR_snprintf(depthStr, depthStrLen, "depthFromLeaf:%d", depth);
|
||||
nodeDepth = (const char *) depthStr;
|
||||
|
||||
// Store the name and the value of this node
|
||||
|
||||
{
|
||||
// get the name and prepend the depth
|
||||
rv = currentNode->GetNodeName(nodeInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// nodeName = nodeDepth;
|
||||
// nodeName += nodeInfo;
|
||||
nodeName = nodeInfo;
|
||||
|
||||
if (prLogModuleInfo) {
|
||||
nsAutoCString nodeInfoCStr(nodeName);
|
||||
PR_LOG(prLogModuleInfo, 3, ("%s", (const char *)nodeInfoCStr));
|
||||
}
|
||||
|
||||
rv = currentNode->GetNodeValue(nodeInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// nodeValue = nodeDepth;
|
||||
// nodeValue += nodeInfo;
|
||||
nodeValue = nodeInfo;
|
||||
|
||||
if (prLogModuleInfo) {
|
||||
nsAutoCString nodeInfoCStr(nodeValue);
|
||||
PR_LOG(prLogModuleInfo, 3, ("%s", (const char *)nodeInfoCStr));
|
||||
}
|
||||
|
||||
jNodeName = ::util_NewString(env, nodeName.GetUnicode(),
|
||||
nodeName.Length());
|
||||
jNodeValue = ::util_NewString(env, nodeValue.GetUnicode(),
|
||||
nodeValue.Length());
|
||||
|
||||
util_StoreIntoPropertiesObject(env, (jobject) curThis->properties,
|
||||
(jobject) jNodeName, (jobject) jNodeValue);
|
||||
if (jNodeName) {
|
||||
::util_DeleteString(env, jNodeName);
|
||||
}
|
||||
if (jNodeValue) {
|
||||
::util_DeleteString(env, jNodeValue);
|
||||
}
|
||||
} // end of Storing the name and value of this node
|
||||
|
||||
// store any attributes of this node
|
||||
{
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> nodeMap;
|
||||
rv = currentNode->GetAttributes(getter_AddRefs(nodeMap));
|
||||
if (NS_FAILED(rv) || !nodeMap) {
|
||||
return rv;
|
||||
}
|
||||
PRUint32 length, i;
|
||||
rv = nodeMap->GetLength(&length);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
for (i = 0; i < length; i++) {
|
||||
rv = nodeMap->Item(i, getter_AddRefs(currentNode));
|
||||
|
||||
if (nsnull == currentNode) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = currentNode->GetNodeName(nodeInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// nodeName = nodeDepth;
|
||||
// nodeName += nodeInfo;
|
||||
nodeName = nodeInfo;
|
||||
|
||||
if (prLogModuleInfo) {
|
||||
nsAutoCString nodeInfoCStr(nodeName);
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("attribute[%d], %s", i, (const char *)nodeInfoCStr));
|
||||
}
|
||||
|
||||
rv = currentNode->GetNodeValue(nodeInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// nodeValue = nodeDepth;
|
||||
// nodeValue += nodeInfo;
|
||||
nodeValue = nodeInfo;
|
||||
|
||||
if (prLogModuleInfo) {
|
||||
nsAutoCString nodeInfoCStr(nodeValue);
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("attribute[%d] %s", i,(const char *)nodeInfoCStr));
|
||||
}
|
||||
jNodeName = ::util_NewString(env, nodeName.GetUnicode(),
|
||||
nodeName.Length());
|
||||
jNodeValue = ::util_NewString(env, nodeValue.GetUnicode(),
|
||||
nodeValue.Length());
|
||||
|
||||
util_StoreIntoPropertiesObject(env, (jobject) curThis->properties,
|
||||
(jobject) jNodeName, (jobject) jNodeValue);
|
||||
if (jNodeName) {
|
||||
::util_DeleteString(env, jNodeName);
|
||||
}
|
||||
if (jNodeValue) {
|
||||
::util_DeleteString(env, jNodeValue);
|
||||
}
|
||||
}
|
||||
} // end of storing the attributes
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
145
mozilla/java/webclient/src_moz/DOMMouseListenerImpl.h
Normal file
145
mozilla/java/webclient/src_moz/DOMMouseListenerImpl.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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 Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DOMMouseListenerImpl_h
|
||||
#define DOMMouseListenerImpl_h
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
/**
|
||||
|
||||
* This class is the shim between the mozilla listener event system for
|
||||
* mouse events and the java MouseListener interface.
|
||||
* For each of the Mouse* methods, we call the appropriate method in java.
|
||||
* See the implementation of MouseOver for an example.
|
||||
|
||||
* For each mouseEvent, we create a Properties object containing
|
||||
* information about the event. We use methods in dom_util to do this.
|
||||
|
||||
*/
|
||||
|
||||
class DOMMouseListenerImpl : public nsIDOMMouseListener {
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
MOUSE_DOWN_EVENT_MASK = 0,
|
||||
MOUSE_UP_EVENT_MASK,
|
||||
MOUSE_CLICK_EVENT_MASK,
|
||||
MOUSE_DOUBLE_CLICK_EVENT_MASK,
|
||||
MOUSE_OVER_EVENT_MASK,
|
||||
MOUSE_OUT_EVENT_MASK,
|
||||
NUMBER_OF_MASK_NAMES
|
||||
} EVENT_MASK_NAMES;
|
||||
|
||||
|
||||
#ifdef XP_UNIX
|
||||
static jlong maskValues [NUMBER_OF_MASK_NAMES];
|
||||
#else
|
||||
static jlong maskValues [DOMMouseListenerImpl::EVENT_MASK_NAMES::NUMBER_OF_MASK_NAMES];
|
||||
#endif
|
||||
|
||||
static char *maskNames [];
|
||||
|
||||
DOMMouseListenerImpl(JNIEnv *yourJNIEnv,
|
||||
WebShellInitContext *yourInitContext,
|
||||
jobject yourTarget);
|
||||
|
||||
DOMMouseListenerImpl();
|
||||
|
||||
/* nsIDOMEventListener methods */
|
||||
nsresult HandleEvent(nsIDOMEvent* aEvent);
|
||||
|
||||
|
||||
/* nsIDOMMouseListener methods */
|
||||
|
||||
nsresult MouseDown(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
nsresult MouseUp(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
nsresult MouseClick(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
nsresult MouseDblClick(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
nsresult MouseOver(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
nsresult MouseOut(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
//
|
||||
// Local methods
|
||||
//
|
||||
|
||||
jobject JNICALL getPropertiesFromEvent(nsIDOMEvent *aMouseEvent);
|
||||
|
||||
static nsresult JNICALL takeActionOnNode(nsCOMPtr<nsIDOMNode> curNode,
|
||||
void *yourObject);
|
||||
|
||||
protected:
|
||||
|
||||
JNIEnv *mJNIEnv;
|
||||
WebShellInitContext *mInitContext;
|
||||
jobject mTarget;
|
||||
|
||||
//
|
||||
// The following arguments are used in the takeActionOnNode method.
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* 0 is the leaf depth. That's why we call it the inverse depth.
|
||||
|
||||
*/
|
||||
|
||||
PRInt32 inverseDepth;
|
||||
|
||||
/**
|
||||
|
||||
* The properties table, created during a mouseEvent handler
|
||||
|
||||
*/
|
||||
|
||||
jobject properties;
|
||||
|
||||
/**
|
||||
|
||||
* the nsIDOMEvent in the current event
|
||||
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> currentDOMEvent;
|
||||
|
||||
//
|
||||
// End of ivars used in takeActionOnNode
|
||||
//
|
||||
|
||||
};
|
||||
|
||||
#endif // DOMMouseListenerImpl_h
|
||||
@@ -28,22 +28,15 @@
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
#include<stdio.h>
|
||||
#include "jni_util.h"
|
||||
#include "dom_util.h"
|
||||
#include "nsActions.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
// PENDING(edburns): take this out
|
||||
#include "winbase.h"
|
||||
// end of take this out
|
||||
#endif
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
||||
|
||||
jlong DocumentLoaderObserverImpl::maskValues[] = { -1L };
|
||||
|
||||
char *DocumentLoaderObserverImpl::maskNames[] = {
|
||||
@@ -58,26 +51,21 @@ char *DocumentLoaderObserverImpl::maskNames[] = {
|
||||
nsnull
|
||||
};
|
||||
|
||||
|
||||
/*************
|
||||
NS_IMETHODIMP_(nsrefcnt) DocumentLoaderObserverImpl::AddRef(void)
|
||||
{
|
||||
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
|
||||
++mRefCnt;
|
||||
return mRefCnt;
|
||||
}
|
||||
**************/
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverIID, NS_IDOCUMENT_LOADER_OBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverImplIID, NS_IDOCLOADEROBSERVERIMPL_IID);
|
||||
|
||||
NS_IMPL_ADDREF(DocumentLoaderObserverImpl);
|
||||
NS_IMPL_RELEASE(DocumentLoaderObserverImpl);
|
||||
|
||||
DocumentLoaderObserverImpl::DocumentLoaderObserverImpl(){
|
||||
DocumentLoaderObserverImpl::DocumentLoaderObserverImpl() : mRefCnt(1),
|
||||
mTarget(nsnull), mMouseListener(nsnull) {
|
||||
}
|
||||
|
||||
DocumentLoaderObserverImpl::DocumentLoaderObserverImpl(JNIEnv *env,
|
||||
WebShellInitContext *yourInitContext,
|
||||
jobject yourTarget) :
|
||||
mJNIEnv(env), mInitContext(yourInitContext), mTarget(yourTarget)
|
||||
WebShellInitContext *yourInitContext) :
|
||||
mJNIEnv(env), mInitContext(yourInitContext), mTarget(nsnull),
|
||||
mMouseListener(nsnull)
|
||||
{
|
||||
if (nsnull == gVm) { // declared in jni_util.h
|
||||
::util_GetJavaVM(env, &gVm); // save this vm reference away for the callback!
|
||||
@@ -93,24 +81,30 @@ DocumentLoaderObserverImpl::DocumentLoaderObserverImpl(JNIEnv *env,
|
||||
mRefCnt = 1; // PENDING(edburns): not sure about how right this is to do.
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::QueryInterface(REFNSIID aIID, void** aInstance)
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::QueryInterface(REFNSIID aIID,
|
||||
void** aInstance)
|
||||
{
|
||||
if (nsnull == aInstance)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstance = nsnull;
|
||||
|
||||
|
||||
if (aIID.Equals(kIDocumentLoaderObserverIID)) {
|
||||
*aInstance = (void*) ((nsIDocumentLoaderObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
if (nsnull == aInstance)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstance = nsnull;
|
||||
|
||||
|
||||
if (aIID.Equals(kIDocumentLoaderObserverIID)) {
|
||||
*aInstance = (void*) ((nsIDocumentLoaderObserver*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIDocumentLoaderObserverImplIID)) {
|
||||
*aInstance = (void*) ((DocumentLoaderObserverImpl*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
/* nsIDocumentLoaderObserver methods */
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIURI* aURL,
|
||||
@@ -122,6 +116,11 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartDocumentLoad(nsIDocumentLoader*
|
||||
("DocumentLoaderObserverImpl.cpp: OnStartDocumentLoad\n"));
|
||||
}
|
||||
#endif
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
char *urlStr = nsnull;
|
||||
jobject urlJStr = nsnull;
|
||||
if (nsnull != aURL) {
|
||||
@@ -141,16 +140,9 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartDocumentLoad(nsIDocumentLoader*
|
||||
mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[START_DOCUMENT_LOAD_EVENT_MASK], urlJStr);
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
// This violates my goal of confining all #ifdef BAL_INTERFACE to
|
||||
// jni_util files, but this is the only part of the code that knows
|
||||
// that eventData is a jstring. In java, this will get garbage
|
||||
// collected, but in non-java contexts, it will not. Thus, we have
|
||||
// to manually de-allocate it.
|
||||
if (urlJStr) {
|
||||
::util_DeleteStringUTF(mInitContext->env, (jstring) urlJStr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -165,6 +157,39 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndDocumentLoad(nsIDocumentLoader* l
|
||||
("!!DocumentLoaderObserverImpl.cpp: OnEndDocumentLoad\n"));
|
||||
}
|
||||
#endif
|
||||
// if we have a mouse listener
|
||||
if (mMouseListener) {
|
||||
// install the mouse listener into mozilla
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
PR_ASSERT(mMouseListener);
|
||||
|
||||
if (nsnull == loader) {
|
||||
// NOT really ok, but we can't do anything.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!(doc = dom_getDocumentFromLoader(loader))) {
|
||||
// NOT really ok, but we can't do anything.
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMEventTarget> domEventTarget;
|
||||
nsresult rv;
|
||||
|
||||
rv = doc->QueryInterface(NS_GET_IID(nsIDOMEventTarget),
|
||||
getter_AddRefs(domEventTarget));
|
||||
if (NS_FAILED(rv) || !domEventTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsAutoString eType("mouseover");
|
||||
domEventTarget->AddEventListener(eType, mMouseListener, PR_FALSE);
|
||||
|
||||
} // end of "install mouse listener"
|
||||
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
util_SendEventToJava(mInitContext->env,
|
||||
mInitContext->nativeEventThread, mTarget,
|
||||
@@ -181,6 +206,11 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartURLLoad(nsIDocumentLoader* load
|
||||
("!DocumentLoaderObserverImpl: OnStartURLLoad\n"));
|
||||
}
|
||||
#endif
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[START_URL_LOAD_EVENT_MASK], nsnull);
|
||||
|
||||
@@ -198,6 +228,11 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnProgressURLLoad(nsIDocumentLoader* l
|
||||
("!DocumentLoaderObserverImpl: OnProgressURLLoad\n"));
|
||||
}
|
||||
#endif
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[PROGRESS_URL_LOAD_EVENT_MASK], nsnull);
|
||||
|
||||
@@ -216,28 +251,26 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnStatusURLLoad(nsIDocumentLoader* loa
|
||||
aMsg.GetUnicode()));
|
||||
}
|
||||
#endif
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int length = aMsg.Length();
|
||||
|
||||
// IMPORTANT: do not use initContext->env here since it comes
|
||||
// from another thread. Use JNU_GetEnv instead.
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2);
|
||||
jstring statusMessage = ::util_NewString(env, aMsg.GetUnicode(), length);
|
||||
jstring statusMessage = ::util_NewString(env, (const jchar *)
|
||||
aMsg.GetUnicode(), length);
|
||||
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[STATUS_URL_LOAD_EVENT_MASK], (jobject) statusMessage);
|
||||
|
||||
#ifdef BAL_INTERFACE
|
||||
// This violates my goal of confining all #ifdef BAL_INTERFACE to
|
||||
// jni_util files, but this is the only part of the code that knows
|
||||
// that eventData is a jstring. In java, this will get garbage
|
||||
// collected, but in non-java contexts, it will not. Thus, we have
|
||||
// to manually de-allocate it.
|
||||
if (statusMessage) {
|
||||
::util_DeleteString(mInitContext->env, statusMessage);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -251,6 +284,11 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndURLLoad(nsIDocumentLoader* loader
|
||||
("!DocumentLoaderObserverImpl: OnEndURLLoad\n"));
|
||||
}
|
||||
#endif
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[END_URL_LOAD_EVENT_MASK], nsnull);
|
||||
|
||||
@@ -268,11 +306,55 @@ NS_IMETHODIMP DocumentLoaderObserverImpl::HandleUnknownContentType(nsIDocumentLo
|
||||
("!DocumentLoaderObserverImpl: HandleUnknownContentType\n"));
|
||||
}
|
||||
#endif
|
||||
// If we don't have a target, don't take any action
|
||||
if (nsnull == mTarget) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget,
|
||||
maskValues[UNKNOWN_CONTENT_EVENT_MASK], nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// Methods from DocumentLoaderObserverImpl
|
||||
//
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::AddMouseListener(nsCOMPtr<nsIDOMMouseListener> toAdd)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (nsnull == toAdd) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mMouseListener = toAdd;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::RemoveMouseListener(nsCOMPtr<nsIDOMMouseListener> toRemove)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::SetTarget(jobject yourTarget)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mTarget = yourTarget;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DocumentLoaderObserverImpl::ClearTarget(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
mTarget = nsnull;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,26 @@
|
||||
#include "nsISupportsUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDocumentLoaderObserver.h"
|
||||
|
||||
#include "jni_util.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
|
||||
class nsIURI;
|
||||
|
||||
#include "jni_util.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
/**
|
||||
|
||||
* We define a local IID to allow the addDocumentLoadListener and
|
||||
* addMouseListener functions in EventRegistration.{h,cpp} to
|
||||
* interrogate the currently installed DocumentLoaderObserver instance
|
||||
* in mozilla.
|
||||
|
||||
*/
|
||||
|
||||
#define NS_IDOCLOADEROBSERVERIMPL_IID_STR "fdadb2e0-3028-11d4-8a96-0080c7b9c5ba"
|
||||
|
||||
#define NS_IDOCLOADEROBSERVERIMPL_IID {0xfdadb2e0, 0x3028, 0x11d4, { 0x8a, 0x96, 0x00, 0x80, 0xc7, 0xb9, 0xc5, 0xba }}
|
||||
|
||||
/**
|
||||
|
||||
* This class is the shim between the mozilla listener event system for
|
||||
@@ -44,6 +59,15 @@ class nsIURI;
|
||||
* For each of the On* methods, we call the appropriate method in java.
|
||||
* See the implementation of OnEndDocumentLoad for an example.
|
||||
|
||||
* A DocumentLoaderObserverImpl instance has a "jobject target", which
|
||||
* is the Java object that should ultimately receive the events. This
|
||||
* target will be null if the user just wants to listen for mouse
|
||||
* events. It willl be non-null if the user wants to listen for
|
||||
* DocumentLoad events.
|
||||
|
||||
* It also hosts a nsIDOMMouseListener instance, which piggybacks on the
|
||||
* nsIDocumentLoaderObserver instance.
|
||||
|
||||
*/
|
||||
|
||||
class DocumentLoaderObserverImpl : public nsIDocumentLoaderObserver {
|
||||
@@ -72,10 +96,10 @@ static jlong maskValues [DocumentLoaderObserverImpl::EVENT_MASK_NAMES::NUMBER_OF
|
||||
static char *maskNames [];
|
||||
|
||||
DocumentLoaderObserverImpl(JNIEnv *yourJNIEnv,
|
||||
WebShellInitContext *yourInitContext,
|
||||
jobject yourTarget);
|
||||
WebShellInitContext *yourInitContext);
|
||||
|
||||
DocumentLoaderObserverImpl();
|
||||
virtual ~DocumentLoaderObserverImpl() {};
|
||||
|
||||
/* nsIDocumentLoaderObserver methods */
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
|
||||
@@ -107,11 +131,30 @@ static char *maskNames [];
|
||||
const char *aContentType,
|
||||
const char *aCommand);
|
||||
|
||||
//
|
||||
// Methods for NS_IDOCLOADEROBSERVERIMPL_IID
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
* Called in EventRegistration.{h,cpp} addMouseListener.
|
||||
|
||||
*/
|
||||
|
||||
NS_IMETHOD AddMouseListener(nsCOMPtr<nsIDOMMouseListener> toAdd);
|
||||
|
||||
NS_IMETHOD RemoveMouseListener(nsCOMPtr<nsIDOMMouseListener> toRemove);
|
||||
|
||||
NS_IMETHOD SetTarget(jobject newTarget);
|
||||
|
||||
NS_IMETHOD ClearTarget(void);
|
||||
|
||||
protected:
|
||||
|
||||
JNIEnv *mJNIEnv;
|
||||
WebShellInitContext *mInitContext;
|
||||
jobject mTarget;
|
||||
nsCOMPtr<nsIDOMMouseListener> mMouseListener;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
#include "EventRegistration.h"
|
||||
|
||||
#include "nsActions.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "DocumentLoaderObserverImpl.h"
|
||||
#include "DOMMouseListenerImpl.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDocumentLoaderObserverImplIID, NS_IDOCLOADEROBSERVERIMPL_IID);
|
||||
|
||||
void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
jobject listener)
|
||||
@@ -39,19 +43,101 @@ void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
// Assert (nsnull != initContext->nativeEventThread)
|
||||
|
||||
|
||||
PR_ASSERT(initContext->nativeEventThread);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocumentLoaderObserver> curObserver;
|
||||
nsCOMPtr<DocumentLoaderObserverImpl> myListener = nsnull;
|
||||
|
||||
// create the c++ "peer" for the DocumentLoadListener, which is an
|
||||
// nsIDocumentLoaderObserver.
|
||||
DocumentLoaderObserverImpl *observerImpl =
|
||||
new DocumentLoaderObserverImpl(env, initContext, listener);
|
||||
|
||||
wsAddDocLoaderObserverEvent *actionEvent =
|
||||
new wsAddDocLoaderObserverEvent(initContext->docShell,
|
||||
observerImpl);
|
||||
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostEvent(initContext, event);
|
||||
PR_ASSERT(nsnull != initContext->docShell);
|
||||
|
||||
// tricky logic to accomodate "piggybacking" a mouseListener.
|
||||
|
||||
// See if there already is a DocListener
|
||||
rv = initContext->docShell->GetDocLoaderObserver(getter_AddRefs(curObserver));
|
||||
if (NS_FAILED(rv) || !curObserver) {
|
||||
// if there is no listener, we need to create and add it now
|
||||
|
||||
// create the c++ "peer" for the DocumentLoadListener, which is an
|
||||
// nsIDocumentLoaderObserver.
|
||||
curObserver = new DocumentLoaderObserverImpl(env, initContext);
|
||||
if (nsnull == curObserver) {
|
||||
return;
|
||||
}
|
||||
|
||||
wsAddDocLoaderObserverEvent *actionEvent =
|
||||
new wsAddDocLoaderObserverEvent(initContext->docShell,
|
||||
curObserver);
|
||||
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostSynchronousEvent(initContext, event);
|
||||
}
|
||||
|
||||
if (curObserver) {
|
||||
// if we have an observer (either just created, or from mozilla),
|
||||
// install the target.
|
||||
|
||||
rv = curObserver->QueryInterface(kIDocumentLoaderObserverImplIID,
|
||||
getter_AddRefs(myListener));
|
||||
if (NS_SUCCEEDED(rv) && myListener) {
|
||||
myListener->SetTarget(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addMouseListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
jobject listener)
|
||||
{
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null initContext passed toaddDocumentLoadListener");
|
||||
return;
|
||||
}
|
||||
|
||||
if (initContext->initComplete) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocumentLoaderObserver> curObserver;
|
||||
nsCOMPtr<DocumentLoaderObserverImpl> myListener = nsnull;
|
||||
|
||||
PR_ASSERT(nsnull != initContext->docShell);
|
||||
|
||||
// See if there already is a DocListener
|
||||
rv = initContext->docShell->GetDocLoaderObserver(getter_AddRefs(curObserver));
|
||||
if (NS_SUCCEEDED(rv) && curObserver) {
|
||||
|
||||
// if so, se if it's something we added
|
||||
rv = curObserver->QueryInterface(kIDocumentLoaderObserverImplIID,
|
||||
getter_AddRefs(myListener));
|
||||
}
|
||||
else {
|
||||
|
||||
// if not, we need to create a listener
|
||||
myListener = new DocumentLoaderObserverImpl(env, initContext);
|
||||
// note that we don't call setTarget, since this
|
||||
// DocumentLoaderObserver is just for getting mouse events
|
||||
|
||||
// install our listener into mozilla
|
||||
wsAddDocLoaderObserverEvent *actionEvent =
|
||||
new wsAddDocLoaderObserverEvent(initContext->docShell,
|
||||
myListener);
|
||||
|
||||
PLEvent * event = (PLEvent*) *actionEvent;
|
||||
|
||||
::util_PostSynchronousEvent(initContext, event);
|
||||
}
|
||||
|
||||
if (nsnull == myListener) {
|
||||
// either the new failed, or the currently installed listener
|
||||
// wasn't installed by us. Either way, do nothing.
|
||||
return;
|
||||
}
|
||||
// we have a listener
|
||||
|
||||
nsCOMPtr<nsIDOMMouseListener> mouseListener =
|
||||
new DOMMouseListenerImpl(env, initContext, listener);
|
||||
|
||||
myListener->AddMouseListener(mouseListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,24 @@
|
||||
*/
|
||||
|
||||
void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
jobject listener);
|
||||
jobject listener);
|
||||
|
||||
/**
|
||||
|
||||
* This function creates an instance of DOMMouseListenerImpl,
|
||||
* which is the shim between the mozilla nsIDOMMouseListener class
|
||||
* and the Java MouseListener interface. See
|
||||
* DocumentLoaderObserverImpl.h
|
||||
|
||||
* PENDING(): implement removeMouseListener
|
||||
|
||||
* PENDING(): implement the ability to have multiple listener instances
|
||||
* per listener types, all of which get notified.
|
||||
|
||||
*/
|
||||
|
||||
void addMouseListener(JNIEnv *env, WebShellInitContext *initContext,
|
||||
jobject listener);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,8 @@ DLLNAMESTUB = libwebclientstub.so
|
||||
MOZILLA_TOP = ../../..
|
||||
DIST = ${MOZILLA_TOP}/dist
|
||||
LIBDIR = ${DIST}/lib
|
||||
#CC = gcc -g -fno-rtti -fno-exceptions -pedantic -Wno-long-long
|
||||
#MKSHLIB = c++ -G
|
||||
CC = CC -pic
|
||||
MKSHLIB = CC -G
|
||||
# WARNING: YOU NEED TO RUN 'gtk-config --cflags' and stick it in here
|
||||
@@ -115,6 +117,9 @@ jni_util.o: jni_util.cpp
|
||||
jni_util_export.o: jni_util_export.cpp
|
||||
${CC} ${DEFINES} ${INCLUDE} -c jni_util_export.cpp
|
||||
|
||||
bal_util.o: bal_util.cpp
|
||||
${CC} ${DEFINES} ${INCLUDE} -c bal_util.cpp
|
||||
|
||||
rdf_util.o: rdf_util.cpp
|
||||
${CC} ${DEFINES} ${INCLUDE} -c rdf_util.cpp
|
||||
|
||||
|
||||
@@ -32,10 +32,12 @@ OBJS = \
|
||||
.\$(OBJDIR)\jni_util.obj \
|
||||
.\$(OBJDIR)\jni_util_export.obj \
|
||||
.\$(OBJDIR)\rdf_util.obj \
|
||||
.\$(OBJDIR)\dom_util.obj \
|
||||
.\$(OBJDIR)\nsActions.obj \
|
||||
.\$(OBJDIR)\BookmarksImpl.obj \
|
||||
.\$(OBJDIR)\CurrentPageImpl.obj \
|
||||
.\$(OBJDIR)\DocumentLoaderObserverImpl.obj \
|
||||
.\$(OBJDIR)\DOMMouseListenerImpl.obj \
|
||||
.\$(OBJDIR)\EventRegistration.obj \
|
||||
.\$(OBJDIR)\HistoryImpl.obj \
|
||||
.\$(OBJDIR)\WrapperFactoryImpl.obj \
|
||||
@@ -76,6 +78,7 @@ LLIBS = \
|
||||
$(DIST)\lib\nsreg.lib \
|
||||
$(DIST)\lib\nspr3.lib \
|
||||
$(DIST)\lib\plds3.lib \
|
||||
$(DIST)\lib\plc3.lib \
|
||||
# $(DEPTH)\xpfe\bootstrap\$(OBJDIR)\nsSetupRegistry.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ char * errorMessages[] = {
|
||||
|
||||
const char *gSupportedListenerInterfaces[] = {
|
||||
"org/mozilla/webclient/DocumentLoadListener",
|
||||
"java/awt/event/MouseListener",
|
||||
nsnull
|
||||
};
|
||||
|
||||
@@ -118,6 +119,7 @@ const char *gSupportedListenerInterfaces[] = {
|
||||
|
||||
typedef enum {
|
||||
DOCUMENT_LOAD_LISTENER = 0,
|
||||
MOUSE_LISTENER,
|
||||
LISTENER_NOT_FOUND
|
||||
} LISTENER_CLASSES;
|
||||
|
||||
@@ -245,6 +247,9 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr
|
||||
case DOCUMENT_LOAD_LISTENER:
|
||||
addDocumentLoadListener(env, initContext, globalRef);
|
||||
break;
|
||||
case MOUSE_LISTENER:
|
||||
addMouseListener(env, initContext, globalRef);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
||||
if (::util_ExceptionOccurred(env)) {
|
||||
::util_ThrowExceptionToJava(env, "raptorWebShellLoadURL Exception: unable to extract Java string");
|
||||
if (urlStringChars != nsnull)
|
||||
::util_ReleaseStringChars(env, urlString, urlStringChars);
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
||||
if (initContext == nsnull) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellLoadURL");
|
||||
if (urlStringChars != nsnull)
|
||||
::util_ReleaseStringChars(env, urlString, urlStringChars);
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl
|
||||
::util_PostEvent(initContext, event);
|
||||
}
|
||||
|
||||
::util_ReleaseStringChars(env, urlString, urlStringChars);
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl_nativeRefresh
|
||||
|
||||
@@ -233,7 +233,7 @@ Java_org_mozilla_webclient_wrapper_1native_RDFTreeNode_nativeToString
|
||||
length = string->Length();
|
||||
}
|
||||
|
||||
result = ::util_NewString(env, textForNode, length);
|
||||
result = ::util_NewString(env, (const jchar *) textForNode, length);
|
||||
}
|
||||
else {
|
||||
result = ::util_NewStringUTF(env, "");
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include "bal_util.h"
|
||||
|
||||
#include "wchar.h"
|
||||
|
||||
void JNICALL bal_jstring_newFromAscii(jstring *newStr, const char *value)
|
||||
{
|
||||
jint length;
|
||||
|
||||
114
mozilla/java/webclient/src_moz/dom_util.cpp
Normal file
114
mozilla/java/webclient/src_moz/dom_util.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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 Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#include "dom_util.h"
|
||||
|
||||
#include "ns_globals.h" // for prLogModuleInfo and gComponentManager
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIDOMEventTarget.h"
|
||||
|
||||
nsresult dom_iterateToRoot(nsCOMPtr<nsIDOMNode> currentNode,
|
||||
fpTakeActionOnNodeType nodeFunction,
|
||||
void *yourObject)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
nsresult rv;
|
||||
|
||||
if (nodeFunction) {
|
||||
rv = nodeFunction(currentNode, yourObject);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = currentNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
if (nsnull == parentNode) {
|
||||
return rv;
|
||||
}
|
||||
dom_iterateToRoot(parentNode, nodeFunction, yourObject);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> dom_getDocumentFromLoader(nsIDocumentLoader *loader)
|
||||
{
|
||||
PR_ASSERT(nsnull != loader);
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsISupports> container;
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
nsCOMPtr<nsIDOMDocument> result = nsnull;
|
||||
|
||||
rv = loader->GetContainer(getter_AddRefs(container));
|
||||
if (NS_FAILED(rv) || !container) {
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = container->QueryInterface(NS_GET_IID(nsIDocShell),
|
||||
getter_AddRefs(docShell));
|
||||
if (NS_FAILED(rv) || !docShell) {
|
||||
return result;
|
||||
}
|
||||
result = dom_getDocumentFromDocShell(docShell);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> dom_getDocumentFromDocShell(nsIDocShell *docShell)
|
||||
{
|
||||
PR_ASSERT(nsnull != docShell);
|
||||
nsCOMPtr<nsIDOMDocument> result = nsnull;
|
||||
nsCOMPtr<nsIContentViewer> contentv;
|
||||
nsCOMPtr<nsIDocumentViewer> docv;
|
||||
nsIDocument *document; // PENDING(edburns): does GetDocument do an AddRef?
|
||||
nsresult rv;
|
||||
|
||||
rv = docShell->GetContentViewer(getter_AddRefs(contentv));
|
||||
if (NS_FAILED(rv) || !contentv) {
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = contentv->QueryInterface(NS_GET_IID(nsIDocumentViewer),
|
||||
getter_AddRefs(docv));
|
||||
if (NS_FAILED(rv) || !docv) {
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = docv->GetDocument(document);
|
||||
if (NS_FAILED(rv) || !document) {
|
||||
return result;
|
||||
}
|
||||
|
||||
rv = document->QueryInterface(NS_GET_IID(nsIDOMDocument),
|
||||
getter_AddRefs(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
77
mozilla/java/webclient/src_moz/dom_util.h
Normal file
77
mozilla/java/webclient/src_moz/dom_util.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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 Original Code is RaptorCanvas.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Kirk Baker and
|
||||
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
|
||||
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Ed Burns <edburns@acm.org>
|
||||
*/
|
||||
|
||||
#ifndef dom_util_h
|
||||
#define dom_util_h
|
||||
|
||||
#include <jni.h> // for JNICALL
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMNode.h"
|
||||
class nsIDocumentLoader;
|
||||
class nsIDocShell;
|
||||
|
||||
/**
|
||||
|
||||
* Methods to simplify webclient accessing the mozilla DOM.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
* Used in conjunction with dom_iterateToRoot to allow action to be
|
||||
* taken on each node in a path from a node to the root.
|
||||
|
||||
*/
|
||||
|
||||
typedef nsresult (JNICALL *fpTakeActionOnNodeType) (nsCOMPtr<nsIDOMNode> curNode,
|
||||
void *yourObject);
|
||||
|
||||
/**
|
||||
|
||||
* Starting from startNode, recursively ascend the DOM tree to the root,
|
||||
* calling the user provided function at each node, passing the user
|
||||
* provided object to the function.
|
||||
|
||||
*/
|
||||
|
||||
nsresult dom_iterateToRoot(nsCOMPtr<nsIDOMNode> startNode,
|
||||
fpTakeActionOnNodeType nodeFunction,
|
||||
void *yourObject);
|
||||
|
||||
/**
|
||||
|
||||
* Given an nsIDocumentLoader instance, obtain the nsIDOMDocument instance.
|
||||
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> dom_getDocumentFromLoader(nsIDocumentLoader *loader);
|
||||
|
||||
/**
|
||||
|
||||
* Given an nsIDocShell instance, obtain the nsIDOMDocument instance.
|
||||
|
||||
*/
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> dom_getDocumentFromDocShell(nsIDocShell *docShell);
|
||||
|
||||
#endif // dom_util_h
|
||||
@@ -25,11 +25,21 @@
|
||||
* Ann Sunhachawee
|
||||
*/
|
||||
|
||||
#include "prlog.h" // for PR_ASSERT
|
||||
|
||||
#include "jni_util.h"
|
||||
|
||||
JavaVM *gVm = nsnull; // declared in ns_globals.h, which is included in
|
||||
// jni_util.h
|
||||
|
||||
//
|
||||
// Local cache variables of JNI data items
|
||||
//
|
||||
|
||||
static jclass gPropertiesClass = nsnull;
|
||||
static jmethodID gPropertiesInitMethodID = nsnull;
|
||||
static jmethodID gPropertiesSetPropertyMethodID = nsnull;
|
||||
|
||||
void util_ThrowExceptionToJava (JNIEnv * env, const char * message)
|
||||
{
|
||||
if (env->ExceptionOccurred()) {
|
||||
@@ -358,7 +368,73 @@ void util_SetIntValueForInstance(JNIEnv *env, jobject obj,
|
||||
#endif;
|
||||
}
|
||||
|
||||
jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed)
|
||||
{
|
||||
jobject result = nsnull;
|
||||
#ifdef BAL_INTERFACE
|
||||
if (nsnull != externalCreatePropertiesObject) {
|
||||
result = externalCreatePropertiesObject(env, reserved_NotUsed);
|
||||
}
|
||||
#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"))) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = env->NewObject(gPropertiesClass, gPropertiesInitMethodID);
|
||||
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject,
|
||||
jobject reserved_NotUsed)
|
||||
{
|
||||
#ifdef BAL_INTERFACE
|
||||
if (nsnull != externalDestroyPropertiesObject) {
|
||||
externalDestroyPropertiesObject(env, propertiesObject,
|
||||
reserved_NotUsed);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject,
|
||||
jobject name, jobject value)
|
||||
{
|
||||
#ifdef BAL_INTERFACE
|
||||
if (nsnull != externalStoreIntoPropertiesObject) {
|
||||
externalStoreIntoPropertiesObject(env, propertiesObject, name, value);
|
||||
}
|
||||
#else
|
||||
if (nsnull == gPropertiesSetPropertyMethodID) {
|
||||
PR_ASSERT(gPropertiesClass);
|
||||
if (nsnull == (gPropertiesSetPropertyMethodID =
|
||||
env->GetMethodID(gPropertiesClass,
|
||||
"setProperty",
|
||||
"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;"))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
PR_ASSERT(gPropertiesSetPropertyMethodID);
|
||||
|
||||
env->CallObjectMethod(propertiesObject, gPropertiesSetPropertyMethodID,
|
||||
name, value);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
JNIEXPORT jvalue JNICALL
|
||||
JNU_CallMethodByName(JNIEnv *env,
|
||||
|
||||
@@ -182,6 +182,34 @@ jint util_GetIntValueFromInstance(JNIEnv *env, jobject instance,
|
||||
void util_SetIntValueForInstance(JNIEnv *env, jobject instance,
|
||||
const char *fieldName, jint newValue);
|
||||
|
||||
/**
|
||||
|
||||
* A JNI wrapper to create a java.util.Properties object, or the
|
||||
* equivalent object in the BAL case.
|
||||
|
||||
*/
|
||||
|
||||
jobject util_CreatePropertiesObject(JNIEnv *env, jobject reserved_NotUsed);
|
||||
|
||||
/**
|
||||
|
||||
* A JNI wrapper to destroy the object from CreatePropertiesObject
|
||||
|
||||
*/
|
||||
|
||||
void util_DestroyPropertiesObject(JNIEnv *env, jobject propertiesObject,
|
||||
jobject reserved_NotUsed);
|
||||
|
||||
/**
|
||||
|
||||
* A JNI wrapper for storing a name/value pair into the Properties
|
||||
* object created by CreatePropertiesObject
|
||||
|
||||
*/
|
||||
|
||||
void util_StoreIntoPropertiesObject(JNIEnv *env, jobject propertiesObject,
|
||||
jobject name, jobject value);
|
||||
|
||||
|
||||
//
|
||||
// Functions from secret JDK files
|
||||
|
||||
@@ -40,6 +40,12 @@ fpInstanceOfType externalInstanceOf = nsnull; // jni_util_export.h
|
||||
|
||||
fpInitializeEventMaskType externalInitializeEventMask = nsnull; // jni_util_export.h
|
||||
|
||||
fpCreatePropertiesObjectType externalCreatePropertiesObject = nsnull; // jni_util_export.h
|
||||
|
||||
fpDestroyPropertiesObjectType externalDestroyPropertiesObject = nsnull; // jni_util_export.h
|
||||
|
||||
fpStoreIntoPropertiesObjectType externalStoreIntoPropertiesObject = nsnull; // jni_util_export.h
|
||||
|
||||
JNIEXPORT const char * JNICALL util_GetStringUTFChars(JNIEnv *env,
|
||||
jstring inString)
|
||||
{
|
||||
@@ -114,10 +120,7 @@ JNIEXPORT void JNICALL util_DeleteStringUTF(JNIEnv *env, jstring toDelete)
|
||||
#ifdef BAL_INTERFACE
|
||||
util_DeleteString(env, toDelete);
|
||||
#else
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("This shouldn't get called in a non-BAL context!\n"));
|
||||
}
|
||||
// do nothing, java takes care of it
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -140,10 +143,7 @@ JNIEXPORT void JNICALL util_DeleteString(JNIEnv *env, jstring toDelete)
|
||||
#ifdef BAL_INTERFACE
|
||||
bal_jstring_release(toDelete);
|
||||
#else
|
||||
if (prLogModuleInfo) {
|
||||
PR_LOG(prLogModuleInfo, 3,
|
||||
("This shouldn't get called in a non-BAL context!\n"));
|
||||
}
|
||||
// do nothing, java takes care of it
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -193,6 +193,21 @@ JNIEXPORT void JNICALL util_SetInitializeEventMaskFunction(fpInitializeEventMask
|
||||
externalInitializeEventMask = fp;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_SetCreatePropertiesObjectFunction(fpCreatePropertiesObjectType fp)
|
||||
{
|
||||
externalCreatePropertiesObject = fp;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_SetDestroyPropertiesObjectFunction(fpDestroyPropertiesObjectType fp)
|
||||
{
|
||||
externalDestroyPropertiesObject = fp;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL util_SetStoreIntoPropertiesObjectFunction(fpStoreIntoPropertiesObjectType fp)
|
||||
{
|
||||
externalStoreIntoPropertiesObject = fp;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
util_InitializeEventMaskValuesFromClass(const char *className,
|
||||
char *maskNames[],
|
||||
|
||||
@@ -149,7 +149,48 @@ typedef JNIEXPORT void (JNICALL * fpInitializeEventMaskType)
|
||||
jclass listenerClass,
|
||||
const char **nullTermMaskNameArray,
|
||||
jlong *maskValueArray);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* Called when webclient wants to create a "Properties" object. Right
|
||||
* now, no parameters are actually used.
|
||||
|
||||
*/
|
||||
|
||||
typedef JNIEXPORT jobject (JNICALL * fpCreatePropertiesObjectType)
|
||||
(JNIEnv *env, jobject reserved_NotUsed);
|
||||
|
||||
/**
|
||||
|
||||
* Called after webclient is done using a "Properties" object it created
|
||||
* with fpCreatePropertiesObject
|
||||
|
||||
* @param propertiesObject the propertiesObject created with
|
||||
* fpCreatePropertiesObject
|
||||
|
||||
*/
|
||||
|
||||
typedef JNIEXPORT void (JNICALL * fpDestroyPropertiesObjectType)
|
||||
(JNIEnv *env, jobject propertiesObject, jobject reserved_NotUsed);
|
||||
|
||||
/**
|
||||
|
||||
* Called after webclient has called fpCreatePropertiesObjectType when
|
||||
* webclient wants to store values into the properties object.
|
||||
|
||||
* @param env not used
|
||||
|
||||
* @param propertiesObject obtained from fpCreatePropertiesObjectType
|
||||
|
||||
* @param name the name of the property
|
||||
|
||||
* @param the value of the property
|
||||
|
||||
*/
|
||||
|
||||
typedef JNIEXPORT void (JNICALL * fpStoreIntoPropertiesObjectType)
|
||||
(JNIEnv *env, jobject propertiesObject, jobject name, jobject value);
|
||||
|
||||
/**
|
||||
|
||||
* This function must be called at app initialization.
|
||||
@@ -180,6 +221,37 @@ JNIEXPORT void JNICALL util_SetEventOccurredFunction(fpEventOccurredType fp);
|
||||
|
||||
JNIEXPORT void JNICALL util_SetInitializeEventMaskFunction(fpInitializeEventMaskType fp);
|
||||
|
||||
/**
|
||||
|
||||
* This function must be called at app initialization.
|
||||
|
||||
* @see fpCreatePropertiesObjectType
|
||||
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL util_SetCreatePropertiesObjectFunction(fpCreatePropertiesObjectType fp);
|
||||
|
||||
/**
|
||||
|
||||
* This function must be called at app initialization.
|
||||
|
||||
* @see fpDestroyPropertiesObjectType
|
||||
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL util_SetDestroyPropertiesObjectFunction(fpDestroyPropertiesObjectType fp);
|
||||
|
||||
/**
|
||||
|
||||
* This function must be called at app initialization.
|
||||
|
||||
* @see fpStoreIntoPropertiesObjectType
|
||||
|
||||
*/
|
||||
|
||||
JNIEXPORT void JNICALL util_SetStoreIntoPropertiesObjectFunction(fpStoreIntoPropertiesObjectType fp);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,6 +283,36 @@ extern fpInstanceOfType externalInstanceOf;
|
||||
|
||||
extern fpInitializeEventMaskType externalInitializeEventMask;
|
||||
|
||||
/**
|
||||
|
||||
* defined in jni_util_export.cpp
|
||||
|
||||
* The function pointer set with util_SetCreatePropertiesObjectFunction
|
||||
|
||||
*/
|
||||
|
||||
extern fpCreatePropertiesObjectType externalCreatePropertiesObject;
|
||||
|
||||
/**
|
||||
|
||||
* defined in jni_util_export.cpp
|
||||
|
||||
* The function pointer set with util_SetDestroyPropertiesObjectFunction
|
||||
|
||||
*/
|
||||
|
||||
extern fpDestroyPropertiesObjectType externalDestroyPropertiesObject;
|
||||
|
||||
/**
|
||||
|
||||
* defined in jni_util_export.cpp
|
||||
|
||||
* The function pointer set with util_SetStoreIntoPropertiesObjectFunction
|
||||
|
||||
*/
|
||||
|
||||
extern fpStoreIntoPropertiesObjectType externalStoreIntoPropertiesObject;
|
||||
|
||||
/**
|
||||
|
||||
* Called by the mozilla event listener implementation class at
|
||||
|
||||
Reference in New Issue
Block a user