r91930 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91929‎ | r91930 | r91931 >
Date:23:57, 11 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Got rid of final measurements, they aren't needed.
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.TextFlow.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js
@@ -19,7 +19,7 @@
2020 * @param text {String} Text to escape
2121 * @return {String} HTML escaped text
2222 */
23 -TextFlow.prototype.escape = function( text ) {
 23+TextFlow.prototype.escape = function( start, end ) {
2424 return text
2525 // Tags
2626 .replace( /&/g, '&' )
@@ -80,9 +80,9 @@
8181 fit = this.fitCharacters(
8282 this.lines[line].start, this.lines[line].end, ruler, position.left
8383 );
84 - ruler.innerHTML = this.escape( this.content.substring( this.lines[line].start, fit.end ) );
 84+ ruler.innerHTML = this.escape( this.lines[line].start, fit.end );
8585 var left = ruler.clientWidth;
86 - ruler.innerHTML = this.escape( this.content.substring( this.lines[line].start, fit.end + 1 ) );
 86+ ruler.innerHTML = this.escape( this.lines[line].start, fit.end + 1 );
8787 var right = ruler.clientWidth;
8888 var center = Math.round( left + ( ( right - left ) / 2 ) );
8989 $ruler.remove();
@@ -158,9 +158,7 @@
159159 if ( this.lines[line].start < offset ) {
160160 var $ruler = $( '<div class="editSurface-line"></div>' ).appendTo( this.$ ),
161161 ruler = $ruler[0];
162 - ruler.innerHTML = this.escape(
163 - this.lines[line].text.substring( 0, offset - this.lines[line].start )
164 - );
 162+ ruler.innerHTML = this.escape( this.lines[line].start, offset );
165163 position.left = ruler.clientWidth;
166164 $ruler.remove();
167165 }
@@ -295,13 +293,12 @@
296294 * @param end {Integer} Ending of text range for line
297295 */
298296 TextFlow.prototype.appendLine = function( start, end ) {
299 - var lineText = this.content.substring( start, end );
300297 $line = $( '<div class="editSurface-line" line-index="'
301 - + this.lines.length + '">' + this.escape( lineText ) + '</div>' )
 298+ + this.lines.length + '">' + this.escape( start, end ) + '</div>' )
302299 .appendTo( this.$ );
303300 // Collect line information
304301 this.lines.push({
305 - 'text': lineText,
 302+ 'text': this.content.substring( start, end ),
306303 'start': start,
307304 'end': end,
308305 'width': $line.outerWidth(),
@@ -339,9 +336,7 @@
340337 // Place "middle" directly in the center of "start" and "end"
341338 middle = Math.ceil( ( start + end ) / 2 );
342339 // Prepare the line for measurement using pre-escaped HTML
343 - ruler.innerHTML = this.escape(
344 - this.content.substring( this.boundaries[offset], this.boundaries[middle] )
345 - );
 340+ ruler.innerHTML = this.escape( this.boundaries[offset], this.boundaries[middle] );
346341 // Test for over/under using width of the rendered line
347342 if ( ( lineWidth = ruler.clientWidth ) > width ) {
348343 // Detect impossible fit (the first word won't fit by itself)
@@ -356,13 +351,6 @@
357352 start = middle;
358353 }
359354 } while ( start < end );
360 - // Final measurement if start isn't at middle
361 - if ( start !== middle ) {
362 - ruler.innerHTML = this.escape(
363 - this.content.substring( this.boundaries[offset], this.boundaries[start] )
364 - );
365 - lineWidth = ruler.clientWidth;
366 - }
367355 return { 'end': start, 'width': lineWidth };
368356 };
369357
@@ -387,7 +375,7 @@
388376 // Place "middle" directly in the center of "start" and "end"
389377 middle = Math.ceil( ( start + end ) / 2 );
390378 // Fill the line with a portion of the text, escaped as HTML
391 - ruler.innerHTML = this.escape( this.content.substring( offset, middle ) );
 379+ ruler.innerHTML = this.escape( offset, middle );
392380 // Test for over/under using width of the rendered line
393381 if ( ( lineWidth = ruler.clientWidth ) > width ) {
394382 // Detect impossible fit (the first character won't fit by itself)
@@ -402,10 +390,5 @@
403391 start = middle;
404392 }
405393 } while ( start < end );
406 - // Final measurement if start isn't at middle
407 - if ( start !== middle ) {
408 - ruler.innerHTML = this.escape( this.content.substring( offset, start ) );
409 - lineWidth = ruler.clientWidth;
410 - }
411394 return { 'end': start, 'width': lineWidth };
412395 };

Status & tagging log