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)
137 if (attrs [attrs_pos] == null)
138 attrs [attrs_pos] = new AddedAttr ();
140 attrs [attrs_pos].name = name;
141 attrs [attrs_pos].value = value;
142 attrs [attrs_pos].key = key;
146 protected virtual void AddStyleAttribute (string name, string value, HtmlTextWriterStyle key)
150 if (styles [styles_pos] == null)
151 styles [styles_pos] = new AddedStyle ();
153 styles [styles_pos].name = name;
154 value = HttpUtility.HtmlAttributeEncode (value);
155 styles [styles_pos].value = value;
156 styles [styles_pos].key = key;
160 public virtual void AddStyleAttribute (string name, string value)
162 AddStyleAttribute (name, value, GetStyleKey (name));
165 public virtual void AddStyleAttribute (HtmlTextWriterStyle key, string value)
167 AddStyleAttribute (GetStyleName (key), value, key);
170 public override void Close ()
175 protected virtual string EncodeAttributeValue (HtmlTextWriterAttribute attrKey, string value)
177 return HttpUtility.HtmlAttributeEncode (value);
180 protected string EncodeAttributeValue (string value, bool fEncode)
183 return HttpUtility.HtmlAttributeEncode (value);
187 protected string EncodeUrl (string url)
189 return HttpUtility.UrlPathEncode (url);
193 protected virtual void FilterAttributes ()
195 AddedAttr style_attr = new AddedAttr ();
197 for (int i = 0; i <= attrs_pos; i++) {
198 AddedAttr a = attrs [i];
199 if (OnAttributeRender (a.name, a.value, a.key)) {
200 if (a.key == HtmlTextWriterAttribute.Style) {
205 WriteAttribute (a.name, a.value, false);
209 if (styles_pos != -1 || style_attr.value != null) {
212 Write (EqualsDoubleQuoteString);
215 for (int i = 0; i <= styles_pos; i++) {
216 AddedStyle a = styles [i];
217 if (OnStyleAttributeRender (a.name, a.value, a.key)) {
218 if (a.key == HtmlTextWriterStyle.BackgroundImage)
219 a.value = String.Concat ("url(", HttpUtility.UrlPathEncode (a.value), ")");
220 WriteStyleAttribute (a.name, a.value, false);
224 Write (style_attr.value);
225 Write (DoubleQuoteChar);
228 styles_pos = attrs_pos = -1;
231 public override void Flush ()
236 protected HtmlTextWriterAttribute GetAttributeKey (string attrName)
238 object attribute = _attributeTable [attrName];
239 if (attribute == null)
240 return (HtmlTextWriterAttribute) (-1);
242 return (HtmlTextWriterAttribute) ((HtmlAttribute) attribute).key;
245 protected string GetAttributeName (HtmlTextWriterAttribute attrKey)
247 if ((int) attrKey < htmlattrs.Length)
248 return htmlattrs [(int) attrKey].name;
253 protected HtmlTextWriterStyle GetStyleKey (string styleName)
255 object style = _styleTable [styleName];
257 return (HtmlTextWriterStyle) (-1);
259 return (HtmlTextWriterStyle) ((HtmlStyle) style).key;
262 protected string GetStyleName (HtmlTextWriterStyle styleKey)
264 return StaticGetStyleName (styleKey);
267 protected virtual HtmlTextWriterTag GetTagKey (string tagName)
269 object tag = _tagTable [tagName];
271 return HtmlTextWriterTag.Unknown;
273 return (HtmlTextWriterTag) ((HtmlTag) tag).key;
276 internal static string StaticGetTagName (HtmlTextWriterTag tagKey)
278 if ((int) tagKey < tags.Length)
279 return tags [(int) tagKey].name;
285 protected virtual string GetTagName (HtmlTextWriterTag tagKey)
287 if ((int) tagKey < tags.Length)
288 return tags [(int) tagKey].name;
293 protected bool IsAttributeDefined (HtmlTextWriterAttribute key)
296 return IsAttributeDefined (key, out value);
299 protected bool IsAttributeDefined (HtmlTextWriterAttribute key, out string value)
301 for (int i = 0; i <= attrs_pos; i++)
302 if (attrs [i].key == key) {
303 value = attrs [i].value;
311 protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key)
314 return IsStyleAttributeDefined (key, out value);
317 protected bool IsStyleAttributeDefined (HtmlTextWriterStyle key, out string value)
319 for (int i = 0; i <= styles_pos; i++)
320 if (styles [i].key == key) {
321 value = styles [i].value;
329 protected virtual bool OnAttributeRender (string name, string value, HtmlTextWriterAttribute key)
334 protected virtual bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key)
339 protected virtual bool OnTagRender (string name, HtmlTextWriterTag key)
345 protected virtual void OutputTabs ()
351 for (int i = 0; i < Indent; i++)
352 b.Write (tab_string);
357 protected string PopEndTag ()
359 if (tagstack_pos == -1)
360 throw new InvalidOperationException ();
367 protected void PushEndTag (string endTag)
373 void PushEndTag (HtmlTextWriterTag t)
380 protected virtual string RenderAfterContent ()
385 protected virtual string RenderAfterTag ()
390 protected virtual string RenderBeforeContent ()
395 protected virtual string RenderBeforeTag ()
400 public virtual void RenderBeginTag (string tagName)
402 bool ignore = !OnTagRender (tagName, GetTagKey (tagName));
404 PushEndTag (tagName);
409 public virtual void RenderBeginTag (HtmlTextWriterTag tagKey)
411 bool ignore = !OnTagRender (GetTagName (tagKey), tagKey);
418 void WriteIfNotNull (string s)
427 WriteIfNotNull (RenderBeforeTag ());
429 WriteBeginTag (TagName);
432 HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown;
434 switch (tags [(int) key].tag_type) {
436 Write (TagRightChar);
439 Write (TagRightChar);
443 case TagType.SelfClosing:
444 Write (SelfClosingTagEnd);
449 // FIXME what do i do for self close here?
450 WriteIfNotNull (RenderBeforeContent ());
454 public virtual void RenderEndTag ()
457 // FIXME what do i do for self close here?
458 WriteIfNotNull (RenderAfterContent ());
461 HtmlTextWriterTag key = (int) TagKey < tags.Length ? TagKey : HtmlTextWriterTag.Unknown;
463 switch (tags [(int) key].tag_type) {
465 WriteEndTag (TagName);
469 WriteLineNoTabs (String.Empty);
470 WriteEndTag (TagName);
473 case TagType.SelfClosing:
479 WriteIfNotNull (RenderAfterTag ());
485 public virtual void WriteAttribute (string name, string value, bool fEncode)
490 Write (EqualsDoubleQuoteString);
491 value = EncodeAttributeValue (value, fEncode);
493 Write (DoubleQuoteChar);
498 public virtual void WriteBeginTag (string tagName)
504 public virtual void WriteEndTag (string tagName)
506 Write (EndTagLeftChars);
508 Write (TagRightChar);
511 public virtual void WriteFullBeginTag (string tagName)
515 Write (TagRightChar);
518 public virtual void WriteStyleAttribute (string name, string value)
520 WriteStyleAttribute (name, value, false);
523 public virtual void WriteStyleAttribute (string name, string value, bool fEncode)
526 Write (StyleEqualsChar);
527 Write (EncodeAttributeValue (value, fEncode));
528 Write (SemicolonChar);
531 public override void Write (char [] buffer, int index, int count)
534 b.Write (buffer, index, count);
537 public override void Write (double value)
543 public override void Write (char value)
549 public override void Write (char [] buffer)
555 public override void Write (int value)
561 public override void Write (string format, object arg0)
564 b.Write (format, arg0);
567 public override void Write (string format, object arg0, object arg1)
570 b.Write (format, arg0, arg1);
573 public override void Write (string format, params object [] args)
576 b.Write (format, args);
579 public override void Write (string s)
585 public override void Write (long value)
591 public override void Write (object value)
597 public override void Write (float value)
603 public override void Write (bool value)
609 public virtual void WriteAttribute (string name, string value)
611 WriteAttribute (name, value, false);
614 public override void WriteLine (char value)
621 public override void WriteLine (long value)
628 public override void WriteLine (object value)
635 public override void WriteLine (double value)
642 public override void WriteLine (char [] buffer, int index, int count)
645 b.WriteLine (buffer, index, count);
649 public override void WriteLine (char [] buffer)
652 b.WriteLine (buffer);
656 public override void WriteLine (bool value)
663 public override void WriteLine ()
670 public override void WriteLine (int value)
677 public override void WriteLine (string format, object arg0, object arg1)
680 b.WriteLine (format, arg0, arg1);
684 public override void WriteLine (string format, object arg0)
687 b.WriteLine (format, arg0);
691 public override void WriteLine (string format, params object [] args)
694 b.WriteLine (format, args);
698 [CLSCompliant (false)]
699 public override void WriteLine (uint value)
706 public override void WriteLine (string s)
713 public override void WriteLine (float value)
720 public void WriteLineNoTabs (string s)
726 public override Encoding Encoding {
742 public System.IO.TextWriter InnerWriter {
751 public override string NewLine {
760 protected HtmlTextWriterTag TagKey {
762 if (tagstack_pos == -1)
763 throw new InvalidOperationException ();
765 return tagstack [tagstack_pos].key;
769 if (tagstack [tagstack_pos] == null)
770 tagstack [tagstack_pos] = new AddedTag ();
772 tagstack [tagstack_pos].key = value;
773 tagstack [tagstack_pos].name = GetTagName (value);
777 protected string TagName {
779 if (tagstack_pos == -1)
780 throw new InvalidOperationException ();
782 return tagstack [tagstack_pos].name;
786 if (tagstack [tagstack_pos] == null)
787 tagstack [tagstack_pos] = new AddedTag ();
789 tagstack [tagstack_pos].name = value;
790 tagstack [tagstack_pos].key = GetTagKey (value);
791 if (tagstack [tagstack_pos].key != HtmlTextWriterTag.Unknown)
792 tagstack [tagstack_pos].name = GetTagName (tagstack [tagstack_pos].key);
798 if (tagstack_pos == -1)
799 throw new InvalidOperationException ();
801 return tagstack [tagstack_pos].ignore;
805 if (tagstack_pos == -1)
806 throw new InvalidOperationException ();
808 tagstack [tagstack_pos].ignore = value;
812 internal HttpWriter GetHttpWriter ()
814 return b as HttpWriter;
822 // These emulate generic Stack <T>, since we can't use that ;-(. _pos is the current
823 // element.IE, you edit blah [blah_pos]. I *really* want generics, sigh.
825 AddedStyle [] styles;
827 AddedTag [] tagstack;
829 int styles_pos = -1, attrs_pos = -1, tagstack_pos = -1;
838 public HtmlTextWriterTag key;
849 public HtmlTextWriterStyle key;
860 public HtmlTextWriterAttribute key;
864 void NextStyleStack ()
867 styles = new AddedStyle [16];
869 if (++styles_pos < styles.Length)
872 int nsize = styles.Length * 2;
873 AddedStyle [] ncontents = new AddedStyle [nsize];
875 Array.Copy (styles, ncontents, styles.Length);
879 void NextAttrStack ()
882 attrs = new AddedAttr [16];
884 if (++attrs_pos < attrs.Length)
887 int nsize = attrs.Length * 2;
888 AddedAttr [] ncontents = new AddedAttr [nsize];
890 Array.Copy (attrs, ncontents, attrs.Length);
896 if (tagstack == null)
897 tagstack = new AddedTag [16];
899 if (++tagstack_pos < tagstack.Length)
902 int nsize = tagstack.Length * 2;
903 AddedTag [] ncontents = new AddedTag [nsize];
905 Array.Copy (tagstack, ncontents, tagstack.Length);
906 tagstack = ncontents;
909 public const string DefaultTabString = "\t";
910 public const char DoubleQuoteChar = '"';
911 public const string EndTagLeftChars = "</";
912 public const char EqualsChar = '=';
913 public const string EqualsDoubleQuoteString = "=\"";
914 public const string SelfClosingChars = " /";
915 public const string SelfClosingTagEnd = " />";
916 public const char SemicolonChar = ';';
917 public const char SingleQuoteChar = '\'';
918 public const char SlashChar = '/';
919 public const char SpaceChar = ' ';
920 public const char StyleEqualsChar = ':';
921 public const char TagLeftChar = '<';
922 public const char TagRightChar = '>';
931 sealed class HtmlTag {
932 readonly public HtmlTextWriterTag key;
933 readonly public string name;
934 readonly public TagType tag_type;
936 public HtmlTag (HtmlTextWriterTag k, string n, TagType tt)
944 sealed class HtmlStyle {
945 readonly public HtmlTextWriterStyle key;
946 readonly public string name;
948 public HtmlStyle (HtmlTextWriterStyle k, string n)
956 sealed class HtmlAttribute {
957 readonly public HtmlTextWriterAttribute key;
958 readonly public string name;
960 public HtmlAttribute (HtmlTextWriterAttribute k, string n)
967 static HtmlTag [] tags = {
968 new HtmlTag (HtmlTextWriterTag.Unknown, String.Empty, TagType.Block),
969 new HtmlTag (HtmlTextWriterTag.A, "a", TagType.Inline),
970 new HtmlTag (HtmlTextWriterTag.Acronym, "acronym", TagType.Inline),
971 new HtmlTag (HtmlTextWriterTag.Address, "address", TagType.Block),
972 new HtmlTag (HtmlTextWriterTag.Area, "area", TagType.Block),
973 new HtmlTag (HtmlTextWriterTag.B, "b", TagType.Inline),
974 new HtmlTag (HtmlTextWriterTag.Base, "base", TagType.SelfClosing),
975 new HtmlTag (HtmlTextWriterTag.Basefont, "basefont", TagType.SelfClosing),
976 new HtmlTag (HtmlTextWriterTag.Bdo, "bdo", TagType.Inline),
977 new HtmlTag (HtmlTextWriterTag.Bgsound, "bgsound", TagType.SelfClosing),
978 new HtmlTag (HtmlTextWriterTag.Big, "big", TagType.Inline),
979 new HtmlTag (HtmlTextWriterTag.Blockquote, "blockquote", TagType.Block),
980 new HtmlTag (HtmlTextWriterTag.Body, "body", TagType.Block),
981 new HtmlTag (HtmlTextWriterTag.Br, "br", TagType.Block),
982 new HtmlTag (HtmlTextWriterTag.Button, "button", TagType.Inline),
983 new HtmlTag (HtmlTextWriterTag.Caption, "caption", TagType.Block),
984 new HtmlTag (HtmlTextWriterTag.Center, "center", TagType.Block),
985 new HtmlTag (HtmlTextWriterTag.Cite, "cite", TagType.Inline),
986 new HtmlTag (HtmlTextWriterTag.Code, "code", TagType.Inline),
987 new HtmlTag (HtmlTextWriterTag.Col, "col", TagType.SelfClosing),
988 new HtmlTag (HtmlTextWriterTag.Colgroup, "colgroup", TagType.Block),
989 new HtmlTag (HtmlTextWriterTag.Dd, "dd", TagType.Inline),
990 new HtmlTag (HtmlTextWriterTag.Del, "del", TagType.Inline),
991 new HtmlTag (HtmlTextWriterTag.Dfn, "dfn", TagType.Inline),
992 new HtmlTag (HtmlTextWriterTag.Dir, "dir", TagType.Block),
993 new HtmlTag (HtmlTextWriterTag.Div, "div", TagType.Block),
994 new HtmlTag (HtmlTextWriterTag.Dl, "dl", TagType.Block),
995 new HtmlTag (HtmlTextWriterTag.Dt, "dt", TagType.Inline),
996 new HtmlTag (HtmlTextWriterTag.Em, "em", TagType.Inline),
997 new HtmlTag (HtmlTextWriterTag.Embed, "embed", TagType.SelfClosing),
998 new HtmlTag (HtmlTextWriterTag.Fieldset, "fieldset", TagType.Block),
999 new HtmlTag (HtmlTextWriterTag.Font, "font", TagType.Inline),
1000 new HtmlTag (HtmlTextWriterTag.Form, "form", TagType.Block),
1001 new HtmlTag (HtmlTextWriterTag.Frame, "frame", TagType.SelfClosing),
1002 new HtmlTag (HtmlTextWriterTag.Frameset, "frameset", TagType.Block),
1003 new HtmlTag (HtmlTextWriterTag.H1, "h1", TagType.Block),
1004 new HtmlTag (HtmlTextWriterTag.H2, "h2", TagType.Block),
1005 new HtmlTag (HtmlTextWriterTag.H3, "h3", TagType.Block),
1006 new HtmlTag (HtmlTextWriterTag.H4, "h4", TagType.Block),
1007 new HtmlTag (HtmlTextWriterTag.H5, "h5", TagType.Block),
1008 new HtmlTag (HtmlTextWriterTag.H6, "h6", TagType.Block),
1009 new HtmlTag (HtmlTextWriterTag.Head, "head", TagType.Block),
1010 new HtmlTag (HtmlTextWriterTag.Hr, "hr", TagType.SelfClosing),
1011 new HtmlTag (HtmlTextWriterTag.Html, "html", TagType.Block),
1012 new HtmlTag (HtmlTextWriterTag.I, "i", TagType.Inline),
1013 new HtmlTag (HtmlTextWriterTag.Iframe, "iframe", TagType.Block),
1014 new HtmlTag (HtmlTextWriterTag.Img, "img", TagType.SelfClosing),
1015 new HtmlTag (HtmlTextWriterTag.Input, "input", TagType.SelfClosing),
1016 new HtmlTag (HtmlTextWriterTag.Ins, "ins", TagType.Inline),
1017 new HtmlTag (HtmlTextWriterTag.Isindex, "isindex", TagType.SelfClosing),
1018 new HtmlTag (HtmlTextWriterTag.Kbd, "kbd", TagType.Inline),
1019 new HtmlTag (HtmlTextWriterTag.Label, "label", TagType.Inline),
1020 new HtmlTag (HtmlTextWriterTag.Legend, "legend", TagType.Block),
1021 new HtmlTag (HtmlTextWriterTag.Li, "li", TagType.Inline),
1022 new HtmlTag (HtmlTextWriterTag.Link, "link", TagType.SelfClosing),
1023 new HtmlTag (HtmlTextWriterTag.Map, "map", TagType.Block),
1024 new HtmlTag (HtmlTextWriterTag.Marquee, "marquee", TagType.Block),
1025 new HtmlTag (HtmlTextWriterTag.Menu, "menu", TagType.Block),
1026 new HtmlTag (HtmlTextWriterTag.Meta, "meta", TagType.SelfClosing),
1027 new HtmlTag (HtmlTextWriterTag.Nobr, "nobr", TagType.Inline),
1028 new HtmlTag (HtmlTextWriterTag.Noframes, "noframes", TagType.Block),
1029 new HtmlTag (HtmlTextWriterTag.Noscript, "noscript", TagType.Block),
1030 new HtmlTag (HtmlTextWriterTag.Object, "object", TagType.Block),
1031 new HtmlTag (HtmlTextWriterTag.Ol, "ol", TagType.Block),
1032 new HtmlTag (HtmlTextWriterTag.Option, "option", TagType.Block),
1033 new HtmlTag (HtmlTextWriterTag.P, "p", TagType.Inline),
1034 new HtmlTag (HtmlTextWriterTag.Param, "param", TagType.Block),
1035 new HtmlTag (HtmlTextWriterTag.Pre, "pre", TagType.Block),
1036 new HtmlTag (HtmlTextWriterTag.Q, "q", TagType.Inline),
1037 new HtmlTag (HtmlTextWriterTag.Rt, "rt", TagType.Block),
1038 new HtmlTag (HtmlTextWriterTag.Ruby, "ruby", TagType.Block),
1039 new HtmlTag (HtmlTextWriterTag.S, "s", TagType.Inline),
1040 new HtmlTag (HtmlTextWriterTag.Samp, "samp", TagType.Inline),
1041 new HtmlTag (HtmlTextWriterTag.Script, "script", TagType.Block),
1042 new HtmlTag (HtmlTextWriterTag.Select, "select", TagType.Block),
1043 new HtmlTag (HtmlTextWriterTag.Small, "small", TagType.Block),
1044 new HtmlTag (HtmlTextWriterTag.Span, "span", TagType.Inline),
1045 new HtmlTag (HtmlTextWriterTag.Strike, "strike", TagType.Inline),
1046 new HtmlTag (HtmlTextWriterTag.Strong, "strong", TagType.Inline),
1047 new HtmlTag (HtmlTextWriterTag.Style, "style", TagType.Block),
1048 new HtmlTag (HtmlTextWriterTag.Sub, "sub", TagType.Inline),
1049 new HtmlTag (HtmlTextWriterTag.Sup, "sup", TagType.Inline),
1050 new HtmlTag (HtmlTextWriterTag.Table, "table", TagType.Block),
1051 new HtmlTag (HtmlTextWriterTag.Tbody, "tbody", TagType.Block),
1052 new HtmlTag (HtmlTextWriterTag.Td, "td", TagType.Inline),
1053 new HtmlTag (HtmlTextWriterTag.Textarea, "textarea", TagType.Inline),
1054 new HtmlTag (HtmlTextWriterTag.Tfoot, "tfoot", TagType.Block),
1055 new HtmlTag (HtmlTextWriterTag.Th, "th", TagType.Inline),
1056 new HtmlTag (HtmlTextWriterTag.Thead, "thead", TagType.Block),
1057 new HtmlTag (HtmlTextWriterTag.Title, "title", TagType.Block),
1058 new HtmlTag (HtmlTextWriterTag.Tr, "tr", TagType.Block),
1059 new HtmlTag (HtmlTextWriterTag.Tt, "tt", TagType.Inline),
1060 new HtmlTag (HtmlTextWriterTag.U, "u", TagType.Inline),
1061 new HtmlTag (HtmlTextWriterTag.Ul, "ul", TagType.Block),
1062 new HtmlTag (HtmlTextWriterTag.Var, "var", TagType.Inline),
1063 new HtmlTag (HtmlTextWriterTag.Wbr, "wbr", TagType.SelfClosing),
1064 new HtmlTag (HtmlTextWriterTag.Xml, "xml", TagType.Block),
1067 static HtmlAttribute [] htmlattrs = {
1068 new HtmlAttribute (HtmlTextWriterAttribute.Accesskey, "accesskey"),
1069 new HtmlAttribute (HtmlTextWriterAttribute.Align, "align"),
1070 new HtmlAttribute (HtmlTextWriterAttribute.Alt, "alt"),
1071 new HtmlAttribute (HtmlTextWriterAttribute.Background, "background"),
1072 new HtmlAttribute (HtmlTextWriterAttribute.Bgcolor, "bgcolor"),
1073 new HtmlAttribute (HtmlTextWriterAttribute.Border, "border"),
1074 new HtmlAttribute (HtmlTextWriterAttribute.Bordercolor, "bordercolor"),
1075 new HtmlAttribute (HtmlTextWriterAttribute.Cellpadding, "cellpadding"),
1076 new HtmlAttribute (HtmlTextWriterAttribute.Cellspacing, "cellspacing"),
1077 new HtmlAttribute (HtmlTextWriterAttribute.Checked, "checked"),
1078 new HtmlAttribute (HtmlTextWriterAttribute.Class, "class"),
1079 new HtmlAttribute (HtmlTextWriterAttribute.Cols, "cols"),
1080 new HtmlAttribute (HtmlTextWriterAttribute.Colspan, "colspan"),
1081 new HtmlAttribute (HtmlTextWriterAttribute.Disabled, "disabled"),
1082 new HtmlAttribute (HtmlTextWriterAttribute.For, "for"),
1083 new HtmlAttribute (HtmlTextWriterAttribute.Height, "height"),
1084 new HtmlAttribute (HtmlTextWriterAttribute.Href, "href"),
1085 new HtmlAttribute (HtmlTextWriterAttribute.Id, "id"),
1086 new HtmlAttribute (HtmlTextWriterAttribute.Maxlength, "maxlength"),
1087 new HtmlAttribute (HtmlTextWriterAttribute.Multiple, "multiple"),
1088 new HtmlAttribute (HtmlTextWriterAttribute.Name, "name"),
1089 new HtmlAttribute (HtmlTextWriterAttribute.Nowrap, "nowrap"),
1090 new HtmlAttribute (HtmlTextWriterAttribute.Onchange, "onchange"),
1091 new HtmlAttribute (HtmlTextWriterAttribute.Onclick, "onclick"),
1092 new HtmlAttribute (HtmlTextWriterAttribute.ReadOnly, "readonly"),
1093 new HtmlAttribute (HtmlTextWriterAttribute.Rows, "rows"),
1094 new HtmlAttribute (HtmlTextWriterAttribute.Rowspan, "rowspan"),
1095 new HtmlAttribute (HtmlTextWriterAttribute.Rules, "rules"),
1096 new HtmlAttribute (HtmlTextWriterAttribute.Selected, "selected"),
1097 new HtmlAttribute (HtmlTextWriterAttribute.Size, "size"),
1098 new HtmlAttribute (HtmlTextWriterAttribute.Src, "src"),
1099 new HtmlAttribute (HtmlTextWriterAttribute.Style, "style"),
1100 new HtmlAttribute (HtmlTextWriterAttribute.Tabindex, "tabindex"),
1101 new HtmlAttribute (HtmlTextWriterAttribute.Target, "target"),
1102 new HtmlAttribute (HtmlTextWriterAttribute.Title, "title"),
1103 new HtmlAttribute (HtmlTextWriterAttribute.Type, "type"),
1104 new HtmlAttribute (HtmlTextWriterAttribute.Valign, "valign"),
1105 new HtmlAttribute (HtmlTextWriterAttribute.Value, "value"),
1106 new HtmlAttribute (HtmlTextWriterAttribute.Width, "width"),
1107 new HtmlAttribute (HtmlTextWriterAttribute.Wrap, "wrap"),
1108 new HtmlAttribute (HtmlTextWriterAttribute.Abbr, "abbr"),
1109 new HtmlAttribute (HtmlTextWriterAttribute.AutoComplete, "autocomplete"),
1110 new HtmlAttribute (HtmlTextWriterAttribute.Axis, "axis"),
1111 new HtmlAttribute (HtmlTextWriterAttribute.Content, "content"),
1112 new HtmlAttribute (HtmlTextWriterAttribute.Coords, "coords"),
1113 new HtmlAttribute (HtmlTextWriterAttribute.DesignerRegion, "_designerregion"),
1114 new HtmlAttribute (HtmlTextWriterAttribute.Dir, "dir"),
1115 new HtmlAttribute (HtmlTextWriterAttribute.Headers, "headers"),
1116 new HtmlAttribute (HtmlTextWriterAttribute.Longdesc, "longdesc"),
1117 new HtmlAttribute (HtmlTextWriterAttribute.Rel, "rel"),
1118 new HtmlAttribute (HtmlTextWriterAttribute.Scope, "scope"),
1119 new HtmlAttribute (HtmlTextWriterAttribute.Shape, "shape"),
1120 new HtmlAttribute (HtmlTextWriterAttribute.Usemap, "usemap"),
1121 new HtmlAttribute (HtmlTextWriterAttribute.VCardName, "vcard_name"),
1124 static HtmlStyle [] htmlstyles = {
1125 new HtmlStyle (HtmlTextWriterStyle.BackgroundColor, "background-color"),
1126 new HtmlStyle (HtmlTextWriterStyle.BackgroundImage, "background-image"),
1127 new HtmlStyle (HtmlTextWriterStyle.BorderCollapse, "border-collapse"),
1128 new HtmlStyle (HtmlTextWriterStyle.BorderColor, "border-color"),
1129 new HtmlStyle (HtmlTextWriterStyle.BorderStyle, "border-style"),
1130 new HtmlStyle (HtmlTextWriterStyle.BorderWidth, "border-width"),
1131 new HtmlStyle (HtmlTextWriterStyle.Color, "color"),
1132 new HtmlStyle (HtmlTextWriterStyle.FontFamily, "font-family"),
1133 new HtmlStyle (HtmlTextWriterStyle.FontSize, "font-size"),
1134 new HtmlStyle (HtmlTextWriterStyle.FontStyle, "font-style"),
1135 new HtmlStyle (HtmlTextWriterStyle.FontWeight, "font-weight"),
1136 new HtmlStyle (HtmlTextWriterStyle.Height, "height"),
1137 new HtmlStyle (HtmlTextWriterStyle.TextDecoration, "text-decoration"),
1138 new HtmlStyle (HtmlTextWriterStyle.Width, "width"),
1139 new HtmlStyle (HtmlTextWriterStyle.ListStyleImage, "list-style-image"),
1140 new HtmlStyle (HtmlTextWriterStyle.ListStyleType, "list-style-type"),
1141 new HtmlStyle (HtmlTextWriterStyle.Cursor, "cursor"),
1142 new HtmlStyle (HtmlTextWriterStyle.Direction, "direction"),
1143 new HtmlStyle (HtmlTextWriterStyle.Display, "display"),
1144 new HtmlStyle (HtmlTextWriterStyle.Filter, "filter"),
1145 new HtmlStyle (HtmlTextWriterStyle.FontVariant, "font-variant"),
1146 new HtmlStyle (HtmlTextWriterStyle.Left, "left"),
1147 new HtmlStyle (HtmlTextWriterStyle.Margin, "margin"),
1148 new HtmlStyle (HtmlTextWriterStyle.MarginBottom, "margin-bottom"),
1149 new HtmlStyle (HtmlTextWriterStyle.MarginLeft, "margin-left"),
1150 new HtmlStyle (HtmlTextWriterStyle.MarginRight, "margin-right"),
1151 new HtmlStyle (HtmlTextWriterStyle.MarginTop, "margin-top"),
1152 new HtmlStyle (HtmlTextWriterStyle.Overflow, "overflow"),
1153 new HtmlStyle (HtmlTextWriterStyle.OverflowX, "overflow-x"),
1154 new HtmlStyle (HtmlTextWriterStyle.OverflowY, "overflow-y"),
1155 new HtmlStyle (HtmlTextWriterStyle.Padding, "padding"),
1156 new HtmlStyle (HtmlTextWriterStyle.PaddingBottom, "padding-bottom"),
1157 new HtmlStyle (HtmlTextWriterStyle.PaddingLeft, "padding-left"),
1158 new HtmlStyle (HtmlTextWriterStyle.PaddingRight, "padding-right"),
1159 new HtmlStyle (HtmlTextWriterStyle.PaddingTop, "padding-top"),
1160 new HtmlStyle (HtmlTextWriterStyle.Position, "position"),
1161 new HtmlStyle (HtmlTextWriterStyle.TextAlign, "text-align"),
1162 new HtmlStyle (HtmlTextWriterStyle.VerticalAlign, "vertical-align"),
1163 new HtmlStyle (HtmlTextWriterStyle.TextOverflow, "text-overflow"),
1164 new HtmlStyle (HtmlTextWriterStyle.Top, "top"),
1165 new HtmlStyle (HtmlTextWriterStyle.Visibility, "visibility"),
1166 new HtmlStyle (HtmlTextWriterStyle.WhiteSpace, "white-space"),
1167 new HtmlStyle (HtmlTextWriterStyle.ZIndex, "z-index"),
1170 public virtual bool IsValidFormAttribute (string attribute)
1176 public virtual void WriteBreak ()
1178 string br = GetTagName (HtmlTextWriterTag.Br);
1180 Write (SelfClosingTagEnd);
1183 public virtual void WriteEncodedText (string text)
1185 Write (HttpUtility.HtmlEncode (text));
1188 [MonoNotSupported ("")]
1189 public virtual void WriteEncodedUrl (string url)
1191 // WriteUrlEncodedString (url, false);
1192 throw new NotImplementedException ();
1195 [MonoNotSupported ("")]
1196 public virtual void WriteEncodedUrlParameter (string urlText)
1198 // WriteUrlEncodedString (urlText, true);
1199 throw new NotImplementedException ();
1202 [MonoNotSupported ("")]
1203 protected void WriteUrlEncodedString (string text, bool argument)
1205 throw new NotImplementedException ();
1208 [MonoNotSupported ("")]
1209 public virtual void EnterStyle (Style style)
1211 throw new NotImplementedException ();
1214 [MonoNotSupported ("")]
1215 public virtual void EnterStyle (Style style, HtmlTextWriterTag tag)
1217 throw new NotImplementedException ();
1220 [MonoNotSupported ("")]
1221 public virtual void ExitStyle (Style style)
1223 throw new NotImplementedException ();
1226 [MonoNotSupported ("")]
1227 public virtual void ExitStyle (Style style, HtmlTextWriterTag tag)
1229 throw new NotImplementedException ();
1232 public virtual void BeginRender ()
1236 public virtual void EndRender ()