wp/wp-includes/html-api/class-wp-html-processor-state.php
changeset 21 48c4eec2b7e6
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
       
     1 <?php
       
     2 /**
       
     3  * HTML API: WP_HTML_Processor_State class
       
     4  *
       
     5  * @package WordPress
       
     6  * @subpackage HTML-API
       
     7  * @since 6.4.0
       
     8  */
       
     9 
       
    10 /**
       
    11  * Core class used by the HTML processor during HTML parsing
       
    12  * for managing the internal parsing state.
       
    13  *
       
    14  * This class is designed for internal use by the HTML processor.
       
    15  *
       
    16  * @since 6.4.0
       
    17  *
       
    18  * @access private
       
    19  *
       
    20  * @see WP_HTML_Processor
       
    21  */
       
    22 class WP_HTML_Processor_State {
       
    23 	/*
       
    24 	 * Insertion mode constants.
       
    25 	 *
       
    26 	 * These constants exist and are named to make it easier to
       
    27 	 * discover and recognize the supported insertion modes in
       
    28 	 * the parser.
       
    29 	 *
       
    30 	 * Out of all the possible insertion modes, only those
       
    31 	 * supported by the parser are listed here. As support
       
    32 	 * is added to the parser for more modes, add them here
       
    33 	 * following the same naming and value pattern.
       
    34 	 *
       
    35 	 * @see https://html.spec.whatwg.org/#the-insertion-mode
       
    36 	 */
       
    37 
       
    38 	/**
       
    39 	 * Initial insertion mode for full HTML parser.
       
    40 	 *
       
    41 	 * @since 6.4.0
       
    42 	 *
       
    43 	 * @see https://html.spec.whatwg.org/#the-initial-insertion-mode
       
    44 	 * @see WP_HTML_Processor_State::$insertion_mode
       
    45 	 *
       
    46 	 * @var string
       
    47 	 */
       
    48 	const INSERTION_MODE_INITIAL = 'insertion-mode-initial';
       
    49 
       
    50 	/**
       
    51 	 * In body insertion mode for full HTML parser.
       
    52 	 *
       
    53 	 * @since 6.4.0
       
    54 	 *
       
    55 	 * @see https://html.spec.whatwg.org/#parsing-main-inbody
       
    56 	 * @see WP_HTML_Processor_State::$insertion_mode
       
    57 	 *
       
    58 	 * @var string
       
    59 	 */
       
    60 	const INSERTION_MODE_IN_BODY = 'insertion-mode-in-body';
       
    61 
       
    62 	/**
       
    63 	 * Tracks open elements while scanning HTML.
       
    64 	 *
       
    65 	 * This property is initialized in the constructor and never null.
       
    66 	 *
       
    67 	 * @since 6.4.0
       
    68 	 *
       
    69 	 * @see https://html.spec.whatwg.org/#stack-of-open-elements
       
    70 	 *
       
    71 	 * @var WP_HTML_Open_Elements
       
    72 	 */
       
    73 	public $stack_of_open_elements = null;
       
    74 
       
    75 	/**
       
    76 	 * Tracks open formatting elements, used to handle mis-nested formatting element tags.
       
    77 	 *
       
    78 	 * This property is initialized in the constructor and never null.
       
    79 	 *
       
    80 	 * @since 6.4.0
       
    81 	 *
       
    82 	 * @see https://html.spec.whatwg.org/#list-of-active-formatting-elements
       
    83 	 *
       
    84 	 * @var WP_HTML_Active_Formatting_Elements
       
    85 	 */
       
    86 	public $active_formatting_elements = null;
       
    87 
       
    88 	/**
       
    89 	 * Refers to the currently-matched tag, if any.
       
    90 	 *
       
    91 	 * @since 6.4.0
       
    92 	 *
       
    93 	 * @var WP_HTML_Token|null
       
    94 	 */
       
    95 	public $current_token = null;
       
    96 
       
    97 	/**
       
    98 	 * Tree construction insertion mode.
       
    99 	 *
       
   100 	 * @since 6.4.0
       
   101 	 *
       
   102 	 * @see https://html.spec.whatwg.org/#insertion-mode
       
   103 	 *
       
   104 	 * @var string
       
   105 	 */
       
   106 	public $insertion_mode = self::INSERTION_MODE_INITIAL;
       
   107 
       
   108 	/**
       
   109 	 * Context node initializing fragment parser, if created as a fragment parser.
       
   110 	 *
       
   111 	 * @since 6.4.0
       
   112 	 *
       
   113 	 * @see https://html.spec.whatwg.org/#concept-frag-parse-context
       
   114 	 *
       
   115 	 * @var [string, array]|null
       
   116 	 */
       
   117 	public $context_node = null;
       
   118 
       
   119 	/**
       
   120 	 * The frameset-ok flag indicates if a `FRAMESET` element is allowed in the current state.
       
   121 	 *
       
   122 	 * > The frameset-ok flag is set to "ok" when the parser is created. It is set to "not ok" after certain tokens are seen.
       
   123 	 *
       
   124 	 * @since 6.4.0
       
   125 	 *
       
   126 	 * @see https://html.spec.whatwg.org/#frameset-ok-flag
       
   127 	 *
       
   128 	 * @var bool
       
   129 	 */
       
   130 	public $frameset_ok = true;
       
   131 
       
   132 	/**
       
   133 	 * Constructor - creates a new and empty state value.
       
   134 	 *
       
   135 	 * @since 6.4.0
       
   136 	 *
       
   137 	 * @see WP_HTML_Processor
       
   138 	 */
       
   139 	public function __construct() {
       
   140 		$this->stack_of_open_elements     = new WP_HTML_Open_Elements();
       
   141 		$this->active_formatting_elements = new WP_HTML_Active_Formatting_Elements();
       
   142 	}
       
   143 }