jenkins-bot has submitted this change and it was merged. Change subject: Remove SurfaceObserver locking (unused) ......................................................................
Remove SurfaceObserver locking (unused) The SurfaceObserver lock guarded against setTimeout calls, but the lock was only ever used synchronously. Remove 'lock' and 'unlock' events. Instead, re-sync the SurfaceObserver by listening to the 'documentUpdate' and 'select' events. Signed-off-by: Roan Kattouw <[email protected]> Change-Id: Ib15c39f3d25677da70625581b3b2765ae66994b4 --- M modules/ve/ce/ve.ce.Surface.js M modules/ve/ce/ve.ce.SurfaceObserver.js M modules/ve/dm/ve.dm.Surface.js 3 files changed, 15 insertions(+), 44 deletions(-) Approvals: Divec: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index 82be00d..e942e6f 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -60,7 +60,8 @@ this, { 'contentChange': 'onContentChange', 'selectionChange': 'onSelectionChange' } ); this.model.connect( this, - { 'select': 'onModelSelect', 'lock': 'onLock', 'unlock': 'onUnlock' } ); + { 'select': 'onModelSelect', 'documentUpdate': 'onModelDocumentUpdate' } + ); $documentNode = this.documentView.getDocumentNode().$; $documentNode.on( { @@ -982,6 +983,18 @@ if ( !this.focusedNode && !this.isRenderingLocked() && selection !== this.newModelSelection ) { this.showSelection( selection ); } + + // Update the selection state in the SurfaceObserver + this.surfaceObserver.pollOnceNoEmit(); +}; + +/** + * Handle documentUpdate events on the surface model. + * @param {ve.dm.Transaction} transaction Transaction that was processed + */ +ve.ce.Surface.prototype.onModelDocumentUpdate = function () { + // Update the state of the SurfaceObserver + this.surfaceObserver.pollOnceNoEmit(); }; /** @@ -1175,25 +1188,6 @@ newRange ); } -}; - -/** - * Handle surface lock events. - * - * @method - */ -ve.ce.Surface.prototype.onLock = function () { - this.surfaceObserver.locked = true; -}; - -/** - * Handle surface unlock events. - * - * @method - */ -ve.ce.Surface.prototype.onUnlock = function () { - this.surfaceObserver.locked = false; - this.surfaceObserver.pollOnceNoEmit(); }; /*! Relocation */ diff --git a/modules/ve/ce/ve.ce.SurfaceObserver.js b/modules/ve/ce/ve.ce.SurfaceObserver.js index e166572..172887a 100644 --- a/modules/ve/ce/ve.ce.SurfaceObserver.js +++ b/modules/ve/ce/ve.ce.SurfaceObserver.js @@ -24,7 +24,6 @@ this.documentView = documentView; this.domDocument = null; this.polling = false; - this.locked = false; this.timeoutId = null; this.frequency = 250; // ms @@ -112,7 +111,7 @@ clearTimeout( this.timeoutId ); this.timeoutId = null; } - if ( !firstTime && !this.locked ) { + if ( !firstTime ) { this.pollOnce(); } // only reach this point if pollOnce does not throw an exception diff --git a/modules/ve/dm/ve.dm.Surface.js b/modules/ve/dm/ve.dm.Surface.js index 36952cd..f686207 100644 --- a/modules/ve/dm/ve.dm.Surface.js +++ b/modules/ve/dm/ve.dm.Surface.js @@ -44,14 +44,6 @@ /* Events */ /** - * @event lock - */ - -/** - * @event unlock - */ - -/** * @event select * @param {ve.Range} selection */ @@ -366,8 +358,6 @@ * * @param {ve.Range} selection New selection * - * @fires lock - * @fires unlock * @fires select * @fires contextChange */ @@ -387,9 +377,6 @@ this.selection = selection; return; } - - // Stop observation polling, things changing right now are known already - this.emit( 'lock' ); // Detect if selected nodes changed selectedNodes.start = this.documentModel.getNodeFromOffset( selection.start ); @@ -447,9 +434,6 @@ if ( contextChange ) { this.emitContextChange(); } - - // Continue observation polling, we want to know about things that change from here on out - this.emit( 'unlock' ); }; /** @@ -459,9 +443,7 @@ * @param {ve.dm.Transaction|ve.dm.Transaction[]|null} transactions One or more transactions to * process, or null to process none * @param {ve.Range} [selection] Selection to apply - * @fires lock * @fires contextChange - * @fires unlock */ ve.dm.Surface.prototype.change = function ( transactions, selection ) { this.changeInternal( transactions, selection, false ); @@ -475,9 +457,7 @@ * @param {ve.dm.Transaction|ve.dm.Transaction[]|null} transactions * @param {ve.Range} [selection] [selection] * @param {boolean} [skipUndoStack=false] If true, do not modify the undo stack. Used by undo/redo - * @fires lock * @fires contextChange - * @fires unlock */ ve.dm.Surface.prototype.changeInternal = function ( transactions, selection, skipUndoStack ) { var i, len, selectionAfter, selectionBefore = this.selection, contextChange = false; @@ -494,7 +474,6 @@ transactions = [transactions]; } this.transacting = true; - this.emit( 'lock' ); for ( i = 0, len = transactions.length; i < len; i++ ) { if ( !transactions[i].isNoOp() ) { if ( !skipUndoStack ) { @@ -508,7 +487,6 @@ } } } - this.emit( 'unlock' ); this.transacting = false; } selectionAfter = this.selection; -- To view, visit https://gerrit.wikimedia.org/r/87035 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib15c39f3d25677da70625581b3b2765ae66994b4 Gerrit-PatchSet: 14 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Divec <[email protected]> Gerrit-Reviewer: Catrope <[email protected]> Gerrit-Reviewer: Divec <[email protected]> Gerrit-Reviewer: Esanders <[email protected]> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
