r103354 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103353‎ | r103354 | r103355 >
Date:19:02, 16 November 2011
Author:catrope
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/bases/es.DocumentBranchNode.js
@@ -263,7 +263,8 @@
264264 * @param {es.Range} range Range to select nodes within
265265 * @param {Boolean} [shallow] Do not recurse into child nodes of child nodes
266266 * @returns {Array} List of objects with 'node', 'range' and 'globalRange' properties describing nodes which are
267 - * covered by the range and the range within the node that is covered
 267+ * covered by the range and the range within the node that is covered. If an entire node is covered, 'range' is
 268+ * absent but 'globalRange' is still set
268269 */
269270 es.DocumentBranchNode.prototype.selectNodes = function( range, shallow ) {
270271 if ( typeof range === 'undefined' ) {
@@ -360,19 +361,19 @@
361362 // end is between childNode and this.children[i+1]
362363 // start is not inside childNode, so the selection covers
363364 // all of childNode, then ends
364 - nodes.push( { 'node': childNode } );
 365+ nodes.push( { 'node': childNode, 'globalRange': new es.Range( left - 1, right + 1 ) } );
365366 // We've reached the end so we're done
366367 return nodes;
367368 } else if ( start == left - 1 ) {
368369 // start is between this.children[i-1] and childNode
369370 // end is not inside childNode, so the selection covers
370371 // all of childNode and more
371 - nodes.push( { 'node': childNode } );
 372+ nodes.push( { 'node': childNode, 'globalRange': new es.Range( left - 1, right + 1 ) } );
372373 } else if ( nodes.length > 0 ) {
373374 // Neither the start nor the end is inside childNode, but nodes is non-empty,
374375 // so childNode must be between the start and the end
375376 // Add the entire node, so no range property
376 - nodes.push( { 'node': childNode } );
 377+ nodes.push( { 'node': childNode, 'globalRange': new es.Range( left - 1, right + 1 ) } );
377378 }
378379
379380 // Move left to the start of this.children[i+1] for the next iteration

Follow-up revisions

RevisionCommit summaryAuthorDate
r103358Fixed test data in response to r103354tparscal19:26, 16 November 2011

Status & tagging log