in 3 stages so events can be registered before the window is actually created.
The creation of the window is now done only when a user requests something
from the binding (like opening a window, or rendering content)
2008-11-23 Andreia Gaita <shana@jitted.com>
svn path=/trunk/mcs/; revision=119732
+2008-11-23 Andreia Gaita <shana@jitted.com>
+
+ * Mono.Mozilla/Base.cs, Mono.Mozilla/WebBrowser.cs: Separate initialization
+ in 3 stages so events can be registered before the window is actually created.
+ The creation of the window is now done only when a user requests something
+ from the binding (like opening a window, or rendering content)
+
2008-11-19 Andreia Gaita <shana@jitted.com>
* Mono.Mozilla/DOM/Node.cs, Mono.Mozilla/DOM/Window.cs: Fix comparison operators
IntPtr ptrCallback = Marshal.AllocHGlobal (Marshal.SizeOf (info.callback));
Marshal.StructureToPtr (info.callback, ptrCallback, true);
- info.gluezilla = gluezilla_createBrowserWindow (ptrCallback, handle, width, height, Environment.CurrentDirectory, monoMozDir, control.platform);
+ info.gluezilla = gluezilla_bind (ptrCallback, handle, width, height, Environment.CurrentDirectory, monoMozDir, control.platform);
lock (initLock) {
if (info.gluezilla == IntPtr.Zero) {
Marshal.FreeHGlobal (ptrCallback);
return true;
}
+ public static bool Create (IWebBrowser control) {
+ if (!isInitialized ())
+ return false;
+ BindingInfo info = getBinding (control);
+
+ gluezilla_createBrowserWindow (info.gluezilla);
+ return true;
+ }
+
public static void Shutdown (IWebBrowser control)
{
lock (initLock) {
private static extern short gluezilla_init (Platform platform, out Platform mozPlatform);
[DllImport ("gluezilla")]
- private static extern IntPtr gluezilla_shutdown (IntPtr instance);
+ private static extern IntPtr gluezilla_bind (IntPtr events, IntPtr hwnd,
+ Int32 width, Int32 height,
+ string startDir, string dataDir,
+ Platform platform);
[DllImport ("gluezilla")]
- private static extern IntPtr gluezilla_createBrowserWindow (/*IntPtr instance, */IntPtr events, IntPtr hwnd, Int32 width, Int32 height, string startDir, string dataDir, Platform platform);
-
+ private static extern int gluezilla_createBrowserWindow (IntPtr instance);
+
+ [DllImport ("gluezilla")]
+ private static extern IntPtr gluezilla_shutdown (IntPtr instance);
+
// layout
[DllImport ("gluezilla")]
private static extern int gluezilla_focus (IntPtr instance, FocusOption focus);
string aBuf,
uint aCount);
- [DllImport ("gluezilla")]
- [return: MarshalAs (UnmanagedType.Interface)]
- public static extern nsIServiceManager gluezilla_getServiceManager ();
-
[DllImport ("gluezilla")]
[return: MarshalAs (UnmanagedType.Interface)]
public static extern nsIServiceManager gluezilla_getServiceManager2 (IntPtr instance);
{
internal class WebBrowser : IWebBrowser
{
- private bool loaded;
- private DOM.Document document;
+ bool loaded;
+ bool created = false;
+ bool creating = false;
+
+ DOM.Document document;
internal DOM.Navigation navigation;
internal Platform platform;
internal Platform enginePlatform;
internal Callback callbacks;
- private System.ComponentModel.EventHandlerList events;
- private System.ComponentModel.EventHandlerList domEvents;
+ System.ComponentModel.EventHandlerList events;
+ System.ComponentModel.EventHandlerList domEvents;
- private string statusText;
+ string statusText;
- private bool streamingMode;
+ bool streamingMode;
internal Hashtable documents;
return loaded;
}
+ bool Created {
+ get {
+ if (!creating && !created) {
+ creating = true;
+ created = Base.Create (this);
+ }
+ return created;
+ }
+ }
+
public void Shutdown ()
{
Base.Shutdown (this);
public INavigation Navigation {
get {
+ if (!Created) return null;
+
if (navigation == null) {
nsIWebNavigation webNav = Base.GetWebNavigation (this);
public bool Offline {
get {
bool ret;
+ if (!Created) return true;
IOService.getOffline (out ret);
return ret;
}
#region Layout
public void FocusIn (FocusOption focus)
{
+ if (!created) return;
Base.Focus (this, focus);
}
public void FocusOut ()
{
+ if (!created) return;
Base.Blur (this);
}
public void Activate ()
{
+ if (!created) return;
Base.Activate (this);
}
public void Deactivate ()
{
+ if (!created) return;
Base.Deactivate (this);
}
public void Resize (int width, int height)
{
+ if (!created) return;
Base.Resize (this, width, height);
}
-
public void Render (byte[] data)
{
+ if (!Created) return;
if (data == null)
throw new ArgumentNullException ("data");
string html = System.Text.ASCIIEncoding.UTF8.GetString (data);
public void Render (string html)
{
+ if (!Created) return;
Render (html, "file:///", "text/html");
}
public void Render (string html, string uri, string contentType)
{
-
+ if (!Created) return;
nsIWebBrowserStream stream;
if (Navigation != null) {
stream = (nsIWebBrowserStream) navigation.navigation;
}
public void ExecuteScript (string script) {
+ if (!Created) return;
Base.EvalScript (this, script);
}