gecko-dev/java/webclient/src_moz/NativeWrapperFactory.cpp

249 строки
6.9 KiB
C++
Исходник Обычный вид История

The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
/* -*- 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 <kbaker@eb.com>
* Ian Wilkinson <iw@ennoble.com>
* Mark Lin <mark.lin@eng.sun.com>
* Mark Goddard
* Ed Burns <edburns@acm.org>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Ann Sunhachawee
*/
#include "nsIEventQueueService.h" // for PLEventQueue
#include "nsIServiceManager.h" // for do_GetService
#include "nsEmbedAPI.h" // for NS_HandleEmbeddingEvent
#include "NativeWrapperFactory.h"
#include "ns_util.h"
#if defined(XP_UNIX) && !defined(XP_MACOSX)
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
#include <unistd.h>
#include "gdksuperwin.h"
#include "gtkmozarea.h"
extern "C" {
static int wc_x_error (Display *display,
XErrorEvent *error);
}
#endif
PLEventQueue *NativeWrapperFactory::sActionQueue = nsnull;
PRThread *NativeWrapperFactory::sEmbeddedThread = nsnull;
PRBool NativeWrapperFactory::sInitComplete = PR_FALSE;
NativeWrapperFactory::NativeWrapperFactory(void)
{
mEnv = nsnull;
mNativeEventThread = nsnull;
}
NativeWrapperFactory::~NativeWrapperFactory()
{
sProfile = nsnull;
sProfileInternal = nsnull;
sPrefs = nsnull;
sAppShell = nsnull;
}
nsresult
NativeWrapperFactory::Init(JNIEnv * env, jobject newNativeEventThread)
{
mFailureCode = NS_ERROR_FAILURE;
if (nsnull == sEmbeddedThread) {
//
// Do java communication initialization
//
mEnv = env;
// store the java NativeEventThread class
mNativeEventThread = ::util_NewGlobalRef(env,
newNativeEventThread);
//
// create the singleton event queue
//
// create the static sActionQueue
nsCOMPtr<nsIEventQueueService>
aEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);
if (!aEventQService) {
mFailureCode = NS_ERROR_FAILURE;
return mFailureCode;
}
// Create the event queue.
mFailureCode = aEventQService->CreateThreadEventQueue();
sEmbeddedThread = PR_GetCurrentThread();
if (!sEmbeddedThread) {
mFailureCode = NS_ERROR_FAILURE;
return mFailureCode;
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("NativeBrowserControl_Init: Create UI Thread EventQueue: %d\n",
mFailureCode));
// We need to do something different for Unix
nsIEventQueue * EQueue = nsnull;
mFailureCode = aEventQService->GetThreadEventQueue(sEmbeddedThread, &EQueue);
if (NS_FAILED(mFailureCode)) {
return mFailureCode;
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("NativeBrowserControl_Init: Get UI Thread EventQueue: %d\n",
mFailureCode));
#ifdef XP_UNIX
/************
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
gdk_input_add(EQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
EQueue);
************/
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
#endif
PLEventQueue * plEventQueue = nsnull;
EQueue->GetPLEventQueue(&plEventQueue);
sActionQueue = plEventQueue;
if (!sActionQueue) {
mFailureCode = NS_ERROR_FAILURE;
return mFailureCode;
}
PR_LOG(prLogModuleInfo, PR_LOG_DEBUG,
("NativeBrowserControl_Init: get ActionQueue: %d\n",
mFailureCode));
#if defined(XP_UNIX) && !defined(XP_MACOSX)
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
// The gdk_x_error function exits in some cases, we don't
// want that.
XSetErrorHandler(wc_x_error);
#endif
sInitComplete = PR_TRUE;
}
mFailureCode = NS_OK;
}
void
NativeWrapperFactory::Destroy(void)
{
if (nsnull != mNativeEventThread) {
::util_DeleteGlobalRef(mEnv, mNativeEventThread);
}
// PENDING(edburns): take over the stuff from
// WindowControlActionEvents
// wsDeallocateInitContextEvent::handleEvent()
// This flag might have been set from
// EmbedWindow::DestroyBrowserWindow() as well if someone used a
// window.close() or something or some other script action to close
// the window. No harm setting it again.
}
PRUint32
NativeWrapperFactory::ProcessEventLoop(void)
{
if (PR_GetCurrentThread() != sEmbeddedThread) {
return 0;
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
while(gtk_events_pending()) {
gtk_main_iteration();
}
#elif !defined(XP_MACOSX)
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
MSG msg;
PRBool wasHandled;
if (::PeekMessage(&msg, nsnull, 0, 0, PM_NOREMOVE)) {
if (::GetMessage(&msg, nsnull, 0, 0)) {
wasHandled = PR_FALSE;
::NS_HandleEmbeddingEvent(msg, wasHandled);
if (!wasHandled) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
}
#endif
::PR_Sleep(PR_INTERVAL_NO_WAIT);
if (sInitComplete && sActionQueue) {
PLEvent * event = nsnull;
PL_ENTER_EVENT_QUEUE_MONITOR(sActionQueue);
if (::PL_EventAvailable(sActionQueue)) {
event = ::PL_GetEvent(sActionQueue);
}
PL_EXIT_EVENT_QUEUE_MONITOR(sActionQueue);
if (event != nsnull) {
::PL_HandleEvent(event);
}
}
// PENDING(edburns): revisit this. Not sure why this is necessary, but
// this fixes bug 44327
// printf("%c", 8); // 8 is ASCII for backspace
return 1;
}
nsresult
NativeWrapperFactory::GetFailureCode(void)
{
return mFailureCode;
}
/* static */
PRBool
NativeWrapperFactory::IsInitialized(void)
{
return sInitComplete;
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
The churn continues. After this checkin, BrowserControlFactoryTest runs, but nothing else does. As you all probably already know, all mozilla API calls have to happen on the same thread. For webclient, this will be the NativeEventThread. This change-bundle does many many things, here are the main ones. These changes are in concert with the checkin I just did to the diagram at <http://www.mozilla.org/projects/blackwood/webclient/design/20040306-webclient-2_0.zargo>. M classes_spec/org/mozilla/webclient/impl/WrapperFactory.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java * <p>This class is the hub of the startup and shutdown sequence for * Webclient. It is a singleton and owns references to other app * singletons:</p> * * <ul> * <li><p>{@link NativeEventThread}</p></li> * * <li><p>{@link Bookmarks}</p></li> * * <li><p>{@link Preferences}</p></li> * * <li><p>{@link ProfileManager}</p></li> * <li><p>the native object singleton corresponding to this java * object (if necessary)</p></li> * * </ul> * * <p>It maintains a set of {@link BrowserControlImpl} instances so that * we may return the native pointer for each one.</p> * * <p>This class is responsible for creating and initializing and * deleting {@link BrowserControlImpl} instances, as well as ensuring * that the native counterpart is proprely maintained in kind.</p> * * <p>This class has a tight contract with {@link * NativeEventThread}.</p> - make BrowserControl creation and deletion part of this classes responsibilities. - introduce NativeWrapperFactory concept. - own the one and only NativeEventThread. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java - make this a singleton. - remove dependencies on BrowserControl and nativeBrowserControl * <p>This is a singleton class. All native events pass thru this class * by virtue of the {@link #pushRunnable} or {@link pushNotifyRunnable} * methods.</p> - remove listener logic. This'll go into EventRegistration, where it belongs. A src_moz/NativeWrapperFactory.cpp A src_moz/NativeWrapperFactory.h - takes the place of the old WebclientContext - is now a class M classes_spec/org/mozilla/webclient/impl/BrowserControlImpl.java - this no longer destroys the nativeBrowserControl. That is now done by WrapperFactoryImpl. M classes_spec/org/mozilla/webclient/impl/WebclientFactoryImpl.java - no longer maintain browserControlCount. M classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java M classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java - rename NativeContext to NativeWrapperFactory, to illustrate its singletonness. M classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - comment out a bunch of stuff in anticipation of the new threading model, currently being fleshed out. M classes_spec/org/mozilla/webclient/impl/wrapper_native/ImplObjectNative.java - NativeEventThread is singleton M src_moz/BookmarksImpl.cpp M src_moz/PreferencesImpl.cpp M src_moz/ProfileManagerImpl.cpp M src_moz/RDFEnumeration.cpp M src_moz/RDFTreeNode.cpp - rename WebclientContext to NativeWrapperFactory. M src_moz/EmbedWindow.cpp - mBaseWindow->Destroy(); + if (mBaseWindow) { + mBaseWindow->Destroy(); + } M src_moz/Makefile.in - Bring back NavigationImpl - add NativeWrapperFactory. M src_moz/NativeBrowserControl.cpp M src_moz/NativeBrowserControl.h - move event queue and java related stuff to NativeWrapperFactory. This class is now essentially a copy of EmbedPrivate in GtkEmbed. M src_moz/NativeEventThread.cpp - remove methods, most of it has moved to WrapperFactoryImpl/NativeWrapperFactory. M src_moz/NavigationImpl.cpp - comment out all methods but LoadURI. M src_moz/WrapperFactoryImpl.cpp - take functionality over from NativeEventThread. M src_moz/ns_util.cpp M src_moz/ns_util.h - the eventQueue is owned by NativeWrapperFactory now. M src_moz/rdf_util.cpp M src_share/jni_util.cpp - make all exceptions RuntimeExceptions, so they can be thrown from a Runnable. M test/automated/src/classes/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImplTest.java - comment out the meat of this test until I figure out how to test it. M test/automated/src/test/BrowserControlFactoryTest_correct - new content.
2004-04-16 02:58:08 +04:00
static int
wc_x_error (Display *display,
XErrorEvent *error)
{
if (error->error_code)
{
char buf[64];
XGetErrorText (display, error->error_code, buf, 63);
fprintf (stderr, "Webclient-Gdk-ERROR **: %s\n serial %ld error_code %d request_code %d minor_code %d\n",
buf,
error->serial,
error->error_code,
error->request_code,
error->minor_code);
}
return 0;
}
#endif