* remove @license tag (to prevent Closure compiler keeping the comment)
* use copyright@kogmbh.com email address everywhere
* remove "additional permission", to be added only to released webodf.js
* separate license header by empty line from following content
Allowing the same bookmark to appear multiple times in this particular cache
causes major headaches when the bookmark is updated, as EACH step-to-DOM (s2D)
entry pointing to the bookmark would also need to be updated.
As there is no real performance benefit from having the same bookmark
appear multiple times, life is made significantly simpler by only allowing
the bookmark to appear a maximum of once in the s2D cache.
It is valid for multiple bookmarks to share the same step number if
the user of the steps cache does not have a perfectly granular position
filter.
For example, paragraphs within a tracked changes block are not valid
steps according to the TextPositionFilter. This means all these
paragraphs stack up on the same step.
Whenever any iteration occurs, the cache needs to be updated so damage
can be repaired. This particular change fixes an issue where restoring
from the root bookmark ends up iterating up to the first damaged
paragraph bookmark, which should cause the paragraph bookmark to be
repaired.
This requires consumers to be able to mark ALL current bookmarks as
damaged, which is now achieved by passing in "-1" as the inflection
step to the damageCacheAfter(…) call.
Fixing this bug has exposed another existing issue that potentially
re-orders bookmarks that share the same step. This uncovered problem
will be addressed in a subsequent commit.
Fixes the cache corruption aspect of issue #503
Converting the cache to a damage-based approach improves the per-update
efficiency immensely, but carries some additional risk as invalid
bookmarks are deliberately left behind for performance reasons.
This patch specifically fixes an issue where bookmarks between the
undamaged step and the current iterator position were being treated as
repaired bookmarks, when in fact they were still damaged (as they had
never been seen during iteration in the document). The new logic will
ensure these bookmarks stay in the damaged region until they are
eventually iterated over in an updateCache call.
A happy side effect of this is that all query functions now only ever
return undamaged bookmarks, making the class itself easier to use and
understand.
Calculating exact changes in a document can be extremely difficult to
do properly, as such, StepsCache ideally will not rely on them.
In this new approach, modifications to the step cache only require the
last known unmodified step. As iteration across the document occurs,
damaged regions of the cache are repaired and updated, and dead nodes
are removed from the system.
This improves the performance of local edits immensely, at the expense
of "long jump" type operations (e.g., add text then move immediately
to the document end).
Fixes issue #417
The StepsCache is built on the concept that nodes are not re-ordered in
the document during updates. This means the only operations that need to
be supported is adding or removing a node. By maintaining a double
linked list, nearby bookmarks can be very quickly found for any step.