(cm)
| 4347 | // first approximation until the line becomes visible (and is thus |
| 4348 | // properly measurable). |
| 4349 | function estimateHeight(cm) { |
| 4350 | var th = textHeight(cm.display), |
| 4351 | wrapping = cm.options.lineWrapping |
| 4352 | var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3) |
| 4353 | return function (line) { |
| 4354 | if (lineIsHidden(cm.doc, line)) { |
| 4355 | return 0 |
| 4356 | } |
| 4357 | |
| 4358 | var widgetsHeight = 0 |
| 4359 | if (line.widgets) { |
| 4360 | for (var i = 0; i < line.widgets.length; i++) { |
| 4361 | if (line.widgets[i].height) { |
| 4362 | widgetsHeight += line.widgets[i].height |
| 4363 | } |
| 4364 | } |
| 4365 | } |
| 4366 | |
| 4367 | if (wrapping) { |
| 4368 | return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th |
| 4369 | } else { |
| 4370 | return widgetsHeight + th |
| 4371 | } |
| 4372 | } |
| 4373 | } |
| 4374 | |
| 4375 | function estimateLineHeights(cm) { |
| 4376 | var doc = cm.doc, |
no test coverage detected