changeset 352:a3c5f744d03f

Update Browser/Mozilla package to SWT 3.4.1 and bug fixes
author John Reimer <terminal.node@gmail.com>
date Tue, 04 Nov 2008 21:20:45 -0800
parents f1bb3949939b
children 7f3013c93a95
files dwt/browser/Download.d dwt/browser/Download_1_8.d dwt/browser/HelperAppLauncherDialog.d dwt/browser/HelperAppLauncherDialogFactory.d dwt/browser/Mozilla.d
diffstat 5 files changed, 137 insertions(+), 125 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/browser/Download.d	Mon Nov 03 23:35:30 2008 +0100
+++ b/dwt/browser/Download.d	Tue Nov 04 21:20:45 2008 -0800
@@ -20,9 +20,8 @@
 
 import dwt.browser.Mozilla;
 
-//import dwt.internal.Compatibility;
 import XPCOM = dwt.internal.mozilla.XPCOM;
-//import dwt.internal.mozilla.XPCOMObject;
+
 import dwt.internal.mozilla.prtime;
 import dwt.internal.mozilla.Common;
 import dwt.internal.mozilla.nsID;
@@ -125,15 +124,15 @@
     * these interfaces the second argument implements and act accordingly.  
     */
     String filename = null;
-    //nsISupports supports = new nsISupports (aTarget);
-    nsIURI target = null;
-    rc = aTarget.QueryInterface (&nsIURI.IID, cast(void**)&target);
+    nsISupports supports = cast(nsISupports)aTarget;
+    nsIURI target;
+    rc = supports.QueryInterface (&nsIURI.IID, cast(void**)&target);
     if (rc is 0) {  /* >= 1.7 */
         //result[0] = 0;
         //int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
         scope auto aPath = new nsEmbedCString;
         rc = target.GetPath (cast(nsACString*)aPath);
-        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
         //length = XPCOM.nsEmbedCString_Length (aPath);
         //buffer = XPCOM.nsEmbedCString_get (aPath);
         //dest = new byte[length];
@@ -144,22 +143,16 @@
         filename = filename.substring (separator + 1);
         target.Release ();
     } else {    /* < 1.7 */
-        // Earlier versions (<1.7) of Mozilla are not really supported
-        // in the D port (yet) because we depend on bindings where the interface
-        // is directly mapped, not wrapped as in the Java SWT case
-        implMissing(__FILE__,__LINE__);
-    /*
-        //nsILocalFile target = new nsILocalFile (aTarget);
+        nsILocalFile target2 = cast(nsILocalFile) aTarget;
         scope auto aNativeTarget = new nsEmbedCString;
-        rc = aTarget.GetNativeLeafName (cast(nsACString*)aNativeTarget);
-        if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+        rc = target2.GetNativeLeafName (cast(nsACString*)aNativeTarget);
+        if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
         //length = XPCOM.nsEmbedCString_Length (aNativeTarget);
         //buffer = XPCOM.nsEmbedCString_get (aNativeTarget);
         //dest = new byte[length];
         //XPCOM.memmove (dest, buffer, length);
         //XPCOM.nsEmbedCString_delete (aNativeTarget);
         filename = aNativeTarget.toString;
-    */
     }
 
     Listener listener = new class() Listener  {
--- a/dwt/browser/Download_1_8.d	Mon Nov 03 23:35:30 2008 +0100
+++ b/dwt/browser/Download_1_8.d	Tue Nov 04 21:20:45 2008 -0800
@@ -118,7 +118,7 @@
     // nsIURI source = new nsIURI (aSource);
     scope auto aSpec = new nsEmbedCString;
     int rc = aSource.GetHost (cast(nsACString*)aSpec);
-    if (rc !is XPCOM.NS_OK) Mozilla.error(rc);
+    if (rc !is XPCOM.NS_OK) Mozilla.error(rc,__FILE__,__LINE__);
     //int length = XPCOM.nsEmbedCString_Length (aSpec);
     //int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
     //byte[] dest = new byte[length];
@@ -148,7 +148,7 @@
             }
             if (cancelable !is null) {
                 int rc = cancelable.Cancel (XPCOM.NS_BINDING_ABORTED);
-                if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
+                if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
             }
             shell = null;
             cancelable = null;
--- a/dwt/browser/HelperAppLauncherDialog.d	Mon Nov 03 23:35:30 2008 +0100
+++ b/dwt/browser/HelperAppLauncherDialog.d	Tue Nov 04 21:20:45 2008 -0800
@@ -26,7 +26,6 @@
 import dwt.internal.mozilla.nsIHelperAppLauncher;
 import dwt.internal.mozilla.nsIHelperAppLauncherDialog;
 import dwt.internal.mozilla.nsIHelperAppLauncher_1_8;
-import dwt.internal.mozilla.nsIHelperAppLauncher_1_9;
 import dwt.internal.mozilla.nsISupports;
 import dwt.internal.mozilla.nsILocalFile;
 import dwt.internal.mozilla.nsStringAPI;
@@ -36,6 +35,13 @@
 import dwt.widgets.FileDialog;
 import dwt.widgets.Shell;
 
+/**
+ * This class implements the HelperAppLauncherDialog interface for mozilla
+ * versions 1.4 - 1.8.x.  For mozilla versions >= 1.9 this interface is
+ * implemented by class HelperAppLauncherDialog_1_9.  HelperAppLauncherDialogFactory
+ * determines at runtime which of these classes to instantiate. 
+ */
+
 class HelperAppLauncherDialog : nsIHelperAppLauncherDialog {
     int refCount = 0;
 
@@ -77,7 +83,7 @@
     * cancels the File Dialog, cancels or closes the Download Dialog
     * and when the Download Dialog goes away after the download is completed.
     */
-    //if (refCount is 0) disposeCOMInterfaces ();
+    if (refCount is 0) return 0;
     return refCount;
 }
 
@@ -85,33 +91,24 @@
 
 extern(System)
 nsresult Show(nsIHelperAppLauncher aLauncher, nsISupports aContext, PRUint32 aReason) {
-    /*
-    * The interface for nsIHelperAppLauncher changed in GRE versions 1.8 and 1.9.  Query for
-    * each of these interfaces in turn until one is found.
-    */
-    // FIXME: Not sure if this will work because of different versions of 
-    // nsIHelperAppLauncher.  Remember to check. -JJR
-    nsIHelperAppLauncher_1_9 helperAppLauncher1;
-    int rc = aLauncher.QueryInterface (&nsIHelperAppLauncher_1_9.IID, cast(void**)&helperAppLauncher1);
+     /*
+     * The interface for nsIHelperAppLauncher changed as of mozilla 1.8.  Query the received
+     * nsIHelperAppLauncher for the new interface, and if it is not found then fall back to
+     * the old interface. 
+     */
+
+    nsISupports supports = cast(nsISupports)aLauncher;
+    nsIHelperAppLauncher_1_8 helperAppLauncher;
+    nsresult rc = supports.QueryInterface (&nsIHelperAppLauncher_1_8.IID, cast(void**)&helperAppLauncher);
     if (rc is 0) {
-       // nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher);
-        rc = helperAppLauncher1.SaveToDisk (null, 0);
-        helperAppLauncher1.Release ();
+        rc = helperAppLauncher.SaveToDisk (null, 0);
+        helperAppLauncher.Release ();
         return rc;
     }
 
-    //result[0] = 0;
-    nsIHelperAppLauncher_1_8 helperAppLauncher2;
-    rc = aLauncher.QueryInterface (&nsIHelperAppLauncher_1_8.IID, cast(void**)&helperAppLauncher2);
-    if (rc is 0) {
-        //nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8 (aLauncher);
-        rc = helperAppLauncher2.SaveToDisk (null, 0);
-        helperAppLauncher2.Release ();
-        return rc;
-    }
-
-    //nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher (aLauncher);  /* < 1.8 */
+    /* < 1.8 */
     return aLauncher.SaveToDisk (null, 0);
+    // no Release for this? -JJR
 }
 
 extern(System)
@@ -131,47 +128,29 @@
      * The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first
      * argument must be queried for both the old and new nsIHelperAppLauncher interfaces. 
      */
-    bool using_1_8 = false, using_1_9 = false;
-    // technically this should have an AddRef? -JJR
-    //nsISupports support = cast(nsISupports)arg0; 
-    //int /*long*/[] result = new int /*long*/[1];
+    bool using_1_8 = false;
+    nsISupports support = cast(nsISupports)aLauncher; 
+    
     if (aLauncher is null)
         assert(0);
-        
-    // TODO: D Bindings are locked to the XPCOM interface version provided in
-    // dwt/internal/mozilla package; therefore the following version checks 
-    // are redundant for now. In this case, 1.8 and 1.9
-    // will be bypassed.  To get 1.8 and 1.9 working for D, we will 
-    // have to customize this section a bit or simply remove the references
-    // until the default aligns with these versions in later swt updates. 
-    // For now this should work as is.
 
     nsIHelperAppLauncher_1_8 helperAppLauncher1;
