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: Trigger active format reconstruction when reaching text nodes. #6054

Conversation

dmsnell
Copy link
Contributor

@dmsnell dmsnell commented Feb 7, 2024

Trac ticket: Core-60455

See alternative in #6203
See alternative in sirreal#6

Status

  • Needs tests to confirm behaviors.

Description

When encountering text nodes in an HTML document, the HTML Parser needs to run the active format reconstruction algorithm, even if it doesn't stop to visit those text nodes. This is because the formats, which might need reconstructing, will impact the breadcrumbs of all downstream nodes from the text node.

In this patch, this process is triggered, but the text nodes are then skipped, since the HTML Processor doesn't currently support visiting them.

Copy link

github-actions bot commented Feb 7, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dmsnell, jonsurrell, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

github-actions bot commented Feb 7, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@sirreal
Copy link
Member

sirreal commented Feb 7, 2024

I expected this to fix some of the tests from #5794 but this seems to have no impact at all on the html5lib tests results.

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

This change seems good, there seem to be no regressions, I do agree it would be good to have some tests for this behavior.

@dmsnell dmsnell force-pushed the html-api/reconstruct-active-formatting-elements-on-text branch from 6ea811d to 3050b34 Compare February 26, 2024 23:19
@dmsnell
Copy link
Contributor Author

dmsnell commented Feb 26, 2024

@westonruter would you mind giving this another pass? I added tests to assert the behavior, and they fail in trunk for me. I'd like to merge this ASAP to ensure the bug doesn't leak into 6.5

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

This looks good, thanks.

@dmsnell dmsnell force-pushed the html-api/reconstruct-active-formatting-elements-on-text branch 2 times, most recently from e9bbdbf to c57f20f Compare February 29, 2024 01:00
@dmsnell
Copy link
Contributor Author

dmsnell commented Feb 29, 2024

I'm not sure what is happening, because I thought this was all green, but it wasn't testing properly for me, and upon deeper inspection, I think many things need updating.

In fdb23e7 I have made the tests pass, but I'm concerned this is too rushed and that we should try a different approach, namely, detecting if we need reconstruction and bailing on a text node if we do.

@dmsnell dmsnell force-pushed the html-api/reconstruct-active-formatting-elements-on-text branch from 96975a2 to fdb23e7 Compare February 29, 2024 03:13
@dmsnell dmsnell force-pushed the html-api/reconstruct-active-formatting-elements-on-text branch from fdb23e7 to 39f6ae2 Compare March 5, 2024 17:01
Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

I've done another review pass and I'm happy with these changes.

I have no intention of continuing with sirreal#6.

dmsnell and others added 5 commits March 11, 2024 16:58
When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.

In this patch, this process is triggered, but the text nodes are then
skipped, since the HTML Processor doesn't currently support visiting
them.

Co-authored-by: Weston Ruter <westonruter@git.wordpress.org>
Co-authored-by: Jon Surrell <jonsurrell@git.wordpress.org>
@dmsnell dmsnell force-pushed the html-api/reconstruct-active-formatting-elements-on-text branch from 4e697fc to d8c1078 Compare March 11, 2024 23:59
pento pushed a commit that referenced this pull request Mar 12, 2024
When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.

In this patch, this process is triggered, which properly triggers the
active format reconstruction. It also enables the visiting of other token
types as is possible in the Tag Processor.

Developed in #6054
Discussed in https://core.trac.wordpress.org/ticket/60170

Props: dmsnell, jonsurrell, westonruter.
Fixes: #60455.
Follow-up to: [57348].



git-svn-id: https://develop.svn.wordpress.org/trunk@57806 602fd350-edb4-49c9-b593-d223f7449a82
@dmsnell
Copy link
Contributor Author

dmsnell commented Mar 12, 2024

Merged in [57806]
2452282

@dmsnell dmsnell closed this Mar 12, 2024
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Mar 12, 2024
When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.

In this patch, this process is triggered, which properly triggers the
active format reconstruction. It also enables the visiting of other token
types as is possible in the Tag Processor.

Developed in WordPress/wordpress-develop#6054
Discussed in https://core.trac.wordpress.org/ticket/60170

Props: dmsnell, jonsurrell, westonruter.
Fixes: #60455.
Follow-up to: [57348].


Built from https://develop.svn.wordpress.org/trunk@57806


git-svn-id: http://core.svn.wordpress.org/trunk@57307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@dmsnell dmsnell deleted the html-api/reconstruct-active-formatting-elements-on-text branch March 12, 2024 00:26
github-actions bot pushed a commit to gilzow/wordpress-performance that referenced this pull request Mar 12, 2024
When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.

In this patch, this process is triggered, which properly triggers the
active format reconstruction. It also enables the visiting of other token
types as is possible in the Tag Processor.

Developed in WordPress/wordpress-develop#6054
Discussed in https://core.trac.wordpress.org/ticket/60170

Props: dmsnell, jonsurrell, westonruter.
Fixes: #60455.
Follow-up to: [57348].


Built from https://develop.svn.wordpress.org/trunk@57806


git-svn-id: https://core.svn.wordpress.org/trunk@57307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit that referenced this pull request Mar 13, 2024
When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.
In this patch, this process is triggered, which properly triggers the
active format reconstruction. It also enables the visiting of other token
types as is possible in the Tag Processor.

Developed in #6054
Discussed in https://core.trac.wordpress.org/ticket/60170

Reviewed by swissspidy.
Merges [57806] to the to the 6.5 branch.

Props: dmsnell, jonsurrell, westonruter.
Fixes: #60455.
Follow-up to: [57348].


git-svn-id: https://develop.svn.wordpress.org/branches/6.5@57823 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to WordPress/WordPress that referenced this pull request Mar 13, 2024
When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.
In this patch, this process is triggered, which properly triggers the
active format reconstruction. It also enables the visiting of other token
types as is possible in the Tag Processor.

Developed in WordPress/wordpress-develop#6054
Discussed in https://core.trac.wordpress.org/ticket/60170

Reviewed by swissspidy.
Merges [57806] to the to the 6.5 branch.

Props: dmsnell, jonsurrell, westonruter.
Fixes: #60455.
Follow-up to: [57348].

Built from https://develop.svn.wordpress.org/branches/6.5@57823


git-svn-id: http://core.svn.wordpress.org/branches/6.5@57324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants