Commit Graph
62 Commits
Author SHA1 Message Date
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
Tobias Hintze a9b7caaf97 insert some asserts against node===null in various places
(PositionIterator, SelectionMover, Document)
2013-02-04 20:39:05 +01:00
Jos van den Oever e4b8a83eac Fix the jumping cursor issue.
Counting of DOM positions was done with filtering, but the cursor requires no filtering.
2013-01-31 10:32:51 +01:00
Jos van den Oever bc3e2f9f08 Update to newer Closure Compiler. 2012-12-28 11:59:47 +01:00
Jos van den Oever b23fd669d3 Use dom offset when synchronizing with selection.
The DOM Selection uses 'normal' offset counting. This offset should be used when the PositionIterator is used to set the selection.
2012-11-16 17:24:39 +01:00
Jos van den Oever 8b0c05095b Update iterator position properly for inserting a cursor for another user in the same text node. 2012-11-15 11:24:56 +01:00
Jos van den Oever f3b0a0ebf4 Small clean-up of unused code. 2012-11-09 21:34:36 +01:00
Jos van den Oever 5dcdb449c3 Make sure that setPosition works even if there are neighboring Text nodes. 2012-11-09 18:01:43 +01:00
Jos van den Oever e966700c7a Implement getPositionInTextNode. 2012-10-22 15:01:46 +02:00
Jos van den Oever 669399f5f7 Handle the case when a position is set to the end of a text node. 2012-10-21 16:24:43 +02:00
Tobias Hintze 758333d210 update "@source:" references to gitorious.org/webodf
(as in master: de1a79c36f)
2012-10-21 12:18:15 +02:00
Jos van den Oever 236dd81f31 Work towards moving the avatar line up and line down.
For this to work, the checking of the position of the selection should be stricter. This patch refactors the way the PositionIterator is updated when the cursor is removed. The iterator is now updated in such a way that no not-yet-valid offset needs to be set.
2012-10-05 17:31:58 +02:00