Index: trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.DocumentSynchronizer.js |
— | — | @@ -46,13 +46,12 @@ |
47 | 47 | ve.dm.DocumentSynchronizer.prototype.synchronize = function() { |
48 | 48 | // TODO: Normalize the actions list to clean up nested actions |
49 | 49 | // Perform all actions |
50 | | - var adjustment = 0, |
51 | | - action, |
| 50 | + var action, |
52 | 51 | offset, |
53 | 52 | parent; |
54 | 53 | for ( var i = 0, len = this.actions.length; i < len; i++ ) { |
55 | 54 | action = this.actions[i]; |
56 | | - offset = action.offset === null ? null : ( action.offset + adjustment ); |
| 55 | + offset = action.offset; |
57 | 56 | switch ( action.type ) { |
58 | 57 | case 'insert': |
59 | 58 | // Compute the offset if it wasn't provided |
— | — | @@ -72,15 +71,11 @@ |
73 | 72 | parent = target.getParent(); |
74 | 73 | parent.splice( parent.indexOf( target ), 0, action.node ); |
75 | 74 | } |
76 | | - // Adjust proceeding offsets positively by the length of the node being inserted |
77 | | - adjustment += action.node.getElementLength(); |
78 | 75 | break; |
79 | 76 | case 'delete': |
80 | 77 | // Replace original node with new node |
81 | 78 | parent = action.node.getParent(); |
82 | 79 | parent.splice( parent.indexOf( action.node ), 1 ); |
83 | | - // Adjust proceeding offsets negatively by the length of the node being deleted |
84 | | - adjustment -= action.node.getElementLength(); |
85 | 80 | break; |
86 | 81 | case 'rebuild': |
87 | 82 | // Compute the offset if it wasn't provided |
— | — | @@ -93,18 +88,10 @@ |
94 | 89 | ) ); |
95 | 90 | parent = action.node.getParent(); |
96 | 91 | ve.batchedSplice( parent, parent.indexOf( action.node ), 1, newNodes ); |
97 | | - // Adjust proceeding offsets by the difference between the original and new nodes |
98 | | - var newNodesLength = 0; |
99 | | - for ( var j = 0, jlen = newNodes.length; j < jlen; j++ ) { |
100 | | - newNodesLength += newNodes[j].getElementLength(); |
101 | | - } |
102 | | - adjustment += newNodesLength - action.node.getElementLength(); |
103 | 92 | break; |
104 | 93 | case 'resize': |
105 | 94 | // Adjust node length - causes update events to be emitted |
106 | 95 | action.node.adjustContentLength( action.adjustment ); |
107 | | - // Adjust proceeding offsets by the amount the node is being lengthened or shortened |
108 | | - adjustment += action.adjustment; |
109 | 96 | break; |
110 | 97 | case 'update': |
111 | 98 | // Emit update events |