Get rid of `HTMLEditor::RemoveEmptyNodesIn`
Categories
(Core :: DOM: Editor, enhancement)
Tracking
()
People
(Reporter: masayuki, Unassigned)
References
(Blocks 3 open bugs)
Details
Attachments
(1 file)
|
4.55 KB,
text/html
|
Details |
It's a post-processor of editing the content. HTMLEditor records the range which the edit handlers touched and cleans up empty nodes in the range later. However, this is completely slow and hacky because:
- It needs to iterate all over the nodes in the range
- It needs to check each one is empty with digging each child's descendants
- Some handlers intentionally leave empty nodes so that they need to mark as it won't run.
Actually, it often appears in the profiles. However, this is difficult to do this because we need to look for every points which may create an empty node.
An empty node may appear when the all children or all data of a node is deleted or splitting an element at its start or end edge. That may be required to preserve the original node for new content or to move something after the split.
| Reporter | ||
Comment 1•5 months ago
|
||
I'm currently thinking that we can put an array to TopLevelEditSubActionData as mMaybeEmptyContent. When new empty nodes appear, that may be caused by:
- Splitting a node at its edge and the new empty node is not used
- All nodes in a container element are removed but nobody appended new content into it
- All data in a
Textis removed but nobody appended new data into it
So, we could manage the array with some small changes. Then, we can stop scanning the range in RemoveEmptyNodesIn() which appears in the benchmarks or heavy scenarios.
This approach allows the handles remove (or not append) a node from (to) the array to avoid to be removed.
However, this approach does not remove unnecessary nodes from the modified range which are not created by us. I'm not sure whether deleting such node is a good thing for web apps, though.
Comment 2•3 months ago
|
||
Description
•