# HG changeset patch # User John Reimer # Date 1224562433 25200 # Node ID 7d6e1394b8492895735a4f4e150f8827eef7de5a # Parent a4b331f7579076e04e9d3e3e73537d3f8d6f1836 Mozilla update diff -r a4b331f75790 -r 7d6e1394b849 dwt/browser/Mozilla.d --- a/dwt/browser/Mozilla.d Sun Oct 19 21:41:55 2008 -0700 +++ b/dwt/browser/Mozilla.d Mon Oct 20 21:13:53 2008 -0700 @@ -654,8 +654,8 @@ //length = STARTUP.length (); //char[] chars = new char [length + 1]; //STARTUP.getChars (0, length, chars, 0); - wchar[] chars = Utf.toString16(STARTUP) ~ "\0"; - rc = observerService.NotifyObservers (null, PROFILE_DO_CHANGE.ptr, chars.ptr); + wchar[] chars = Utf.toString16(STARTUP).toString16z; + rc = observerService.NotifyObservers (null, PROFILE_DO_CHANGE.ptr, chars); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); @@ -798,7 +798,7 @@ //localizedString = new nsIPrefLocalizedString (result[0]); //result[0] = 0; } - localizedString.SetDataWithLength (newLocales.length, newLocales.toString16); + localizedString.SetDataWithLength (newLocales.length, Utf.toString16(newLocales).toString16z); rc = prefBranch.SetComplexValue (PREFERENCES_LANGUAGES.ptr, nsIPrefLocalizedString.IID, cast(nsISupports)localizedString); } if (localizedString !is null) { @@ -862,7 +862,7 @@ //localizedString = new nsIPrefLocalizedString (result[0]); //result[0] = 0; } - localizedString.SetDataWithLength (newCharset.length, newCharset.toString16); + localizedString.SetDataWithLength (newCharset.length, Utf.toString16(newCharset).toString16z); rc = prefBranch.SetComplexValue (PREFERENCE_CHARSET.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString); } if (localizedString !is null) localizedString.Release (); @@ -895,7 +895,7 @@ //int length = proxyHost.length (); //char[] charBuffer = new char[length + 1]; //proxyHost.getChars (0, length, charBuffer, 0); - rc = localizedString.SetDataWithLength (proxyHost.length, proxyHost.toString16); + rc = localizedString.SetDataWithLength (proxyHost.length, Utf.toString16(proxyHost).toString16z); if (rc !is XPCOM.NS_OK) error (rc); //buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true); rc = prefBranch.SetComplexValue (PREFERENCE_PROXYHOST_FTP.ptr, &nsIPrefLocalizedString.IID, cast(nsISupports)localizedString); @@ -954,7 +954,7 @@ PromptService2Factory factory = new PromptService2Factory (); factory.AddRef (); - nsIComponentRegistrar componentRegistrar; + nsIComponentRegistrar componentRegistrar; rc = componentManager.QueryInterface (&nsIComponentRegistrar.IID, cast(void**)&componentRegistrar); if (rc !is XPCOM.NS_OK) { browser.dispose (); @@ -968,10 +968,10 @@ //nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); //result[0] = 0; //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true); - String aClassName = "Prompt Service"; + String aClassName = "Prompt Service"; //byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$ - - rc = componentRegistrar.RegisterFactory (XPCOM.NS_PROMPTSERVICE_CID, aClassName, XPCOM.NS_PROMPTSERVICE_CONTRACTID, cast(nsIFactory)factory); + + rc = componentRegistrar.RegisterFactory (XPCOM.NS_PROMPTSERVICE_CID, aClassName.ptr, XPCOM.NS_PROMPTSERVICE_CONTRACTID, cast(nsIFactory)factory); if (rc !is XPCOM.NS_OK) { browser.dispose (); @@ -982,9 +982,9 @@ HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory (); dialogFactory.AddRef (); //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true); - aClassName = "Helper App Launcher Dialog"; + 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, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, cast(nsIFactory)dialogFactory); + rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName.ptr, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, cast(nsIFactory)dialogFactory); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); @@ -1001,9 +1001,9 @@ DownloadFactory downloadFactory = new DownloadFactory (); downloadFactory.AddRef (); //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true); - aClassName = "Download"; + aClassName = "Download"; //aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$ - rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, XPCOM.NS_DOWNLOAD_CONTRACTID, cast(nsIFactory)downloadFactory); + rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_DOWNLOAD_CONTRACTID, cast(nsIFactory)downloadFactory); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); @@ -1013,9 +1013,9 @@ FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory (); pickerFactory.AddRef (); //aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true); - aClassName = "FilePicker"; + aClassName = "FilePicker"; //aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$ - rc = componentRegistrar.RegisterFactory (XPCOM.NS_FILEPICKER_CID, aClassName, XPCOM.NS_FILEPICKER_CONTRACTID, cast(nsIFactory)pickerFactory); + rc = componentRegistrar.RegisterFactory (XPCOM.NS_FILEPICKER_CID, aClassName.ptr, XPCOM.NS_FILEPICKER_CONTRACTID, cast(nsIFactory)pickerFactory); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); @@ -1054,14 +1054,14 @@ //int length = SHUTDOWN_PERSIST.length (); //char[] chars = new char [length + 1]; //SHUTDOWN_PERSIST.getChars (0, length, chars, 0); - rc = observerService.NotifyObservers (null, PROFILE_BEFORE_CHANGE.ptr, SHUTDOWN_PERSIST.toString16); + rc = observerService.NotifyObservers (null, PROFILE_BEFORE_CHANGE.ptr, Utf.toString16(SHUTDOWN_PERSIST).toString16z); if (rc !is XPCOM.NS_OK) error (rc); observerService.Release (); if (LocationProvider !is null) { String prefsLocation = LocationProvider.profilePath ~ AppFileLocProvider.PREFERENCES_FILE; scope auto pathString = new nsEmbedString (prefsLocation); - nsILocalFile localFile; + nsILocalFile localFile; rc = XPCOM.NS_NewLocalFile (cast(nsAString*)pathString, 1, &localFile); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); if (localFile is null) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER); @@ -1069,7 +1069,7 @@ //nsILocalFile localFile = new nsILocalFile (result [0]); //result[0] = 0; - nsIFile prefFile; + nsIFile prefFile; rc = localFile.QueryInterface (&nsIFile.IID, &prefFile); if (rc !is XPCOM.NS_OK) Mozilla.error (rc); if (prefFile is null) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE); @@ -1077,7 +1077,7 @@ //nsIFile prefFile = new nsIFile (result[0]); //result[0] = 0; - nsIPrefService prefService; + nsIPrefService prefService; //buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true); rc = serviceManager.GetServiceByContractID (XPCOM.NS_PREFSERVICE_CONTRACTID, &nsIPrefService.IID, &prefService); if (rc !is XPCOM.NS_OK) error (rc); @@ -1134,7 +1134,7 @@ //result[0] = 0; //createCOMInterfaces (); - AddRef (); + this.AddRef (); /***** CAREFUL HERE: check to make sure this is correct XPCOM ***** connection for webBrowserChrome. -JJR @@ -1198,24 +1198,26 @@ * Check for the availability of the pre-1.8 implementation of nsIDocShell * to determine if the GRE's version is < 1.8. */ - rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result); + nsIInterfaceRequestor interfaceRequestor; + rc = webBrowser.QueryInterface (&nsIInterfaceRequestor.IID, cast(void**)&interfaceRequestor); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (XPCOM.NS_ERROR_FAILURE); } - if (result[0] is 0) { + if (interfaceRequestor is null) { browser.dispose (); error (XPCOM.NS_ERROR_NO_INTERFACE); } - nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]); - result[0] = 0; + //nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]); + //result[0] = 0; - rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result); - if (rc is XPCOM.NS_OK && result[0] !is 0) { + nsIDocShell docShell; + rc = interfaceRequestor.GetInterface (&nsIDocShell.IID, cast(void**)&docShell); + if (rc is XPCOM.NS_OK && docShell !is null) { IsPre_1_8 = true; - new nsISupports (result[0]).Release (); + docShell.Release (); } - result[0] = 0; + //result[0] = 0; /* * A Download factory for contract "Transfer" must be registered iff the GRE's version is 1.8.x. @@ -1227,33 +1229,36 @@ * functionality is provided by the GRE. */ if (!IsPre_1_8) { - rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result); - if (rc is XPCOM.NS_OK && result[0] !is 0) { /* 1.8 */ - new nsISupports (result[0]).Release (); - result[0] = 0; - rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result); + nsIDocShell_1_8 docShell_1_8; + 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); } - if (result[0] is 0) { + if (componentRegistrar is null) { browser.dispose (); error (XPCOM.NS_NOINTERFACE); } - nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]); + // 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); - byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$ - rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress ()); + // byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true); + + // byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$ + rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName.ptr, XPCOM.NS_TRANSFER_CONTRACTID, cast(nsIFactory)downloadFactory_1_8); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); } downloadFactory_1_8.Release (); componentRegistrar.Release (); - } else { /* >= 1.9 */ + } else { /* >= 1.9 */ /* * Bug in XULRunner 1.9. Mozilla no longer clears its background before initial content has * been set. As a result embedders appear broken if they do not immediately navigate to a url. @@ -1263,34 +1268,59 @@ * normal. The Mozilla bug for this is https://bugzilla.mozilla.org/show_bug.cgi?id=415789. */ awaitingNavigate = true; - rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + nsIWebNavigation webNavigation; + rc = webBrowser.QueryInterface (&nsIWebNavigation.IID, cast(void**)&webNavigation); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); } - if (result[0] is 0) { + if (webNavigation is null) { browser.dispose (); error (XPCOM.NS_ERROR_NO_INTERFACE); } - nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); - char[] uri = new char[ABOUT_BLANK.length () + 1]; - ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0); - rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0); + //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + //char[] uri = new char[ABOUT_BLANK.length () + 1]; + //ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0); + rc = webNavigation.LoadURI (Utf.toString16(ABOUT_BLANK).toString16z, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); webNavigation.Release (); } } - result[0] = 0; + //result[0] = 0; interfaceRequestor.Release (); } componentManager.Release (); - rc = webBrowser.AddWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID); + nsIWeakReference weakReference; + rc = this.QueryInterface(&nsIWeakReference.IID, cast(void**)&weakReference); + if (rc !is XPCOM.NS_OK) { + browser.dispose(); + error(rc); + } + if (weakReference is null) { + browser.dispose(); + error(XPCOM.NS_ERROR_NO_INTERFACE); + } + + // TODO: Find appropriate place to "Release" weakReference + rc = webBrowser.AddWebBrowserListener (weakReference, &nsIWebProgressListener.IID); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); } - rc = webBrowser.SetParentURIContentListener (uriContentListener.getAddress ()); + // TODO: Find appropriate place to "Release" uriContentListener + nsIUriContentListener uriContentListener; + this.QueryInterface(&nsIUriContentListener.IID, cast(void**)&uriContentListener); + if (rc !is XPCOM.NS_OK) { + browser.dispose(); + error(rc) + } + if (uriContentListener is null) + browser.dispose(); + error(XPCOM.NS_ERROR_NO_INTERFACE); + } + + rc = webBrowser.SetParentURIContentListener (uriContentListener); if (rc !is XPCOM.NS_OK) { browser.dispose (); error (rc); @@ -1357,12 +1387,13 @@ public bool back () { if (awaitingNavigate) return false; - int /*long*/[] result = new int /*long*/[1]; - int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + //int /*long*/[] result = new int /*long*/[1]; + nsIWebNavigation webNavigation; + int rc = webBrowser.QueryInterface (&nsIWebNavigation.IID, cast(void**)&webNavigation); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + if (webNavigation is null) error (XPCOM.NS_ERROR_NO_INTERFACE); - nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); rc = webNavigation.GoBack (); webNavigation.Release (); return rc is XPCOM.NS_OK; @@ -1371,17 +1402,18 @@ public bool execute (String script) { if (awaitingNavigate) return false; - String url = PREFIX_JAVASCRIPT + script + ";void(0);"; //$NON-NLS-1$ - int /*long*/[] result = new int /*long*/[1]; - int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + String url = PREFIX_JAVASCRIPT ~ script ~ ";void(0);"; //$NON-NLS-1$ + //int /*long*/[] result = new int /*long*/[1]; + nsIWebNavigation webNavigation; + int rc = webBrowser.QueryInterface (&nsIWebNavigation.IID, cast(void**)&webNavigation); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + if (webNavigation is null) error (XPCOM.NS_ERROR_NO_INTERFACE); - nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); - char[] arg = url.toCharArray (); - char[] c = new char[arg.length+1]; - System.arraycopy (arg, 0, c, 0, arg.length); - rc = webNavigation.LoadURI (c, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0); + //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + //char[] arg = url.toCharArray (); + //char[] c = new char[arg.length+1]; + //System.arraycopy (arg, 0, c, 0, arg.length); + rc = webNavigation.LoadURI (Utf.toString16(url).toString16z, nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null); webNavigation.Release (); return rc is XPCOM.NS_OK; } @@ -1393,12 +1425,13 @@ public bool forward () { if (awaitingNavigate) return false; - int /*long*/[] result = new int /*long*/[1]; - int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result); + //int /*long*/[] result = new int /*long*/[1]; + nsIWebNavigation webNavigation; + int rc = webBrowser.QueryInterface (&nsIWebNavigation.IID, cast(void**)&webNavigation); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_ERROR_NO_INTERFACE); + if (webNavigation is null) error (XPCOM.NS_ERROR_NO_INTERFACE); - nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); + //nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]); rc = webNavigation.GoForward (); webNavigation.Release (); @@ -1408,62 +1441,69 @@ public String getText () { if (awaitingNavigate) return ""; //$NON-NLS-1$ - int /*long*/[] result = new int /*long*/[1]; - int rc = webBrowser.GetContentDOMWindow (result); + //int /*long*/[] result = new int /*long*/[1]; + nsIDOMWIndow window; + int rc = webBrowser.GetContentDOMWindow (&window); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + if (window is null) error (XPCOM.NS_NOINTERFACE); - nsIDOMWindow window = new nsIDOMWindow (result[0]); - result[0] = 0; - rc = window.GetDocument (result); + //nsIDOMWindow window = new nsIDOMWindow (result[0]); + //result[0] = 0; + nsIDOMDocument document; + rc = window.GetDocument (&document); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + if (document is null) error (XPCOM.NS_NOINTERFACE); window.Release (); - int /*long*/ document = result[0]; - result[0] = 0; - rc = XPCOM.NS_GetComponentManager (result); + //int /*long*/ document = result[0]; + //result[0] = 0; + nsIComponentManager componentManager; + rc = XPCOM.NS_GetComponentManager (&componentManager); if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); + if (componentManager is null) error (XPCOM.NS_NOINTERFACE); + + //nsIComponentManager componentManager = new nsIComponentManager (result[0]); + //result[0] = 0; + //byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true); + String chars = null; + nsIDOMSerializer_1_7 serializer_1_7; + rc = componentManager.CreateInstanceByContractID (XPCOM.NS_DOMSERIALIZER_CONTRACTID, null, &nsIDOMSerializer_1_7.IID, cast(void**)&serializer_1_7); + if (rc is XPCOM.NS_OK) { /* mozilla >= 1.7 */ + if (serializer_1_7 is null) error (XPCOM.NS_NOINTERFACE); - nsIComponentManager componentManager = new nsIComponentManager (result[0]); - result[0] = 0; - byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true); - char[] chars = null; + //nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]); + //result[0] = 0; + scope auto string = new nsEmbedString; + rc = serializer_1_7.SerializeToString (cast(nsIDOMNode)document, cast(nsAString*) string); + serializer_1_7.Release (); - rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer_1_7.NS_IDOMSERIALIZER_IID, result); - if (rc is XPCOM.NS_OK) { /* mozilla >= 1.7 */ - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); - - nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]); - result[0] = 0; - int /*long*/ string = XPCOM.nsEmbedString_new (); - rc = serializer.SerializeToString (document, string); + //int length = XPCOM.nsEmbedString_Length (string); + //int /*long*/ buffer = XPCOM.nsEmbedString_get (string); + //chars = new char[length]; + //XPCOM.memmove (chars, buffer, length * 2); + //XPCOM.nsEmbedString_delete (string); + chars = string.toString; + } else { /* mozilla < 1.7 */ + nsIDOMSerializer serializer; + rc = componentManager.CreateInstanceByContractID (XPCOM.NS_DOMSERIALIZER_CONTRACTID, null, &nsIDOMSerializer.IID, cast(void**)&serializer); + if (rc !is XPCOM.NS_OK) error (rc); + if (serializer is null) error (XPCOM.NS_NOINTERFACE); + // TODO: Lookup SerializeToString contract. Find out if the string must provide it's own memory to the method. -JJR + PRUnichar* string; + //nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]); + //result[0] = 0; + rc = serializer.SerializeToString (cast(nsIDOMNode)document, &string ); serializer.Release (); - int length = XPCOM.nsEmbedString_Length (string); - int /*long*/ buffer = XPCOM.nsEmbedString_get (string); - chars = new char[length]; - XPCOM.memmove (chars, buffer, length * 2); - XPCOM.nsEmbedString_delete (string); - } else { /* mozilla < 1.7 */ - rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer.NS_IDOMSERIALIZER_IID, result); - if (rc !is XPCOM.NS_OK) error (rc); - if (result[0] is 0) error (XPCOM.NS_NOINTERFACE); - - nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]); - result[0] = 0; - rc = serializer.SerializeToString (document, result); - serializer.Release (); - - int length = XPCOM.strlen_PRUnichar (result[0]); - chars = new char[length]; - XPCOM.memmove (chars, result[0], length * 2); + //int length = XPCOM.strlen_PRUnichar (string); + //chars = new char[length]; + //XPCOM.memmove (chars, result[0], length * 2); + chars = Utf.toString(string.fromString16z); } componentManager.Release (); - new nsISupports (document).Release (); - return new String (chars); + document.Release (); + return chars.dup; } public String getUrl () {