jenkins-bot has submitted this change and it was merged.

Change subject: Update VE core submodule to master (3feadb2)
......................................................................


Update VE core submodule to master (3feadb2)

New changes:
fc4af20 Fix filibuster expansion bug
3feadb2 [BREAKING CHANGE] Refactor for multiple surfaces

Local changes:
* Use target.getSurface now that targets can have multiple surfaces
* Remove debug bar code now surfaces manage their own
* Remove import rules code now implemented in base target

Change-Id: I18d6f9f2f36431959d31347b4c1952a1aca1350e
---
M lib/ve
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
M modules/ve-mw/init/ve.init.mw.Target.js
3 files changed, 57 insertions(+), 63 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/ve b/lib/ve
index b6423de..3feadb2 160000
--- a/lib/ve
+++ b/lib/ve
-Subproject commit b6423dea45d3c6b1d8755dce47e1eb0dd808cb6d
+Subproject commit 3feadb265740c564fb2d209d7da20ff27396fd5d
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 3161d4a..c646c69 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -210,10 +210,10 @@
 
        this.toolbar.$bar.slideDown( 'fast', function () {
                // Check the surface wasn't torn down while the toolbar was 
animating
-               if ( this.surface ) {
+               if ( this.getSurface() ) {
                        this.toolbar.initialize();
-                       this.surface.getView().emit( 'position' );
-                       this.surface.getContext().updateDimensions();
+                       this.getSurface().getView().emit( 'position' );
+                       this.getSurface().getContext().updateDimensions();
                }
        }.bind( this ) );
 };
