Inez has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/59655


Change subject: Avoid rendering content of ve.ce.ContentBranchNode multiple 
times when only one transaction is applied
......................................................................

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

Change-Id: I940bb96b670afb7ab3de524919b56912d027a2ef
---
M modules/ve/ce/ve.ce.BranchNode.js
M modules/ve/ce/ve.ce.ContentBranchNode.js
M modules/ve/dm/ve.dm.DocumentSynchronizer.js
M modules/ve/dm/ve.dm.TransactionProcessor.js
4 files changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/55/59655/1

diff --git a/modules/ve/ce/ve.ce.BranchNode.js 
b/modules/ve/ce/ve.ce.BranchNode.js
index 203771c..61cd2df 100644
--- a/modules/ve/ce/ve.ce.BranchNode.js
+++ b/modules/ve/ce/ve.ce.BranchNode.js
@@ -28,8 +28,8 @@
        // 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
diff --git a/modules/ve/ce/ve.ce.ContentBranchNode.js 
b/modules/ve/ce/ve.ce.ContentBranchNode.js
index 8c589a7..674f825 100644
--- a/modules/ve/ce/ve.ce.ContentBranchNode.js
+++ b/modules/ve/ce/ve.ce.ContentBranchNode.js
@@ -20,8 +20,16 @@
        // 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();
diff --git a/modules/ve/dm/ve.dm.DocumentSynchronizer.js 
b/modules/ve/dm/ve.dm.DocumentSynchronizer.js
index 6f2619c..9bec286 100644
--- a/modules/ve/dm/ve.dm.DocumentSynchronizer.js
+++ b/modules/ve/dm/ve.dm.DocumentSynchronizer.js
@@ -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 */
@@ -62,7 +63,7 @@
                // No tree synchronization needed
                // Queue events
                this.queueEvent( selection[i].node, 'annotation' );
-               this.queueEvent( selection[i].node, 'update' );
+               this.queueEvent( selection[i].node, 'update', this.transaction 
);
        }
 };
 
diff --git a/modules/ve/dm/ve.dm.TransactionProcessor.js 
b/modules/ve/dm/ve.dm.TransactionProcessor.js
index 5c66493..01af036 100644
--- a/modules/ve/dm/ve.dm.TransactionProcessor.js
+++ b/modules/ve/dm/ve.dm.TransactionProcessor.js
@@ -24,7 +24,7 @@
        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.

-- 
To view, visit https://gerrit.wikimedia.org/r/59655
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I940bb96b670afb7ab3de524919b56912d027a2ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to