Exemple #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;
 }
Exemple #2
0
        internal override bool Process(Token token)
        {
            switch (token.type)
            {
                case TokenType.StartTag:
                {
                    // start tag, end tag, doctype, comment, character, eof
                    Insert(token.AsStartTag());
                    break;
                }

                case TokenType.EndTag:
                {
                    PopStackToClose(token.AsEndTag());
                    break;
                }

                case TokenType.Comment:
                {
                    Insert(token.AsComment());
                    break;
                }

                case TokenType.Character:
                {
                    Insert(token.AsCharacter());
                    break;
                }

                case TokenType.Doctype:
                {
                    Insert(token.AsDoctype());
                    break;
                }

                case TokenType.EOF:
                {
                    // could put some normalisation here if desired
                    break;
                }

                default:
                {
                    Validate.Fail("Unexpected token type: " + token.type);
                    break;
                }
            }
            return true;
        }
Exemple #3
0
        internal override bool Process(Token token)
        {
            switch (token.type)
            {
            case TokenType.StartTag:
            {
                // start tag, end tag, doctype, comment, character, eof
                Insert(token.AsStartTag());
                break;
            }

            case TokenType.EndTag:
            {
                PopStackToClose(token.AsEndTag());
                break;
            }

            case TokenType.Comment:
            {
                Insert(token.AsComment());
                break;
            }

            case TokenType.Character:
            {
                Insert(token.AsCharacter());
                break;
            }

            case TokenType.Doctype:
            {
                Insert(token.AsDoctype());
                break;
            }

            case TokenType.EOF:
            {
                // could put some normalisation here if desired
                break;
            }

            default:
            {
                Validate.Fail("Unexpected token type: " + token.type);
                break;
            }
            }
            return(true);
        }