Enabling Gecko in MSHTML

Jacek Caban jack at itma.pwr.wroc.pl
Mon Apr 18 15:47:25 CDT 2005


Ivan Leo Puoti wrote:

> Jacek Caban wrote:
>
>> Hi.
>>
>> Now MSHTML is ready for a patch that enables HTML rendering over
>> Gecko API.
>
> Any chance this will work with the native unix gecko?

Yes, I believe. Unfortunatelly I've not succeeded in this as my knowlage
about
X and gtk programing is poor. So I need some help on it. A patch that makes
nonwindow-like stuff to enable UNIX Gecko is attached. To make it
complete, 'just' one error in view.c has to be fixed.

As it's the development version, path to Mozilla dir is hardcoded -
it'll be simple
to fix, but first I'd like to see it working. To make changes more
clear, this patch
depends on my last patch I've sent yesterday. Parts of code that depend on
version of Gecko used are ifdef-ed by UNIX_GECKO.

Any help/suggestions very welcomed.

>
> Ivan
>
Jacek
-------------- next part --------------
--- dlls/mshtml-old/nsiface.idl	2005-04-18 20:41:21.000000000 +0200
+++ dlls/mshtml/nsiface.idl	2005-04-18 22:46:28.000000000 +0200
@@ -25,6 +25,13 @@
 
 import "wtypes.idl";
 
+cpp_quote("#define UNIX_GECKO");
+
+cpp_quote("#ifdef UNIX_GECKO");
+cpp_quote("#undef STDMETHODCALLTYPE");
+cpp_quote("#define STDMETHODCALLTYPE");
+cpp_quote("#endif");
+
 typedef HRESULT nsresult;
 typedef ULONG nsrefcnt;
 
--- dlls/mshtml-old/nsembd.c	2005-04-18 20:41:21.000000000 +0200
+++ dlls/mshtml/nsembd.c	2005-04-18 20:31:37.000000000 +0200
@@ -17,6 +17,7 @@
  */
 
 #include "config.h"
+#include "wine/port.h"
 
 #include <stdarg.h>
 #include <stdio.h>
@@ -34,6 +35,7 @@
 
 #include "wine/debug.h"
 #include "wine/unicode.h"
+#include "wine/library.h"
 
 #include "initguid.h"
 #include "mshtml_private.h"
@@ -50,6 +52,13 @@ DEFINE_GUID(CLSID_nsWebBrowser, 0xf1eac7
 
 #define PR_UINT32_MAX 0xffffffff
 
+#ifdef UNIX_GECKO
+
+#undef WINAPI
+#define WINAPI
+
+#else
+
 static const WCHAR mozilla_key_path[] =
     {'S','o','f','t','w','a','r','e','\\',
      'm','o','z','i','l','l','a','.','o','r','g','\\',
@@ -57,6 +66,8 @@ static const WCHAR mozilla_key_path[] =
 
 static const WCHAR wszGreHome[] = {'G','r','e','H','o','m','e',0};
 
+#endif
+
 typedef struct {
     void *d1;
     PRUint32 d2;
@@ -73,13 +84,30 @@ static nsresult (*NS_StringContainerFini
 static nsresult (*NS_StringSetData)(nsString*,const PRUnichar*,PRUint32);
 static nsresult (*NS_NewLocalFile)(const nsString*,PRBool,nsIFile**);
 
-static HINSTANCE xpcom_handle = 0;
 static PRUnichar mozilla_path[MAX_PATH];
 
 static nsIServiceManager *pServMgr = NULL;
 static nsIComponentManager *pCompMgr = NULL;
 
-static BOOL get_path() {
+#ifdef UNIX_GECKO
+
+static void *xpcom_handle = NULL;
+
+static BOOL get_path()
+{
+#warning Mozilla path is hardcoded
+    PRUnichar unix_mozilla_path[] = {'/','o','p','t','/','m','o','z','i','l','l','a',0};
+
+    memcpy(mozilla_path, unix_mozilla_path, sizeof(unix_mozilla_path));
+    return TRUE;
+}
+
+#else
+
+static HINSTANCE xpcom_handle = 0;
+
+static BOOL get_path()
+{
     DWORD res, type, i;
     HKEY mozilla_key, hkey;
     WCHAR key_name[100];
@@ -103,6 +131,8 @@ static BOOL get_path() {
     return ret;
 }
 
+#endif
+
 void close_gecko()
 {
     if(pCompMgr)
@@ -111,8 +141,13 @@ void close_gecko()
     if(pServMgr)
         NS_ShutdownXPCOM(pServMgr);
 
+#ifdef UNIX_GECKO
+    if(xpcom_handle)
+        wine_dlclose(xpcom_handle, NULL, 0);
+#else
     if(xpcom_handle)
         FreeLibrary(xpcom_handle);
+#endif
 }
 
 static void try_load_gecko()
@@ -138,6 +173,22 @@ static void try_load_gecko()
     
     TRACE("found path %s\n", debugstr_w(mozilla_path));
 
+#ifdef UNIX_GECKO
+
+    xpcom_handle = wine_dlopen("libxpcom.so", RTLD_NOW|RTLD_GLOBAL, NULL, 0);
+    if(!xpcom_handle) {
+        ERR("Could not load XPCOM\n");
+        close_gecko();
+        return;
+    }
+
+#define NS_DLSYM(func) \
+            func = (typeof(func))wine_dlsym(xpcom_handle, #func, NULL, 0); \
+            if(!func) \
+                ERR("Could not load " #func "\n");
+
+#else
+
     xpcom_handle = LoadLibraryW(strXPCOM);
     if(!xpcom_handle) {
         /* FIXME:
@@ -166,6 +217,8 @@ static void try_load_gecko()
     if(!func) \
         ERR("Could not GetProcAddress(" #func ") failed\n");
 
+#endif
+
     NS_DLSYM(NS_InitXPCOM2)
     NS_DLSYM(NS_ShutdownXPCOM)
     NS_DLSYM(NS_StringContainerInit)
@@ -247,8 +300,6 @@ static nsIWebBrowser* ns_create_webbrows
         return NULL;
     }
 
-    TRACE("ending\n");
-
     return ret;
 }
 
--- dlls/mshtml-old/view.c	2005-04-18 20:41:21.000000000 +0200
+++ dlls/mshtml/view.c	2005-04-18 22:46:06.000000000 +0200
@@ -121,6 +121,22 @@ static void activate_container(HTMLDocum
     nsIWebBrowserSetup *wbsetup;
     nsresult nsres;
 
+#ifdef UNIX_GECKO
+
+#error Here we have to create a native UNIX window from This->hwnd.
+#error There are two possible ways:
+#error 1. Create a GtkWindow or GdkWindow
+#error 2. Get XID and patch Gecko to accept it (do 1. but in Gecko code)
+#error    This way should be better as Wine doesn't have to know anything about gtk/gdk
+
+    nativeWindow native_window = NULL;
+
+#else
+
+    nativeWindow native_window = This->hwnd;
+
+#endif
+
     if(!This->nscontainer)
         return;
 
@@ -148,7 +164,7 @@ static void activate_container(HTMLDocum
         nsres = nsIWebBrowser_QueryInterface(This->nscontainer->webbrowser,
                 &IID_nsIBaseWindow, (void**)&This->nscontainer->window);
         if(NS_SUCCEEDED(nsres)) {
-            nsres = nsIBaseWindow_InitWindow(This->nscontainer->window, This->hwnd, NULL,
+            nsres = nsIBaseWindow_InitWindow(This->nscontainer->window, native_window, NULL,
                     0, 0, rect->right, rect->bottom);
             if(nsres == NS_OK) {
                 nsres = nsIBaseWindow_Create(This->nscontainer->window);


More information about the wine-devel mailing list