| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 * @ignore 20 * 21 * @see WP_HTML_Processor 22 */ 23 class WP_HTML_Processor_State { 24 /* 25 * Insertion mode constants. 26 * 27 * These constants exist and are named to make it easier to 28 * discover and recognize the supported insertion modes in 29 * the parser. 30 * 31 * Out of all the possible insertion modes, only those 32 * supported by the parser are listed here. As support 33 * is added to the parser for more modes, add them here 34 * following the same naming and value pattern. 35 * 36 * @see https://html.spec.whatwg.org/#the-insertion-mode 37 */ 38 39 /** 40 * Initial insertion mode for full HTML parser. 41 * 42 * @since 6.4.0 43 * 44 * @see https://html.spec.whatwg.org/#the-initial-insertion-mode 45 * @see WP_HTML_Processor_State::$insertion_mode 46 * 47 * @var string 48 */ 49 const INSERTION_MODE_INITIAL = 'insertion-mode-initial'; 50 51 /** 52 * Before HTML insertion mode for full HTML parser. 53 * 54 * @since 6.7.0 55 * 56 * @see https://html.spec.whatwg.org/#the-before-html-insertion-mode 57 * @see WP_HTML_Processor_State::$insertion_mode 58 * 59 * @var string 60 */ 61 const INSERTION_MODE_BEFORE_HTML = 'insertion-mode-before-html'; 62 63 /** 64 * Before head insertion mode for full HTML parser. 65 * 66 * @since 6.7.0 67 * 68 * @see https://html.spec.whatwg.org/#parsing-main-beforehead 69 * @see WP_HTML_Processor_State::$insertion_mode 70 * 71 * @var string 72 */ 73 const INSERTION_MODE_BEFORE_HEAD = 'insertion-mode-before-head'; 74 75 /** 76 * In head insertion mode for full HTML parser. 77 * 78 * @since 6.7.0 79 * 80 * @see https://html.spec.whatwg.org/#parsing-main-inhead 81 * @see WP_HTML_Processor_State::$insertion_mode 82 * 83 * @var string 84 */ 85 const INSERTION_MODE_IN_HEAD = 'insertion-mode-in-head'; 86 87 /** 88 * In head noscript insertion mode for full HTML parser. 89 * 90 * @since 6.7.0 91 * 92 * @see https://html.spec.whatwg.org/#parsing-main-inheadnoscript 93 * @see WP_HTML_Processor_State::$insertion_mode 94 * 95 * @var string 96 */ 97 const INSERTION_MODE_IN_HEAD_NOSCRIPT = 'insertion-mode-in-head-noscript'; 98 99 /** 100 * After head insertion mode for full HTML parser. 101 * 102 * @since 6.7.0 103 * 104 * @see https://html.spec.whatwg.org/#parsing-main-afterhead 105 * @see WP_HTML_Processor_State::$insertion_mode 106 * 107 * @var string 108 */ 109 const INSERTION_MODE_AFTER_HEAD = 'insertion-mode-after-head'; 110 111 /** 112 * In body insertion mode for full HTML parser. 113 * 114 * @since 6.4.0 115 * 116 * @see https://html.spec.whatwg.org/#parsing-main-inbody 117 * @see WP_HTML_Processor_State::$insertion_mode 118 * 119 * @var string 120 */ 121 const INSERTION_MODE_IN_BODY = 'insertion-mode-in-body'; 122 123 /** 124 * In table insertion mode for full HTML parser. 125 * 126 * @since 6.7.0 127 * 128 * @see https://html.spec.whatwg.org/#parsing-main-intable 129 * @see WP_HTML_Processor_State::$insertion_mode 130 * 131 * @var string 132 */ 133 const INSERTION_MODE_IN_TABLE = 'insertion-mode-in-table'; 134 135 /** 136 * In table text insertion mode for full HTML parser. 137 * 138 * @since 6.7.0 139 * 140 * @see https://html.spec.whatwg.org/#parsing-main-intabletext 141 * @see WP_HTML_Processor_State::$insertion_mode 142 * 143 * @var string 144 */ 145 const INSERTION_MODE_IN_TABLE_TEXT = 'insertion-mode-in-table-text'; 146 147 /** 148 * In caption insertion mode for full HTML parser. 149 * 150 * @since 6.7.0 151 * 152 * @see https://html.spec.whatwg.org/#parsing-main-incaption 153 * @see WP_HTML_Processor_State::$insertion_mode 154 * 155 * @var string 156 */ 157 const INSERTION_MODE_IN_CAPTION = 'insertion-mode-in-caption'; 158 159 /** 160 * In column group insertion mode for full HTML parser. 161 * 162 * @since 6.7.0 163 * 164 * @see https://html.spec.whatwg.org/#parsing-main-incolumngroup 165 * @see WP_HTML_Processor_State::$insertion_mode 166 * 167 * @var string 168 */ 169 const INSERTION_MODE_IN_COLUMN_GROUP = 'insertion-mode-in-column-group'; 170 171 /** 172 * In table body insertion mode for full HTML parser. 173 * 174 * @since 6.7.0 175 * 176 * @see https://html.spec.whatwg.org/#parsing-main-intablebody 177 * @see WP_HTML_Processor_State::$insertion_mode 178 * 179 * @var string 180 */ 181 const INSERTION_MODE_IN_TABLE_BODY = 'insertion-mode-in-table-body'; 182 183 /** 184 * In row insertion mode for full HTML parser. 185 * 186 * @since 6.7.0 187 * 188 * @see https://html.spec.whatwg.org/#parsing-main-inrow 189 * @see WP_HTML_Processor_State::$insertion_mode 190 * 191 * @var string 192 */ 193 const INSERTION_MODE_IN_ROW = 'insertion-mode-in-row'; 194 195 /** 196 * In cell insertion mode for full HTML parser. 197 * 198 * @since 6.7.0 199 * 200 * @see https://html.spec.whatwg.org/#parsing-main-incell 201 * @see WP_HTML_Processor_State::$insertion_mode 202 * 203 * @var string 204 */ 205 const INSERTION_MODE_IN_CELL = 'insertion-mode-in-cell'; 206 207 /** 208 * In select insertion mode for full HTML parser. 209 * 210 * @since 6.7.0 211 * 212 * @see https://html.spec.whatwg.org/#parsing-main-inselect 213 * @see WP_HTML_Processor_State::$insertion_mode 214 * 215 * @var string 216 */ 217 const INSERTION_MODE_IN_SELECT = 'insertion-mode-in-select'; 218 219 /** 220 * In select in table insertion mode for full HTML parser. 221 * 222 * @since 6.7.0 223 * 224 * @see https://html.spec.whatwg.org/#parsing-main-inselectintable 225 * @see WP_HTML_Processor_State::$insertion_mode 226 * 227 * @var string 228 */ 229 const INSERTION_MODE_IN_SELECT_IN_TABLE = 'insertion-mode-in-select-in-table'; 230 231 /** 232 * In template insertion mode for full HTML parser. 233 * 234 * @since 6.7.0 235 * 236 * @see https://html.spec.whatwg.org/#parsing-main-intemplate 237 * @see WP_HTML_Processor_State::$insertion_mode 238 * 239 * @var string 240 */ 241 const INSERTION_MODE_IN_TEMPLATE = 'insertion-mode-in-template'; 242 243 /** 244 * After body insertion mode for full HTML parser. 245 * 246 * @since 6.7.0 247 * 248 * @see https://html.spec.whatwg.org/#parsing-main-afterbody 249 * @see WP_HTML_Processor_State::$insertion_mode 250 * 251 * @var string 252 */ 253 const INSERTION_MODE_AFTER_BODY = 'insertion-mode-after-body'; 254 255 /** 256 * In frameset insertion mode for full HTML parser. 257 * 258 * @since 6.7.0 259 * 260 * @see https://html.spec.whatwg.org/#parsing-main-inframeset 261 * @see WP_HTML_Processor_State::$insertion_mode 262 * 263 * @var string 264 */ 265 const INSERTION_MODE_IN_FRAMESET = 'insertion-mode-in-frameset'; 266 267 /** 268 * After frameset insertion mode for full HTML parser. 269 * 270 * @since 6.7.0 271 * 272 * @see https://html.spec.whatwg.org/#parsing-main-afterframeset 273 * @see WP_HTML_Processor_State::$insertion_mode 274 * 275 * @var string 276 */ 277 const INSERTION_MODE_AFTER_FRAMESET = 'insertion-mode-after-frameset'; 278 279 /** 280 * After after body insertion mode for full HTML parser. 281 * 282 * @since 6.7.0 283 * 284 * @see https://html.spec.whatwg.org/#the-after-after-body-insertion-mode 285 * @see WP_HTML_Processor_State::$insertion_mode 286 * 287 * @var string 288 */ 289 const INSERTION_MODE_AFTER_AFTER_BODY = 'insertion-mode-after-after-body'; 290 291 /** 292 * After after frameset insertion mode for full HTML parser. 293 * 294 * @since 6.7.0 295 * 296 * @see https://html.spec.whatwg.org/#the-after-after-frameset-insertion-mode 297 * @see WP_HTML_Processor_State::$insertion_mode 298 * 299 * @var string 300 */ 301 const INSERTION_MODE_AFTER_AFTER_FRAMESET = 'insertion-mode-after-after-frameset'; 302 303 /** 304 * The stack of template insertion modes. 305 * 306 * @since 6.7.0 307 * 308 * @see https://html.spec.whatwg.org/#the-insertion-mode:stack-of-template-insertion-modes 309 * 310 * @var array<string> 311 */ 312 public $stack_of_template_insertion_modes = array(); 313 314 /** 315 * Tracks open elements while scanning HTML. 316 * 317 * This property is initialized in the constructor and never null. 318 * 319 * @since 6.4.0 320 * 321 * @see https://html.spec.whatwg.org/#stack-of-open-elements 322 * 323 * @var WP_HTML_Open_Elements 324 */ 325 public $stack_of_open_elements; 326 327 /** 328 * Tracks open formatting elements, used to handle mis-nested formatting element tags. 329 * 330 * This property is initialized in the constructor and never null. 331 * 332 * @since 6.4.0 333 * 334 * @see https://html.spec.whatwg.org/#list-of-active-formatting-elements 335 * 336 * @var WP_HTML_Active_Formatting_Elements 337 */ 338 public $active_formatting_elements; 339 340 /** 341 * Refers to the currently-matched tag, if any. 342 * 343 * @since 6.4.0 344 * 345 * @var WP_HTML_Token|null 346 */ 347 public $current_token = null; 348 349 /** 350 * Tree construction insertion mode. 351 * 352 * @since 6.4.0 353 * 354 * @see https://html.spec.whatwg.org/#insertion-mode 355 * 356 * @var string 357 */ 358 public $insertion_mode = self::INSERTION_MODE_INITIAL; 359 360 /** 361 * Context node initializing fragment parser, if created as a fragment parser. 362 * 363 * @since 6.4.0 364 * @deprecated 6.8.0 WP_HTML_Processor tracks the context_node internally. 365 * 366 * @var null 367 */ 368 public $context_node = null; 369 370 /** 371 * The recognized encoding of the input byte stream. 372 * 373 * > The stream of code points that comprises the input to the tokenization 374 * > stage will be initially seen by the user agent as a stream of bytes 375 * > (typically coming over the network or from the local file system). 376 * > The bytes encode the actual characters according to a particular character 377 * > encoding, which the user agent uses to decode the bytes into characters. 378 * 379 * @since 6.7.0 380 * 381 * @var string|null 382 */ 383 public $encoding = null; 384 385 /** 386 * The parser's confidence in the input encoding. 387 * 388 * > When the HTML parser is decoding an input byte stream, it uses a character 389 * > encoding and a confidence. The confidence is either tentative, certain, or 390 * > irrelevant. The encoding used, and whether the confidence in that encoding 391 * > is tentative or certain, is used during the parsing to determine whether to 392 * > change the encoding. If no encoding is necessary, e.g. because the parser is 393 * > operating on a Unicode stream and doesn't have to use a character encoding 394 * > at all, then the confidence is irrelevant. 395 * 396 * @since 6.7.0 397 * 398 * @var string 399 */ 400 public $encoding_confidence = 'tentative'; 401 402 /** 403 * HEAD element pointer. 404 * 405 * @since 6.7.0 406 * 407 * @see https://html.spec.whatwg.org/multipage/parsing.html#head-element-pointer 408 * 409 * @var WP_HTML_Token|null 410 */ 411 public $head_element = null; 412 413 /** 414 * FORM element pointer. 415 * 416 * > points to the last form element that was opened and whose end tag has 417 * > not yet been seen. It is used to make form controls associate with 418 * > forms in the face of dramatically bad markup, for historical reasons. 419 * > It is ignored inside template elements. 420 * 421 * @todo This may be invalidated by a seek operation. 422 * 423 * @see https://html.spec.whatwg.org/#form-element-pointer 424 * 425 * @since 6.7.0 426 * 427 * @var WP_HTML_Token|null 428 */ 429 public $form_element = null; 430 431 /** 432 * The frameset-ok flag indicates if a `FRAMESET` element is allowed in the current state. 433 * 434 * > The frameset-ok flag is set to "ok" when the parser is created. It is set to "not ok" after certain tokens are seen. 435 * 436 * @since 6.4.0 437 * 438 * @see https://html.spec.whatwg.org/#frameset-ok-flag 439 * 440 * @var bool 441 */ 442 public $frameset_ok = true; 443 444 /** 445 * Constructor - creates a new and empty state value. 446 * 447 * @since 6.4.0 448 * 449 * @see WP_HTML_Processor 450 */ 451 public function __construct() { 452 $this->stack_of_open_elements = new WP_HTML_Open_Elements(); 453 $this->active_formatting_elements = new WP_HTML_Active_Formatting_Elements(); 454 } 455 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sun Jun 14 08:20:09 2026 | Cross-referenced by PHPXref |