From ad8ed2e23ee55844ae6250bf14f0dc427df28521 Mon Sep 17 00:00:00 2001 From: "ashuk%eng.sun.com" Date: Fri, 30 Jun 2000 00:01:58 +0000 Subject: [PATCH] bug=44279 a=edburns r=edburns author=ashuk. This code makes Webclient work with Mozilla M16. git-svn-id: svn://10.0.0.236/trunk@73562 18797224-902f-48f8-a5cc-f745e15eee43 --- .../org/mozilla/webclient/test/EMWindow.java | 8 +- .../wrapper_native/CurrentPageImpl.java | 12 +- .../wrapper_native/NativeEventThread.java | 64 +- .../wrapper_native/WCMouseListenerImpl.java | 2 + .../java/webclient/src_moz/BookmarksImpl.cpp | 8 +- .../webclient/src_moz/CBrowserContainer.cpp | 1400 +++++++++++++++++ .../webclient/src_moz/CBrowserContainer.h | 206 +++ .../webclient/src_moz/CurrentPageImpl.cpp | 164 +- .../src_moz/DOMMouseListenerImpl.cpp | 649 -------- .../webclient/src_moz/DOMMouseListenerImpl.h | 150 -- .../src_moz/DocumentLoaderObserverImpl.cpp | 371 ----- .../src_moz/DocumentLoaderObserverImpl.h | 163 -- .../webclient/src_moz/EventRegistration.cpp | 161 -- .../webclient/src_moz/EventRegistration.h | 76 - .../java/webclient/src_moz/HistoryImpl.cpp | 59 +- mozilla/java/webclient/src_moz/Makefile.win | 13 +- .../webclient/src_moz/NativeEventThread.cpp | 457 ++++-- .../java/webclient/src_moz/NavigationImpl.cpp | 7 +- .../webclient/src_moz/WindowControlImpl.cpp | 57 +- .../webclient/src_moz/WrapperFactoryImpl.cpp | 79 +- mozilla/java/webclient/src_moz/jni_util.cpp | 1 + mozilla/java/webclient/src_moz/jni_util.h | 27 +- mozilla/java/webclient/src_moz/nsActions.cpp | 295 ++-- mozilla/java/webclient/src_moz/nsActions.h | 129 +- mozilla/java/webclient/src_moz/ns_globals.h | 17 +- .../webclient/src_moz/wcIBrowserContainer.h | 59 + 26 files changed, 2412 insertions(+), 2222 deletions(-) create mode 100644 mozilla/java/webclient/src_moz/CBrowserContainer.cpp create mode 100644 mozilla/java/webclient/src_moz/CBrowserContainer.h delete mode 100644 mozilla/java/webclient/src_moz/DOMMouseListenerImpl.cpp delete mode 100644 mozilla/java/webclient/src_moz/DOMMouseListenerImpl.h delete mode 100644 mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp delete mode 100644 mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.h delete mode 100644 mozilla/java/webclient/src_moz/EventRegistration.cpp delete mode 100644 mozilla/java/webclient/src_moz/EventRegistration.h create mode 100644 mozilla/java/webclient/src_moz/wcIBrowserContainer.h diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java index 5153c6212df..fa7f3d3015a 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java @@ -51,7 +51,7 @@ import org.w3c.dom.Document; * This is a test application for using the BrowserControl. * - * @version $Id: EMWindow.java,v 1.14 2000-06-08 02:16:06 edburns%acm.org Exp $ + * @version $Id: EMWindow.java,v 1.15 2000-06-30 00:01:58 ashuk%eng.sun.com Exp $ * * @see org.mozilla.webclient.BrowserControlFactory @@ -121,6 +121,7 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc MenuItem sourceItem = new MenuItem("View Page Source"); MenuItem pageInfoItem = new MenuItem("View Page Info"); MenuItem selectAllItem = new MenuItem("Select All"); + MenuItem copyItem = new MenuItem("Copy"); menuBar.add(fileMenu); menuBar.add(viewMenu); menuBar.add(searchMenu); @@ -139,6 +140,8 @@ public class EMWindow extends Frame implements DialogClient, ActionListener, Doc pageInfoItem.addActionListener(this); editMenu.add(selectAllItem); selectAllItem.addActionListener(this); + editMenu.add(copyItem); + copyItem.addActionListener(this); // Create the URL field urlField = new TextField("", 30); @@ -364,6 +367,9 @@ public void actionPerformed (ActionEvent evt) else if (command.equals("Select All")) { currentPage.selectAll(); } + else if (command.equals("Copy")) { + currentPage.copyCurrentSelectionToSystemClipboard(); + } } // deal with the button bar commands else if(command.equals("Stop")) { diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java index 8b95ef0db04..5598d2181c1 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/CurrentPageImpl.java @@ -167,12 +167,12 @@ public byte [] getSourceBytes(boolean viewMode) byte [] result = null; myFactory.throwExceptionIfNotInitialized(); - /* synchronized(myBrowserControl) { + synchronized(myBrowserControl) { result = nativeGetSourceBytes(nativeWebShell, viewMode); } - */ + - throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getSourceBytes has not yet been implemented.\n Will be available after Webclient M3 Release\n"); + //throw new UnimplementedException("\nUnimplementedException -----\n API Function CurrentPage::getSourceBytes has not yet been implemented.\n Will be available after Webclient M3 Release\n"); // PENDING (Ashu) - This should work - but it does not get anything from URl // and hangs up from time to time. Have to Debug. In M15, other native solution @@ -201,9 +201,9 @@ public byte [] getSourceBytes(boolean viewMode) { System.out.println("Error occurred while establishing connection -- \n ERROR - " + e); } - - return result; */ + return result; + } public void resetFind() @@ -260,7 +260,7 @@ public static void main(String [] args) Assert.setEnabled(true); Log.setApplicationName("CurrentPageImpl"); Log.setApplicationVersion("0.0"); - Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.6 2000-06-04 22:16:05 edburns%acm.org Exp $"); + Log.setApplicationVersionDate("$Id: CurrentPageImpl.java,v 1.7 2000-06-30 00:01:35 ashuk%eng.sun.com Exp $"); } diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java index abe81572746..ea49d505bb4 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/NativeEventThread.java @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): Ed Burns + * Ashutosh Kulkarni */ package org.mozilla.webclient.wrapper_native; @@ -176,7 +177,7 @@ public void delete() public void run() { - this.setPriority(Thread.MIN_PRIORITY); + // this.setPriority(Thread.MIN_PRIORITY); Assert.assert(-1 != nativeWebShell); Assert.assert(null != windowControl); @@ -200,20 +201,22 @@ public void run() if (null == this.browserControlCanvas) { return; } + synchronized (this.browserControlCanvas.getTreeLock()) { nativeProcessEvents(nativeWebShell); } if (null != listenersToAdd && !listenersToAdd.isEmpty()) { tempEnum = listenersToAdd.elements(); - while (tempEnum.hasMoreElements()) { - nativeAddListener(nativeWebShell, - (WebclientEventListener) - tempEnum.nextElement()); + while (tempEnum.hasMoreElements()) { + nativeAddListener(nativeWebShell, + (WebclientEventListener) + tempEnum.nextElement()); + } + listenersToAdd.clear(); } - listenersToAdd.clear(); - } - doRemoveListeners(); + doRemoveListeners(); + } } } @@ -327,31 +330,28 @@ void nativeEventOccurred(WebclientEventListener target, long eventType, Assert.assert(-1 != nativeWebShell); Assert.assert(null != windowControl); - synchronized(this.browserControlCanvas.getTreeLock()) { - WebclientEvent event = null; - - if (target instanceof DocumentLoadListener) { - event = new DocumentLoadEvent(this, eventType, eventData); - } - else if (target instanceof MouseListener) { - Assert.assert(target instanceof WCMouseListenerImpl); - - // We create a plain vanilla WebclientEvent, which the - // WCMouseListenerImpl target knows how to deal with. - - // Also, the source happens to be the browserControlCanvas - // to satisfy the java.awt.event.MouseEvent's requirement - // that the source be a java.awt.Component subclass. - - event = new WebclientEvent(browserControlCanvas, eventType, eventData); - } - // else... - - // PENDING(edburns): maybe we need to put this in some sort of - // event queue? - - target.eventDispatched(event); + WebclientEvent event = null; + + if (target instanceof DocumentLoadListener) { + event = new DocumentLoadEvent(this, eventType, eventData); } + else if (target instanceof MouseListener) { + Assert.assert(target instanceof WCMouseListenerImpl); + + // We create a plain vanilla WebclientEvent, which the + // WCMouseListenerImpl target knows how to deal with. + + // Also, the source happens to be the browserControlCanvas + // to satisfy the java.awt.event.MouseEvent's requirement + // that the source be a java.awt.Component subclass. + + event = new WebclientEvent(browserControlCanvas, eventType, eventData); + } + // else... + + // PENDING(edburns): maybe we need to put this in some sort of + // event queue? + target.eventDispatched(event); } // diff --git a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java index e6ba8036e92..ee58f06f114 100644 --- a/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java +++ b/mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/WCMouseListenerImpl.java @@ -116,6 +116,7 @@ public void eventDispatched(WebclientEvent event) int modifiers = 0, x = -1, y = -1, clickCount = 0; String str; boolean bool; + if (null != props) { if (null != (str = props.getProperty("ClientX"))) { x = Integer.valueOf(str).intValue(); } @@ -161,6 +162,7 @@ public void eventDispatched(WebclientEvent event) modifiers += InputEvent.SHIFT_MASK; } } + } switch ((int) event.getType()) { case (int) WCMouseEvent.MOUSE_DOWN_EVENT_MASK: mouseEvent = diff --git a/mozilla/java/webclient/src_moz/BookmarksImpl.cpp b/mozilla/java/webclient/src_moz/BookmarksImpl.cpp index d5d3014f31f..22a0bece0e4 100644 --- a/mozilla/java/webclient/src_moz/BookmarksImpl.cpp +++ b/mozilla/java/webclient/src_moz/BookmarksImpl.cpp @@ -59,14 +59,14 @@ Java_org_mozilla_webclient_wrapper_1native_BookmarksImpl_nativeNewRDFNode nsCOMPtr newNode; nsresult rv; jint result = -1; - nsAutoString uri("NC:BookmarksRoot"); + nsAutoString uri(L"NC:BookmarksRoot"); - const char *url = ::util_GetStringUTFChars(env, urlString); - uri.Append("#$"); + const jchar *url = ::util_GetStringChars(env, urlString); + uri.Append(L"#$"); uri.Append(url); rv = gRDF->GetUnicodeResource(uri.GetUnicode(), getter_AddRefs(newNode)); - ::util_ReleaseStringUTFChars(env, urlString, url); + ::util_ReleaseStringChars(env, urlString, url); if (NS_FAILED(rv)) { ::util_ThrowExceptionToJava(env, "Exception: nativeNewRDFNode: can't create new nsIRDFResource."); return result; diff --git a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp new file mode 100644 index 00000000000..af9e28822d0 --- /dev/null +++ b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp @@ -0,0 +1,1400 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * + * Contributor(s): Ashutosh Kulkarni + * Ed Burns + */ + + + +#include +#include "CBrowserContainer.h" +#include "nsCWebBrowser.h" +#include "nsIWebBrowser.h" +#include "nsIDOMNamedNodeMap.h" + +#include "prprf.h" // for PR_snprintf +#include "nsFileSpec.h" // for nsAutoCString + +#include "dom_util.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + +jlong CBrowserContainer::DocumentLoader_maskValues[] = { -1L }; +char * CBrowserContainer::DocumentLoader_maskNames[] = { + "START_DOCUMENT_LOAD_EVENT_MASK", + "END_DOCUMENT_LOAD_EVENT_MASK", + "START_URL_LOAD_EVENT_MASK", + "END_URL_LOAD_EVENT_MASK", + "PROGRESS_URL_LOAD_EVENT_MASK", + "STATUS_URL_LOAD_EVENT_MASK", + "UNKNOWN_CONTENT_EVENT_MASK", + "FETCH_INTERRUPT_EVENT_MASK", + nsnull +}; + +jlong CBrowserContainer::DOMMouseListener_maskValues[] = { -1L }; +char *CBrowserContainer::DOMMouseListener_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 +}; + +static jboolean PROPERTIES_KEYS_INITED = JNI_FALSE; +static jobject SCREEN_X_KEY = nsnull; +static jobject SCREEN_Y_KEY = nsnull; +static jobject CLIENT_X_KEY = nsnull; +static jobject CLIENT_Y_KEY = nsnull; +static jobject ALT_KEY = nsnull; +static jobject CTRL_KEY = nsnull; +static jobject SHIFT_KEY = nsnull; +static jobject META_KEY = nsnull; +static jobject BUTTON_KEY = nsnull; +static jobject CLICK_COUNT_KEY = nsnull; +static jobject TRUE_VALUE = nsnull; +static jobject FALSE_VALUE = nsnull; +static jobject ONE_VALUE = nsnull; +static jobject TWO_VALUE = nsnull; + +#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS) + +#define WC_ITOA(intVal, buf, radix) sprintf(buf, "%d", intVal) +#else +#define WC_ITOA(intVal, buf, radix) itoa(intVal, buf, radix) +#endif + + +/** + + * Initialize the above static jobject as jstrings + + */ + +jboolean initPropertiesKeys(); + +CBrowserContainer::CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *env, + WebShellInitContext *yourInitContext) : + m_pOwner(pOwner), mJNIEnv(env), mInitContext(yourInitContext), + mDocTarget(nsnull), mMouseTarget(nsnull), mDomEventTarget(nsnull), + inverseDepth(-1), properties(nsnull), currentDOMEvent(nsnull) +{ + NS_INIT_REFCNT(); + if (nsnull == gVm) { // declared in jni_util.h + ::util_GetJavaVM(env, &gVm); // save this vm reference away for the callback! + } + +} + + +CBrowserContainer::~CBrowserContainer() +{ +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsISupports implementation + +NS_IMPL_ADDREF(CBrowserContainer) +NS_IMPL_RELEASE(CBrowserContainer) + +NS_INTERFACE_MAP_BEGIN(CBrowserContainer) + // NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome) + NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) + NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChrome) + NS_INTERFACE_MAP_ENTRY(nsIURIContentListener) + NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeOwner) + NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) + NS_INTERFACE_MAP_ENTRY(nsIStreamObserver) + NS_INTERFACE_MAP_ENTRY(nsIDocumentLoaderObserver) + NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) + NS_INTERFACE_MAP_ENTRY(nsIWebShellContainer) + NS_INTERFACE_MAP_ENTRY(nsIPrompt) + NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener) + NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener) + NS_INTERFACE_MAP_ENTRY(wcIBrowserContainer) +NS_INTERFACE_MAP_END + + +/////////////////////////////////////////////////////////////////////////////// +// nsIInterfaceRequestor + +NS_IMETHODIMP CBrowserContainer::GetInterface(const nsIID & uuid, void * *result) +{ + const nsIID &iid = NS_GET_IID(nsIPrompt); + if (memcmp(&uuid, &iid, sizeof(nsIID)) == 0) + { + *result = (nsIPrompt *) this; + AddRef(); + return NS_OK; + } + return NS_ERROR_FAILURE; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIPrompt + +/* void alert (in wstring text); */ +NS_IMETHODIMP CBrowserContainer::Alert(const PRUnichar *dialogTitle, + const PRUnichar *text) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean confirm (in wstring text); */ +NS_IMETHODIMP CBrowserContainer::Confirm(const PRUnichar *dialogTitle, + const PRUnichar *text, + PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean confirmCheck (in wstring text, in wstring checkMsg, out boolean checkValue); */ +NS_IMETHODIMP CBrowserContainer::ConfirmCheck(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar *checkMsg, + PRBool *checkValue, + PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean prompt (in wstring text, in wstring defaultText, out wstring result); */ +NS_IMETHODIMP CBrowserContainer::Prompt(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar* passwordRealm, + const PRUnichar* defaultText, + PRUnichar **result, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean promptUsernameAndPassword (in wstring text, out wstring user, out wstring pwd); */ +NS_IMETHODIMP CBrowserContainer::PromptUsernameAndPassword(const PRUnichar *dialogTitle, + const PRUnichar *text, const PRUnichar *passwordRealm, PRBool persistPassword, + PRUnichar **user, PRUnichar **pwd, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean promptPassword (in wstring text, in wstring title, out wstring pwd); */ +NS_IMETHODIMP CBrowserContainer::PromptPassword(const PRUnichar *dialogTitle, + const PRUnichar *text, + const PRUnichar* passwordRealm, + PRBool persistPassword, + PRUnichar **pwd, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* boolean select (in wstring inDialogTitle, in wstring inMsg, in PRUint32 inCount, [array, size_is (inCount)] in wstring inList, out long outSelection); */ +NS_IMETHODIMP CBrowserContainer::Select(const PRUnichar *inDialogTitle, const PRUnichar *inMsg, PRUint32 inCount, const PRUnichar **inList, PRInt32 *outSelection, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void universalDialog (in wstring inTitleMessage, in wstring inDialogTitle, in wstring inMsg, in wstring inCheckboxMsg, in wstring inButton0Text, in wstring inButton1Text, in wstring inButton2Text, in wstring inButton3Text, in wstring inEditfield1Msg, in wstring inEditfield2Msg, inout wstring inoutEditfield1Value, inout wstring inoutEditfield2Value, in wstring inIConURL, inout boolean inoutCheckboxState, in PRInt32 inNumberButtons, in PRInt32 inNumberEditfields, in PRInt32 inEditField1Password, out PRInt32 outButtonPressed); */ +NS_IMETHODIMP CBrowserContainer::UniversalDialog(const PRUnichar *inTitleMessage, const PRUnichar *inDialogTitle, const PRUnichar *inMsg, const PRUnichar *inCheckboxMsg, const PRUnichar *inButton0Text, const PRUnichar *inButton1Text, const PRUnichar *inButton2Text, const PRUnichar *inButton3Text, const PRUnichar *inEditfield1Msg, const PRUnichar *inEditfield2Msg, PRUnichar **inoutEditfield1Value, PRUnichar **inoutEditfield2Value, const PRUnichar *inIConURL, PRBool *inoutCheckboxState, PRInt32 inNumberButtons, PRInt32 inNumberEditfields, PRInt32 inEditField1Password, PRInt32 *outButtonPressed) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIWebProgressListener + +/* void onProgressChange (in nsIChannel channel, in long curSelfProgress, in long maxSelfProgress, in long curTotalProgress, in long maxTotalProgress); */ +NS_IMETHODIMP CBrowserContainer::OnProgressChange(nsIChannel *channel, PRInt32 curSelfProgress, PRInt32 maxSelfProgress, PRInt32 curTotalProgress, PRInt32 maxTotalProgress) +{ + // NG_TRACE(_T("CBrowserContainer::OnProgressChange(...)\n")); + + long nProgress = curTotalProgress; + long nProgressMax = maxTotalProgress; + + if (nProgress == 0) + { + } + if (nProgressMax == 0) + { + nProgressMax = LONG_MAX; + } + if (nProgress > nProgressMax) + { + nProgress = nProgressMax; // Progress complete + } + + //PENDING (Ashu) + // Code to indicate Status Change goes here + + return NS_OK; +} + + +/* void onChildProgressChange (in nsIChannel channel, in long curChildProgress, in long maxChildProgress); */ +NS_IMETHODIMP CBrowserContainer::OnChildProgressChange(nsIChannel *channel, PRInt32 curChildProgress, PRInt32 maxChildProgress) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* void onStatusChange (in nsIChannel channel, in long progressStatusFlags); */ +NS_IMETHODIMP CBrowserContainer::OnStatusChange(nsIChannel *channel, PRInt32 progressStatusFlags) +{ + + return NS_OK; +} + + +/* void onChildStatusChange (in nsIChannel channel, in long progressStatusFlags); */ +NS_IMETHODIMP CBrowserContainer::OnChildStatusChange(nsIChannel *channel, PRInt32 progressStatusFlags) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* void onLocationChange (in nsIURI location); */ +NS_IMETHODIMP CBrowserContainer::OnLocationChange(nsIURI *location) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIURIContentListener + +/* void onStartURIOpen (in nsIURI aURI, in string aWindowTarget, out boolean aAbortOpen); */ +NS_IMETHODIMP CBrowserContainer::OnStartURIOpen(nsIURI *pURI, const char *aWindowTarget, PRBool *aAbortOpen) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +/* void getProtocolHandler (in nsIURI aURI, out nsIProtocolHandler aProtocolHandler); */ +NS_IMETHODIMP CBrowserContainer::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandler) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* void doContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, in nsIChannel aOpenedChannel, out nsIStreamListener aContentHandler, out boolean aAbortProcess); */ +NS_IMETHODIMP CBrowserContainer::DoContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, nsIChannel *aOpenedChannel, nsIStreamListener **aContentHandler, PRBool *aAbortProcess) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* boolean isPreferred (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */ +NS_IMETHODIMP CBrowserContainer::IsPreferred(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* boolean canHandleContent (in string aContentType, in nsURILoadCommand aCommand, in string aWindowTarget, out string aDesiredContentType); */ +NS_IMETHODIMP CBrowserContainer::CanHandleContent(const char *aContentType, nsURILoadCommand aCommand, const char *aWindowTarget, char **aDesiredContentType, PRBool *_retval) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* attribute nsISupports loadCookie; */ +NS_IMETHODIMP CBrowserContainer::GetLoadCookie(nsISupports * *aLoadCookie) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +NS_IMETHODIMP CBrowserContainer::SetLoadCookie(nsISupports * aLoadCookie) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/* attribute nsIURIContentListener parentContentListener; */ +NS_IMETHODIMP CBrowserContainer::GetParentContentListener(nsIURIContentListener * *aParentContentListener) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +NS_IMETHODIMP CBrowserContainer::SetParentContentListener(nsIURIContentListener * aParentContentListener) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIDocShellTreeOwner + + +NS_IMETHODIMP +CBrowserContainer::FindItemWithName(const PRUnichar* aName, + nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem** aFoundItem) +{ + return NS_ERROR_FAILURE; + +} + + +NS_IMETHODIMP +CBrowserContainer::ContentShellAdded(nsIDocShellTreeItem* aContentShell, + PRBool aPrimary, const PRUnichar* aID) +{ + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::GetPrimaryContentShell(nsIDocShellTreeItem** aShell) +{ + NS_ERROR("Haven't Implemented this yet"); + *aShell = nsnull; + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SizeShellTo(nsIDocShellTreeItem* aShell, + PRInt32 aCX, PRInt32 aCY) +{ + // Ignore request to be resized + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::ShowModal() +{ + // Ignore request to be shown modally + return NS_OK; +} + + +NS_IMETHODIMP CBrowserContainer::GetNewWindow(PRInt32 aChromeFlags, + nsIDocShellTreeItem** aDocShellTreeItem) +{ + + return NS_ERROR_NOT_IMPLEMENTED; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIBaseWindow + +NS_IMETHODIMP +CBrowserContainer::InitWindow(nativeWindow parentNativeWindow, nsIWidget * parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::Create(void) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::Destroy(void) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetPosition(PRInt32 x, PRInt32 y) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetPosition(PRInt32 *x, PRInt32 *y) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetSize(PRInt32 cx, PRInt32 cy, PRBool fRepaint) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetSize(PRInt32 *cx, PRInt32 *cy) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetPositionAndSize(PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy, PRBool fRepaint) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetPositionAndSize(PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::Repaint(PRBool force) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetParentWidget(nsIWidget * *aParentWidget) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetParentWidget(nsIWidget * aParentWidget) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetParentNativeWindow(nativeWindow *aParentNativeWindow) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetParentNativeWindow(nativeWindow aParentNativeWindow) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetVisibility(PRBool *aVisibility) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetVisibility(PRBool aVisibility) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetMainWidget(nsIWidget * *aMainWidget) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetFocus(void) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::FocusAvailable(nsIBaseWindow *aCurrentFocus, PRBool *aTookFocus) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetTitle(PRUnichar * *aTitle) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetTitle(const PRUnichar * aTitle) +{ + return NS_ERROR_FAILURE; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIWebBrowserChrome implementation + +NS_IMETHODIMP +CBrowserContainer::SetJSStatus(const PRUnichar *status) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetJSDefaultStatus(const PRUnichar *status) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetOverLink(const PRUnichar *link) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetWebBrowser(nsIWebBrowser * *aWebBrowser) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetWebBrowser(nsIWebBrowser * aWebBrowser) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetChromeMask(PRUint32 *aChromeMask) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SetChromeMask(PRUint32 aChromeMask) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::GetNewBrowser(PRUint32 chromeMask, nsIWebBrowser **_retval) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::FindNamedBrowserItem(const PRUnichar *aName, nsIDocShellTreeItem **_retval) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) +{ + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +CBrowserContainer::ShowAsModal(void) +{ + return NS_ERROR_FAILURE; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIStreamObserver implementation + + +NS_IMETHODIMP +CBrowserContainer::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext) +{ + + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg) +{ + return NS_OK; +} + + +/////////////////////////////////////////////////////////////////////////////// +// nsIDocumentLoaderObserver implementation + + +NS_IMETHODIMP +CBrowserContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, + const char* aCommand) +{ + // remove the old mouse listener for the old document + if (mDomEventTarget) { + nsAutoString eType(L"mouseover"); + mDomEventTarget->RemoveEventListener(eType, this, PR_FALSE); + mDomEventTarget = nsnull; + } + + if (!mDocTarget) { + return NS_OK; + } +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 4, + ("CBrowserContainer: OnStartDocumentLoad\n")); + } +#endif + char *urlStr = nsnull; + jobject urlJStr = nsnull; + if (nsnull != aURL) { + + // 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); + + aURL->GetSpec(&urlStr); + if (nsnull != urlStr) { + urlJStr = (jobject) ::util_NewStringUTF(env, urlStr); + ::Recycle(urlStr); + } + } + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, mDocTarget, + DocumentLoader_maskValues[CBrowserContainer::DOCUMENT_LOADER_EVENT_MASK_NAMES::START_DOCUMENT_LOAD_EVENT_MASK], urlJStr); + + if (urlJStr) { + ::util_DeleteStringUTF(mInitContext->env, (jstring) urlJStr); + } + + return NS_OK; +} + + +// we need this to fire the document complete +NS_IMETHODIMP +CBrowserContainer::OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel *aChannel, nsresult aStatus) +{ + if (nsnull != loader) { + if (mInitContext->currentDocument = dom_getDocumentFromLoader(loader)){ + // if we have a mouse listener + if (mMouseTarget) { + // turn the currentDocument into an nsIDOMEventTarget + mDomEventTarget = + do_QueryInterface(mInitContext->currentDocument); + // if successful + if (mDomEventTarget) { + nsAutoString eType(L"mouseover"); + mDomEventTarget->AddEventListener(eType, this, PR_FALSE); + } + } + } + } + + if (!mDocTarget) { + return NS_OK; + } +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 4, + ("CBrowserContainer: OnEndDocumentLoad\n")); + } +#endif + + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, mDocTarget, + DocumentLoader_maskValues[CBrowserContainer::DOCUMENT_LOADER_EVENT_MASK_NAMES::END_DOCUMENT_LOAD_EVENT_MASK], nsnull); + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel) +{ + //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, + DocumentLoader_maskValues[CBrowserContainer::DOCUMENT_LOADER_EVENT_MASK_NAMES::START_URL_LOAD_EVENT_MASK], nsnull); + + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* aChannel, PRUint32 aProgress, PRUint32 aProgressMax) +{ + if (!mDocTarget) { + return NS_OK; + } +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 4, + ("CBrowserContainer: OnProgressURLLoad\n")); + } +#endif + + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, mDocTarget, + DocumentLoader_maskValues[CBrowserContainer::DOCUMENT_LOADER_EVENT_MASK_NAMES::PROGRESS_URL_LOAD_EVENT_MASK], nsnull); + + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::OnStatusURLLoad(nsIDocumentLoader* loader, + nsIChannel* channel, nsString& aMsg) +{ + + //NOTE: This appears to get fired for each individual item on a page, indicating the status of that item. + if (!mDocTarget) { + return NS_OK; + } +#if DEBUG_RAPTOR_CANVAS + if (prLogModuleInfo) { + PR_LOG(prLogModuleInfo, 4, + ("CBrowserContainer: OnStatusURLLoad\n")); + } +#endif + 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, (const jchar *) + aMsg.GetUnicode(), length); + + util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, + mDocTarget, + DocumentLoader_maskValues[CBrowserContainer::DOCUMENT_LOADER_EVENT_MASK_NAMES::STATUS_URL_LOAD_EVENT_MASK], + (jobject) statusMessage); + + if (statusMessage) { + ::util_DeleteString(mInitContext->env, statusMessage); + } + + return NS_OK; +} + + +NS_IMETHODIMP +CBrowserContainer::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsresult aStatus) +{ + //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, + DocumentLoader_maskValues[CBrowserContainer::DOCUMENT_LOADER_EVENT_MASK_NAMES::END_URL_LOAD_EVENT_MASK], nsnull); + + return NS_OK; +} + + +nsresult +CBrowserContainer::HandleEvent(nsIDOMEvent* aEvent) +{ + return NS_OK; +} + + +nsresult +CBrowserContainer::MouseDown(nsIDOMEvent* aMouseEvent) +{ + if (!mMouseTarget) { + return NS_OK; + } + PR_ASSERT(nsnull != aMouseEvent); + + getPropertiesFromEvent(aMouseEvent); + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, + mMouseTarget, + DOMMouseListener_maskValues[CBrowserContainer::DOM_MOUSE_LISTENER_EVENT_MASK_NAMES::MOUSE_DOWN_EVENT_MASK], + properties); + return NS_OK; +} + + +nsresult +CBrowserContainer::MouseUp(nsIDOMEvent* aMouseEvent) +{ + if (!mMouseTarget) { + return NS_OK; + } + PR_ASSERT(nsnull != aMouseEvent); + + getPropertiesFromEvent(aMouseEvent); + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, + mMouseTarget, + DOMMouseListener_maskValues[CBrowserContainer::DOM_MOUSE_LISTENER_EVENT_MASK_NAMES::MOUSE_UP_EVENT_MASK], + properties); + return NS_OK; +} + +nsresult +CBrowserContainer::MouseClick(nsIDOMEvent* aMouseEvent) +{ + if (!mMouseTarget) { + return NS_OK; + } + PR_ASSERT(nsnull != aMouseEvent); + + getPropertiesFromEvent(aMouseEvent); + + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + ::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY, + ONE_VALUE, (jobject) mInitContext); + + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, + mMouseTarget, + DOMMouseListener_maskValues[CBrowserContainer::DOM_MOUSE_LISTENER_EVENT_MASK_NAMES::MOUSE_CLICK_EVENT_MASK], + properties); + return NS_OK; +} + + +nsresult +CBrowserContainer::MouseDblClick(nsIDOMEvent* aMouseEvent) +{ + if (!mMouseTarget) { + return NS_OK; + } + PR_ASSERT(nsnull != aMouseEvent); + + getPropertiesFromEvent(aMouseEvent); + + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + ::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY, + TWO_VALUE, (jobject) mInitContext); + + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, + mMouseTarget, + DOMMouseListener_maskValues[CBrowserContainer::DOM_MOUSE_LISTENER_EVENT_MASK_NAMES::MOUSE_DOUBLE_CLICK_EVENT_MASK], + properties); + return NS_OK; +} + + +nsresult +CBrowserContainer::MouseOver(nsIDOMEvent* aMouseEvent) +{ + if (!mMouseTarget) { + return NS_OK; + } + PR_ASSERT(nsnull != aMouseEvent); + + getPropertiesFromEvent(aMouseEvent); + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, + mMouseTarget, + DOMMouseListener_maskValues[CBrowserContainer::DOM_MOUSE_LISTENER_EVENT_MASK_NAMES::MOUSE_OVER_EVENT_MASK], + properties); + return NS_OK; +} + + +nsresult +CBrowserContainer::MouseOut(nsIDOMEvent* aMouseEvent) +{ + if (!mMouseTarget) { + return NS_OK; + } + PR_ASSERT(nsnull != aMouseEvent); + + getPropertiesFromEvent(aMouseEvent); + util_SendEventToJava(mInitContext->env, + mInitContext->nativeEventThread, + mMouseTarget, + DOMMouseListener_maskValues[CBrowserContainer::DOM_MOUSE_LISTENER_EVENT_MASK_NAMES::MOUSE_OUT_EVENT_MASK], + properties); + return NS_OK; +} + +// +// From wcIBrowserContainer +// + + +NS_IMETHODIMP CBrowserContainer::AddMouseListener(jobject target) +{ + nsresult rv = NS_OK; + if (!mInitContext->initComplete) { + return NS_ERROR_FAILURE; + } + + if (-1 == DOMMouseListener_maskValues[0]) { + util_InitializeEventMaskValuesFromClass("org/mozilla/webclient/WCMouseEvent", + DOMMouseListener_maskNames, + DOMMouseListener_maskValues); + } + mMouseTarget = target; + + return rv; +} + +NS_IMETHODIMP CBrowserContainer::AddDocumentLoadListener(jobject target) +{ + nsresult rv = NS_OK; + if (!mInitContext->initComplete) { + return NS_ERROR_FAILURE; + } + + if (-1 == CBrowserContainer::DocumentLoader_maskValues[0]) { + util_InitializeEventMaskValuesFromClass("org/mozilla/webclient/DocumentLoadEvent", + DocumentLoader_maskNames, + DocumentLoader_maskValues); + } + mDocTarget = target; + + return rv; +} + +NS_IMETHODIMP CBrowserContainer::RemoveAllListeners() +{ + if (mDomEventTarget) { + nsAutoString eType(L"mouseover"); + mDomEventTarget->RemoveEventListener(eType, this, PR_FALSE); + mDomEventTarget = nsnull; + } + mMouseTarget = nsnull; + mDocTarget = nsnull; + return NS_OK; +} + + +// +// Methods from nsIWebShellContainer +// + +NS_IMETHODIMP CBrowserContainer::WillLoadURL(nsIWebShell* aShell, + const PRUnichar* aURL, + nsLoadType aReason) +{ + return NS_OK; +} + +NS_IMETHODIMP CBrowserContainer::BeginLoadURL(nsIWebShell* aShell, + const PRUnichar* aURL) +{ + return NS_OK; +} + +NS_IMETHODIMP CBrowserContainer::EndLoadURL(nsIWebShell* aShell, + const PRUnichar* aURL, + nsresult aStatus) +{ + return NS_OK; +} + +jobject JNICALL CBrowserContainer::getPropertiesFromEvent(nsIDOMEvent *event) +{ + nsCOMPtr eventTarget; + nsCOMPtr currentNode; + nsCOMPtr aMouseEvent = event; + nsresult rv = NS_OK;; + + rv = aMouseEvent->GetTarget(getter_AddRefs(eventTarget)); + if (NS_FAILED(rv)) { + return properties; + } + currentNode = do_QueryInterface(eventTarget); + if (!currentNode) { + return properties; + } + inverseDepth = 0; + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + + if (properties) { + util_ClearPropertiesObject(env, properties, (jobject) mInitContext); + } + else { + if (!(properties = + util_CreatePropertiesObject(env, (jobject)mInitContext))) { + return properties; + } + } + dom_iterateToRoot(currentNode, CBrowserContainer::takeActionOnNode, + (void *)this); + addMouseEventDataToProperties(aMouseEvent); + + return properties; +} + +void JNICALL CBrowserContainer::addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent) +{ + if (!properties) { + return; + } + nsresult rv; + + // Add modifiers, keys, mouse buttons, etc, to the properties table + nsCOMPtr mouseEvent; + + rv = aMouseEvent->QueryInterface(nsIDOMMouseEvent::GetIID(), + getter_AddRefs(mouseEvent)); + if (NS_FAILED(rv)) { + return; + } + // initialize the standard properties keys + if (!PROPERTIES_KEYS_INITED) { + // if the initialization failed, don't modify the properties + if (!initPropertiesKeys()) { + return; + } + } + PRInt32 intVal; + PRUint16 int16Val; + PRBool boolVal; + char buf[20]; + jstring strVal; + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + + // PENDING(edburns): perhaps use a macro to speed this up? + rv = mouseEvent->GetScreenX(&intVal); + if (NS_SUCCEEDED(rv)) { + WC_ITOA(intVal, buf, 10); + strVal = ::util_NewStringUTF(env, buf); + ::util_StoreIntoPropertiesObject(env, properties, SCREEN_X_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetScreenY(&intVal); + if (NS_SUCCEEDED(rv)) { + WC_ITOA(intVal, buf, 10); + strVal = ::util_NewStringUTF(env, buf); + ::util_StoreIntoPropertiesObject(env, properties, SCREEN_Y_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetClientX(&intVal); + if (NS_SUCCEEDED(rv)) { + WC_ITOA(intVal, buf, 10); + strVal = ::util_NewStringUTF(env, buf); + ::util_StoreIntoPropertiesObject(env, properties, CLIENT_X_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetClientY(&intVal); + if (NS_SUCCEEDED(rv)) { + WC_ITOA(intVal, buf, 10); + strVal = ::util_NewStringUTF(env, buf); + ::util_StoreIntoPropertiesObject(env, properties, CLIENT_Y_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + int16Val = 0; + rv = mouseEvent->GetButton(&int16Val); + if (NS_SUCCEEDED(rv)) { + WC_ITOA(int16Val, buf, 10); + strVal = ::util_NewStringUTF(env, buf); + ::util_StoreIntoPropertiesObject(env, properties, BUTTON_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetAltKey(&boolVal); + if (NS_SUCCEEDED(rv)) { + strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; + ::util_StoreIntoPropertiesObject(env, properties, ALT_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetCtrlKey(&boolVal); + if (NS_SUCCEEDED(rv)) { + strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; + ::util_StoreIntoPropertiesObject(env, properties, CTRL_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetShiftKey(&boolVal); + if (NS_SUCCEEDED(rv)) { + strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; + ::util_StoreIntoPropertiesObject(env, properties, SHIFT_KEY, + (jobject) strVal, + (jobject) mInitContext); + } + + rv = mouseEvent->GetMetaKey(&boolVal); + if (NS_SUCCEEDED(rv)) { + strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; + ::util_StoreIntoPropertiesObject(env, properties, META_KEY, + (jobject) strVal, + (jobject) mInitContext); + } +} + +nsresult JNICALL CBrowserContainer::takeActionOnNode(nsCOMPtr currentNode, + void *myObject) +{ + nsresult rv = NS_OK; + nsString nodeInfo, nodeName, nodeValue; //, nodeDepth; + jstring jNodeName, jNodeValue; + PRUint32 depth = -1; + CBrowserContainer *curThis = nsnull; + const PRUint32 depthStrLen = 20; + // char depthStr[depthStrLen]; + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + + PR_ASSERT(nsnull != myObject); + curThis = (CBrowserContainer *) 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, 4, ("%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, 4, ("%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, + (jobject) curThis->mInitContext); + 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 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, 4, + ("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, 4, + ("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, + (jobject) curThis->mInitContext); + if (jNodeName) { + ::util_DeleteString(env, jNodeName); + } + if (jNodeValue) { + ::util_DeleteString(env, jNodeValue); + } + } + } // end of storing the attributes + + return rv; +} + +// +// Local functions +// + +jboolean initPropertiesKeys() +{ + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + + if (nsnull == (SCREEN_X_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "ScreenX")))) { + return JNI_FALSE; + } + if (nsnull == (SCREEN_Y_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "ScreenY")))) { + return JNI_FALSE; + } + if (nsnull == (CLIENT_X_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "ClientX")))) { + return JNI_FALSE; + } + if (nsnull == (CLIENT_Y_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "ClientY")))) { + return JNI_FALSE; + } + if (nsnull == (ALT_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "Alt")))) { + return JNI_FALSE; + } + if (nsnull == (CTRL_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "Ctrl")))) { + return JNI_FALSE; + } + if (nsnull == (SHIFT_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "Shift")))) { + return JNI_FALSE; + } + if (nsnull == (META_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "Meta")))) { + return JNI_FALSE; + } + if (nsnull == (BUTTON_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "Button")))) { + return JNI_FALSE; + } + if (nsnull == (CLICK_COUNT_KEY = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, + "ClickCount")))) { + return JNI_FALSE; + } + if (nsnull == (TRUE_VALUE = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "true")))) { + return JNI_FALSE; + } + if (nsnull == (FALSE_VALUE = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "false")))) { + return JNI_FALSE; + } + if (nsnull == (ONE_VALUE = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "1")))) { + return JNI_FALSE; + } + if (nsnull == (TWO_VALUE = + ::util_NewGlobalRef(env, (jobject) + ::util_NewStringUTF(env, "2")))) { + return JNI_FALSE; + } + + return PROPERTIES_KEYS_INITED = JNI_TRUE; +} diff --git a/mozilla/java/webclient/src_moz/CBrowserContainer.h b/mozilla/java/webclient/src_moz/CBrowserContainer.h new file mode 100644 index 00000000000..e836cf8b7a8 --- /dev/null +++ b/mozilla/java/webclient/src_moz/CBrowserContainer.h @@ -0,0 +1,206 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): Ashutosh Kulkarni + * Ed Burns + * + */ + +#ifndef BROWSERCONTAINER_H +#define BROWSERCONTAINER_H + +#include "nsISupports.h" +#include "nsISupportsUtils.h" +#include "nsString.h" +#include "nsIDOMMouseListener.h" +#include "nsIDOMMouseEvent.h" +#include "nsIDOMEventTarget.h" +#include "nsIWebBrowserChrome.h" +#include "nsIWebProgressListener.h" +#include "nsIWebShell.h" // We still have to implement nsIWebShellContainer + // in order to receveive some DocumentLoaderObserver + // events. edburns +#include "nsIStreamObserver.h" +#include "nsIURIContentListener.h" +#include "nsIDocumentLoaderObserver.h" +#include "nsIDocShellTreeOwner.h" +#include "nsIInterfaceRequestor.h" +#include "nsIPrompt.h" +#include "nsCWebBrowser.h" + +#include "wcIBrowserContainer.h" + +#include "jni_util.h" + +class nsIURI; + +// This is the class that handles the XPCOM side of things, callback +// interfaces into the web shell and so forth. + +class CBrowserContainer : + public nsIBaseWindow, + public nsIWebBrowserChrome, + public nsIWebProgressListener, + public nsIWebShellContainer, + public nsIStreamObserver, + public nsIURIContentListener, + public nsIDocumentLoaderObserver, + public nsIDocShellTreeOwner, + public nsIInterfaceRequestor, + public nsIPrompt, + public nsIDOMMouseListener, + public wcIBrowserContainer +{ + +public: + +typedef enum { + START_DOCUMENT_LOAD_EVENT_MASK = 0, + END_DOCUMENT_LOAD_EVENT_MASK, + START_URL_LOAD_EVENT_MASK, + END_URL_LOAD_EVENT_MASK, + PROGRESS_URL_LOAD_EVENT_MASK, + STATUS_URL_LOAD_EVENT_MASK, + UNKNOWN_CONTENT_EVENT_MASK, + FETCH_INTERRUPT_EVENT_MASK, + NUMBER_OF_DOCUMENT_LOADER_MASK_NAMES +} DOCUMENT_LOADER_EVENT_MASK_NAMES; + +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_DOM_MOUSE_LISTENER_MASK_NAMES +} DOM_MOUSE_LISTENER_EVENT_MASK_NAMES; + + +static jlong DocumentLoader_maskValues [NUMBER_OF_DOCUMENT_LOADER_MASK_NAMES]; +static char *DocumentLoader_maskNames []; + +static jlong DOMMouseListener_maskValues [NUMBER_OF_DOM_MOUSE_LISTENER_MASK_NAMES]; +static char *DOMMouseListener_maskNames []; + + +public: + CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *yourJNIEnv, WebShellInitContext *yourInitContext); + + CBrowserContainer(); + +public: + virtual ~CBrowserContainer(); + +// Protected members +protected: + nsIWebBrowser *m_pOwner; + JNIEnv *mJNIEnv; + WebShellInitContext *mInitContext; + jobject mDocTarget; + jobject mMouseTarget; + nsCOMPtr mDomEventTarget; + +// +// 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 currentDOMEvent; + +// +// End of ivars used in takeActionOnNode +// + + +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIBASEWINDOW + NS_DECL_NSIWEBBROWSERCHROME + NS_DECL_NSIDOCSHELLTREEOWNER + NS_DECL_NSIURICONTENTLISTENER + NS_DECL_NSISTREAMOBSERVER + NS_DECL_NSIDOCUMENTLOADEROBSERVER + NS_DECL_NSIINTERFACEREQUESTOR + NS_DECL_NSIWEBPROGRESSLISTENER + + NS_DECL_WCIBROWSERCONTAINER + + // "Services" accessed through nsIInterfaceRequestor + NS_DECL_NSIPROMPT + + // nsIDOMMouseListener + + virtual nsresult HandleEvent(nsIDOMEvent* aEvent); + virtual nsresult MouseDown(nsIDOMEvent* aMouseEvent); + virtual nsresult MouseUp(nsIDOMEvent* aMouseEvent); + virtual nsresult MouseClick(nsIDOMEvent* aMouseEvent); + virtual nsresult MouseDblClick(nsIDOMEvent* aMouseEvent); + virtual nsresult MouseOver(nsIDOMEvent* aMouseEvent); + virtual nsresult MouseOut(nsIDOMEvent* aMouseEvent); + + // nsIWebShellContainer + NS_IMETHOD WillLoadURL(nsIWebShell* aShell, + const PRUnichar* aURL, + nsLoadType aReason); + + NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, + const PRUnichar* aURL); + + + NS_IMETHOD EndLoadURL(nsIWebShell* aShell, + const PRUnichar* aURL, + nsresult aStatus); + +protected: +// +// Local methods +// +jobject JNICALL getPropertiesFromEvent(nsIDOMEvent *aMouseEvent); + +void JNICALL addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent); + +static nsresult JNICALL takeActionOnNode(nsCOMPtr curNode, + void *yourObject); + +}; + +#endif + diff --git a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp index 1e27646928a..b8c4dadaa59 100644 --- a/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp +++ b/mozilla/java/webclient/src_moz/CurrentPageImpl.cpp @@ -22,7 +22,7 @@ * Mark Lin * Mark Goddard * Ed Burns - * Ann Sunhachawee + * Ashutosh Kulkarni */ /* @@ -53,6 +53,11 @@ #include "nsIDOMRange.h" #include "nsIContentViewer.h" #include "nsIServiceManager.h" +#include "nsIContentViewer.h" +#include "nsIContentViewerEdit.h" +#include "nsIDOMWindow.h" +#include "nsIScriptGlobalObject.h" +#include "nsIInterfaceRequestor.h" static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID); @@ -63,29 +68,12 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp (JNIEnv *env, jobject obj, jint webShellPtr) { WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; - nsCOMPtr presShell; - nsresult rv; - - rv = initContext->docShell->GetPresShell(getter_AddRefs(presShell)); - // PENDING() should this be done using an nsActionEvent subclass? - - if (NS_FAILED(rv)) { - initContext->initFailCode = kHistoryWebShellError; - ::util_ThrowExceptionToJava(env, "Exception: can't Copy to Clipboard"); - return; - } - - presShell->DoCopy(); - - /*** - - This looks like the right way to do it, but as of 01/13/00, it - doesn't work. See a post on n.p.m.embedding: - - Message-ID: <85ll4n$nli$1@nnrp1.deja.com> - - - **/ + nsIContentViewer* contentViewer ; + nsresult rv = nsnull; + rv = initContext->docShell->GetContentViewer(&contentViewer); + nsCOMPtr contentViewerEdit(do_QueryInterface(contentViewer)); + rv = contentViewerEdit->CopySelection(); + } /* @@ -99,6 +87,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; + //First get the FindComponent object nsresult rv; @@ -109,9 +98,13 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp return; } - // Create a Search Context for the FindComponent + nsCOMPtr interfaceRequestor(do_QueryInterface(initContext->docShell)); + nsCOMPtr domWindow; + rv = interfaceRequestor->GetInterface(NS_GET_IID(nsIDOMWindow), getter_AddRefs(domWindow)); + + nsCOMPtr searchContext; - rv = findComponent->CreateContext(initContext->webShell, nsnull, getter_AddRefs(searchContext)); + rv = findComponent->CreateContext(domWindow, nsnull, getter_AddRefs(searchContext)); if (NS_FAILED(rv)) { initContext->initFailCode = kSearchContextError; ::util_ThrowExceptionToJava(env, "Exception: can't create SearchContext for Find"); @@ -141,6 +134,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp // Save in initContext struct for future findNextInPage calls initContext->searchContext = srchcontext; + } @@ -201,13 +195,14 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage } if (initContext->initComplete) { - nsISessionHistory *yourHistory; + // nsISessionHistory *yourHistory; + nsISHistory* yourHistory; nsresult rv; - rv = initContext->webShell->GetSessionHistory(yourHistory); + rv = initContext->webNavigation->GetSessionHistory(&yourHistory); if (NS_FAILED(rv)) { - ::util_ThrowExceptionToJava(env, "Exception: can't get SessionHistory from webshell"); + ::util_ThrowExceptionToJava(env, "Exception: can't get SessionHistory from webNavigation"); return urlString; } @@ -272,8 +267,8 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSource (JNIEnv * env, jobject jobj) { - jstring result = nsnull; + return result; } @@ -283,18 +278,20 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPage * Signature: ()[B */ JNIEXPORT jbyteArray JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeGetSourceBytes -(JNIEnv * env, jobject jobj, jint webShellPtr, jboolean mode) +(JNIEnv * env, jobject jobj, jint webShellPtr, jboolean viewMode) { -/* - WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; - nsCOMPtr docShell = initContext->docShell; - if (mode) - docShell->SetViewMode(nsIDocShell::viewSource); - else - docShell->SetViewMode(nsIDocShell::viewNormal); -*/ - + + WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; + + if (initContext->initComplete) { + wsViewSourceEvent * actionEvent = + new wsViewSourceEvent(initContext->docShell, ((JNI_TRUE == viewMode)? PR_TRUE : PR_FALSE)); + PLEvent * event = (PLEvent*) *actionEvent; + + ::util_PostSynchronousEvent(initContext, event); + } + jbyteArray result = nsnull; return result; } @@ -319,82 +316,13 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImp JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_CurrentPageImpl_nativeSelectAll (JNIEnv * env, jobject obj, jint webShellPtr) { - WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; - nsCOMPtr presShell; - nsresult rv; - - rv = initContext->docShell->GetPresShell(getter_AddRefs(presShell)); - - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get PresShell"); - return; - } - - nsCOMPtr selection; - rv = presShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection)); - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get DOMSelection"); - return; - } - - nsCOMPtr contentViewer; - rv = initContext->docShell->GetContentViewer(getter_AddRefs(contentViewer)); - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get contentViewer"); - return; - } - - nsCOMPtr docViewer(do_QueryInterface(contentViewer)); - - nsCOMPtr doc; - rv = docViewer->GetDocument(*getter_AddRefs(doc)); - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get Document object"); - return; - } - - - nsCOMPtr htmldoc; - rv = doc->QueryInterface(kIDOMHTMLDocumentIID, getter_AddRefs(htmldoc)); - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get DOMHTMLDocument"); - return; - } - - nsCOMPtrbodyElement; - rv = htmldoc->GetBody(getter_AddRefs(bodyElement)); - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get DOMHTMLElement"); - return; - } - - nsCOMPtrbodyNode = do_QueryInterface(bodyElement); - if (!bodyNode) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get DOMNode"); - return; - } - - rv = selection->ClearSelection(); - - nsCOMPtr range; - rv = nsComponentManager::CreateInstance(kCDOMRangeCID, nsnull, - NS_GET_IID(nsIDOMRange), - getter_AddRefs(range)); - - rv = range->SelectNodeContents(bodyNode); - - rv = selection->AddRange(range); - - if (NS_FAILED(rv)) { - initContext->initFailCode = kSelectAllError; - ::util_ThrowExceptionToJava(env, "Exception: can't get final Select working"); - return; - } + WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; + nsIContentViewer* contentViewer ; + nsresult rv = nsnull; + rv = initContext->docShell->GetContentViewer(&contentViewer); + nsCOMPtr contentViewerEdit(do_QueryInterface(contentViewer)); + rv = contentViewerEdit->SelectAll(); + if (NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Exception: can't do SelectAll through contentViewerEdit"); + } } diff --git a/mozilla/java/webclient/src_moz/DOMMouseListenerImpl.cpp b/mozilla/java/webclient/src_moz/DOMMouseListenerImpl.cpp deleted file mode 100644 index e14832c686a..00000000000 --- a/mozilla/java/webclient/src_moz/DOMMouseListenerImpl.cpp +++ /dev/null @@ -1,649 +0,0 @@ -/* -*- 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 - * - */ - -#include "DOMMouseListenerImpl.h" - -#include "nsString.h" -#include "nsFileSpec.h" // for nsAutoCString -#include "nsIDOMNamedNodeMap.h" -#include "nsIDOMMouseEvent.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 - -#include // for itoa - -#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS) - -#define WC_ITOA(intVal, buf, radix) sprintf(buf, "%d", intVal) -#else -#define WC_ITOA(intVal, buf, radix) itoa(intVal, buf, radix) -#endif - -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 -}; - -static jboolean PROPERTIES_KEYS_INITED = JNI_FALSE; -static jobject SCREEN_X_KEY = nsnull; -static jobject SCREEN_Y_KEY = nsnull; -static jobject CLIENT_X_KEY = nsnull; -static jobject CLIENT_Y_KEY = nsnull; -static jobject ALT_KEY = nsnull; -static jobject CTRL_KEY = nsnull; -static jobject SHIFT_KEY = nsnull; -static jobject META_KEY = nsnull; -static jobject BUTTON_KEY = nsnull; -static jobject CLICK_COUNT_KEY = nsnull; -static jobject TRUE_VALUE = nsnull; -static jobject FALSE_VALUE = nsnull; - -/** - - * Initialize the above static jobject as jstrings - - */ - -jboolean initPropertiesKeys(); - -//NS_IMPL_ADDREF(DOMMouseListenerImpl); -//NS_IMPL_RELEASE(DOMMouseListenerImpl); - -NS_IMETHODIMP_(nsrefcnt) DOMMouseListenerImpl::AddRef() -{ - mRefCnt++; - return mRefCnt; -} - -NS_IMETHODIMP_(nsrefcnt) DOMMouseListenerImpl::Release() -{ - mRefCnt--; - - if (mRefCnt == 0) { - mRefCnt = 1; /* stabilize */ - NS_DELETEXPCOM(this); - return 0; - } - return mRefCnt; -} - - - -DOMMouseListenerImpl::DOMMouseListenerImpl() : mJNIEnv(nsnull), - mInitContext(nsnull), mTarget(nsnull), - inverseDepth(-1), properties(nsnull), currentDOMEvent(nsnull) -{ -} - -DOMMouseListenerImpl::DOMMouseListenerImpl(JNIEnv *env, - WebShellInitContext *yourInitContext, - jobject yourTarget) : - mJNIEnv(env), mInitContext(yourInitContext), mTarget(yourTarget), - inverseDepth(-1), properties(nsnull), currentDOMEvent(nsnull) -{ - 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 = 0; // PENDING(edburns): not sure about how right this is to do. -} - -DOMMouseListenerImpl::~DOMMouseListenerImpl() -{ - if (properties) { - JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); - util_DestroyPropertiesObject(env, properties, (jobject) mInitContext); - properties = nsnull; - } - currentDOMEvent = nsnull; - -} - -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, 4, - ("!DOMMouseListenerImpl::MouseDown\n")); - } -#endif - PR_ASSERT(nsnull != aMouseEvent); - - getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, - mTarget, - maskValues[MOUSE_DOWN_EVENT_MASK], - properties); - return NS_OK; -} - -nsresult DOMMouseListenerImpl::MouseUp(nsIDOMEvent *aMouseEvent) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 4, - ("!DOMMouseListenerImpl::MouseUp\n")); - } -#endif - PR_ASSERT(nsnull != aMouseEvent); - - getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, - mTarget, - maskValues[MOUSE_UP_EVENT_MASK], - properties); - return NS_OK; -} - -nsresult DOMMouseListenerImpl::MouseClick(nsIDOMEvent *aMouseEvent) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 4, - ("!DOMMouseListenerImpl::MouseClick\n")); - } -#endif - PR_ASSERT(nsnull != aMouseEvent); - - getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, - mTarget, - maskValues[MOUSE_CLICK_EVENT_MASK], - properties); - return NS_OK; -} - -nsresult DOMMouseListenerImpl::MouseDblClick(nsIDOMEvent *aMouseEvent) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 4, - ("!DOMMouseListenerImpl::MouseDoubleClick\n")); - } -#endif - PR_ASSERT(nsnull != aMouseEvent); - - getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, - mTarget, - maskValues[MOUSE_DOUBLE_CLICK_EVENT_MASK], - properties); - return NS_OK; -} - -nsresult DOMMouseListenerImpl::MouseOver(nsIDOMEvent *aMouseEvent) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 4, - ("!DOMMouseListenerImpl::MouseOver\n")); - } -#endif - PR_ASSERT(nsnull != aMouseEvent); - - getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, - mTarget, - maskValues[MOUSE_OVER_EVENT_MASK], - properties); - - return NS_OK; -} - -nsresult DOMMouseListenerImpl::MouseOut(nsIDOMEvent *aMouseEvent) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 4, - ("!DOMMouseListenerImpl::MouseOut\n")); - } -#endif - PR_ASSERT(nsnull != aMouseEvent); - - getPropertiesFromEvent(aMouseEvent); - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, - mTarget, - maskValues[MOUSE_OUT_EVENT_MASK], - properties); - return NS_OK; -} - -jobject JNICALL DOMMouseListenerImpl::getPropertiesFromEvent(nsIDOMEvent *event) -{ - nsCOMPtr currentNode; - nsCOMPtr aMouseEvent = event; - 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); - - if (properties) { - util_ClearPropertiesObject(env, properties, (jobject) mInitContext); - } - else { - if (!(properties = - util_CreatePropertiesObject(env, (jobject)mInitContext))) { - return properties; - } - } - dom_iterateToRoot(currentNode, DOMMouseListenerImpl::takeActionOnNode, - (void *)this); - addMouseEventDataToProperties(aMouseEvent); - - return properties; -} - -void JNICALL DOMMouseListenerImpl::addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent) -{ - if (!properties) { - return; - } - nsresult rv; - - // Add modifiers, keys, mouse buttons, etc, to the properties table - nsCOMPtr mouseEvent; - - rv = aMouseEvent->QueryInterface(nsIDOMMouseEvent::GetIID(), - getter_AddRefs(mouseEvent)); - if (NS_FAILED(rv)) { - return; - } - // initialize the standard properties keys - if (!PROPERTIES_KEYS_INITED) { - // if the initialization failed, don't modify the properties - if (!initPropertiesKeys()) { - return; - } - } - PRInt32 intVal; - PRUint16 int16Val; - PRBool boolVal; - char buf[20]; - jstring strVal; - JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); - - // PENDING(edburns): perhaps use a macro to speed this up? - rv = mouseEvent->GetScreenX(&intVal); - if (NS_SUCCEEDED(rv)) { - WC_ITOA(intVal, buf, 10); - strVal = ::util_NewStringUTF(env, buf); - ::util_StoreIntoPropertiesObject(env, properties, SCREEN_X_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetScreenY(&intVal); - if (NS_SUCCEEDED(rv)) { - WC_ITOA(intVal, buf, 10); - strVal = ::util_NewStringUTF(env, buf); - ::util_StoreIntoPropertiesObject(env, properties, SCREEN_Y_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetClientX(&intVal); - if (NS_SUCCEEDED(rv)) { - WC_ITOA(intVal, buf, 10); - strVal = ::util_NewStringUTF(env, buf); - ::util_StoreIntoPropertiesObject(env, properties, CLIENT_X_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetClientY(&intVal); - if (NS_SUCCEEDED(rv)) { - WC_ITOA(intVal, buf, 10); - strVal = ::util_NewStringUTF(env, buf); - ::util_StoreIntoPropertiesObject(env, properties, CLIENT_Y_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - int16Val = 0; - rv = mouseEvent->GetButton(&int16Val); - if (NS_SUCCEEDED(rv)) { - WC_ITOA(int16Val, buf, 10); - strVal = ::util_NewStringUTF(env, buf); - ::util_StoreIntoPropertiesObject(env, properties, BUTTON_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - int16Val = 0; - rv = mouseEvent->GetClickCount(&int16Val); - if (NS_SUCCEEDED(rv)) { - WC_ITOA(int16Val, buf, 10); - strVal = ::util_NewStringUTF(env, buf); - ::util_StoreIntoPropertiesObject(env, properties, CLICK_COUNT_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetAltKey(&boolVal); - if (NS_SUCCEEDED(rv)) { - strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; - ::util_StoreIntoPropertiesObject(env, properties, ALT_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetCtrlKey(&boolVal); - if (NS_SUCCEEDED(rv)) { - strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; - ::util_StoreIntoPropertiesObject(env, properties, CTRL_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetShiftKey(&boolVal); - if (NS_SUCCEEDED(rv)) { - strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; - ::util_StoreIntoPropertiesObject(env, properties, SHIFT_KEY, - (jobject) strVal, - (jobject) mInitContext); - } - - rv = mouseEvent->GetMetaKey(&boolVal); - if (NS_SUCCEEDED(rv)) { - strVal = boolVal ? (jstring) TRUE_VALUE : (jstring) FALSE_VALUE; - ::util_StoreIntoPropertiesObject(env, properties, META_KEY, - (jobject) strVal, - (jobject) mInitContext); - } -} - -nsresult JNICALL DOMMouseListenerImpl::takeActionOnNode(nsCOMPtr 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, 4, ("%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, 4, ("%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, - (jobject) curThis->mInitContext); - 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 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, 4, - ("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, 4, - ("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, - (jobject) curThis->mInitContext); - if (jNodeName) { - ::util_DeleteString(env, jNodeName); - } - if (jNodeValue) { - ::util_DeleteString(env, jNodeValue); - } - } - } // end of storing the attributes - - return rv; -} - -// -// Local functions -// - -jboolean initPropertiesKeys() -{ - JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); - - if (nsnull == (SCREEN_X_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "ScreenX")))) { - return JNI_FALSE; - } - if (nsnull == (SCREEN_Y_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "ScreenY")))) { - return JNI_FALSE; - } - if (nsnull == (CLIENT_X_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "ClientX")))) { - return JNI_FALSE; - } - if (nsnull == (CLIENT_Y_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "ClientY")))) { - return JNI_FALSE; - } - if (nsnull == (ALT_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "Alt")))) { - return JNI_FALSE; - } - if (nsnull == (CTRL_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "Ctrl")))) { - return JNI_FALSE; - } - if (nsnull == (SHIFT_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "Shift")))) { - return JNI_FALSE; - } - if (nsnull == (META_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "Meta")))) { - return JNI_FALSE; - } - if (nsnull == (BUTTON_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "Button")))) { - return JNI_FALSE; - } - if (nsnull == (CLICK_COUNT_KEY = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, - "ClickCount")))) { - return JNI_FALSE; - } - if (nsnull == (TRUE_VALUE = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "true")))) { - return JNI_FALSE; - } - if (nsnull == (FALSE_VALUE = - ::util_NewGlobalRef(env, (jobject) - ::util_NewStringUTF(env, "false")))) { - return JNI_FALSE; - } - - return PROPERTIES_KEYS_INITED = JNI_TRUE; -} diff --git a/mozilla/java/webclient/src_moz/DOMMouseListenerImpl.h b/mozilla/java/webclient/src_moz/DOMMouseListenerImpl.h deleted file mode 100644 index 311a2a449da..00000000000 --- a/mozilla/java/webclient/src_moz/DOMMouseListenerImpl.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- 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 - * - */ - -#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(); - - virtual ~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 -// -protected: - -jobject JNICALL getPropertiesFromEvent(nsIDOMEvent *aMouseEvent); - -void JNICALL addMouseEventDataToProperties(nsIDOMEvent *aMouseEvent); - -static nsresult JNICALL takeActionOnNode(nsCOMPtr 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 currentDOMEvent; - -// -// End of ivars used in takeActionOnNode -// - -}; - -#endif // DOMMouseListenerImpl_h diff --git a/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp b/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp deleted file mode 100644 index 08c8bcd4ad7..00000000000 --- a/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* -*- 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): Kirk Baker - * Ian Wilkinson - * Mark Lin - * Mark Goddard - * Ed Burns - * Ann Sunhachawee - */ - -#include "DocumentLoaderObserverImpl.h" - -#include "nsString.h" -#include "jni_util.h" -#include "dom_util.h" -#include "nsActions.h" - -#include "nsIDOMDocument.h" - -#include "prlog.h" // for PR_ASSERT - -jlong DocumentLoaderObserverImpl::maskValues[] = { -1L }; - -char *DocumentLoaderObserverImpl::maskNames[] = { - "START_DOCUMENT_LOAD_EVENT_MASK", - "END_DOCUMENT_LOAD_EVENT_MASK", - "START_URL_LOAD_EVENT_MASK", - "END_URL_LOAD_EVENT_MASK", - "PROGRESS_URL_LOAD_EVENT_MASK", - "STATUS_URL_LOAD_EVENT_MASK", - "UNKNOWN_CONTENT_EVENT_MASK", - "FETCH_INTERRUPT_EVENT_MASK", - nsnull -}; - -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() : mRefCnt(1), -mTarget(nsnull), mMouseListener(nsnull), mDomEventTarget(nsnull) { -} - -DocumentLoaderObserverImpl::DocumentLoaderObserverImpl(JNIEnv *env, - 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! - } -#ifndef BAL_INTERFACE - PR_ASSERT(gVm); -#endif - - if (-1 == maskValues[0]) { - util_InitializeEventMaskValuesFromClass("org/mozilla/webclient/DocumentLoadEvent", - maskNames, maskValues); - } - mRefCnt = 1; // PENDING(edburns): not sure about how right this is to do. -} - -DocumentLoaderObserverImpl::~DocumentLoaderObserverImpl() -{ - RemoveMouseListener(); -} - -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; - } - 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, - const char* aCommand) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("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) { - - // 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); - - aURL->GetSpec(&urlStr); - if (nsnull != urlStr) { - urlJStr = (jobject) ::util_NewStringUTF(env, urlStr); - ::Recycle(urlStr); - } - } - util_SendEventToJava(mInitContext->env, - mInitContext->nativeEventThread, mTarget, - maskValues[START_DOCUMENT_LOAD_EVENT_MASK], urlJStr); - - if (urlJStr) { - ::util_DeleteStringUTF(mInitContext->env, (jstring) urlJStr); - } - - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - nsresult aStatus) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("!!DocumentLoaderObserverImpl.cpp: OnEndDocumentLoad\n")); - } -#endif - nsCOMPtr doc; - 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; - } - mInitContext->currentDocument = doc; - - // if we have a mouse listener - if (mMouseListener) { - // install the mouse listener into mozilla - - PR_ASSERT(mMouseListener); - - nsresult rv; - - rv = doc->QueryInterface(NS_GET_IID(nsIDOMEventTarget), - getter_AddRefs(mDomEventTarget)); - if (NS_FAILED(rv) || !mDomEventTarget) { - return NS_OK; - } - nsAutoString eType("mouseover"); - mDomEventTarget->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, - maskValues[END_DOCUMENT_LOAD_EVENT_MASK], nsnull); - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("!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); - - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - PRUint32 aProgress, - PRUint32 aProgressMax) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("!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); - - - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - nsString& aMsg) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("!DocumentLoaderObserverImpl: OnStatusURLLoad: %S\n", - 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, (const jchar *) - aMsg.GetUnicode(), length); - - util_SendEventToJava(mInitContext->env, mInitContext->nativeEventThread, mTarget, - maskValues[STATUS_URL_LOAD_EVENT_MASK], (jobject) statusMessage); - - if (statusMessage) { - ::util_DeleteString(mInitContext->env, statusMessage); - } - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - nsresult aStatus) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("!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); - - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::HandleUnknownContentType(nsIDocumentLoader* loader, - nsIChannel* channel, - const char *aContentType, - const char *aCommand) -{ -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("!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 toAdd) -{ - nsresult rv = NS_ERROR_FAILURE; - - if (nsnull == toAdd) { - return rv; - } - - mMouseListener = toAdd; - - return NS_OK; -} - -NS_IMETHODIMP DocumentLoaderObserverImpl::RemoveMouseListener() -{ - nsresult rv = NS_OK; - - if (mDomEventTarget && mMouseListener) { - nsAutoString eType("mouseover"); - mDomEventTarget->RemoveEventListener(eType, mMouseListener, PR_FALSE); - mDomEventTarget = nsnull; - mMouseListener = nsnull; - } - - 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; -} diff --git a/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.h b/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.h deleted file mode 100644 index 87f0d5b6f80..00000000000 --- a/mozilla/java/webclient/src_moz/DocumentLoaderObserverImpl.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- 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): Kirk Baker - * Ian Wilkinson - * Mark Lin - * Mark Goddard - * Ed Burns - * Ann Sunhachawee - */ - -#ifndef DocumentLoaderObserverImpl_h -#define DocumentLoaderObserverImpl_h - -#include "nsISupports.h" -#include "nsISupportsUtils.h" -#include "nsString.h" -#include "nsIDocumentLoaderObserver.h" -#include "nsIDOMMouseListener.h" -#include "nsIDOMEventTarget.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 - * 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. - - */ - -class DocumentLoaderObserverImpl : public nsIDocumentLoaderObserver { - NS_DECL_ISUPPORTS -public: - -typedef enum { - START_DOCUMENT_LOAD_EVENT_MASK = 0, - END_DOCUMENT_LOAD_EVENT_MASK, - START_URL_LOAD_EVENT_MASK, - END_URL_LOAD_EVENT_MASK, - PROGRESS_URL_LOAD_EVENT_MASK, - STATUS_URL_LOAD_EVENT_MASK, - UNKNOWN_CONTENT_EVENT_MASK, - FETCH_INTERRUPT_EVENT_MASK, - NUMBER_OF_MASK_NAMES -} EVENT_MASK_NAMES; - - -#ifdef XP_UNIX -static jlong maskValues [NUMBER_OF_MASK_NAMES]; -#else -static jlong maskValues [DocumentLoaderObserverImpl::EVENT_MASK_NAMES::NUMBER_OF_MASK_NAMES]; -#endif - -static char *maskNames []; - - DocumentLoaderObserverImpl(JNIEnv *yourJNIEnv, - WebShellInitContext *yourInitContext); - - DocumentLoaderObserverImpl(); - virtual ~DocumentLoaderObserverImpl(); - - /* nsIDocumentLoaderObserver methods */ - NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, - nsIURI* aURL, - const char* aCommand); - - NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - nsresult aStatus); - - NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel); - - NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - PRUint32 aProgress, - PRUint32 aProgressMax); - - NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - nsString& aMsg); - - NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, - nsIChannel* channel, - nsresult aStatus); - - NS_IMETHOD HandleUnknownContentType(nsIDocumentLoader* loader, - nsIChannel* channel, - const char *aContentType, - const char *aCommand); - -// -// Methods for NS_IDOCLOADEROBSERVERIMPL_IID -// - -/** - - * Called in EventRegistration.{h,cpp} addMouseListener. - - */ - - NS_IMETHOD AddMouseListener(nsCOMPtr toAdd); - - NS_IMETHOD RemoveMouseListener(void); - - NS_IMETHOD SetTarget(jobject newTarget); - - NS_IMETHOD ClearTarget(void); - -protected: - - JNIEnv *mJNIEnv; - WebShellInitContext *mInitContext; - jobject mTarget; - nsCOMPtr mMouseListener; - nsCOMPtr mDomEventTarget; - -}; - -#endif // DocumentLoaderObserverImpl_h diff --git a/mozilla/java/webclient/src_moz/EventRegistration.cpp b/mozilla/java/webclient/src_moz/EventRegistration.cpp deleted file mode 100644 index ea635592056..00000000000 --- a/mozilla/java/webclient/src_moz/EventRegistration.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- 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): Kirk Baker - * Ian Wilkinson - * Mark Lin - * Mark Goddard - * Ed Burns - * Ann Sunhachawee - */ - -#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) -{ - if (initContext->initComplete) { - - - PR_ASSERT(initContext->nativeEventThread); - nsresult rv; - nsCOMPtr curObserver; - nsCOMPtr myListener = nsnull; - - 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->initComplete) { - nsresult rv; - nsCOMPtr curObserver; - nsCOMPtr 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 mouseListener = - new DOMMouseListenerImpl(env, initContext, listener); - - myListener->AddMouseListener(mouseListener); - } -} - -void removeAllListeners(JNIEnv *env, WebShellInitContext *initContext) -{ - if (initContext->initComplete) { - nsresult rv; - nsCOMPtr curObserver; - nsCOMPtr 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, see if it's something we added - rv = curObserver->QueryInterface(kIDocumentLoaderObserverImplIID, - getter_AddRefs(myListener)); - } - if (myListener) { - // remove the doc listener from the docShell - rv = initContext->docShell->SetDocLoaderObserver(nsnull); - // remove the mouse listener from the doc listener - myListener->RemoveMouseListener(); - myListener = nsnull; - } - } - -} diff --git a/mozilla/java/webclient/src_moz/EventRegistration.h b/mozilla/java/webclient/src_moz/EventRegistration.h deleted file mode 100644 index ee132c8eb44..00000000000 --- a/mozilla/java/webclient/src_moz/EventRegistration.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- 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): Kirk Baker - * Ian Wilkinson - * Mark Lin - * Mark Goddard - * Ed Burns - * Ann Sunhachawee - */ - -#ifndef EventRegistration_h -#define EventRegistration_h - -#include "jni_util.h" - -/** - - * This file contains methods to add and remove listeners. - - */ - -/** - - * This function creates an instance of DocumentLoaderObserverImpl, - * which is the shim between the mozilla nsIDocumentLoaderObserver class - * and the Java DocumentLoadListener interface. See - * DocumentLoaderObserverImpl.h - - * PENDING(): implement removeDocumentLoadListener - - * PENDING(): implement the ability to have multiple listener instances - * per listener types, all of which get notified. - - */ - -void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext, - 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); - -void removeAllListeners(JNIEnv *env, WebShellInitContext *initContext); - - -#endif diff --git a/mozilla/java/webclient/src_moz/HistoryImpl.cpp b/mozilla/java/webclient/src_moz/HistoryImpl.cpp index bd30cd7d855..99fced2fef3 100644 --- a/mozilla/java/webclient/src_moz/HistoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/HistoryImpl.cpp @@ -22,7 +22,7 @@ * Mark Lin * Mark Goddard * Ed Burns - * Ann Sunhachawee + * Ashutosh Kulkarni */ #include "HistoryImpl.h" @@ -47,7 +47,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeBack if (initContext->initComplete) { wsBackEvent * actionEvent = - new wsBackEvent(initContext->sessionHistory, initContext->webShell); + new wsBackEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostSynchronousEvent(initContext, event); @@ -63,7 +63,8 @@ JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanBack jboolean result = JNI_FALSE; JNIEnv * pEnv = env; jobject jobj = obj; - void * voidResult; + void * voidResult; + // PRBool voidResult; WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; @@ -73,12 +74,12 @@ JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeCanBack } if (initContext->initComplete) { - wsCanBackEvent * actionEvent = - new wsCanBackEvent(initContext->sessionHistory); + wsCanBackEvent * actionEvent = + new wsCanBackEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; voidResult = ::util_PostSynchronousEvent(initContext, event); - + result = (PR_FALSE == ((PRBool) voidResult)) ? JNI_FALSE : JNI_TRUE; } @@ -115,8 +116,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_na if (initContext->initComplete) { wsForwardEvent * actionEvent = - new wsForwardEvent(initContext->sessionHistory, - initContext->webShell); + new wsForwardEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostSynchronousEvent(initContext, event); @@ -142,7 +142,7 @@ JNIEXPORT jboolean JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImp if (initContext->initComplete) { wsCanForwardEvent * actionEvent = - new wsCanForwardEvent(initContext->sessionHistory); + new wsCanForwardEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; voidResult = ::util_PostSynchronousEvent(initContext, event); @@ -195,8 +195,16 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetCurrentHistoryIn } if (initContext->initComplete) { + nsISHistory* sHistory; + nsresult rv = initContext->webNavigation->GetSessionHistory(&sHistory); + + if ( NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Exception: couldn't get History for passing to raptorWebShellGetHistoryIndex"); + return result; + } + wsGetHistoryIndexEvent * actionEvent = - new wsGetHistoryIndexEvent(initContext->sessionHistory); + new wsGetHistoryIndexEvent(sHistory); PLEvent * event = (PLEvent*) *actionEvent; voidResult = ::util_PostSynchronousEvent(initContext, event); @@ -224,8 +232,7 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeSetCurrentHistoryIn if (initContext->initComplete) { wsGoToEvent * actionEvent = - new wsGoToEvent(initContext->sessionHistory, - initContext->webShell, historyIndex); + new wsGoToEvent(initContext->webNavigation, historyIndex); PLEvent * event = (PLEvent*) *actionEvent; voidResult = ::util_PostSynchronousEvent(initContext, event); @@ -249,10 +256,18 @@ Java_org_mozilla_webclient_wrapper_1native_HistoryImpl_nativeGetHistoryLength ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetHistoryLength"); return result; } - + if (initContext->initComplete) { + nsISHistory* sHistory; + nsresult rv = initContext->webNavigation->GetSessionHistory(&sHistory); + + if ( NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Exception: couldn't get History for passing to raptorWebShellGetHistoryIndex"); + return result; + } + wsGetHistoryLengthEvent * actionEvent = - new wsGetHistoryLengthEvent(initContext->sessionHistory); + new wsGetHistoryLengthEvent(sHistory); PLEvent * event = (PLEvent*) *actionEvent; voidResult = ::util_PostSynchronousEvent(initContext, event); @@ -277,11 +292,19 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_webclient_wrapper_1native_HistoryImpl ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellGetURL"); return nsnull; } - + if (initContext->initComplete) { - wsGetURLForIndexEvent * actionEvent = - new wsGetURLForIndexEvent(initContext->sessionHistory, - historyIndex); + nsISHistory* sHistory; + nsresult rv = initContext->webNavigation->GetSessionHistory(&sHistory); + + if ( NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Exception: couldn't get History for passing to raptorWebShellGetHistoryIndex"); + return nsnull; + } + + wsGetURLForIndexEvent * actionEvent = + new wsGetURLForIndexEvent(initContext->sHistory, + historyIndex); PLEvent * event = (PLEvent*) *actionEvent; charResult = (char *) ::util_PostSynchronousEvent(initContext, event); diff --git a/mozilla/java/webclient/src_moz/Makefile.win b/mozilla/java/webclient/src_moz/Makefile.win index acd2cfebb48..f41163a4e8d 100644 --- a/mozilla/java/webclient/src_moz/Makefile.win +++ b/mozilla/java/webclient/src_moz/Makefile.win @@ -26,21 +26,20 @@ MAKE_OBJ_TYPE = DLL MODULE=webclient + 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)\BookmarksImpl.obj \ .\$(OBJDIR)\WrapperFactoryImpl.obj \ .\$(OBJDIR)\WindowControlImpl.obj \ .\$(OBJDIR)\NavigationImpl.obj \ + .\$(OBJDIR)\CBrowserContainer.obj \ .\$(OBJDIR)\NativeEventThread.obj \ .\$(OBJDIR)\RDFEnumeration.obj \ .\$(OBJDIR)\RDFTreeNode.obj \ @@ -80,9 +79,9 @@ LLIBS = \ $(DIST)\lib\xpcom.lib \ $(DIST)\lib\gkgfxwin.lib \ $(DIST)\lib\nsreg.lib \ - $(DIST)\lib\nspr3.lib \ - $(DIST)\lib\plds3.lib \ - $(DIST)\lib\plc3.lib \ + $(DIST)\lib\nspr4.lib \ + $(DIST)\lib\plc4.lib \ + $(DIST)\lib\plds4.lib \ # $(DEPTH)\xpfe\bootstrap\$(OBJDIR)\nsSetupRegistry.obj \ $(NULL) diff --git a/mozilla/java/webclient/src_moz/NativeEventThread.cpp b/mozilla/java/webclient/src_moz/NativeEventThread.cpp index 14bb0061120..1a2a993e812 100644 --- a/mozilla/java/webclient/src_moz/NativeEventThread.cpp +++ b/mozilla/java/webclient/src_moz/NativeEventThread.cpp @@ -22,32 +22,48 @@ * Mark Lin * Mark Goddard * Ed Burns + * Ashutosh Kulkarni * Ann Sunhachawee */ #include "NativeEventThread.h" +#include "CBrowserContainer.h" #include "jni_util.h" -#include "EventRegistration.h" // event callbacks +#include "ns_globals.h" +#include "nsIServiceManager.h" // for NS_InitXPCOM +#include "nsIProfile.h" // for the profile manager +#include "nsICmdLineService.h" // for the cmdline service to give to the + // profile manager. + +#include "nsCRT.h" // for nsCRT::strcmp +#include "prenv.h" +#include "nsILocalFile.h" +// #include "WrapperFactoryImpl.cpp" #ifdef XP_PC #include #endif #include "nsAppShellCIDs.h" // for NS_SESSIONHISTORY_CID -#include "nsIBaseWindow.h" // to get methods like SetVisibility #include "nsCOMPtr.h" // to get nsIBaseWindow from webshell //nsIDocShell is included in jni_util.h #include "nsIEventQueueService.h" // for PLEventQueue -#include "nsIPref.h" // for preferences #include "nsRepository.h" #include "nsIServiceManager.h" // for do_GetService -#include "nsISessionHistory.h" // for history +#include "nsIPref.h" // for preferences #include "nsIThread.h" // for PRThread +#include "nsIDocShell.h" +#include "nsIBaseWindow.h" +#include "nsIDocShellTreeItem.h" +#include "nsCWebBrowser.h" +#include "nsIEventQueueService.h" +#include "nsIThread.h" //nsIWebShell is included in jni_util.h + #include "prlog.h" // for PR_ASSERT #ifdef XP_UNIX @@ -59,8 +75,51 @@ static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); -static NS_DEFINE_IID(kISessionHistoryIID, NS_ISESSIONHISTORY_IID); -static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID); +static NS_DEFINE_IID(kISHistoryIID, NS_ISHISTORY_IID); +static NS_DEFINE_CID(kSHistoryCID, NS_SHISTORY_CID); + +static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); + +static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); + +static const char *NS_DOCSHELL_PROGID = "component://netscape/docshell/html"; +//static const char *NS_WEBBROWSER_PROGID = "component://netscape/embedding/browser/nsWebBrowser"; + +extern const char * gBinDir; + +#ifdef XP_PC + +// All this stuff is needed to initialize the history + +#define APPSHELL_DLL "appshell.dll" +#define BROWSER_DLL "nsbrowser.dll" +#define EDITOR_DLL "ender.dll" + +#else + +#ifdef XP_MAC + +#define APPSHELL_DLL "APPSHELL_DLL" +#define EDITOR_DLL "ENDER_DLL" + +#else + +// XP_UNIX || XP_BEOS +#define APPSHELL_DLL "libnsappshell"MOZ_DLL_SUFFIX +#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX +#define EDITOR_DLL "libender"MOZ_DLL_SUFFIX + +#endif // XP_MAC + +#endif // XP_PC + +// +// Functions to hook into mozilla +// + +extern "C" void NS_SetupRegistry(); +extern nsresult NS_AutoregisterComponents(); + // // Local functions @@ -76,8 +135,8 @@ int processEventLoop(WebShellInitContext * initContext); /** - * Called from Java nativeInitialize to create the webshell, history, - * prefs, and other mozilla things, then start the event loop. + * Called from Java nativeInitialize to create the webshell, history + * and other mozilla things, then start the event loop. */ @@ -87,7 +146,13 @@ nsresult InitMozillaStuff (WebShellInitContext * arg); // Local data // -nsISessionHistory *gHistory = nsnull; +nsISHistory *gHistory = nsnull; +nsIComponentManager *gComponentManager = nsnull; +static PRBool gFirstTime = PR_TRUE; +static PLEventQueue * gActionQueue; +static PRThread * gEmbeddedThread; + + char * errorMessages[] = { "No Error", @@ -101,11 +166,6 @@ char * errorMessages[] = { * a null terminated array of listener interfaces we support. - * PENDING(): this should probably live in EventRegistration.h - - * PENDING(edburns): need to abstract this out so we can use it from uno - * and JNI. - */ const char *gSupportedListenerInterfaces[] = { @@ -114,8 +174,7 @@ const char *gSupportedListenerInterfaces[] = { nsnull }; -// these index into the gSupportedListenerInterfaces array, this should -// also live in EventRegistration.h +// these index into the gSupportedListenerInterfaces array typedef enum { DOCUMENT_LOAD_LISTENER = 0, @@ -191,8 +250,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr * PENDING(): implement nativeRemoveListener, which must call * RemoveGlobalRef. - * See the comments for EventRegistration.h:addDocumentLoadListener - */ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeAddListener @@ -204,7 +261,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr ::util_ThrowExceptionToJava(env, "Exception: null initContext passed tonativeAddListener"); return; } - if (nsnull == initContext->nativeEventThread) { // store the java EventRegistrationImpl class in the initContext initContext->nativeEventThread = @@ -242,15 +298,17 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NativeEventThr ::util_ThrowExceptionToJava(env, "Exception: NativeEventThread.nativeAddListener(): can't create NewGlobalRef\n\tfor argument"); return; } + PR_ASSERT(initContext->browserContainer); switch(listenerType) { case DOCUMENT_LOAD_LISTENER: - addDocumentLoadListener(env, initContext, globalRef); + initContext->browserContainer->AddDocumentLoadListener(globalRef); break; case MOUSE_LISTENER: - addMouseListener(env, initContext, globalRef); + initContext->browserContainer->AddMouseListener(globalRef); break; } + } JNIEXPORT void JNICALL @@ -263,10 +321,9 @@ Java_org_mozilla_webclient_wrapper_1native_NativeEventThread_nativeRemoveAllList return; } - removeAllListeners(env, initContext); + // removeAllListeners(env, initContext); } - /** * This function processes methods inserted into WebShellInitContext's @@ -343,99 +400,173 @@ static void event_processor_callback(gpointer data, #endif // + +void DoMozInitialization(WebShellInitContext * initContext) +{ + if (gFirstTime) { + nsILocalFile * pathFile = nsnull; + nsresult rv = nsnull; + JNIEnv * env = initContext->env; + const char * BinDir = gBinDir; + + rv = NS_NewLocalFile(BinDir, &pathFile); + if (NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "call to NS_NewLocalFile failed."); + return; + } + + // It is vitally important to call NS_InitXPCOM before calling + // anything else. + NS_InitXPCOM(nsnull, pathFile); + NS_SetupRegistry(); + rv = NS_GetGlobalComponentManager(&gComponentManager); + if (NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "NS_GetGlobalComponentManager() failed."); + return; + } + prLogModuleInfo = PR_NewLogModule("webclient"); + const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE"); + if (nsnull != webclientLogFile) { + PR_SetLogFile(webclientLogFile); + // If this fails, it just goes to stdout/stderr + } + + gComponentManager->RegisterComponentLib(kSHistoryCID, nsnull, + nsnull, APPSHELL_DLL, + PR_FALSE, PR_FALSE); + NS_AutoregisterComponents(); + + // handle the profile manager nonsense + nsCOMPtr cmdLine =do_GetService(kCmdLineServiceCID); + nsCOMPtr profile = do_GetService(NS_PROFILE_PROGID); + if (!cmdLine || !profile) { + ::util_ThrowExceptionToJava(env, "Can't get the profile manager."); + return; + } + char *argv[1]; + argv[0] = strdup(gBinDir); + rv = cmdLine->Initialize(1, argv); + nsCRT::free(argv[0]); + if (NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Can't initialize nsICmdLineService."); + return; + } + rv = profile->StartupWithArgs(cmdLine); + if (NS_FAILED(rv)) { + ::util_ThrowExceptionToJava(env, "Can't statrup nsIProfile service."); + return; + } + } +} + + + nsresult InitMozillaStuff (WebShellInitContext * initContext) { + nsresult rv = nsnull; + + DoMozInitialization(initContext); + PR_ASSERT(gComponentManager); - nsCOMPtr - aEventQService = do_GetService(NS_EVENTQUEUESERVICE_PROGID); + if (gFirstTime) + { + nsCOMPtr + aEventQService = do_GetService(NS_EVENTQUEUESERVICE_PROGID); - // if we get here, we know that aEventQService is not null. - nsresult rv = NS_ERROR_FAILURE; - PRBool allowPlugins = PR_FALSE; + // if we get here, we know that aEventQService is not null. + nsresult rv = NS_ERROR_FAILURE; - //TODO Add tracing from nspr. + //TODO Add tracing from nspr. -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", - initContext)); - } -#endif - - // Create the Event Queue for the UI thread... - if (!aEventQService) { - initContext->initFailCode = kEventQueueError; - return rv; - } - - // Create the event queue. - rv = aEventQService->CreateThreadEventQueue(); - - initContext->embeddedThread = PR_GetCurrentThread(); - - // Create the action queue - if (initContext->embeddedThread) { - -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): embeddedThread != nsnull\n", initContext)); - } -#endif - if (initContext->actionQueue == nsnull) { -#if DEBUG_RAPTOR_CANVAS + #if DEBUG_RAPTOR_CANVAS if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, ("InitMozillaStuff(%lx): Create the action queue\n", initContext)); + PR_LOG(prLogModuleInfo, 3, + ("InitMozillaStuff(%lx): Create the Event Queue for the UI thread...\n", + initContext)); } -#endif - // We need to do something different for Unix - nsIEventQueue * EQueue = nsnull; - - rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread, - &EQueue); - if (NS_FAILED(rv)) { - initContext->initFailCode = kCreateWebShellError; + #endif + + // Create the Event Queue for the UI thread... + if (!aEventQService) { + initContext->initFailCode = kEventQueueError; return rv; } - -#ifdef XP_UNIX - gdk_input_add(EQueue->GetEventQueueSelectFD(), - GDK_INPUT_READ, - event_processor_callback, - EQueue); -#endif - - PLEventQueue * plEventQueue = nsnull; - - EQueue->GetPLEventQueue(&plEventQueue); - initContext->actionQueue = plEventQueue; - } - } - else { - initContext->initFailCode = kCreateWebShellError; - return NS_ERROR_UNEXPECTED; - } - -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("InitMozillaStuff(%lx): Create the WebShell...\n", initContext)); - } -#endif - // Create the WebShell. - rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, getter_AddRefs(initContext->webShell)); - if (NS_FAILED(rv)) { - initContext->initFailCode = kCreateWebShellError; - return rv; - } -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("InitMozillaStuff(%lx): Init the WebShell...\n", initContext)); - } -#endif + // Create the event queue. + rv = aEventQService->CreateThreadEventQueue(); + initContext->embeddedThread = PR_GetCurrentThread(); + gEmbeddedThread = initContext->embeddedThread; + + // Create the action queue + if (initContext->embeddedThread) { + + if (initContext->actionQueue == nsnull) { + printf("InitMozillaStuff(%lx): Create the action queue\n", initContext); + + // We need to do something different for Unix + nsIEventQueue * EQueue = nsnull; + + rv = aEventQService->GetThreadEventQueue(initContext->embeddedThread, + &EQueue); + if (NS_FAILED(rv)) { + initContext->initFailCode = kCreateWebShellError; + return rv; + } + + #ifdef XP_UNIX + gdk_input_add(EQueue->GetEventQueueSelectFD(), + GDK_INPUT_READ, + event_processor_callback, + EQueue); + #endif + + PLEventQueue * plEventQueue = nsnull; + + EQueue->GetPLEventQueue(&plEventQueue); + initContext->actionQueue = plEventQueue; + gActionQueue = initContext->actionQueue; + } + } + else { + initContext->initFailCode = kCreateWebShellError; + return NS_ERROR_UNEXPECTED; + } + } + else + { + initContext->embeddedThread = gEmbeddedThread; + initContext->actionQueue = gActionQueue; + } + + // Setup Prefs obj and read default prefs + if (gFirstTime) + { + nsCOMPtr mPrefs(do_GetService(kPrefCID)); + if (!mPrefs) { + initContext->initFailCode = kCreateWebShellError; + return NS_ERROR_UNEXPECTED; + } + rv = mPrefs->StartUp(); + rv = mPrefs->ReadUserPrefs(); + gFirstTime = PR_FALSE; + } + PRBool allowPlugins = PR_TRUE; + + // Create the WebBrowser. + nsCOMPtr webBrowser; + webBrowser = do_CreateInstance(NS_WEBBROWSER_PROGID); + + initContext->webBrowser = webBrowser; + + // Get the BaseWindow from the DocShell - upcast + // nsCOMPtr docShellAsWin(do_QueryInterface(webBrowser)); + nsCOMPtr docShellAsWin; + rv = webBrowser->QueryInterface(NS_GET_IID(nsIBaseWindow), getter_AddRefs(docShellAsWin)); + + initContext->baseWindow = docShellAsWin; + + printf ("Init the baseWindow\n"); #ifdef XP_UNIX GdkSuperWin * superwin; @@ -445,83 +576,90 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) if (prLogModuleInfo) { PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - before Init Call...\n", initContext)); } - rv = initContext->webShell->Init((nsNativeWidget *)superwin, initContext->x, initContext->y, initContext->w, initContext->h); + rv = initContext->baseWindow->InitWindow((nativeWindow) superwin, nsnull, initContext->x, initContext->y, initContext->w, initContext->h); if (prLogModuleInfo) { PR_LOG(prLogModuleInfo, 3, ("Ashu Debugs - Inside InitMozillaStuff(%lx): - after Init Call...\n", initContext)); } #else - rv = initContext->webShell->Init((nsNativeWidget *)initContext->parentHWnd, + rv = initContext->baseWindow->InitWindow((nativeWindow) initContext->parentHWnd, nsnull, initContext->x, initContext->y, initContext->w, initContext->h); #endif - + printf("Create the BaseWindow...\n"); + + rv = initContext->baseWindow->Create(); + if (NS_FAILED(rv)) { initContext->initFailCode = kInitWebShellError; return rv; } -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("InitMozillaStuff(%lx): Install Prefs in the Webshell...\n", initContext)); - } -#endif + // Create the DocShell - nsCOMPtr prefs = do_GetService(NS_PREF_PROGID); - - if (prefs) { - if (nsnull == gComponentManager) { // only do this once per app. - prefs->ReadUserPrefs(); - } - // Set the prefs in the outermost webshell. - initContext->webShell->SetPrefs(prefs); + nsIDocShell * docShell; + rv = webBrowser->GetDocShell(getter_AddRefs(&docShell)); + initContext->docShell = docShell; + printf("docShell is %l \n", docShell); + + if (NS_FAILED(rv)) { + initContext->initFailCode = kCreateDocShellError; + return rv; } + // create our BrowserContainer, which implements many many things. + + initContext->browserContainer = + new CBrowserContainer(initContext->webBrowser, initContext->env, + initContext); + + // set the WebShellContainer. This is a pain. It's necessary + // because nsWebShell.cpp still checks for mContainer all over the + // place. + nsCOMPtr wsContainer(do_QueryInterface(initContext->browserContainer)); + nsCOMPtr webShell(do_QueryInterface(docShell)); + webShell->SetContainer(wsContainer); + + // set the URIContentListener + nsCOMPtr contentListener(do_QueryInterface(initContext->browserContainer)); + webBrowser->SetParentURIContentListener(contentListener); + + // set the TreeOwner + nsCOMPtr docShellAsItem(do_QueryInterface(docShell)); + nsCOMPtr treeOwner(do_QueryInterface(initContext->browserContainer)); + docShellAsItem->SetTreeOwner(treeOwner); + + // set the docloaderobserver + nsCOMPtr observer(do_QueryInterface(initContext->browserContainer)); + docShell->SetDocLoaderObserver(observer); + if (nsnull == gHistory) { - rv = gComponentManager->CreateInstance(kSessionHistoryCID, nsnull, - kISessionHistoryIID, + rv = gComponentManager->CreateInstance(kSHistoryCID, nsnull, + kISHistoryIID, (void**)&gHistory); - if (NS_FAILED(rv)) { - initContext->initFailCode = kHistoryWebShellError; - return rv; - } + if (NS_FAILED(rv)) { + initContext->initFailCode = kHistoryWebShellError; + return rv; + } } - initContext->webShell->SetSessionHistory(gHistory); - // set the sessionHistory in the initContexn - initContext->sessionHistory = gHistory; - -#if DEBUG_RAPTOR_CANVAS - if (prLogModuleInfo) { - PR_LOG(prLogModuleInfo, 3, - ("InitMozillaStuff(%lx): Show the WebShell...\n", initContext)); - } -#endif + printf("Creation Done.....\n"); + // Get the WebNavigation Object from the DocShell + nsCOMPtr webNav(do_QueryInterface(initContext->docShell)); + initContext->webNavigation = webNav; - nsCOMPtr baseWindow; - - rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); + // Set the History + // initContext->webNavigation->SetSessionHistory(gHistory); + + // Save the sessionHistory in the initContext + // initContext->sHistory = gHistory; + printf("Show the webBrowser\n"); + // Show the webBrowser + rv = initContext->baseWindow->SetVisibility(PR_TRUE); if (NS_FAILED(rv)) { initContext->initFailCode = kShowWebShellError; return rv; } - rv = baseWindow->SetVisibility(PR_TRUE); - if (NS_FAILED(rv)) { - initContext->initFailCode = kShowWebShellError; - return rv; - } - - // set the docShell - rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIDocShell), - getter_AddRefs(initContext->docShell)); - - if (NS_FAILED(rv)) { - initContext->initFailCode = kHistoryWebShellError; - return rv; - } - initContext->initComplete = TRUE; @@ -531,9 +669,14 @@ nsresult InitMozillaStuff (WebShellInitContext * initContext) ("InitMozillaStuff(%lx): enter event loop\n", initContext)); } #endif - + PRThread *thread = PR_GetCurrentThread(); + printf("debug: edburns: InitMozillaStuff currentThread %p\n", thread); + // Just need to loop once to clear out events before returning processEventLoop(initContext); return rv; } + + + diff --git a/mozilla/java/webclient/src_moz/NavigationImpl.cpp b/mozilla/java/webclient/src_moz/NavigationImpl.cpp index 18894f7d245..1b9c1d535c5 100644 --- a/mozilla/java/webclient/src_moz/NavigationImpl.cpp +++ b/mozilla/java/webclient/src_moz/NavigationImpl.cpp @@ -22,6 +22,7 @@ * Mark Lin * Mark Goddard * Ed Burns + * Ashutosh Kulkarni * Ann Sunhachawee */ @@ -66,7 +67,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl } if (initContext->initComplete) { - wsLoadURLEvent * actionEvent = new wsLoadURLEvent(initContext->webShell, urlStringChars); + wsLoadURLEvent * actionEvent = new wsLoadURLEvent(initContext->webNavigation, urlStringChars); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); @@ -90,7 +91,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl } if (initContext->initComplete) { - wsRefreshEvent * actionEvent = new wsRefreshEvent(initContext->webShell, (long) loadFlags); + wsRefreshEvent * actionEvent = new wsRefreshEvent(initContext->webNavigation, (PRInt32) loadFlags); PLEvent * event = (PLEvent*) *actionEvent; voidResult = ::util_PostSynchronousEvent(initContext, event); @@ -115,7 +116,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_NavigationImpl } if (initContext->initComplete) { - wsStopEvent * actionEvent = new wsStopEvent(initContext->webShell); + wsStopEvent * actionEvent = new wsStopEvent(initContext->webNavigation); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); diff --git a/mozilla/java/webclient/src_moz/WindowControlImpl.cpp b/mozilla/java/webclient/src_moz/WindowControlImpl.cpp index 47ad2b5a999..f6905356615 100644 --- a/mozilla/java/webclient/src_moz/WindowControlImpl.cpp +++ b/mozilla/java/webclient/src_moz/WindowControlImpl.cpp @@ -22,6 +22,7 @@ * Mark Lin * Mark Goddard * Ed Burns + * Ashutosh Kulkarni * Ann Sunhachawee */ @@ -50,7 +51,7 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetBounds } if (initContext->initComplete) { wsResizeEvent * actionEvent = - new wsResizeEvent(initContext->webShell, x, y, w, h); + new wsResizeEvent(initContext->baseWindow, x, y, w, h); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); @@ -83,8 +84,12 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI initContext->initFailCode = 0; initContext->parentHWnd = parentHWnd; initContext->webShell = nsnull; + initContext->docShell = nsnull; + initContext->baseWindow = nsnull; + initContext->sHistory = nsnull; + initContext->webNavigation = nsnull; + initContext->presShell = nsnull; initContext->embeddedThread = nsnull; - initContext->sessionHistory = nsnull; initContext->actionQueue = nsnull; initContext->env = env; initContext->nativeEventThread = nsnull; @@ -96,6 +101,7 @@ JNIEXPORT jint JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI initContext->searchContext = nsnull; initContext->currentDocument = nsnull; initContext->propertiesClass = nsnull; + initContext->browserContainer = nsnull; #ifdef XP_UNIX initContext->gtkWinPtr = @@ -128,9 +134,10 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo // see http://bugzilla.mozilla.org/show_bug.cgi?id=38271 initContext->webShell = nsnull; - - //NOTE we don't de-allocate the global session history here. - initContext->sessionHistory = nsnull; + initContext->webNavigation = nsnull; + initContext->presShell = nsnull; + initContext->sHistory = nsnull; + initContext->baseWindow = nsnull; // PENDING(edburns): not sure if these need to be deleted initContext->actionQueue = nsnull; @@ -151,6 +158,7 @@ Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeDestroyInitCo initContext->searchContext = nsnull; initContext->currentDocument = nsnull; initContext->propertiesClass = nsnull; + initContext->browserContainer = nsnull; delete initContext; } @@ -167,7 +175,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI } if (initContext->initComplete) { - wsMoveToEvent * actionEvent = new wsMoveToEvent(initContext->webShell, x, y); + wsMoveToEvent * actionEvent = new wsMoveToEvent(initContext->baseWindow, x, y); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); @@ -185,7 +193,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI } if (initContext->initComplete) { - wsRemoveFocusEvent * actionEvent = new wsRemoveFocusEvent(initContext->webShell); + wsRemoveFocusEvent * actionEvent = new wsRemoveFocusEvent(initContext->baseWindow); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); @@ -203,7 +211,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI } if (initContext->initComplete) { - wsRepaintEvent * actionEvent = new wsRepaintEvent(initContext->webShell, (PRBool) forceRepaint); + wsRepaintEvent * actionEvent = new wsRepaintEvent(initContext->baseWindow, (PRBool) forceRepaint); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); @@ -214,24 +222,18 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetVisible (JNIEnv *env, jobject obj, jint webShellPtr, jboolean newState) { - WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; - nsCOMPtr baseWindow; - nsresult rv; - - rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - initContext->initFailCode = kShowWebShellError; - return; - } - rv = baseWindow->SetVisibility(JNI_TRUE == newState ? PR_TRUE : PR_FALSE); - if (NS_FAILED(rv)) { - initContext->initFailCode = kShowWebShellError; - ::util_ThrowExceptionToJava(env, "Exception: can't SetVisibility"); - return; - } + WebShellInitContext* initContext = (WebShellInitContext *) webShellPtr; + if (initContext == nsnull) { + ::util_ThrowExceptionToJava(env, "Exception: null webShellPtr passed to raptorWebShellRepaint"); + return; + } + if (initContext->initComplete) { + wsShowEvent * actionEvent = new wsShowEvent(initContext->baseWindow, JNI_TRUE == newState ? PR_TRUE : PR_FALSE); + PLEvent * event = (PLEvent*) *actionEvent; + ::util_PostEvent(initContext, event); + } + } JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlImpl_nativeSetFocus @@ -245,12 +247,9 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WindowControlI } if (initContext->initComplete) { - wsSetFocusEvent * actionEvent = new wsSetFocusEvent(initContext->webShell); + wsSetFocusEvent * actionEvent = new wsSetFocusEvent(initContext->baseWindow); PLEvent * event = (PLEvent*) *actionEvent; ::util_PostEvent(initContext, event); } } - - - diff --git a/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp b/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp index c0f5eb05083..564e2c07f56 100644 --- a/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp +++ b/mozilla/java/webclient/src_moz/WrapperFactoryImpl.cpp @@ -22,53 +22,17 @@ * Mark Lin * Mark Goddard * Ed Burns + * Ashutosh Kulkarni * Ann Sunhachawee */ #include "WrapperFactoryImpl.h" #include "jni_util.h" - -#include "nsIServiceManager.h" // for NS_InitXPCOM -#include "nsAppShellCIDs.h" // for NS_SESSIONHISTORY_CID #include "nsCRT.h" // for nsCRT::strcmp -#include "prenv.h" -static NS_DEFINE_CID(kSessionHistoryCID, NS_SESSIONHISTORY_CID); - -#ifdef XP_PC - -// All this stuff is needed to initialize the history - -#define APPSHELL_DLL "appshell.dll" -#define BROWSER_DLL "nsbrowser.dll" -#define EDITOR_DLL "ender.dll" - -#else - -#ifdef XP_MAC - -#define APPSHELL_DLL "APPSHELL_DLL" -#define EDITOR_DLL "ENDER_DLL" - -#else - -// XP_UNIX || XP_BEOS -#define APPSHELL_DLL "libnsappshell"MOZ_DLL_SUFFIX -#define APPCORES_DLL "libappcores"MOZ_DLL_SUFFIX -#define EDITOR_DLL "libender"MOZ_DLL_SUFFIX - -#endif // XP_MAC - -#endif // XP_PC - -// -// file data -// - - -static nsFileSpec gBinDir; +const char * gBinDir; PRLogModuleInfo *prLogModuleInfo = NULL; // declared in jni_util.h @@ -86,53 +50,20 @@ const char *gImplementedInterfaces[] = { // global data // -nsIComponentManager *gComponentManager = nsnull; // // Functions to hook into mozilla // -extern "C" void NS_SetupRegistry(); -extern nsresult NS_AutoregisterComponents(); - JNIEXPORT void JNICALL Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeAppInitialize( JNIEnv *env, jobject obj, jstring verifiedBinDirAbsolutePath) { - static PRBool gFirstTime = PR_TRUE; - nsresult rv; - - if (gFirstTime) { + const char *nativePath = (const char *) ::util_GetStringUTFChars(env, verifiedBinDirAbsolutePath); - gBinDir = nativePath; - - // It is vitally important to call NS_InitXPCOM before calling - // anything else. - NS_InitXPCOM(nsnull, &gBinDir); - NS_SetupRegistry(); - rv = NS_GetGlobalComponentManager(&gComponentManager); - if (NS_FAILED(rv)) { - ::util_ThrowExceptionToJava(env, "NS_GetGlobalComponentManager() failed."); - ::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath, - nativePath); - return; - } - prLogModuleInfo = PR_NewLogModule("webclient"); - const char *webclientLogFile = PR_GetEnv("WEBCLIENT_LOG_FILE"); - if (nsnull != webclientLogFile) { - PR_SetLogFile(webclientLogFile); - // If this fails, it just goes to stdout/stderr - } - - gComponentManager->RegisterComponentLib(kSessionHistoryCID, nsnull, - nsnull, APPSHELL_DLL, - PR_FALSE, PR_FALSE); - NS_AutoregisterComponents(); - gFirstTime = PR_FALSE; + gBinDir = PL_strdup(nativePath); ::util_ReleaseStringUTFChars(env, verifiedBinDirAbsolutePath, nativePath); - - } } JNIEXPORT void JNICALL @@ -141,6 +72,8 @@ Java_org_mozilla_webclient_wrapper_1native_WrapperFactoryImpl_nativeTerminate { gComponentManager = nsnull; gHistory = nsnull; + nsCRT::free((char *) gBinDir); + gBinDir = nsnull; } JNIEXPORT jboolean JNICALL diff --git a/mozilla/java/webclient/src_moz/jni_util.cpp b/mozilla/java/webclient/src_moz/jni_util.cpp index dd604a8bcfd..547030624b9 100644 --- a/mozilla/java/webclient/src_moz/jni_util.cpp +++ b/mozilla/java/webclient/src_moz/jni_util.cpp @@ -22,6 +22,7 @@ * Mark Lin * Mark Goddard * Ed Burns + * Ashutosh Kulkarni * Ann Sunhachawee */ diff --git a/mozilla/java/webclient/src_moz/jni_util.h b/mozilla/java/webclient/src_moz/jni_util.h index cf2947d2406..6de0c3fa69e 100644 --- a/mozilla/java/webclient/src_moz/jni_util.h +++ b/mozilla/java/webclient/src_moz/jni_util.h @@ -22,6 +22,7 @@ * Mark Lin * Mark Goddard * Ed Burns + * Ashutosh Kulkarni * Ann Sunhachawee */ @@ -38,14 +39,20 @@ #include #include "nsCOMPtr.h" // so we can save the docShell +#include "nsIWebBrowser.h" #include "nsIDocShell.h" // so we can save our nsIDocShell -#include "nsISessionHistory.h" // so we can save our nsISessionHistory +#include "nsIBaseWindow.h" // to get methods like SetVisibility +#include "nsIWebNavigation.h" // for all Navigation commands +#include "nsISHistory.h" // for session history +#include "nsIPresShell.h" #include "nsIThread.h" // for PRThread #include "nsIWebShell.h" // for nsIWebShell #include "nsIEventQueueService.h" // for PLEventQueue #include "nsISearchContext.h" // for Find #include "nsIDOMDocument.h" +#include "wcIBrowserContainer.h" // our BrowserContainer + #include "ns_globals.h" // Ashu @@ -71,7 +78,11 @@ struct WebShellInitContext { #endif nsCOMPtr webShell; nsCOMPtr docShell; - nsISessionHistory* sessionHistory; + nsCOMPtr baseWindow; + nsCOMPtr sHistory; + nsCOMPtr webNavigation; + nsCOMPtr presShell; + nsCOMPtr webBrowser; PLEventQueue * actionQueue; PRThread * embeddedThread; JNIEnv * env; @@ -83,22 +94,24 @@ struct WebShellInitContext { int y; int w; int h; - int gtkWinPtr; - nsCOMPtr searchContext; - nsCOMPtr currentDocument; + int gtkWinPtr; + nsCOMPtr searchContext; + nsCOMPtr currentDocument; jclass propertiesClass; + nsCOMPtr browserContainer; }; enum { kEventQueueError = 1, kCreateWebShellError, + kCreateDocShellError, + kGetBaseWindowError, kInitWebShellError, kShowWebShellError, kHistoryWebShellError, kClipboardWebShellError, kFindComponentError, - kSearchContextError, - kSelectAllError + kSearchContextError }; extern JavaVM *gVm; // defined in jni_util.cpp diff --git a/mozilla/java/webclient/src_moz/nsActions.cpp b/mozilla/java/webclient/src_moz/nsActions.cpp index 8dedfcbeca1..cb12016f80b 100644 --- a/mozilla/java/webclient/src_moz/nsActions.cpp +++ b/mozilla/java/webclient/src_moz/nsActions.cpp @@ -19,6 +19,7 @@ * * Contributor(s): Kirk Baker * Ian Wilkinson + * Ashutosh Kulkarni * Mark Lin * Mark Goddard * Ed Burns @@ -32,6 +33,8 @@ #include "nsCOMPtr.h" #include "nsIContentViewer.h" #include "nsIBaseWindow.h" +#include "nsISHEntry.h" +#include "nsIURI.h" void * handleEvent (PLEvent * event); @@ -73,7 +76,7 @@ nsActionEvent::nsActionEvent () (PLDestroyEventProc) ::destroyEvent); } -wsHistoryActionEvent::wsHistoryActionEvent(nsISessionHistory *yourHistory) +wsHistoryActionEvent::wsHistoryActionEvent(nsISHistory *yourHistory) { mHistory = yourHistory; } @@ -82,9 +85,9 @@ wsHistoryActionEvent::wsHistoryActionEvent(nsISessionHistory *yourHistory) * wsResizeEvent */ -wsResizeEvent::wsResizeEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h) : +wsResizeEvent::wsResizeEvent(nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h) : nsActionEvent(), - mWebShell(webShell), + mBaseWindow(baseWindow), mLeft(x), mBottom(y), mWidth(w), @@ -97,17 +100,9 @@ void * wsResizeEvent::handleEvent () { nsresult rv = NS_ERROR_FAILURE; - if (mWebShell) { - - nsCOMPtr baseWindow; - - rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - return nsnull; - } - rv = baseWindow->SetPositionAndSize(mLeft, mBottom, mWidth, mHeight, + if (mBaseWindow) { + + rv = mBaseWindow->SetPositionAndSize(mLeft, mBottom, mWidth, mHeight, PR_TRUE); @@ -123,9 +118,9 @@ wsResizeEvent::handleEvent () * wsLoadURLEvent */ -wsLoadURLEvent::wsLoadURLEvent(nsIWebShell* webShell, PRUnichar * urlString) : +wsLoadURLEvent::wsLoadURLEvent(nsIWebNavigation* webNavigation, PRUnichar * urlString) : nsActionEvent(), - mWebShell(webShell), + mWebNavigation(webNavigation), mURL(nsnull) { mURL = new nsString(urlString); @@ -135,18 +130,17 @@ wsLoadURLEvent::wsLoadURLEvent(nsIWebShell* webShell, PRUnichar * urlString) : void * wsLoadURLEvent::handleEvent () { - if (mWebShell && mURL) { - - nsresult rv = mWebShell->LoadURL(mURL->GetUnicode()); - } - return nsnull; + if (mWebNavigation && mURL) { + nsresult rv = mWebNavigation->LoadURI(mURL->GetUnicode()); + } + return nsnull; } // handleEvent() wsLoadURLEvent::~wsLoadURLEvent () { - if (mURL != nsnull) - delete mURL; + if (mURL != nsnull) + delete mURL; } @@ -155,9 +149,9 @@ wsLoadURLEvent::~wsLoadURLEvent () * wsStopEvent */ -wsStopEvent::wsStopEvent(nsIWebShell* webShell) : +wsStopEvent::wsStopEvent(nsIWebNavigation* webNavigation) : nsActionEvent(), - mWebShell(webShell) + mWebNavigation(webNavigation) { } @@ -165,8 +159,8 @@ wsStopEvent::wsStopEvent(nsIWebShell* webShell) : void * wsStopEvent::handleEvent () { - if (mWebShell) { - nsresult rv = mWebShell->Stop(); + if (mWebNavigation) { + nsresult rv = mWebNavigation->Stop(); } return nsnull; } // handleEvent() @@ -177,9 +171,10 @@ wsStopEvent::handleEvent () * wsShowEvent */ -wsShowEvent::wsShowEvent(nsIWebShell* webShell) : +wsShowEvent::wsShowEvent(nsIBaseWindow* baseWindow, PRBool state) : nsActionEvent(), - mWebShell(webShell) + mBaseWindow(baseWindow), + mState(state) { } @@ -187,17 +182,8 @@ wsShowEvent::wsShowEvent(nsIWebShell* webShell) : void * wsShowEvent::handleEvent () { - if (mWebShell) { - nsresult rv; - nsCOMPtr baseWindow; - - rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - return nsnull; - } - baseWindow->SetVisibility(PR_TRUE); + if (mBaseWindow) { + mBaseWindow->SetVisibility(mState); } return nsnull; } // handleEvent() @@ -208,9 +194,9 @@ wsShowEvent::handleEvent () * wsHideEvent */ -wsHideEvent::wsHideEvent(nsIWebShell* webShell) : +wsHideEvent::wsHideEvent(nsIBaseWindow* baseWindow) : nsActionEvent(), - mWebShell(webShell) + mBaseWindow(baseWindow) { } @@ -218,17 +204,8 @@ wsHideEvent::wsHideEvent(nsIWebShell* webShell) : void * wsHideEvent::handleEvent () { - if (mWebShell) { - nsresult rv; - nsCOMPtr baseWindow; - - rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - return nsnull; - } - baseWindow->SetVisibility(PR_FALSE); + if (mBaseWindow) { + mBaseWindow->SetVisibility(PR_FALSE); } return nsnull; } // handleEvent() @@ -239,9 +216,9 @@ wsHideEvent::handleEvent () * wsMoveToEvent */ -wsMoveToEvent::wsMoveToEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y) : +wsMoveToEvent::wsMoveToEvent(nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y) : nsActionEvent(), - mWebShell(webShell), + mBaseWindow(baseWindow), mX(x), mY(y) { @@ -251,17 +228,8 @@ wsMoveToEvent::wsMoveToEvent(nsIWebShell* webShell, PRInt32 x, PRInt32 y) : void * wsMoveToEvent::handleEvent () { - if (mWebShell) { - nsresult rv; - nsCOMPtr baseWindow; - - rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - return nsnull; - } - rv = baseWindow->SetPosition(mX, mY); + if (mBaseWindow) { + nsresult rv = mBaseWindow->SetPosition(mX, mY); } return nsnull; } // handleEvent() @@ -271,9 +239,9 @@ wsMoveToEvent::handleEvent () * wsSetFocusEvent */ -wsSetFocusEvent::wsSetFocusEvent(nsIWebShell* webShell) : +wsSetFocusEvent::wsSetFocusEvent(nsIBaseWindow* baseWindow) : nsActionEvent(), - mWebShell(webShell) + mBaseWindow(baseWindow) { } @@ -281,17 +249,8 @@ wsSetFocusEvent::wsSetFocusEvent(nsIWebShell* webShell) : void * wsSetFocusEvent::handleEvent () { - if (mWebShell) { - nsresult rv; - nsCOMPtr baseWindow; - - rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - return nsnull; - } - rv = baseWindow->SetFocus(); + if (mBaseWindow) { + nsresult rv = mBaseWindow->SetFocus(); } return nsnull; } // handleEvent() @@ -302,9 +261,9 @@ wsSetFocusEvent::handleEvent () * wsRemoveFocusEvent */ -wsRemoveFocusEvent::wsRemoveFocusEvent(nsIWebShell* webShell) : +wsRemoveFocusEvent::wsRemoveFocusEvent(nsIBaseWindow* baseWindow) : nsActionEvent(), - mWebShell(webShell) + mBaseWindow(baseWindow) { } @@ -312,8 +271,9 @@ wsRemoveFocusEvent::wsRemoveFocusEvent(nsIWebShell* webShell) : void * wsRemoveFocusEvent::handleEvent () { - if (mWebShell) { - nsresult rv = mWebShell->RemoveFocus(); + if (mBaseWindow) { + //PENDING (Ashu) : No removeFocus functionality provided in M15 + // nsresult rv = mWebShell->RemoveFocus(); } return nsnull; } // handleEvent() @@ -324,9 +284,9 @@ wsRemoveFocusEvent::handleEvent () * wsRepaintEvent */ -wsRepaintEvent::wsRepaintEvent(nsIWebShell* webShell, PRBool forceRepaint) : +wsRepaintEvent::wsRepaintEvent(nsIBaseWindow* baseWindow, PRBool forceRepaint) : nsActionEvent(), - mWebShell(webShell), + mBaseWindow(baseWindow), mForceRepaint(forceRepaint) { } @@ -335,17 +295,8 @@ wsRepaintEvent::wsRepaintEvent(nsIWebShell* webShell, PRBool forceRepaint) : void * wsRepaintEvent::handleEvent () { - if (mWebShell) { - nsresult rv; - nsCOMPtr baseWindow; - - rv = mWebShell->QueryInterface(NS_GET_IID(nsIBaseWindow), - getter_AddRefs(baseWindow)); - - if (NS_FAILED(rv)) { - return nsnull; - } - rv = baseWindow->Repaint(mForceRepaint); + if (mBaseWindow) { + nsresult rv = mBaseWindow->Repaint(mForceRepaint); } return nsnull; } // handleEvent() @@ -356,8 +307,9 @@ wsRepaintEvent::handleEvent () * wsCanBackEvent */ -wsCanBackEvent::wsCanBackEvent(nsISessionHistory* yourSessionHistory) : - wsHistoryActionEvent(yourSessionHistory) +wsCanBackEvent::wsCanBackEvent(nsIWebNavigation* webNavigation) : + nsActionEvent(), + mWebNavigation(webNavigation) { } @@ -366,11 +318,11 @@ void * wsCanBackEvent::handleEvent () { void *result = nsnull; - if (mHistory) { + if (mWebNavigation) { nsresult rv; PRBool canGoBack; - rv = mHistory->CanGoBack(&canGoBack); + rv = mWebNavigation->GetCanGoBack(&canGoBack); if (NS_FAILED(rv)) { return result; @@ -385,9 +337,11 @@ wsCanBackEvent::handleEvent () * wsCanForwardEvent */ -wsCanForwardEvent::wsCanForwardEvent(nsISessionHistory* yourSessionHistory) : - wsHistoryActionEvent(yourSessionHistory) +wsCanForwardEvent::wsCanForwardEvent(nsIWebNavigation* webNavigation) : + nsActionEvent(), + mWebNavigation(webNavigation) { + } @@ -395,11 +349,11 @@ void * wsCanForwardEvent::handleEvent () { void *result = nsnull; - if (mHistory) { + if (mWebNavigation) { nsresult rv; PRBool canGoForward; - rv = mHistory->CanGoForward(&canGoForward); + rv = mWebNavigation->GetCanGoForward(&canGoForward); if (NS_FAILED(rv)) { return result; @@ -417,9 +371,9 @@ wsCanForwardEvent::handleEvent () * wsBackEvent */ -wsBackEvent::wsBackEvent(nsISessionHistory* yourSessionHistory, - nsIWebShell *yourWebShell) : - wsHistoryActionEvent(yourSessionHistory), mWebShell(yourWebShell) +wsBackEvent::wsBackEvent(nsIWebNavigation* webNavigation) : + nsActionEvent(), + mWebNavigation(webNavigation) { } @@ -428,8 +382,8 @@ void * wsBackEvent::handleEvent () { void *result = nsnull; - if (mHistory && mWebShell) { - nsresult rv = mHistory->GoBack(mWebShell); + if (mWebNavigation) { + nsresult rv = mWebNavigation->GoBack(); result = (void *) rv; } @@ -442,10 +396,9 @@ wsBackEvent::handleEvent () * wsForwardEvent */ -wsForwardEvent::wsForwardEvent(nsISessionHistory *yourSessionHistory, - nsIWebShell* webShell) : - wsHistoryActionEvent(yourSessionHistory), - mWebShell(webShell) +wsForwardEvent::wsForwardEvent(nsIWebNavigation* webNavigation) : + nsActionEvent(), + mWebNavigation(webNavigation) { } @@ -454,9 +407,9 @@ void * wsForwardEvent::handleEvent () { void *result = nsnull; - if (mHistory && mWebShell) { + if (mWebNavigation) { - nsresult rv = mHistory->GoForward(mWebShell); + nsresult rv = mWebNavigation->GoForward(); result = (void *) rv; } return result; @@ -468,10 +421,9 @@ wsForwardEvent::handleEvent () * wsGoToEvent */ -wsGoToEvent::wsGoToEvent(nsISessionHistory *yourSessionHistory, - nsIWebShell* webShell, PRInt32 historyIndex) : - wsHistoryActionEvent(yourSessionHistory), - mWebShell(webShell), mHistoryIndex(historyIndex) +wsGoToEvent::wsGoToEvent(nsIWebNavigation* webNavigation, PRInt32 historyIndex) : + nsActionEvent(), + mWebNavigation(webNavigation), mHistoryIndex(historyIndex) { } @@ -480,9 +432,11 @@ void * wsGoToEvent::handleEvent () { void *result = nsnull; - if (mHistory && mWebShell) { - nsresult rv = mHistory->Goto(mHistoryIndex, mWebShell, PR_TRUE); - result = (void *) rv; + nsresult rv = nsnull; + if (mWebNavigation) { + //PENDING (Ashu) : GoTo Functionality seems to be missing in M15 + // nsresult rv = mHistory->Goto(mHistoryIndex, mWebShell, PR_TRUE); + result = (void *) rv; } return result; } // handleEvent() @@ -493,8 +447,9 @@ wsGoToEvent::handleEvent () * wsGetHistoryLengthEvent */ -wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(nsISessionHistory* yourSessionHistory) : - wsHistoryActionEvent(yourSessionHistory) +wsGetHistoryLengthEvent::wsGetHistoryLengthEvent(nsISHistory * sHistory) : + nsActionEvent(), + mHistory(sHistory) { } @@ -506,7 +461,7 @@ wsGetHistoryLengthEvent::handleEvent () if (mHistory) { PRInt32 historyLength = 0; - nsresult rv = mHistory->GetHistoryLength(&historyLength); + nsresult rv = mHistory->GetCount(&historyLength); result = (void *) historyLength; } return result; @@ -518,8 +473,9 @@ wsGetHistoryLengthEvent::handleEvent () * wsGetHistoryIndexEvent */ -wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(nsISessionHistory *yourSessionHistory) : - wsHistoryActionEvent(yourSessionHistory) +wsGetHistoryIndexEvent::wsGetHistoryIndexEvent(nsISHistory * sHistory) : + nsActionEvent(), + mHistory(sHistory) { } @@ -531,7 +487,7 @@ wsGetHistoryIndexEvent::handleEvent () if (mHistory) { PRInt32 historyIndex = 0; - nsresult rv = mHistory->GetCurrentIndex(&historyIndex); + nsresult rv = mHistory->GetIndex(&historyIndex); result = (void *) historyIndex; } return result; @@ -543,8 +499,9 @@ wsGetHistoryIndexEvent::handleEvent () * wsGetURLEvent */ -wsGetURLEvent::wsGetURLEvent(nsISessionHistory* yourSessionHistory) : - wsHistoryActionEvent(yourSessionHistory) +wsGetURLEvent::wsGetURLEvent(nsISHistory * sHistory) : + nsActionEvent(), + mHistory(sHistory) { } @@ -560,18 +517,30 @@ wsGetURLEvent::handleEvent () char *currentURL = nsnull; nsresult rv; - rv = mHistory->GetCurrentIndex(¤tIndex); + rv = mHistory->GetIndex(¤tIndex); if (NS_FAILED(rv)) { return result; } - // THIS STRING NEEDS TO BE deleted!!!!!! - rv = mHistory->GetURLForIndex(currentIndex, ¤tURL); + nsISHEntry * Entry; + rv = mHistory->GetEntryAtIndex(currentIndex, PR_FALSE, &Entry); if (NS_FAILED(rv)) { return result; } + + nsIURI * URI; + rv = Entry->GetURI(&URI); + + if (NS_FAILED(rv)) { + return result; + } + + rv = URI->GetSpec(¤tURL); + if (NS_FAILED(rv)) { + return result; + } result = (void *) currentURL; } @@ -582,10 +551,11 @@ wsGetURLEvent::handleEvent () * wsGetURLForIndexEvent */ -wsGetURLForIndexEvent::wsGetURLForIndexEvent(nsISessionHistory *yourSessionHistory, +wsGetURLForIndexEvent::wsGetURLForIndexEvent(nsISHistory * sHistory, PRInt32 historyIndex) : - wsHistoryActionEvent(yourSessionHistory), - mHistoryIndex(historyIndex) + nsActionEvent(), + mHistory(sHistory), + mHistoryIndex(historyIndex) { } @@ -597,11 +567,25 @@ wsGetURLForIndexEvent::handleEvent () if (mHistory) { nsresult rv; char *indexURL = nsnull; - rv = mHistory->GetURLForIndex(mHistoryIndex, &indexURL); + nsISHEntry * Entry; + rv = mHistory->GetEntryAtIndex(mHistoryIndex, PR_FALSE, &Entry); if (NS_FAILED(rv)) { return result; } + + nsIURI * URI; + rv = Entry->GetURI(&URI); + + if (NS_FAILED(rv)) { + return result; + } + + rv = URI->GetSpec(&indexURL); + if (NS_FAILED(rv)) { + return result; + } + result = (void *) indexURL; } return result; @@ -615,24 +599,51 @@ wsGetURLForIndexEvent::handleEvent () * wsRefreshEvent */ -wsRefreshEvent::wsRefreshEvent(nsIWebShell* webShell, long yourLoadFlags) : +wsRefreshEvent::wsRefreshEvent(nsIWebNavigation* webNavigation, PRInt32 reloadType) : nsActionEvent(), - mWebShell(webShell) + mWebNavigation(webNavigation), + mReloadType(reloadType) { - loadFlags = (nsLoadFlags) yourLoadFlags; + } void * wsRefreshEvent::handleEvent () { - if (mWebShell) { - nsresult rv = mWebShell->Reload(loadFlags); + if (mWebNavigation) { + nsresult rv = mWebNavigation->Reload(mReloadType); return (void *) rv; } return nsnull; } // handleEvent() + + +wsViewSourceEvent::wsViewSourceEvent(nsIDocShell* docShell, PRBool viewMode) : + nsActionEvent(), + mDocShell(docShell), + mViewMode(viewMode) +{ +} + +void * +wsViewSourceEvent::handleEvent () +{ + if(mDocShell) { + if(mViewMode) { + nsresult rv = mDocShell->SetViewMode(nsIDocShell::viewSource); + return (void *) rv; + } + else + { + nsresult rv = mDocShell->SetViewMode(nsIDocShell::viewNormal); + return (void *) rv; + } + } + return nsnull; +} + wsAddDocLoaderObserverEvent::wsAddDocLoaderObserverEvent(nsIDocShell* yourDocShell, nsIDocumentLoaderObserver *yourObserver) : nsActionEvent(), diff --git a/mozilla/java/webclient/src_moz/nsActions.h b/mozilla/java/webclient/src_moz/nsActions.h index 9c1e7b1956f..8243f05cce0 100644 --- a/mozilla/java/webclient/src_moz/nsActions.h +++ b/mozilla/java/webclient/src_moz/nsActions.h @@ -19,6 +19,7 @@ * * Contributor(s): Kirk Baker * Ian Wilkinson + * Ashutosh Kulkarni * Mark Lin * Mark Goddard * Ed Burns @@ -37,12 +38,12 @@ #include "nsIDocShell.h" #include "nsIDocumentLoaderObserver.h" #include "nsIWebShell.h" -#include "nsISessionHistory.h" +#include "nsISHistory.h" +#include "nsIBaseWindow.h" +#include "nsIWebNavigation.h" #include "nsString.h" #include "plevent.h" -#include "DocumentLoaderObserverImpl.h" - /** * Concrete subclasses of nsActionEvent are used to safely convey an @@ -95,20 +96,20 @@ protected: class wsHistoryActionEvent : public nsActionEvent { public: - wsHistoryActionEvent(nsISessionHistory *yourHistory); + wsHistoryActionEvent(nsISHistory *yourHistory); virtual ~wsHistoryActionEvent() {}; protected: - nsISessionHistory *mHistory; + nsISHistory *mHistory; }; class wsResizeEvent : public nsActionEvent { public: - wsResizeEvent (nsIWebShell* webShell, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h); + wsResizeEvent (nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; PRInt32 mLeft; PRInt32 mBottom; PRInt32 mWidth; @@ -118,56 +119,57 @@ protected: class wsLoadURLEvent : public nsActionEvent { public: - wsLoadURLEvent (nsIWebShell* webShell, PRUnichar * urlString); + wsLoadURLEvent (nsIWebNavigation* webNavigation, PRUnichar * urlString); ~wsLoadURLEvent (); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIWebNavigation * mWebNavigation; nsString * mURL; }; class wsStopEvent : public nsActionEvent { public: - wsStopEvent (nsIWebShell* webShell); + wsStopEvent (nsIWebNavigation* webNavigation); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIWebNavigation * mWebNavigation; }; class wsShowEvent : public nsActionEvent { public: - wsShowEvent (nsIWebShell* webShell); + wsShowEvent (nsIBaseWindow* baseWindow, PRBool state); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; + PRBool mState; }; class wsHideEvent : public nsActionEvent { public: - wsHideEvent (nsIWebShell* webShell); + wsHideEvent (nsIBaseWindow* baseWindow); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; }; class wsMoveToEvent : public nsActionEvent { public: - wsMoveToEvent (nsIWebShell* webShell, PRInt32 x, PRInt32 y); + wsMoveToEvent (nsIBaseWindow* baseWindow, PRInt32 x, PRInt32 y); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; PRInt32 mX; PRInt32 mY; }; @@ -176,119 +178,131 @@ protected: class wsSetFocusEvent : public nsActionEvent { public: - wsSetFocusEvent(nsIWebShell* webShell); + wsSetFocusEvent(nsIBaseWindow* baseWindow); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; }; class wsRemoveFocusEvent : public nsActionEvent { public: - wsRemoveFocusEvent(nsIWebShell* webShell); + wsRemoveFocusEvent(nsIBaseWindow* baseWindow); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; }; class wsRepaintEvent : public nsActionEvent { public: - wsRepaintEvent (nsIWebShell* webShell, PRBool forceRepaint); + wsRepaintEvent (nsIBaseWindow* baseWindow, PRBool forceRepaint); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIBaseWindow * mBaseWindow; PRBool mForceRepaint; }; -class wsCanBackEvent : public wsHistoryActionEvent { +//class wsCanBackEvent : public wsHistoryActionEvent { +class wsCanBackEvent : public nsActionEvent { public: - wsCanBackEvent (nsISessionHistory* yourSessionHistory); + wsCanBackEvent (nsIWebNavigation* webNavigation); void * handleEvent (void); +protected: + nsIWebNavigation * mWebNavigation; }; -class wsCanForwardEvent : public wsHistoryActionEvent { +//class wsCanForwardEvent : public wsHistoryActionEvent { +class wsCanForwardEvent : public nsActionEvent { public: - wsCanForwardEvent(nsISessionHistory* yourSessionHistory); + wsCanForwardEvent(nsIWebNavigation* webNavigation); void * handleEvent (void); +protected: + nsIWebNavigation * mWebNavigation; }; -class wsBackEvent : public wsHistoryActionEvent { +class wsBackEvent : public nsActionEvent { public: - wsBackEvent (nsISessionHistory* yourSessionHistory, - nsIWebShell *yourWebShell); + wsBackEvent (nsIWebNavigation* webNavigation); void * handleEvent (void); protected: - nsIWebShell *mWebShell; + nsIWebNavigation * mWebNavigation; }; -class wsForwardEvent : public wsHistoryActionEvent { +class wsForwardEvent : public nsActionEvent { public: - wsForwardEvent (nsISessionHistory* yourSessionHistory, - nsIWebShell *yourWebShell); + wsForwardEvent (nsIWebNavigation* webNavigation); void * handleEvent (void); protected: - nsIWebShell *mWebShell; + nsIWebNavigation * mWebNavigation; }; -class wsGoToEvent : public wsHistoryActionEvent { +class wsGoToEvent : public nsActionEvent { public: - wsGoToEvent (nsISessionHistory *yourSessionHistory, - nsIWebShell* webShell, + wsGoToEvent (nsIWebNavigation* webNavigation, PRInt32 historyIndex); void * handleEvent (void); protected: - nsIWebShell * mWebShell; + nsIWebNavigation * mWebNavigation; PRInt32 mHistoryIndex; }; -class wsGetHistoryLengthEvent : public wsHistoryActionEvent { +class wsGetHistoryLengthEvent : public nsActionEvent { public: - wsGetHistoryLengthEvent(nsISessionHistory* yourSessionHistory); + wsGetHistoryLengthEvent(nsISHistory * sHistory); void * handleEvent (void); + +protected: + nsISHistory * mHistory; }; -class wsGetHistoryIndexEvent : public wsHistoryActionEvent { +class wsGetHistoryIndexEvent : public nsActionEvent { public: - wsGetHistoryIndexEvent (nsISessionHistory *yourSessionHistory); + wsGetHistoryIndexEvent (nsISHistory * sHistory); void * handleEvent (void); +protected: + nsISHistory * mHistory; }; -class wsGetURLEvent : public wsHistoryActionEvent { +class wsGetURLEvent : public nsActionEvent { public: - wsGetURLEvent (nsISessionHistory* yourSessionHistory); + wsGetURLEvent (nsISHistory * sHistory); void * handleEvent (void); +protected: + nsISHistory * mHistory; }; -class wsGetURLForIndexEvent : public wsHistoryActionEvent { + +class wsGetURLForIndexEvent : public nsActionEvent { public: - wsGetURLForIndexEvent(nsISessionHistory *yourSessionHistory, + wsGetURLForIndexEvent(nsISHistory * sHistory, PRInt32 historyIndex); void * handleEvent (void); protected: - PRInt32 mHistoryIndex; + nsISHistory * mHistory; + PRInt32 mHistoryIndex; }; @@ -296,15 +310,26 @@ protected: // added by Mark Goddard OTMP 9/2/1999 class wsRefreshEvent : public nsActionEvent { public: - wsRefreshEvent (nsIWebShell* webShell, - long yourLoadFlags); + wsRefreshEvent (nsIWebNavigation* webNavigation, + PRInt32 reloadType); void * handleEvent (void); protected: - nsIWebShell * mWebShell; - nsLoadFlags loadFlags; + nsIWebNavigation * mWebNavigation; + PRInt32 mReloadType; }; +class wsViewSourceEvent : public nsActionEvent { +public: + wsViewSourceEvent (nsIDocShell * docShell, PRBool viewMode); + void * handleEvent (void); + +protected: + nsIDocShell * mDocShell; + PRBool mViewMode; +}; + + class wsAddDocLoaderObserverEvent : public nsActionEvent { public: wsAddDocLoaderObserverEvent(nsIDocShell *yourDocShell, diff --git a/mozilla/java/webclient/src_moz/ns_globals.h b/mozilla/java/webclient/src_moz/ns_globals.h index b3d4b558b35..6f03d7f0813 100644 --- a/mozilla/java/webclient/src_moz/ns_globals.h +++ b/mozilla/java/webclient/src_moz/ns_globals.h @@ -18,6 +18,7 @@ * Rights Reserved. * * Contributor(s): Ed Burns + * Ashutosh Kulkarni * */ @@ -28,6 +29,10 @@ */ +#include "nsIWebShell.h" // for nsIWebShell +#include "nsIEventQueueService.h" // for PLEventQueue + + #ifndef ns_globals_h #define ns_globals_h @@ -46,7 +51,8 @@ extern PRLogModuleInfo *prLogModuleInfo; // defined in WrapperFactory.cpp */ class nsIComponentManager; -extern nsIComponentManager *gComponentManager; // defined in WrapperFactoryImpl.cpp +extern nsIComponentManager *gComponentManager; // defined in NativeEventThread.cpp +extern const char * gBinDir; // defined in WrapperFactoryImpl.cpp /** @@ -58,9 +64,14 @@ extern nsIComponentManager *gComponentManager; // defined in WrapperFactoryImpl. */ -class nsISessionHistory; -extern nsISessionHistory *gHistory; // defined in NativeEventThread.cpp +class nsISHistory; +extern nsISHistory *gHistory; // defined in NativeEventThread.cpp +class nsIEventQueueService; +extern PLEventQueue * gActionQueue; // defined in NativeEventThread.cpp + +class nsIThread; +extern PRThread * gEmbeddedThread; // defined in NativeEventThread.cpp #endif // ns_globals_h diff --git a/mozilla/java/webclient/src_moz/wcIBrowserContainer.h b/mozilla/java/webclient/src_moz/wcIBrowserContainer.h new file mode 100644 index 00000000000..03f65e8bacd --- /dev/null +++ b/mozilla/java/webclient/src_moz/wcIBrowserContainer.h @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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 Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * + * Contributor(s): + */ + +#ifndef WCI_BROWSERCONTAINER +#define WCI_BROWSERCONTAINER + +#include "nsISupports.h" + +#include "jni.h" + +#define WC_IBROWSERCONTAINER_IID_STR "fdadb2e0-3028-11d4-8a96-0080c7b9c5ba" +#define WC_IBROWSERCONTAINER_IID {0xfdadb2e0, 0x3028, 0x11d4, { 0x8a, 0x96, 0x00, 0x80, 0xc7, 0xb9, 0xc5, 0xba }} + +/** + + * This interface defines methods that webclient mozilla must use to + * support listeners. + + */ + +class wcIBrowserContainer : public nsISupports { +public: + + NS_DEFINE_STATIC_IID_ACCESSOR(WC_IBROWSERCONTAINER_IID) + + + NS_IMETHOD AddMouseListener(jobject target) = 0; + NS_IMETHOD AddDocumentLoadListener(jobject target) = 0; + NS_IMETHOD RemoveAllListeners() = 0; + +}; + +#define NS_DECL_WCIBROWSERCONTAINER \ + NS_IMETHOD AddMouseListener(jobject target); \ + NS_IMETHOD AddDocumentLoadListener(jobject target); \ + NS_IMETHOD RemoveAllListeners(); + + +#endif