| [ 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 * @deprecated 7.1.0 The "in select" insertion mode was removed from the standard. 213 * @ignore 214 * 215 * @see WP_HTML_Processor_State::$insertion_mode 216 * 217 * @var string 218 */ 219 const INSERTION_MODE_IN_SELECT = 'insertion-mode-in-select'; 220 221 /** 222 * In select in table insertion mode for full HTML parser. 223 * 224 * @since 6.7.0 225 * 226 * @deprecated 7.1.0 The "in select in table" insertion mode was removed from the standard. 227 * @ignore 228 * 229 * @see WP_HTML_Processor_State::$insertion_mode 230 * 231 * @var string 232 */ 233 const INSERTION_MODE_IN_SELECT_IN_TABLE = 'insertion-mode-in-select-in-table'; 234 235 /** 236 * In template insertion mode for full HTML parser. 237 * 238 * @since 6.7.0 239 * 240 * @see https://html.spec.whatwg.org/#parsing-main-intemplate 241 * @see WP_HTML_Processor_State::$insertion_mode 242 * 243 * @var string 244 */ 245 const INSERTION_MODE_IN_TEMPLATE = 'insertion-mode-in-template'; 246 247 /** 248 * After body insertion mode for full HTML parser. 249 * 250 * @since 6.7.0 251 * 252 * @see https://html.spec.whatwg.org/#parsing-main-afterbody 253 * @see WP_HTML_Processor_State::$insertion_mode 254 * 255 * @var string 256 */ 257 const INSERTION_MODE_AFTER_BODY = 'insertion-mode-after-body'; 258 259 /** 260 * In frameset insertion mode for full HTML parser. 261 * 262 * @since 6.7.0 263 * 264 * @see https://html.spec.whatwg.org/#parsing-main-inframeset 265 * @see WP_HTML_Processor_State::$insertion_mode 266 * 267 * @var string 268 */ 269 const INSERTION_MODE_IN_FRAMESET = 'insertion-mode-in-frameset'; 270 271 /** 272 * After frameset insertion mode for full HTML parser. 273 * 274 * @since 6.7.0 275 * 276 * @see https://html.spec.whatwg.org/#parsing-main-afterframeset 277 * @see WP_HTML_Processor_State::$insertion_mode 278 * 279 * @var string 280 */ 281 const INSERTION_MODE_AFTER_FRAMESET = 'insertion-mode-after-frameset'; 282 283 /** 284 * After after body insertion mode for full HTML parser. 285 * 286 * @since 6.7.0 287 * 288 * @see https://html.spec.whatwg.org/#the-after-after-body-insertion-mode 289 * @see WP_HTML_Processor_State::$insertion_mode 290 * 291 * @var string 292 */ 293 const INSERTION_MODE_AFTER_AFTER_BODY = 'insertion-mode-after-after-body'; 294 295 /** 296 * After after frameset insertion mode for full HTML parser. 297 * 298 * @since 6.7.0 299 * 300 * @see https://html.spec.whatwg.org/#the-after-after-frameset-insertion-mode 301 * @see WP_HTML_Processor_State::$insertion_mode 302 * 303 * @var string 304 */ 305 const INSERTION_MODE_AFTER_AFTER_FRAMESET = 'insertion-mode-after-after-frameset'; 306 307 /** 308 * The stack of template insertion modes. 309 * 310 * @since 6.7.0 311 * 312 * @see https://html.spec.whatwg.org/#the-insertion-mode:stack-of-template-insertion-modes 313 * 314 * @var array<string> 315 */ 316 public $stack_of_template_insertion_modes = array(); 317 318 /** 319 * Tracks open elements while scanning HTML. 320 * 321 * This property is initialized in the constructor and never null. 322 * 323 * @since 6.4.0 324 * 325 * @see https://html.spec.whatwg.org/#stack-of-open-elements 326 * 327 * @var WP_HTML_Open_Elements 328 */ 329 public $stack_of_open_elements; 330 331 /** 332 * Tracks open formatting elements, used to handle mis-nested formatting element tags. 333 * 334 * This property is initialized in the constructor and never null. 335 * 336 * @since 6.4.0 337 * 338 * @see https://html.spec.whatwg.org/#list-of-active-formatting-elements 339 * 340 * @var WP_HTML_Active_Formatting_Elements 341 */ 342 public $active_formatting_elements; 343 344 /** 345 * Refers to the currently-matched tag, if any. 346 * 347 * @since 6.4.0 348 * 349 * @var WP_HTML_Token|null 350 */ 351 public $current_token = null; 352 353 /** 354 * Tree construction insertion mode. 355 * 356 * @since 6.4.0 357 * 358 * @see https://html.spec.whatwg.org/#insertion-mode 359 * 360 * @var string 361 */ 362 public $insertion_mode = self::INSERTION_MODE_INITIAL; 363 364 /** 365 * Context node initializing fragment parser, if created as a fragment parser. 366 * 367 * @since 6.4.0 368 * @deprecated 6.8.0 WP_HTML_Processor tracks the context_node internally. 369 * 370 * @var null 371 */ 372 public $context_node = null; 373 374 /** 375 * The recognized encoding of the input byte stream. 376 * 377 * > The stream of code points that comprises the input to the tokenization 378 * > stage will be initially seen by the user agent as a stream of bytes 379 * > (typically coming over the network or from the local file system). 380 * > The bytes encode the actual characters according to a particular character 381 * > encoding, which the user agent uses to decode the bytes into characters. 382 * 383 * @since 6.7.0 384 * 385 * @var string|null 386 */ 387 public $encoding = null; 388 389 /** 390 * The parser's confidence in the input encoding. 391 * 392 * > When the HTML parser is decoding an input byte stream, it uses a character 393 * > encoding and a confidence. The confidence is either tentative, certain, or 394 * > irrelevant. The encoding used, and whether the confidence in that encoding 395 * > is tentative or certain, is used during the parsing to determine whether to 396 * > change the encoding. If no encoding is necessary, e.g. because the parser is 397 * > operating on a Unicode stream and doesn't have to use a character encoding 398 * > at all, then the confidence is irrelevant. 399 * 400 * @since 6.7.0 401 * 402 * @var string 403 */ 404 public $encoding_confidence = 'tentative'; 405 406 /** 407 * HEAD element pointer. 408 * 409 * @since 6.7.0 410 * 411 * @see https://html.spec.whatwg.org/multipage/parsing.html#head-element-pointer 412 * 413 * @var WP_HTML_Token|null 414 */ 415 public $head_element = null; 416 417 /** 418 * FORM element pointer. 419 * 420 * > points to the last form element that was opened and whose end tag has 421 * > not yet been seen. It is used to make form controls associate with 422 * > forms in the face of dramatically bad markup, for historical reasons. 423 * > It is ignored inside template elements. 424 * 425 * @todo This may be invalidated by a seek operation. 426 * 427 * @see https://html.spec.whatwg.org/#form-element-pointer 428 * 429 * @since 6.7.0 430 * 431 * @var WP_HTML_Token|null 432 */ 433 public $form_element = null; 434 435 /** 436 * The frameset-ok flag indicates if a `FRAMESET` element is allowed in the current state. 437 * 438 * > The frameset-ok flag is set to "ok" when the parser is created. It is set to "not ok" after certain tokens are seen. 439 * 440 * @since 6.4.0 441 * 442 * @see https://html.spec.whatwg.org/#frameset-ok-flag 443 * 444 * @var bool 445 */ 446 public $frameset_ok = true; 447 448 /** 449 * Constructor - creates a new and empty state value. 450 * 451 * @since 6.4.0 452 * 453 * @see WP_HTML_Processor 454 */ 455 public function __construct() { 456 $this->stack_of_open_elements = new WP_HTML_Open_Elements(); 457 $this->active_formatting_elements = new WP_HTML_Active_Formatting_Elements(); 458 } 459 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Jul 25 08:20:20 2026 | Cross-referenced by PHPXref |