This checkin enables the StartDocumentLoadEvent. Now adding the rest of

the DocumentLoadListener events will be trivial.

Next step: flesh out the rest of the DocumentLoadListener events.
Modify NavigationTest so that it does its selection checking inside the
listeners.  This will probably require creating a Thread, managed by
EventRegistrationImpl, that is used to process callbacks from mozilla
into Java, so that we don't get deadlock.

M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java

- remove all dependencies on NativeEventThread

- introduce dependency on BrowserControlCanvas (needed for future
  MouseListener) work.

- {add,remove}DocumentLoadListener() now just a matter of
  adding/removing to List.

- add nativeEventOccurred() method, called from native code

M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java

- remove dependency on BrowserControlCanvas

- removed nativeEventOccurred

M src_moz/EmbedProgress.cpp

- delete the global ref in the dtor.

- create the global ref in SetEventRegistration().

- call back to Java on startDocumentLoad.

M src_moz/NativeBrowserControl.cpp

- initialize our string constants.

M src_share/jni_util.cpp
M src_share/jni_util.h

- alter the signature of util_SendEventToJava

-void util_SendEventToJava(JNIEnv *yourEnv, jobject nativeEventThread,
-                          jobject webclientEventListener,
+void util_SendEventToJava(JNIEnv *yourEnv, jobject eventRegistrationImpl,
                           jstring eventListenerClassName,
                           jlong eventType, jobject eventData)

M test/automated/src/classes/org/mozilla/webclient/NavigationTest.java

- show that the DocumentLoadListener gets called.


git-svn-id: svn://10.0.0.236/trunk@157818 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2004-06-12 05:46:48 +00:00
parent fbabb8e7d7
commit cf2ea3a91d
8 changed files with 126 additions and 156 deletions

View File

@@ -36,10 +36,17 @@
EmbedProgress::EmbedProgress(void)
{
mOwner = nsnull;
mEventRegistration = nsnull;
}
EmbedProgress::~EmbedProgress()
{
if (nsnull != mEventRegistration) {
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
::util_DeleteGlobalRef(env, mEventRegistration);
mEventRegistration = nsnull;
}
}
NS_IMPL_ISUPPORTS2(EmbedProgress,
@@ -63,8 +70,16 @@ EmbedProgress::Init(NativeBrowserControl *aOwner)
nsresult
EmbedProgress::SetEventRegistration(jobject yourEventRegistration)
{
mEventRegistration = yourEventRegistration;
return NS_OK;
nsresult rv = NS_OK;
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
mEventRegistration = ::util_NewGlobalRef(env, yourEventRegistration);
if (nsnull == mEventRegistration) {
::util_ThrowExceptionToJava(env, "Exception: EmbedProgress->SetEventRegistration(): can't create NewGlobalRef\n\tfor eventRegistration");
rv = NS_ERROR_FAILURE;
}
return rv;
}
NS_IMETHODIMP
@@ -73,18 +88,20 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
PRUint32 aStateFlags,
nsresult aStatus)
{
// get the uri for this request
nsXPIDLCString uriString;
RequestToURIString(aRequest, getter_Copies(uriString));
nsString tmpString;
tmpString.AssignWithConversion(uriString);
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("EmbedProgress::OnStateChange: URI: %s\n",
(const char *) uriString));
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
nsXPIDLCString uriString;
RequestToURIString(aRequest, getter_Copies(uriString));
jstring uriJstr = ::util_NewStringUTF(env, (const char *) uriString);
nsString tmpString;
tmpString.AssignWithConversion(uriString);
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("EmbedProgress::OnStateChange: URI: %s\n",
(const char *) uriString));
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, ("debug: edburns: EmbedProgress::OnStateChange: interpreting flags\n"));
if (aStateFlags & STATE_IS_REQUEST) {
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, ("debug: edburns: EmbedProgress::OnStateChange: STATE_IS_REQUEST\n"));
}
@@ -97,7 +114,7 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
if (aStateFlags & STATE_IS_WINDOW) {
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, ("debug: edburns: EmbedProgress::OnStateChange: STATE_IS_WINDOW\n"));
}
if (aStateFlags & STATE_START) {
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG, ("debug: edburns: EmbedProgress::OnStateChange: STATE_START\n"));
}
@@ -122,6 +139,12 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
if ((aStateFlags & STATE_IS_NETWORK) &&
(aStateFlags & STATE_START))
{
util_SendEventToJava(nsnull,
mEventRegistration,
DOCUMENT_LOAD_LISTENER_CLASSNAME,
DocumentLoader_maskValues[START_DOCUMENT_LOAD_EVENT_MASK],
uriJstr);
// gtk_signal_emit(GTK_OBJECT(mOwner->mOwningWidget),
// moz_embed_signals[NET_START]);
}
@@ -152,6 +175,8 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
*********/
}
::util_DeleteStringUTF(env, uriJstr);
return NS_OK;
}