This checkin uses the information in this nntp post:

From: valeski@netscape.com (Judson Valeski)
Newsgroups: netscape.public.mozilla.embedding
Subject: Re: nsIDocumentLoaderObserver migration guide?
Date: 8 May 2001 14:41:33 GMT
Organization: Another Netscape Collabra Server User
Lines: 44
Message-ID: <3AF8059A.D83EAAF@netscape.com>

To enable fine grained status tracking in webclient.

The following files are in this checkin.

M classes_spec/org/mozilla/webclient/test/EMWindow.java
M src_moz/CBrowserContainer.cpp
M src_moz/CBrowserContainer.h


git-svn-id: svn://10.0.0.236/trunk@94282 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2001-05-08 21:57:57 +00:00
parent 610fe60930
commit 8ced81e20c
3 changed files with 106 additions and 26 deletions

View File

@@ -57,7 +57,7 @@ import java.io.FileInputStream;
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.28 2001-05-08 20:54:12 edburns%acm.org Exp $
* @version $Id: EMWindow.java,v 1.29 2001-05-08 21:57:53 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
@@ -94,6 +94,7 @@ private UniversalDialog uniDialog = null;
private HistoryActionListener historyActionListener = null;
private Menu bookmarksMenu;
private Label statusLabel;
private Label urlStatusLabel;
private String currentURL;
private Document currentDocument = null;
@@ -233,10 +234,18 @@ private UniversalDialog uniDialog = null;
statusPanel = new Panel();
statusPanel.setLayout(new BorderLayout());
// create and add the statusLabel
// create and add the statusLabel and the urlStatusLabel
statusLabel = new Label("", Label.LEFT);
statusLabel.setBackground(Color.lightGray);
statusPanel.add(statusLabel, BorderLayout.CENTER);
urlStatusLabel = new Label("", Label.LEFT);
urlStatusLabel.setBackground(Color.lightGray);
Panel tPanel = new Panel();
tPanel.setLayout(new BorderLayout());
tPanel.add(statusLabel, BorderLayout.NORTH);
tPanel.add(urlStatusLabel, BorderLayout.SOUTH);
statusPanel.add(tPanel, BorderLayout.CENTER);
// Create the browser
try {
@@ -663,6 +672,7 @@ public void eventDispatched(WebclientEvent event)
forwardMenuItem.setEnabled(history.canForward());
populateHistoryMenu();
statusLabel.setText("Done.");
urlStatusLabel.setText("");
currentDocument = currentPage.getDOM();
// add the new document to the domViewer
if (null != currentDocument && null != domViewer) {
@@ -678,6 +688,14 @@ public void eventDispatched(WebclientEvent event)
status = "Status: " + (String) event.getEventData();
statusLabel.setText(status);
break;
case ((int) DocumentLoadEvent.START_URL_LOAD_EVENT_MASK):
status = (String) event.getEventData();
urlStatusLabel.setText("startURL: " + status);
break;
case ((int) DocumentLoadEvent.END_URL_LOAD_EVENT_MASK):
status = (String) event.getEventData();
urlStatusLabel.setText(" endURL: " + status);
break;
}
}
}

View File

