18 Commits
Author SHA1 Message Date
Friedrich W. H. Kossebau 68cc8025f6 Allow to control verifyCache behaviour of existing ops.StepsCache instances 2015-06-07 13:16:34 +02:00
Philip Peitsch 97bc84d27f Enable StepsCache verification 2015-06-01 18:00:12 +02:00
Philip Peitsch 3172ad8dec Convert core.DomUtils into a static singleton 2014-09-12 10:17:09 +10:00
Friedrich W. H. Kossebau 1e2a4a8323 Normalize license headers of the webodf.js source files
* 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
2014-06-02 12:19:05 +02:00
Philip Peitsch e5b052c438 Ensure each bookmark is only present ONCE in the step-to-DOM point cache
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.
2014-05-19 23:23:59 +10:00
Philip Peitsch 8ba76d4dd6 Add additional asserts to verify cache integrity
Add asserts to detect cache corruption of the nature experienced here.
These more stringent checks have caused an additional operation test to
fail.
2014-05-19 23:23:58 +10:00
Friedrich W. H. Kossebau 90bdd8ed0e Fix StepsCache's getNodeId() to always return a string 2014-04-29 17:01:44 +02:00
Philip Peitsch 8bb0072b09 Add StepCache support for multiple bookmarks with the same step number
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.
2014-04-09 17:05:32 +10:00
Philip Peitsch 6766a96de3 Update the StepsCache when restoring a bookmarked position
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
2014-04-09 17:05:32 +10:00
Philip Peitsch acef143923 Move ODT-specific logic out of StepsCache into the steps translator
This is purely a refactor laying the groundwork for fixing the failing
operations tests. There are no expected functional impacts.
2014-04-09 17:05:32 +10:00
Philip Peitsch 120dc48cc3 Clarified some comments based on PR feedback 2014-03-01 00:59:02 +11:00
Philip Peitsch 451663110e Modify the damageCacheAfterStep to cope with negative values
If a negative value is passed in as the inflection point to the cache,
it is treated as if it were 0 and the cache is effectively cleared.
2014-03-01 00:59:02 +11:00
Philip Peitsch 93fe54aee7 Ensure damaged bookmarks are never leaked outside of the cache
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.
2014-03-01 00:59:02 +11:00
Philip Peitsch a25b70ad9e Add a cache verification function to ensure cache integrity
Cache integrity checks are very slow, so this should only be enabled
when troubleshooting cache problems.
2014-02-28 21:19:49 +11:00
Philip Peitsch 388e4acd89 Rework how StepsCache responds to step updates to improve robustness
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
2014-02-28 21:19:49 +11:00
Philip Peitsch 20afe0e263 Fix cache-update issue that was causing watchdog overflow errors 2014-02-28 21:19:49 +11:00
Philip Peitsch 5b35bdf412 Improve navigation speed across StepCache items
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.
2014-02-28 21:19:49 +11:00
Philip Peitsch b1b48d5fa4 Split StepsCache out of StepsTranslator into it's own file 2014-02-28 21:19:49 +11:00