[webkit-dev] Adding Persistent Position

Ryosuke Niwa rniwa at webkit.org
Thu Jun 23 14:43:00 PDT 2011


Hi,

I think we need a PersistentPosition that auto-corrects itself and survives
DOM mutations without being orphaned; similar to how Range is automatically
updated.

Why?

   1. ReplaceSelectionCommand and DeleteSelectionCommand have wrapper for
   removeNode, deleteTextFromNode, etc... to update Positions they maintain.
   2. InsertListCommand and IndentOutdentCommand crash all the time because
   Position get lost in moveParagraph, etc...
   3. FrameSelection has a special function that gets called whenever Node
   is removed to update its end points but VisibleSelection doesn't so
   endingSelection() becomes stale very easily compared to FrameSelection.


On the other hand, adding this new class and instantiating them as member
variables of subclasses of CompositeEditCommand may impact performance
because CompositeEditCommand stays on the memory even after it's pushed into
undo stack.  Also, maintaining a pointer (probably from Document) to stack
object (although member variables of CompositeEditCommand will end up living
in heap) seems like a dangerous design although we could make it ref-counted
as well.

To address the performance impact, we can modify CompositeEditCommand so
that it won't be added to the undo stack.  Instead, CompositeEditCommand
will create an EditCommandComposition that stores a tree of
SimpleEditCommands that inherits from EditCommand and will be added to the
undo stack.

Any thoughts?

Best,
Ryosuke Niwa
Software Engineer
Google Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20110623/27239165/attachment.html>


More information about the webkit-dev mailing list