♻️ [PANA-5945] Support child list InsertionCursors #4163
+402
−66
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.
Motivation
Change records are a new, experimental data format for session replay data that's designed to record the same information in a more compact, more compressible form.
We've already landed support for recording full snapshots as Change records behind an experiment flag. The next step is to introduce support for incremental snapshots, as well. This requires making improvements to a number of different aspects of the recording code, so this PR is the first in a series that will work toward the goal of supporting incremental snapshots.
Changes
The Change record version of the DOM serialization code tracks its position in the DOM using an
InsertionCursor. TheInsertionCursor's role is to convert the insertion position of each serialized node into an encoded form used by Change records; any location in the DOM can be specified using a single integer.Today, the only factory function that exists for
InsertionCursorobjects creates them initially positioned at the root of the DOM. That's all we needed to support full snapshots. However, for incremental snapshots, we need to start serialization at an arbitrary point in the DOM; in other words, we need to be able to create anInsertionCursorthat initially points to a position in the child list of some existing, already-serialized DOM node. This allows us to use theseInsertionCursors to serialize new DOM subtrees as they are added.This PR adds a factory function for
InsertionCursors calledcreateChildInsertionCursor()that positions the newInsertionCursorwithin an existing child list. It also updates the tests to test this new functionality.