Esanders has uploaded a new change for review.

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

Change subject: WIP Death to isolation
......................................................................

WIP Death to isolation

Change-Id: I55c55439f93f9780eda2014c5a5f46270129e609
---
M src/ce/styles/ve.ce.Surface.css
M src/ce/ve.ce.Surface.js
M src/ui/actions/ve.ui.WindowAction.js
M src/ui/dialogs/ve.ui.FindAndReplaceDialog.js
M src/ui/dialogs/ve.ui.ToolbarDialog.js
M src/ui/styles/dialogs/ve.ui.ToolbarDialog.css
M src/ui/ve.ui.DesktopContext.js
M src/ui/ve.ui.MobileContext.js
M src/ui/ve.ui.MobileSurface.js
M src/ui/ve.ui.Surface.js
10 files changed, 101 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/18/178918/1

diff --git a/src/ce/styles/ve.ce.Surface.css b/src/ce/styles/ve.ce.Surface.css
index 5e8ea14..73b3024 100644
--- a/src/ce/styles/ve.ce.Surface.css
+++ b/src/ce/styles/ve.ce.Surface.css
@@ -16,6 +16,20 @@
 }
 
 /* @noflip */
+.ve-ce-surface-deactivatedSelection {
+       position: absolute;
+       top: 0;
+       left: 0;
+       opacity: 0.5;
+       pointer-events: none;
+}
+
+.ve-ce-surface-deactivatedSelection > div {
+       position: absolute;
+       background: #6da9f7;
+}
+
+/* @noflip */
 .ve-ce-surface-highlights {
        position: absolute;
        top: 0;
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 6eff240..dc49d60 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -50,6 +50,8 @@
        this.selecting = false;
        this.resizing = false;
        this.focused = false;
+       this.deactivated = false;
+       this.$deactivatedSelection = this.$( '<div>' );
        this.activeTableNode = null;
        this.contentBranchNodeChanged = false;
        this.$highlightsFocused = this.$( '<div>' );
@@ -156,6 +158,7 @@
        this.$highlights.addClass( 've-ce-surface-highlights' );
        this.$highlightsFocused.addClass( 've-ce-surface-highlights-focused' );
        this.$highlightsBlurred.addClass( 've-ce-surface-highlights-blurred' );
+       this.$deactivatedSelection.addClass( 
've-ce-surface-deactivatedSelection' );
        this.$pasteTarget.addClass( 've-ce-surface-paste' )
                .attr( 'tabIndex', -1 )
                .prop( 'contentEditable', 'true' );
@@ -163,6 +166,7 @@
        // Add elements to the DOM
        this.$element.append( this.$documentNode, this.$pasteTarget );
        this.surface.$blockers.append( this.$highlights );
+       this.surface.$selections.append( this.$deactivatedSelection );
 };
 
 /* Inheritance */
@@ -289,7 +293,7 @@
        this.$window.off( 'resize', this.onWindowResizeHandler );
 
        // HACK: Blur to make selection/cursor disappear (needed in Firefox in 
some cases)
-       documentNode.$element[0].blur();
+       this.$documentNode[0].blur();
 
        // Remove DOM elements (also disconnects their events)
        this.$element.remove();
@@ -629,6 +633,37 @@
        }
 };
 