@@ -291,7 +291,7 @@
        if ( noDialog || this.activating || !this.edited ) {
                this.cancel( trackMechanism );
        } else {
-               this.surface.dialogs.openWindow( 'cancelconfirm' ).then( 
function ( opened ) {
+               this.getSurface().dialogs.openWindow( 'cancelconfirm' ).then( 
function ( opened ) {
                        opened.then( function ( closing ) {
                                closing.then( function ( data ) {
                                        if ( data && data.action === 'discard' 
) {
@@ -430,14 +430,13 @@
                return;
        }
        this.activating = false;
-       this.surface.getModel().connect( this, {
+       this.getSurface().getModel().connect( this, {
                history: 'updateToolbarSaveButtonState'
        } );
-       this.surface.setImportRules( this.constructor.static.importRules );
 
        // TODO: mwTocWidget should probably live in a ve.ui.MWSurface subclass
        if ( mw.config.get( 'wgVisualEditorConfig' ).enableTocWidget ) {
-               this.surface.mwTocWidget = new ve.ui.MWTocWidget( this.surface 
);
+               this.getSurface().mwTocWidget = new ve.ui.MWTocWidget( 
this.getSurface() );
        }
 
        // Update UI
@@ -445,7 +444,7 @@
        this.changeDocumentTitle();
        this.hidePageContent();
 
-       this.surface.getView().focus();
+       this.getSurface().getView().focus();
 
        this.setupToolbarSaveButton();
        this.attachToolbarSaveButton();
@@ -738,7 +737,7 @@
  */
 ve.init.mw.ViewPageTarget.prototype.onShowChanges = function ( diffHtml ) {
        // Invalidate the viewer diff on next change
-       this.surface.getModel().getDocument().once( 'transact',
+       this.getSurface().getModel().getDocument().once( 'transact',
                this.saveDialog.clearDiff.bind( this.saveDialog )
        );
        this.saveDialog.setDiffAndReview( diffHtml );
@@ -813,7 +812,7 @@
  * @param {jQuery.Event} e Mouse click event
  */
 ve.init.mw.ViewPageTarget.prototype.onToolbarMetaButtonClick = function () {
-       this.surface.getDialogs().openWindow( 'meta' );
+       this.getSurface().getDialogs().openWindow( 'meta' );
 };
 
 /**
@@ -822,7 +821,7 @@
 ve.init.mw.ViewPageTarget.prototype.updateToolbarSaveButtonState = function () 
{
        var isDisabled;
 
-       this.edited = this.surface.getModel().hasBeenModified();
+       this.edited = this.getSurface().getModel().hasBeenModified();
        // Disable the save button if we have no history or if the sanity check 
is not finished
        isDisabled = ( !this.edited && !this.restoring ) || 
!this.sanityCheckFinished;
        this.toolbarSaveButton.setDisabled( isDisabled );
@@ -863,7 +862,7 @@
  */
 ve.init.mw.ViewPageTarget.prototype.onSaveDialogReviewComplete = function ( 
wikitext ) {
        // Invalidate the viewer wikitext on next change
-       this.surface.getModel().getDocument().once( 'transact',
+       this.getSurface().getModel().getDocument().once( 'transact',
                this.saveDialog.clearDiff.bind( this.saveDialog )
        );
        this.saveDialog.setDiffAndReview( $( '<pre>' ).text( wikitext ) );
@@ -915,14 +914,14 @@
  * @method
  */
 ve.init.mw.ViewPageTarget.prototype.editSource = function () {
-       if ( !this.surface.getModel().hasBeenModified() ) {
+       if ( !this.getSurface().getModel().hasBeenModified() ) {
                this.switchToWikitextEditor( true );
                return;
        }
 
-       this.surface.getView().getDocument().getDocumentNode().$element.css( 
'opacity', 0.5 );
+       
this.getSurface().getView().getDocument().getDocumentNode().$element.css( 
'opacity', 0.5 );
 
-       this.surface.getDialogs().openWindow( 'wikitextswitchconfirm', { 
target: this } );
+       this.getSurface().getDialogs().openWindow( 'wikitextswitchconfirm', { 
target: this } );
 };
 
 /**
@@ -1015,8 +1014,8 @@
        this.tearDownToolbar();
        this.tearDownDebugBar();
        this.restoreDocumentTitle();
-       if ( this.surface.mwTocWidget ) {
-               this.surface.mwTocWidget.teardown();
+       if ( this.getSurface().mwTocWidget ) {
+               this.getSurface().mwTocWidget.teardown();
        }
 
        if ( this.saveDialog ) {
@@ -1030,9 +1029,8 @@
 
        return $.when.apply( $, promises ).then( function () {
                // Destroy surface
-               if ( this.surface ) {
-                       this.surface.destroy();
-                       this.surface = null;
+               while ( this.surfaces.length ) {
+                       this.surfaces.pop().destroy();
                }
                this.active = false;
        }.bind( this ) );
@@ -1045,17 +1043,17 @@
  * @method
  */
 ve.init.mw.ViewPageTarget.prototype.setupSkinTabs = function () {
-       var viewPageTarget = this;
+       var target = this;
        if ( this.isViewPage ) {
                // Allow instant switching back to view mode, without refresh
                $( '#ca-view a, #ca-nstab-visualeditor a' )
                        .click( this.onViewTabClick.bind( this ) );
 
                $( '#ca-viewsource, #ca-edit' ).click( function ( e ) {
-                       if ( viewPageTarget.surface && 
!viewPageTarget.deactivating ) {
-                               viewPageTarget.editSource();
+                       if ( target.getSurface() && !target.deactivating ) {
+                               target.editSource();
 
-                               if ( 
viewPageTarget.surface.getModel().hasBeenModified() ) {
+                               if ( 
target.getSurface().getModel().hasBeenModified() ) {
                                        e.preventDefault();
                                }
                        }
@@ -1107,7 +1105,7 @@
 ve.init.mw.ViewPageTarget.prototype.attachToolbarSaveButton = function () {
        var $actionTools = $( '<div>' ),
                $pushButtons = $( '<div>' ),
-               actions = new ve.ui.TargetToolbar( this, this.surface );
+               actions = new ve.ui.TargetToolbar( this, this.getSurface() );
 
        actions.setup( [
                { include: [ 'help', 'notices' ] },
@@ -1138,10 +1136,10 @@
  */
 ve.init.mw.ViewPageTarget.prototype.showSaveDialog = function () {
        this.emit( 'saveWorkflowBegin' );
-       this.surface.getDialogs().getWindow( 'mwSave' ).then( function ( win ) {
-               var currentWindow = 
this.surface.getContext().getInspectors().getCurrentWindow(),
+       this.getSurface().getDialogs().getWindow( 'mwSave' ).then( function ( 
win ) {
+               var currentWindow = 
this.getSurface().getContext().getInspectors().getCurrentWindow(),
                        target = this;
-               this.origSelection = this.surface.getModel().getSelection();
+               this.origSelection = 
this.getSurface().getModel().getSelection();
 
                // Make sure any open inspectors are closed
                if ( currentWindow ) {
@@ -1150,7 +1148,7 @@
 
                // Preload the serialization
                if ( !this.docToSave ) {
-                       this.docToSave = ve.dm.converter.getDomFromModel( 
this.surface.getModel().getDocument() );
+                       this.docToSave = ve.dm.converter.getDomFromModel( 
this.getSurface().getModel().getDocument() );
                }
                this.prepareCacheKey( this.docToSave );
 
@@ -1170,9 +1168,9 @@
                }
 
                this.saveDialog.setSanityCheck( this.sanityCheckVerified );
-               this.surface.getDialogs().openWindow(
+               this.getSurface().getDialogs().openWindow(
                        this.saveDialog,
-                       { dir: this.surface.getModel().getDocument().getLang() }
+                       { dir: 
this.getSurface().getModel().getDocument().getLang() }
                )
                        // Call onSaveDialogClose() when the save dialog starts 
closing
                        .done( function ( opened ) {
@@ -1192,12 +1190,12 @@
                this.docToSave = null;
                this.clearPreparedCacheKey();
        }.bind( this );
-       if ( this.surface ) {
-               this.surface.getModel().getDocument().once( 'transact', clear );
+       if ( this.getSurface() ) {
+               this.getSurface().getModel().getDocument().once( 'transact', 
clear );
        } else {
                clear();
        }
-       this.surface.getModel().setSelection( this.origSelection );
+       this.getSurface().getModel().setSelection( this.origSelection );
        this.emit( 'saveWorkflowEnd' );
 };
 
@@ -1619,7 +1617,7 @@
                                        )
                                )
                        ) {
-                       this.surface.getDialogs().openWindow( 'betaWelcome' );
+                       this.getSurface().getDialogs().openWindow( 
'betaWelcome' );
                }
 
                if ( prefSaysShow ) {
@@ -1641,10 +1639,10 @@
                }
        }
 
-       if ( this.surface.getModel().metaList.getItemsInGroup( 'mwRedirect' 
).length ) {
-               this.surface.getDialogs().openWindow( 'meta', {
+       if ( this.getSurface().getModel().metaList.getItemsInGroup( 
'mwRedirect' ).length ) {
+               this.getSurface().getDialogs().openWindow( 'meta', {
                        page: 'settings',
-                       fragment: this.surface.getModel().getFragment()
+                       fragment: this.getSurface().getModel().getFragment()
                } );
        }
 };
@@ -1683,7 +1681,7 @@
                        return undefined;
                }
                // Check if there's been an edit
-               if ( this.surface && this.edited && mw.user.options.get( 
'useeditwarning' ) ) {
+               if ( this.getSurface() && this.edited && mw.user.options.get( 
'useeditwarning' ) ) {
                        // Return our message
                        message = ve.msg( 'visualeditor-viewpage-savewarning' );
                }
@@ -1714,7 +1712,7 @@
                } ).toString();
        } else {
                this.serialize(
-                       this.docToSave || ve.dm.converter.getDomFromModel( 
this.surface.getModel().getDocument() ),
+                       this.docToSave || ve.dm.converter.getDomFromModel( 
this.getSurface().getModel().getDocument() ),
                        function ( wikitext ) {
                                ve.track( 'mwedit.abort', { type: 'switchwith', 
mechanism: 'navigate' } );
                                this.submitWithSaveFields( { wpDiff: 1, 
veswitched: 1 }, wikitext );
@@ -1727,5 +1725,5 @@
  * Resets the document opacity when we've decided to cancel switching to the 
wikitext editor.
  */
 ve.init.mw.ViewPageTarget.prototype.resetDocumentOpacity = function () {
-       this.surface.getView().getDocument().getDocumentNode().$element.css( 
'opacity', 1 );
+       
this.getSurface().getView().getDocument().getDocumentNode().$element.css( 
'opacity', 1 );
 };
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js 
b/modules/ve-mw/init/ve.init.mw.Target.js
index 6022c77..41e1b63 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -602,7 +602,7 @@
  */
 ve.init.mw.Target.prototype.onSaveError = function ( doc, saveData, jqXHR, 
status, data ) {
        var api, editApi,
-               viewPage = this;
+               target = this;
        this.saving = false;
 
        // Handle empty response
@@ -637,12 +637,12 @@
                        prop: 'info',
                        // Try to send the normalised form so that it is less 
likely we get extra data like
                        // data.normalised back that we don't need.
-                       titles: new mw.Title( viewPage.pageName ).toText(),
+                       titles: new mw.Title( target.pageName ).toText(),
                        indexpageids: '',
                        intoken: 'edit'
                } )
                        .always( function () {
-                               viewPage.emit( 'saveErrorBadToken' );
+                               target.emit( 'saveErrorBadToken' );
                        } )
                        .done( function ( data ) {
                                var userMsg,
@@ -653,7 +653,7 @@
                                        isAnon = mw.user.isAnon();
 
                                if ( userInfo && editToken ) {
-                                       viewPage.editToken = editToken;
+                                       target.editToken = editToken;
 
                                        if (
                                                ( isAnon && userInfo.anon !== 
undefined ) ||
@@ -662,7 +662,7 @@
                                                        mw.config.get( 
'wgUserId' ) === userInfo.id
                                        ) {
                                                // New session is the same user 
still
-                                               viewPage.save( doc, saveData );
+                                               target.save( doc, saveData );
                                        } else {
                                                // The now current session is a 
different user
                                                if ( userInfo.anon !== 
undefined ) {
@@ -674,7 +674,7 @@
                                                                // functions 
like mw.user.isAnon rely on this.
                                                                wgUserName: null
                                                        } );
-                                                       viewPage.emit( 
'saveErrorNewUser', null );
+                                                       target.emit( 
'saveErrorNewUser', null );
                                                } else {
                                                        // New session is a 
different user
                                                        mw.config.set( { 
wgUserId: userInfo.id, wgUserName: userInfo.name } );
@@ -684,7 +684,7 @@
                                                                
mw.messages.get( 'visualeditor-savedialog-identify-user' )
                                                                        
.replace( /\$1/g, userInfo.name )
                                                        );
-                                                       viewPage.emit( 
'saveErrorNewUser', userInfo.name );
+                                                       target.emit( 
'saveErrorNewUser', userInfo.name );
                                                }
                                        }
                                }
@@ -1367,8 +1367,7 @@
                );
                setTimeout( function () {
                        // Create ui.Surface (also creates ce.Surface and 
dm.Surface and builds CE tree)
-                       var surface = target.createSurface( dmDoc, { 
excludeCommands: target.constructor.static.excludeCommands } );
-                       target.surface = surface;
+                       var surface = target.addSurface( dmDoc );
                        surface.$element.addClass( 
've-init-mw-viewPageTarget-surface' )
                                .addClass( target.protectedClasses );
                        setTimeout( function () {
@@ -1379,9 +1378,6 @@
                                surface.getContext().toggle( false );
                                target.$element.append( surface.$element );
                                target.setupToolbar();
-                               if ( ve.debug ) {
-                                       target.setupDebugBar();
-                               }
 
                                // Apply mw-body-content to the view 
(ve-ce-surface).
                                // Not to surface (ve-ui-surface), since that 
contains both the view
@@ -1422,15 +1418,15 @@
 ve.init.mw.Target.prototype.startSanityCheck = function () {
        // We have to get a copy of the data now, before we unlock the surface 
and let the user edit,
        // but we can defer the actual conversion and comparison
-       var viewPage = this,
-               doc = viewPage.surface.getModel().getDocument(),
+       var target = this,
+               doc = target.surface.getModel().getDocument(),
                data = new ve.dm.FlatLinearData( doc.getStore().clone(), 
ve.copy( doc.getFullData() ) ),
-               oldDom = viewPage.doc,
+               oldDom = target.doc,
                d = $.Deferred();
 
        // Reset
-       viewPage.sanityCheckFinished = false;
-       viewPage.sanityCheckVerified = false;
+       target.sanityCheckFinished = false;
+       target.sanityCheckVerified = false;
 
        setTimeout( function () {
                // We can't compare oldDom.body and newDom.body directly, 
because the attributes on the
@@ -1457,15 +1453,15 @@
                d.resolve();
        } );
 
-       viewPage.sanityCheckPromise = d.promise()
+       target.sanityCheckPromise = d.promise()
                .done( function () {
                        // If we detect no roundtrip errors,
                        // don't emphasize "review changes" to the user.
-                       viewPage.sanityCheckVerified = true;
+                       target.sanityCheckVerified = true;
                })
                .always( function () {
-                       viewPage.sanityCheckFinished = true;
-                       viewPage.emit( 'sanityCheckComplete' );
+                       target.sanityCheckFinished = true;
+                       target.emit( 'sanityCheckComplete' );
                } );
 };
 
@@ -1477,7 +1473,7 @@
  */
 ve.init.mw.Target.prototype.restoreEditSection = function () {
        if ( this.section !== undefined && this.section > 0 ) {
-               var surfaceView = this.surface.getView(),
+               var surfaceView = this.getSurface().getView(),
                        $documentNode = 
surfaceView.getDocument().getDocumentNode().$element,
                        $section = $documentNode.find( 'h1, h2, h3, h4, h5, h6' 
).eq( this.section - 1 ),
                        headingNode = $section.data( 'view' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I18d6f9f2f36431959d31347b4c1952a1aca1350e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to