Author: andreia
Date: 2008-01-24 13:06:18 -0500 (Thu, 24 Jan 2008)
New Revision: 93825

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlDocument.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElement.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElementCollection.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlHistory.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindow.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindowCollection.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowser.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowserBase.cs
Log:
* HtmlDocument.cs:
- Save a reference to the IDocument in the instance and
  use that one instead of going to WebHost.Document; the document that the 
  WebHost returns might not be the right one (in case of frames).
- Use the hashcode returned from the IDocument interface.
- Implemented: ActiveElement, ActiveLinkColor, All, BackColor, Cookie, 
  Domain (setter is not supported), Encoding, ForeColor, Forms, Images, 
  LinkColor, Url, VisitedColor, Window

* HtmlElement.cs: 
- Implemented: CanHaveChildren, Children, Document, GetAttribute, 
  set_Attribute, NextSibling, Parent, TagName, AppendChild, 
  GetElementsByTagName, GetHashCode, HasAttribute, InsertAdjacentElement,
  SetAttribute, Equals, equality operators.
- Added stubs for: AttachEventHandler, DetachEventHandler, Focus, 
  InvokeMember, RaiseEvent, RemoveFocus, ScrollIntoView, 

* HtmlElementCollection.cs: Change implementation to use a generic
collection. Implemented Enumerator and CopyTo

* HtmlHistory.cs: Add constructor, no implementation yet.

* HtmlWindow.cs: Initial implementation with: Name, Parent, Alert,
Confirm, Prompt, Navigation, ScrollTo, Open, OpenNew, GetHashCode, 
Equals, equality operators.

* HtmlWindowCollection.cs: Implemented. 

* WebBrowser.cs: Use the Navigation object to navigate (WebHost.Navigate
has been deprecated).

* WebBrowserBase.cs: Use Completed event to track document loading
(Navigated has been deprecated)

2008-01-24  Andreia Gaita <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2008-01-24 18:05:12 UTC (rev 93824)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2008-01-24 18:06:18 UTC (rev 93825)
@@ -1,3 +1,39 @@
+2008-01-24  Andreia Gaita <[EMAIL PROTECTED]>
+
+       * HtmlDocument.cs:
+       - Save a reference to the IDocument in the instance and
+         use that one instead of going to WebHost.Document; the document that 
the 
+         WebHost returns might not be the right one (in case of frames).
+       - Use the hashcode returned from the IDocument interface.
+       - Implemented: ActiveElement, ActiveLinkColor, All, BackColor, Cookie, 
+         Domain (setter is not supported), Encoding, ForeColor, Forms, Images, 
+         LinkColor, Url, VisitedColor, Window
+
+       * HtmlElement.cs: 
+       - Implemented: CanHaveChildren, Children, Document, GetAttribute, 
+         set_Attribute, NextSibling, Parent, TagName, AppendChild, 
+         GetElementsByTagName, GetHashCode, HasAttribute, 
InsertAdjacentElement,
+         SetAttribute, Equals, equality operators.
+       - Added stubs for: AttachEventHandler, DetachEventHandler, Focus, 
+         InvokeMember, RaiseEvent, RemoveFocus, ScrollIntoView, 
+       
+       * HtmlElementCollection.cs: Change implementation to use a generic
+       collection. Implemented Enumerator and CopyTo
+
+       * HtmlHistory.cs: Add constructor, no implementation yet.
+
+       * HtmlWindow.cs: Initial implementation with: Name, Parent, Alert,
+       Confirm, Prompt, Navigation, ScrollTo, Open, OpenNew, GetHashCode, 
+       Equals, equality operators.
+
+       * HtmlWindowCollection.cs: Implemented. 
+
+       * WebBrowser.cs: Use the Navigation object to navigate (WebHost.Navigate
+       has been deprecated).
+
+       * WebBrowserBase.cs: Use Completed event to track document loading
+       (Navigated has been deprecated)
+
 2008-01-24  Jonatham Pobst  <[EMAIL PROTECTED]>
 
        * ThemeWin32Classic.cs: Add tab stops and NoWrap to dropdown MenuItems. 
 Top

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlDocument.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlDocument.cs  
2008-01-24 18:05:12 UTC (rev 93824)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlDocument.cs  
2008-01-24 18:06:18 UTC (rev 93825)
@@ -17,7 +17,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2007 Novell, Inc.
+// Copyright (c) 2007, 2008 Novell, Inc.
 //
 // Authors:
 //     Andreia Gaita   <[EMAIL PROTECTED]>
