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 _negotiating
= (state
& (uint) StateFlags
.Negotiating
) != 0;
101 bool _transferring
= (state
& (uint) StateFlags
.Transferring
) != 0;
102 bool _redirecting
= (state
& (uint) StateFlags
.Redirecting
) != 0;
103 bool _stop
= (state
& (uint) StateFlags
.Stop
) != 0;
104 bool _request
= (state
& (uint) StateFlags
.IsRequest
) != 0;
105 bool _document
= (state
& (uint) StateFlags
.IsDocument
) != 0;
106 bool _network
= (state
& (uint) StateFlags
.IsNetwork
) != 0;
107 bool _window
= (state
& (uint) StateFlags
.IsWindow
) != 0;
109 if (_start
&& _request
&& _document
&& !calledLoadStarted
) {
111 progress
.getDOMWindow (out win
);
112 nsIChannel channel
= (nsIChannel
) request
;
114 channel
.getURI (out uri
);
116 currentUri
= "about:blank";
118 AsciiString spec
= new AsciiString (String
.Empty
);
119 uri
.getSpec (spec
.Handle
);
120 currentUri
= spec
.ToString ();
123 calledLoadStarted
= true;
124 LoadStartedEventHandler eh
= (LoadStartedEventHandler
) (owner
.Events
[WebBrowser
.LoadStartedEvent
]);
127 AsciiString name
= new AsciiString (String
.Empty
);
128 win
.getName (name
.Handle
);
130 LoadStartedEventArgs e
= new LoadStartedEventArgs (currentUri
, name
.ToString ());
133 request
.cancel (2152398850); //NS_BINDING_ABORTED
139 if (_document
&& _request
&& _transferring
) {
141 progress
.getDOMWindow (out win
);
142 nsIChannel channel
= (nsIChannel
) request
;
144 channel
.getURI (out uri
);
146 currentUri
= "about:blank";
148 AsciiString spec
= new AsciiString (String
.Empty
);
149 uri
.getSpec (spec
.Handle
);
150 currentUri
= spec
.ToString ();
154 win
.getTop (out topWin
);
155 if (topWin
== null || topWin
.GetHashCode () == win
.GetHashCode ()) {
158 win
.getDocument (out doc
);
160 owner
.document
= new Mono
.Mozilla
.DOM
.Document (owner
, doc
);
163 LoadCommitedEventHandler eh
= (LoadCommitedEventHandler
) (owner
.Events
[WebBrowser
.LoadCommitedEvent
]);
165 LoadCommitedEventArgs e
= new LoadCommitedEventArgs (currentUri
);
171 if (_document
&& _request
&& _redirecting
) {
173 progress
.getDOMWindow (out win
);
174 nsIChannel channel
= (nsIChannel
) request
;
176 channel
.getURI (out uri
);
178 currentUri
= "about:blank";
180 AsciiString spec
= new AsciiString (String
.Empty
);
181 uri
.getSpec (spec
.Handle
);
182 currentUri
= spec
.ToString ();
187 if (_stop
&& !_request
&& !_document
&& _network
&& _window
) {
188 calledLoadStarted
= false;
189 LoadFinishedEventHandler eh1
= (LoadFinishedEventHandler
) (owner
.Events
[WebBrowser
.LoadFinishedEvent
]);
193 progress
.getDOMWindow (out win
);
194 LoadFinishedEventArgs e
= new LoadFinishedEventArgs (currentUri
);
201 if (_stop
&& !_request
&& _document
&& !_network
&& !_window
) {
203 progress
.getDOMWindow (out win
);
205 win
.getDocument (out doc
);
207 int hash
= doc
.GetHashCode ();
208 if (owner
.documents
.ContainsKey (hash
)) {
209 DOM
.Document document
= owner
.documents
[hash
] as DOM
.Document
;
211 EventHandler eh1
= (EventHandler
)(document
.Events
[DOM
.Document
.LoadStoppedEvent
]);
216 calledLoadStarted
= false;
220 Console
.Error
.WriteLine ("{0} completed", s
.ToString ());
224 public void OnProgress (nsIWebProgress progress
, nsIRequest request
, Int32 currentTotalProgress
, Int32 maxTotalProgress
)
227 OnGeneric ("OnProgress");
229 ProgressChangedEventHandler eh
= (ProgressChangedEventHandler
) (owner
.Events
[Mono
.Mozilla
.WebBrowser
.ProgressChangedEvent
]);
231 Mono
.WebBrowser
.ProgressChangedEventArgs e
= new Mono
.WebBrowser
.ProgressChangedEventArgs (currentTotalProgress
, maxTotalProgress
);
236 public void OnLocationChanged (nsIWebProgress progress
, nsIRequest request
, nsIURI uri
)
239 OnGeneric ("OnLocationChanged");
243 public void OnStatusChange (nsIWebProgress progress
, nsIRequest request
, string message
, Int32 status
)
245 StatusChangedEventHandler eh
= (StatusChangedEventHandler
) (owner
.Events
[WebBrowser
.StatusChangedEvent
]);
247 StatusChangedEventArgs e
= new StatusChangedEventArgs (message
, status
);
252 public void OnSecurityChange (nsIWebProgress progress
, nsIRequest request
, uint status
)
254 SecurityChangedEventHandler eh
= (SecurityChangedEventHandler
) (owner
.Events
[WebBrowser
.SecurityChangedEvent
]);
256 SecurityLevel state
= SecurityLevel
.Insecure
;
259 state
= SecurityLevel
.Insecure
;
262 state
= SecurityLevel
.Mixed
;
265 state
= SecurityLevel
.Secure
;
269 SecurityChangedEventArgs e
= new SecurityChangedEventArgs (state
);
274 public bool OnClientDomKeyDown (KeyInfo keyInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
277 OnGeneric ("OnClientDomKeyDown");
278 Console
.Error
.WriteLine ("OnClientDomKeyDown");
280 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
281 string key
= String
.Intern (node
.GetHashCode () + ":keydown");
282 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
284 EventArgs e1
= new EventArgs ();
288 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.KeyDownEvent
]);
290 NodeEventArgs e
= new NodeEventArgs (node
);
297 public bool OnClientDomKeyUp (KeyInfo keyInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
300 OnGeneric ("OnClientDomKeyUp");
301 Console
.Error
.WriteLine ("OnClientDomKeyUp");
303 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
304 string key
= String
.Intern (node
.GetHashCode () + ":keyup");
305 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
307 EventArgs e1
= new EventArgs ();
311 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.KeyUpEvent
]);
313 NodeEventArgs e
= new NodeEventArgs (node
);
320 public bool OnClientDomKeyPress (KeyInfo keyInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
323 OnGeneric ("OnClientDomKeyPress");
324 Console
.Error
.WriteLine ("OnClientDomKeyPress");
326 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
327 string key
= String
.Intern (node
.GetHashCode () + ":keypress");
328 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
330 EventArgs e1
= new EventArgs ();
334 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.KeyPressEvent
]);
336 NodeEventArgs e
= new NodeEventArgs (node
);
343 public bool OnClientMouseDown (MouseInfo mouseInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
346 OnGeneric ("OnClientMouseDown");
347 Console
.Error
.WriteLine ("OnClientMouseDown");
349 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
350 string key
= String
.Intern (node
.GetHashCode () + ":mousedown");
351 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
353 EventArgs e1
= new EventArgs ();
357 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.MouseDownEvent
]);
359 NodeEventArgs e
= new NodeEventArgs (node
);
366 public bool OnClientMouseUp (MouseInfo mouseInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
369 OnGeneric ("OnClientMouseUp");
370 Console
.Error
.WriteLine ("OnClientMouseUp");
372 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
373 string key
= String
.Intern (node
.GetHashCode () + ":mouseup");
374 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
376 EventArgs e1
= new EventArgs ();
380 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.MouseUpEvent
]);
382 NodeEventArgs e
= new NodeEventArgs (node
);
389 public bool OnClientMouseClick (MouseInfo mouseInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
392 OnGeneric ("OnClientMouseClick");
393 Console
.Error
.WriteLine ("OnClientMouseClick");
395 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
396 string key
= String
.Intern (node
.GetHashCode () + ":click");
397 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
399 EventArgs e1
= new EventArgs ();
403 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.MouseClickEvent
]);
405 NodeEventArgs e
= new NodeEventArgs (node
);
412 public bool OnClientMouseDoubleClick (MouseInfo mouseInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
415 OnGeneric ("OnClientMouseDoubleClick");
416 Console
.Error
.WriteLine ("OnClientMouseDoubleClick");
418 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
419 string key
= String
.Intern (node
.GetHashCode () + ":dblclick");
420 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
422 EventArgs e1
= new EventArgs ();
426 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.MouseDoubleClickEvent
]);
428 NodeEventArgs e
= new NodeEventArgs (node
);
435 public bool OnClientMouseOver (MouseInfo mouseInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
438 OnGeneric ("OnClientMouseOver");
439 Console
.Error
.WriteLine ("OnClientMouseOver");
441 DOM
.DOMObject helper
= new DOM
.DOMObject(this.owner
);
442 INode node
= helper
.GetTypedNode (target
);
443 string key
= String
.Intern (node
.GetHashCode () + ":mouseover");
444 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
446 EventArgs e1
= new EventArgs ();
450 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.MouseEnterEvent
]);
452 NodeEventArgs e
= new NodeEventArgs (node
);
459 public bool OnClientMouseOut (MouseInfo mouseInfo
, ModifierKeys modifiers
, nsIDOMNode target
)
462 OnGeneric ("OnClientMouseOut");
463 Console
.Error
.WriteLine ("OnClientMouseOut");
465 INode node
= new Mono
.Mozilla
.DOM
.Node (owner
, target
);
466 string key
= String
.Intern (node
.GetHashCode () + ":mouseout");
467 EventHandler eh1
= (EventHandler
) owner
.DomEvents
[key
];
469 EventArgs e1
= new EventArgs ();
473 NodeEventHandler eh
= (NodeEventHandler
) (owner
.Events
[WebBrowser
.MouseLeaveEvent
]);
475 NodeEventArgs e
= new NodeEventArgs (node
);
482 public bool OnClientActivate ()
485 OnGeneric ("OnClientActivate");
486 Console
.Error
.WriteLine ("OnClientActivate");
488 // TODO: Add WebBrowser.OnClientActivate implementation
492 public bool OnClientFocus ()
495 OnGeneric ("OnClientFocus");
496 Console
.Error
.WriteLine ("OnClientFocus");
498 EventHandler eh
= (EventHandler
) (owner
.Events
[WebBrowser
.FocusEvent
]);
500 EventArgs e
= new EventArgs ();
506 public bool OnClientBlur ()
509 OnGeneric ("OnClientBlur");
510 Console
.Error
.WriteLine ("OnClientBlur");
512 EventHandler eh
= (EventHandler
) (owner
.Events
[WebBrowser
.BlurEvent
]);
514 EventArgs e
= new EventArgs ();
520 public bool OnCreateNewWindow ()
525 OnGeneric ("OnCreateNewWindow");
526 Console
.Error
.WriteLine ("OnCreateNewWindow");
528 CreateNewWindowEventHandler eh
= (CreateNewWindowEventHandler
) (owner
.Events
[WebBrowser
.CreateNewWindowEvent
]);
530 CreateNewWindowEventArgs e
= new CreateNewWindowEventArgs (false);
536 public void OnAlert (IntPtr title
, IntPtr text
)
539 OnGeneric ("OnAlert");
540 Console
.Error
.WriteLine ("OnAlert");
542 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
544 AlertEventArgs e
= new AlertEventArgs ();
545 e
.Type
= DialogType
.Alert
;
546 if (title
!= IntPtr
.Zero
)
547 e
.Title
= Marshal
.PtrToStringUni (title
);
548 if (text
!= IntPtr
.Zero
)
549 e
.Text
= Marshal
.PtrToStringUni (text
);
554 public bool OnAlertCheck (IntPtr title
, IntPtr text
, IntPtr chkMsg
, ref bool chkState
)
557 OnGeneric ("OnAlertCheck");
558 Console
.Error
.WriteLine ("OnAlertCheck");
560 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
562 AlertEventArgs e
= new AlertEventArgs ();
563 e
.Type
= DialogType
.AlertCheck
;
564 if (title
!= IntPtr
.Zero
)
565 e
.Title
= Marshal
.PtrToStringUni (title
);
566 if (text
!= IntPtr
.Zero
)
567 e
.Text
= Marshal
.PtrToStringUni (text
);
568 if (chkMsg
!= IntPtr
.Zero
)
569 e
.CheckMessage
= Marshal
.PtrToStringUni (chkMsg
);
570 e
.CheckState
= chkState
;
577 public bool OnConfirm (IntPtr title
, IntPtr text
)
580 OnGeneric ("OnConfirm");
581 Console
.Error
.WriteLine ("OnConfirm");
583 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
585 AlertEventArgs e
= new AlertEventArgs ();
586 e
.Type
= DialogType
.Confirm
;
587 if (title
!= IntPtr
.Zero
)
588 e
.Title
= Marshal
.PtrToStringUni (title
);
589 if (text
!= IntPtr
.Zero
)
590 e
.Text
= Marshal
.PtrToStringUni (text
);
597 public bool OnConfirmCheck (IntPtr title
, IntPtr text
, IntPtr chkMsg
, ref bool chkState
)
600 OnGeneric ("OnConfirmCheck");
601 Console
.Error
.WriteLine ("OnConfirmCheck");
603 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
605 AlertEventArgs e
= new AlertEventArgs ();
606 e
.Type
= DialogType
.ConfirmCheck
;
607 if (title
!= IntPtr
.Zero
)
608 e
.Title
= Marshal
.PtrToStringUni (title
);
609 if (text
!= IntPtr
.Zero
)
610 e
.Text
= Marshal
.PtrToStringUni (text
);
611 if (chkMsg
!= IntPtr
.Zero
)
612 e
.CheckMessage
= Marshal
.PtrToStringUni (chkMsg
);
613 e
.CheckState
= chkState
;
615 chkState
= e
.CheckState
;
621 public bool OnConfirmEx (IntPtr title
, IntPtr text
, DialogButtonFlags flags
,
622 IntPtr title0
, IntPtr title1
, IntPtr title2
,
623 IntPtr chkMsg
, ref bool chkState
, out Int32 retVal
)
626 OnGeneric ("OnConfirmEx");
627 Console
.Error
.WriteLine ("OnConfirmEx");
631 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
633 AlertEventArgs e
= new AlertEventArgs ();
634 e
.Type
= DialogType
.ConfirmEx
;
635 if (title
!= IntPtr
.Zero
)
636 e
.Title
= Marshal
.PtrToStringUni (title
);
637 if (text
!= IntPtr
.Zero
)
638 e
.Text
= Marshal
.PtrToStringUni (text
);
639 if (chkMsg
!= IntPtr
.Zero
)
640 e
.CheckMessage
= Marshal
.PtrToStringUni (chkMsg
);
641 e
.CheckState
= chkState
;
643 chkState
= e
.CheckState
;
649 public bool OnPrompt (IntPtr title
, IntPtr text
, ref IntPtr retVal
)
652 OnGeneric ("OnPrompt");
653 Console
.Error
.WriteLine ("OnPrompt");
655 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
657 AlertEventArgs e
= new AlertEventArgs ();
658 e
.Type
= DialogType
.Prompt
;
659 if (title
!= IntPtr
.Zero
)
660 e
.Title
= Marshal
.PtrToStringUni (title
);
661 if (text
!= IntPtr
.Zero
)
662 e
.Text
= Marshal
.PtrToStringUni (text
);
663 if (retVal
!= IntPtr
.Zero
)
664 e
.Text2
= Marshal
.PtrToStringUni (retVal
);
666 retVal
= Marshal
.StringToHGlobalUni (e
.StringReturn
);
672 public bool OnPromptUsernameAndPassword (IntPtr title
, IntPtr text
, IntPtr chkMsg
, ref bool chkState
, out IntPtr username
, out IntPtr password
)
675 OnGeneric ("OnPromptUsernameAndPassword");
676 Console
.Error
.WriteLine ("OnPromptUsernameAndPassword");
678 username
= IntPtr
.Zero
;
679 password
= IntPtr
.Zero
;
680 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
682 AlertEventArgs e
= new AlertEventArgs ();
683 e
.Type
= DialogType
.PromptUsernamePassword
;
684 if (title
!= IntPtr
.Zero
)
685 e
.Title
= Marshal
.PtrToStringUni (title
);
686 if (text
!= IntPtr
.Zero
)
687 e
.Text
= Marshal
.PtrToStringUni (text
);
688 if (chkMsg
!= IntPtr
.Zero
)
689 e
.CheckMessage
= Marshal
.PtrToStringUni (chkMsg
);
690 e
.CheckState
= chkState
;
697 public bool OnPromptPassword (IntPtr title
, IntPtr text
, IntPtr chkMsg
, ref bool chkState
, out IntPtr password
)
700 OnGeneric ("OnPromptPassword");
701 Console
.Error
.WriteLine ("OnPromptPassword");
703 password
= IntPtr
.Zero
;
704 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
706 AlertEventArgs e
= new AlertEventArgs ();
707 e
.Type
= DialogType
.PromptPassword
;
708 if (title
!= IntPtr
.Zero
)
709 e
.Title
= Marshal
.PtrToStringUni (title
);
710 if (text
!= IntPtr
.Zero
)
711 e
.Text
= Marshal
.PtrToStringUni (text
);
712 if (chkMsg
!= IntPtr
.Zero
)
713 e
.CheckMessage
= Marshal
.PtrToStringUni (chkMsg
);
714 e
.CheckState
= chkState
;
721 public bool OnSelect (IntPtr title
, IntPtr text
, uint count
, IntPtr list
, out int retVal
)
724 OnGeneric ("OnSelect");
725 Console
.Error
.WriteLine ("OnSelect");
728 AlertEventHandler eh
= (AlertEventHandler
) (owner
.Events
[WebBrowser
.AlertEvent
]);
730 AlertEventArgs e
= new AlertEventArgs ();
731 e
.Type
= DialogType
.Select
;
732 if (title
!= IntPtr
.Zero
)
733 e
.Title
= Marshal
.PtrToStringUni (title
);
734 if (text
!= IntPtr
.Zero
)
735 e
.Text
= Marshal
.PtrToStringUni (text
);
742 public void OnLoad ()
745 OnGeneric ("OnLoad");
746 Console
.Error
.WriteLine ("OnLoad");
748 ((DOM
.Window
)owner
.Window
).OnLoad ();
751 public void OnUnload ()
754 OnGeneric ("OnUnload");
755 Console
.Error
.WriteLine ("OnUnload");
757 ((DOM
.Window
)owner
.Window
).OnUnload ();
760 public void OnShowContextMenu (UInt32 contextFlags
,
761 [MarshalAs (UnmanagedType
.Interface
)] nsIDOMEvent eve
,
762 [MarshalAs (UnmanagedType
.Interface
)] nsIDOMNode node
)
765 OnGeneric ("OnShowContextMenu");
766 Console
.Error
.WriteLine ("OnShowContextMenu");
768 ContextMenuEventHandler eh
= (ContextMenuEventHandler
) (owner
.Events
[WebBrowser
.ContextMenuEvent
]);
771 nsIDOMMouseEvent mouseEvent
= (nsIDOMMouseEvent
) eve
;
773 mouseEvent
.getClientX (out x
);
774 mouseEvent
.getClientY (out y
);
775 ContextMenuEventArgs args
= new ContextMenuEventArgs(x
, y
);
781 public void OnGeneric (string type
)
784 // string t = Marshal.PtrToStringUni (type);
785 Console
.Error
.WriteLine ("Callback Generic:{0}", type
);
787 EventHandler eh
= (EventHandler
) (owner
.Events
[WebBrowser
.GenericEvent
]);
789 EventArgs e
= new EventArgs ();
802 internal delegate void CallbackVoid ();
804 internal delegate void CallbackString (string arg1
);
805 internal delegate void CallbackWString ([MarshalAs(UnmanagedType
.LPWStr
)] string arg1
);
807 internal delegate void CallbackStringString (string arg1
, string arg2
);
808 internal delegate void CallbackStringInt (string arg1
, Int32 arg2
);
809 internal delegate void CallbackWStringInt ([MarshalAs (UnmanagedType
.LPWStr
)] string arg1
, Int32 arg2
);
810 internal delegate void CallbackStringIntInt (string arg1
, Int32 arg2
, Int32 arg3
);
811 internal delegate void CallbackStringIntUint (string arg1
, Int32 arg2
, UInt32 arg3
);
814 internal delegate void CallbackIntInt (Int32 arg1
, Int32 arg2
);
815 internal delegate void CallbackIntUint (Int32 arg2
, UInt32 arg3
);
817 internal delegate void CallbackUint (UInt32 arg1
);
818 internal delegate void CallbackUintInt (UInt32 arg1
, Int32 arg2
);
820 internal delegate void CallbackPtrPtr (IntPtr arg1
, IntPtr arg2
);
822 //Don't have to worry about marshalling bool, PRBool seems very constant and uses 4 bit int underneath
823 internal delegate void CallbackBool (bool val
);
825 internal delegate bool KeyCallback (KeyInfo keyInfo
, ModifierKeys modifiers
, [MarshalAs (UnmanagedType
.Interface
)] nsIDOMNode target
);
826 internal delegate bool MouseCallback (MouseInfo mouseInfo
, ModifierKeys modifiers
, [MarshalAs (UnmanagedType
.Interface
)] nsIDOMNode target
);
828 internal delegate void GenericCallback (IntPtr type
);
831 internal delegate bool Callback2 ();
832 internal delegate bool Callback2String (string arg1
);
835 internal delegate bool CallbackOnAlertCheck (IntPtr title
, IntPtr text
, IntPtr chkMsg
, ref bool chkState
);
836 internal delegate bool CallbackOnConfirm (IntPtr title
, IntPtr text
);
837 internal delegate bool CallbackOnConfirmCheck (IntPtr title
, IntPtr text
, IntPtr chkMsg
, ref bool chkState
);
838 internal delegate bool CallbackOnConfirmEx (IntPtr title
, IntPtr text
, Mono
.WebBrowser
.DialogButtonFlags flags
,
839 IntPtr title0
, IntPtr title1
, IntPtr title2
,
840 IntPtr chkMsg
, ref bool chkState
, out Int32 retVal
);
841 internal delegate bool CallbackOnPrompt (IntPtr title
, IntPtr text
,
843 internal delegate bool CallbackOnPromptUsernameAndPassword
844 (IntPtr title
, IntPtr text
,
845 IntPtr chkMsg
, ref bool chkState
,
846 out IntPtr username
, out IntPtr password
);
847 internal delegate bool CallbackOnPromptPassword
848 (IntPtr title
, IntPtr text
,
849 IntPtr chkMsg
, ref bool chkState
,
850 out IntPtr password
);
851 internal delegate bool CallbackOnSelect (IntPtr title
, IntPtr text
,
852 UInt32 count
, IntPtr list
,
855 internal delegate void CallbackOnLocationChanged ([MarshalAs (UnmanagedType
.Interface
)] nsIWebProgress progress
,
856 [MarshalAs (UnmanagedType
.Interface
)] nsIRequest request
,
857 [MarshalAs (UnmanagedType
.Interface
)] nsIURI uri
);
859 internal delegate void CallbackOnStatusChange ([MarshalAs (UnmanagedType
.Interface
)] nsIWebProgress progress
,
860 [MarshalAs (UnmanagedType
.Interface
)] nsIRequest request
,
861 [MarshalAs (UnmanagedType
.LPWStr
)] string message
, Int32 status
);
863 internal delegate void CallbackOnSecurityChange ([MarshalAs (UnmanagedType
.Interface
)] nsIWebProgress progress
,
864 [MarshalAs (UnmanagedType
.Interface
)] nsIRequest request
,
867 internal delegate void CallbackOnStateChange ([MarshalAs (UnmanagedType
.Interface
)] nsIWebProgress progress
,
868 [MarshalAs (UnmanagedType
.Interface
)] nsIRequest request
,
869 Int32 arg2
, UInt32 arg3
);
870 internal delegate void CallbackOnProgress ([MarshalAs (UnmanagedType
.Interface
)] nsIWebProgress progress
,
871 [MarshalAs (UnmanagedType
.Interface
)] nsIRequest request
,
872 Int32 arg2
, Int32 arg3
);
874 internal delegate void CallbackOnShowContextMenu (UInt32 contextFlags
,
875 [MarshalAs (UnmanagedType
.Interface
)] nsIDOMEvent eve
,
876 [MarshalAs (UnmanagedType
.Interface
)] nsIDOMNode node
);
885 [StructLayout (LayoutKind
.Sequential
)]
886 internal struct CallbackBinder
{
888 public CallbackVoid OnWidgetLoaded
;
890 public CallbackOnStateChange OnStateChange
;
891 public CallbackOnProgress OnProgress
;
892 public CallbackOnLocationChanged OnLocationChanged
;
894 public CallbackOnStatusChange OnStatusChange
;
895 public CallbackOnSecurityChange OnSecurityChange
;
897 public KeyCallback OnKeyDown
;
898 public KeyCallback OnKeyUp
;
899 public KeyCallback OnKeyPress
;
901 public MouseCallback OnMouseDown
;
902 public MouseCallback OnMouseUp
;
903 public MouseCallback OnMouseClick
;
904 public MouseCallback OnMouseDoubleClick
;
905 public MouseCallback OnMouseOver
;
906 public MouseCallback OnMouseOut
;
908 public Callback2 OnActivate
;
909 public Callback2 OnFocus
;
910 public Callback2 OnBlur
;
912 public CallbackPtrPtr OnAlert
;
913 public CallbackOnAlertCheck OnAlertCheck
;
914 public CallbackOnConfirm OnConfirm
;
915 public CallbackOnConfirmCheck OnConfirmCheck
;
916 public CallbackOnConfirmEx OnConfirmEx
;
917 public CallbackOnPrompt OnPrompt
;
918 public CallbackOnPromptUsernameAndPassword OnPromptUsernameAndPassword
;
919 public CallbackOnPromptPassword OnPromptPassword
;
920 public CallbackOnSelect OnSelect
;
922 public CallbackVoid OnLoad
;
923 public CallbackVoid OnUnload
;
925 public CallbackOnShowContextMenu OnShowContextMenu
;
927 public CallbackWString OnGeneric
;
929 internal CallbackBinder (Callback callback
) {
930 this.OnWidgetLoaded
= new CallbackVoid (callback
.OnWidgetLoaded
);
932 this.OnStateChange
= new CallbackOnStateChange (callback
.OnStateChange
);
934 this.OnProgress
= new CallbackOnProgress (callback
.OnProgress
);
935 this.OnLocationChanged
= new CallbackOnLocationChanged (callback
.OnLocationChanged
);
936 this.OnStatusChange
= new CallbackOnStatusChange (callback
.OnStatusChange
);
937 this.OnSecurityChange
= new CallbackOnSecurityChange (callback
.OnSecurityChange
);
939 this.OnKeyDown
= new KeyCallback (callback
.OnClientDomKeyDown
);
940 this.OnKeyUp
= new KeyCallback (callback
.OnClientDomKeyUp
);
941 this.OnKeyPress
= new KeyCallback (callback
.OnClientDomKeyPress
);
943 this.OnMouseDown
= new MouseCallback (callback
.OnClientMouseDown
);
944 this.OnMouseUp
= new MouseCallback (callback
.OnClientMouseUp
);
945 this.OnMouseClick
= new MouseCallback (callback
.OnClientMouseClick
);
946 this.OnMouseDoubleClick
= new MouseCallback (callback
.OnClientMouseDoubleClick
);
947 this.OnMouseOver
= new MouseCallback (callback
.OnClientMouseOver
);
948 this.OnMouseOut
= new MouseCallback (callback
.OnClientMouseOut
);
950 this.OnActivate
= new Callback2 (callback
.OnClientActivate
);
951 this.OnFocus
= new Callback2 (callback
.OnClientFocus
);
952 this.OnBlur
= new Callback2 (callback
.OnClientBlur
);
954 this.OnAlert
= new CallbackPtrPtr (callback
.OnAlert
);
955 this.OnAlertCheck
= new CallbackOnAlertCheck (callback
.OnAlertCheck
);
956 this.OnConfirm
= new CallbackOnConfirm (callback
.OnConfirm
);
957 this.OnConfirmCheck
= new CallbackOnConfirmCheck (callback
.OnConfirmCheck
);
958 this.OnConfirmEx
= new CallbackOnConfirmEx (callback
.OnConfirmEx
);
959 this.OnPrompt
= new CallbackOnPrompt (callback
.OnPrompt
);
960 this.OnPromptUsernameAndPassword
= new CallbackOnPromptUsernameAndPassword (callback
.OnPromptUsernameAndPassword
);
961 this.OnPromptPassword
= new CallbackOnPromptPassword (callback
.OnPromptPassword
);
962 this.OnSelect
= new CallbackOnSelect (callback
.OnSelect
);
964 this.OnLoad
= new CallbackVoid (callback
.OnLoad
);
965 this.OnUnload
= new CallbackVoid (callback
.OnUnload
);
967 this.OnShowContextMenu
= new CallbackOnShowContextMenu (callback
.OnShowContextMenu
);
969 this.OnGeneric
= new CallbackWString (callback
.OnGeneric
);
974 [StructLayout (LayoutKind
.Sequential
)]
975 internal struct SizeInfo
978 public UInt32 height
;
981 [StructLayout (LayoutKind
.Sequential
)]
982 internal struct ModifierKeys
985 public Int32 ctrlKey
;
986 public Int32 metaKey
;
987 public Int32 shiftKey
;
990 [StructLayout (LayoutKind
.Sequential
)]
991 internal struct MouseInfo
993 public UInt16 button
;
994 public Int32 clientX
;
995 public Int32 clientY
;
996 public Int32 screenX
;
997 public Int32 screenY
;
1000 [StructLayout (LayoutKind
.Sequential
)]
1001 internal struct KeyInfo
1003 public UInt32 charCode
;
1004 public UInt32 keyCode
;
1008 internal enum StateFlags
1016 IsDocument
= 131072,
1019 Restoring
= 16777216,
1023 SecureHigh
= 262144,