@@ -413,11 +413,15 @@ NS_IMETHODIMP CBrowserContainer::OnStateChange(nsIWebProgress *aWebProgress,
nsXPIDLString name;
nsCOMPtr<nsIDOMWindow> domWin;
nsresult rv;
if (NS_FAILED(rv = aRequest->GetName(getter_Copies(name)))) {
return rv;
}
//
// document states
//
if ((aStateFlags & STATE_START) && (aStateFlags & STATE_IS_DOCUMENT)) {
if (NS_FAILED(rv = aRequest->GetName(getter_Copies(name)))) {
return rv;
}
if (NS_FAILED(rv =aWebProgress->GetDOMWindow(getter_AddRefs(domWin)))||
!domWin) {
return rv;
@@ -429,6 +433,15 @@ NS_IMETHODIMP CBrowserContainer::OnStateChange(nsIWebProgress *aWebProgress,
if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_DOCUMENT)) {
doEndDocumentLoad(aWebProgress);
}
//
// request states
//
if ((aStateFlags & STATE_START) && (aStateFlags & STATE_IS_REQUEST)) {
doStartURLLoad(name.get());
}
if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_REQUEST)) {
doEndURLLoad(name.get());
}
if (aStateFlags & STATE_REDIRECTING) {
printf("debug: edburns: STATE_REDIRECTING\n");
}
@@ -646,6 +659,72 @@ CBrowserContainer::doEndDocumentLoad(nsIWebProgress *aWebProgress)
return NS_OK;
}
nsresult JNICALL
CBrowserContainer::doStartURLLoad(const PRUnichar *aDocumentName)
{
//NOTE: This appears to get fired once for each individual item on a page.
if (!mDocTarget) {
return NS_OK;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
#if DEBUG_RAPTOR_CANVAS
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 4,
("CBrowserContainer: OnStartURLLoad\n"));
}
#endif
nsAutoString nameAutoStr(aDocumentName);
jstring nameJStr = ::util_NewString(env, (const jchar *)
nameAutoStr.GetUnicode(),
nameAutoStr.Length());
util_SendEventToJava(mInitContext->env,
mInitContext->nativeEventThread, mDocTarget,
DOCUMENT_LOAD_LISTENER_CLASSNAME,
DocumentLoader_maskValues[START_URL_LOAD_EVENT_MASK],
nameJStr);
if (nameJStr) {
::util_DeleteString(mInitContext->env, nameJStr);
}
return NS_OK;
}
nsresult JNICALL
CBrowserContainer::doEndURLLoad(const PRUnichar *aDocumentName)
{
//NOTE: This appears to get fired once for each individual item on a page.
if (!mDocTarget) {
return NS_OK;
}
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
#if DEBUG_RAPTOR_CANVAS
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 4,
("CBrowserContainer: OnStartURLLoad\n"));
}
#endif
nsAutoString nameAutoStr(aDocumentName);
jstring nameJStr = ::util_NewString(env, (const jchar *)
nameAutoStr.GetUnicode(),
nameAutoStr.Length());
util_SendEventToJava(mInitContext->env,
mInitContext->nativeEventThread, mDocTarget,
DOCUMENT_LOAD_LISTENER_CLASSNAME,
DocumentLoader_maskValues[END_URL_LOAD_EVENT_MASK],
nameJStr);
if (nameJStr) {
::util_DeleteString(mInitContext->env, nameJStr);
}
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
@@ -1018,24 +1097,6 @@ NS_IMETHODIMP
CBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader,
nsIRequest* aRequest)
{
//NOTE: This appears to get fired once for each individual item on a page.
if (!mDocTarget) {
return NS_OK;
}
#if DEBUG_RAPTOR_CANVAS
if (prLogModuleInfo) {
PR_LOG(prLogModuleInfo, 4,
("CBrowserContainer: OnStartURLLoad\n"));
}
#endif
util_SendEventToJava(mInitContext->env,
mInitContext->nativeEventThread, mDocTarget,
DOCUMENT_LOAD_LISTENER_CLASSNAME,
DocumentLoader_maskValues[START_URL_LOAD_EVENT_MASK],
nsnull);
return NS_OK;
}
NS_IMETHODIMP

View File

@@ -177,8 +177,9 @@ void JNICALL addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent);
*/
nsresult JNICALL doStartDocumentLoad(const PRUnichar *documentName);
//nsresult JNICALL doStartUrlLoad(const PRUnichar *documentName);
nsresult JNICALL doEndDocumentLoad(nsIWebProgress *aWebProgress);
nsresult JNICALL doStartURLLoad(const PRUnichar *documentName);
nsresult JNICALL doEndURLLoad(const PRUnichar *documentName);
static nsresult JNICALL takeActionOnNode(nsCOMPtr<nsIDOMNode> curNode,
void *yourObject);