70 Commits
Author SHA1 Message Date
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
Jos van den Oever ed7270442f Remove loadClass calls from class files. The load system reads the dependencies from the manifest.json files now. 2014-02-07 15:38:09 +01:00
Friedrich W. H. Kossebau d2671e2a00 @returns -> @return 2014-01-31 15:33:43 +01:00
Jos van den Oever 3c96e17009 Make sure the cursor always has a Range. 2013-11-26 16:56:01 +01:00
Jos van den Oever cb406f1c16 A number for Cursor related type annotations. 2013-11-26 16:55:59 +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 d5e46b083b Ensure Node.insertBefore is called with null, not undefined (IE compatibility) 2013-11-19 20:25:17 +11:00
Philip Peitsch 79efc63ac2 Small cleanup to cursor insertion logic
Don't need to walk through each sibling to find the correct offset.
2013-11-14 20:28:30 +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
Aditya Bhatt 05d8d6ce29 * Make hand-drawn selections have proper direction.
* All cursor classes gain hasForwardSelection() methods.
* maintainCursorSelection now preserves selection direction.
2013-10-15 11:47:42 +02:00
Philip Peitsch 36f502ede2 Fix shift+click selection extension for reverse selections (FF and older Chrome)
The selection direction was being lost when the window's current selection
was resynchronised to the cursor selection. For firefox and some versions
of Chrome, this would cause selection extension behaviours (shift+click)
to work incorrectly when attempting to extend the selection to the left
of the caret.
2013-10-15 09:29:23 +02:00
Jos van den Oever 64d57c96cf Fix issues exposed by latest JSLint. 2013-07-24 21:41:56 +02:00
Philip Peitsch 2af09cc034 Refactored out common DOM utility methods 2013-07-15 09:40:50 +02:00
Philip Peitsch c810c764cb Prevent the cursor from incorrectly collapsing during DOM mods 2013-07-02 21:19:36 +02:00
Philip Peitsch f4352a27ec Removed duplicate behaviour
Logic in Cursor is no longer necessary with improved
PositionIterator.setUnfilteredPosition logic.
2013-06-21 16:56:56 +02:00
Philip Peitsch 135c8affc9 Support range selection in edit mode
Works similarly to the existing cursor. A node is
placed in for the start and end positions of a cursor.

The window selection is updated based on cursor moved events.
The selection sync logic really belongs in SessionView. However,
as only a single selection is supported in the current
implementation, this has been temporarily put into SessionController.

A new function OdtDocument.getCursorSelection has been added
to make it trivial to support range-selection operations.

* Move responsibility for setting the memberId into Cursor to
  allow proper hiding of anchor node
2013-06-20 02:26:29 +10:00
Philip Peitsch 0209521db4 Removed unnecessary position adaptions 2013-06-19 13:43:46 +02:00
Philip Peitsch 4ab30523c0 Modified cursor movement to remove the need to adapt position iterators 2013-06-19 13:43:46 +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 eca37e6771 Modified Cursor api to allow the selection to be specified directly
This provides better encapsulation and clarifies the usage slightly.
Hopefully, it will decrease the ways to cause the selection & actual
cursor position can get out of sync.

