MCPcopy Create free account
hub / github.com/sql-js/sql.js / estimateHeight

Function estimateHeight

GUI/codemirror/lib/codemirror.js:272–288  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

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

Callers 4

estimateLineHeightsFunction · 0.85
codemirror.jsFile · 0.85
updateLineFunction · 0.85

Calls 3

textHeightFunction · 0.85
charWidthFunction · 0.85
lineIsHiddenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…