(cm)
| 271 | // first approximation until the line becomes visible (and is thus |
| 272 | // properly measurable). |
| 273 | function estimateHeight(cm) { |
| 274 | var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; |
| 275 | var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); |
| 276 | return function(line) { |
| 277 | if (lineIsHidden(cm.doc, line)) return 0; |
| 278 | |
| 279 | var widgetsHeight = 0; |
| 280 | if (line.widgets) for (var i = 0; i < line.widgets.length; i++) { |
| 281 | if (line.widgets[i].height) widgetsHeight += line.widgets[i].height; |
| 282 | } |
| 283 | |
| 284 | if (wrapping) |
| 285 | return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th; |
| 286 | else |
| 287 | return widgetsHeight + th; |
| 288 | }; |
| 289 | } |
| 290 | |
| 291 | function estimateLineHeights(cm) { |
| 292 | var doc = cm.doc, est = estimateHeight(cm); |
no test coverage detected