Repository navigation
Implement a nesting limit - #811
Merged
Merged
Conversation
mrobinson
reviewed
Nov 2, 2026
| /// | ||
| /// Following the example set by Gecko and Blink, | ||
| /// html5ever limits the tree depth. | ||
| fn nesting_limit(&self) { |
Member
There was a problem hiding this comment.
Nit: It might make sense to describe how the nesting limit is enforced in the rustdoc. Do other browsers take the same approach other than sharing a nesting limit? Maybe it makes sense to call this something like "pop_elements_until_nesting_limit_reached" as well, just to make it very clear what it does.
Contributor
Author
There was a problem hiding this comment.
I did some more investigation and found a spot where this disagrees with Firefox.
Instead of popping elements until the nesting limit is reached, I've copied Gecko implementation more closely, as described in whatwg/html#3732 (comment).
notriddle
force-pushed
the
nesting-limit
branch
from
November 3, 2026 06:58
bd19d2c to
df46b4e
Compare
notriddle
force-pushed
the
nesting-limit
branch
from
November 3, 2026 07:05
df46b4e to
2c14e52
Compare
Opening a document with 512 `<i>` tags in Firefox, as found in the included test case, shows the same DOM, including the correct text nesting and two `<i>` tags at the tip of the pyramid. Fixes servo#788 Results of running the test are given below. Before ------ <div> n= 4000 bytes= 44001 51.818ms <div> n= 16000 bytes= 176001 459.037ms <div> n= 64000 bytes= 704001 7.551s <ul><li> n= 4000 bytes= 32001 115.165ms <ul><li> n= 16000 bytes= 128001 1.845s <ul><li> n= 64000 bytes= 512001 35.355s <b> n= 4000 bytes= 12001 814.333µs <b> n= 16000 bytes= 48001 2.981ms <b> n= 64000 bytes= 192001 12.490ms After ----- <div> n= 4000 bytes= 44001 8.136ms <div> n= 16000 bytes= 176001 33.434ms <div> n= 64000 bytes= 704001 134.578ms <ul><li> n= 4000 bytes= 32001 15.342ms <ul><li> n= 16000 bytes= 128001 62.561ms <ul><li> n= 64000 bytes= 512001 253.616ms <b> n= 4000 bytes= 12001 727.458µs <b> n= 16000 bytes= 48001 2.664ms <b> n= 64000 bytes= 192001 10.497ms
notriddle
force-pushed
the
nesting-limit
branch
from
November 3, 2026 07:07
2c14e52 to
89b26d9
Compare
mrobinson
approved these changes
Nov 3, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening a document with 512
<i>tags in Firefox, as found in the included test case, shows the same DOM, including the correct text nesting and two<i>tags at the tip of the pyramid.Fixes #788
Results of running the test are given below.
Before
After