Skip to content

Commit

Permalink
HTML API: Stub out remaining insertion modes in the HTML Processor.
Browse files Browse the repository at this point in the history
As part of work to add more spec support to the HTML API, this patch adds
stubs for all of the remaining parser insertion modes in the HTML Processor.
These modes are not all supported yet, but they will be necessary to continue
adding support for other tags and markup.

Developed in WordPress#6973
Discussed in https://core.trac.wordpress.org/ticket/61576

Props dmsnell, jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58679 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
dmsnell committed Jul 5, 2024
1 parent aa11864 commit 6763e5d
Show file tree
Hide file tree
Showing 2 changed files with 588 additions and 31 deletions.
144 changes: 120 additions & 24 deletions src/wp-includes/html-api/class-wp-html-processor-state.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,76 @@ class WP_HTML_Processor_State {
const INSERTION_MODE_INITIAL = 'insertion-mode-initial';

/**
* In body insertion mode for full HTML parser.
* Before HTML insertion mode for full HTML parser.
*
* @since 6.4.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inbody
* @see https://html.spec.whatwg.org/#the-before-html-insertion-mode
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_BODY = 'insertion-mode-in-body';
const INSERTION_MODE_BEFORE_HTML = 'insertion-mode-before-html';

/**
* In select insertion mode for full HTML parser.
* Before head insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inselect
* @see https://html.spec.whatwg.org/#parsing-main-beforehead
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_SELECT = 'insertion-mode-in-select';
const INSERTION_MODE_BEFORE_HEAD = 'insertion-mode-before-head';

/**
* In select in table insertion mode for full HTML parser.
* In head insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inselectintable
* @see https://html.spec.whatwg.org/#parsing-main-inhead
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_SELECT_IN_TABLE = 'insertion-mode-in-select-in-table';
const INSERTION_MODE_IN_HEAD = 'insertion-mode-in-head';

/**
* In head noscript insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inheadnoscript
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_HEAD_NOSCRIPT = 'insertion-mode-in-head-noscript';

/**
* After head insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-afterhead
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_AFTER_HEAD = 'insertion-mode-after-head';

/**
* In body insertion mode for full HTML parser.
*
* @since 6.4.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inbody
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_BODY = 'insertion-mode-in-body';

/**
* In table insertion mode for full HTML parser.
Expand All @@ -95,6 +131,18 @@ class WP_HTML_Processor_State {
*/
const INSERTION_MODE_IN_TABLE = 'insertion-mode-in-table';

/**
* In table text insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-intabletext
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_TABLE_TEXT = 'insertion-mode-in-table-text';

/**
* In caption insertion mode for full HTML parser.
*
Expand All @@ -107,6 +155,18 @@ class WP_HTML_Processor_State {
*/
const INSERTION_MODE_IN_CAPTION = 'insertion-mode-in-caption';

/**
* In column group insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-incolumngroup
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_COLUMN_GROUP = 'insertion-mode-in-column-group';

/**
* In table body insertion mode for full HTML parser.
*
Expand Down Expand Up @@ -144,16 +204,52 @@ class WP_HTML_Processor_State {
const INSERTION_MODE_IN_CELL = 'insertion-mode-in-cell';

/**
* In column group insertion mode for full HTML parser.
* In select insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-incolumngroup
* @see https://html.spec.whatwg.org/#parsing-main-inselect
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_COLUMN_GROUP = 'insertion-mode-in-column-group';
const INSERTION_MODE_IN_SELECT = 'insertion-mode-in-select';

/**
* In select in table insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inselectintable
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_SELECT_IN_TABLE = 'insertion-mode-in-select-in-table';

/**
* In template insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-intemplate
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_TEMPLATE = 'insertion-mode-in-template';

/**
* After body insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-afterbody
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_AFTER_BODY = 'insertion-mode-after-body';

/**
* In frameset insertion mode for full HTML parser.
Expand All @@ -168,52 +264,52 @@ class WP_HTML_Processor_State {
const INSERTION_MODE_IN_FRAMESET = 'insertion-mode-in-frameset';

/**
* In head insertion mode for full HTML parser.
* After frameset insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-inhead
* @see https://html.spec.whatwg.org/#parsing-main-afterframeset
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_HEAD = 'insertion-mode-in-head';
const INSERTION_MODE_AFTER_FRAMESET = 'insertion-mode-after-frameset';

/**
* Before head insertion mode for full HTML parser.
* After after body insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-beforehead
* @see https://html.spec.whatwg.org/#the-after-after-body-insertion-mode
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_BEFORE_HEAD = 'insertion-mode-before-head';
const INSERTION_MODE_AFTER_AFTER_BODY = 'insertion-mode-after-after-body';

/**
* After head insertion mode for full HTML parser.
* After after frameset insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-afterhead
* @see https://html.spec.whatwg.org/#the-after-after-frameset-insertion-mode
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_AFTER_HEAD = 'insertion-mode-after-head';
const INSERTION_MODE_AFTER_AFTER_FRAMESET = 'insertion-mode-after-after-frameset';

/**
* In template insertion mode for full HTML parser.
* In foreign content insertion mode for full HTML parser.
*
* @since 6.7.0
*
* @see https://html.spec.whatwg.org/#parsing-main-intemplate
* @see https://html.spec.whatwg.org/#parsing-main-inforeign
* @see WP_HTML_Processor_State::$insertion_mode
*
* @var string
*/
const INSERTION_MODE_IN_TEMPLATE = 'insertion-mode-in-template';
const INSERTION_MODE_IN_FOREIGN_CONTENT = 'insertion-mode-in-foreign-content';

/**
* The stack of template insertion modes.
Expand Down
Loading

0 comments on commit 6763e5d

Please sign in to comment.