Index: trunk/extensions/VisualEditor/demos/ce/main.js |
— | — | @@ -625,6 +625,8 @@ |
626 | 626 | documentModel.data.splice( 0, documentModel.data.length ); |
627 | 627 | ve.insertIntoArray( documentModel.data, 0, newDocumentModel.data ); |
628 | 628 | surfaceModel.select( new ve.Range( 1, 1 ) ); |
| 629 | + // FIXME: this should be using ve.batchedSplice(), otherwise things |
| 630 | + // could explode if newDocumentModel.getChildren() is very long |
629 | 631 | documentModel.splice.apply( |
630 | 632 | documentModel, |
631 | 633 | [0, documentModel.getChildren().length] |
Index: trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.DocumentSynchronizer.js |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | new ve.Range( offset, action.node.getElementLength() + action.adjustment ) |
88 | 88 | ) ); |
89 | 89 | parent = action.node.getParent(); |
90 | | - parent.splice.apply( parent, [parent.indexOf( action.node ), 1].concat( newNodes ) ); |
| 90 | + ve.batchedSplice( parent, parent.indexOf( action.node ), 1, newNodes ); |
91 | 91 | // Adjust proceeding offsets by the difference between the original and new nodes |
92 | 92 | var newNodesLength = 0; |
93 | 93 | for ( var j = 0, jlen = newNodes.length; j < jlen; j++ ) { |
Index: trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js |
— | — | @@ -138,15 +138,7 @@ |
139 | 139 | remove--; |
140 | 140 | } |
141 | 141 | } |
142 | | - // Try to perform this in a single operation if possible, this reduces the number of UI updates |
143 | | - // TODO: Introduce a global for max argument length - 1024 is also assumed in ve.insertIntoArray |
144 | | - if ( newNodes.length < 1024 ) { |
145 | | - parent.splice.apply( parent, [index, remove].concat( newNodes ) ); |
146 | | - } else if ( newNodes.length ) { |
147 | | - parent.splice.apply( parent, [index, remove] ); |
148 | | - // Safe to call with arbitrary length of newNodes |
149 | | - ve.insertIntoArray( parent, index, newNodes ); |
150 | | - } |
| 142 | + ve.batchedSplice( parent, index, remove, newNodes ); |
151 | 143 | }; |
152 | 144 | |
153 | 145 | /** |
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js |
— | — | @@ -467,6 +467,8 @@ |
468 | 468 | if( res.tokens ) { |
469 | 469 | // Splice in the returned tokens (while replacing the original |
470 | 470 | // token), and process them next. |
| 471 | + // FIXME: this should be using ve.batchedSplice(), otherwise things |
| 472 | + // could explode if res.tokens is very long |
471 | 473 | [].splice.apply( tokens, [i, 1].concat(res.tokens) ); |
472 | 474 | tokensLength = tokens.length; |
473 | 475 | i--; // continue at first inserted token |
— | — | @@ -662,6 +664,8 @@ |
663 | 665 | if( res.tokens ) { |
664 | 666 | // Splice in the returned tokens (while replacing the original |
665 | 667 | // token), and process them next. |
| 668 | + // FIXME: this should be using ve.batchedSplice(), otherwise things |
| 669 | + // could explode if res.tokens is very long |
666 | 670 | [].splice.apply( tokens, [i, 1].concat(res.tokens) ); |
667 | 671 | tokensLength = tokens.length; |
668 | 672 | i--; // continue at first inserted token |
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.js |
— | — | @@ -717,6 +717,8 @@ |
718 | 718 | documentModel.data.splice( 0, documentModel.data.length ); |
719 | 719 | ve.insertIntoArray( documentModel.data, 0, newDocumentModel.data ); |
720 | 720 | surfaceModel.select( new ve.Range( 1, 1 ) ); |
| 721 | + // FIXME: this should be using ve.batchedSplice(), otherwise things |
| 722 | + // could explode if newDocumentModel.getChildren() is very long |
721 | 723 | documentModel.splice.apply( |
722 | 724 | documentModel, |
723 | 725 | [0, documentModel.getChildren().length] |