Author: andreia
Date: 2007-12-25 00:01:57 -0500 (Tue, 25 Dec 2007)
New Revision: 91870

Modified:
   trunk/mcs/class/Mono.Mozilla/ChangeLog
   trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/Base.cs
   trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMHTMLDocument.cs
   trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMObject.cs
   trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs
   trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/WebBrowser.cs
   trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/interfaces/nsIWebNavigation.cs
   trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs
   trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/IWebBrowser.cs
Log:
* Mono.Mozilla/DOM/DOMHTMLDocument.cs,
  Mono.Mozilla/DOM/DOMObject.cs
  Mono.Mozilla/DOM/Navigation.cs:
  
Properly dispose unmanaged resources.
Use native mozilla dom interfaces through com directly instead
of going through the glue, as they are now proxies that invoke
the methods on the main mozilla ui properly (avoiding threading problems).
Check if library was properly initialized.
Add Go method - implements navigation
directly through COM instead of going through the glue.

* Mono.Mozilla/interfaces/nsIWebNavigation.cs: Use typed flags instead of
generic uint32. Remove comments about threading (as it is now safe to use
this interface)

* Mono.Mozilla/Base.cs: Return bool on initialization so I can track if
library was properly initialized from the interfaces that go directly 
through COM and not through the glue

* Mono.Mozilla/WebBrowser.cs: Save initialization result so interfaces
don't get called if the library was not initialized.

2007-12-25  Andreia Gaita  <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/Mono.Mozilla/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Mozilla/ChangeLog      2007-12-25 00:50:16 UTC (rev 
91869)
+++ trunk/mcs/class/Mono.Mozilla/ChangeLog      2007-12-25 05:01:57 UTC (rev 
91870)
@@ -1,3 +1,28 @@
+2007-12-25  Andreia Gaita  <[EMAIL PROTECTED]>
+
+       * Mono.Mozilla/DOM/DOMHTMLDocument.cs,
+         Mono.Mozilla/DOM/DOMObject.cs
+         Mono.Mozilla/DOM/Navigation.cs:
+         
+       Properly dispose unmanaged resources.
+       Use native mozilla dom interfaces through com directly instead
+       of going through the glue, as they are now proxies that invoke
+       the methods on the main mozilla ui properly (avoiding threading 
problems).
+       Check if library was properly initialized.
+       Add Go method - implements navigation
+       directly through COM instead of going through the glue.
+       
+       * Mono.Mozilla/interfaces/nsIWebNavigation.cs: Use typed flags instead 
of
+       generic uint32. Remove comments about threading (as it is now safe to 
use
+       this interface)
+
+       * Mono.Mozilla/Base.cs: Return bool on initialization so I can track if
+       library was properly initialized from the interfaces that go directly 
+       through COM and not through the glue
+
+       * Mono.Mozilla/WebBrowser.cs: Save initialization result so interfaces
+       don't get called if the library was not initialized.
+
 2007-11-08  Andreia Gaita  <[EMAIL PROTECTED]>
 
        * Mono.Mozilla.csproj, Mono.Mozilla2K5.csproj: Synch with .sources

Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/Base.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/Base.cs   2007-12-25 00:50:16 UTC 
(rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/Base.cs   2007-12-25 05:01:57 UTC 
(rev 91870)
@@ -72,7 +72,7 @@
                        Trace.AutoFlush = true;
                }
 
-               public static void Init (WebBrowser control)
+               public static bool Init (WebBrowser control)
                {
                        BindingInfo info = new BindingInfo ();
                        info.callback = new CallbackBinder (control);
@@ -94,11 +94,12 @@
                                Console.WriteLine ("libgluezilla not found. To 
have webbrowser support, you need libgluezilla installed");
                                Marshal.FreeHGlobal (ptrCallback);
                                gluezillaInstalled = false;
-                               return;
+                               return false;
                        }
                        gluezillaInstalled = true;
                        boundControls.Add (control as IWebBrowser, info);
-                       DebugStartup ();
+                       DebugStartup ();
+                       return true;
                }
 
                public static void Shutdown (IWebBrowser control)
@@ -259,8 +260,17 @@
                public static void StringSet (HandleRef str, string text)
                {
                        gluezilla_stringSet (str, text);
+               }
+/*             
+               public static nsIServiceManager GetServiceManager (IWebBrowser 
control)
+               {
+                       if (!isInitialized ())
+                               return null;
+                       BindingInfo info = getBinding (control);
+
+                       return gluezilla_getServiceManager (info.gluezilla);
                }
-
+*/
                #region pinvokes
                [DllImport("gluezilla")]
                private static extern void gluezilla_debug_startup();
@@ -316,6 +326,10 @@
                private static extern IntPtr gluezilla_stringGet (HandleRef 
str);
                [DllImport ("gluezilla")]
                private static extern void gluezilla_stringSet (HandleRef str, 
[MarshalAs (UnmanagedType.LPWStr)] string text);
+
+
+//             [DllImport ("gluezilla")]
+//             private static extern nsIServiceManager 
gluezilla_getServiceManager (IntPtr instance);
                #endregion
        }
 }

Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMHTMLDocument.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMHTMLDocument.cs    
2007-12-25 00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMHTMLDocument.cs    
2007-12-25 05:01:57 UTC (rev 91870)
@@ -33,12 +33,26 @@
 {
        internal class DOMHTMLDocument: DOMObject, IDOMHTMLDocument
        {
-               private nsIDOMHTMLDocument document;
+               private nsIDOMHTMLDocument document;
+               private bool disposed = false;
                
                public DOMHTMLDocument (nsIDOMHTMLDocument document)
                {
                        this.document = document;
-               }
+               }
+
+               #region IDisposable Members
+               protected override  void Dispose (bool disposing)
+               {
+                       if (!disposed) {
+                               if (disposing) {
+                                       this.document = null;
+                               }
+                               disposed = true;
+                       }
+                       base.Dispose(disposing);
+               }               
+               #endregion
 
                #region IDOMDocument Members
 
@@ -47,8 +61,16 @@
                                nsIDOMHTMLElement body;
                                this.document.getBody (out body);
                                return new DOMHTMLElement (body);
-                       }
+                       }
                }