+ve.ce.Surface.prototype.deactivate = function () {
+       this.deactivated = true;
+       this.$documentNode[0].blur();
+       this.updateDeactivedSelection();
+};
+
+ve.ce.Surface.prototype.updateDeactivedSelection = function () {
+       var i, l, rects,
+               selection = this.getModel().getSelection();
+
+       this.$deactivatedSelection.empty();
+
+       if ( this.focusedNode || !( selection instanceof ve.dm.LinearSelection 
) ) {
+               return;
+       }
+       rects = this.surface.getView().getSelectionRects( selection );
+       for ( i = 0, l = rects.length; i < l; i++ ) {
+               this.$deactivatedSelection.append( this.$( '<div>' ).css( {
+                       top: rects[i].top,
+                       left: rects[i].left,
+                       width: rects[i].width,
+                       height: rects[i].height
+               } ) );
+       }
+};
+
+ve.ce.Surface.prototype.activate = function () {
+       this.deactivated = false;
+       this.$deactivatedSelection.empty();
+};
+
 /**
  * Handle document focus events.
  *
@@ -646,6 +681,7 @@
        this.eventSequencer.attach( this.$element );
        this.surfaceObserver.startTimerLoop();
        this.focused = true;
+       this.activate();
        this.emit( 'focus' );
 };
 
@@ -660,16 +696,18 @@
 ve.ce.Surface.prototype.onDocumentBlur = function () {
        this.eventSequencer.detach();
        this.surfaceObserver.stopTimerLoop();
-       this.surfaceObserver.pollOnce();
-       this.surfaceObserver.clear();
-       if ( this.focusedNode ) {
-               this.focusedNode.setFocused( false );
-               this.focusedNode = null;
-       }
        this.dragging = false;
        this.focused = false;
-       this.getModel().setNullSelection();
-       this.emit( 'blur' );
+       if ( !this.deactivated ) {
+               this.surfaceObserver.pollOnce();
+               this.surfaceObserver.clear();
+               if ( this.focusedNode ) {
+                       this.focusedNode.setFocused( false );
+                       this.focusedNode = null;
+               }
+               this.getModel().setNullSelection();
+               this.emit( 'blur' );
+       }
 };
 
 /**
@@ -3044,6 +3082,11 @@
                return;
        }
 
+       if ( this.deactivated ) {
+               this.updateDeactivedSelection();
+               return;
+       }
+
        var endRange,
                range = selection.getRange(),
                rangeSelection = this.getRangeSelection( range ),
@@ -3118,7 +3161,10 @@
        var nativeRange, rangeSelection,
                selection = this.getModel().getSelection();
 
-       if ( range && selection instanceof ve.dm.LinearSelection && 
selection.getRange().equalsSelection( range ) ) {
+       if (
+               range && !this.deactivated &&
+               selection instanceof ve.dm.LinearSelection && 
selection.getRange().equalsSelection( range )
+       ) {
                // Range requested is equivalent to native selection so reset
                range = null;
        }
diff --git a/src/ui/actions/ve.ui.WindowAction.js 
b/src/ui/actions/ve.ui.WindowAction.js
index 17402d0..18a0f94 100644
--- a/src/ui/actions/ve.ui.WindowAction.js
+++ b/src/ui/actions/ve.ui.WindowAction.js
@@ -58,8 +58,11 @@
 
        data = ve.extendObject( { dir: dir }, data, { fragment: fragment } );
 
-       if ( windowType === 'toolbar' ) {
+       if ( windowType === 'inspector' ) {
+               surface.getView().deactivate();
+       } else if ( windowType === 'toolbar' ) {
                data = ve.extendObject( data, { surface: surface } );
+               surface.getView().deactivate();
        } else if ( windowType === 'dialog' ) {
                // For non-isolated dialogs, remove the selection and re-apply 
on close
                surface.getView().nativeSelection.removeAllRanges();
diff --git a/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js 
b/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js
index 1375b52..61ec083 100644
--- a/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js
+++ b/src/ui/dialogs/ve.ui.FindAndReplaceDialog.js
@@ -157,7 +157,7 @@
        return ve.ui.FindAndReplaceDialog.super.prototype.getSetupProcess.call( 
this, data )
                .first( function () {
                        this.surface = data.surface;
-                       this.surface.$controls.append( this.$findResults );
+                       this.surface.$selections.append( this.$findResults );
                        this.surface.getModel().connect( this, { 
documentUpdate: this.updateFragmentsDebounced } );
                        this.surface.getView().connect( this, { position: 
this.positionResultsDebounced } );
 
@@ -281,14 +281,14 @@
                return;
        }
 
-       var i, l, j, rects, $result, top;
+       var i, ilen, j, jlen, rects, $result, top;
 
        this.$findResults.empty();
-       for ( i = 0, l = this.fragments.length; i < l; i++ ) {
+       for ( i = 0, ilen = this.fragments.length; i < ilen; i++ ) {
                rects = this.surface.getView().getSelectionRects( 
this.fragments[i].getSelection() );
                $result = this.$( '<div>' ).addClass( 
've-ui-findAndReplaceDialog-findResult' );
                top = Infinity;
-               for ( j in rects ) {
+               for ( j = 0, jlen = rects.length; j < jlen; j++ ) {
                        top = Math.min( top, rects[j].top );
                        $result.append( this.$( '<div>' ).css( {
                                top: rects[j].top,
diff --git a/src/ui/dialogs/ve.ui.ToolbarDialog.js 
b/src/ui/dialogs/ve.ui.ToolbarDialog.js
index 8a221e6..dca32c9 100644
--- a/src/ui/dialogs/ve.ui.ToolbarDialog.js
+++ b/src/ui/dialogs/ve.ui.ToolbarDialog.js
@@ -30,3 +30,15 @@
 OO.inheritClass( ve.ui.ToolbarDialog, OO.ui.Dialog );
 
 ve.ui.ToolbarDialog.static.size = 'full';
+
+/* Methods */
+
+/**
+ * @inheritdoc
+ */
+ve.ui.ToolbarDialog.prototype.initialize = function () {
+       // Parent method
+       ve.ui.ToolbarDialog.super.prototype.initialize.apply( this );
+
+       this.$content.addClass( 've-ui-toolbarDialog-content' );
+};
diff --git a/src/ui/styles/dialogs/ve.ui.ToolbarDialog.css 
b/src/ui/styles/dialogs/ve.ui.ToolbarDialog.css
index 1e10dbe..53abe9a 100644
--- a/src/ui/styles/dialogs/ve.ui.ToolbarDialog.css
+++ b/src/ui/styles/dialogs/ve.ui.ToolbarDialog.css
@@ -20,6 +20,11 @@
        max-height: 150px;
 }
 
