Bug 534644 - e10s: implement Qt ipc/chromium backend, part 2. r=benjamin.
authorOleg Romashin <romaxa@gmail.com>
Fri, 29 Jan 2010 08:50:44 +0200
changeset 37621 b7912eea7f1f24fd29b10d55397f6b630837e2a6
parent 37620 9d22aba6e080d6204bb21f36d607e4384e8416f7
child 37622 772391c92a9d3e96c73a43b4a04d899cde414f53
push id11403
push userromaxa@gmail.com
push dateFri, 29 Jan 2010 06:51:19 +0000
treeherdermozilla-central@b7912eea7f1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs534644
milestone1.9.3a1pre
Bug 534644 - e10s: implement Qt ipc/chromium backend, part 2. r=benjamin.
dom/base/Makefile.in
dom/plugins/PluginInstanceChild.cpp
dom/plugins/PluginModuleChild.cpp
ipc/chromium/chromium-config.mk
toolkit/xre/nsEmbedFunctions.cpp
widget/src/qt/nsAppShell.cpp
--- a/dom/base/Makefile.in
+++ b/dom/base/Makefile.in
@@ -107,13 +107,11 @@ include $(topsrcdir)/dom/dom-config.mk
 
 ifdef MOZ_JSDEBUGGER
 DEFINES += -DMOZ_JSDEBUGGER
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_X11
-ifdef MOZ_ENABLE_GTK2
 CXXFLAGS += $(TK_CFLAGS)
 LDFLAGS += $(TK_LIBS)
 endif