As this was the only use of the Selection stack, the whole class is
now removed
2013-06-12 16:30:48 +10:00
Aditya Bhatt 7c16ef8bac code restructuring. 2013-05-13 10:18:11 +00:00
Aditya Bhatt cd2acd5f26 Set textNodeIncrease to prev.length in removeCursor even when next is
null/not a text node.
2013-05-13 10:18:10 +00:00
Aditya Bhatt 60fe6497aa Less textNode creation and faster text insertion. 2013-05-13 10:18:10 +00:00
Aditya Bhatt b92389c98d * Stop using cursorTextNode, and use the simplest way to delete and
split textNodes for a cursor.
* Delete any empty text nodes that are created and unused during
insertion.
2013-05-13 10:18:10 +00:00
Aditya Bhatt 8d57a04c8e Insert text:s elements instead of spaces in OpInsertText.
Also make the cursor behave properly around such elements.
2013-05-13 10:18:10 +00:00
Aditya Bhatt b1ab50d7da Do not avoid empty text nodes in Cursor::getPositionInContainer 2013-05-13 10:17:30 +00:00
Friedrich W. H. Kossebau e243502bfa In core.Cursor.getPositionInContainer() deal with empty text nodes to the left of the cursor
e.g. fixes cursor mis-placement on double press of Home button
2013-04-26 12:37:39 +02:00
Tobias Hintze ab60ca51c7 add and fixup some asserts 2013-04-25 09:10:50 +02:00
Aditya Bhatt be6b911440 fix closure error 2013-04-24 22:48:53 +05:30
Aditya Bhatt 32fa7ab768 comments and jsdoc 2013-04-24 20:33:25 +05:30
Aditya Bhatt 7a41e83b10 Call removeCursor only when the cursor isn't already removed, in
Cursor:updateToSelection
2013-04-24 20:28:25 +05:30
Aditya Bhatt ef492dcefb Make closure stop complaining 2013-04-24 16:13:13 +05:30
Aditya Bhatt a264d41f6c Merge two nested ifs and elses 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 39dc0f6ef3 Make jslint happy 2013-04-24 16:07:41 +05:30
Aditya Bhatt c769bedcbe Make Cursor::removeCursor also work when there is no next sibling. 2013-04-24 16:07:41 +05:30
Aditya Bhatt 624f555c5a If the cursorNode is at a right extremity between a splitted textNode,
then we need to make sure not to delete cursorTextNode during
removeCursor! Otherwise the entire text content to the left of the
cursor will be deleted. Instead, clone the cursorTextNode and insert it
before the cursor position to preserve the DOM structure.
2013-04-24 16:07:41 +05:30
Aditya Bhatt 468f5490b1 A method to retrieve the cursor position using it's node's DOM location,
as a container + offset pair. Use this position for
iterator.setPosition() every time SelectionMover uses it for some
distance calculation. This fixes the problem where after a removeText
operation a textNode would be removed from the DOM and therefore
container.parentNode would be null, thus breaking movement.
2013-04-24 16:07:41 +05:30
Tobias Hintze f2023c9b8f add more runtime.assert calls 2013-04-22 12:05:54 +02:00
Aditya Bhatt 9e2582aa0d Initialize the cursorTextNode with "" if the putCursorIntoTextNode
offset is zero.
2013-04-03 18:55:25 +05:30
Friedrich W. H. Kossebau 6a568a8f58 Split ops.OdtCursor from core.Cursor & rename ops.Document to ops.OdtDocument
Also:
* rename gui.CaretTests to ops.OdtCursorTests (as it is testing ops.OdtCursor)
* remove test-less CaretTests.js, had broken setup now
2013-03-06 15:44:28 +01:00
Jos van den Oever f0022cf3ca More documentation and types. 2013-02-06 18:10:18 +01:00
Jos van den Oever b481485ad0 Revert patch that removed cursorTextNode.
The cursorTextNode is essential to how the cursor works. It contains the front
half of the text node in which the cursor resides.
2013-02-04 18:54:02 +01:00
Aditya Bhatt 1db72bf0e7 Add asserts and watchdogs 2013-01-29 13:26:25 +05:30
Friedrich W. H. Kossebau b201db9f19 Remove cursorTextNode variable from Cursor
seems no longer needed to keep a pointer to the text section before the cursor

concept would also need complicated treatment on paragraph splitting
2012-12-28 12:29:45 +01:00
Jos van den Oever 0aa78fde82 Potential fix for cursor placement issues.
A next patch will add more tests, but cursory testing already shows better behavior. The fix consists of more explicit communication with handlers about whether and how much the affected text node changes.
2012-11-15 18:21:05 +01:00
Friedrich W. H. Kossebau a058242e6b Split ops.Document from ops.Session (initial step)
Idea here is to create abstraction as much as possible for all ODF-related
objects, e.g. the cursor objects now belong to and know the ODF document model
they run around in.

Some avatar tests still need fixing/adaption, but from manually testing it
looks good, so commiting now to prevent too much differences.
2012-11-09 12:19:08 +01:00