73 Commits
Author SHA1 Message Date
Jos van den Oever b8ad5b3889 Upgrade to Closure Compiler 20150505.
We are now using our own copy of the externs to deal with differences
of opinion on best typing of types.
2015-06-01 08:53:35 +02:00
Philip Peitsch ad14efa800 Fix PositionIteration bug when first position is a rejected text node 2014-09-12 09:21:22 +10:00
Philip Peitsch e8ea129623 Fix setUnfilteredPosition to escape child text nodes of rejected parents
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
2014-09-08 10:01:53 +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 06bf81c8c7 Start iteration after highest rejected parent in PositionIterator
New logic will move to the next accepted node after the highest
rejected parent rather than the lowest rejected parent.
2014-02-20 21:25:45 +11:00
Philip Peitsch 36f3e4f89f Avoid slow calls when updating StepsTranslator cache
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.
2014-02-20 21:24:41 +11:00
Friedrich W. H. Kossebau d2671e2a00 @returns -> @return 2014-01-31 15:33:43 +01:00
Friedrich W. H. Kossebau 6d099688fb Use NodeFilter.SHOW_ALL instead of value constant everywhere 2014-01-16 15:56:08 +01:00
Jos van den Oever 83982c5059 More type fixes.
This patch also contains quite some cleanups and reorganization in runtime.js.
2013-11-22 18:32:20 +01:00
Jos van den Oever 9521e7c2de Revert CC for now. 2013-11-22 18:32:20 +01:00
Jos van den Oever 29b04dbbd3 Update Closure compiler and more typechecking.
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.
2013-11-22 18:32:20 +01:00
Philip Peitsch 8bf0740bc3 Don't use text nodes as tree-walker roots (IE compatibility)
IE10 will throw an exception if the root passed
into a tree walker is a text node.
2013-11-19 20:25:17 +11:00
Philip Peitsch 35b7096697 Use local variables for commonly accessed globals
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
2013-11-18 23:41:16 +11:00
Jos van den Oever 8e35d5f002 Add more documentation to PositionIterator. 2013-11-18 09:43:17 +01:00
Jos van den Oever d4607cf63c Add documentation to PositionIterator. 2013-11-18 01:13:02 +01:00
Philip Peitsch f28151e4c2 Find a nearby known cached point when requested DOM point is outside any cached areas 2013-11-14 20:28:34 +11:00
Friedrich W. H. Kossebau c2a795e668 Update link to repo: now https://github.com/kogmbh/WebODF/ 2013-10-23 18:20:30 +02:00
Friedrich W. H. Kossebau 508570dab8 Add copy of the AGPL3 to sources (+ add to created zip files) 2013-10-21 17:55:16 +02:00
Philip Peitsch 4ba4eaf312 Ensure PositionIterator.setUnfilteredPosition has round-trip stability
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.
2013-10-08 01:30:32 +11:00
Philip Peitsch 0727acf238 Jump to next valid position when setUnfilteredPosition is passed a child of an invalid parent
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.
2013-09-24 18:10:31 +10:00
Philip Peitsch 4f1349afdb Remove PositionIterator.domOffset
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.
2013-09-20 00:15:53 +10:00
Philip Peitsch c0133c249a Removed unsafe position iterator functions. Moved into only test class referencing these 2013-07-24 09:58:33 +02:00
Philip Peitsch f7cd9fe437 Allow position iterator to complete even if root is never reached 2013-07-15 09:40:50 +02:00
Philip Peitsch 402ae2a023 Removed PositionIterator.setPosition
PositionIterator.setPosition has been superseded by the unfiltered
variant for all use cases.
2013-07-03 21:52:40 +10:00
Philip Peitsch 84e79a983a Fix case where setUnfilteredPosition is passed an offset to a non-visible child
PositionIterator.setUnfilteredPosition must always set the current node to a
visible node.
2013-07-03 21:40:12 +10:00
Friedrich W. H. Kossebau 09b5d43f97 let's use NodeFilter.XXX constants instead of magic values 2013-07-02 22:31:02 +02:00
Philip Peitsch 4e0f4a0df4 Removed PositionIterator.offset and all references
PositionIterator exposes a myriad of confusing offsets. These are being
slowly retired where possible in an effort to reduce possible mis-use
and confusion.
2013-07-02 21:31:29 +02:00
Friedrich W. H. Kossebau 8df04919fc Fix warning message: in PositionIterator.setUnfilteredPosition, not setPosition 2013-06-27 18:36:20 +02:00
Jos van den Oever 7381592256 Fix compilation and make types a bit stricter. 2013-06-21 16:56:56 +02:00
Jos van den Oever 3634d63e3b Compile fix. 2013-06-19 17:08:52 +02:00
Philip Peitsch ea8c135546 PositionIterator.setUnfilteredPosition automatically advances to the next valid position
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
2013-06-19 16:58:13 +02:00
Friedrich W. H. Kossebau 55fc7ab9c6 Switch code to use Node.${XXX}_NODE instead of magic values 2013-06-17 13:49:07 +02:00
Philip Peitsch d7360bab22 getAppliedStyles returns unique computed styles for all text nodes within a given range
This is useful for determining whether all text within a given selection is bold or italic, or
has a uniform size or font name.
2013-06-14 18:16:15 +10:00
Jos van den Oever e76ecd15d0 Add a few comments to clarify the new function. 2013-06-12 11:17:43 +02:00
Philip Peitsch ff4033be4b OdtDocument.getDistanceFromCursor expects filtered offsets
* Fixed api comments incorrectly claiming unfiltered offsets
2013-06-12 11:00:01 +02:00
Jos van den Oever a3b311060a Add failing test and make leftNode and rightNode return only filtered nodes. 2013-05-08 18:38:01 +02:00
Jos van den Oever 6cf5bbef1e Insert a new text node at the correct position.
A new PositionIterator function is needed for this: rightNode. For completeness sake, leftNode() is also introduced.
2013-05-06 11:39:48 +02:00
Friedrich W. H. Kossebau bd07b2c8a9 Support END key, by going to end of paragraph for now 2013-05-03 19:12:38 +02:00
Friedrich W. H. Kossebau 84c4ba7813 Fix broken calculation in SelectionMover's countStepsToPosition() (ignored that comparePoints() used unfiltered offsets) 2013-05-03 19:12:28 +02:00
Aditya Bhatt 2869ffa4bf Make positions in the beginning of a container but right before a span
unwalkable.
Additionally, make the offset=0 in spans that have no allowable siblings
to the left walkable.
2013-04-25 09:11:38 +02:00
Tobias Hintze ab60ca51c7 add and fixup some asserts 2013-04-25 09:10:50 +02:00
Aditya Bhatt ef492dcefb Make closure stop complaining 2013-04-24 16:13:13 +05:30
Aditya Bhatt a1e7644aad jsdoc 2013-04-24 16:13:13 +05:30
Aditya Bhatt c9f9a5d2c2 When calculating the offset in Cursor::getPositionInContainer, if it is
not in a text node, then use the nodefilter to make unwanted nodes not
count towards the offset
2013-04-24 16:13:13 +05:30
Aditya Bhatt 4c80c84e4e Rewritten OpRemoveText, using the new and awesome getTextNeighborhood
method, which can delete text across serveral nodes.
2013-04-24 16:07:41 +05:30
Aditya Bhatt e68ed4ee27 Rename nextPosition and previousPosition methods in Position Iterator
to get() versions, and add a method to OdtDocument to get a position
iterator at a desired position value
2013-04-24 16:07:40 +05:30
Aditya Bhatt c2c9106cd7 a getNeighborhood method for PositionIterator, which gives an array of
textNodes (which was 1 textNode, but splitted for some reason like
having a cursor)
2013-04-24 16:07:40 +05:30
Aditya Bhatt b8b2418d5a Some convenience retriever methods - previousSibling(), nextSibling(), and
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.
2013-04-24 16:07:40 +05:30
Tobias Hintze 377f925a66 PositionIterator: more assert 2013-04-22 14:10:56 +02:00
Tobias Hintze e96ebc7128 PositionIterator: more asserts 2013-04-22 12:36:39 +02:00