r91580 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91579‎ | r91580 | r91581 >
Date:18:34, 6 July 2011
Author:inez
Status:deferred
Tags:
Comment:
Fix implementation of TextFlow.prototype.getPosition function, and comment out for now not working n+1 position support
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.TextFlow.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js
@@ -119,14 +119,14 @@
120120 * positions, which is a nice benefit of this method.
121121 */
122122 while ( line < lineCount ) {
123 - if ( offset >= lines[line].start && offset < lines[line].end ) {
124 - position.bottom = position.top + lines[line].height;
 123+ if ( offset >= this.lines[line].start && offset < this.lines[line].end ) {
 124+ position.bottom = position.top + this.lines[line].height;
125125 break;
126126 }
127 - position.top += lines[line].height;
 127+ position.top += this.lines[line].height;
128128 line++;
129129 };
130 -
 130+
131131 /*
132132 * Virtual n+1 position
133133 *
@@ -134,6 +134,7 @@
135135 * line, a virtual n+1 position is supported. Offsets beyond this virtual position will cause
136136 * an exception to be thrown.
137137 */
 138+/*
138139 if ( line === lineCount ) {
139140 if ( offset !== lines[line].end + 1 ) {
140141 line--;
@@ -143,6 +144,7 @@
144145 throw 'Out of range error. Offset is expected to be less than or equal to text length.';
145146 }
146147 }
 148+*/
147149
148150 /*
149151 * Offset measuring
@@ -150,14 +152,14 @@
151153 * Since the left position will be zero for the first character in the line, so we can skip
152154 * measuring for those cases.
153155 */
154 - if ( lines[line].start < offset ) {
 156+ if ( this.lines[line].start < offset ) {
155157 var $ruler = $( '<div class="editSurface-line"></div>' ).appendTo( this.$ ),
156158 ruler = $ruler[0];
157 - ruler.innerHTML = this.escape( text.substring( lines[startLine].start, offset ) );
 159+ ruler.innerHTML = this.escape( this.lines[line].text.substring( 0, offset - this.lines[line].start ) );
158160 position.left = ruler.clientWidth;
159161 $ruler.remove();
160 - }
161 -
 162+ }
 163+
162164 return position;
163165 };
164166

Status & tagging log