+
+               public string Text {
+                       set {
+                               nsIDOMElement element;
+                               this.document.getDocumentElement (out element);
+                               
+                       }
+               }
 
                public string Title {
                        get {

Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMObject.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMObject.cs  2007-12-25 
00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/DOMObject.cs  2007-12-25 
05:01:57 UTC (rev 91870)
@@ -31,7 +31,8 @@
 {
        internal class DOMObject : IDisposable
        {
-               internal HandleRef storage;
+               internal HandleRef storage;
+               private bool disposed = false;
 
                internal DOMObject ()
                {
@@ -40,15 +41,26 @@
                }
 
                ~DOMObject ()
-               {
-                       this.Dispose ();
+               {
+                       Dispose (false);
                }
 
                #region IDisposable Members
+
+               protected virtual void Dispose (bool disposing)
+               {
+                       if (!disposed) {
+                               if (disposing) {
+                                       Base.StringFinish (storage);
+                               }
+                               disposed = true;
+                       }
+               }
 
                public void Dispose ()
                {
-                       Base.StringFinish (storage);
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
                }
 
                #endregion

Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs 2007-12-25 
00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs 2007-12-25 
05:01:57 UTC (rev 91870)
@@ -31,43 +31,73 @@
 
 namespace Mono.Mozilla.DOM
 {
-       internal class Navigation: INavigation
+       internal class Navigation: DOMObject, INavigation
        {
 
-               private nsIWebNavigation webNav;
-               private IWebBrowser control;
+               private nsIWebNavigation navigation;
+               private IWebBrowser control;
+               private bool disposed = false;
+               
                public Navigation (IWebBrowser control, nsIWebNavigation webNav)
                {
-                       this.webNav = webNav;
+                       this.navigation = webNav;
                        this.control = control;
                }
+
+
+               #region IDisposable Members
+               protected override  void Dispose (bool disposing)
+               {
+                       if (!disposed) {
+                               if (disposing) {
+                                       this.navigation = null;
+                               }
+                               disposed = true;
+                       }
+                       base.Dispose(disposing);
+               }               
+               #endregion      
 
                #region INavigation Members
 
                public bool CanGoBack {
-                       get {
+                       get {
+                               if (navigation == null)
+                                       return false;
+                                       
                                bool canGoBack;
-                               webNav.CanGoBack (out canGoBack);
+                               navigation.CanGoBack (out canGoBack);
                                return canGoBack;
                        }
                }
 
                public bool CanGoForward {
                        get {
+                               if (navigation == null)
+                                       return false;
+
                                bool canGoForward;
-                               webNav.CanGoForward (out canGoForward);
+                               navigation.CanGoForward (out canGoForward);
                                return canGoForward;
                        }
                }
 
                public bool Back ()
                {
-                       return Base.Back (control);
+                       if (navigation == null)
+                               return false;
+
+                       //return Base.Back (control);
+                       return navigation.GoBack () == 0;
                }
 
                public bool Forward ()
                {
-                       return Base.Forward (control);
+                       if (navigation == null)
+                               return false;
+
+                       //return Base.Forward (control);
+                       return navigation.GoForward () == 0;
                }
 
                public void Home ()
@@ -77,17 +107,37 @@
 
                public void Reload ()
                {
-                       Base.Reload (control, ReloadOption.None);
+                       if (navigation == null)
+                               return;
+
+                       //Base.Reload (control, ReloadOption.None);
+                       navigation.Reload (ReloadOption.None);
                }
 
                public void Reload (ReloadOption option)
                {
-                       Base.Reload (control, option);
+                       if (navigation == null)
+                               return;
+
+                       //Base.Reload (control, option);
+                       navigation.Reload (option);
                }
 
                public void Stop ()
                {
-                       Base.Stop (control);
+                       if (navigation == null)
+                               return;
+
+                       //Base.Stop (control);
+                       navigation.Stop (StopOption.All);
+               }
+               
+               public void Go (string url)
+               {
+                       if (navigation == null)
+                               return;
+
+                       navigation.LoadURI (url, ReloadOption.None, null, null, 
null);
                }
 
                #endregion

Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/WebBrowser.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/WebBrowser.cs     2007-12-25 
00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/WebBrowser.cs     2007-12-25 
05:01:57 UTC (rev 91870)
@@ -40,18 +40,18 @@
        public class WebBrowser : Component, IWebBrowser, ICallback
        {
                private bool loaded;
-               private IDOMHTMLDocument document;
-               private INavigation navigation;
+               private DOM.DOMHTMLDocument document;
+               private DOM.Navigation navigation;
 
                public WebBrowser ()
                {
-                       loaded = false;
-                       Base.Init (this);
+                       loaded = Base.Init (this);
                }
 
-               public void Load (IntPtr handle, int width, int height)
-               {
-                       Base.Bind (this, handle, width, height);
+               public bool Load (IntPtr handle, int width, int height)
+               {
+                       Base.Bind (this, handle, width, height);
+                       return loaded;
                }
 
                public void Shutdown ()
@@ -67,7 +67,7 @@
                                        nsIDOMHTMLDocument doc = 
Base.GetDOMDocument (this);
                                        document = new DOM.DOMHTMLDocument 
(doc);
                                }
-                               return document;
+                               return document as IDOMHTMLDocument;
                        }
                }
 
@@ -75,11 +75,12 @@
                {
                        get
                        {
-                               if (navigation == null) {
+                               if (navigation == null) {
+                                       
                                        nsIWebNavigation webNav = 
Base.GetWebNavigation (this);
                                        navigation = new DOM.Navigation (this, 
webNav);
                                }
-                               return navigation;
+                               return navigation as INavigation;
                        }
                }
 
@@ -108,8 +109,8 @@
                }
 
                public void Navigate (string url)
-               {
-                       this.document = null;
+               {
+                       this.document = null;
                        this.navigation = null;
                        Base.Navigate (this, url);
                }

Modified: 
trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/interfaces/nsIWebNavigation.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/interfaces/nsIWebNavigation.cs    
2007-12-25 00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/interfaces/nsIWebNavigation.cs    
2007-12-25 05:01:57 UTC (rev 91870)
@@ -43,52 +43,33 @@
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
                int CanGoForward (out bool canGoForward);
 
-               /// <summary>
-               /// Do not use on non-windows platforms due to threading 
problems
-               /// </summary>
-               /// <returns></returns>
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
                int GoBack ();
 
-               /// <summary>
-               /// Do not use on non-windows platforms due to threading 
problems
-               /// </summary>
-               /// <returns></returns>
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
                int GoForward ();
 
-               /// <summary>
-               /// Do not use on non-windows platforms due to threading 
problems
-               /// </summary>
-               /// <returns></returns>
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
                int GotoIndex (Int32 index);
 
-               /// <summary>
-               /// Do not use on non-windows platforms due to threading 
problems
-               /// </summary>
-               /// <returns></returns>
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
-               int LoadURI (string uri, UInt32 loadFlags,
+               int LoadURI ([MarshalAs(UnmanagedType.LPWStr)] string uri, 
+                                       Mono.WebBrowser.ReloadOption loadFlags,
                                        [MarshalAs (UnmanagedType.Interface)] 
nsIURI referrer,
                                   [MarshalAs (UnmanagedType.Interface)] 
nsIInputStream postData,
                                   [MarshalAs (UnmanagedType.Interface)] 
nsIInputStream headers);
 
-               /// <summary>
-               /// Do not use on non-windows platforms due to threading 
problems
-               /// </summary>
-               /// <returns></returns>
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
-               int Reload (UInt32 reloadFlags);
+               int Reload (Mono.WebBrowser.ReloadOption reloadFlags);
 
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
-               int Stop (UInt32 stopFlags);
+               int Stop (StopOption stopFlags);
 
                [PreserveSigAttribute]
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
@@ -110,5 +91,12 @@
                [MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = 
MethodCodeType.Runtime)]
                int SetSessionHistory ([MarshalAs (UnmanagedType.Interface)] 
nsISHistory sessionHistory);
 
-       }
+       }
+       
+       internal enum StopOption : uint
+       {
+               Network = 1,
+               Content = 2,
+               All = 3
+       }
 }

Modified: trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs     
2007-12-25 00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs     
2007-12-25 05:01:57 UTC (rev 91870)
@@ -37,6 +37,7 @@
                void Home ();
                void Reload ();
                void Reload (ReloadOption option);
-               void Stop ();
+               void Stop ();
+               void Go (string url);
        }
 }

Modified: trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/IWebBrowser.cs
===================================================================
--- trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/IWebBrowser.cs 2007-12-25 
00:50:16 UTC (rev 91869)
+++ trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/IWebBrowser.cs 2007-12-25 
05:01:57 UTC (rev 91870)
@@ -34,7 +34,7 @@
 {
        public interface IWebBrowser
        {
-               void Load (IntPtr handle, int width, int height);
+               bool Load (IntPtr handle, int width, int height);
                void Shutdown ();
                void FocusIn (FocusOption focus);
                void FocusOut ();
@@ -62,7 +62,7 @@
                event EventHandler Navigated;
        }
 
-       public enum ReloadOption
+       public enum ReloadOption : uint
        {
                None = 0,
                Proxy = 1,

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to