mediawiki-extensions-Visual.../modules/ve/test
Roan Kattouw 6772f92e70 Get rid of 'reversed' flag on transactions
The way we implemented undoing transactions was horrible. We'd process
the original transaction, but with a reversed=true flag. That meant we
had to keep track of the 'reversed' flag everywhere, and use ternaries
like insert = reversed ? op.remove : op.insert; all over the place to
access transaction operations. Redo then worked by reapplying the
transaction. We would verify that this was OK by tracking whether the
transaction was in an applied state or an undone state.

This commit makes it so every transaction can only be applied once. To
undo, you obtain a mirror image of the transaction with tx.reverse(),
then apply that. To redo, you clone the original transaction with
tx.clone() and apply that. All the code that had to use ternaries to
check whether the transaction was being applied in reverse or not is
gone now, because you can only apply a given transaction forwards,
never in reverse.

Bonus:
* Make ve.dm.Document's .completeHistory a simple array of
  transactions, rather than transaction/boolean pairs
* In the protection of double application test, clone the example
  document properly; it modified ve.dm.example.data, which was "fine"
  because it ran .commit() and .rollback() the same number of times

Change-Id: I3050c5430be4a12510f22e20853560b92acebb67
2013-10-02 19:37:08 -07:00
..
ce Add more tests for ve.ce.Surface#onContentChange 2013-09-27 11:55:43 +01:00
dm Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00
init ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ui Move repeated code for creating a test ve.ui.Surface in utils 2013-09-27 11:53:51 +01:00
example.png Optimise png images with optipng 2013-07-05 09:47:12 +00:00
index.php Tests for handleDelete in ve.ce.Surface 2013-09-24 15:32:37 +00:00
ve.BranchNode.test.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.Document.test.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.Element.test.js Make local overlays local to surface and remove insane z-indexes 2013-07-02 19:35:43 +00:00
ve.Factory.test.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.LeafNode.test.js Use static.name once for ce and dm nodes 2013-03-07 17:19:39 -08:00
ve.Node.test.js Store DM nodes in InternalList 2013-06-03 22:10:07 +01:00
ve.qunit.js Include element HTML in QUnit summary for diff 2013-08-02 16:10:05 +01:00
ve.Range.test.js Fix copy and paste of backwards selction 2013-08-22 18:10:34 +00:00
ve.test.js Don't emit Surface changes back to the Surface 2013-08-21 17:26:32 +00:00
ve.test.utils.js Move repeated code for creating a test ve.ui.Surface in utils 2013-09-27 11:53:51 +01:00