Merge "Avoid rendering content of ve.ce.ContentBranchNode multiple times when only one transaction is applied"

This commit is contained in:
jenkins-bot 2013-04-18 18:58:42 +00:00 committed by Gerrit Code Review
commit 1bfc9594b3
4 changed files with 15 additions and 6 deletions

View file

@ -28,8 +28,8 @@ ve.ce.BranchNode = function VeCeBranchNode( model, $element ) {
// Properties
this.domWrapperElementType = this.$.get( 0 ).nodeName.toLowerCase();
this.slugs = { };
this.emitChildUpdate = ve.bind( function () {
this.emit( 'childUpdate' );
this.emitChildUpdate = ve.bind( function ( transaction ) {
this.emit( 'childUpdate', transaction );
}, this );
// Events

View file

@ -20,8 +20,16 @@ ve.ce.ContentBranchNode = function VeCeContentBranchNode( model, $element ) {
// Parent constructor
ve.ce.BranchNode.call( this, model, $element );
// Properties
var lastTransaction;
// Events
this.addListenerMethod( this, 'childUpdate', 'renderContents' );
this.on( 'childUpdate', ve.bind( function( transaction ) {
if ( lastTransaction !== transaction ) {
lastTransaction = transaction;
this.renderContents();
}
}, this ) );
// Initialization
this.renderContents();

View file

@ -21,12 +21,13 @@
* @constructor
* @param {ve.dm.Document} doc Document to synchronize
*/
ve.dm.DocumentSynchronizer = function VeDmDocumentSynchronizer( doc ) {
ve.dm.DocumentSynchronizer = function VeDmDocumentSynchronizer( doc, transaction ) {
// Properties
this.document = doc;
this.actionQueue = [];
this.eventQueue = [];
this.adjustment = 0;
this.transaction = transaction;
};
/* Static Properties */
@ -255,7 +256,7 @@ ve.dm.DocumentSynchronizer.prototype.queueEvent = function ( node ) {
node.queuedEventHashes[hash] = true;
this.eventQueue.push( {
'node': node,
'args': args
'args': args.concat( this.transaction )
} );
}
};

View file

@ -24,7 +24,7 @@ ve.dm.TransactionProcessor = function VeDmTransactionProcessor( doc, transaction
this.document = doc;
this.transaction = transaction;
this.operations = transaction.getOperations();
this.synchronizer = new ve.dm.DocumentSynchronizer( doc );
this.synchronizer = new ve.dm.DocumentSynchronizer( doc, transaction );
this.reversed = reversed;
// Linear model offset that we're currently at. Operations in the transaction are ordered, so
// the cursor only ever moves forward.