Author: andreia Date: 2008-01-21 11:23:20 -0500 (Mon, 21 Jan 2008) New Revision: 93408
Modified: trunk/mcs/class/Mono.Mozilla/ChangeLog trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Document.cs trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Element.cs trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/HTMLElementCollection.cs trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/IDocument.cs trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs Log: * Mono.WebBrowser/DOM/INavigation.cs: Add Go overload with flags, and LoadFlags enumeration. * Mono.WebBrowser/DOM/IDocument.cs: Add CreateElement, GetElement, Equals and Write. * Mono.Mozilla/DOM/Document.cs: Add CreateElement, GetElement, Equals and Write implementations. Fix GetElementsByTagName to return a proper IElementCollection instance. * Mono.Mozilla/DOM/Element.cs: Add Top, Left, Width and Height properties to support retrieving elements by location. * Mono.Mozilla/DOM/Navigation.cs: Reset WebBrowser object cache so that the next time Document (and others, eventually) is accessed, it will be retrieved from mozilla. This should happen on any action that causes a document reload. Add Go overload to support flags when loading an uri (bypassing proxies, refreshing from cache, etc). * Mono.Mozilla/DOM/HTMLElementCollection.cs: Fix inheritance 2008-01-21 Andreia Gaita <[EMAIL PROTECTED]> Modified: trunk/mcs/class/Mono.Mozilla/ChangeLog =================================================================== --- trunk/mcs/class/Mono.Mozilla/ChangeLog 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/ChangeLog 2008-01-21 16:23:20 UTC (rev 93408) @@ -1,5 +1,30 @@ 2008-01-21 Andreia Gaita <[EMAIL PROTECTED]> + * Mono.WebBrowser/DOM/INavigation.cs: Add Go overload with flags, + and LoadFlags enumeration. + + * Mono.WebBrowser/DOM/IDocument.cs: Add CreateElement, GetElement, + Equals and Write. + + * Mono.Mozilla/DOM/Document.cs: Add CreateElement, GetElement, + Equals and Write implementations. + Fix GetElementsByTagName to return a proper IElementCollection instance. + + * Mono.Mozilla/DOM/Element.cs: Add Top, Left, Width and Height + properties to support retrieving elements by location. + + * Mono.Mozilla/DOM/Navigation.cs: Reset WebBrowser object cache + so that the next time Document (and others, eventually) is accessed, + it will be retrieved from mozilla. This should happen on any + action that causes a document reload. + + Add Go overload to support flags when loading an uri (bypassing proxies, + refreshing from cache, etc). + + * Mono.Mozilla/DOM/HTMLElementCollection.cs: Fix inheritance + +2008-01-21 Andreia Gaita <[EMAIL PROTECTED]> + * Mono.Mozilla/WebBrowser.cs: fix Document accessor 2008-01-14 Andreia Gaita <[EMAIL PROTECTED]> Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Document.cs =================================================================== --- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Document.cs 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Document.cs 2008-01-21 16:23:20 UTC (rev 93408) @@ -34,7 +34,7 @@ { internal class Document : Node, IDocument { - private nsIDOMHTMLDocument document; + internal nsIDOMHTMLDocument document; public Document (WebBrowser control, nsIDOMHTMLDocument document) : base (control, document) @@ -123,6 +123,14 @@ return Base.StringGet (storage); } } + + public IElement CreateElement (string tagName) + { + nsIDOMElement nsElement; + Base.StringSet (storage, tagName); + this.document.createElement (storage, out nsElement); + return new HTMLElement (control, (nsIDOMHTMLElement)nsElement); + } public IElement GetElementById (string id) { @@ -139,13 +147,38 @@ { if (!resources.Contains ("GetElementsByTagName" + name)) { nsIDOMNodeList nodes; - this.document.getElementsByTagName (storage, out nodes); - resources.Add ("GetElementsByTagName" + name, nodes); + this.document.getElementsByTagName (storage, out nodes); + resources.Add ("GetElementsByTagName" + name, new HTMLElementCollection(control, nodes)); } return resources["GetElementsByTagName" + name] as IElementCollection; } + + public IElement GetElement (int x, int y) + { + nsIDOMNodeList nodes; + this.document.getChildNodes (out nodes); + HTMLElementCollection col = new HTMLElementCollection(control, nodes); + IElement ret = null; + foreach (Element el in col) { + if (el.Left <= x && el.Top <= y && + el.Left + el.Width >= x && el.Top + el.Height >= y) { + ret = el; + break; + } + } + return ret; + } + + public bool Equals (IDocument obj) { + Document doc = (Document) obj; + return doc.document == this.document; + } + + public void Write (string text) { + Base.StringSet (storage, text); + this.document.write (storage); + } - #endregion } } Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Element.cs =================================================================== --- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Element.cs 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Element.cs 2008-01-21 16:23:20 UTC (rev 93408) @@ -91,7 +91,7 @@ } return resources["All"] as IElementCollection; } - } + } public virtual bool HasAttribute (string name) { @@ -110,7 +110,38 @@ Base.StringFinish (ret); return val; } - #endregion + #endregion + + internal int Top { + get { + int ret; + ((nsIDOMNSHTMLElement)this.element).getOffsetTop (out ret); + return ret; + } + } + + internal int Left { + get { + int ret; + ((nsIDOMNSHTMLElement)this.element).getOffsetLeft (out ret); + return ret; + } + } + internal int Width { + get { + int ret; + ((nsIDOMNSHTMLElement)this.element).getOffsetWidth (out ret); + return ret; + } + } + + internal int Height { + get { + int ret; + ((nsIDOMNSHTMLElement)this.element).getOffsetHeight (out ret); + return ret; + } + } } } Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/HTMLElementCollection.cs =================================================================== --- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/HTMLElementCollection.cs 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/HTMLElementCollection.cs 2008-01-21 16:23:20 UTC (rev 93408) @@ -33,7 +33,7 @@ namespace Mono.Mozilla.DOM { - internal class HTMLElementCollection : NodeList + internal class HTMLElementCollection : NodeList, IElementCollection { public HTMLElementCollection (WebBrowser control, nsIDOMNodeList nodeList) : base (control, nodeList) { Modified: trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs =================================================================== --- trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/Mono.Mozilla/DOM/Navigation.cs 2008-01-21 16:23:20 UTC (rev 93408) @@ -83,7 +83,7 @@ if (navigation == null) return false; - //return Base.Back (control); + control.Reset (); return navigation.goBack () == 0; } @@ -92,12 +92,13 @@ if (navigation == null) return false; - //return Base.Forward (control); + control.Reset (); return navigation.goForward () == 0; } public void Home () { + control.Reset (); Base.Home (control); } @@ -106,7 +107,7 @@ if (navigation == null) return; - //Base.Reload (control, ReloadOption.None); + control.Reset (); navigation.reload ((uint)ReloadOption.None); } @@ -115,7 +116,7 @@ if (navigation == null) return; - //Base.Reload (control, option); + control.Reset (); navigation.reload ((uint)option); } @@ -124,7 +125,6 @@ if (navigation == null) return; - //Base.Stop (control); navigation.stop ((uint)StopOption.All); } @@ -133,8 +133,18 @@ if (navigation == null) return; - navigation.loadURI (url, (uint)ReloadOption.None, null, null, null); + control.Reset (); + navigation.loadURI (url, (uint)LoadFlags.None, null, null, null); } + + public void Go (string url, LoadFlags flags) + { + if (navigation == null) + return; + + control.Reset (); + navigation.loadURI (url, (uint)flags, null, null, null); + } #endregion Modified: trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/IDocument.cs =================================================================== --- trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/IDocument.cs 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/IDocument.cs 2008-01-21 16:23:20 UTC (rev 93408) @@ -31,12 +31,15 @@ public interface IDocument : INode { IElement Body { get; } + IElement CreateElement (string tagName); IElement DocumentElement { get; } IElement GetElementById (string id); + IElement GetElement (int x, int y); IElementCollection GetElementsByTagName (string id); string Title { get; set;} - string Url { get; } + string Url { get; } + void Write (string text); - + bool Equals (IDocument obj); } } Modified: trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs =================================================================== --- trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs 2008-01-21 16:19:26 UTC (rev 93407) +++ trunk/mcs/class/Mono.Mozilla/Mono.WebBrowser/DOM/INavigation.cs 2008-01-21 16:23:20 UTC (rev 93408) @@ -38,6 +38,18 @@ void Reload (); void Reload (ReloadOption option); void Stop (); - void Go (string url); + void Go (string url); + void Go (string url, LoadFlags flags); + } + + [Flags] + public enum LoadFlags : uint { + None = 0x0000, + AsMetaRefresh = 0x0010, + AsLinkClick = 0x0020, + BypassHistory = 0x0040, + ReplaceHistory = 0x0080, + BypassLocalCache = 0x0100, + BypassProxy = 0x0200 } } _______________________________________________ Mono-patches maillist - Mono-patches@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-patches