https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103354

Revision: 103354
Author:   catrope
Date:     2011-11-16 19:02:23 +0000 (Wed, 16 Nov 2011)
Log Message:
-----------
In selectNodes(), also set globalRange for fully-covered nodes. There is no 
sane value for range in this case, but there sure is a sane value for 
globalRange so we might as well return it. I also use this in my 
prepareRemoval() fixes in my next commit

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js

Modified: 
trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js     
2011-11-16 18:59:15 UTC (rev 103353)
+++ trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js     
2011-11-16 19:02:23 UTC (rev 103354)
@@ -263,7 +263,8 @@
  * @param {es.Range} range Range to select nodes within
  * @param {Boolean} [shallow] Do not recurse into child nodes of child nodes
  * @returns {Array} List of objects with 'node', 'range' and 'globalRange' 
properties describing nodes which are
- * covered by the range and the range within the node that is covered
+ * covered by the range and the range within the node that is covered. If an 
entire node is covered, 'range' is
+ * absent but 'globalRange' is still set
  */
 es.DocumentBranchNode.prototype.selectNodes = function( range, shallow ) {
        if ( typeof range === 'undefined' ) {
@@ -360,19 +361,19 @@
                        // end is between childNode and this.children[i+1]
                        // start is not inside childNode, so the selection 
covers
                        // all of childNode, then ends
-                       nodes.push( { 'node': childNode } );
+                       nodes.push( { 'node': childNode, 'globalRange': new 
es.Range( left - 1, right + 1 ) } );
                        // We've reached the end so we're done
                        return nodes;
                } else if ( start == left - 1 ) {
                        // start is between this.children[i-1] and childNode
                        // end is not inside childNode, so the selection covers
                        // all of childNode and more
-                       nodes.push( { 'node': childNode } );
+                       nodes.push( { 'node': childNode, 'globalRange': new 
es.Range( left - 1, right + 1 ) } );
                } else if ( nodes.length > 0 ) {
                        // Neither the start nor the end is inside childNode, 
but nodes is non-empty,
                        // so childNode must be between the start and the end
                        // Add the entire node, so no range property
-                       nodes.push( { 'node': childNode } );
+                       nodes.push( { 'node': childNode, 'globalRange': new 
es.Range( left - 1, right + 1 ) } );
                }
                
                // Move left to the start of this.children[i+1] for the next 
iteration


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

Reply via email to