1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2007 Novell, Inc.
23 // Andreia Gaita (avidigal@novell.com)
30 using System.Runtime.InteropServices;
31 using System.Diagnostics;
33 namespace Mono.Mozilla {
35 using Mono.WebBrowser;
36 using Mono.WebBrowser.DOM;
38 internal class Callback
42 bool calledLoadStarted;
44 public Callback (WebBrowser owner)
52 public void OnWidgetLoaded ()
55 OnGeneric ("OnWidgetLoaded");
60 public void OnStateChange (nsIWebProgress progress, nsIRequest request, Int32 status, UInt32 state)
66 //OnGeneric ("OnStateChange");
68 System.Text.StringBuilder s = new System.Text.StringBuilder ();
69 if ((state & (uint) StateFlags.Start) != 0) {
72 if ((state & (uint) StateFlags.Redirecting) != 0) {
73 s.Append ("Redirecting\t");
75 if ((state & (uint) StateFlags.Transferring) != 0) {
76 s.Append ("Transferring\t");
78 if ((state & (uint) StateFlags.Negotiating) != 0) {
79 s.Append ("Negotiating\t");
81 if ((state & (uint) StateFlags.Stop) != 0) {
84 if ((state & (uint) StateFlags.IsRequest) != 0) {
85 s.Append ("Request\t");
87 if ((state & (uint) StateFlags.IsDocument) != 0) {
88 s.Append ("Document\t");
90 if ((state & (uint) StateFlags.IsNetwork) != 0) {
91 s.Append ("Network\t");
93 if ((state & (uint) StateFlags.IsWindow) != 0) {
94 s.Append ("Window\t");
96 Console.Error.WriteLine (s.ToString ());
99 bool _start = (state & (uint) StateFlags.Start) != 0;
100 bool _transferring = (state & (uint) StateFlags.Transferring) != 0;
101 bool _redirecting = (state & (uint) StateFlags.Redirecting) != 0;
102 bool _stop = (state & (uint) StateFlags.Stop) != 0;
103 bool _request = (state & (uint) StateFlags.IsRequest) != 0;
104 bool _document = (state & (uint) StateFlags.IsDocument) != 0;
105 bool _network = (state & (uint) StateFlags.IsNetwork) != 0;
106 bool _window = (state & (uint) StateFlags.IsWindow) != 0;
108 if (_start && _request && _document && !calledLoadStarted) {
110 progress.getDOMWindow (out win);
111 nsIChannel channel = (nsIChannel) request;
113 channel.getURI (out uri);
115 currentUri = "about:blank";
117 AsciiString spec = new AsciiString (String.Empty);
118 uri.getSpec (spec.Handle);
119 currentUri = spec.ToString ();
122 calledLoadStarted = true;
123 LoadStartedEventHandler eh = (LoadStartedEventHandler) (owner.Events [WebBrowser.LoadStartedEvent]);
126 AsciiString name = new AsciiString (String.Empty);
127 win.getName (name.Handle);
129 LoadStartedEventArgs e = new LoadStartedEventArgs (currentUri, name.ToString ());
132 request.cancel (2152398850); //NS_BINDING_ABORTED
138 if (_document && _request && _transferring) {
140 progress.getDOMWindow (out win);
141 nsIChannel channel = (nsIChannel) request;
143 channel.getURI (out uri);
145 currentUri = "about:blank";
147 AsciiString spec = new AsciiString (String.Empty);
148 uri.getSpec (spec.Handle);
149 currentUri = spec.ToString ();
153 win.getTop (out topWin);
154 if (topWin == null || topWin.GetHashCode () == win.GetHashCode ()) {
157 win.getDocument (out doc);
159 owner.document = new Mono.Mozilla.DOM.Document (owner, doc);
162 LoadCommitedEventHandler eh = (LoadCommitedEventHandler) (owner.Events[WebBrowser.LoadCommitedEvent]);
164 LoadCommitedEventArgs e = new LoadCommitedEventArgs (currentUri);
170 if (_document && _request && _redirecting) {
172 progress.getDOMWindow (out win);
173 nsIChannel channel = (nsIChannel) request;
175 channel.getURI (out uri);
177 currentUri = "about:blank";
179 AsciiString spec = new AsciiString (String.Empty);
180 uri.getSpec (spec.Handle);
181 currentUri = spec.ToString ();
186 if (_stop && !_request && !_document && _network && _window) {
187 calledLoadStarted = false;
188 LoadFinishedEventHandler eh1 = (LoadFinishedEventHandler) (owner.Events[WebBrowser.LoadFinishedEvent]);
192 progress.getDOMWindow (out win);
193 LoadFinishedEventArgs e = new LoadFinishedEventArgs (currentUri);
200 if (_stop && !_request && _document && !_network && !_window) {
202 progress.getDOMWindow (out win);
204 win.getDocument (out doc);
206 int hash = doc.GetHashCode ();
207 if (owner.documents.ContainsKey (hash)) {
208 DOM.Document document = owner.documents[hash] as DOM.Document;
210 EventHandler eh1 = (EventHandler)(document.Events[DOM.Document.LoadStoppedEvent]);
215 calledLoadStarted = false;
219 Console.Error.WriteLine ("{0} completed", s.ToString ());
223 public void OnProgress (nsIWebProgress progress, nsIRequest request, Int32 currentTotalProgress, Int32 maxTotalProgress)
226 OnGeneric ("OnProgress");
228 ProgressChangedEventHandler eh = (ProgressChangedEventHandler) (owner.Events [Mono.Mozilla.WebBrowser.ProgressChangedEvent]);
230 Mono.WebBrowser.ProgressChangedEventArgs e = new Mono.WebBrowser.ProgressChangedEventArgs (currentTotalProgress, maxTotalProgress);
235 public void OnLocationChanged (nsIWebProgress progress, nsIRequest request, nsIURI uri)
238 OnGeneric ("OnLocationChanged");
242 public void OnStatusChange (nsIWebProgress progress, nsIRequest request, string message, Int32 status)
244 StatusChangedEventHandler eh = (StatusChangedEventHandler) (owner.Events[WebBrowser.StatusChangedEvent]);
246 StatusChangedEventArgs e = new StatusChangedEventArgs (message, status);
251 public void OnSecurityChange (nsIWebProgress progress, nsIRequest request, uint status)
253 SecurityChangedEventHandler eh = (SecurityChangedEventHandler) (owner.Events[WebBrowser.SecurityChangedEvent]);
255 SecurityLevel state = SecurityLevel.Insecure;
258 state = SecurityLevel.Insecure;
261 state = SecurityLevel.Mixed;
264 state = SecurityLevel.Secure;
268 SecurityChangedEventArgs e = new SecurityChangedEventArgs (state);
273 public bool OnClientDomKeyDown (KeyInfo keyInfo, ModifierKeys modifiers, nsIDOMNode target)
276 OnGeneric ("OnClientDomKeyDown");
277 Console.Error.WriteLine ("OnClientDomKeyDown");
279 INode node = new Mono.Mozilla.DOM.Node (owner, target);
280 string key = String.Intern (node.GetHashCode () + ":keydown");
281 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
283 EventArgs e1 = new EventArgs ();
287 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.KeyDownEvent]);
289 NodeEventArgs e = new NodeEventArgs (node);
296 public bool OnClientDomKeyUp (KeyInfo keyInfo, ModifierKeys modifiers, nsIDOMNode target)
299 OnGeneric ("OnClientDomKeyUp");
300 Console.Error.WriteLine ("OnClientDomKeyUp");
302 INode node = new Mono.Mozilla.DOM.Node (owner, target);
303 string key = String.Intern (node.GetHashCode () + ":keyup");
304 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
306 EventArgs e1 = new EventArgs ();
310 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.KeyUpEvent]);
312 NodeEventArgs e = new NodeEventArgs (node);
319 public bool OnClientDomKeyPress (KeyInfo keyInfo, ModifierKeys modifiers, nsIDOMNode target)
322 OnGeneric ("OnClientDomKeyPress");
323 Console.Error.WriteLine ("OnClientDomKeyPress");
325 INode node = new Mono.Mozilla.DOM.Node (owner, target);
326 string key = String.Intern (node.GetHashCode () + ":keypress");
327 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
329 EventArgs e1 = new EventArgs ();
333 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.KeyPressEvent]);
335 NodeEventArgs e = new NodeEventArgs (node);
342 public bool OnClientMouseDown (MouseInfo mouseInfo, ModifierKeys modifiers, nsIDOMNode target)
345 OnGeneric ("OnClientMouseDown");
346 Console.Error.WriteLine ("OnClientMouseDown");
348 INode node = new Mono.Mozilla.DOM.Node (owner, target);
349 string key = String.Intern (node.GetHashCode () + ":mousedown");
350 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
352 EventArgs e1 = new EventArgs ();
356 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.MouseDownEvent]);
358 NodeEventArgs e = new NodeEventArgs (node);
365 public bool OnClientMouseUp (MouseInfo mouseInfo, ModifierKeys modifiers, nsIDOMNode target)
368 OnGeneric ("OnClientMouseUp");
369 Console.Error.WriteLine ("OnClientMouseUp");
371 INode node = new Mono.Mozilla.DOM.Node (owner, target);
372 string key = String.Intern (node.GetHashCode () + ":mouseup");
373 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
375 EventArgs e1 = new EventArgs ();
379 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.MouseUpEvent]);
381 NodeEventArgs e = new NodeEventArgs (node);
388 public bool OnClientMouseClick (MouseInfo mouseInfo, ModifierKeys modifiers, nsIDOMNode target)
391 OnGeneric ("OnClientMouseClick");
392 Console.Error.WriteLine ("OnClientMouseClick");
394 INode node = new Mono.Mozilla.DOM.Node (owner, target);
395 string key = String.Intern (node.GetHashCode () + ":click");
396 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
398 EventArgs e1 = new EventArgs ();
402 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.MouseClickEvent]);
404 NodeEventArgs e = new NodeEventArgs (node);
411 public bool OnClientMouseDoubleClick (MouseInfo mouseInfo, ModifierKeys modifiers, nsIDOMNode target)
414 OnGeneric ("OnClientMouseDoubleClick");
415 Console.Error.WriteLine ("OnClientMouseDoubleClick");
417 INode node = new Mono.Mozilla.DOM.Node (owner, target);
418 string key = String.Intern (node.GetHashCode () + ":dblclick");
419 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
421 EventArgs e1 = new EventArgs ();
425 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.MouseDoubleClickEvent]);
427 NodeEventArgs e = new NodeEventArgs (node);
434 public bool OnClientMouseOver (MouseInfo mouseInfo, ModifierKeys modifiers, nsIDOMNode target)
437 OnGeneric ("OnClientMouseOver");
438 Console.Error.WriteLine ("OnClientMouseOver");
440 DOM.DOMObject helper = new DOM.DOMObject(this.owner);
441 INode node = helper.GetTypedNode (target);
442 string key = String.Intern (node.GetHashCode () + ":mouseover");
443 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
445 EventArgs e1 = new EventArgs ();
449 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.MouseEnterEvent]);
451 NodeEventArgs e = new NodeEventArgs (node);
458 public bool OnClientMouseOut (MouseInfo mouseInfo, ModifierKeys modifiers, nsIDOMNode target)
461 OnGeneric ("OnClientMouseOut");
462 Console.Error.WriteLine ("OnClientMouseOut");
464 INode node = new Mono.Mozilla.DOM.Node (owner, target);
465 string key = String.Intern (node.GetHashCode () + ":mouseout");
466 EventHandler eh1 = (EventHandler) owner.DomEvents[key];
468 EventArgs e1 = new EventArgs ();
472 NodeEventHandler eh = (NodeEventHandler) (owner.Events[WebBrowser.MouseLeaveEvent]);
474 NodeEventArgs e = new NodeEventArgs (node);
481 public bool OnClientActivate ()
484 OnGeneric ("OnClientActivate");
485 Console.Error.WriteLine ("OnClientActivate");
487 // TODO: Add WebBrowser.OnClientActivate implementation
491 public bool OnClientFocus ()
494 OnGeneric ("OnClientFocus");
495 Console.Error.WriteLine ("OnClientFocus");
497 EventHandler eh = (EventHandler) (owner.Events[WebBrowser.FocusEvent]);
499 EventArgs e = new EventArgs ();
505 public bool OnClientBlur ()
508 OnGeneric ("OnClientBlur");
509 Console.Error.WriteLine ("OnClientBlur");
511 EventHandler eh = (EventHandler) (owner.Events[WebBrowser.BlurEvent]);
513 EventArgs e = new EventArgs ();
519 public bool OnCreateNewWindow ()
524 OnGeneric ("OnCreateNewWindow");
525 Console.Error.WriteLine ("OnCreateNewWindow");
527 CreateNewWindowEventHandler eh = (CreateNewWindowEventHandler) (owner.Events[WebBrowser.CreateNewWindowEvent]);
529 CreateNewWindowEventArgs e = new CreateNewWindowEventArgs (false);
535 public void OnAlert (IntPtr title, IntPtr text)
538 OnGeneric ("OnAlert");
539 Console.Error.WriteLine ("OnAlert");
541 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
543 AlertEventArgs e = new AlertEventArgs ();
544 e.Type = DialogType.Alert;
545 if (title != IntPtr.Zero)
546 e.Title = Marshal.PtrToStringUni (title);
547 if (text != IntPtr.Zero)
548 e.Text = Marshal.PtrToStringUni (text);
553 public bool OnAlertCheck (IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState)
556 OnGeneric ("OnAlertCheck");
557 Console.Error.WriteLine ("OnAlertCheck");
559 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
561 AlertEventArgs e = new AlertEventArgs ();
562 e.Type = DialogType.AlertCheck;
563 if (title != IntPtr.Zero)
564 e.Title = Marshal.PtrToStringUni (title);
565 if (text != IntPtr.Zero)
566 e.Text = Marshal.PtrToStringUni (text);
567 if (chkMsg != IntPtr.Zero)
568 e.CheckMessage = Marshal.PtrToStringUni (chkMsg);
569 e.CheckState = chkState;
576 public bool OnConfirm (IntPtr title, IntPtr text)
579 OnGeneric ("OnConfirm");
580 Console.Error.WriteLine ("OnConfirm");
582 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
584 AlertEventArgs e = new AlertEventArgs ();
585 e.Type = DialogType.Confirm;
586 if (title != IntPtr.Zero)
587 e.Title = Marshal.PtrToStringUni (title);
588 if (text != IntPtr.Zero)
589 e.Text = Marshal.PtrToStringUni (text);
596 public bool OnConfirmCheck (IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState)
599 OnGeneric ("OnConfirmCheck");
600 Console.Error.WriteLine ("OnConfirmCheck");
602 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
604 AlertEventArgs e = new AlertEventArgs ();
605 e.Type = DialogType.ConfirmCheck;
606 if (title != IntPtr.Zero)
607 e.Title = Marshal.PtrToStringUni (title);
608 if (text != IntPtr.Zero)
609 e.Text = Marshal.PtrToStringUni (text);
610 if (chkMsg != IntPtr.Zero)
611 e.CheckMessage = Marshal.PtrToStringUni (chkMsg);
612 e.CheckState = chkState;
614 chkState = e.CheckState;
620 public bool OnConfirmEx (IntPtr title, IntPtr text, DialogButtonFlags flags,
621 IntPtr title0, IntPtr title1, IntPtr title2,
622 IntPtr chkMsg, ref bool chkState, out Int32 retVal)
625 OnGeneric ("OnConfirmEx");
626 Console.Error.WriteLine ("OnConfirmEx");
630 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
632 AlertEventArgs e = new AlertEventArgs ();
633 e.Type = DialogType.ConfirmEx;
634 if (title != IntPtr.Zero)
635 e.Title = Marshal.PtrToStringUni (title);
636 if (text != IntPtr.Zero)
637 e.Text = Marshal.PtrToStringUni (text);
638 if (chkMsg != IntPtr.Zero)
639 e.CheckMessage = Marshal.PtrToStringUni (chkMsg);
640 e.CheckState = chkState;
642 chkState = e.CheckState;
648 public bool OnPrompt (IntPtr title, IntPtr text, ref IntPtr retVal)
651 OnGeneric ("OnPrompt");
652 Console.Error.WriteLine ("OnPrompt");
654 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
656 AlertEventArgs e = new AlertEventArgs ();
657 e.Type = DialogType.Prompt;
658 if (title != IntPtr.Zero)
659 e.Title = Marshal.PtrToStringUni (title);
660 if (text != IntPtr.Zero)
661 e.Text = Marshal.PtrToStringUni (text);
662 if (retVal != IntPtr.Zero)
663 e.Text2 = Marshal.PtrToStringUni (retVal);
665 retVal = Marshal.StringToHGlobalUni (e.StringReturn);
671 public bool OnPromptUsernameAndPassword (IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState, out IntPtr username, out IntPtr password)
674 OnGeneric ("OnPromptUsernameAndPassword");
675 Console.Error.WriteLine ("OnPromptUsernameAndPassword");
677 username = IntPtr.Zero;
678 password = IntPtr.Zero;
679 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
681 AlertEventArgs e = new AlertEventArgs ();
682 e.Type = DialogType.PromptUsernamePassword;
683 if (title != IntPtr.Zero)
684 e.Title = Marshal.PtrToStringUni (title);
685 if (text != IntPtr.Zero)
686 e.Text = Marshal.PtrToStringUni (text);
687 if (chkMsg != IntPtr.Zero)
688 e.CheckMessage = Marshal.PtrToStringUni (chkMsg);
689 e.CheckState = chkState;
696 public bool OnPromptPassword (IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState, out IntPtr password)
699 OnGeneric ("OnPromptPassword");
700 Console.Error.WriteLine ("OnPromptPassword");
702 password = IntPtr.Zero;
703 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
705 AlertEventArgs e = new AlertEventArgs ();
706 e.Type = DialogType.PromptPassword;
707 if (title != IntPtr.Zero)
708 e.Title = Marshal.PtrToStringUni (title);
709 if (text != IntPtr.Zero)
710 e.Text = Marshal.PtrToStringUni (text);
711 if (chkMsg != IntPtr.Zero)
712 e.CheckMessage = Marshal.PtrToStringUni (chkMsg);
713 e.CheckState = chkState;
720 public bool OnSelect (IntPtr title, IntPtr text, uint count, IntPtr list, out int retVal)
723 OnGeneric ("OnSelect");
724 Console.Error.WriteLine ("OnSelect");
727 AlertEventHandler eh = (AlertEventHandler) (owner.Events[WebBrowser.AlertEvent]);
729 AlertEventArgs e = new AlertEventArgs ();
730 e.Type = DialogType.Select;
731 if (title != IntPtr.Zero)
732 e.Title = Marshal.PtrToStringUni (title);
733 if (text != IntPtr.Zero)
734 e.Text = Marshal.PtrToStringUni (text);
741 public void OnLoad ()
744 OnGeneric ("OnLoad");
745 Console.Error.WriteLine ("OnLoad");
747 ((DOM.Window)owner.Window).OnLoad ();
750 public void OnUnload ()
753 OnGeneric ("OnUnload");
754 Console.Error.WriteLine ("OnUnload");
756 ((DOM.Window)owner.Window).OnUnload ();
759 public void OnShowContextMenu (UInt32 contextFlags,
760 [MarshalAs (UnmanagedType.Interface)] nsIDOMEvent eve,
761 [MarshalAs (UnmanagedType.Interface)] nsIDOMNode node)
764 OnGeneric ("OnShowContextMenu");
765 Console.Error.WriteLine ("OnShowContextMenu");
767 ContextMenuEventHandler eh = (ContextMenuEventHandler) (owner.Events[WebBrowser.ContextMenuEvent]);
770 nsIDOMMouseEvent mouseEvent = (nsIDOMMouseEvent) eve;
772 mouseEvent.getClientX (out x);
773 mouseEvent.getClientY (out y);
774 ContextMenuEventArgs args = new ContextMenuEventArgs(x, y);
780 public void OnGeneric (string type)
783 // string t = Marshal.PtrToStringUni (type);
784 Console.Error.WriteLine ("Callback Generic:{0}", type);
786 EventHandler eh = (EventHandler) (owner.Events[WebBrowser.GenericEvent]);
788 EventArgs e = new EventArgs ();
801 internal delegate void CallbackVoid ();
803 internal delegate void CallbackString (string arg1);
804 internal delegate void CallbackWString ([MarshalAs(UnmanagedType.LPWStr)] string arg1);
806 internal delegate void CallbackStringString (string arg1, string arg2);
807 internal delegate void CallbackStringInt (string arg1, Int32 arg2);
808 internal delegate void CallbackWStringInt ([MarshalAs (UnmanagedType.LPWStr)] string arg1, Int32 arg2);
809 internal delegate void CallbackStringIntInt (string arg1, Int32 arg2, Int32 arg3);
810 internal delegate void CallbackStringIntUint (string arg1, Int32 arg2, UInt32 arg3);
813 internal delegate void CallbackIntInt (Int32 arg1, Int32 arg2);
814 internal delegate void CallbackIntUint (Int32 arg2, UInt32 arg3);
816 internal delegate void CallbackUint (UInt32 arg1);
817 internal delegate void CallbackUintInt (UInt32 arg1, Int32 arg2);
819 internal delegate void CallbackPtrPtr (IntPtr arg1, IntPtr arg2);
821 //Don't have to worry about marshalling bool, PRBool seems very constant and uses 4 bit int underneath
822 internal delegate void CallbackBool (bool val);
824 internal delegate bool KeyCallback (KeyInfo keyInfo, ModifierKeys modifiers, [MarshalAs (UnmanagedType.Interface)] nsIDOMNode target);
825 internal delegate bool MouseCallback (MouseInfo mouseInfo, ModifierKeys modifiers, [MarshalAs (UnmanagedType.Interface)] nsIDOMNode target);
827 internal delegate void GenericCallback (IntPtr type);
830 internal delegate bool Callback2 ();
831 internal delegate bool Callback2String (string arg1);
834 internal delegate bool CallbackOnAlertCheck (IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState);
835 internal delegate bool CallbackOnConfirm (IntPtr title, IntPtr text);
836 internal delegate bool CallbackOnConfirmCheck (IntPtr title, IntPtr text, IntPtr chkMsg, ref bool chkState);
837 internal delegate bool CallbackOnConfirmEx (IntPtr title, IntPtr text, Mono.WebBrowser.DialogButtonFlags flags,
838 IntPtr title0, IntPtr title1, IntPtr title2,
839 IntPtr chkMsg, ref bool chkState, out Int32 retVal);
840 internal delegate bool CallbackOnPrompt (IntPtr title, IntPtr text,
842 internal delegate bool CallbackOnPromptUsernameAndPassword
843 (IntPtr title, IntPtr text,
844 IntPtr chkMsg, ref bool chkState,
845 out IntPtr username, out IntPtr password);
846 internal delegate bool CallbackOnPromptPassword
847 (IntPtr title, IntPtr text,
848 IntPtr chkMsg, ref bool chkState,
849 out IntPtr password);
850 internal delegate bool CallbackOnSelect (IntPtr title, IntPtr text,
851 UInt32 count, IntPtr list,
854 internal delegate void CallbackOnLocationChanged ([MarshalAs (UnmanagedType.Interface)] nsIWebProgress progress,
855 [MarshalAs (UnmanagedType.Interface)] nsIRequest request,
856 [MarshalAs (UnmanagedType.Interface)] nsIURI uri);
858 internal delegate void CallbackOnStatusChange ([MarshalAs (UnmanagedType.Interface)] nsIWebProgress progress,
859 [MarshalAs (UnmanagedType.Interface)] nsIRequest request,
860 [MarshalAs (UnmanagedType.LPWStr)] string message, Int32 status);
862 internal delegate void CallbackOnSecurityChange ([MarshalAs (UnmanagedType.Interface)] nsIWebProgress progress,
863 [MarshalAs (UnmanagedType.Interface)] nsIRequest request,
866 internal delegate void CallbackOnStateChange ([MarshalAs (UnmanagedType.Interface)] nsIWebProgress progress,
867 [MarshalAs (UnmanagedType.Interface)] nsIRequest request,
868 Int32 arg2, UInt32 arg3);
869 internal delegate void CallbackOnProgress ([MarshalAs (UnmanagedType.Interface)] nsIWebProgress progress,
870 [MarshalAs (UnmanagedType.Interface)] nsIRequest request,
871 Int32 arg2, Int32 arg3);
873 internal delegate void CallbackOnShowContextMenu (UInt32 contextFlags,
874 [MarshalAs (UnmanagedType.Interface)] nsIDOMEvent eve,
875 [MarshalAs (UnmanagedType.Interface)] nsIDOMNode node);
884 [StructLayout (LayoutKind.Sequential)]
885 internal struct CallbackBinder {
887 public CallbackVoid OnWidgetLoaded;
889 public CallbackOnStateChange OnStateChange;
890 public CallbackOnProgress OnProgress;
891 public CallbackOnLocationChanged OnLocationChanged;
893 public CallbackOnStatusChange OnStatusChange;
894 public CallbackOnSecurityChange OnSecurityChange;
896 public KeyCallback OnKeyDown;
897 public KeyCallback OnKeyUp;
898 public KeyCallback OnKeyPress;
900 public MouseCallback OnMouseDown;
901 public MouseCallback OnMouseUp;
902 public MouseCallback OnMouseClick;
903 public MouseCallback OnMouseDoubleClick;
904 public MouseCallback OnMouseOver;
905 public MouseCallback OnMouseOut;
907 public Callback2 OnActivate;
908 public Callback2 OnFocus;
909 public Callback2 OnBlur;
911 public CallbackPtrPtr OnAlert;
912 public CallbackOnAlertCheck OnAlertCheck;
913 public CallbackOnConfirm OnConfirm;
914 public CallbackOnConfirmCheck OnConfirmCheck;
915 public CallbackOnConfirmEx OnConfirmEx;
916 public CallbackOnPrompt OnPrompt;
917 public CallbackOnPromptUsernameAndPassword OnPromptUsernameAndPassword;
918 public CallbackOnPromptPassword OnPromptPassword;
919 public CallbackOnSelect OnSelect;
921 public CallbackVoid OnLoad;
922 public CallbackVoid OnUnload;
924 public CallbackOnShowContextMenu OnShowContextMenu;
926 public CallbackWString OnGeneric;
928 internal CallbackBinder (Callback callback) {
929 this.OnWidgetLoaded = new CallbackVoid (callback.OnWidgetLoaded);
931 this.OnStateChange = new CallbackOnStateChange (callback.OnStateChange);
933 this.OnProgress = new CallbackOnProgress (callback.OnProgress);
934 this.OnLocationChanged = new CallbackOnLocationChanged (callback.OnLocationChanged);
935 this.OnStatusChange = new CallbackOnStatusChange (callback.OnStatusChange);
936 this.OnSecurityChange = new CallbackOnSecurityChange (callback.OnSecurityChange);
938 this.OnKeyDown = new KeyCallback (callback.OnClientDomKeyDown);
939 this.OnKeyUp = new KeyCallback (callback.OnClientDomKeyUp);
940 this.OnKeyPress = new KeyCallback (callback.OnClientDomKeyPress);
942 this.OnMouseDown = new MouseCallback (callback.OnClientMouseDown);
943 this.OnMouseUp = new MouseCallback (callback.OnClientMouseUp);
944 this.OnMouseClick = new MouseCallback (callback.OnClientMouseClick);
945 this.OnMouseDoubleClick = new MouseCallback (callback.OnClientMouseDoubleClick);
946 this.OnMouseOver = new MouseCallback (callback.OnClientMouseOver);
947 this.OnMouseOut = new MouseCallback (callback.OnClientMouseOut);
949 this.OnActivate = new Callback2 (callback.OnClientActivate);
950 this.OnFocus = new Callback2 (callback.OnClientFocus);
951 this.OnBlur = new Callback2 (callback.OnClientBlur);
953 this.OnAlert = new CallbackPtrPtr (callback.OnAlert);
954 this.OnAlertCheck = new CallbackOnAlertCheck (callback.OnAlertCheck);
955 this.OnConfirm = new CallbackOnConfirm (callback.OnConfirm);
956 this.OnConfirmCheck = new CallbackOnConfirmCheck (callback.OnConfirmCheck);
957 this.OnConfirmEx = new CallbackOnConfirmEx (callback.OnConfirmEx);
958 this.OnPrompt = new CallbackOnPrompt (callback.OnPrompt);
959 this.OnPromptUsernameAndPassword = new CallbackOnPromptUsernameAndPassword (callback.OnPromptUsernameAndPassword);
960 this.OnPromptPassword = new CallbackOnPromptPassword (callback.OnPromptPassword);
961 this.OnSelect = new CallbackOnSelect (callback.OnSelect);
963 this.OnLoad = new CallbackVoid (callback.OnLoad);
964 this.OnUnload = new CallbackVoid (callback.OnUnload);
966 this.OnShowContextMenu = new CallbackOnShowContextMenu (callback.OnShowContextMenu);
968 this.OnGeneric = new CallbackWString (callback.OnGeneric);
973 [StructLayout (LayoutKind.Sequential)]
974 internal struct SizeInfo
977 public UInt32 height;
980 [StructLayout (LayoutKind.Sequential)]
981 internal struct ModifierKeys
984 public Int32 ctrlKey;
985 public Int32 metaKey;
986 public Int32 shiftKey;
989 [StructLayout (LayoutKind.Sequential)]
990 internal struct MouseInfo
992 public UInt16 button;
993 public Int32 clientX;
994 public Int32 clientY;
995 public Int32 screenX;
996 public Int32 screenY;
999 [StructLayout (LayoutKind.Sequential)]
1000 internal struct KeyInfo
1002 public UInt32 charCode;
1003 public UInt32 keyCode;
1007 internal enum StateFlags
1015 IsDocument = 131072,
1018 Restoring = 16777216,
1022 SecureHigh = 262144,