X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Web%2FSystem.Web.UI%2FHtmlTextWriter.cs;h=925d94316272c7803ff67a582489dcd67734cb72;hb=bd6a8c46ab0a82d9668f698749b9383144ba2e5c;hp=6875304ac79646bd98e0bd5e203c960e86d2a4ed;hpb=84b709f11124509f2268722945b803ee7e631d93;p=mono.git diff --git a/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs b/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs index 6875304ac79..925d9431627 100644 --- a/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs +++ b/mcs/class/System.Web/System.Web.UI/HtmlTextWriter.cs @@ -1,4 +1,10 @@ - +// +// System.Web.UI.HtmlTextWriter +// +// Author: +// Ben Maurer +// +// (c) 2005 Novell // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -19,1031 +25,1108 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -/* System.Web.UI -* Authors -* Leen Toelen (toelen@hotmail.com) -*/ - -using System; -using System.IO; -using System.Collections; -using System.Web; -using System.Web.UI; - -namespace System.Web.UI{ - -public class HtmlTextWriter : System.IO.TextWriter { - -static HtmlTextWriter(){ - HtmlTextWriter._tagKeyLookupTable = new Hashtable(97); - HtmlTextWriter._tagNameLookupArray = new TagInformation[97]; - HtmlTextWriter.RegisterTag("", HtmlTextWriterTag.Unknown, TagType.Other); - HtmlTextWriter.RegisterTag("a", HtmlTextWriterTag.A, TagType.Inline); - HtmlTextWriter.RegisterTag("acronym", HtmlTextWriterTag.Acronym, TagType.Inline); - HtmlTextWriter.RegisterTag("address", HtmlTextWriterTag.Address, TagType.Other); - HtmlTextWriter.RegisterTag("area", HtmlTextWriterTag.Area, TagType.Other); - HtmlTextWriter.RegisterTag("b", HtmlTextWriterTag.B, TagType.Inline); - HtmlTextWriter.RegisterTag("base", HtmlTextWriterTag.Base, TagType.NonClosing); - HtmlTextWriter.RegisterTag("basefont", HtmlTextWriterTag.Basefont, TagType.NonClosing); - HtmlTextWriter.RegisterTag("bdo", HtmlTextWriterTag.Bdo, TagType.Inline); - HtmlTextWriter.RegisterTag("bgsound", HtmlTextWriterTag.Bgsound, TagType.NonClosing); - HtmlTextWriter.RegisterTag("big", HtmlTextWriterTag.Big, TagType.Inline); - HtmlTextWriter.RegisterTag("blockquote", HtmlTextWriterTag.Blockquote, TagType.Other); - HtmlTextWriter.RegisterTag("body", HtmlTextWriterTag.Body, TagType.Other); - HtmlTextWriter.RegisterTag("br", HtmlTextWriterTag.Br, TagType.Other); - HtmlTextWriter.RegisterTag("button", HtmlTextWriterTag.Button, TagType.Inline); - HtmlTextWriter.RegisterTag("caption", HtmlTextWriterTag.Caption, TagType.Other); - HtmlTextWriter.RegisterTag("center", HtmlTextWriterTag.Center, TagType.Other); - HtmlTextWriter.RegisterTag("cite", HtmlTextWriterTag.Cite, TagType.Inline); - HtmlTextWriter.RegisterTag("code", HtmlTextWriterTag.Code, TagType.Inline); - HtmlTextWriter.RegisterTag("col", HtmlTextWriterTag.Col, TagType.NonClosing); - HtmlTextWriter.RegisterTag("colgroup", HtmlTextWriterTag.Colgroup, TagType.Other); - HtmlTextWriter.RegisterTag("del", HtmlTextWriterTag.Del, TagType.Inline); - HtmlTextWriter.RegisterTag("dd", HtmlTextWriterTag.Dd, TagType.Inline); - HtmlTextWriter.RegisterTag("dfn", HtmlTextWriterTag.Dfn, TagType.Inline); - HtmlTextWriter.RegisterTag("dir", HtmlTextWriterTag.Dir, TagType.Other); - HtmlTextWriter.RegisterTag("div", HtmlTextWriterTag.Div, TagType.Other); - HtmlTextWriter.RegisterTag("dl", HtmlTextWriterTag.Dl, TagType.Other); - HtmlTextWriter.RegisterTag("dt", HtmlTextWriterTag.Dt, TagType.Inline); - HtmlTextWriter.RegisterTag("em", HtmlTextWriterTag.Em, TagType.Inline); - HtmlTextWriter.RegisterTag("embed", HtmlTextWriterTag.Embed, TagType.NonClosing); - HtmlTextWriter.RegisterTag("fieldset", HtmlTextWriterTag.Fieldset, TagType.Other); - HtmlTextWriter.RegisterTag("font", HtmlTextWriterTag.Font, TagType.Inline); - HtmlTextWriter.RegisterTag("form", HtmlTextWriterTag.Form, TagType.Other); - HtmlTextWriter.RegisterTag("frame", HtmlTextWriterTag.Frame, TagType.NonClosing); - HtmlTextWriter.RegisterTag("frameset", HtmlTextWriterTag.Frameset, TagType.Other); - HtmlTextWriter.RegisterTag("h1", HtmlTextWriterTag.H1, TagType.Other); - HtmlTextWriter.RegisterTag("h2", HtmlTextWriterTag.H2, TagType.Other); - HtmlTextWriter.RegisterTag("h3", HtmlTextWriterTag.H3, TagType.Other); - HtmlTextWriter.RegisterTag("h4", HtmlTextWriterTag.H4, TagType.Other); - HtmlTextWriter.RegisterTag("h5", HtmlTextWriterTag.H5, TagType.Other); - HtmlTextWriter.RegisterTag("h6", HtmlTextWriterTag.H6, TagType.Other); - HtmlTextWriter.RegisterTag("head", HtmlTextWriterTag.Head, TagType.Other); - HtmlTextWriter.RegisterTag("hr", HtmlTextWriterTag.Hr, TagType.NonClosing); - HtmlTextWriter.RegisterTag("html", HtmlTextWriterTag.Html, TagType.Other); - HtmlTextWriter.RegisterTag("i", HtmlTextWriterTag.I, TagType.Inline); - HtmlTextWriter.RegisterTag("iframe", HtmlTextWriterTag.Iframe, TagType.Other); - HtmlTextWriter.RegisterTag("img", HtmlTextWriterTag.Img, TagType.NonClosing); - HtmlTextWriter.RegisterTag("input", HtmlTextWriterTag.Input, TagType.NonClosing); - HtmlTextWriter.RegisterTag("ins", HtmlTextWriterTag.Ins, TagType.Inline); - HtmlTextWriter.RegisterTag("isindex", HtmlTextWriterTag.Isindex, TagType.NonClosing); - HtmlTextWriter.RegisterTag("kbd", HtmlTextWriterTag.Kbd, TagType.Inline); - HtmlTextWriter.RegisterTag("label", HtmlTextWriterTag.Label, TagType.Inline); - HtmlTextWriter.RegisterTag("legend", HtmlTextWriterTag.Legend, TagType.Other); - HtmlTextWriter.RegisterTag("li", HtmlTextWriterTag.Li, TagType.Inline); - HtmlTextWriter.RegisterTag("link", HtmlTextWriterTag.Link, TagType.NonClosing); - HtmlTextWriter.RegisterTag("map", HtmlTextWriterTag.Map, TagType.Other); - HtmlTextWriter.RegisterTag("marquee", HtmlTextWriterTag.Marquee, TagType.Other); - HtmlTextWriter.RegisterTag("menu", HtmlTextWriterTag.Menu, TagType.Other); - HtmlTextWriter.RegisterTag("meta", HtmlTextWriterTag.Meta, TagType.NonClosing); - HtmlTextWriter.RegisterTag("nobr", HtmlTextWriterTag.Nobr, TagType.Inline); - HtmlTextWriter.RegisterTag("noframes", HtmlTextWriterTag.Noframes, TagType.Other); - HtmlTextWriter.RegisterTag("noscript", HtmlTextWriterTag.Noscript, TagType.Other); - HtmlTextWriter.RegisterTag("object", HtmlTextWriterTag.Object, TagType.Other); - HtmlTextWriter.RegisterTag("ol", HtmlTextWriterTag.Ol, TagType.Other); - HtmlTextWriter.RegisterTag("option", HtmlTextWriterTag.Option, TagType.Other); - HtmlTextWriter.RegisterTag("p", HtmlTextWriterTag.P, TagType.Inline); - HtmlTextWriter.RegisterTag("param", HtmlTextWriterTag.Param, TagType.Other); - HtmlTextWriter.RegisterTag("pre", HtmlTextWriterTag.Pre, TagType.Other); - HtmlTextWriter.RegisterTag("q", HtmlTextWriterTag.Q, TagType.Inline); - HtmlTextWriter.RegisterTag("rt", HtmlTextWriterTag.Rt, TagType.Other); - HtmlTextWriter.RegisterTag("ruby", HtmlTextWriterTag.Ruby, TagType.Other); - HtmlTextWriter.RegisterTag("s", HtmlTextWriterTag.S, TagType.Inline); - HtmlTextWriter.RegisterTag("samp", HtmlTextWriterTag.Samp, TagType.Inline); - HtmlTextWriter.RegisterTag("script", HtmlTextWriterTag.Script, TagType.Other); - HtmlTextWriter.RegisterTag("select", HtmlTextWriterTag.Select, TagType.Other); - HtmlTextWriter.RegisterTag("small", HtmlTextWriterTag.Small, TagType.Other); - HtmlTextWriter.RegisterTag("span", HtmlTextWriterTag.Span, TagType.Inline); - HtmlTextWriter.RegisterTag("strike", HtmlTextWriterTag.Strike, TagType.Inline); - HtmlTextWriter.RegisterTag("strong", HtmlTextWriterTag.Strong, TagType.Inline); - HtmlTextWriter.RegisterTag("style", HtmlTextWriterTag.Style, TagType.Other); - HtmlTextWriter.RegisterTag("sub", HtmlTextWriterTag.Sub, TagType.Inline); - HtmlTextWriter.RegisterTag("sup", HtmlTextWriterTag.Sup, TagType.Inline); - HtmlTextWriter.RegisterTag("table", HtmlTextWriterTag.Table, TagType.Other); - HtmlTextWriter.RegisterTag("tbody", HtmlTextWriterTag.Tbody, TagType.Other); - HtmlTextWriter.RegisterTag("td", HtmlTextWriterTag.Td, TagType.Inline); - HtmlTextWriter.RegisterTag("textarea", HtmlTextWriterTag.Textarea, TagType.Inline); - HtmlTextWriter.RegisterTag("tfoot", HtmlTextWriterTag.Tfoot, TagType.Other); - HtmlTextWriter.RegisterTag("th", HtmlTextWriterTag.Th, TagType.Inline); - HtmlTextWriter.RegisterTag("thead", HtmlTextWriterTag.Thead, TagType.Other); - HtmlTextWriter.RegisterTag("title", HtmlTextWriterTag.Title, TagType.Other); - HtmlTextWriter.RegisterTag("tr", HtmlTextWriterTag.Tr, TagType.Other); - HtmlTextWriter.RegisterTag("tt", HtmlTextWriterTag.Tt, TagType.Inline); - HtmlTextWriter.RegisterTag("u", HtmlTextWriterTag.U, TagType.Inline); - HtmlTextWriter.RegisterTag("ul", HtmlTextWriterTag.Ul, TagType.Other); - HtmlTextWriter.RegisterTag("var", HtmlTextWriterTag.Var, TagType.Inline); - HtmlTextWriter.RegisterTag("wbr", HtmlTextWriterTag.Wbr, TagType.NonClosing); - HtmlTextWriter.RegisterTag("xml", HtmlTextWriterTag.Xml, TagType.Other); - - HtmlTextWriter._attrKeyLookupTable = new Hashtable(40); - HtmlTextWriter._attrNameLookupArray = new AttributeInformation[40]; - HtmlTextWriter.RegisterAttribute("accesskey", HtmlTextWriterAttribute.Accesskey, true); - HtmlTextWriter.RegisterAttribute("align", HtmlTextWriterAttribute.Align, false); - HtmlTextWriter.RegisterAttribute("alt", HtmlTextWriterAttribute.Alt, true); - HtmlTextWriter.RegisterAttribute("background", HtmlTextWriterAttribute.Background, true); - HtmlTextWriter.RegisterAttribute("bgcolor", HtmlTextWriterAttribute.Bgcolor, false); - HtmlTextWriter.RegisterAttribute("border", HtmlTextWriterAttribute.Border, false); - HtmlTextWriter.RegisterAttribute("bordercolor", HtmlTextWriterAttribute.Bordercolor, false); - HtmlTextWriter.RegisterAttribute("cellpadding", HtmlTextWriterAttribute.Cellpadding, false); - HtmlTextWriter.RegisterAttribute("cellspacing", HtmlTextWriterAttribute.Cellspacing, false); - HtmlTextWriter.RegisterAttribute("checked", HtmlTextWriterAttribute.Checked, false); - HtmlTextWriter.RegisterAttribute("class", HtmlTextWriterAttribute.Class, true); - HtmlTextWriter.RegisterAttribute("cols", HtmlTextWriterAttribute.Cols, false); - HtmlTextWriter.RegisterAttribute("colspan", HtmlTextWriterAttribute.Colspan, false); - HtmlTextWriter.RegisterAttribute("disabled", HtmlTextWriterAttribute.Disabled, false); - HtmlTextWriter.RegisterAttribute("for", HtmlTextWriterAttribute.For, false); - HtmlTextWriter.RegisterAttribute("height", HtmlTextWriterAttribute.Height, false); - HtmlTextWriter.RegisterAttribute("href", HtmlTextWriterAttribute.Href, true); - HtmlTextWriter.RegisterAttribute("id", HtmlTextWriterAttribute.Id, false); - HtmlTextWriter.RegisterAttribute("maxlength", HtmlTextWriterAttribute.Maxlength, false); - HtmlTextWriter.RegisterAttribute("multiple", HtmlTextWriterAttribute.Multiple, false); - HtmlTextWriter.RegisterAttribute("name", HtmlTextWriterAttribute.Name, false); - HtmlTextWriter.RegisterAttribute("nowrap", HtmlTextWriterAttribute.Nowrap, false); - HtmlTextWriter.RegisterAttribute("onchange", HtmlTextWriterAttribute.Onchange, true); - HtmlTextWriter.RegisterAttribute("onclick", HtmlTextWriterAttribute.Onclick, true); - HtmlTextWriter.RegisterAttribute("readonly", HtmlTextWriterAttribute.ReadOnly, false); - HtmlTextWriter.RegisterAttribute("rows", HtmlTextWriterAttribute.Rows, false); - HtmlTextWriter.RegisterAttribute("rowspan", HtmlTextWriterAttribute.Rowspan, false); - HtmlTextWriter.RegisterAttribute("rules", HtmlTextWriterAttribute.Rules, false); - HtmlTextWriter.RegisterAttribute("selected", HtmlTextWriterAttribute.Selected, false); - HtmlTextWriter.RegisterAttribute("size", HtmlTextWriterAttribute.Size, false); - HtmlTextWriter.RegisterAttribute("src", HtmlTextWriterAttribute.Src, true); - HtmlTextWriter.RegisterAttribute("style", HtmlTextWriterAttribute.Style, false); - HtmlTextWriter.RegisterAttribute("tabindex", HtmlTextWriterAttribute.Tabindex, false); - HtmlTextWriter.RegisterAttribute("target", HtmlTextWriterAttribute.Target, false); - HtmlTextWriter.RegisterAttribute("title", HtmlTextWriterAttribute.Title, true); - HtmlTextWriter.RegisterAttribute("type", HtmlTextWriterAttribute.Type, false); - HtmlTextWriter.RegisterAttribute("valign", HtmlTextWriterAttribute.Valign, false); - HtmlTextWriter.RegisterAttribute("value", HtmlTextWriterAttribute.Value, true); - HtmlTextWriter.RegisterAttribute("width", HtmlTextWriterAttribute.Width, false); - HtmlTextWriter.RegisterAttribute("wrap", HtmlTextWriterAttribute.Wrap, false); - - HtmlTextWriter._styleKeyLookupTable = new Hashtable(14); - HtmlTextWriter._styleNameLookupArray = new String[14]; - HtmlTextWriter.RegisterStyle("background-color", HtmlTextWriterStyle.BackgroundColor); - HtmlTextWriter.RegisterStyle("background-image", HtmlTextWriterStyle.BackgroundImage); - HtmlTextWriter.RegisterStyle("border-collapse", HtmlTextWriterStyle.BorderCollapse); - HtmlTextWriter.RegisterStyle("border-color", HtmlTextWriterStyle.BorderColor); - HtmlTextWriter.RegisterStyle("border-style", HtmlTextWriterStyle.BorderStyle); - HtmlTextWriter.RegisterStyle("border-width", HtmlTextWriterStyle.BorderWidth); - HtmlTextWriter.RegisterStyle("color", HtmlTextWriterStyle.Color); - HtmlTextWriter.RegisterStyle("font-family", HtmlTextWriterStyle.FontFamily); - HtmlTextWriter.RegisterStyle("font-size", HtmlTextWriterStyle.FontSize); - HtmlTextWriter.RegisterStyle("font-style", HtmlTextWriterStyle.FontStyle); - HtmlTextWriter.RegisterStyle("font-weight", HtmlTextWriterStyle.FontWeight); - HtmlTextWriter.RegisterStyle("height", HtmlTextWriterStyle.Height); - HtmlTextWriter.RegisterStyle("text-decoration", HtmlTextWriterStyle.TextDecoration); - HtmlTextWriter.RegisterStyle("width", HtmlTextWriterStyle.Width); -} - -public HtmlTextWriter(TextWriter writer):this(writer, " "){} - -public HtmlTextWriter(TextWriter writer, string tabString) : base() { - this.writer = writer; - this.tabString = tabString; - indentLevel = 0; - tabsPending = false; - _httpWriter = writer as HttpWriter; - _isDescendant = GetType() == typeof(HtmlTextWriter) == false; - _attrList = new RenderAttribute[20]; - _attrCount = 0; - _styleList = new RenderStyle[20]; - _styleCount = 0; - _endTags = new TagStackEntry[16]; - _endTagCount = 0; - _inlineCount = 0; -} - -public virtual void AddAttribute(HtmlTextWriterAttribute key, string value){ - if ((int) key >= 0 && (int) key < HtmlTextWriter._attrNameLookupArray.Length) { - AttributeInformation attrInfo = HtmlTextWriter._attrNameLookupArray[(int) key]; - AddAttribute(attrInfo.name, value, key, attrInfo.encode); - } -} - -public virtual void AddAttribute(HtmlTextWriterAttribute key, string value, bool fEncode){ - if ((int) key >= 0 && (int) key < HtmlTextWriter._attrNameLookupArray.Length) { - AddAttribute(HtmlTextWriter._attrNameLookupArray[(int) key].name, value, key, fEncode); - } -} - -public virtual void AddAttribute(string name, string value){ - HtmlTextWriterAttribute attr = GetAttributeKey(name); - value = EncodeAttributeValue(GetAttributeKey(name), value); - AddAttribute(name, value, attr); -} - -public virtual void AddAttribute(string name, string value, bool fEndode){ - value = EncodeAttributeValue(value, fEndode); - AddAttribute(name, value, GetAttributeKey(name)); -} - -protected virtual void AddAttribute(string name, string value, HtmlTextWriterAttribute key){ - AddAttribute(name, value, key, false); -} - -private void AddAttribute(string name, string value, HtmlTextWriterAttribute key, bool encode){ - if (_attrCount >= (int) _attrList.Length) { - RenderAttribute[] rAttrArr = new RenderAttribute[_attrList.Length * 2]; - System.Array.Copy(_attrList, rAttrArr, (int) _attrList.Length); - _attrList = rAttrArr; - } - RenderAttribute rAttr; - rAttr.name = name; - rAttr.value = value; - rAttr.key = key; - rAttr.encode = encode; - _attrList [_attrCount++] = rAttr; -} - -public virtual void AddStyleAttribute(HtmlTextWriterStyle key, string value){ - AddStyleAttribute(GetStyleName(key), value, key); -} - -public virtual void AddStyleAttribute(string name, string value){ - AddStyleAttribute(name, value, GetStyleKey(name)); -} - -protected virtual void AddStyleAttribute(string name, string value, HtmlTextWriterStyle key){ - if (_styleCount >= (int) _styleList.Length) { - RenderStyle[] rAttrArr = new RenderStyle[_styleList.Length * 2]; - System.Array.Copy(_styleList, rAttrArr, (int) _styleList.Length); - _styleList = rAttrArr; - } - RenderStyle rAttr; - rAttr.name = name; - rAttr.value = value; - rAttr.key = key; - _styleList [_styleCount++] = rAttr; -} - -public override void Close(){ - writer.Close(); -} - -protected virtual string EncodeAttributeValue(HtmlTextWriterAttribute attrKey, string value){ - bool valid = true; - if (0 <= (int) attrKey && (int) attrKey < HtmlTextWriter._attrNameLookupArray.Length) - valid = HtmlTextWriter._attrNameLookupArray[(int) attrKey].encode; - return EncodeAttributeValue(value, valid); -} - -protected string EncodeAttributeValue(string value, bool fEncode){ - if (value == null) - return null; - if (!(fEncode)) - return value; - return System.Web.HttpUtility.HtmlAttributeEncode(value); -} - -protected string EncodeUrl(string url){ - if (url.IndexOf(SpaceChar) < 0) - return url; - System.Text.StringBuilder sb = new System.Text.StringBuilder(); - for(int i=0; i <= url.Length; i++){ - char temp = url[i]; - if (temp != 32) - sb.Append(temp); - else - sb.Append("%20"); - } - return sb.ToString(); -} - -protected virtual void FilterAttributes(){ - int count = 0; - for(int i=0; i < _styleCount; i++){ - RenderStyle rStyle = _styleList[i]; - if (OnStyleAttributeRender(rStyle.name, rStyle.value, rStyle.key)) { - count++; - } - } - _styleCount = count; - count = 0; - for(int i=0; i <= _attrCount; i++){ - RenderAttribute rAttr = _attrList[i]; - if (OnAttributeRender(rAttr.name, rAttr.value, rAttr.key)) { - count++; - } - } - _attrCount = count; -} - -public override void Flush(){ - writer.Flush(); -} - -protected HtmlTextWriterAttribute GetAttributeKey(string attrName){ - if (attrName != null && attrName.Length > 0) { - object attr = HtmlTextWriter._attrKeyLookupTable[attrName.ToLower()]; - if (attr != null) - return (HtmlTextWriterAttribute) attr; - } - return (HtmlTextWriterAttribute) (-1); -} - -protected string GetAttributeName(HtmlTextWriterAttribute attrKey){ - if ((int) attrKey >= 0 && (int) attrKey < HtmlTextWriter._attrNameLookupArray.Length) - return HtmlTextWriter._attrNameLookupArray[(int) attrKey].name; - return System.String.Empty; -} - -protected HtmlTextWriterStyle GetStyleKey(string styleName){ - if (styleName != null && styleName.Length > 0) { - object style = HtmlTextWriter._styleKeyLookupTable[styleName.ToLower()]; - if (style != null) - return (HtmlTextWriterStyle) style; - } - return (HtmlTextWriterStyle) (-1); -} - -protected string GetStyleName(HtmlTextWriterStyle styleKey){ - if ((int) styleKey >= 0 && (int) styleKey < HtmlTextWriter._styleNameLookupArray.Length) - return HtmlTextWriter._styleNameLookupArray[(int) styleKey]; - return System.String.Empty; -} - -protected virtual HtmlTextWriterTag GetTagKey(string tagName){ - if (tagName != null && tagName.Length > 0) { - object tag = HtmlTextWriter._tagKeyLookupTable[tagName.ToLower()]; - if (tag != null) - return (HtmlTextWriterTag) tag; - } - return 0; -} - -protected virtual string GetTagName(HtmlTextWriterTag tagKey){ - if ((int) tagKey >= 0 && (int) tagKey < HtmlTextWriter._tagNameLookupArray.Length) - return HtmlTextWriter._tagNameLookupArray[(int) tagKey].name; - return System.String.Empty; -} - -protected bool IsAttributeDefined(HtmlTextWriterAttribute key){ - for (int i=0; i < _attrCount; i++) { - if (_attrList[i].key == key) - return true; - } - return false; -} - -protected bool IsAttributeDefined(HtmlTextWriterAttribute key, out string value){ - value = null; - for (int i=0; i < _attrCount; i++) { - if (_attrList[i].key == key) { - value = _attrList[i].value; - return true; - } - } - return false; -} - -protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key){ - for (int i= 0; i < _styleCount; i++) { - if (_styleList[i].key == key) - return true; - } - return false; -} - -protected bool IsStyleAttributeDefined(HtmlTextWriterStyle key, out string value){ - value = null; - for( int i=0; i < _styleCount; i++) { - if (_styleList[i].key == key) { - value = _styleList[i].value; - return true; - } - } - return false; -} - -protected virtual bool OnAttributeRender(string name, string value, HtmlTextWriterAttribute key){ - return true; -} - -protected virtual bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key){ - return true; -} - -protected virtual bool OnTagRender(string name, HtmlTextWriterTag key){ - return true; -} - -protected virtual void OutputTabs(){ - if (tabsPending) { - for(int i=0; i < indentLevel; i++) { - writer.Write(tabString); - } - tabsPending = false; - } -} - -protected string PopEndTag(){ - if (_endTagCount <= 0) - throw new InvalidOperationException("A PopEndTag was called without a corresponding PushEndTag"); - _endTagCount--; - TagKey = _endTags[_endTagCount].tagKey; - return _endTags[_endTagCount].endTagText; -} - -protected void PushEndTag(string endTag){ - if (_endTagCount >= (int) _endTags.Length) { - TagStackEntry[] temp = new TagStackEntry[(int) _endTags.Length * 2]; - System.Array.Copy(_endTags, temp, (int) _endTags.Length); - _endTags = temp; - } - _endTags[_endTagCount].tagKey = _tagKey; - _endTags[_endTagCount].endTagText = endTag; - _endTagCount++; -} - -protected static void RegisterAttribute(string name, HtmlTextWriterAttribute key){ - HtmlTextWriter.RegisterAttribute(name, key, false); -} - -private static void RegisterAttribute(string name, HtmlTextWriterAttribute key, bool fEncode){ - name = name.ToLower(); - HtmlTextWriter._attrKeyLookupTable.Add(name, key); - if ((int) key < (int) HtmlTextWriter._attrNameLookupArray.Length) - HtmlTextWriter._attrNameLookupArray[(int) key] = new AttributeInformation(name, fEncode); -} - -protected static void RegisterStyle(string name, HtmlTextWriterStyle key){ - name = name.ToLower(); - HtmlTextWriter._styleKeyLookupTable.Add(name, key); - if ((int) key < (int) HtmlTextWriter._styleNameLookupArray.Length) - HtmlTextWriter._styleNameLookupArray[(int) key] = name; -} - -protected static void RegisterTag(string name, HtmlTextWriterTag key){ - HtmlTextWriter.RegisterTag(name, key, TagType.Other); -} - -private static void RegisterTag(string name, HtmlTextWriterTag key, TagType type){ - name = name.ToLower(); - HtmlTextWriter._tagKeyLookupTable.Add(name, key); - string fullTag = null; - if ((int) type != 1 && (int) key != 0) { - fullTag = EndTagLeftChars + name + TagRightChar; - } - if ((int) key < HtmlTextWriter._tagNameLookupArray.Length) - HtmlTextWriter._tagNameLookupArray[(int) key] = new TagInformation(name, type, fullTag); -} - -protected virtual string RenderAfterContent(){ - return null; -} - -protected virtual string RenderAfterTag(){ - return null; -} - -protected virtual string RenderBeforeContent(){ - return null; -} - -protected virtual string RenderBeforeTag(){ - return null; -} - -public virtual void RenderBeginTag(HtmlTextWriterTag tagKey){ - TagKey = tagKey; - bool tagRendered = true; - bool tagRender = true; - if (_isDescendant) { - tagRender = OnTagRender(_tagName, _tagKey); - FilterAttributes(); - string beforeTag = RenderBeforeTag(); - if (beforeTag != null) { - if (tabsPending) - OutputTabs(); - writer.Write(beforeTag); - } - } - TagInformation currentTag = HtmlTextWriter._tagNameLookupArray[_tagIndex]; - if (currentTag.closingTag == null && currentTag.tagType == TagType.Other) { - currentTag.closingTag = EndTagLeftChars + _tagName + TagRightChar; - } - - if (tagRender) { - tagRendered = false; - if (tabsPending) - OutputTabs(); - writer.Write(TagLeftChar); - writer.Write(_tagName); - RenderAttribute rAttr; - string rAttrValue = null; - for (int i=0; i < _attrCount; i++) { - rAttr = _attrList[i]; - if (rAttr.key == HtmlTextWriterAttribute.Style) - rAttrValue = rAttr.value; - else { - writer.Write(SpaceChar); - writer.Write(rAttr.name); - if (rAttr.value != null) { - writer.Write(EqualsChar); - writer.Write(DoubleQuoteChar); - if (rAttr.encode) { - if (_httpWriter == null) { - System.Web.HttpUtility.HtmlAttributeEncode(rAttr.value, writer); - } - else { - System.Web.HttpUtility.HtmlAttributeEncode(rAttr.value, (TextWriter) _httpWriter); - } - } - else { - writer.Write(rAttr.value); - } - writer.Write(DoubleQuoteChar); - } - } - } - if (_styleCount > 0 || rAttrValue != null) { - writer.Write(SpaceChar); - writer.Write("style"); - writer.Write(EqualsChar); - writer.Write(DoubleQuoteChar); - RenderStyle rStyle; - for (int i=0; i < _styleCount; i++) { - rStyle = _styleList[i]; - writer.Write(rStyle.name); - writer.Write(StyleEqualsChar); - writer.Write(rStyle.value); - writer.Write(SemicolonChar); - } - if (rAttrValue != null) - writer.Write(rAttrValue); - writer.Write(DoubleQuoteChar); - } - if (currentTag.tagType == TagType.NonClosing) { - writer.Write(SpaceChar); - writer.Write(SlashChar); - writer.Write(TagRightChar); - } - else - writer.Write(TagRightChar); - } - string beforeContent = RenderBeforeContent(); - if (beforeContent != null) { - if (tabsPending) - OutputTabs(); - writer.Write(beforeContent); - } - if (tagRendered) { - if (currentTag.tagType == TagType.Inline) - _inlineCount++; - else { - WriteLine(); - Indent++; - } - if (currentTag.closingTag == null) { - currentTag.closingTag = EndTagLeftChars + _tagName + TagRightChar; - } - } - if (_isDescendant) { - string afterContent = RenderAfterContent(); - if (afterContent != null) { - if (currentTag.closingTag != null) - currentTag.closingTag = afterContent; - } - string afterTag = RenderAfterTag(); - if (afterTag != null) { - if (currentTag.closingTag != null) - currentTag.closingTag = afterTag; - } - } - PushEndTag(currentTag.closingTag); - _attrCount = 0; - _styleCount = 0; -} - -public virtual void RenderBeginTag(string tagName){ - TagName = tagName; - RenderBeginTag(_tagKey); -} - -public virtual void RenderEndTag(){ - string endTagText = PopEndTag(); - if (endTagText != null) { - if (HtmlTextWriter._tagNameLookupArray[_tagIndex].tagType == 0) { - _inlineCount--; - Write(endTagText); - } - else{ - WriteLine(); - Indent--; - Write(endTagText); - } - } -} - -public override void Write(bool value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(char value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(char[] buffer){ - if (tabsPending) - OutputTabs(); - writer.Write(buffer); -} - -public override void Write(char[] buffer, int index, int count){ - if (tabsPending) - OutputTabs(); - writer.Write(buffer, index, count); -} - -public override void Write(double value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(int value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(long value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(object value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(float value){ - if (tabsPending) - OutputTabs(); - writer.Write(value); -} - -public override void Write(string s){ - if (tabsPending) - OutputTabs(); - writer.Write(s); -} - -public override void Write(string format, object arg0){ - if (tabsPending) - OutputTabs(); - writer.Write(format, arg0); -} - -public override void Write(string format, object arg0, object arg1){ - if (tabsPending) - OutputTabs(); - writer.Write(format, arg0, arg1); -} - -public override void Write(string format, params object[] arg){ - if (tabsPending) - OutputTabs(); - writer.Write(format, arg); -} - -public virtual void WriteAttribute(string name, string value){ - WriteAttribute(name, value, false); -} - -public virtual void WriteAttribute(string name, string value, bool fEncode){ - writer.Write(SpaceChar); - writer.Write(name); - if (value != null) { - writer.Write(EqualsChar); - writer.Write(DoubleQuoteChar); - if (fEncode) { - if (_httpWriter == null) { - System.Web.HttpUtility.HtmlAttributeEncode(value, writer); - } - else{ - System.Web.HttpUtility.HtmlAttributeEncode(value, (TextWriter) _httpWriter); - } - } - else{ - writer.Write(value); - } - writer.Write(DoubleQuoteChar); - } -} - -public virtual void WriteBeginTag(string tagName){ - if (tabsPending) - OutputTabs(); - writer.Write(TagLeftChar); - writer.Write(tagName); -} - -public virtual void WriteEndTag(string tagName){ - if (tabsPending) - OutputTabs(); - writer.Write(TagLeftChar); - writer.Write(SlashChar); - writer.Write(tagName); - writer.Write(TagRightChar); -} - -public virtual void WriteFullBeginTag(string tagName){ - if (tabsPending) - OutputTabs(); - writer.Write(TagLeftChar); - writer.Write(tagName); - writer.Write(TagRightChar); -} - -public override void WriteLine(){ - writer.WriteLine(); - tabsPending = true; -} - -public override void WriteLine(bool value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(char value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(char[] buffer){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(buffer); - tabsPending = true; -} - -public override void WriteLine(char[] buffer, int index, int count){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(buffer, index, count); - tabsPending = true; -} - -public override void WriteLine(double value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(int value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(long value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(object value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(float value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public override void WriteLine(string s){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(s); - tabsPending = true; -} - -public override void WriteLine(string format, object arg0){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(format, arg0); - tabsPending = true; -} - -public override void WriteLine(string format, object arg0, object arg1){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(format, arg0, arg1); - tabsPending = true; -} - -public override void WriteLine(string format, params object[] arg){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(format, arg); - tabsPending = true; -} - -[CLSCompliant(false)] -public override void WriteLine(uint value){ - if (tabsPending) - OutputTabs(); - writer.WriteLine(value); - tabsPending = true; -} - -public void WriteLineNoTabs(string s){ - writer.WriteLine(s); -} - -public virtual void WriteStyleAttribute(string name, string value){ - WriteStyleAttribute(name, value, false); -} - -public virtual void WriteStyleAttribute(string name, string value, bool fEncode){ - writer.Write(name); - writer.Write(StyleEqualsChar); - if (fEncode) { - if (_httpWriter == null) { - System.Web.HttpUtility.HtmlAttributeEncode(value, writer); - } - else{ - System.Web.HttpUtility.HtmlAttributeEncode(value, (TextWriter) _httpWriter); - } - } - else { - writer.Write(value); - } - writer.Write(SemicolonChar); -} - -public override System.Text.Encoding Encoding { - get{ - return writer.Encoding; - } -} - -public int Indent { - get{ - return indentLevel; - } - set{ - if (value < 0) - value = 0; - indentLevel = value; - } -} - -public TextWriter InnerWriter { - get{ - return writer; - } - set{ - writer = value; - _httpWriter = value as HttpWriter; - } -} - -public override string NewLine { - get{ - return writer.NewLine; - } - set{ - writer.NewLine = value; - } -} - -protected HtmlTextWriterTag TagKey { - get{ - return _tagKey; - } - set{ - _tagIndex = (int) value; - if (_tagIndex < 0 || _tagIndex >= (int) HtmlTextWriter._tagNameLookupArray.Length) - throw new ArgumentOutOfRangeException("value"); - _tagKey = value; - if (value != 0) - _tagName = HtmlTextWriter._tagNameLookupArray[_tagIndex].name; - } -} - -protected string TagName { - get{ - return _tagName; - } - set{ - _tagName = value; - _tagKey = GetTagKey(_tagName); - _tagIndex = (int) _tagKey; - } -} - -public const string DefaultTabString = "\t"; -public const char DoubleQuoteChar = '"'; -public const string EndTagLeftChars = ""; -public const char SemicolonChar = ';'; -public const char SingleQuoteChar = '\''; -public const char SlashChar = '/'; -public const char SpaceChar = ' '; -public const char StyleEqualsChar = ':'; -public const char TagLeftChar = '<'; -public const char TagRightChar = '>'; - -private int _attrCount; -private int _endTagCount; -private int _styleCount; -private int indentLevel; -private int _inlineCount; -private int _tagIndex; - -private bool _isDescendant; -private bool tabsPending; - -private HtmlTextWriterTag _tagKey; -private TextWriter writer; -private HttpWriter _httpWriter; - -private static Hashtable _attrKeyLookupTable; -private static Hashtable _styleKeyLookupTable; -private static Hashtable _tagKeyLookupTable; - -private string _tagName; -private string tabString; -private static string[] _styleNameLookupArray; - -private RenderAttribute[] _attrList; -private static AttributeInformation[] _attrNameLookupArray; -private static TagInformation[] _tagNameLookupArray; -private TagStackEntry[] _endTags; -private RenderStyle[] _styleList; - -} //HtmlTextWriter - -struct AttributeInformation { - public bool encode; - public string name; - - public AttributeInformation(string name, bool encode){ - this.encode = encode; - this.name = name; - } -} - -struct RenderAttribute { - public bool encode; - public HtmlTextWriterAttribute key; - public string name; - public string value; -} - -struct RenderStyle { - public HtmlTextWriterStyle key; - public string name; - public string value; -} - -struct TagInformation { - public string closingTag; - public string name; - public TagType tagType; - - public TagInformation(string name, TagType tagType, string closingTag){ - this.name = name; - this.tagType = tagType; - this.closingTag = closingTag; - } -} - -struct TagStackEntry { - public string endTagText; - public HtmlTextWriterTag tagKey; -} - -enum TagType { - Inline, - NonClosing, - Other -} - - -} // namespace System.Web.UI.HtmlControls - + +using System.IO; +using System.Globalization; +using System.Collections; +using System.Security.Permissions; +using System.Text; + +namespace System.Web.UI { + + // CAS + [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] + [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] + public class HtmlTextWriter : TextWriter { + + + public HtmlTextWriter (TextWriter writer) : this (writer, DefaultTabString) + { + } + + public HtmlTextWriter (TextWriter writer, string tabString) + { + if (writer == null) + throw new ArgumentNullException (); + + b = writer; + tab_string = tabString; + } + + internal static string StaticGetStyleName (System.Web.UI.HtmlTextWriterStyle styleKey) + { + if ((int) styleKey < htmlstyles.Length) + return htmlstyles [(int) styleKey].name; + + return null; + } + + [MonoTODO] + protected static void RegisterAttribute (string name, HtmlTextWriterAttribute key) + { + } + + [MonoTODO] + protected static void RegisterStyle (string name, HtmlTextWriterStyle key) + { + } + + [MonoTODO] + protected static void RegisterTag (string name, HtmlTextWriterTag key) + { + } + + + public virtual void AddAttribute (HtmlTextWriterAttribute key, string value, bool fEncode) + { + if (fEncode) + value = EncodeAttributeValue (key, value); + AddAttribute (GetAttributeName (key), value, key); + } + + + public virtual void AddAttribute (HtmlTextWriterAttribute key, string value) + { + AddAttribute (key, value, true); + } + + + public virtual void AddAttribute (string name, string value, bool fEncode) + { + if (fEncode) + value = HttpUtility.HtmlAttributeEncode (value); + + AddAttribute (name, value, GetAttributeKey (name)); + } + + public virtual void AddAttribute (string name, string value) + { + AddAttribute (name, value, true); + } + + protected virtual void AddAttribute (string name, string value, HtmlTextWriterAttribute key) + { + NextAttrStack (); + attrs [attrs_pos].name = name; + attrs [attrs_pos].value = value; + attrs [attrs_pos].key = key; + } + + + protected virtual void AddStyleAttribute (string name, string value, HtmlTextWriterStyle key) + { + NextStyleStack (); + styles [styles_pos].name = name; + styles [styles_pos].value = value; + styles [styles_pos].key = key; + } + + + public virtual void AddStyleAttribute (string name, string value) + { + AddStyleAttribute (name, value, GetStyleKey (name)); + } + + public virtual void AddStyleAttribute (HtmlTextWriterStyle key, string value) + { + AddStyleAttribute (GetStyleName (key), value, key); + } + + public override void Close () + { + b.Close (); + } + + protected virtual string EncodeAttributeValue (HtmlTextWriterAttribute attrKey, string value) + { + return HttpUtility.HtmlEncode (value); + } + + protected string EncodeAttributeValue (string value, bool fEncode) + { + if (fEncode) + return HttpUtility.HtmlEncode (value); + return value; + } + + protected string EncodeUrl (string url) + { + return HttpUtility.UrlPathEncode (url); + } + + + protected virtual void FilterAttributes () + { + AddedAttr style_attr = new AddedAttr (); + + for (int i = 0; i <= attrs_pos; i ++) { + AddedAttr a = attrs [i]; + if (OnAttributeRender (a.name, a.value, a.key)) { + if (a.key == HtmlTextWriterAttribute.Style) { + style_attr = a; + continue; + } + + WriteAttribute (a.name, a.value, false); + } + } + + if (styles_pos != -1 || style_attr.value != null) { + Write (SpaceChar); + Write ("style"); + Write (EqualsDoubleQuoteString); + + + for (int i = 0; i <= styles_pos; i ++) { + AddedStyle a = styles [i]; + if (OnStyleAttributeRender (a.name, a.value, a.key)) + WriteStyleAttribute (a.name, a.value, false); + } + + Write (style_attr.value); + Write (DoubleQuoteChar); + } + + styles_pos = attrs_pos = -1; + } + + public override void Flush () + { + b.Flush (); + } + + [MonoTODO] + protected HtmlTextWriterAttribute GetAttributeKey (string attrName) + { + // I don't think we want to binary search + // because there might be something added to + // the enum later. Do we really need anything + // faster than a linear search? + + foreach (HtmlAttribute t in htmlattrs) { + if (String.Compare(t.name, attrName, true, CultureInfo.InvariantCulture) == 0) + return t.key; + } + + return (HtmlTextWriterAttribute)(-1); + } + + [MonoTODO] + protected string GetAttributeName (HtmlTextWriterAttribute attrKey) + { + if ((int) attrKey < htmlattrs.Length) + return htmlattrs [(int) attrKey].name; + + return null; + } + + [MonoTODO] + protected HtmlTextWriterStyle GetStyleKey (string styleName) + { + // I don't think we want to binary search + // because there might be something added to + // the enum later. Do we really need anything + // faster than a linear search? + + foreach (HtmlStyle t in htmlstyles) { + if (String.Compare(t.name, styleName, true, CultureInfo.InvariantCulture) == 0) + return t.key; + } + + return (HtmlTextWriterStyle)(-1); + } + + [MonoTODO] + protected string GetStyleName (HtmlTextWriterStyle styleKey) + { + return StaticGetStyleName (styleKey); + } + + [MonoTODO] + protected virtual HtmlTextWriterTag GetTagKey (string tagName) + { + // I don't think we want to binary search + // because there might be something added to + // the enum later. Do we really need anything + // faster than a linear search? + + foreach (HtmlTag t in tags) { + if (String.Compare(t.name, tagName, true, CultureInfo.InvariantCulture) == 0) + return t.key; + } + + return HtmlTextWriterTag.Unknown; + } + + internal static string StaticGetTagName (HtmlTextWriterTag tagKey) + { + if ((int) tagKey < tags.Length) + return tags [(int) tagKey].name; + + return null; + } + + + [MonoTODO] + protected virtual string GetTagName (HtmlTextWriterTag tagKey) + { + if ((int) tagKey < tags.Length) + return tags [(int) tagKey].name; + + return null; + } + + protected bool IsAttributeDefined (HtmlTextWriterAttribute key) + { + string value; + return IsAttributeDefined (key, out value); + } + + protected bool IsAttributeDefined (HtmlTextWriterAttribute key, out string value) + { + for (int i = 0; i <= attrs_pos; i ++) + if (attrs [i].key == key){ + value = attrs [i].value; + return true; + } + + value = null; + return false; + } + + protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key) + { + string value; + return IsStyleAttributeDefined (key, out value); + } + + protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key, out string value) + { + for (int i = 0; i <= styles_pos; i ++) + if (styles [i].key == key){ + value = styles [i].value; + return true; + } + + value = null; + return false; + } + + protected virtual bool OnAttributeRender (string name, string value, HtmlTextWriterAttribute key) + { + return true; + } + + protected virtual bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key) + { + return true; + } + + protected virtual bool OnTagRender (string name, HtmlTextWriterTag key) + { + return true; + } + + + protected virtual void OutputTabs () + { + if (! newline) + return; + newline = false; + + for (int i = 0; i < Indent; i ++) + b.Write (tab_string); + } + + + + protected string PopEndTag () + { + if (tagstack_pos == -1) + throw new InvalidOperationException (); + + string s = TagName; + tagstack_pos --; + return s; + } + + protected void PushEndTag (string endTag) + { + NextTagStack (); + TagName = endTag; + } + + void PushEndTag (HtmlTextWriterTag t) + { + NextTagStack (); + TagKey = t; + } + + + protected virtual string RenderAfterContent () + { + return null; + } + + protected virtual string RenderAfterTag () + { + return null; + } + + protected virtual string RenderBeforeContent () + { + return null; + } + + protected virtual string RenderBeforeTag () + { + return null; + } + + public virtual void RenderBeginTag (string tagName) + { + if (! OnTagRender (tagName, GetTagKey (tagName))) + return; + + PushEndTag (tagName); + + DoBeginTag (); + } + + public virtual void RenderBeginTag (HtmlTextWriterTag tagKey) + { + if (! OnTagRender (GetTagName (tagKey), tagKey)) + return; + + PushEndTag (tagKey); + + DoBeginTag (); + } + + void WriteIfNotNull (string s) + { + if (s != null) + Write (s); + } + + + void DoBeginTag () + { + WriteIfNotNull (RenderBeforeTag ()); + WriteBeginTag (TagName); + FilterAttributes (); + + HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown; + + switch (tags [(int) key].tag_type) { + case TagType.Inline: + Write (TagRightChar); + break; + case TagType.Block: + Write (TagRightChar); + WriteLine (); + Indent ++; + break; + case TagType.SelfClosing: + Write (SelfClosingTagEnd); + break; + } + + // FIXME what do i do for self close here? + WriteIfNotNull (RenderBeforeContent ()); + } + + + public virtual void RenderEndTag () + { + // FIXME what do i do for self close here? + WriteIfNotNull (RenderAfterContent ()); + + HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown; + + switch (tags [(int) key].tag_type) { + case TagType.Inline: + WriteEndTag (TagName); + break; + case TagType.Block: + Indent --; + WriteLineNoTabs (""); + WriteEndTag (TagName); + + break; + case TagType.SelfClosing: + // NADA + break; + } + WriteIfNotNull (RenderAfterTag ()); + + PopEndTag (); + } + + + public virtual void WriteAttribute (string name, string value, bool fEncode) + { + Write (SpaceChar); + Write (name); + if (value != null) { + Write (EqualsDoubleQuoteString); + value = EncodeAttributeValue (value, fEncode); + Write (value); + Write (DoubleQuoteChar); + } + } + + + public virtual void WriteBeginTag (string tagName) + { + Write (TagLeftChar); + Write (tagName); + } + + public virtual void WriteEndTag (string tagName) + { + Write (EndTagLeftChars); + Write (tagName); + Write (TagRightChar); + } + + public virtual void WriteFullBeginTag (string tagName) + { + Write (TagLeftChar); + Write (tagName); + Write (TagRightChar); + } + + public virtual void WriteStyleAttribute (string name, string value) + { + WriteStyleAttribute (name, value, true); + } + + public virtual void WriteStyleAttribute (string name, string value, bool fEncode) + { +#if NET_2_0 + if (name == "background-image") { + value = String.Concat ("url(", value, ")"); + } +#endif + Write (name); + Write (StyleEqualsChar); + Write (EncodeAttributeValue (value, fEncode)); + Write (SemicolonChar); + } + + public override void Write (char [] buffer, int index, int count) + { + OutputTabs (); + b.Write (buffer, index, count); + } + + public override void Write (double value) + { + OutputTabs (); + b.Write (value); + } + + public override void Write (char value) + { + OutputTabs (); + b.Write (value); + } + + public override void Write (char [] buffer) + { + OutputTabs (); + b.Write (buffer); + } + + public override void Write (int value) + { + OutputTabs (); + b.Write (value); + } + + public override void Write (string format, object arg0) + { + OutputTabs (); + b.Write (format, arg0); + } + + public override void Write (string format, object arg0, object arg1) + { + OutputTabs (); + b.Write (format, arg0, arg1); + } + + public override void Write (string format, params object [] args) + { + OutputTabs (); + b.Write (format, args); + } + + public override void Write (string s) + { + OutputTabs (); + b.Write (s); + } + + public override void Write (long value) + { + OutputTabs (); + b.Write (value); + } + + public override void Write (object value) + { + OutputTabs (); + b.Write (value); + } + + public override void Write (float value) + { + OutputTabs (); + b.Write (value); + } + + public override void Write (bool value) + { + OutputTabs (); + b.Write (value); + } + + public virtual void WriteAttribute (string name, string value) + { + WriteAttribute (name, value, true); + } + + public override void WriteLine (char value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine (long value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine (object value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine (double value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine (char [] buffer, int index, int count) + { + OutputTabs (); + b.WriteLine (buffer, index, count); + newline = true; + } + + public override void WriteLine (char [] buffer) + { + OutputTabs (); + b.WriteLine (buffer); + newline = true; + } + + public override void WriteLine (bool value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine () + { + OutputTabs (); + b.WriteLine (); + newline = true; + } + + public override void WriteLine (int value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine (string format, object arg0, object arg1) + { + OutputTabs (); + b.WriteLine (format, arg0, arg1); + newline = true; + } + + public override void WriteLine (string format, object arg0) + { + OutputTabs (); + b.WriteLine (format, arg0); + newline = true; + } + + public override void WriteLine (string format, params object [] args) + { + OutputTabs (); + b.WriteLine (format, args); + newline = true; + } + + [CLSCompliant (false)] + public override void WriteLine (uint value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public override void WriteLine (string s) + { + OutputTabs (); + b.WriteLine (s); + newline = true; + } + + public override void WriteLine (float value) + { + OutputTabs (); + b.WriteLine (value); + newline = true; + } + + public void WriteLineNoTabs (string s) + { + b.WriteLine (s); + newline = true; + } + + public override Encoding Encoding { + get { + return b.Encoding; + } + } + + int indent; + public int Indent { + get { + return indent; + } + set { + indent = value; + } + } + + public System.IO.TextWriter InnerWriter { + get { + return b; + } + set { + b = value; + } + } + + public override string NewLine { + get { + return b.NewLine; + } + set { + b.NewLine = value; + } + } + + protected HtmlTextWriterTag TagKey { + get { + if (tagstack_pos == -1) + throw new InvalidOperationException (); + + return tagstack [tagstack_pos].key; + } + set { + tagstack [tagstack_pos].key = value; + tagstack [tagstack_pos].name = GetTagName (value); + } + } + + protected string TagName { + get { + if (tagstack_pos == -1) + throw new InvalidOperationException (); + + return tagstack [tagstack_pos].name; + } + set { + tagstack [tagstack_pos].name = value; + tagstack [tagstack_pos].key = GetTagKey (value); + if (tagstack [tagstack_pos].key != HtmlTextWriterTag.Unknown) + tagstack [tagstack_pos].name = GetTagName (tagstack [tagstack_pos].key); + } + } + + + TextWriter b; + string tab_string; + bool newline; + + // + // These emulate generic Stack , since we can't use that ;-(. _pos is the current + // element.IE, you edit blah [blah_pos]. I *really* want generics, sigh. + // + AddedStyle [] styles; + AddedAttr [] attrs; + AddedTag [] tagstack; + + int styles_pos = -1, attrs_pos = -1, tagstack_pos = -1; + + struct AddedTag { + public string name; + public HtmlTextWriterTag key; + } + + struct AddedStyle { + public string name; + public HtmlTextWriterStyle key; + public string value; + } + + struct AddedAttr { + public string name; + public HtmlTextWriterAttribute key; + public string value; + } + + void NextStyleStack () + { + if (styles == null) + styles = new AddedStyle [16]; + + if (++styles_pos < styles.Length) + return; + + int nsize = styles.Length * 2; + AddedStyle [] ncontents = new AddedStyle [nsize]; + + Array.Copy (styles, ncontents, styles.Length); + styles = ncontents; + } + + void NextAttrStack () + { + if (attrs == null) + attrs = new AddedAttr [16]; + + if (++attrs_pos < attrs.Length) + return; + + int nsize = attrs.Length * 2; + AddedAttr [] ncontents = new AddedAttr [nsize]; + + Array.Copy (attrs, ncontents, attrs.Length); + attrs = ncontents; + } + + void NextTagStack () + { + if (tagstack == null) + tagstack = new AddedTag [16]; + + if (++tagstack_pos < tagstack.Length) + return; + + int nsize = tagstack.Length * 2; + AddedTag [] ncontents = new AddedTag [nsize]; + + Array.Copy (tagstack, ncontents, tagstack.Length); + tagstack = ncontents; + } + + public const string DefaultTabString = "\t"; + public const char DoubleQuoteChar = '"'; + public const string EndTagLeftChars = ""; + public const char SemicolonChar = ';'; + public const char SingleQuoteChar = '\''; + public const char SlashChar = '/'; + public const char SpaceChar = ' ' ; + public const char StyleEqualsChar = ':'; + public const char TagLeftChar = '<'; + public const char TagRightChar = '>'; + + enum TagType { + Block, + Inline, + SelfClosing, + } + + + struct HtmlTag { + public HtmlTextWriterTag key; + public string name; + public TagType tag_type; + + public HtmlTag (HtmlTextWriterTag k, string n, TagType tt) + { + key = k; + name = n; + tag_type = tt; + } + } + + struct HtmlStyle { + public HtmlTextWriterStyle key; + public string name; + + public HtmlStyle (HtmlTextWriterStyle k, string n) + { + key = k; + name = n; + } + } + + + struct HtmlAttribute { + public HtmlTextWriterAttribute key; + public string name; + + public HtmlAttribute (HtmlTextWriterAttribute k, string n) + { + key = k; + name = n; + } + } + + static HtmlTag [] tags = { + new HtmlTag (HtmlTextWriterTag.Unknown, "", TagType.Block), + new HtmlTag (HtmlTextWriterTag.A, "a", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Acronym, "acronym", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Address, "address", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Area, "area", TagType.Block), + new HtmlTag (HtmlTextWriterTag.B, "b", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Base, "base", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Basefont, "basefont", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Bdo, "bdo", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Bgsound, "bgsound", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Big, "big", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Blockquote, "blockquote", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Body, "body", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Br, "br", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Button, "button", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Caption, "caption", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Center, "center", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Cite, "cite", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Code, "code", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Col, "col", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Colgroup, "colgroup", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Dd, "dd", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Del, "del", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Dfn, "dfn", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Dir, "dir", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Div, "div", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Dl, "dl", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Dt, "dt", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Em, "em", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Embed, "embed", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Fieldset, "fieldset", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Font, "font", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Form, "form", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Frame, "frame", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Frameset, "frameset", TagType.Block), + new HtmlTag (HtmlTextWriterTag.H1, "h1", TagType.Block), + new HtmlTag (HtmlTextWriterTag.H2, "h2", TagType.Block), + new HtmlTag (HtmlTextWriterTag.H3, "h3", TagType.Block), + new HtmlTag (HtmlTextWriterTag.H4, "h4", TagType.Block), + new HtmlTag (HtmlTextWriterTag.H5, "h5", TagType.Block), + new HtmlTag (HtmlTextWriterTag.H6, "h6", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Head, "head", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Hr, "hr", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Html, "html", TagType.Block), + new HtmlTag (HtmlTextWriterTag.I, "i", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Iframe, "iframe", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Img, "img", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Input, "input", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Ins, "ins", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Isindex, "isindex", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Kbd, "kbd", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Label, "label", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Legend, "legend", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Li, "li", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Link, "link", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Map, "map", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Marquee, "marquee", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Menu, "menu", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Meta, "meta", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Nobr, "nobr", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Noframes, "noframes", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Noscript, "noscript", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Object, "object", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Ol, "ol", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Option, "option", TagType.Block), + new HtmlTag (HtmlTextWriterTag.P, "p", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Param, "param", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Pre, "pre", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Q, "q", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Rt, "rt", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Ruby, "ruby", TagType.Block), + new HtmlTag (HtmlTextWriterTag.S, "s", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Samp, "samp", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Script, "script", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Select, "select", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Small, "small", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Span, "span", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Strike, "strike", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Strong, "strong", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Style, "style", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Sub, "sub", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Sup, "sup", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Table, "table", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Tbody, "tbody", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Td, "td", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Textarea, "textarea", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Tfoot, "tfoot", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Th, "th", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Thead, "thead", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Title, "title", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Tr, "tr", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Tt, "tt", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.U, "u", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Ul, "ul", TagType.Block), + new HtmlTag (HtmlTextWriterTag.Var, "var", TagType.Inline), + new HtmlTag (HtmlTextWriterTag.Wbr, "wbr", TagType.SelfClosing), + new HtmlTag (HtmlTextWriterTag.Xml, "xml", TagType.Block), + }; + + static HtmlAttribute [] htmlattrs = { + new HtmlAttribute (HtmlTextWriterAttribute.Accesskey, "accesskey"), + new HtmlAttribute (HtmlTextWriterAttribute.Align, "align"), + new HtmlAttribute (HtmlTextWriterAttribute.Alt, "alt"), + new HtmlAttribute (HtmlTextWriterAttribute.Background, "background"), + new HtmlAttribute (HtmlTextWriterAttribute.Bgcolor, "bgcolor"), + new HtmlAttribute (HtmlTextWriterAttribute.Border, "border"), + new HtmlAttribute (HtmlTextWriterAttribute.Bordercolor, "bordercolor"), + new HtmlAttribute (HtmlTextWriterAttribute.Cellpadding, "cellpadding"), + new HtmlAttribute (HtmlTextWriterAttribute.Cellspacing, "cellspacing"), + new HtmlAttribute (HtmlTextWriterAttribute.Checked, "checked"), + new HtmlAttribute (HtmlTextWriterAttribute.Class, "class"), + new HtmlAttribute (HtmlTextWriterAttribute.Cols, "cols"), + new HtmlAttribute (HtmlTextWriterAttribute.Colspan, "colspan"), + new HtmlAttribute (HtmlTextWriterAttribute.Disabled, "disabled"), + new HtmlAttribute (HtmlTextWriterAttribute.For, "for"), + new HtmlAttribute (HtmlTextWriterAttribute.Height, "height"), + new HtmlAttribute (HtmlTextWriterAttribute.Href, "href"), + new HtmlAttribute (HtmlTextWriterAttribute.Id, "id"), + new HtmlAttribute (HtmlTextWriterAttribute.Maxlength, "maxlength"), + new HtmlAttribute (HtmlTextWriterAttribute.Multiple, "multiple"), + new HtmlAttribute (HtmlTextWriterAttribute.Name, "name"), + new HtmlAttribute (HtmlTextWriterAttribute.Nowrap, "nowrap"), + new HtmlAttribute (HtmlTextWriterAttribute.Onchange, "onchange"), + new HtmlAttribute (HtmlTextWriterAttribute.Onclick, "onclick"), + new HtmlAttribute (HtmlTextWriterAttribute.ReadOnly, "readonly"), + new HtmlAttribute (HtmlTextWriterAttribute.Rows, "rows"), + new HtmlAttribute (HtmlTextWriterAttribute.Rowspan, "rowspan"), + new HtmlAttribute (HtmlTextWriterAttribute.Rules, "rules"), + new HtmlAttribute (HtmlTextWriterAttribute.Selected, "selected"), + new HtmlAttribute (HtmlTextWriterAttribute.Size, "size"), + new HtmlAttribute (HtmlTextWriterAttribute.Src, "src"), + new HtmlAttribute (HtmlTextWriterAttribute.Style, "style"), + new HtmlAttribute (HtmlTextWriterAttribute.Tabindex, "tabindex"), + new HtmlAttribute (HtmlTextWriterAttribute.Target, "target"), + new HtmlAttribute (HtmlTextWriterAttribute.Title, "title"), + new HtmlAttribute (HtmlTextWriterAttribute.Type, "type"), + new HtmlAttribute (HtmlTextWriterAttribute.Valign, "valign"), + new HtmlAttribute (HtmlTextWriterAttribute.Value, "value"), + new HtmlAttribute (HtmlTextWriterAttribute.Width, "width"), + new HtmlAttribute (HtmlTextWriterAttribute.Wrap, "wrap"), +#if NET_2_0 + new HtmlAttribute (HtmlTextWriterAttribute.Abbr, "abbr"), + new HtmlAttribute (HtmlTextWriterAttribute.AutoComplete, "autocomplete"), + new HtmlAttribute (HtmlTextWriterAttribute.Axis, "axis"), + new HtmlAttribute (HtmlTextWriterAttribute.Content, "content"), + new HtmlAttribute (HtmlTextWriterAttribute.Coords, "coords"), + new HtmlAttribute (HtmlTextWriterAttribute.DesignerRegion, "_designerregion"), + new HtmlAttribute (HtmlTextWriterAttribute.Dir, "dir"), + new HtmlAttribute (HtmlTextWriterAttribute.Headers, "headers"), + new HtmlAttribute (HtmlTextWriterAttribute.Longdesc, "longdesc"), + new HtmlAttribute (HtmlTextWriterAttribute.Rel, "rel"), + new HtmlAttribute (HtmlTextWriterAttribute.Scope, "scope"), + new HtmlAttribute (HtmlTextWriterAttribute.Shape, "shape"), + new HtmlAttribute (HtmlTextWriterAttribute.Usemap, "usemap"), + new HtmlAttribute (HtmlTextWriterAttribute.VCardName, "vcard_name"), +#endif + }; + + static HtmlStyle [] htmlstyles = { + new HtmlStyle (HtmlTextWriterStyle.BackgroundColor, "background-color"), + new HtmlStyle (HtmlTextWriterStyle.BackgroundImage, "background-image"), + new HtmlStyle (HtmlTextWriterStyle.BorderCollapse, "border-collapse"), + new HtmlStyle (HtmlTextWriterStyle.BorderColor, "border-color"), + new HtmlStyle (HtmlTextWriterStyle.BorderStyle, "border-style"), + new HtmlStyle (HtmlTextWriterStyle.BorderWidth, "border-width"), + new HtmlStyle (HtmlTextWriterStyle.Color, "color"), + new HtmlStyle (HtmlTextWriterStyle.FontFamily, "font-family"), + new HtmlStyle (HtmlTextWriterStyle.FontSize, "font-size"), + new HtmlStyle (HtmlTextWriterStyle.FontStyle, "font-style"), + new HtmlStyle (HtmlTextWriterStyle.FontWeight, "font-weight"), + new HtmlStyle (HtmlTextWriterStyle.Height, "height"), + new HtmlStyle (HtmlTextWriterStyle.TextDecoration, "text-decoration"), + new HtmlStyle (HtmlTextWriterStyle.Width, "width"), +#if NET_2_0 + new HtmlStyle (HtmlTextWriterStyle.ListStyleImage, "list-style-image"), + new HtmlStyle (HtmlTextWriterStyle.ListStyleType, "list-style-type"), + new HtmlStyle (HtmlTextWriterStyle.Cursor, "cursor"), + new HtmlStyle (HtmlTextWriterStyle.Direction, "direction"), + new HtmlStyle (HtmlTextWriterStyle.Display, "display"), + new HtmlStyle (HtmlTextWriterStyle.Filter, "filter"), + new HtmlStyle (HtmlTextWriterStyle.FontVariant, "font-variant"), + new HtmlStyle (HtmlTextWriterStyle.Left, "left"), + new HtmlStyle (HtmlTextWriterStyle.Margin, "margin"), + new HtmlStyle (HtmlTextWriterStyle.MarginBottom, "margin-bottom"), + new HtmlStyle (HtmlTextWriterStyle.MarginLeft, "margin-left"), + new HtmlStyle (HtmlTextWriterStyle.MarginRight, "margin-right"), + new HtmlStyle (HtmlTextWriterStyle.MarginTop, "margin-top"), + new HtmlStyle (HtmlTextWriterStyle.Overflow, "overflow"), + new HtmlStyle (HtmlTextWriterStyle.OverflowX, "overflow-x"), + new HtmlStyle (HtmlTextWriterStyle.OverflowY, "overflow-y"), + new HtmlStyle (HtmlTextWriterStyle.Padding, "padding"), + new HtmlStyle (HtmlTextWriterStyle.PaddingBottom, "padding-bottom"), + new HtmlStyle (HtmlTextWriterStyle.PaddingLeft, "padding-left"), + new HtmlStyle (HtmlTextWriterStyle.PaddingRight, "padding-right"), + new HtmlStyle (HtmlTextWriterStyle.PaddingTop, "padding-top"), + new HtmlStyle (HtmlTextWriterStyle.Position, "position"), + new HtmlStyle (HtmlTextWriterStyle.TextAlign, "text-align"), + new HtmlStyle (HtmlTextWriterStyle.VerticalAlign, "vertical-align"), + new HtmlStyle (HtmlTextWriterStyle.TextOverflow, "text-overflow"), + new HtmlStyle (HtmlTextWriterStyle.Top, "top"), + new HtmlStyle (HtmlTextWriterStyle.Visibility, "visibility"), + new HtmlStyle (HtmlTextWriterStyle.WhiteSpace, "white-space"), + new HtmlStyle (HtmlTextWriterStyle.ZIndex, "z-index"), +#endif + }; + +#if NET_2_0 + public virtual bool IsValidFormAttribute (string attribute) + { + return true; + } + + // writes
+ public virtual void WriteBreak () + { + string br = GetTagName (HtmlTextWriterTag.Br); + WriteBeginTag (br); + Write (SelfClosingTagEnd); + } +#endif + } +}