@@ -26,29 +26,40 @@
 
 using System;
 using System.Drawing;
-using System.ComponentModel;
+using System.ComponentModel;
+using System.Globalization;
+using Mono.WebBrowser.DOM;
 
 namespace System.Windows.Forms
 {
        [MonoTODO ("Needs Implementation")]
        public sealed class HtmlDocument
        {
-               Mono.WebBrowser.IWebBrowser webHost;
-               internal HtmlDocument (Mono.WebBrowser.IWebBrowser webHost)
+               Mono.WebBrowser.IWebBrowser webHost;
+               IDocument document;
+
+               internal HtmlDocument (Mono.WebBrowser.IWebBrowser webHost) : 
this (webHost, webHost.Document)
                {
+               }
+
+               internal HtmlDocument (Mono.WebBrowser.IWebBrowser webHost, 
IDocument doc)
+               {
                        this.webHost = webHost;
+                       this.document = doc;
                }
-
+
                #region Methods
 
 
                public void AttachEventHandler (string eventName, EventHandler 
eventHandler)
-               { }
+               { 
+                       throw new NotImplementedException ();
+               }
 
                public HtmlElement CreateElement (string elementTag) 
                { 
-                       Mono.WebBrowser.DOM.IElement element = 
webHost.Document.CreateElement (elementTag);
-                       return new HtmlElement (element);
+                       Mono.WebBrowser.DOM.IElement element = 
document.CreateElement (elementTag);
+                       return new HtmlElement (webHost, element);
                }
 
                public void DetachEventHandler (string eventName, EventHandler 
eventHandler) 
@@ -73,26 +84,26 @@
 
                public HtmlElement GetElementById (string id)
                {
-                       return new HtmlElement (webHost.Document.GetElementById 
(id));
+                       return new HtmlElement (webHost, 
document.GetElementById (id));
                }
 
                public HtmlElement GetElementFromPoint (Point point) 
                {
-                       Mono.WebBrowser.DOM.IElement elem = 
webHost.Document.GetElement (point.X, point.Y);
+                       Mono.WebBrowser.DOM.IElement elem = document.GetElement 
(point.X, point.Y);
                        if (elem != null)
-                               return new HtmlElement(elem);
+                               return new HtmlElement(webHost, elem);
                        return null;
                }
 
                public HtmlElementCollection GetElementsByTagName (string 
tagName) 
                {
-                       Mono.WebBrowser.DOM.IElementCollection col = 
webHost.Document.GetElementsByTagName (tagName);
-                       return new HtmlElementCollection (col);
+                       Mono.WebBrowser.DOM.IElementCollection col = 
document.GetElementsByTagName (tagName);
+                       return new HtmlElementCollection (webHost, col);
                }
 
                public override int GetHashCode () 
                { 
-                       return base.GetHashCode (); 
+                       return document.GetHashCode (); 
                }
 
                public Object InvokeScript (string scriptName)
@@ -133,87 +144,121 @@
 
                public void Write (string text) 
                {
-                       webHost.Document.Write (text);
+                       document.Write (text);
                }
 
                #endregion
 
                #region Properties
-               [MonoTODO ("Needs Implementation")]
-
-               public HtmlElement ActiveElement
-               {
-                       get { throw new NotImplementedException (); }
+               public HtmlElement ActiveElement {
+                       get { 
+                               Mono.WebBrowser.DOM.IElement element = 
document.Active;
+                               if (element == null)
+                                       return null;
+                               return new HtmlElement (webHost, element);
+                       
+                       }
                }
                public Color ActiveLinkColor {
-                       get { throw new NotImplementedException ();}
-                       set { throw new NotImplementedException (); } 
+                       get { return ParseColor(document.ActiveLinkColor); }
+                       set { document.ActiveLinkColor = 
value.ToArgb().ToString(); }
                }
 
                public HtmlElementCollection All
                {
-                       get { throw new NotImplementedException (); }
+                       get {
+                               return new HtmlElementCollection (webHost, 
document.DocumentElement.All);
+                       }
                }
 
                public Color BackColor
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
-               }
+                       get { return ParseColor(document.BackColor); }
+                       set { document.BackColor = value.ToArgb().ToString(); }
+               }
+               
                public HtmlElement Body {
-                       get { return new HtmlElement (webHost.Document.Body); }
+                       get { return new HtmlElement (webHost, document.Body); }
                }
                public string Cookie
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return document.Cookie; }
+                       set { document.Cookie = value; }
                }
                public string DefaultEncoding { get { throw new 
NotImplementedException (); } }
                public string Domain
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return document.Domain; }
+                       set { throw new NotSupportedException ("Setting the 
domain is not supported per the DOM Level 2 HTML specification. Sorry."); }
                }
-               public Object DomDocument { get { throw new 
NotImplementedException (); } }
+               public Object DomDocument { get { throw new 
NotImplementedException (); } }
+               
                public string Encoding
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return document.Charset; }
+                       set { document.Charset = value; }
                }
+
                public bool Focused { get { throw new NotImplementedException 
(); } }
                public Color ForeColor
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return ParseColor(document.ForeColor); }
+                       set { document.ForeColor = value.ToArgb().ToString(); }
                }
-               public HtmlElementCollection Forms { get { throw new 
NotImplementedException (); } }
-               public HtmlElementCollection Images { get { throw new 
NotImplementedException (); } }
+               
+               public HtmlElementCollection Forms { 
+                       get { return new HtmlElementCollection (webHost, 
document.Forms); } 
+               }
+               
+               public HtmlElementCollection Images { 
+                       get { return new HtmlElementCollection (webHost, 
document.Images); }    
+               }
                public Color LinkColor
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return ParseColor(document.LinkColor); }
+                       set { document.LinkColor = value.ToArgb().ToString(); }
                }
-               public HtmlElementCollection Links { get { throw new 
NotImplementedException (); } }
+               
+               public HtmlElementCollection Links {
+                       get { return new HtmlElementCollection (webHost, 
document.Links); } 
+               }
+               
                public bool RightToLeft
                {
                        get { throw new NotImplementedException (); }
                        set { throw new NotImplementedException (); }
-               }
+               }
+               
                public string Title
                {
-                       get { return webHost.Document.Title; }
-                       set { webHost.Document.Title = value; }
+                       get { return document.Title; }
+                       set { document.Title = value; }
                }
-               public Uri Url { get { throw new NotImplementedException (); } }
+               
+               public Uri Url { 
+                       get { return new Uri (document.Url); } 
+               }
+               
                public Color VisitedLinkColor
                {
-                       get { throw new NotImplementedException (); }
-                       set { throw new NotImplementedException (); }
+                       get { return ParseColor(document.VisitedLinkColor); }
+                       set { document.VisitedLinkColor =  
value.ToArgb().ToString(); }
                }
-               public HtmlWindow Window { get { throw new 
NotImplementedException (); } }
+               
+               public HtmlWindow Window { 
+                       get { return new HtmlWindow (webHost, webHost.Window); 
} 
+               
+               }
 
 
-               #endregion
+               #endregion
+               
+               private Color ParseColor (string color) {
+                       if (color.IndexOf ("#") >= 0) {
+                               return Color.FromArgb (int.Parse 
(color.Substring (color.IndexOf ("#") + 1), NumberStyles.HexNumber));
+                       }
+                       return Color.FromName (color);
+               }
        }
 }
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElement.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElement.cs   
2008-01-24 18:05:12 UTC (rev 93824)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElement.cs   
2008-01-24 18:06:18 UTC (rev 93825)
@@ -17,7 +17,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2007 Novell, Inc.
+// Copyright (c) 2007, 2008 Novell, Inc.
 //
 // Authors:
 //     Andreia Gaita   <[EMAIL PROTECTED]>
@@ -31,21 +31,61 @@
 {
        [MonoTODO ("Needs Implementation")]
        public sealed class HtmlElement
-       {
-               private IElement element;
-               internal HtmlElement (IElement element)
-               {
+       {
+               private Mono.WebBrowser.IWebBrowser webHost;
+               internal IElement element;
+               internal HtmlElement (Mono.WebBrowser.IWebBrowser webHost, 
IElement element)
+               {
+                       this.webHost = webHost;
                        this.element = element;
                }
 
                #region Properties
-               public HtmlElementCollection All
-               {
+               public HtmlElementCollection All {
                        get {
-                               return new HtmlElementCollection 
(this.element.All);
+                               return new HtmlElementCollection (webHost, 
this.element.All);
                        }
                }
+
+               // from http://www.w3.org/TR/html401/index/elements.html
+               public bool CanHaveChildren {
+                       get {
+                               string tag = this.TagName;
+                               switch (tag.ToLower ()) {
+                                       case "area":
+                                       case "base":
+                                       case "basefont":
+                                       case "br":
+                                       case "col":
+                                       case "frame":
+                                       case "hr":
+                                       case "img":
+                                       case "input":
+                                       case "isindex":
+                                       case "link":
+                                       case "meta":
+                                       case "param":
+                                               return false;
+                                       break;
+                                       default:
+                                               return true;
+                                               break;
+                               }
+                       }
+               }
 
+               public HtmlElementCollection Children {
+                       get {
+                               return new HtmlElementCollection (webHost, 
this.element.Children);
+                       }
+               }
+               
+               public HtmlDocument Document {
+                       get {
+                               return new HtmlDocument (webHost, 
element.Owner);
+                       }
+               }
+
                public string InnerHtml
                {
                        get { return this.element.InnerHTML; }
@@ -60,18 +100,145 @@
 
                public string Id
                {
-                       get { return element.GetAttribute ("id"); }
+                       get { return GetAttribute("id"); }
+                       set { SetAttribute ("id", value); }
                }
 
                public string Name
                {
-                       get { return element.GetAttribute ("name"); }
+                       get { return GetAttribute ("name"); }
+                       set { SetAttribute ("name", value); }
                }
 
                public HtmlElement FirstChild
                {
-                       get { return new HtmlElement 
((IElement)element.FirstChild); }
+                       get { return new HtmlElement (webHost, 
(IElement)element.FirstChild); }
+               }
+
+               public HtmlElement NextSibling {
+                       get { return new HtmlElement (webHost, 
(IElement)element.Next); }
+               }
+               
+               public HtmlElement Parent {
+                       get { return new HtmlElement (webHost, 
(IElement)element.Parent); }
+               }
+
+               public string TagName {
+                       get { return element.TagName; }
                }
+               #endregion
+               
+               #region Methods
+               public HtmlElement AppendChild (HtmlElement child)
+               {
+                       IElement newChild = this.element.AppendChild 
(child.element);
+                       child.element = newChild;
+                       return child;
+               }
+               
+               public void AttachEventHandler (string eventName, EventHandler 
eventHandler)
+               { 
+                       throw new NotImplementedException ();
+               }
+
+               public void DetachEventHandler (string eventName, EventHandler 
eventHandler) 
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               public void Focus () 
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public string GetAttribute (string name) {
+                       return element.GetAttribute (name);
+               }
+
+               public HtmlElementCollection GetElementsByTagName (string 
tagName) 
+               {
+                       Mono.WebBrowser.DOM.IElementCollection col = 
element.GetElementsByTagName (tagName);
+                       return new HtmlElementCollection (webHost, col);
+               }               
+               
+               public override int GetHashCode () 
+               { 
+                       return element.GetHashCode (); 
+               }
+
+               internal bool HasAttribute (string name) {
+                       return element.HasAttribute (name);
+               }
+
+               public HtmlElement InsertAdjacentElement 
(HtmlElementInsertionOrientation orientation, HtmlElement newElement) {
+                       
+                       switch (orientation) {
+                               case 
HtmlElementInsertionOrientation.BeforeBegin:
+                                       IElement newChild1 = 
this.element.Parent.InsertBefore (newElement.element, this.element);
+                                       newElement.element = newChild1;
+                                       return newElement;                      
                
+                               break;
+                               case HtmlElementInsertionOrientation.AfterBegin:
+                                       IElement newChild2 = 
this.element.InsertBefore (newElement.element, this.element.FirstChild);
+                                       newElement.element = newChild2;
+                                       return newElement;                      
                
+                               break;
+                               case HtmlElementInsertionOrientation.BeforeEnd:
+                                       return this.AppendChild (newElement);   
                                
+                               break;
+                               case HtmlElementInsertionOrientation.AfterEnd:
+                                       return this.AppendChild (newElement);
+                               break;
+                       }
+                       return null;
+               }
+               
+               public object InvokeMember (string method) {
+                       throw new NotImplementedException ();
+               }
                
+               public object InvokeMember (string method, object[] parameters) 
{
+                       throw new NotImplementedException ();
+               }
+               
+               public void RaiseEvent (string name) 
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void RemoveFocus () 
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public void ScrollIntoView (bool alignWithTop) 
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               public void SetAttribute (string name, string value)
+               {
+                       this.element.SetAttribute (name, value);
+               }
+
+               public override bool Equals (object obj) {
+                       return this == (HtmlElement) obj;
+               }
+               
+               public static bool operator ==(HtmlElement left, HtmlElement 
right) {
+                       if ((object)left == (object)right) {
+                               return true;
+                       }
+
+                       if ((object)left == null || (object)right == null) {
+                               return false;
+                       }
+
+                       return left.Equals (right); 
+               }
+
+               public static bool operator !=(HtmlElement left, HtmlElement 
right) {
+                       return !(left == right);
+               }
                #endregion
 
        }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElementCollection.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElementCollection.cs
 2008-01-24 18:05:12 UTC (rev 93824)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElementCollection.cs
 2008-01-24 18:06:18 UTC (rev 93825)
@@ -17,101 +17,88 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2007 Novell, Inc.
+// Copyright (c) 2007, 2008 Novell, Inc.
 //
 // Authors:
 //     Andreia Gaita   <[EMAIL PROTECTED]>
 
 #if NET_2_0
 
-using System;
+using System;
 using System.Collections;
+using System.Collections.Generic;
 using Mono.WebBrowser.DOM;
 
 namespace System.Windows.Forms
 {
-       [MonoTODO ("Needs Implementation")]
        public sealed class HtmlElementCollection: ICollection, IEnumerable
        {
-               private IElementCollection collection;
-               private HtmlElement[] elements;
+               private List<HtmlElement> elements;
+               private Mono.WebBrowser.IWebBrowser webHost;
 
-               internal HtmlElementCollection (IElementCollection col)
-               {
-                       collection = col;
+               internal HtmlElementCollection (Mono.WebBrowser.IWebBrowser 
webHost, IElementCollection col)
+               {
+                       elements = new List<HtmlElement>();
+                       foreach (IElement elem in col) {
+                               elements.Add (new HtmlElement (webHost, elem));
+                       }
+                       this.webHost = webHost;
                }
 
-               private HtmlElementCollection (HtmlElement[] elems)
-               {
-                       elements = elems;
+               private HtmlElementCollection (Mono.WebBrowser.IWebBrowser 
webHost, List<HtmlElement> elems)
+               {
+                       elements = elems;
+                       this.webHost = webHost;
                }
 
                public int Count
                {
                        get { 
-                               if (collection != null)
-                                       return collection.Count;
-                               if (elements != null)
-                                       return elements.Length;
-                               return 0;
+                               return elements.Count;
                        }
                }
 
                public HtmlElement this[string elementId]
                {
                        get {
-                               if (collection != null) {
-                                       foreach (IElement elem in collection) {
-                                               if (elem.HasAttribute ("id") && 
elem.GetAttribute ("id").Equals (elementId)) {
-                                                       return new HtmlElement 
(elem);
-                                               }
-                                       }                                       
+                               foreach (HtmlElement element in elements) {
+                                       if (element.Id.Equals (elementId))
+                                               return element;
                                }
-                               if (elements != null) {
-                                       for (int i = 0; i < elements.Length; 
i++) {
-                                               if (elements[i].Id.Equals 
(elementId))
-                                                       return elements[i];
-                                       }
-                               }
                                return null;
                        }
                }
 
                public HtmlElement this[int index]
                {
-                       get {
-                               if (collection != null)
-                                       return new 
HtmlElement(collection[index]);
-                               if (elements != null)
-                                       return elements[index];
-                               return null;
+                       get {
+                               if (index > elements.Count || index < 0)
+                                       return null;
+                               return elements[index];
                        }
                }
 
                public HtmlElementCollection GetElementsByName (string name)
-               {
-                       HtmlElement[] elems = new HtmlElement[this.Count];
-                       int count = 0;
-                       foreach (IElement elem in collection) {
+               {
+                       List<HtmlElement> elems = new List<HtmlElement>();
+
+                       foreach (HtmlElement elem in elements) {
                                if (elem.HasAttribute ("name") && 
elem.GetAttribute ("name").Equals (name)) {
-                                       elems[count] = new HtmlElement (elem);
-                                       count++;
+                                       elems.Add (new HtmlElement (webHost, 
elem.element));
                                }
                        }
-                       HtmlElement[] resized = new HtmlElement [count];
-                       elems.CopyTo (resized, 0);
-                       return new HtmlElementCollection (resized);
+                       return new HtmlElementCollection (webHost, elems);
                }
-
-               [MonoTODO ("Needs Implementation")]
+
+               
                public IEnumerator GetEnumerator ()
                {
-                       return null;
+                       return elements.GetEnumerator ();
                }
 
                void ICollection.CopyTo (Array dest, int index)
-               {
-                       throw new NotImplementedException ();
+               {
+                       elements.CopyTo (dest as HtmlElement[], index);
                }
 
                object ICollection.SyncRoot
@@ -123,8 +110,6 @@
                {
                        get { return false; }
                }
-
-
        }
 }
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlHistory.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlHistory.cs   
2008-01-24 18:05:12 UTC (rev 93824)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlHistory.cs   
2008-01-24 18:06:18 UTC (rev 93825)
@@ -1,32 +1,42 @@
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007, 2008 Novell, Inc.
+//
+// Authors:
+//     Andreia Gaita ([EMAIL PROTECTED])
 //
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Copyright (c) 2007 Novell, Inc.
-//
 
-using System;
 
 #if NET_2_0
+using System;
+using Mono.WebBrowser.DOM;
 
 namespace System.Windows.Forms
 {
        public sealed class HtmlHistory {
+
+               private Mono.WebBrowser.IWebBrowser webHost;
+               internal HtmlHistory (Mono.WebBrowser.IWebBrowser webHost)
+               {
+                       this.webHost = webHost;
+               }
        }
 }
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindow.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindow.cs    
2008-01-24 18:05:12 UTC (rev 93824)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindow.cs    
2008-01-24 18:06:18 UTC (rev 93825)
@@ -1,32 +1,167 @@
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007, 2008 Novell, Inc.
+//
+// Authors:
+//     Andreia Gaita ([EMAIL PROTECTED])
 //
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Copyright (c) 2007 Novell, Inc.
-//
 
+#if NET_2_0
+
 using System;
+using System.Drawing;
+using Mono.WebBrowser.DOM;
 
-#if NET_2_0
-
 namespace System.Windows.Forms
 {
        public sealed class HtmlWindow {
+
+               private IWindow window;
+               private Mono.WebBrowser.IWebBrowser webHost;
+               internal HtmlWindow (Mono.WebBrowser.IWebBrowser webHost, 
IWindow iWindow)
+               {
+                       this.window = iWindow;
+                       this.webHost = webHost;
+               }
+       
+#region Properties
+               public string Name {
+                       get { return this.window.Name; }
+                       set { this.window.Name = value; }
+               }
+               
+               public HtmlWindow Parent {
+                       get { return new HtmlWindow (webHost, 
this.window.Parent); }
+               }
+#endregion
+               
+#region Methods
+               public void Alert (string message) 
+               {                       
+                       MessageBox.Show ("Alert", message);             
+               }
+
+               public bool Confirm (string message) 
+               {                       
+                       DialogResult ret = MessageBox.Show (message, "Confirm", 
MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
+                       return ret == DialogResult.OK;
+               }
+               
+               public string Prompt (string message, string defaultValue)
+               {
+                       WebBrowserDialogs.Prompt prompt = new 
WebBrowserDialogs.Prompt ("Prompt", message, defaultValue);
+                       DialogResult ret = prompt.Show ();
+                       return prompt.Text;
+               }
+               
+               public void Navigate (string urlString)
+               {
+                       webHost.Navigation.Go (urlString);
+               }
+
+               public void Navigate (Uri url)
+               {
+                       webHost.Navigation.Go (url.ToString ());
+               }
+               
+               public void ScrollTo (Point point)
+               {
+                       ScrollTo (point.X, point.Y);
+               }
+
+               public void ScrollTo (int x, int y)
+               {
+                       this.window.ScrollTo (x, y);
+               }
+
+               [MonoTODO("Blank opens in current window at the moment. Missing 
media and search implementations. No options implemented")]
+               public HtmlWindow Open (Uri url, string target, string options, 
bool replace)
+               {
+                       return Open (url.ToString(), target, options, replace);
+               }
+
+               [MonoTODO("Blank opens in current window at the moment. Missing 
media and search implementations. No options implemented")]
+               public HtmlWindow Open (string url, string target, string 
options, bool replace) 
+               {
+                       switch (target) {
+                               case "_blank":
+                                       this.window.Open (url);
+                               break;
+                               case "_media":
+                               break;
+                               case "_parent":
+                                       this.window.Parent.Open (url);
+                               break;
+                               case "_search":
+                               break;
+                               case "_self":
+                                       this.window.Open (url);
+                               break;
+                               case "_top":
+                                       this.window.Top.Open (url);
+                               break;
+                       }
+                       return this;
+               }
+               
+               [MonoTODO("Opens in current window at the moment.")]
+               public HtmlWindow OpenNew (string url, string options)
+               {
+                       return Open (url, "_blank", options, false);
+               }
+
+               [MonoTODO("Opens in current window at the moment.")]
+               public HtmlWindow OpenNew (Uri url, string options)
+               {
+                       return OpenNew (url.ToString (), options);
+               }
+               
+#endregion
+               
+               
+#region Standard stuff
+               public override int GetHashCode () 
+               { 
+                       return window.GetHashCode (); 
+               }
+       
+               public override bool Equals (object obj) {
+                       return this == (HtmlWindow) obj;
+               }
+               
+               public static bool operator ==(HtmlWindow left, HtmlWindow 
right) {
+                       if ((object)left == (object)right) {
+                               return true;
+                       }
+
+                       if ((object)left == null || (object)right == null) {
+                               return false;
+                       }
+
+                       return left.Equals (right); 
+               }
+
+               public static bool operator !=(HtmlWindow left, HtmlWindow 
right) {
+                       return !(left == right);
+               }
+#endregion
        }
 }
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindowCollection.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindowCollection.cs
  2008-01-24 18:05:12 UTC (rev 93824)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlWindowCollection.cs
  2008-01-24 18:06:18 UTC (rev 93825)
@@ -1,32 +1,100 @@
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007, 2008 Novell, Inc.
+//
+// Authors:
+//     Andreia Gaita ([EMAIL PROTECTED])
 //
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-// Copyright (c) 2007 Novell, Inc.
-//
 
-using System;
 
 #if NET_2_0
 
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Mono.WebBrowser.DOM;
+
 namespace System.Windows.Forms
 {
-       public sealed class HtmlWindowCollection {
+       public sealed class HtmlWindowCollection: ICollection, IEnumerable {
+               private List<HtmlWindow> windows;
+               private Mono.WebBrowser.IWebBrowser webHost;
+
+               internal HtmlWindowCollection (Mono.WebBrowser.IWebBrowser 
webHost, IWindowCollection col)
+               {
+                       windows = new List<HtmlWindow>();
+                       foreach (IWindow window in col) {
+                               windows.Add (new HtmlWindow (webHost, window));
+                       }
+
+                       this.webHost = webHost;
+               }
+               
+               public int Count
+               {
+                       get { 
+                               return windows.Count;
+                       }
+               }               
+
+               public HtmlWindow this[string name]
+               {
+                       get {
+                               foreach (HtmlWindow window in windows) {
+                                       if (window.Name.Equals (name))
+                                               return window;
+                               }
+                               return null;
+                       }
+               }
+               
+               public HtmlWindow this[int index]
+               {
+                       get {
+                               if (index > windows.Count || index < 0)
+                                       return null;
+                               return windows[index];
+                       }
+               }
+
+               public IEnumerator GetEnumerator ()
+               {
+                       return windows.GetEnumerator ();
+               }
+
+               void ICollection.CopyTo (Array dest, int index)
+               {
+                       windows.CopyTo (dest as HtmlWindow[], index);
+               }
+
+               object ICollection.SyncRoot
+               {
+                       get { return this; }
+               }
+
+               bool ICollection.IsSynchronized
+               {
+                       get { return false; }
+               }
+               
+
        }
 }
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowser.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowser.cs    
2008-01-24 18:05:12 UTC (rev 93824)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowser.cs    
2008-01-24 18:06:18 UTC (rev 93825)
@@ -17,7 +17,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2007 Novell, Inc.
+// Copyright (c) 2007, 2008 Novell, Inc.
 //
 // Authors:
 //     Andreia Gaita   <[EMAIL PROTECTED]>
@@ -213,56 +213,56 @@
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (urlString);
+                       WebHost.Navigation.Go (urlString);
                }
 
                public void Navigate (Uri url)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (url.ToString ());
+                       WebHost.Navigation.Go (url.ToString ());
                }
 
                public void Navigate (string urlString, bool newWindow)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (urlString);
+                       WebHost.Navigation.Go (urlString);
                }
 
                public void Navigate (string urlString, string targetFrameName)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (urlString);
+                       WebHost.Navigation.Go (urlString);
                }
 
                public void Navigate (Uri url, bool newWindow)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (url.ToString ());
+                       WebHost.Navigation.Go (url.ToString ());
                }
 
                public void Navigate (Uri url, string targetFrameName)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (url.ToString ());
+                       WebHost.Navigation.Go (url.ToString ());
                }
 
                public void Navigate (string urlString, string targetFrameName, 
byte[] postData, string additionalHeaders)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (urlString);
+                       WebHost.Navigation.Go (urlString);
                }
 
                public void Navigate (Uri url, string targetFrameName, byte[] 
postData, string additionalHeaders)
                {
                        documentReady = false;
                        document = null;
-                       WebHost.Navigate (url.ToString ());
+                       WebHost.Navigation.Go (url.ToString ());
                }
 
                public override void Refresh ()
@@ -533,7 +533,7 @@
                        return c.Cancel;
                }
 
-               internal override void OnWebHostNavigated (object sender, 
EventArgs e)
+               internal override void OnWebHostCompleted (object sender, 
EventArgs e)
                {
                        documentReady = true;
                        WebBrowserNavigatedEventArgs n = new 
WebBrowserNavigatedEventArgs (new Uri (WebHost.Document.Url));

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowserBase.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowserBase.cs    
    2008-01-24 18:05:12 UTC (rev 93824)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WebBrowserBase.cs    
    2008-01-24 18:06:18 UTC (rev 93825)
@@ -17,12 +17,14 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-// Copyright (c) 2007 Novell, Inc.
+// Copyright (c) 2007, 2008 Novell, Inc.
 //
 // Authors:
 //     Andreia Gaita   <[EMAIL PROTECTED]>
 
 #if NET_2_0
+
+#undef debug
 
 using System;
 using System.Collections;
@@ -223,7 +225,10 @@
                }
 
                protected override void OnGotFocus (EventArgs e)
-               {
+               {
+#if debug
+                       Console.Error.WriteLine ("WebBrowserBase: OnGotFocus");
+#endif
                        base.OnGotFocus (e);
                        WebHost.FocusIn 
(Mono.WebBrowser.FocusOption.FocusFirstElement);
                }
@@ -234,7 +239,10 @@
                }
 
                protected override void OnLostFocus (EventArgs e)
-               {
+               {
+#if debug
+                       Console.Error.WriteLine ("WebBrowserBase: OnLostFocus");
+#endif
                        base.OnLostFocus (e);
 //                     WebHost.FocusOut ();
                }
@@ -303,7 +311,7 @@
                        webHost.Focus += new EventHandler (OnWebHostFocus);
                        webHost.CreateNewWindow += new 
Mono.WebBrowser.CreateNewWindowEventHandler (OnWebHostCreateNewWindow);
                        webHost.Alert += new Mono.WebBrowser.AlertEventHandler 
(OnWebHostAlert);
-                       webHost.Navigated += new EventHandler 
(OnWebHostNavigated);
+                       webHost.Completed += new EventHandler 
(OnWebHostCompleted);
                }
 
                void OnWebHostAlert (object sender, 
Mono.WebBrowser.AlertEventArgs e)
@@ -381,14 +389,17 @@
                /// <param name="sender"></param>
                /// <param name="e"></param>
                private void OnWebHostFocus (object sender, EventArgs e)
-               {
+               {
+#if debug
+                       Console.Error.WriteLine ("WebBrowserBase: 
OnWebHostFocus");
+#endif
                        this.Focus ();
                }
                
                #endregion
 
                internal abstract bool OnNewWindowInternal ();
-               internal abstract void OnWebHostNavigated (object sender, 
EventArgs e);
+               internal abstract void OnWebHostCompleted (object sender, 
EventArgs e);
                #endregion
        
        }

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

Reply via email to