-endif
--- a/dom/plugins/PluginInstanceChild.cpp
+++ b/dom/plugins/PluginInstanceChild.cpp
@@ -471,24 +471,26 @@ PluginInstanceChild::AnswerNPP_SetWindow
     mWindow.type = aWindow.type;
 
     mWsInfo.colormap = aWindow.colormap;
     if (!XVisualIDToInfo(mWsInfo.display, aWindow.visualID,
                          &mWsInfo.visual, &mWsInfo.depth))
         return false;
 
     if (aWindow.type == NPWindowTypeWindow) {
+#ifdef MOZ_WIDGET_GTK2
         if (GdkWindow* socket_window = gdk_window_lookup(aWindow.window)) {
             // A GdkWindow for the socket already exists.  Need to
             // workaround https://bugzilla.gnome.org/show_bug.cgi?id=607061
             // See wrap_gtk_plug_embedded in PluginModuleChild.cpp.
             g_object_set_data(G_OBJECT(socket_window),
                               "moz-existed-before-set-window",
                               GUINT_TO_POINTER(1));
         }
+#endif
     }
 
     *rv = mPluginIface->setwindow(&mData, &mWindow);
 
 #elif defined(OS_WIN)
     switch (aWindow.type) {
       case NPWindowTypeWindow:
       {
--- a/dom/plugins/PluginModuleChild.cpp
+++ b/dom/plugins/PluginModuleChild.cpp
@@ -172,17 +172,17 @@ PluginModuleChild::Init(const std::strin
 #else
 
 #  error Please copy the initialization code from nsNPAPIPlugin.cpp
 
 #endif
     return true;
 }
 
-#if defined(OS_LINUX)
+#if defined(MOZ_WIDGET_GTK2)
 typedef void (*GObjectDisposeFn)(GObject*);
 typedef void (*GtkPlugEmbeddedFn)(GtkPlug*);
 
 static GObjectDisposeFn real_gtk_plug_dispose;
 static GtkPlugEmbeddedFn real_gtk_plug_embedded;
 
 static void
 undo_bogus_unref(gpointer data, GObject* object, gboolean is_last_ref) {
@@ -248,16 +248,17 @@ PluginModuleChild::InitGraphics()
     NS_ABORT_IF_FALSE(*dispose != wrap_gtk_plug_dispose,
                       "InitGraphics called twice");
     real_gtk_plug_dispose = *dispose;
     *dispose = wrap_gtk_plug_dispose;
 
     GtkPlugEmbeddedFn* embedded = &GTK_PLUG_CLASS(gtk_plug_class)->embedded;
     real_gtk_plug_embedded = *embedded;
     *embedded = wrap_gtk_plug_embedded;
+#elif defined(MOZ_WIDGET_QT)
 #else
     // may not be necessary on all platforms
 #endif
 
     return true;
 }
 
 bool
--- a/ipc/chromium/chromium-config.mk
+++ b/ipc/chromium/chromium-config.mk
@@ -101,16 +101,15 @@ OS_POSIX = 1
 DEFINES += \
   -DOS_LINUX=1 \
   -DOS_POSIX=1 \
   $(NULL)
 
 # NB: to stop gcc warnings about exporting template instantiation
 OS_CXXFLAGS := $(filter-out -pedantic,$(OS_CXXFLAGS))
 
-# TODO support !GTK
-OS_CXXFLAGS += $(MOZ_GTK2_CFLAGS)
-OS_CFLAGS += $(MOZ_GTK2_CFLAGS)
+OS_CXXFLAGS += $(TK_CFLAGS)
+OS_CFLAGS += $(TK_CFLAGS)
 
 endif # }
 endif # }
 
 endif # }
\ No newline at end of file
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -276,16 +276,19 @@ XRE_InitChildProcess(int aArgc,
                      GeckoProcessType aProcess)
 {
   NS_ENSURE_ARG_MIN(aArgc, 2);
   NS_ENSURE_ARG_POINTER(aArgv);
   NS_ENSURE_ARG_POINTER(aArgv[0]);
 
   sChildProcessType = aProcess;
 
+  gArgv = aArgv;
+  gArgc = aArgc;
+
   SetupErrorHandling(aArgv[0]);
   
 #if defined(MOZ_WIDGET_GTK2)
   g_thread_init(NULL);
 #endif
 
   if (PR_GetEnv("MOZ_DEBUG_CHILD_PROCESS")) {
 #ifdef OS_POSIX
--- a/widget/src/qt/nsAppShell.cpp
+++ b/widget/src/qt/nsAppShell.cpp
@@ -46,27 +46,39 @@
 
 #include "prenv.h"
 
 #ifdef MOZ_LOGGING
 #define FORCE_PR_LOG
 #include "prlog.h"
 #endif
 
+#ifdef MOZ_IPC
+#include <QApplication>
+static QApplication *sQApp = nsnull;
+extern int    gArgc;
+extern char **gArgv;
+#endif
+
 #ifdef PR_LOGGING
 PRLogModuleInfo *gWidgetLog = nsnull;
 PRLogModuleInfo *gWidgetFocusLog = nsnull;
 PRLogModuleInfo *gWidgetIMLog = nsnull;
 PRLogModuleInfo *gWidgetDrawLog = nsnull;
 #endif
 
 static int sPokeEvent;
 
 nsAppShell::~nsAppShell()
 {
+#ifdef MOZ_IPC
+    if (sQApp)
+        delete sQApp;
+    sQApp = nsnull;
+#endif
 }
 
 nsresult
 nsAppShell::Init()
 {
 #ifdef PR_LOGGING
     if (!gWidgetLog)
         gWidgetLog = PR_NewLogModule("Widget");
@@ -77,42 +89,47 @@ nsAppShell::Init()
     if (!gWidgetDrawLog)
         gWidgetDrawLog = PR_NewLogModule("WidgetDraw");
 #endif
 #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
     sPokeEvent = QEvent::registerEventType();
 #else
     sPokeEvent = QEvent::User+5000;
 #endif
+
+#ifdef MOZ_IPC
+    if (!qApp) {
+      sQApp = new QApplication(gArgc, (char**)gArgv);
+    }
+#endif
+
     return nsBaseAppShell::Init();
 }
 
 void
 nsAppShell::ScheduleNativeEventCallback()
 {
     QCoreApplication::postEvent(this,
                                 new QEvent((QEvent::Type) sPokeEvent));
 }
 
 
 PRBool
 nsAppShell::ProcessNextNativeEvent(PRBool mayWait)
 {
-   QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents;
-     
-     if (mayWait)
-         flags |= QEventLoop::WaitForMoreEvents;
-     
-     
-     QAbstractEventDispatcher *dispatcher =  QAbstractEventDispatcher::instance(qApp->thread());
-     if (!dispatcher)
-         return PR_FALSE ;
-     
-     return dispatcher->processEvents(flags)?PR_TRUE:PR_FALSE;
+    QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents;
+
+    if (mayWait)
+        flags |= QEventLoop::WaitForMoreEvents;
 
+    QAbstractEventDispatcher *dispatcher =  QAbstractEventDispatcher::instance(qApp->thread());
+    if (!dispatcher)
+        return PR_FALSE;
+
+    return dispatcher->processEvents(flags) ? PR_TRUE : PR_FALSE;
 }
 
 bool
 nsAppShell::event (QEvent *e)
 {
     if (e->type() == sPokeEvent) {
         NativeEventCallback();
         return true;