+/* TODO: fix this upstream */
+.ve-ui-toolbar .oo-ui-window-frame {
+       position: relative;
+}
+
 .ve-ui-toolbarDialog-content > .oo-ui-window-body {
        bottom: auto;
        box-shadow: none;
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index efd8e25..11e4335 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -138,8 +138,7 @@
                $: this.$,
                factory: ve.ui.windowFactory,
                overlay: this.surface.getLocalOverlay(),
-               modal: false,
-               isolate: true
+               modal: false
        } );
 };
 
diff --git a/src/ui/ve.ui.MobileContext.js b/src/ui/ve.ui.MobileContext.js
index 5706079..963e361 100644
--- a/src/ui/ve.ui.MobileContext.js
+++ b/src/ui/ve.ui.MobileContext.js
@@ -50,8 +50,7 @@
 ve.ui.MobileContext.prototype.createInspectorWindowManager = function () {
        return new ve.ui.MobileWindowManager( {
                factory: ve.ui.windowFactory,
-               overlay: this.surface.getGlobalOverlay(),
-               isolate: true
+               overlay: this.surface.getGlobalOverlay()
        } );
 };
 
diff --git a/src/ui/ve.ui.MobileSurface.js b/src/ui/ve.ui.MobileSurface.js
index cb3eb3f..85ca819 100644
--- a/src/ui/ve.ui.MobileSurface.js
+++ b/src/ui/ve.ui.MobileSurface.js
@@ -78,8 +78,7 @@
 ve.ui.MobileSurface.prototype.createDialogWindowManager = function () {
        return new ve.ui.MobileWindowManager( {
                factory: ve.ui.windowFactory,
-               overlay: this.globalOverlay,
-               isolate: true
+               overlay: this.globalOverlay
        } );
 };
 
diff --git a/src/ui/ve.ui.Surface.js b/src/ui/ve.ui.Surface.js
index 0b4a816..d6f519e 100644
--- a/src/ui/ve.ui.Surface.js
+++ b/src/ui/ve.ui.Surface.js
@@ -30,6 +30,7 @@
        // Properties
        this.globalOverlay = new ve.ui.Overlay( { classes: 
['ve-ui-overlay-global'] } );
        this.localOverlay = new ve.ui.Overlay( { $: this.$, classes: 
['ve-ui-overlay-local'] } );
+       this.$selections = this.$( '<div>' );
        this.$blockers = this.$( '<div>' );
        this.$controls = this.$( '<div>' );
        this.$menus = this.$( '<div>' );
@@ -60,8 +61,7 @@
        this.toolbarDialogs = new ve.ui.ToolbarDialogWindowManager( {
                $: this.$,
                factory: ve.ui.windowFactory,
-               modal: false,
-               isolate: true
+               modal: false
        } );
 
        // Initialization
@@ -70,7 +70,7 @@
        this.$element
                .addClass( 've-ui-surface' )
                .append( this.view.$element );
-       this.localOverlay.$element.append( this.$blockers, this.$controls, 
this.$menus );
+       this.localOverlay.$element.append( this.$selections, this.$blockers, 
this.$controls, this.$menus );
        this.globalOverlay.$element.append( this.dialogs.$element );
 };
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55c55439f93f9780eda2014c5a5f46270129e609
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

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

Reply via email to