Divec has uploaded a new change for review.
https://gerrit.wikimedia.org/r/87035
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'/'unlock' events, replacing 'unlock' with a new 'refresh'
event (to re-sync the SurfaceObserver).
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, 11 insertions(+), 35 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/35/87035/1
diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 631c91c..912cc8c 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -59,7 +59,7 @@
this.surfaceObserver.connect(
this, { 'contentChange': 'onContentChange', 'selectionChange':
'onSelectionChange' }
);
- this.model.connect( this, { 'change': 'onChange', 'lock': 'onLock',
'unlock': 'onUnlock' } );
+ this.model.connect( this, { 'change': 'onChange', 'refresh':
'onRefresh' } );
$documentNode = this.documentView.getDocumentNode().$;
$documentNode.on( {
@@ -1161,21 +1161,11 @@
};
/**
- * Handle surface lock events.
+ * Handle surface refresh 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;
+ve.ce.Surface.prototype.onRefresh = function () {
this.surfaceObserver.pollOnceNoEmit();
};
diff --git a/modules/ve/ce/ve.ce.SurfaceObserver.js
b/modules/ve/ce/ve.ce.SurfaceObserver.js
index d0637be..a1cbd90 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
@@ -102,7 +101,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 04283fd..dff44da 100644
--- a/modules/ve/dm/ve.dm.Surface.js
+++ b/modules/ve/dm/ve.dm.Surface.js
@@ -38,11 +38,7 @@
/* Events */
/**
- * @event lock
- */
-
-/**
- * @event unlock
+ * @event refresh
*/
/**
@@ -292,12 +288,11 @@
* @param {ve.dm.Transaction|ve.dm.Transaction[]|null} transactions One or
more transactions to
* process, or null to process none
* @param {ve.Range|undefined} selection
- * @emits lock
* @emits select
* @emits transact
* @emits contextChange
* @emits change
- * @emits unlock
+ * @emits refresh
*/
ve.dm.Surface.prototype.change = function ( transactions, selection ) {
if ( !this.enabled ) {
@@ -308,9 +303,6 @@
selectionChange = false,
contextChange = false,
dataModelData = this.documentModel.data;
-
- // Stop observation polling, things changing right now are known already
- this.emit( 'lock' );
// Process transactions and apply selection changes
if ( transactions ) {
@@ -408,8 +400,7 @@
this.emit( 'change', transactions, selection );
- // Continue observation polling, we want to know about things that
change from here on out
- this.emit( 'unlock' );
+ this.emit( 'refresh' );
};
/**
@@ -441,8 +432,7 @@
*
* @method
* @see ve.dm.Document#rollback
- * @emits lock
- * @emits unlock
+ * @emits refresh
* @emits history
* @returns {ve.Range} Selection or null if no further state could be reached
*/
@@ -455,7 +445,6 @@
this.undoIndex++;
if ( this.bigStack[this.bigStack.length - this.undoIndex] ) {
- this.emit( 'lock' );
item = this.bigStack[this.bigStack.length - this.undoIndex];
selection = item.selection;
@@ -464,7 +453,7 @@
selection = transaction.translateRange( selection, true
);
this.documentModel.rollback( transaction );
}
- this.emit( 'unlock' );
+ this.emit( 'refresh' );
this.emit( 'history' );
return selection;
}
@@ -476,8 +465,7 @@
*
* @method
* @see ve.dm.Document#commit
- * @emits lock
- * @emits unlock
+ * @emits refresh
* @emits history
* @returns {ve.Range} Selection or null if no further state could be reached
*/
@@ -489,7 +477,6 @@
this.breakpoint();
if ( this.bigStack[this.bigStack.length - this.undoIndex] ) {
- this.emit( 'lock' );
item = this.bigStack[this.bigStack.length - this.undoIndex];
selection = item.selection;
for ( i = 0; i < item.stack.length; i++ ) {
@@ -497,7 +484,7 @@
this.documentModel.commit( transaction );
}
this.undoIndex--;
- this.emit( 'unlock' );
+ this.emit( 'refresh' );
this.emit( 'history' );
return selection;
}
--
To view, visit https://gerrit.wikimedia.org/r/87035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib15c39f3d25677da70625581b3b2765ae66994b4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits