mediawiki-extensions-Visual.../modules/ve/dm
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
..
annotations LanguageAnnotation Touchup 2013-09-23 11:41:34 -07:00
lineardata docs: Minor improvements 2013-09-05 23:56:59 +00:00
metaitems ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
nodes Add alt attribute to core image nodes 2013-09-07 12:56:17 -07:00
ve.dm.Annotation.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.AnnotationFactory.js Convert AnnotationFactory and MetaItemFactory to NamedClassFactories 2013-04-09 12:05:05 -07:00
ve.dm.AnnotationSet.js Speed up openAndCloseAnnotations by using store indexes 2013-07-26 18:11:01 -07:00
ve.dm.BranchNode.js Store DM nodes in InternalList 2013-06-03 22:10:07 +01:00
ve.dm.Converter.js Fix exception thrown by converter when data ends in text 2013-09-20 18:26:14 +00:00
ve.dm.DataString.js Code style fixes 2013-05-06 12:36:52 +01:00
ve.dm.Document.js Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00
ve.dm.DocumentSlice.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.DocumentSynchronizer.js doc: Clean up spacing that caused <pre> or broken <ul>/<ol> 2013-07-25 04:02:50 +02:00
ve.dm.IndexValueStore.js ve.copy: Remove obsolete copyArray and copyObject 2013-07-30 01:44:22 +02:00
ve.dm.InternalList.js Merge "Introduce newFromDocumentReplace() transaction builder" 2013-09-26 20:45:54 +00:00
ve.dm.js Bump copyright notice year range to -2013 over -2012 2013-02-19 15:37:34 -08:00
ve.dm.LeafNode.js Store data in LinearData class with an index-value store for objects 2013-03-30 10:06:34 +00:00
ve.dm.LinearData.js docs: Minor improvements 2013-09-05 23:56:59 +00:00
ve.dm.MetaItem.js Rewrite MetaList.onTransact 2013-09-11 15:29:28 -07:00
ve.dm.MetaItemFactory.js Make .static.storeHtmlAttributes more versatile 2013-05-07 14:45:26 -07:00
ve.dm.MetaList.js Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00
ve.dm.Model.js Add .static.getMatchRdfaTypes() wrapper 2013-08-07 17:39:24 +08:00
ve.dm.ModelRegistry.js Fix deprioritization of regex matches in ModelRegistry 2013-08-08 02:52:45 +00:00
ve.dm.Node.js Node annotation blacklists 2013-09-19 19:09:25 +01:00
ve.dm.NodeFactory.js Node annotation blacklists 2013-09-19 19:09:25 +01:00
ve.dm.Surface.js Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00
ve.dm.SurfaceFragment.js Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00
ve.dm.Transaction.js Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00
ve.dm.TransactionProcessor.js Get rid of 'reversed' flag on transactions 2013-10-02 19:37:08 -07:00