Beispiel #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;
 }
Beispiel #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);
        }
Beispiel #3
0
 internal void Insert(Token.Doctype d)
 {
     DocumentType doctypeNode = new DocumentType(d.GetName(), d.GetPublicIdentifier(), d.GetSystemIdentifier(), baseUri);
     InsertNode(doctypeNode);
 }
Beispiel #4
0
 public void ConstructorValidationOkWithBlankPublicAndSystemIds()
 {
     DocumentType fail = new DocumentType("html", "", "", "");
 }
Beispiel #5
0
 public void ConstructorValidationThrowsExceptionOnNulls()
 {
     DocumentType fail = new DocumentType("html", null, null, "");
 }
Beispiel #6
0
 public void ConstructorValidationOkWithBlankName()
 {
     DocumentType fail = new DocumentType("", "", "", "");
 }