2 // System.Web.UI.HtmlTextWriter
5 // Ben Maurer <bmaurer@novell.com>
7 // (c) 2005-2010 Novell, Inc (http://novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Globalization;
31 using System.Collections;
32 using System.Security.Permissions;
34 using System.Web.UI.WebControls;
36 namespace System.Web.UI {
39 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
40 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
41 public class HtmlTextWriter : TextWriter {
44 readonly static Hashtable _tagTable;
45 readonly static Hashtable _attributeTable;
46 readonly static Hashtable _styleTable;
48 static HtmlTextWriter ()
50 _tagTable = new Hashtable (tags.Length, StringComparer.OrdinalIgnoreCase);
51 _attributeTable = new Hashtable (htmlattrs.Length, StringComparer.OrdinalIgnoreCase);
52 _styleTable = new Hashtable (htmlstyles.Length, StringComparer.OrdinalIgnoreCase);
53 foreach (HtmlTag tag in tags)
54 _tagTable.Add (tag.name, tag);
56 foreach (HtmlAttribute attr in htmlattrs)
57 _attributeTable.Add (attr.name, attr);
59 foreach (HtmlStyle style in htmlstyles)
60 _styleTable.Add (style.name, style);
63 public HtmlTextWriter (TextWriter writer) : this (writer, DefaultTabString)
67 public HtmlTextWriter (TextWriter writer, string tabString)
70 tab_string = tabString;
73 internal static string StaticGetStyleName (System.Web.UI.HtmlTextWriterStyle styleKey)
75 if ((int) styleKey < htmlstyles.Length)
76 return htmlstyles [(int) styleKey].name;
81 [MonoTODO ("Does nothing")]
82 protected static void RegisterAttribute (string name, HtmlTextWriterAttribute key)
86 [MonoTODO ("Does nothing")]
87 protected static void RegisterStyle (string name, HtmlTextWriterStyle key)
91 [MonoTODO ("Does nothing")]
92 protected static void RegisterTag (string name, HtmlTextWriterTag key)
97 public virtual void AddAttribute (HtmlTextWriterAttribute key, string value, bool fEncode)
100 value = HttpUtility.HtmlAttributeEncode (value);
102 AddAttribute (GetAttributeName (key), value, key);
106 public virtual void AddAttribute (HtmlTextWriterAttribute key, string value)
108 if ((key != HtmlTextWriterAttribute.Name) && (key != HtmlTextWriterAttribute.Id))
109 value = HttpUtility.HtmlAttributeEncode (value);
111 AddAttribute (GetAttributeName (key), value, key);
115 public virtual void AddAttribute (string name, string value, bool fEncode)
118 value = HttpUtility.HtmlAttributeEncode (value);
120 AddAttribute (name, value, GetAttributeKey (name));
123 public virtual void AddAttribute (string name, string value)
125 HtmlTextWriterAttribute key = GetAttributeKey (name);
127 if ((key != HtmlTextWriterAttribute.Name) && (key != HtmlTextWriterAttribute.Id))
128 value = HttpUtility.HtmlAttributeEncode (value);
130 AddAttribute (name, value, key);
133 protected virtual void AddAttribute (string name, string value, HtmlTextWriterAttribute key)
136 attrs [attrs_pos].name = name;
137 attrs [attrs_pos].value = value;
138 attrs [attrs_pos].key = key;
142 protected virtual void AddStyleAttribute (string name, string value, HtmlTextWriterStyle key)
145 styles [styles_pos].name = name;
146 value = HttpUtility.HtmlAttributeEncode (value);
147 styles [styles_pos].value = value;
148 styles [styles_pos].key = key;
152 public virtual void AddStyleAttribute (string name, string value)
154 AddStyleAttribute (name, value, GetStyleKey (name));
157 public virtual void AddStyleAttribute (HtmlTextWriterStyle key, string value)
159 AddStyleAttribute (GetStyleName (key), value, key);
162 public override void Close ()
167 protected virtual string EncodeAttributeValue (HtmlTextWriterAttribute attrKey, string value)
169 return HttpUtility.HtmlAttributeEncode (value);
172 protected string EncodeAttributeValue (string value, bool fEncode)
175 return HttpUtility.HtmlAttributeEncode (value);
179 protected string EncodeUrl (string url)
181 return HttpUtility.UrlPathEncode (url);
185 protected virtual void FilterAttributes ()
187 AddedAttr style_attr = new AddedAttr ();
189 for (int i = 0; i <= attrs_pos; i++) {
190 AddedAttr a = attrs [i];
191 if (OnAttributeRender (a.name, a.value, a.key)) {
192 if (a.key == HtmlTextWriterAttribute.Style) {
197 WriteAttribute (a.name, a.value, false);
201 if (styles_pos != -1 || style_attr.value != null) {
204 Write (EqualsDoubleQuoteString);
207 for (int i = 0; i <= styles_pos; i++) {
208 AddedStyle a = styles [i];
209 if (OnStyleAttributeRender (a.name, a.value, a.key)) {
210 if (a.key == HtmlTextWriterStyle.BackgroundImage)
211 a.value = String.Concat ("url(", HttpUtility.UrlPathEncode (a.value), ")");
212 WriteStyleAttribute (a.name, a.value, false);
216 Write (style_attr.value);
217 Write (DoubleQuoteChar);
220 styles_pos = attrs_pos = -1;
223 public override void Flush ()
228 protected HtmlTextWriterAttribute GetAttributeKey (string attrName)
230 object attribute = _attributeTable [attrName];
231 if (attribute == null)
232 return (HtmlTextWriterAttribute) (-1);
234 return (HtmlTextWriterAttribute) ((HtmlAttribute) attribute).key;
237 protected string GetAttributeName (HtmlTextWriterAttribute attrKey)
239 if ((int) attrKey < htmlattrs.Length)
240 return htmlattrs [(int) attrKey].name;
245 protected HtmlTextWriterStyle GetStyleKey (string styleName)
247 object style = _styleTable [styleName];
249 return (HtmlTextWriterStyle) (-1);
251 return (HtmlTextWriterStyle) ((HtmlStyle) style).key;
254 protected string GetStyleName (HtmlTextWriterStyle styleKey)
256 return StaticGetStyleName (styleKey);
259 protected virtual HtmlTextWriterTag GetTagKey (string tagName)
261 object tag = _tagTable [tagName];
263 return HtmlTextWriterTag.Unknown;
265 return (HtmlTextWriterTag) ((HtmlTag) tag).key;
268 internal static string StaticGetTagName (HtmlTextWriterTag tagKey)
270 if ((int) tagKey < tags.Length)
271 return tags [(int) tagKey].name;
277 protected virtual string GetTagName (HtmlTextWriterTag tagKey)
279 if ((int) tagKey < tags.Length)
280 return tags [(int) tagKey].name;
285 protected bool IsAttributeDefined (HtmlTextWriterAttribute key)
288 return IsAttributeDefined (key, out value);
291 protected bool IsAttributeDefined (HtmlTextWriterAttribute key, out string value)
293 for (int i = 0; i <= attrs_pos; i++)
294 if (attrs [i].key == key) {
295 value = attrs [i].value;
303 protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key)
306 return IsStyleAttributeDefined (key, out value);
309 protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key, out string value)
311 for (int i = 0; i <= styles_pos; i++)
312 if (styles [i].key == key) {
313 value = styles [i].value;
321 protected virtual bool OnAttributeRender (string name, string value, HtmlTextWriterAttribute key)
326 protected virtual bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key)
331 protected virtual bool OnTagRender (string name, HtmlTextWriterTag key)
337 protected virtual void OutputTabs ()
343 for (int i = 0; i < Indent; i++)
344 b.Write (tab_string);
349 protected string PopEndTag ()
351 if (tagstack_pos == -1)
352 throw new InvalidOperationException ();
359 protected void PushEndTag (string endTag)
365 void PushEndTag (HtmlTextWriterTag t)
372 protected virtual string RenderAfterContent ()
377 protected virtual string RenderAfterTag ()
382 protected virtual string RenderBeforeContent ()
387 protected virtual string RenderBeforeTag ()
392 public virtual void RenderBeginTag (string tagName)
394 bool ignore = !OnTagRender (tagName, GetTagKey (tagName));
396 PushEndTag (tagName);
401 public virtual void RenderBeginTag (HtmlTextWriterTag tagKey)
403 bool ignore = !OnTagRender (GetTagName (tagKey), tagKey);
410 void WriteIfNotNull (string s)
419 WriteIfNotNull (RenderBeforeTag ());
421 WriteBeginTag (TagName);
424 HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown;
426 switch (tags [(int) key].tag_type) {
428 Write (TagRightChar);
431 Write (TagRightChar);
435 case TagType.SelfClosing:
436 Write (SelfClosingTagEnd);
441 // FIXME what do i do for self close here?
442 WriteIfNotNull (RenderBeforeContent ());
446 public virtual void RenderEndTag ()
449 // FIXME what do i do for self close here?
450 WriteIfNotNull (RenderAfterContent ());
453 HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown;
455 switch (tags [(int) key].tag_type) {
457 WriteEndTag (TagName);
461 WriteLineNoTabs (String.Empty);
462 WriteEndTag (TagName);
465 case TagType.SelfClosing:
471 WriteIfNotNull (RenderAfterTag ());
477 public virtual void WriteAttribute (string name, string value, bool fEncode)
482 Write (EqualsDoubleQuoteString);
483 value = EncodeAttributeValue (value, fEncode);
485 Write (DoubleQuoteChar);
490 public virtual void WriteBeginTag (string tagName)
496 public virtual void WriteEndTag (string tagName)
498 Write (EndTagLeftChars);
500 Write (TagRightChar);
503 public virtual void WriteFullBeginTag (string tagName)
507 Write (TagRightChar);
510 public virtual void WriteStyleAttribute (string name, string value)
512 WriteStyleAttribute (name, value, false);
515 public virtual void WriteStyleAttribute (string name, string value, bool fEncode)
518 Write (StyleEqualsChar);
519 Write (EncodeAttributeValue (value, fEncode));
520 Write (SemicolonChar);
523 public override void Write (char [] buffer, int index, int count)
526 b.Write (buffer, index, count);
529 public override void Write (double value)
535 public override void Write (char value)
541 public override void Write (char [] buffer)
547 public override void Write (int value)
553 public override void Write (string format, object arg0)
556 b.Write (format, arg0);
559 public override void Write (string format, object arg0, object arg1)
562 b.Write (format, arg0, arg1);
565 public override void Write (string format, params object [] args)
568 b.Write (format, args);
571 public override void Write (string s)
577 public override void Write (long value)
583 public override void Write (object value)
589 public override void Write (float value)
595 public override void Write (bool value)
601 public virtual void WriteAttribute (string name, string value)
603 WriteAttribute (name, value, false);
606 public override void WriteLine (char value)
613 public override void WriteLine (long value)
620 public override void WriteLine (object value)
627 public override void WriteLine (double value)
634 public override void WriteLine (char [] buffer, int index, int count)
637 b.WriteLine (buffer, index, count);
641 public override void WriteLine (char [] buffer)
644 b.WriteLine (buffer);
648 public override void WriteLine (bool value)
655 public override void WriteLine ()
662 public override void WriteLine (int value)
669 public override void WriteLine (string format, object arg0, object arg1)
672 b.WriteLine (format, arg0, arg1);
676 public override void WriteLine (string format, object arg0)
679 b.WriteLine (format, arg0);
683 public override void WriteLine (string format, params object [] args)
686 b.WriteLine (format, args);
690 [CLSCompliant (false)]
691 public override void WriteLine (uint value)
698 public override void WriteLine (string s)
705 public override void WriteLine (float value)
712 public void WriteLineNoTabs (string s)
718 public override Encoding Encoding {
734 public System.IO.TextWriter InnerWriter {
743 public override string NewLine {
752 protected HtmlTextWriterTag TagKey {
754 if (tagstack_pos == -1)
755 throw new InvalidOperationException ();
757 return tagstack [tagstack_pos].key;
760 tagstack [tagstack_pos].key = value;
761 tagstack [tagstack_pos].name = GetTagName (value);
765 protected string TagName {
767 if (tagstack_pos == -1)
768 throw new InvalidOperationException ();
770 return tagstack [tagstack_pos].name;
773 tagstack [tagstack_pos].name = value;
774 tagstack [tagstack_pos].key = GetTagKey (value);
775 if (tagstack [tagstack_pos].key != HtmlTextWriterTag.Unknown)
776 tagstack [tagstack_pos].name = GetTagName (tagstack [tagstack_pos].key);
782 if (tagstack_pos == -1)
783 throw new InvalidOperationException ();
785 return tagstack [tagstack_pos].ignore;
789 if (tagstack_pos == -1)
790 throw new InvalidOperationException ();
792 tagstack [tagstack_pos].ignore = value;
796 internal HttpWriter GetHttpWriter ()
798 return b as HttpWriter;
806 // These emulate generic Stack <T>, since we can't use that ;-(. _pos is the current
807 // element.IE, you edit blah [blah_pos]. I *really* want generics, sigh.
809 AddedStyle [] styles;
811 AddedTag [] tagstack;
813 int styles_pos = -1, attrs_pos = -1, tagstack_pos = -1;
818 public HtmlTextWriterTag key;
825 public HtmlTextWriterStyle key;
832 public HtmlTextWriterAttribute key;
836 void NextStyleStack ()
839 styles = new AddedStyle [16];
841 if (++styles_pos < styles.Length)
844 int nsize = styles.Length * 2;
845 AddedStyle [] ncontents = new AddedStyle [nsize];
847 Array.Copy (styles, ncontents, styles.Length);
851 void NextAttrStack ()
854 attrs = new AddedAttr [16];
856 if (++attrs_pos < attrs.Length)
859 int nsize = attrs.Length * 2;
860 AddedAttr [] ncontents = new AddedAttr [nsize];
862 Array.Copy (attrs, ncontents, attrs.Length);
868 if (tagstack == null)
869 tagstack = new AddedTag [16];
871 if (++tagstack_pos < tagstack.Length)
874 int nsize = tagstack.Length * 2;
875 AddedTag [] ncontents = new AddedTag [nsize];
877 Array.Copy (tagstack, ncontents, tagstack.Length);
878 tagstack = ncontents;
881 public const string DefaultTabString = "\t";
882 public const char DoubleQuoteChar = '"';
883 public const string EndTagLeftChars = "</";
884 public const char EqualsChar = '=';
885 public const string EqualsDoubleQuoteString = "=\"";
886 public const string SelfClosingChars = " /";
887 public const string SelfClosingTagEnd = " />";
888 public const char SemicolonChar = ';';
889 public const char SingleQuoteChar = '\'';
890 public const char SlashChar = '/';
891 public const char SpaceChar = ' ';
892 public const char StyleEqualsChar = ':';
893 public const char TagLeftChar = '<';
894 public const char TagRightChar = '>';
903 sealed class HtmlTag {
904 readonly public HtmlTextWriterTag key;
905 readonly public string name;
906 readonly public TagType tag_type;
908 public HtmlTag (HtmlTextWriterTag k, string n, TagType tt)
916 sealed class HtmlStyle {
917 readonly public HtmlTextWriterStyle key;
918 readonly public string name;
920 public HtmlStyle (HtmlTextWriterStyle k, string n)
928 sealed class HtmlAttribute {
929 readonly public HtmlTextWriterAttribute key;
930 readonly public string name;
932 public HtmlAttribute (HtmlTextWriterAttribute k, string n)
939 static HtmlTag [] tags = {
940 new HtmlTag (HtmlTextWriterTag.Unknown, String.Empty, TagType.Block),
941 new HtmlTag (HtmlTextWriterTag.A, "a", TagType.Inline),
942 new HtmlTag (HtmlTextWriterTag.Acronym, "acronym", TagType.Inline),
943 new HtmlTag (HtmlTextWriterTag.Address, "address", TagType.Block),
944 new HtmlTag (HtmlTextWriterTag.Area, "area", TagType.Block),
945 new HtmlTag (HtmlTextWriterTag.B, "b", TagType.Inline),
946 new HtmlTag (HtmlTextWriterTag.Base, "base", TagType.SelfClosing),
947 new HtmlTag (HtmlTextWriterTag.Basefont, "basefont", TagType.SelfClosing),
948 new HtmlTag (HtmlTextWriterTag.Bdo, "bdo", TagType.Inline),
949 new HtmlTag (HtmlTextWriterTag.Bgsound, "bgsound", TagType.SelfClosing),
950 new HtmlTag (HtmlTextWriterTag.Big, "big", TagType.Inline),
951 new HtmlTag (HtmlTextWriterTag.Blockquote, "blockquote", TagType.Block),
952 new HtmlTag (HtmlTextWriterTag.Body, "body", TagType.Block),
953 new HtmlTag (HtmlTextWriterTag.Br, "br", TagType.Block),
954 new HtmlTag (HtmlTextWriterTag.Button, "button", TagType.Inline),
955 new HtmlTag (HtmlTextWriterTag.Caption, "caption", TagType.Block),
956 new HtmlTag (HtmlTextWriterTag.Center, "center", TagType.Block),
957 new HtmlTag (HtmlTextWriterTag.Cite, "cite", TagType.Inline),
958 new HtmlTag (HtmlTextWriterTag.Code, "code", TagType.Inline),
959 new HtmlTag (HtmlTextWriterTag.Col, "col", TagType.SelfClosing),
960 new HtmlTag (HtmlTextWriterTag.Colgroup, "colgroup", TagType.Block),
961 new HtmlTag (HtmlTextWriterTag.Dd, "dd", TagType.Inline),
962 new HtmlTag (HtmlTextWriterTag.Del, "del", TagType.Inline),
963 new HtmlTag (HtmlTextWriterTag.Dfn, "dfn", TagType.Inline),
964 new HtmlTag (HtmlTextWriterTag.Dir, "dir", TagType.Block),
965 new HtmlTag (HtmlTextWriterTag.Div, "div", TagType.Block),
966 new HtmlTag (HtmlTextWriterTag.Dl, "dl", TagType.Block),
967 new HtmlTag (HtmlTextWriterTag.Dt, "dt", TagType.Inline),
968 new HtmlTag (HtmlTextWriterTag.Em, "em", TagType.Inline),
969 new HtmlTag (HtmlTextWriterTag.Embed, "embed", TagType.SelfClosing),
970 new HtmlTag (HtmlTextWriterTag.Fieldset, "fieldset", TagType.Block),
971 new HtmlTag (HtmlTextWriterTag.Font, "font", TagType.Inline),
972 new HtmlTag (HtmlTextWriterTag.Form, "form", TagType.Block),
973 new HtmlTag (HtmlTextWriterTag.Frame, "frame", TagType.SelfClosing),
974 new HtmlTag (HtmlTextWriterTag.Frameset, "frameset", TagType.Block),
975 new HtmlTag (HtmlTextWriterTag.H1, "h1", TagType.Block),
976 new HtmlTag (HtmlTextWriterTag.H2, "h2", TagType.Block),
977 new HtmlTag (HtmlTextWriterTag.H3, "h3", TagType.Block),
978 new HtmlTag (HtmlTextWriterTag.H4, "h4", TagType.Block),
979 new HtmlTag (HtmlTextWriterTag.H5, "h5", TagType.Block),
980 new HtmlTag (HtmlTextWriterTag.H6, "h6", TagType.Block),
981 new HtmlTag (HtmlTextWriterTag.Head, "head", TagType.Block),
982 new HtmlTag (HtmlTextWriterTag.Hr, "hr", TagType.SelfClosing),
983 new HtmlTag (HtmlTextWriterTag.Html, "html", TagType.Block),
984 new HtmlTag (HtmlTextWriterTag.I, "i", TagType.Inline),
985 new HtmlTag (HtmlTextWriterTag.Iframe, "iframe", TagType.Block),
986 new HtmlTag (HtmlTextWriterTag.Img, "img", TagType.SelfClosing),
987 new HtmlTag (HtmlTextWriterTag.Input, "input", TagType.SelfClosing),
988 new HtmlTag (HtmlTextWriterTag.Ins, "ins", TagType.Inline),
989 new HtmlTag (HtmlTextWriterTag.Isindex, "isindex", TagType.SelfClosing),
990 new HtmlTag (HtmlTextWriterTag.Kbd, "kbd", TagType.Inline),
991 new HtmlTag (HtmlTextWriterTag.Label, "label", TagType.Inline),
992 new HtmlTag (HtmlTextWriterTag.Legend, "legend", TagType.Block),
993 new HtmlTag (HtmlTextWriterTag.Li, "li", TagType.Inline),
994 new HtmlTag (HtmlTextWriterTag.Link, "link", TagType.SelfClosing),
995 new HtmlTag (HtmlTextWriterTag.Map, "map", TagType.Block),
996 new HtmlTag (HtmlTextWriterTag.Marquee, "marquee", TagType.Block),
997 new HtmlTag (HtmlTextWriterTag.Menu, "menu", TagType.Block),
998 new HtmlTag (HtmlTextWriterTag.Meta, "meta", TagType.SelfClosing),
999 new HtmlTag (HtmlTextWriterTag.Nobr, "nobr", TagType.Inline),
1000 new HtmlTag (HtmlTextWriterTag.Noframes, "noframes", TagType.Block),
1001 new HtmlTag (HtmlTextWriterTag.Noscript, "noscript", TagType.Block),
1002 new HtmlTag (HtmlTextWriterTag.Object, "object", TagType.Block),
1003 new HtmlTag (HtmlTextWriterTag.Ol, "ol", TagType.Block),
1004 new HtmlTag (HtmlTextWriterTag.Option, "option", TagType.Block),
1005 new HtmlTag (HtmlTextWriterTag.P, "p", TagType.Inline),
1006 new HtmlTag (HtmlTextWriterTag.Param, "param", TagType.Block),
1007 new HtmlTag (HtmlTextWriterTag.Pre, "pre", TagType.Block),
1008 new HtmlTag (HtmlTextWriterTag.Q, "q", TagType.Inline),
1009 new HtmlTag (HtmlTextWriterTag.Rt, "rt", TagType.Block),
1010 new HtmlTag (HtmlTextWriterTag.Ruby, "ruby", TagType.Block),
1011 new HtmlTag (HtmlTextWriterTag.S, "s", TagType.Inline),
1012 new HtmlTag (HtmlTextWriterTag.Samp, "samp", TagType.Inline),
1013 new HtmlTag (HtmlTextWriterTag.Script, "script", TagType.Block),
1014 new HtmlTag (HtmlTextWriterTag.Select, "select", TagType.Block),
1015 new HtmlTag (HtmlTextWriterTag.Small, "small", TagType.Block),
1016 new HtmlTag (HtmlTextWriterTag.Span, "span", TagType.Inline),
1017 new HtmlTag (HtmlTextWriterTag.Strike, "strike", TagType.Inline),
1018 new HtmlTag (HtmlTextWriterTag.Strong, "strong", TagType.Inline),
1019 new HtmlTag (HtmlTextWriterTag.Style, "style", TagType.Block),
1020 new HtmlTag (HtmlTextWriterTag.Sub, "sub", TagType.Inline),
1021 new HtmlTag (HtmlTextWriterTag.Sup, "sup", TagType.Inline),
1022 new HtmlTag (HtmlTextWriterTag.Table, "table", TagType.Block),
1023 new HtmlTag (HtmlTextWriterTag.Tbody, "tbody", TagType.Block),
1024 new HtmlTag (HtmlTextWriterTag.Td, "td", TagType.Inline),
1025 new HtmlTag (HtmlTextWriterTag.Textarea, "textarea", TagType.Inline),
1026 new HtmlTag (HtmlTextWriterTag.Tfoot, "tfoot", TagType.Block),
1027 new HtmlTag (HtmlTextWriterTag.Th, "th", TagType.Inline),
1028 new HtmlTag (HtmlTextWriterTag.Thead, "thead", TagType.Block),
1029 new HtmlTag (HtmlTextWriterTag.Title, "title", TagType.Block),
1030 new HtmlTag (HtmlTextWriterTag.Tr, "tr", TagType.Block),
1031 new HtmlTag (HtmlTextWriterTag.Tt, "tt", TagType.Inline),
1032 new HtmlTag (HtmlTextWriterTag.U, "u", TagType.Inline),
1033 new HtmlTag (HtmlTextWriterTag.Ul, "ul", TagType.Block),
1034 new HtmlTag (HtmlTextWriterTag.Var, "var", TagType.Inline),
1035 new HtmlTag (HtmlTextWriterTag.Wbr, "wbr", TagType.SelfClosing),
1036 new HtmlTag (HtmlTextWriterTag.Xml, "xml", TagType.Block),
1039 static HtmlAttribute [] htmlattrs = {
1040 new HtmlAttribute (HtmlTextWriterAttribute.Accesskey, "accesskey"),
1041 new HtmlAttribute (HtmlTextWriterAttribute.Align, "align"),
1042 new HtmlAttribute (HtmlTextWriterAttribute.Alt, "alt"),
1043 new HtmlAttribute (HtmlTextWriterAttribute.Background, "background"),
1044 new HtmlAttribute (HtmlTextWriterAttribute.Bgcolor, "bgcolor"),
1045 new HtmlAttribute (HtmlTextWriterAttribute.Border, "border"),
1046 new HtmlAttribute (HtmlTextWriterAttribute.Bordercolor, "bordercolor"),
1047 new HtmlAttribute (HtmlTextWriterAttribute.Cellpadding, "cellpadding"),
1048 new HtmlAttribute (HtmlTextWriterAttribute.Cellspacing, "cellspacing"),
1049 new HtmlAttribute (HtmlTextWriterAttribute.Checked, "checked"),
1050 new HtmlAttribute (HtmlTextWriterAttribute.Class, "class"),
1051 new HtmlAttribute (HtmlTextWriterAttribute.Cols, "cols"),
1052 new HtmlAttribute (HtmlTextWriterAttribute.Colspan, "colspan"),
1053 new HtmlAttribute (HtmlTextWriterAttribute.Disabled, "disabled"),
1054 new HtmlAttribute (HtmlTextWriterAttribute.For, "for"),
1055 new HtmlAttribute (HtmlTextWriterAttribute.Height, "height"),
1056 new HtmlAttribute (HtmlTextWriterAttribute.Href, "href"),
1057 new HtmlAttribute (HtmlTextWriterAttribute.Id, "id"),
1058 new HtmlAttribute (HtmlTextWriterAttribute.Maxlength, "maxlength"),
1059 new HtmlAttribute (HtmlTextWriterAttribute.Multiple, "multiple"),
1060 new HtmlAttribute (HtmlTextWriterAttribute.Name, "name"),
1061 new HtmlAttribute (HtmlTextWriterAttribute.Nowrap, "nowrap"),
1062 new HtmlAttribute (HtmlTextWriterAttribute.Onchange, "onchange"),
1063 new HtmlAttribute (HtmlTextWriterAttribute.Onclick, "onclick"),
1064 new HtmlAttribute (HtmlTextWriterAttribute.ReadOnly, "readonly"),
1065 new HtmlAttribute (HtmlTextWriterAttribute.Rows, "rows"),
1066 new HtmlAttribute (HtmlTextWriterAttribute.Rowspan, "rowspan"),
1067 new HtmlAttribute (HtmlTextWriterAttribute.Rules, "rules"),
1068 new HtmlAttribute (HtmlTextWriterAttribute.Selected, "selected"),
1069 new HtmlAttribute (HtmlTextWriterAttribute.Size, "size"),
1070 new HtmlAttribute (HtmlTextWriterAttribute.Src, "src"),
1071 new HtmlAttribute (HtmlTextWriterAttribute.Style, "style"),
1072 new HtmlAttribute (HtmlTextWriterAttribute.Tabindex, "tabindex"),
1073 new HtmlAttribute (HtmlTextWriterAttribute.Target, "target"),
1074 new HtmlAttribute (HtmlTextWriterAttribute.Title, "title"),
1075 new HtmlAttribute (HtmlTextWriterAttribute.Type, "type"),
1076 new HtmlAttribute (HtmlTextWriterAttribute.Valign, "valign"),
1077 new HtmlAttribute (HtmlTextWriterAttribute.Value, "value"),
1078 new HtmlAttribute (HtmlTextWriterAttribute.Width, "width"),
1079 new HtmlAttribute (HtmlTextWriterAttribute.Wrap, "wrap"),
1080 new HtmlAttribute (HtmlTextWriterAttribute.Abbr, "abbr"),
1081 new HtmlAttribute (HtmlTextWriterAttribute.AutoComplete, "autocomplete"),
1082 new HtmlAttribute (HtmlTextWriterAttribute.Axis, "axis"),
1083 new HtmlAttribute (HtmlTextWriterAttribute.Content, "content"),
1084 new HtmlAttribute (HtmlTextWriterAttribute.Coords, "coords"),
1085 new HtmlAttribute (HtmlTextWriterAttribute.DesignerRegion, "_designerregion"),
1086 new HtmlAttribute (HtmlTextWriterAttribute.Dir, "dir"),
1087 new HtmlAttribute (HtmlTextWriterAttribute.Headers, "headers"),
1088 new HtmlAttribute (HtmlTextWriterAttribute.Longdesc, "longdesc"),
1089 new HtmlAttribute (HtmlTextWriterAttribute.Rel, "rel"),
1090 new HtmlAttribute (HtmlTextWriterAttribute.Scope, "scope"),
1091 new HtmlAttribute (HtmlTextWriterAttribute.Shape, "shape"),
1092 new HtmlAttribute (HtmlTextWriterAttribute.Usemap, "usemap"),
1093 new HtmlAttribute (HtmlTextWriterAttribute.VCardName, "vcard_name"),
1096 static HtmlStyle [] htmlstyles = {
1097 new HtmlStyle (HtmlTextWriterStyle.BackgroundColor, "background-color"),
1098 new HtmlStyle (HtmlTextWriterStyle.BackgroundImage, "background-image"),
1099 new HtmlStyle (HtmlTextWriterStyle.BorderCollapse, "border-collapse"),
1100 new HtmlStyle (HtmlTextWriterStyle.BorderColor, "border-color"),
1101 new HtmlStyle (HtmlTextWriterStyle.BorderStyle, "border-style"),
1102 new HtmlStyle (HtmlTextWriterStyle.BorderWidth, "border-width"),
1103 new HtmlStyle (HtmlTextWriterStyle.Color, "color"),
1104 new HtmlStyle (HtmlTextWriterStyle.FontFamily, "font-family"),
1105 new HtmlStyle (HtmlTextWriterStyle.FontSize, "font-size"),
1106 new HtmlStyle (HtmlTextWriterStyle.FontStyle, "font-style"),
1107 new HtmlStyle (HtmlTextWriterStyle.FontWeight, "font-weight"),
1108 new HtmlStyle (HtmlTextWriterStyle.Height, "height"),
1109 new HtmlStyle (HtmlTextWriterStyle.TextDecoration, "text-decoration"),
1110 new HtmlStyle (HtmlTextWriterStyle.Width, "width"),
1111 new HtmlStyle (HtmlTextWriterStyle.ListStyleImage, "list-style-image"),
1112 new HtmlStyle (HtmlTextWriterStyle.ListStyleType, "list-style-type"),
1113 new HtmlStyle (HtmlTextWriterStyle.Cursor, "cursor"),
1114 new HtmlStyle (HtmlTextWriterStyle.Direction, "direction"),
1115 new HtmlStyle (HtmlTextWriterStyle.Display, "display"),
1116 new HtmlStyle (HtmlTextWriterStyle.Filter, "filter"),
1117 new HtmlStyle (HtmlTextWriterStyle.FontVariant, "font-variant"),
1118 new HtmlStyle (HtmlTextWriterStyle.Left, "left"),
1119 new HtmlStyle (HtmlTextWriterStyle.Margin, "margin"),
1120 new HtmlStyle (HtmlTextWriterStyle.MarginBottom, "margin-bottom"),
1121 new HtmlStyle (HtmlTextWriterStyle.MarginLeft, "margin-left"),
1122 new HtmlStyle (HtmlTextWriterStyle.MarginRight, "margin-right"),
1123 new HtmlStyle (HtmlTextWriterStyle.MarginTop, "margin-top"),
1124 new HtmlStyle (HtmlTextWriterStyle.Overflow, "overflow"),
1125 new HtmlStyle (HtmlTextWriterStyle.OverflowX, "overflow-x"),
1126 new HtmlStyle (HtmlTextWriterStyle.OverflowY, "overflow-y"),
1127 new HtmlStyle (HtmlTextWriterStyle.Padding, "padding"),
1128 new HtmlStyle (HtmlTextWriterStyle.PaddingBottom, "padding-bottom"),
1129 new HtmlStyle (HtmlTextWriterStyle.PaddingLeft, "padding-left"),
1130 new HtmlStyle (HtmlTextWriterStyle.PaddingRight, "padding-right"),
1131 new HtmlStyle (HtmlTextWriterStyle.PaddingTop, "padding-top"),
1132 new HtmlStyle (HtmlTextWriterStyle.Position, "position"),
1133 new HtmlStyle (HtmlTextWriterStyle.TextAlign, "text-align"),
1134 new HtmlStyle (HtmlTextWriterStyle.VerticalAlign, "vertical-align"),
1135 new HtmlStyle (HtmlTextWriterStyle.TextOverflow, "text-overflow"),
1136 new HtmlStyle (HtmlTextWriterStyle.Top, "top"),
1137 new HtmlStyle (HtmlTextWriterStyle.Visibility, "visibility"),
1138 new HtmlStyle (HtmlTextWriterStyle.WhiteSpace, "white-space"),
1139 new HtmlStyle (HtmlTextWriterStyle.ZIndex, "z-index"),
1142 public virtual bool IsValidFormAttribute (string attribute)
1148 public virtual void WriteBreak ()
1150 string br = GetTagName (HtmlTextWriterTag.Br);
1152 Write (SelfClosingTagEnd);
1155 public virtual void WriteEncodedText (string text)
1157 Write (HttpUtility.HtmlEncode (text));
1160 [MonoNotSupported ("")]
1161 public virtual void WriteEncodedUrl (string url)
1163 // WriteUrlEncodedString (url, false);
1164 throw new NotImplementedException ();
1167 [MonoNotSupported ("")]
1168 public virtual void WriteEncodedUrlParameter (string urlText)
1170 // WriteUrlEncodedString (urlText, true);
1171 throw new NotImplementedException ();
1174 [MonoNotSupported ("")]
1175 protected void WriteUrlEncodedString (string text, bool argument)
1177 throw new NotImplementedException ();
1180 [MonoNotSupported ("")]
1181 public virtual void EnterStyle (Style style)
1183 throw new NotImplementedException ();
1186 [MonoNotSupported ("")]
1187 public virtual void EnterStyle (Style style, HtmlTextWriterTag tag)
1189 throw new NotImplementedException ();
1192 [MonoNotSupported ("")]
1193 public virtual void ExitStyle (Style style)
1195 throw new NotImplementedException ();
1198 [MonoNotSupported ("")]
1199 public virtual void ExitStyle (Style style, HtmlTextWriterTag tag)
1201 throw new NotImplementedException ();
1204 public virtual void BeginRender ()
1208 public virtual void EndRender ()