示例#1
0
 internal override bool Process(Token t, HtmlTreeBuilder tb)
 {
     if (HtmlTreeBuilderState.IsWhitespace(t))
     {
         // ignore whitespace
         return true;
     }
     else if (t.IsComment())
     {
         tb.Insert(t.AsComment());
     }
     else if (t.IsDoctype())
     {
         // todo: parse error check on expected doctypes
         // todo: quirk state check on doctype ids
         Token.Doctype d = t.AsDoctype();
         DocumentType doctype = new DocumentType(d.GetName(), d.GetPublicIdentifier(), d.GetSystemIdentifier(), tb.GetBaseUri());
         tb.GetDocument().AppendChild(doctype);
         if (d.IsForceQuirks())
         {
             tb.GetDocument().QuirksMode = DocumentQuirksMode.Quirks;
         }
         tb.Transition(HtmlTreeBuilderState.BeforeHtml);
     }
     else
     {
         // todo: check not iframe srcdoc
         tb.Transition(HtmlTreeBuilderState.BeforeHtml);
         return tb.Process(t); // re-process token
     }
     return true;
 }
示例#2
0
        public void OuterHtmlGeneration()
        {
            DocumentType html5 = new DocumentType("html", "", "", "");
            Assert.AreEqual("<!DOCTYPE html>", html5.OuterHtml);

            DocumentType publicDocType = new DocumentType("html", "-//IETF//DTD HTML//", "", "");
            Assert.AreEqual("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML//\">", publicDocType.OuterHtml);

            DocumentType systemDocType = new DocumentType("html", "", "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd", "");
            Assert.AreEqual("<!DOCTYPE html \"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd\">", systemDocType.OuterHtml);

            DocumentType combo = new DocumentType("notHtml", "--public", "--system", "");
            Assert.AreEqual("<!DOCTYPE notHtml PUBLIC \"--public\" \"--system\">", combo.OuterHtml);
        }
示例#3
0
 internal void Insert(Token.Doctype d)
 {
     DocumentType doctypeNode = new DocumentType(d.GetName(), d.GetPublicIdentifier(), d.GetSystemIdentifier(), baseUri);
     InsertNode(doctypeNode);
 }
示例#4
0
 public void ConstructorValidationOkWithBlankPublicAndSystemIds()
 {
     DocumentType fail = new DocumentType("html", "", "", "");
 }
示例#5
0
 public void ConstructorValidationThrowsExceptionOnNulls()
 {
     DocumentType fail = new DocumentType("html", null, null, "");
 }
示例#6
0
 public void ConstructorValidationOkWithBlankName()
 {
     DocumentType fail = new DocumentType("", "", "", "");
 }