Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Content.js |
— | — | @@ -1,28 +1,3 @@ |
2 | | -/** |
3 | | - * Creates an ve.es.Content object. |
4 | | - * |
5 | | - * A content view flows text into a DOM element and provides methods to get information about the |
6 | | - * rendered output. HTML serialized specifically for rendering into and editing surface. |
7 | | - * |
8 | | - * Rendering occurs automatically when content is modified, by responding to "update" events from |
9 | | - * the model. Rendering is iterative and interruptable to reduce user feedback latency. |
10 | | - * |
11 | | - * TODO: Cleanup code and comments |
12 | | - * |
13 | | - * @class |
14 | | - * @constructor |
15 | | - * @param {jQuery} $container Element to render into |
16 | | - * @param {ve.ModelNode} model Model to produce view for |
17 | | - * @property {jQuery} $ |
18 | | - * @property {ve.ContentModel} model |
19 | | - * @property {Array} boundaries |
20 | | - * @property {Array} lines |
21 | | - * @property {Integer} width |
22 | | - * @property {RegExp} bondaryTest |
23 | | - * @property {Object} widthCache |
24 | | - * @property {Object} renderState |
25 | | - * @property {Object} contentCache |
26 | | - */ |
27 | 2 | ve.es.Content = function( $container, model ) { |
28 | 3 | // Inheritance |
29 | 4 | ve.EventEmitter.call( this ); |
— | — | @@ -30,13 +5,6 @@ |
31 | 6 | // Properties |
32 | 7 | this.$ = $container; |
33 | 8 | this.model = model; |
34 | | - this.boundaries = []; |
35 | | - this.lines = []; |
36 | | - this.width = null; |
37 | | - this.boundaryTest = /([ \-\t\r\n\f])/g; |
38 | | - this.widthCache = {}; |
39 | | - this.renderState = {}; |
40 | | - this.contentCache = null; |
41 | 9 | |
42 | 10 | if ( model ) { |
43 | 11 | // Events |
— | — | @@ -44,9 +12,6 @@ |
45 | 13 | this.model.on( 'update', function( offset ) { |
46 | 14 | _this.render( offset || 0 ); |
47 | 15 | } ); |
48 | | - |
49 | | - // Initialization |
50 | | - this.scanBoundaries(); |
51 | 16 | } |
52 | 17 | }; |
53 | 18 | |
— | — | @@ -202,50 +167,6 @@ |
203 | 168 | |
204 | 169 | /* Methods */ |
205 | 170 | |
206 | | -/** |
207 | | - * Updates the word boundary cache, which is used for word fitting. |
208 | | - * |
209 | | - * @method |
210 | | - */ |
211 | | -ve.es.Content.prototype.scanBoundaries = function() { |
212 | | - /* |
213 | | - * Word boundary scan |
214 | | - * |
215 | | - * To perform binary-search on words, rather than characters, we need to collect word boundary |
216 | | - * offsets into an array. The offset of the right side of the breaking character is stored, so |
217 | | - * the gaps between stored offsets always include the breaking character at the end. |
218 | | - * |
219 | | - * To avoid encoding the same words as HTML over and over while fitting text to lines, we also |
220 | | - * build a list of HTML escaped strings for each gap between the offsets stored in the |
221 | | - * "boundaries" array. Slices of the "words" array can be joined, producing the escaped HTML of |
222 | | - * the words. |
223 | | - */ |
224 | | - // Get and cache a copy of all content, the make a plain-text version of the cached content |
225 | | - var data = this.contentCache = this.model.getContentData(), |
226 | | - text = ''; |
227 | | - for ( var i = 0, length = data.length; i < length; i++ ) { |
228 | | - text += typeof data[i] === 'string' ? data[i] : data[i][0]; |
229 | | - } |
230 | | - // Purge "boundaries" and "words" arrays |
231 | | - this.boundaries = [0]; |
232 | | - // Reset RegExp object's state |
233 | | - this.boundaryTest.lastIndex = 0; |
234 | | - // Iterate over each word+boundary sequence, capturing offsets and encoding text as we go |
235 | | - var match, |
236 | | - end; |
237 | | - while ( ( match = this.boundaryTest.exec( text ) ) ) { |
238 | | - // Include the boundary character in the range |
239 | | - end = match.index + 1; |
240 | | - // Store the boundary offset |
241 | | - this.boundaries.push( end ); |
242 | | - } |
243 | | - // If the last character is not a boundary character, we need to append the final range to the |
244 | | - // "boundaries" and "words" arrays |
245 | | - if ( end < text.length || this.boundaries.length === 1 ) { |
246 | | - this.boundaries.push( text.length ); |
247 | | - } |
248 | | -}; |
249 | | - |
250 | 171 | ve.es.Content.prototype.render = function( offset ) { |
251 | 172 | this.$.html( this.getHtml( 0, this.model.getContentLength() ) ); |
252 | 173 | }; |
— | — | @@ -263,7 +184,7 @@ |
264 | 185 | } else { |
265 | 186 | range = { 'start': 0, 'end': undefined }; |
266 | 187 | } |
267 | | - var data = this.contentCache.slice( range.start, range.end ), |
| 188 | + var data = this.model.getContentData(), |
268 | 189 | render = ve.es.Content.renderAnnotation, |
269 | 190 | htmlChars = ve.es.Content.htmlCharacters; |
270 | 191 | var out = '', |