mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 03:08:42 +00:00
Merge "Avoid rendering content of ve.ce.ContentBranchNode multiple times when only one transaction is applied"
This commit is contained in:
commit
1bfc9594b3
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 )
|
||||
} );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue