setUnfilteredPosition was incorrectly leaving the walker's currentNode
inside a rejected parent if the target node was a TEXT_NODE. Adjusted
branching logic to ensure the walker always moves to a valid position
if the specified position is not accepted by the current filters.
Fixes#797
* 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
unfilteredDomOffset is extremely slow under certain conditions, greatly
limiting the iteration speed. This patch eliminates all calls that would
trigger this slow call, improving iteration performance.
An additional advantage of this is that the adjusted logic now avoids
the somewhat messy logic that involved diving into the the container
and offset just in case the container's child was a paragraph as
well. By using isBeforeNode, the bookmark creator now knows that
the current node is fetched by getCurrentNode.
The type Runtime.ByteArray is removed. Uint8Array is used instead.
The more rigorous type checking is enabled by the flag --jscomp_error reportUnknownTypes.
To compile with this flag, build the target typecheck-target.
On Chrome & WebKit based browsers, looking up constants on
the Node and NodeFilter classes are extremely expensive. To
avoid this, these are cached for local use in places that have
very large, tight loops.
* Don’t ask for currentNode multiple times when possible
Calling setUnfilteredPosition with a result previously obtained from the
iterator should effectively resume iteration at exactly this position.
As added tests demonstrated, specifying a node with no children and an
offset of 0 was incorrectly causing currentPos to be restored to the value
of 0. This meant calls to iterator.container() would return the a different
value.
PositionIterator.setUnfilteredPosition API doc report that when given
a forbidden position, the iterator jumps to the next visible position.
Add code to cover a missed corner case if the container was a child of
a forbidden parent (or grand parent) node.
The last use of this function was in OdtDocument.getPositionInTextNode.
However, as can be clearly seen in line 325, iterator.domOffset is only
ever called on a TEXT_NODE (if condition, line 323). Examining
PositionIterator, this guarantees identical behaviour as
unfilteredDomOffset.
PositionIterator exposes a myriad of confusing offsets. These are being
slowly retired where possible in an effort to reduce possible mis-use
and confusion.
This makes the result of next & previous always a node that will pass
the filter. Previous implementations could return entirely unexpected
nodes
* Corrected module load order for tests
text() for positionIterator, for when we need more information about a
position's surroundings. Use these methods in getPositionInTextNode and
in the TextPositionFilter in OdtDocument to have (as far as I have
tested) smooth movement across spans and text nodes within a paragraph.
Also, text is now inserted near the cursor position instead of at a
paragraph's extremities. Text removal offsets are broken after this.