bug 79278

This checkin migrates javaDOM to use the new nsIWebProgressListener
interface, removing its dependency on the now non-existant
nsIDocumentLoaderObserver.

It has only been tested inside webclient.  QA needs to do the standalone
javaDOM tests.

The following files are in this bugfix:

dom/jni/org_mozilla_dom_DOMAccessor.cpp
dom/src/nsIJavaDOM.h
dom/src/nsJavaDOMImpl.cpp
dom/src/nsJavaDOMImpl.h
webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java
webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java


git-svn-id: svn://10.0.0.236/trunk@94264 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2001-05-08 20:34:31 +00:00
parent 687609c9ea
commit df9807ce08
6 changed files with 2259 additions and 2158 deletions

View File

@@ -1,118 +1,138 @@
#include "prlog.h"
#include "javaDOMGlobals.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderObserver.h"
#include "nsIServiceManager.h"
#include "nsCURILoader.h"
#include "nsIJavaDOM.h"
#include "org_mozilla_dom_DOMAccessor.h"
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
static NS_DEFINE_IID(kJavaDOMCID, NS_JAVADOM_CID);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: register
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_register
(JNIEnv *env, jclass jthis)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv);
if (NS_FAILED(rv) || !docLoaderService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
rv));
} else {
NS_WITH_SERVICE(nsIDocumentLoaderObserver, javaDOM, kJavaDOMCID, &rv);
if (NS_FAILED(rv) || !javaDOM) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
rv));
} else {
rv = docLoaderService->AddObserver((nsIDocumentLoaderObserver*)javaDOM);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: AddObserver(JavaDOM) failed x\n",
rv));
}
}
}
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: unregister
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_unregister
(JNIEnv *, jclass jthis)
{
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
("DOMAccessor::unregister: unregistering %x\n", jthis));
nsresult rv = NS_OK;
NS_WITH_SERVICE(nsIDocumentLoader, docLoaderService, kDocLoaderServiceCID, &rv);
if (NS_FAILED(rv) || !docLoaderService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: GetService(DocLoaderService) failed %x\n",
rv));
} else {
NS_WITH_SERVICE(nsIDocumentLoaderObserver, javaDOM, kJavaDOMCID, &rv);
if (NS_FAILED(rv) || !javaDOM) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: GetService(JavaDOM) failed %x\n",
rv));
} else {
rv = docLoaderService->RemoveObserver((nsIDocumentLoaderObserver*)javaDOM);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: RemoveObserver(JavaDOM) failed x\n",
rv));
}
}
}
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: createElement
* Signature: (J)Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessor_getNodeByHandle
(JNIEnv *env, jclass jthis, jlong p)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
nsIDOMNode *node = (nsIDOMNode*)p;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: doGC
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_doGC
(JNIEnv *, jclass)
{
JavaDOMGlobals::TakeOutGarbage();
}
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_initialize
(JNIEnv *env, jclass)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
}
#include "prlog.h"
#include "javaDOMGlobals.h"
#include "nsIDocumentLoader.h"
#include "nsIWebProgress.h"
#include "nsIWebProgressListener.h"
#include "nsIServiceManager.h"
#include "nsCURILoader.h"
#include "nsIJavaDOM.h"
#include "org_mozilla_dom_DOMAccessor.h"
static NS_DEFINE_IID(kJavaDOMCID, NS_JAVADOM_CID);
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: register
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_register
(JNIEnv *env, jclass jthis)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
nsresult rv = NS_OK;
nsCOMPtr<nsIDocumentLoader> docLoaderService =
do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
nsCOMPtr<nsIWebProgress> webProgressService;
if (NS_FAILED(rv) || !docLoaderService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
rv));
} else {
NS_WITH_SERVICE(nsIWebProgressListener, javaDOM, kJavaDOMCID, &rv);
if (NS_FAILED(rv) || !javaDOM) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: GetService(JavaDOM) failed: %x\n",
rv));
} else {
webProgressService = do_QueryInterface(docLoaderService, &rv);
if (NS_FAILED(rv) || !webProgressService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: QueryInterface(nsIWebProgressService) failed: %x\n",
rv));
} else {
rv = webProgressService->AddProgressListener((nsIWebProgressListener*)javaDOM);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::register: AddObserver(JavaDOM) failed x\n",
rv));
}
}
}
}
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: unregister
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_unregister
(JNIEnv *, jclass jthis)
{
PR_LOG(JavaDOMGlobals::log, PR_LOG_DEBUG,
("DOMAccessor::unregister: unregistering %x\n", jthis));
nsresult rv = NS_OK;
nsCOMPtr<nsIDocumentLoader> docLoaderService =
do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
nsCOMPtr<nsIWebProgress> webProgressService;
if (NS_FAILED(rv) || !docLoaderService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: GetService(DocLoaderService) failed %x\n",
rv));
} else {
NS_WITH_SERVICE(nsIWebProgressListener, javaDOM, kJavaDOMCID, &rv);
if (NS_FAILED(rv) || !javaDOM) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: GetService(JavaDOM) failed %x\n",
rv));
} else {
webProgressService = do_QueryInterface(docLoaderService, &rv);
if (NS_FAILED(rv) || !webProgressService) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: QueryInterface(nsIWebProgressService) failed: %x\n",
rv));
} else {
rv = webProgressService->RemoveProgressListener((nsIWebProgressListener*)javaDOM);
if (NS_FAILED(rv)) {
PR_LOG(JavaDOMGlobals::log, PR_LOG_ERROR,
("DOMAccessor::unregister: RemoveObserver(JavaDOM) failed x\n",
rv));
}
}
}
}
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: createElement
* Signature: (J)Lorg/w3c/dom/Element;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_dom_DOMAccessor_getNodeByHandle
(JNIEnv *env, jclass jthis, jlong p)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
nsIDOMNode *node = (nsIDOMNode*)p;
return JavaDOMGlobals::CreateNodeSubtype(env, node);
}
/*
* Class: org_mozilla_dom_DOMAccessor
* Method: doGC
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_doGC
(JNIEnv *, jclass)
{
JavaDOMGlobals::TakeOutGarbage();
}
JNIEXPORT void JNICALL Java_org_mozilla_dom_DOMAccessor_initialize
(JNIEnv *env, jclass)
{
if (!JavaDOMGlobals::log) {
JavaDOMGlobals::Initialize(env);
}
}

View File

@@ -1,75 +1,69 @@
/*
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 mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __nsIJavaDOM_h__
#define __nsIJavaDOM_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIDocumentLoaderObserver.h"
#include "jni.h"
class nsIURI;
/* {9cc0ca50-0e31-11d3-8a61-0004ac56c4a5} */
#define NS_IJAVADOM_IID_STR "9cc0ca50-0e31-11d3-8a61-0004ac56c4a5"
#define NS_IJAVADOM_IID \
{0x9cc0ca50, 0x0e31, 0x11d3, \
{ 0x8a, 0x61, 0x00, 0x04, 0xac, 0x56, 0xc4, 0xa5 }}
#define NS_JAVADOM_CID \
{0xd6b2e820, 0x9113, 0x11d3, \
{ 0x9c, 0x11, 0x0, 0x10, 0x5a , 0xe3, 0x80 , 0x1e }}
class nsIJavaDOM : public nsIDocumentLoaderObserver {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IJAVADOM_IID)
/* nsIDocumentLoaderObserver methods */
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
nsIURI* aURL,
const char* aCommand) = 0;
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsresult aStatus) = 0;
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
nsIRequest* request) = 0;
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
PRUint32 aProgress,
PRUint32 aProgressMax) = 0;
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsString& aMsg) = 0;
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsresult aStatus) = 0;
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
nsIChannel* channel,
const char *aContentType,
const char *aCommand) = 0;
};
#endif /* __nsIJavaDOM_h__ */
/*
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 mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __nsIJavaDOM_h__
#define __nsIJavaDOM_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIWebProgressListener.h"
#include "jni.h"
class nsIURI;
/* {9cc0ca50-0e31-11d3-8a61-0004ac56c4a5} */
#define NS_IJAVADOM_IID_STR "9cc0ca50-0e31-11d3-8a61-0004ac56c4a5"
#define NS_IJAVADOM_IID \
{0x9cc0ca50, 0x0e31, 0x11d3, \
{ 0x8a, 0x61, 0x00, 0x04, 0xac, 0x56, 0xc4, 0xa5 }}
#define NS_JAVADOM_CID \
{0xd6b2e820, 0x9113, 0x11d3, \
{ 0x9c, 0x11, 0x0, 0x10, 0x5a , 0xe3, 0x80 , 0x1e }}
class nsIJavaDOM : public nsIWebProgressListener {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IJAVADOM_IID)
NS_IMETHOD OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest,
PRInt32 aStateFlags, PRUint32 aStatus) = 0;
NS_IMETHOD OnProgressChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress) = 0;
NS_IMETHOD OnLocationChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, nsIURI *location) = 0;
NS_IMETHOD OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest,
nsresult aStatus, const PRUnichar *aMessage) = 0;
NS_IMETHOD OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRInt32 state) = 0;
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
nsIChannel* channel,
const char *aContentType,
const char *aCommand) = 0;
};
#endif /* __nsIJavaDOM_h__ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,77 +1,67 @@
#ifndef __nsJavaDOMImpl_h__
#define __nsJavaDOMImpl_h__
#include "jni.h"
#include "nsIJavaDOM.h"
#ifdef JAVA_DOM_OJI_ENABLE
#include "nsJVMManager.h"
#include "JavaDOMSecurityContext.h"
#endif
class nsIURI;
class nsIDOMDocument;
class nsIDocumentLoader;
class nsJavaDOMImpl : public nsIJavaDOM {
NS_DECL_ISUPPORTS
public:
nsJavaDOMImpl();
virtual ~nsJavaDOMImpl();
/* nsIDocumentLoaderObserver methods */
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader,
nsIURI* aURL,
const char* aCommand);
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsresult aStatus);
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
nsIRequest* channel);
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
PRUint32 aProgress,
PRUint32 aProgressMax);
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsString& aMsg);
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader,
nsIRequest* request,
nsresult aStatus);
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
nsIChannel* channel,
const char *aContentType,
const char *aCommand);
private:
#ifdef JAVA_DOM_OJI_ENABLE
static nsJVMManager* jvmManager;
static JavaDOMSecurityContext* securityContext;
#else
static JavaVM* jvm;
#endif
static jclass domAccessorClass;
static jmethodID startURLLoadMID;
static jmethodID endURLLoadMID;
static jmethodID progressURLLoadMID;
static jmethodID statusURLLoadMID;
static jmethodID startDocumentLoadMID;
static jmethodID endDocumentLoadMID;
static JNIEnv* GetJNIEnv(void);
static void StartJVM(void);
static PRBool Init(JNIEnv**);
// cleanup after a JNI method invocation
static PRBool Cleanup(JNIEnv* env);
nsIDOMDocument* GetDocument(nsIDocumentLoader* loader);
};
#endif /* __nsJavaDOMImpl_h__ */
#ifndef __nsJavaDOMImpl_h__
#define __nsJavaDOMImpl_h__
#include "jni.h"
#include "nsIJavaDOM.h"
#ifdef JAVA_DOM_OJI_ENABLE
#include "nsJVMManager.h"
#include "JavaDOMSecurityContext.h"
#endif
class nsIURI;
class nsIDOMDocument;
class nsIDocumentLoader;
class nsJavaDOMImpl : public nsIJavaDOM {
NS_DECL_ISUPPORTS
public:
nsJavaDOMImpl();
virtual ~nsJavaDOMImpl();
NS_DECL_NSIWEBPROGRESSLISTENER
NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader,
nsIChannel* channel,
const char *aContentType,
const char *aCommand);
protected:
/**
* Called from our nsIWebProgressListener.OnStateChanged()
*/
NS_IMETHOD doStartDocumentLoad(const PRUnichar *documentName);
NS_IMETHOD doStartUrlLoad(const PRUnichar *documentName);
NS_IMETHOD doEndDocumentLoad(nsIWebProgress *aWebProgress,
nsIRequest *aRequest, PRUint32 aStatus);
private:
#ifdef JAVA_DOM_OJI_ENABLE
static nsJVMManager* jvmManager;
static JavaDOMSecurityContext* securityContext;
#else
static JavaVM* jvm;
#endif
static jclass domAccessorClass;
static jmethodID startURLLoadMID;
static jmethodID endURLLoadMID;
static jmethodID progressURLLoadMID;
static jmethodID statusURLLoadMID;
static jmethodID startDocumentLoadMID;
static jmethodID endDocumentLoadMID;
static JNIEnv* GetJNIEnv(void);
static void StartJVM(void);
static PRBool Init(JNIEnv**);
// cleanup after a JNI method invocation
static PRBool Cleanup(JNIEnv* env);
nsIDOMDocument* GetDocument(nsIDocumentLoader* loader);
};
#endif /* __nsJavaDOMImpl_h__ */