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

Change subject: Non-DOM-modifying selection
......................................................................


Non-DOM-modifying selection

Create a collapsed selection directly in handleLinearUpOrDownArrowKey, instead
of inserting, selecting and removing a $cursorHolder span. The original purpose
of the insertion technique seems to have been to give a non-collapsed selection
for the native action to work on, then delete the superfluous content
afterwards. However, since Ifd5000fc5e667cb9fd6db0e97cf8a03b4da45553 we have
been deleting the $cursorHolder *before* the native action, so the native
action acts on a collapsed selection in any case.

Also stop treating slugs specially, as there is now no text insertion to create
problems in them.

Change-Id: If507cc2bcc363c1d637409dfa191942c967a7c59
---
M src/ce/ve.ce.Surface.js
1 file changed, 13 insertions(+), 30 deletions(-)

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



diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 9bad070..f5ac467 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -2527,7 +2527,7 @@
  * @param {jQuery.Event} e Up or down key down event
  */
 ve.ce.Surface.prototype.handleLinearUpOrDownArrowKey = function ( e ) {
-       var nativeRange, slug, $cursorHolder, endNode, endOffset,
+       var nativeRange, endNode, endOffset,
                range = this.model.getSelection().getRange(),
                tableEditingRange = this.getActiveTableNode() ? 
this.getActiveTableNode().getEditingRange() : null,
                direction = e.keyCode === OO.ui.Keys.DOWN ? 1 : -1,
@@ -2558,41 +2558,24 @@
        } else if ( !range.isCollapsed() ) {
                // Perform programmatic handling for a selection that is 
expanded because CE
                // behaviour is inconsistent
-               slug = this.documentView.getSlugAtOffset( range.to );
-               if ( !slug ) {
-                       if ( !this.nativeSelection.extend && 
range.isBackwards() ) {
-                               // If the browser doesn't support backwards 
selections, but the dm range
-                               // is backwards, then use anchorNode/Offset to 
compensate
-                               endNode = this.nativeSelection.anchorNode;
-                               endOffset = this.nativeSelection.anchorOffset;
-                       } else {
-                               endNode = this.nativeSelection.focusNode;
-                               endOffset = this.nativeSelection.focusOffset;
-                       }
-                       $cursorHolder = this.$( '<span 
class="ve-ce-surface-cursorHolder"> </span>' ).hide();
-                       if ( endNode.nodeType === Node.TEXT_NODE ) {
-                               endNode.splitText( endOffset );
-                       }
-                       endNode.parentNode.insertBefore(
-                               $cursorHolder[0],
-                               endNode.nextSibling
-                       );
+               if ( !this.nativeSelection.extend && range.isBackwards() ) {
+                       // If the browser doesn't support backwards selections, 
but the dm range
+                       // is backwards, then use anchorNode/Offset to 
compensate
+                       endNode = this.nativeSelection.anchorNode;
+                       endOffset = this.nativeSelection.anchorOffset;
+               } else {
+                       endNode = this.nativeSelection.focusNode;
+                       endOffset = this.nativeSelection.focusOffset;
                }
        }
-       if ( $cursorHolder || slug ) {
+       if ( endNode ) {
                nativeRange = this.getElementDocument().createRange();
-               nativeRange.selectNode( $cursorHolder ? $cursorHolder[0] : slug 
);
+               nativeRange.setStart( endNode, endOffset );
+               nativeRange.setEnd( endNode, endOffset );
                this.nativeSelection.removeAllRanges();
                this.nativeSelection.addRange( nativeRange );
        }
-       if ( $cursorHolder ) {
-               $cursorHolder.remove();
-               this.surfaceObserver.clear();
-       }
-       // If we did text node splitting, try and patch things up
-       if ( endNode && endNode.nodeType === Node.TEXT_NODE ) {
-               ve.normalizeNode( endNode.parentNode );
-       }
+
        setTimeout( function () {
                var viewNode, newRange;
                // Chrome bug lets you cursor into a multi-line 
contentEditable=false with up/down...

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If507cc2bcc363c1d637409dfa191942c967a7c59
Gerrit-PatchSet: 4
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>
Gerrit-Reviewer: Catrope <[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

Reply via email to