// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte CHARACTER = 0;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte COMMENT = 1;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte DOCTYPE = 2;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte END_TAG = 4;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte EOF = 3;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte START_TAG = 5;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static void genericRCDataParsing(TreeConstructor treeConstructor) {
//     treeConstructor.insertHtmlElementToken();
//     treeConstructor.tokenizer.setState(TokenizerState.RCDATA_STATE);
//     treeConstructor.originalInsertionMode = treeConstructor.insertionMode;
//     treeConstructor.insertionMode = TreeConstructionInsertionMode.TEXT;
// }
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static void genericRawTextElementParsing(TreeConstructor treeConstructor) {
//     treeConstructor.insertHtmlElementToken();
//     treeConstructor.tokenizer.setState(TokenizerState.RAWTEXT_STATE);
//     treeConstructor.originalInsertionMode = treeConstructor.insertionMode;
//     treeConstructor.insertionMode = TreeConstructionInsertionMode.TEXT;
// }


import static ch.digitalfondue.jfiveparse.TreeConstructor.CHARACTER;
import static ch.digitalfondue.jfiveparse.TreeConstructor.COMMENT;
import static ch.digitalfondue.jfiveparse.TreeConstructor.DOCTYPE;
import static ch.digitalfondue.jfiveparse.TreeConstructor.END_TAG;
import static ch.digitalfondue.jfiveparse.TreeConstructor.EOF;
import static ch.digitalfondue.jfiveparse.TreeConstructor.START_TAG;
import static ch.digitalfondue.jfiveparse.TreeConstructor.genericRCDataParsing;
import static ch.digitalfondue.jfiveparse.TreeConstructor.genericRawTextElementParsing;
    // --- in head ---

    static void inHead(byte tokenType, String tagName, TreeConstructor treeConstructor) {
        if (tokenType == CHARACTER && Common.isTabLfFfCrOrSpace(treeConstructor.getChr())) {
            treeConstructor.insertCharacter();
        } else if (tokenType == COMMENT) {
            treeConstructor.insertComment();
        } else if (tokenType == DOCTYPE) {
            treeConstructor.emitParseError();
            // ignore
        } else if (Common.isStartTagNamed(tokenType, "html", tagName)) {
            TreeConstructorInBodyForeignContentText.inBody(tokenType, tagName, treeConstructor);
        } else if (tokenType == START_TAG && ("base".equals(tagName) || //
                "basefont".equals(tagName) || //
                "bgsound".equals(tagName) || //
                "link".equals(tagName))) {
            treeConstructor.insertHtmlElementToken();
            treeConstructor.popCurrentNode();
            treeConstructor.ackSelfClosingTagIfSet();
        } else if (Common.isStartTagNamed(tokenType, "meta", tagName)) {
            treeConstructor.insertHtmlElementToken();
            treeConstructor.popCurrentNode();
            treeConstructor.ackSelfClosingTagIfSet();
        } else if (Common.isStartTagNamed(tokenType, "title", tagName)) {
            genericRCDataParsing(treeConstructor);
        } else if (tokenType == START_TAG && (//
                ("noscript".equals(tagName) && treeConstructor.isScriptingFlag()) || //
                ("noframes".equals(tagName) || "style".equals(tagName)))) {
            genericRawTextElementParsing(treeConstructor);
        } else if (Common.isStartTagNamed(tokenType, "noscript", tagName) && !treeConstructor.isScriptingFlag()) {
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte CHARACTER = 0;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte COMMENT = 1;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte DOCTYPE = 2;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte END_TAG = 4;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte EOF = 3;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static final byte START_TAG = 5;
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static void genericRCDataParsing(TreeConstructor treeConstructor) {
//     treeConstructor.insertHtmlElementToken();
//     treeConstructor.tokenizer.setState(TokenizerState.RCDATA_STATE);
//     treeConstructor.originalInsertionMode = treeConstructor.insertionMode;
//     treeConstructor.insertionMode = TreeConstructionInsertionMode.TEXT;
// }
// 
// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructor.java
// static void genericRawTextElementParsing(TreeConstructor treeConstructor) {
//     treeConstructor.insertHtmlElementToken();
//     treeConstructor.tokenizer.setState(TokenizerState.RAWTEXT_STATE);
//     treeConstructor.originalInsertionMode = treeConstructor.insertionMode;
//     treeConstructor.insertionMode = TreeConstructionInsertionMode.TEXT;
// }


// Path: src/main/java/ch/digitalfondue/jfiveparse/TreeConstructorAftersBeforeInitialInHead.java
import static ch.digitalfondue.jfiveparse.TreeConstructor.CHARACTER;
import static ch.digitalfondue.jfiveparse.TreeConstructor.COMMENT;
import static ch.digitalfondue.jfiveparse.TreeConstructor.DOCTYPE;
import static ch.digitalfondue.jfiveparse.TreeConstructor.END_TAG;
import static ch.digitalfondue.jfiveparse.TreeConstructor.EOF;
import static ch.digitalfondue.jfiveparse.TreeConstructor.START_TAG;
import static ch.digitalfondue.jfiveparse.TreeConstructor.genericRCDataParsing;
import static ch.digitalfondue.jfiveparse.TreeConstructor.genericRawTextElementParsing;

    // --- in head ---

    static void inHead(byte tokenType, String tagName, TreeConstructor treeConstructor) {
        if (tokenType == CHARACTER && Common.isTabLfFfCrOrSpace(treeConstructor.getChr())) {
            treeConstructor.insertCharacter();
        } else if (tokenType == COMMENT) {
            treeConstructor.insertComment();
        } else if (tokenType == DOCTYPE) {
            treeConstructor.emitParseError();
            // ignore
        } else if (Common.isStartTagNamed(tokenType, "html", tagName)) {
            TreeConstructorInBodyForeignContentText.inBody(tokenType, tagName, treeConstructor);
        } else if (tokenType == START_TAG && ("base".equals(tagName) || //
                "basefont".equals(tagName) || //
                "bgsound".equals(tagName) || //
                "link".equals(tagName))) {
            treeConstructor.insertHtmlElementToken();
            treeConstructor.popCurrentNode();
            treeConstructor.ackSelfClosingTagIfSet();
        } else if (Common.isStartTagNamed(tokenType, "meta", tagName)) {
            treeConstructor.insertHtmlElementToken();
            treeConstructor.popCurrentNode();
            treeConstructor.ackSelfClosingTagIfSet();
        } else if (Common.isStartTagNamed(tokenType, "title", tagName)) {
            genericRCDataParsing(treeConstructor);
        } else if (tokenType == START_TAG && (//
                ("noscript".equals(tagName) && treeConstructor.isScriptingFlag()) || //
                ("noframes".equals(tagName) || "style".equals(tagName)))) {
            genericRawTextElementParsing(treeConstructor);
        } else if (Common.isStartTagNamed(tokenType, "noscript", tagName) && !treeConstructor.isScriptingFlag()) {
            treeConstructor.insertHtmlElementToken();