-
-    int rc = aLauncher.QueryInterface (&nsIHelperAppLauncher_1_8.IID, cast(void**)&helperAppLauncher1);
-    if (rc is 0) {
+    int rc = support.QueryInterface (&nsIHelperAppLauncher_1_8.IID, cast(void**)&helperAppLauncher1);
+    if (rc is XPCOM.NS_OK) {
         using_1_8 = true;
         hasLauncher = true;
         helperAppLauncher1.Release ();
     } else {
-        nsIHelperAppLauncher_1_9 helperAppLauncher2;
-        rc = aLauncher.QueryInterface (&nsIHelperAppLauncher_1_9.IID, cast(void**)&helperAppLauncher2);
-        if (rc is 0) {
-            using_1_9 = true;
+        nsIHelperAppLauncher helperAppLauncher;
+        rc = support.QueryInterface (&nsIHelperAppLauncher.IID, cast(void**)&helperAppLauncher);
+        if (rc is XPCOM.NS_OK) {
             hasLauncher = true;
-            helperAppLauncher2.Release;
-        } else {
-            nsIHelperAppLauncher helperAppLauncher;
-            rc = aLauncher.QueryInterface (&nsIHelperAppLauncher.IID, cast(void**)&helperAppLauncher);
-            if (rc is 0) {
-                hasLauncher = true;
-                helperAppLauncher.Release;
-            }
+            helperAppLauncher.Release;
         }
     }
 
 /+
-    // In D port, Mozilla version is determined by the bindings used
+    // In D port, no suppport for version >1.4 yet
     if (hasLauncher) {  /* >= 1.5 */
         aDefaultFile = arg2;
         aSuggestedFileExtension = arg3;
@@ -203,15 +182,12 @@
     shell.close ();
     if (name is null) {
         if (hasLauncher) {
-            // not sure if these produce correct interface alignment. Check. -JJR
-            if (using_1_8 || using_1_9) {
-                //rc = aLauncher.Cancel (XPCOM.NS_BINDING_ABORTED);
-                implMissing(__FILE__,__LINE__);
+            if (using_1_8) {
+                rc = (cast(nsIHelperAppLauncher_1_8)aLauncher).Cancel (XPCOM.NS_BINDING_ABORTED);
             } else {
-                //nsIHelperAppLauncher launcher = new nsIHelperAppLauncher (arg0);
                 rc = aLauncher.Cancel ();
             }
-            if (rc !is XPCOM.NS_OK) Mozilla.error (rc); 
+            if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__); 
             return XPCOM.NS_OK;
         }
         return XPCOM.NS_ERROR_FAILURE;
@@ -220,8 +196,8 @@
     nsILocalFile localFile;
     rc = XPCOM.NS_NewLocalFile (cast(nsAString*)path, 1, &localFile);
     //path.dispose ();
-    if (rc !is XPCOM.NS_OK) Mozilla.error (rc);
-    if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+    if (rc !is XPCOM.NS_OK) Mozilla.error (rc,__FILE__,__LINE__);
+    if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER,__FILE__,__LINE__);
     /* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */
     *_retval = localFile; 
     //XPCOM.memmove (_retval, result, C.PTR_SIZEOF);  
--- a/dwt/browser/HelperAppLauncherDialogFactory.d	Mon Nov 03 23:35:30 2008 +0100
+++ b/dwt/browser/HelperAppLauncherDialogFactory.d	Tue Nov 04 21:20:45 2008 -0800
@@ -14,23 +14,22 @@
 
 import dwt.dwthelper.utils;
 
-//import dwt.internal.C;
 import XPCOM = dwt.internal.mozilla.XPCOM;
-//import dwt.internal.mozilla.XPCOMObject;
+
 import dwt.internal.mozilla.Common;
 import dwt.internal.mozilla.nsID;
 import dwt.internal.mozilla.nsIFactory;
 import dwt.internal.mozilla.nsISupports;
 
 import dwt.browser.HelperAppLauncherDialog;
+import dwt.browser.HelperAppLauncherDialog_1_9;
 
 class HelperAppLauncherDialogFactory : nsIFactory {
-    //XPCOMObject supports;
-    //XPCOMObject factory;
     int refCount = 0;
+    bool isPre_1_9 = true;
+
 
 this () {
-//    createCOMInterfaces ();
 }
 
 extern(System)
@@ -42,8 +41,6 @@
 extern(System)
 nsresult QueryInterface (nsID* riid, void** ppvObject) {
     if (riid is null || ppvObject is null) return XPCOM.NS_ERROR_NO_INTERFACE;
-    //nsID guid = new nsID ();
-    //XPCOM.memmove (guid, riid, nsID.sizeof);
     
     if (*riid == nsISupports.IID) {
         *ppvObject = cast(void*)cast(nsISupports)this;
@@ -63,7 +60,7 @@
 extern(System)
 nsrefcnt Release () {
     refCount--;
-    //if (refCount is 0) disposeCOMInterfaces ();
+    if (refCount is 0) return 0;
     return refCount;
 }
 
@@ -71,15 +68,26 @@
 
 extern(System)
 nsresult CreateInstance (nsISupports aOuter, nsID* iid, void** result) { 
-     if (result is null) 
-        return XPCOM.NS_ERROR_INVALID_ARG;
-    auto helperAppLauncherDialog = new HelperAppLauncherDialog;
-    nsresult rv = helperAppLauncherDialog.QueryInterface( iid, result );
-    if (XPCOM.NS_FAILED(rv)) {
-        *result = null;
-        delete helperAppLauncherDialog;
+    if (isPre_1_9) {
+        if (result is null) 
+            return XPCOM.NS_ERROR_INVALID_ARG;
+        auto helperAppLauncherDialog = new HelperAppLauncherDialog;
+        nsresult rv = helperAppLauncherDialog.QueryInterface( iid, result );
+        if (XPCOM.NS_FAILED(rv)) {
+            *result = null;
+            delete helperAppLauncherDialog;
+        } else {
+            if (result is null) 
+                return XPCOM.NS_ERROR_INVALID_ARG;
+            auto helperAppLauncherDialog19 = new HelperAppLauncherDialog_1_9;
+            rv = helperAppLauncherDialog19.QueryInterface( iid, result );
+            if (XPCOM.NS_FAILED(rv)) {
+                *result = null;
+                delete helperAppLauncherDialog19;
+            }
+            return rv;
+        }
     }
-    return rv;
 }
 
 extern(System)
--- a/dwt/browser/Mozilla.d	Mon Nov 03 23:35:30 2008 +0100
+++ b/dwt/browser/Mozilla.d	Tue Nov 04 21:20:45 2008 -0800
@@ -352,11 +352,37 @@
                     // byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
                     rc = XPCOMInit.XPCOMGlueStartup (mozillaPath.ptr);
                     if (rc !is XPCOM.NS_OK) {
-                        IsXULRunner = false;    /* failed */
-                        //mozillaPath = mozillaPath[0 .. locatePrior( mozillaPath, SEPARATOR_OS )];
                         mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
                         if (Device.DEBUG) Cerr ("cannot use detected XULRunner: ") (mozillaPath).newline; //$NON-NLS-1$
-                    } else {
+                        
+                        /* attempt to XPCOMGlueStartup the GRE pointed at by MOZILLA_FIVE_HOME */
+                        auto ptr = Environment.get(XPCOM.MOZILLA_FIVE_HOME);
+                        if (ptr is null) {
+                            IsXULRunner = false;
+                        } else {
+                            //length = C.strlen (ptr);
+                            //byte[] buffer = new byte[length];
+                            //C.memmove (buffer, ptr, length);
+                            mozillaPath = ptr;
+                            /*
+                             * Attempting to XPCOMGlueStartup a mozilla-based GRE !is xulrunner can
+                             * crash, so don't attempt unless the GRE appears to be xulrunner.
+                             */
+                            if (mozillaPath.indexOf("xulrunner") is -1) { //$NON-NLS-1$
+                                IsXULRunner = false;    
+
+                            } else {
+                                mozillaPath ~= SEPARATOR_OS ~ mozDelegate.getLibraryName ();
+                                rc = XPCOMInit.XPCOMGlueStartup (toStringz(mozillaPath));
+                                if (rc !is XPCOM.NS_OK) {
+                                    IsXULRunner = false;
+                                    mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+                                    if (Device.DEBUG) Cerr ("failed to start as XULRunner: " )(mozillaPath).newline; //$NON-NLS-1$
+                                }
+                            }
+                        } 
+                    }
+                    if (IsXULRunner) {
                         XPCOMInitWasGlued = true;
                     }
                 }
@@ -994,18 +1020,6 @@
             error (rc, __FILE__, __LINE__);
         }
         factory.Release ();
-        
-        HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
-        dialogFactory.AddRef ();
-        //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
-        aClassName = "Helper App Launcher Dialog";
-        //aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$
-        rc = componentRegistrar.RegisterFactory (&XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName.ptr, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID.ptr, cast(nsIFactory)dialogFactory);
-        if (rc !is XPCOM.NS_OK) {
-            browser.dispose ();
-            error (rc, __FILE__, __LINE__);
-        }
-        dialogFactory.Release ();
 
         /*
         * This Download factory will be used if the GRE version is < 1.8.
@@ -1109,7 +1123,17 @@
 
                 if (XPCOMWasGlued) {
                     // TODO: is there a difference between two startup methhods? Glue functions are same.
-                    XPCOMInit.XPCOMGlueShutdown ();
+                   /*
+                    * XULRunner 1.9 can crash on Windows if XPCOMGlueShutdown is invoked here,
+                    * presumably because one or more of its unloaded symbols are referenced when
+                    * this callback returns.  The workaround is to delay invoking XPCOMGlueShutdown
+                    * so that its symbols are still available once this callback returns.
+                    */
+                    display.asyncExec (new class() Runnable {
+                        public void run () {
+                            XPCOMInit.XPCOMGlueShutdown ();
+                        }
+                    });
                     XPCOMWasGlued = false;
                 }
                 if (XPCOMInitWasGlued) {
@@ -1195,6 +1219,28 @@
 
     if (!PerformedVersionCheck) {
         PerformedVersionCheck = true;
+        
+        nsIComponentRegistrar componentRegistrar;
+        rc = componentManager.QueryInterface (&nsIComponentRegistrar.IID, cast(void**)&componentRegistrar);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc, __FILE__,__LINE__);
+        }
+        if (componentRegistrar is null) {
+            browser.dispose ();
+            error (XPCOM.NS_NOINTERFACE,__FILE__,__LINE__);
+        }
+
+        HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
+        dialogFactory.AddRef ();
+        //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
+        String aClassName = "Helper App Launcher Dialog"; //$NON-NLS-1$
+        rc = componentRegistrar.RegisterFactory (&XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName.ptr, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID.ptr, cast(nsIFactory)dialogFactory);
+        if (rc !is XPCOM.NS_OK) {
+            browser.dispose ();
+            error (rc,__FILE__,__LINE__);
+        }
+        dialogFactory.Release ();
 
         /*
         * Check for the availability of the pre-1.8 implementation of nsIDocShell
@@ -1235,31 +1281,18 @@
             rc = interfaceRequestor.GetInterface (&nsIDocShell_1_8.IID, cast(void**)&docShell_1_8);
             if (rc is XPCOM.NS_OK && docShell_1_8 !is null) { /* 1.8 */
                 docShell_1_8.Release ();
-                //result[0] = 0;
-                nsIComponentRegistrar componentRegistrar;
-                rc = componentManager.QueryInterface (&nsIComponentRegistrar.IID, cast(void**)&componentRegistrar);
-                if (rc !is XPCOM.NS_OK) {
-                    browser.dispose ();
-                    error (rc, __FILE__, __LINE__);
-                }
-                if (componentRegistrar is null) {
-                    browser.dispose ();
-                    error (XPCOM.NS_NOINTERFACE, __FILE__, __LINE__);
-                }
-
-                // nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
+ 
                 DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 ();
                 downloadFactory_1_8.AddRef ();
                 // byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
                 
-                String aClassName = "Transfer"; //$NON-NLS-1$
+                aClassName = "Transfer"; //$NON-NLS-1$
                 rc = componentRegistrar.RegisterFactory (&XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_TRANSFER_CONTRACTID.ptr, cast(nsIFactory)downloadFactory_1_8);
                 if (rc !is XPCOM.NS_OK) {
                     browser.dispose ();
                     error (rc, __FILE__, __LINE__);
                 }
                 downloadFactory_1_8.Release ();
-                componentRegistrar.Release ();
                 } else { /* >= 1.9 */
                 /*
                  * Bug in XULRunner 1.9.  Mozilla no longer clears its background before initial content has
@@ -1285,10 +1318,12 @@
                 //ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0);
                 rc = webNavigation.LoadURI (ABOUT_BLANK.toString16().toString16z(), nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
                 webNavigation.Release ();
+                dialogFactory.isPre_1_9 = false;
             }
         }
         //result[0] = 0;
         interfaceRequestor.Release ();
+        componentRegistrar.Release ();
     }
     componentManager.Release ();
 
@@ -2835,7 +2870,7 @@
             //byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID, true);
             nsIWebNavigationInfo info;
             rc = serviceManager.GetServiceByContractID (XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID.ptr, &nsIWebNavigationInfo.IID, cast(void**)&info);
-            if (rc is 0) {
+            if (rc is XPCOM.NS_OK) {
                 //byte[] bytes = MozillaDelegate.wcsToMbcs (null, contentType, true);
                 scope auto typePtr = new nsEmbedCString(contentType);
                 //nsIWebNavigationInfo info = new nsIWebNavigationInfo (result[0]);