Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML API: Improve implementation of adoption agency algorithm #6983

Open
wants to merge 19 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
38c29c8
HTML API: Simplify breadcrumb accounting.
dmsnell Jul 6, 2024
e11f9ee
HTML API: Expand Unsupported class and make it available for debugging.
dmsnell Jul 6, 2024
e97f678
HTML API: Support more of the adoption agency algorithm.
dmsnell Jul 3, 2024
2b2d6fe
HTML API: Simplify breadcrumb accounting.
dmsnell Jul 6, 2024
6962fa2
HTML API: Expand Unsupported class and make it available for debugging.
dmsnell Jul 6, 2024
ab1096f
HTML API: Implement "reconstruct the active formatting elements" algo…
dmsnell Jul 6, 2024
ad82d3a
Merge branch 'trunk' into html-api/improve-active-element-reconstruction
dmsnell Aug 8, 2024
99d2175
Merge branch 'trunk' into html-api/improve-adoption-agency-algorithm
dmsnell Aug 8, 2024
22856d3
More iteration
dmsnell Aug 9, 2024
398ce37
Bail when needing to ignore token during adoption.
dmsnell Aug 9, 2024
374cba3
Continue iterating
dmsnell Aug 9, 2024
9bf12f4
Merge branch 'trunk' into html-api/improve-active-element-reconstruction
sirreal Aug 29, 2024
d7dac5e
Goto instead of ignore
dmsnell Sep 2, 2024
cabe36e
Remove dead code
dmsnell Sep 2, 2024
5e4bab9
Merge branch 'trunk' into html-api/improve-active-element-reconstruction
dmsnell Sep 3, 2024
301438f
Merge branch 'trunk' into html-api/improve-adoption-agency-algorithm
dmsnell Sep 3, 2024
9856fce
Merge branch 'trunk' into html-api/improve-active-element-reconstruction
dmsnell Sep 4, 2024
6d60b3a
Merge branch 'trunk' into html-api/improve-adoption-agency-algorithm
dmsnell Sep 4, 2024
dd0f59f
Merge branch 'html-api/improve-active-element-reconstruction' into ht…
dmsnell Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ class WP_HTML_Active_Formatting_Elements {
*/
private $stack = array();

/**
* Returns the node at the given 1-offset index in the list of active formatting elements.
*
* Do not use this method; it is meant to be used only by the HTML Processor.
*
* @since 6.7.0
*
* @access private
*
* @param int $index Number of nodes from the top node to return.
* @return WP_HTML_Token|null Node at the given index in the stack, if one exists, otherwise null.
*/
public function at( $nth ) {
return $this->stack[ $nth - 1 ];
}

/**
* Reports if a specific node is in the stack of active formatting elements.
*
Expand Down
17 changes: 14 additions & 3 deletions src/wp-includes/html-api/class-wp-html-open-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,23 @@ public function remove_node( WP_HTML_Token $token ): bool {
* see WP_HTML_Open_Elements::walk_up().
*
* @since 6.4.0
* @since 6.7.0 Accepts $below_this_node to start traversal below a given node, if it exists.
*
* @param ?WP_HTML_Token $below_this_node Start traversing below this node, if provided and if the node exists.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix PHPdoc:

Suggested change
* @param ?WP_HTML_Token $below_this_node Start traversing below this node, if provided and if the node exists.
* @param WP_HTML_Token|null $below_this_node Start traversing below this node, if provided and if the node exists.

*/
public function walk_down() {
$count = count( $this->stack );
public function walk_down( $below_this_node = null ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function walk_down( $below_this_node = null ) {
public function walk_down( WP_HTML_Token $below_this_node = null ) {

$has_found_node = null === $below_this_node;
$count = count( $this->stack );

for ( $i = 0; $i < $count; $i++ ) {
yield $this->stack[ $i ];
$node = $this->stack[ $i ];

if ( ! $has_found_node ) {
$has_found_node = $node === $below_this_node;
continue;
}

yield $node;
}
}

Expand Down
Loading
Loading