script: Rewrite NodeList::ChildrenList with a cached Vec of nodes - #44435
Merged
Conversation
|
🔨 Triggering try run (#24779803919) for Linux (WPT) |
|
Test results for linux-wpt from try job (#24779803919): Flaky unexpected result (29)
Stable unexpected results that are known to be intermittent (21)
|
|
✨ Try run (#24779803919) succeeded. |
servo#36764 Signed-off-by: Simon Sapin <simon@igalia.com>
In DOM APIs, `Node.childNodes` is a `NodeList` that has an `.item(index)` method that allows random access, but DOM nodes only store pointers to their first/last child and next/previous sibling. The previous implementation involved keeping a "last access" pointer, and a significant amount of logic to find the requested index by walking next/previous sibling pointers from whichever of last access, first child, or last child is nearest. This logic sometimes incorrectly assumed the (nullable) last accessed pointer to be present, causing a panic in `Option::unwrap`. Rather than try to fix that logic, this replaces entirely with the approach suggested in servo#25206 and used by Firefox: keep a cached `Vec` of pointers to all child nodes, created lazily when needed, and invalidated whenever any part of it changes. Fixes servo#25206 Fixes servo#36764 Signed-off-by: Simon Sapin <simon@igalia.com>
SimonSapin
force-pushed
the
childlist-vec
branch
from
April 22, 2026 14:54
110f9e9 to
d0e2bab
Compare
TimvdLippe
enabled auto-merge
April 22, 2026 14:57
Collaborator
|
🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#59405) with upstreamable changes. |
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Apr 22, 2026
Collaborator
|
✍ Updated existing upstream WPT pull request (web-platform-tests/wpt#59405) title and body. |
This was referenced Jul 20, 2026
gterzian
pushed a commit
to gterzian/servo
that referenced
this pull request
Jul 21, 2026
Pass `&JsContext` in a few more places in order to use `*_no_gc` APIs. This is a follow-up to servo#44435 Testing: expecting no change to existing test results --------- Signed-off-by: Simon Sapin <simon@igalia.com>
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.
In DOM APIs,
Node.childNodesis aNodeListthat has an.item(index)method that allows random access, but DOM nodes only store pointers to their first/last child and next/previous sibling. The previous implementation involved keeping a "last accessed" pointer, and a significant amount of logic to find the requested index by walking next/previous sibling pointers from whichever of last accessed, first child, or last child is nearest. This logic sometimes incorrectly assumed the (nullable) last accessed pointer to be present, causing a panic inOption::unwrap.Rather than try to fix that logic, this replaces entirely with the approach suggested in #25206 and used by Firefox: keep a cached
Vecof pointers to all child nodes, created lazily when needed, and invalidated whenever any part of it changes.Testing: the first commit adds a failing WPT crashtest, the second commit fixes it
Fixes: #25206
Fixes: #36764