Author: andreia
Date: 2008-01-14 13:53:57 -0500 (Mon, 14 Jan 2008)
New Revision: 92893
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
Log:
* HtmlElementCollection.cs: Implemented
* HtmlElement.cs: Implemented:
- All
- InnerHtml
- InnerText
- Id
- Name
- FirstChild
* HtmlDocument.cs: Implemented GetElementsByTagName.
2008-01-14 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-14 18:52:07 UTC (rev 92892)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-01-14 18:53:57 UTC (rev 92893)
@@ -1,3 +1,17 @@
+2008-01-14 Andreia Gaita <[EMAIL PROTECTED]>
+
+ * HtmlElementCollection.cs: Implemented
+
+ * HtmlElement.cs: Implemented:
+ - All
+ - InnerHtml
+ - InnerText
+ - Id
+ - Name
+ - FirstChild
+
+ * HtmlDocument.cs: Implemented GetElementsByTagName.
+
2008-01-14 Jonathan Pobst <[EMAIL PROTECTED]>
* Screen.cs: Stub BitsPerPixel to always return 32.
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-14 18:52:07 UTC (rev 92892)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlDocument.cs
2008-01-14 18:53:57 UTC (rev 92893)
@@ -76,8 +76,9 @@
}
public HtmlElementCollection GetElementsByTagName (string
tagName)
- {
- throw new NotImplementedException ();
+ {
+ Mono.WebBrowser.DOM.IElementCollection col =
webHost.Document.GetElementsByTagName (tagName);
+ return new HtmlElementCollection (col);
}
public override int GetHashCode ()
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-14 18:52:07 UTC (rev 92892)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElement.cs
2008-01-14 18:53:57 UTC (rev 92893)
@@ -32,32 +32,46 @@
[MonoTODO ("Needs Implementation")]
public sealed class HtmlElement
{
- private IDOMHTMLElement element;
- internal HtmlElement (IDOMHTMLElement element)
+ private IElement element;
+ internal HtmlElement (IElement element)
{
this.element = element;
}
#region Properties
- [MonoTODO ("Needs Implementation")]
public HtmlElementCollection All
{
- get { throw new NotImplementedException (); }
+ get {
+ return new HtmlElementCollection
(this.element.All);
+ }
}
- [MonoTODO ("Needs Implementation")]
public string InnerHtml
{
- get { return String.Empty; }
+ get { return this.element.InnerHTML; }
set { throw new NotImplementedException (); }
}
- [MonoTODO ("Needs Implementation")]
public string InnerText
{
get { return this.element.InnerText; }
set { this.element.InnerText = value; }
}
+
+ public string Id
+ {
+ get { return element.GetAttribute ("id"); }
+ }
+
+ public string Name
+ {
+ get { return element.GetAttribute ("name"); }
+ }
+
+ public HtmlElement FirstChild
+ {
+ get { return new HtmlElement
((IElement)element.FirstChild); }
+ }
#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-14 18:52:07 UTC (rev 92892)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/HtmlElementCollection.cs
2008-01-14 18:53:57 UTC (rev 92893)
@@ -26,34 +26,81 @@
using System;
using System.Collections;
+using Mono.WebBrowser.DOM;
namespace System.Windows.Forms
{
[MonoTODO ("Needs Implementation")]
public sealed class HtmlElementCollection: ICollection, IEnumerable
{
- [MonoTODO ("Needs Implementation")]
+ private IElementCollection collection;
+ private HtmlElement[] elements;
+
+ internal HtmlElementCollection (IElementCollection col)
+ {
+ collection = col;
+ }
+
+ private HtmlElementCollection (HtmlElement[] elems)
+ {
+ elements = elems;
+ }
+
public int Count
{
- get { return 0; }
+ get {
+ if (collection != null)
+ return collection.Count;
+ if (elements != null)
+ return elements.Length;
+ return 0;
+ }
}
- [MonoTODO ("Needs Implementation")]
public HtmlElement this[string elementId]
{
- get { return null; }
+ get {
+ if (collection != null) {
+ foreach (IElement elem in collection) {
+ if (elem.HasAttribute ("id") &&
elem.GetAttribute ("id").Equals (elementId)) {
+ return new HtmlElement
(elem);
+ }
+ }
+ }
+ if (elements != null) {
+ for (int i = 0; i < elements.Length;
i++) {
+ if (elements[i].Id.Equals
(elementId))
+ return elements[i];
+ }
+ }
+ return null;
+ }
}
- [MonoTODO ("Needs Implementation")]
public HtmlElement this[int index]
{
- get { return null; }
+ get {
+ if (collection != null)
+ return new
HtmlElement(collection[index]);
+ if (elements != null)
+ return elements[index];
+ return null;
+ }
}
- [MonoTODO ("Needs Implementation")]
public HtmlElementCollection GetElementsByName (string name)
{
- throw new NotImplementedException ();
+ HtmlElement[] elems = new HtmlElement[this.Count];
+ int count = 0;
+ foreach (IElement elem in collection) {
+ if (elem.HasAttribute ("name") &&
elem.GetAttribute ("name").Equals (name)) {
+ elems[count] = new HtmlElement (elem);
+ count++;
+ }
+ }
+ HtmlElement[] resized = new HtmlElement [count];
+ elems.CopyTo (resized, 0);
+ return new HtmlElementCollection (resized);
}
[MonoTODO ("Needs Implementation")]
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches