gecko-dev/java/webclient/src_moz/CBrowserContainer.h

182 lines
4.8 KiB
C
Raw Normal View History

/* -*- 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 <ashuk@eng.sun.com>
* Ed Burns <edburns@acm.org>
*
*/
#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 "nsIWebProgress.h"
#include "nsIWebShell.h" // We still have to implement nsIWebShellContainer
// in order to receveive some DocumentLoaderObserver
// events. edburns
#include "nsIURIContentListener.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIInterfaceRequestor.h"
#include "nsIPrompt.h"
#include "nsIAuthPrompt.h"
#include "nsCWebBrowser.h"
// replace nsString::Recycle with nsMemory::Free java/dom/jni/org_mozilla_dom_events_MouseEventImpl.cpp java/dom/jni/org_mozilla_dom_events_UIEventImpl.cpp java/dom/jni/org_mozilla_dom_events_EventImpl.cpp java/dom/jni/org_mozilla_dom_ProcessingInstructionImpl.cpp java/dom/jni/org_mozilla_dom_NodeImpl.cpp java/dom/jni/org_mozilla_dom_NamedNodeMapImpl.cpp java/dom/jni/org_mozilla_dom_ElementImpl.cpp java/dom/jni/org_mozilla_dom_DOMImplementationImpl.cpp java/dom/jni/org_mozilla_dom_DocumentImpl.cpp java/dom/jni/org_mozilla_dom_CharacterDataImpl.cpp java/dom/jni/org_mozilla_dom_AttrImpl.cpp java/dom/jni/javaDOMEventsGlobals.cpp // On*DocumentLoad() now takes an nsIRequest instead of an nsIChannel. // nsIChannel extends nsIRequest. java/dom/src/nsJavaDOMImpl.cpp java/dom/src/nsJavaDOMImpl.h java/dom/src/nsIJavaDOM.h // nsIChannel instances replaced with nsIRequest. Removed ShowModal(), // ExitModalLoop(), FindNamedBrowserItem(). Parameter changes for // {Set,Get}Persistence(). Add DestroyBrowserWindow(), IsWindowModal(). // supports weak references java/webclient/src_moz/CBrowserContainer.h java/webclient/src_moz/CBrowserContainer.cpp // GetProfileList now returns an array of profile names. Need to use // nsIProfileInternal instead of nsIProfile for StartupWithArgs. java/webclient/src_moz/NativeEventThread.cpp // Remove -lxpfelocation_s java/webclient/src_moz/Makefile.in // Don't include appfilelocprovider_s java/webclient/src_moz/Makefile.win // Don't assert thread safe, cause we are thread safe java/webclient/src_moz/InputStreamShim.cpp
2001-04-02 22:48:33 +00:00
#include "nsWeakReference.h"
#include "wcIBrowserContainer.h"
bug=47357 a=edburns r=ashuk This change creates a new directory, java/webclient/src_share, that contains the code that will be used in both src_moz and src_ie, and any other native browser wrapping implementations. Here are the steps I followed to implement this change. 1. Create a new directory java/webclient/src_share 2. Move all jni_util*.* files from src_moz into src_share 3. Make it so src_share compiles into a new .lib src_share has no netscape dependencies. Any functionality that depended on ns dependencies was kept in src_moz. In this case, we have a function prototype only in src_share, with the implementation in src_moz. We did this for nsHashtable. The other trick was for things in WebShellInitContext that had nothing to do with Netscape. This case was accomodated by creating a new struct, ShareInitContext, that contains all WebShellInitContext members that have nothing to do with Netscape. Currently this is just jobject propertiesClass. I modified the WebShellInitContext struct to contain a ShareContext struct as its last member. There are two new methods in jni_util.h that allow for the initialization and deallocation of the members of the ShareContext struct. 4. Make it so src_moz uses the new .lib to provide the jni_util behavior a. Create ns_util* files that include ../src_share/jni_util* files appropriately. The only tricky part was for things in jni_util.h that Here's the list of files in this change. cvs -z3 -n update (in directory D:\Projects\mozilla\java\webclient) cvs server: Updating . M Makefile.win // added src_share to DIRS M src_moz/BookmarksImpl.cpp // include ns_util instead of jni_util M src_moz/CBrowserContainer.cpp // include ns_util instead of jni_util M src_moz/CBrowserContainer.h // include ns_util instead of jni_util M src_moz/CurrentPageImpl.cpp // include ns_util instead of jni_util M src_moz/HistoryImpl.cpp // include ns_util instead of jni_util M src_moz/Makefile.win // include ns_util instead of jni_util M src_moz/NativeEventThread.cpp // include ns_util instead of jni_util M src_moz/NavigationImpl.cpp // include ns_util instead of jni_util M src_moz/RDFEnumeration.cpp // include ns_util instead of jni_util M src_moz/RDFTreeNode.cpp // include ns_util instead of jni_util M src_moz/WindowControlImpl.cpp // include ns_util instead of jni_util // also use new util_InitShareContext // function M src_moz/WrapperFactoryImpl.cpp // include ns_util instead of jni_util R src_moz/jni_util.cpp // moved to ../src_share R src_moz/jni_util.h // moved to ../src_share R src_moz/jni_util_export.cpp // moved to ../src_share R src_moz/jni_util_export.h // moved to ../src_share M src_moz/nsActions.cpp // include ns_util instead of jni_util // also use new util_DeallocateShareContext M src_moz/nsActions.h // include ns_util instead of jni_util A src_moz/ns_util.cpp // include jni_util.h A src_moz/ns_util.h // include jni_util.h, changes to // WebshellInitContext struct A src_moz/ns_util_export.cpp // provide impls for methods in // jni_util_export.h A src_share/Makefile.win A src_share/bal_util.cpp A src_share/bal_util.h A src_share/jni_util.cpp A src_share/jni_util.h A src_share/jni_util_export.cpp A src_share/jni_util_export.h *****CVS exited normally with code 0*****
2000-08-03 21:32:54 +00:00
#include "ns_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 nsIURIContentListener,
public nsIDocShellTreeOwner,
public nsIInterfaceRequestor,
public nsIPrompt,
public nsIAuthPrompt,
public nsIDOMMouseListener,
// replace nsString::Recycle with nsMemory::Free java/dom/jni/org_mozilla_dom_events_MouseEventImpl.cpp java/dom/jni/org_mozilla_dom_events_UIEventImpl.cpp java/dom/jni/org_mozilla_dom_events_EventImpl.cpp java/dom/jni/org_mozilla_dom_ProcessingInstructionImpl.cpp java/dom/jni/org_mozilla_dom_NodeImpl.cpp java/dom/jni/org_mozilla_dom_NamedNodeMapImpl.cpp java/dom/jni/org_mozilla_dom_ElementImpl.cpp java/dom/jni/org_mozilla_dom_DOMImplementationImpl.cpp java/dom/jni/org_mozilla_dom_DocumentImpl.cpp java/dom/jni/org_mozilla_dom_CharacterDataImpl.cpp java/dom/jni/org_mozilla_dom_AttrImpl.cpp java/dom/jni/javaDOMEventsGlobals.cpp // On*DocumentLoad() now takes an nsIRequest instead of an nsIChannel. // nsIChannel extends nsIRequest. java/dom/src/nsJavaDOMImpl.cpp java/dom/src/nsJavaDOMImpl.h java/dom/src/nsIJavaDOM.h // nsIChannel instances replaced with nsIRequest. Removed ShowModal(), // ExitModalLoop(), FindNamedBrowserItem(). Parameter changes for // {Set,Get}Persistence(). Add DestroyBrowserWindow(), IsWindowModal(). // supports weak references java/webclient/src_moz/CBrowserContainer.h java/webclient/src_moz/CBrowserContainer.cpp // GetProfileList now returns an array of profile names. Need to use // nsIProfileInternal instead of nsIProfile for StartupWithArgs. java/webclient/src_moz/NativeEventThread.cpp // Remove -lxpfelocation_s java/webclient/src_moz/Makefile.in // Don't include appfilelocprovider_s java/webclient/src_moz/Makefile.win // Don't assert thread safe, cause we are thread safe java/webclient/src_moz/InputStreamShim.cpp
2001-04-02 22:48:33 +00:00
public wcIBrowserContainer,
public nsSupportsWeakReference
{
public:
public:
- rename initContext to NativeBrowserControl, at both the native and java layers. - Rework NativeEventThread to be usable without having the browserControl window realized. - change who owns the NativEventThread to be the BrowserControl, by proxy through WrapperFactoryImpl. Again, this is with a view toward using webclient without the browserControl window realized. A webclient/src_moz/NativeBrowserControl.h A webclient/src_moz/NativeBrowserControl.cpp - Centerpiece of native Object hierarchy. Owned by NativeEventThread. M webclient/build-tests.xml - reformat - add new test, currently failing, for Navigation. M webclient/classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - destroy our nativeBrowserControl. M webclient/classes_spec/org/mozilla/webclient/impl/WrapperFactory.java - Added API for obtaining the NativeEventThread for a BrowserControl. M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java - rename nativeWebShell to nativeBrowserControl M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - rename nativeWebShell to nativeBrowserControl - add method to get the NativeEventThread for this instance. M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - remove dependency on WindowControl - make this class be the owner of the nativeBrowserControl instance. - rename nativeWebShell to nativeBrowserControl - renamed nativeInitialize to nativeStartup - added nativeShutdown M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java - remove delete() method. - no longer owns NativeEventThread - no longer owns nativeBrowserControl M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java - Take over NativeEventThread ownership responsibilities from WindowControlImpl (by proxy for BrowserControl). M webclient/src_moz/CBrowserContainer.cpp M webclient/src_moz/CBrowserContainer.h M webclient/src_moz/CurrentPageActionEvents.cpp M webclient/src_moz/CurrentPageActionEvents.h M webclient/src_moz/CurrentPageImpl.cpp M webclient/src_moz/HistoryActionEvents.cpp M webclient/src_moz/HistoryActionEvents.h M webclient/src_moz/HistoryImpl.cpp M webclient/src_moz/NativeEventThreadActionEvents.cpp M webclient/src_moz/NativeEventThreadActionEvents.h M webclient/src_moz/NavigationActionEvents.cpp M webclient/src_moz/NavigationActionEvents.h M webclient/src_moz/NavigationImpl.cpp M webclient/src_moz/PromptActionEvents.cpp M webclient/src_moz/PromptActionEvents.h M webclient/src_moz/WindowControlActionEvents.cpp M webclient/src_moz/WindowControlActionEvents.h M webclient/src_moz/WindowCreator.cpp M webclient/src_moz/WindowCreator.h - rename nativeWebShell to nativeBrowserControl M webclient/src_moz/Makefile.in - comment out not yet fixed per-window sources - add NativeBrowserControl.cpp M webclient/src_moz/NativeEventThread.cpp - major refactoring. Much of the work is now being done in NativeBrowserControl.cpp M webclient/src_moz/WindowControlImpl.cpp - remove functionality now located in NativeEventThread and NativeBrowserControl. M webclient/src_moz/WrapperFactoryImpl.cpp - flesh out native{Create,Destroy}BrowserControl. M webclient/src_moz/ns_globals.h - remove gActionQueue and gEmbeddedThread. Moved into class NativeBrowserControl. M webclient/src_moz/ns_util.cpp - rename initContext to NativeBrowserControl - get action queue from NativeBrowserControl M webclient/src_moz/ns_util.h - remove WebShellInitContext! It's finally a class now, called NativeBrowserControl. M webclient/test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - added new testcase to show create/deleteBrowserControl works.
2004-04-10 21:50:39 +00:00
CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *yourJNIEnv, NativeBrowserControl *yourInitContext);
CBrowserContainer();
public:
virtual ~CBrowserContainer();
// Protected members
protected:
nsIWebBrowser *m_pOwner;
JNIEnv *mJNIEnv;
- rename initContext to NativeBrowserControl, at both the native and java layers. - Rework NativeEventThread to be usable without having the browserControl window realized. - change who owns the NativEventThread to be the BrowserControl, by proxy through WrapperFactoryImpl. Again, this is with a view toward using webclient without the browserControl window realized. A webclient/src_moz/NativeBrowserControl.h A webclient/src_moz/NativeBrowserControl.cpp - Centerpiece of native Object hierarchy. Owned by NativeEventThread. M webclient/build-tests.xml - reformat - add new test, currently failing, for Navigation. M webclient/classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - destroy our nativeBrowserControl. M webclient/classes_spec/org/mozilla/webclient/impl/WrapperFactory.java - Added API for obtaining the NativeEventThread for a BrowserControl. M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java - rename nativeWebShell to nativeBrowserControl M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - rename nativeWebShell to nativeBrowserControl - add method to get the NativeEventThread for this instance. M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - remove dependency on WindowControl - make this class be the owner of the nativeBrowserControl instance. - rename nativeWebShell to nativeBrowserControl - renamed nativeInitialize to nativeStartup - added nativeShutdown M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java - remove delete() method. - no longer owns NativeEventThread - no longer owns nativeBrowserControl M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java - Take over NativeEventThread ownership responsibilities from WindowControlImpl (by proxy for BrowserControl). M webclient/src_moz/CBrowserContainer.cpp M webclient/src_moz/CBrowserContainer.h M webclient/src_moz/CurrentPageActionEvents.cpp M webclient/src_moz/CurrentPageActionEvents.h M webclient/src_moz/CurrentPageImpl.cpp M webclient/src_moz/HistoryActionEvents.cpp M webclient/src_moz/HistoryActionEvents.h M webclient/src_moz/HistoryImpl.cpp M webclient/src_moz/NativeEventThreadActionEvents.cpp M webclient/src_moz/NativeEventThreadActionEvents.h M webclient/src_moz/NavigationActionEvents.cpp M webclient/src_moz/NavigationActionEvents.h M webclient/src_moz/NavigationImpl.cpp M webclient/src_moz/PromptActionEvents.cpp M webclient/src_moz/PromptActionEvents.h M webclient/src_moz/WindowControlActionEvents.cpp M webclient/src_moz/WindowControlActionEvents.h M webclient/src_moz/WindowCreator.cpp M webclient/src_moz/WindowCreator.h - rename nativeWebShell to nativeBrowserControl M webclient/src_moz/Makefile.in - comment out not yet fixed per-window sources - add NativeBrowserControl.cpp M webclient/src_moz/NativeEventThread.cpp - major refactoring. Much of the work is now being done in NativeBrowserControl.cpp M webclient/src_moz/WindowControlImpl.cpp - remove functionality now located in NativeEventThread and NativeBrowserControl. M webclient/src_moz/WrapperFactoryImpl.cpp - flesh out native{Create,Destroy}BrowserControl. M webclient/src_moz/ns_globals.h - remove gActionQueue and gEmbeddedThread. Moved into class NativeBrowserControl. M webclient/src_moz/ns_util.cpp - rename initContext to NativeBrowserControl - get action queue from NativeBrowserControl M webclient/src_moz/ns_util.h - remove WebShellInitContext! It's finally a class now, called NativeBrowserControl. M webclient/test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - added new testcase to show create/deleteBrowserControl works.
2004-04-10 21:50:39 +00:00
NativeBrowserControl *mInitContext;
jobject mDocTarget;
jobject mMouseTarget;
jobject mPrompt;
nsCOMPtr<nsIDOMEventTarget> mDomEventTarget;
PRInt32 mBlurSuppressionLevel;
static PRInt32 mInstanceCount;
//
// The following arguments are used in the takeActionOnNode method.
//
/**
* 0 is the leaf depth. That's why we call it the inverse depth.
*/
PRInt32 inverseDepth;
/**
* The properties table, created during a mouseEvent handler
*/
jobject properties;
/**
* the nsIDOMEvent in the current event
*/
nsCOMPtr<nsIDOMEvent> currentDOMEvent;
//
// End of ivars used in takeActionOnNode
//
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIBASEWINDOW
NS_DECL_NSIWEBBROWSERCHROME
NS_DECL_NSIDOCSHELLTREEOWNER
NS_DECL_NSIURICONTENTLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_WCIBROWSERCONTAINER
// "Services" accessed through nsIInterfaceRequestor
NS_DECL_NSIPROMPT
NS_DECL_NSIAUTHPROMPT
// nsIDOMMouseListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
NS_IMETHOD 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);
/**
* Called from our nsIWebProgressListener.OnStateChanged()
*/
nsresult JNICALL doStartDocumentLoad(const PRUnichar *documentName);
nsresult JNICALL doEndDocumentLoad(nsIWebProgress *aWebProgress);
nsresult JNICALL doStartURLLoad(const PRUnichar *documentName);
nsresult JNICALL doEndURLLoad(const PRUnichar *documentName);
static nsresult JNICALL takeActionOnNode(nsCOMPtr<nsIDOMNode> curNode,
void *yourObject);
};
#endif