MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / textHeight

Function textHeight

static/js/codemirror/codemirror.js:1181–1198  ·  view source on GitHub ↗
(display)

Source from the content-addressed store, hash-verified

1179
1180 var measureText;
1181 function textHeight(display) {
1182 if (display.cachedTextHeight != null) return display.cachedTextHeight;
1183 if (measureText == null) {
1184 measureText = elt("pre");
1185 // Measure a bunch of lines, for browsers that compute
1186 // fractional heights.
1187 for (var i = 0; i < 49; ++i) {
1188 measureText.appendChild(document.createTextNode("x"));
1189 measureText.appendChild(elt("br"));
1190 }
1191 measureText.appendChild(document.createTextNode("x"));
1192 }
1193 removeChildrenAndAdd(display.measure, measureText);
1194 var height = measureText.offsetHeight / 50;
1195 if (height > 3) display.cachedTextHeight = height;
1196 removeChildren(display.measure);
1197 return height || 1;
1198 }
1199
1200 function charWidth(display) {
1201 if (display.cachedCharWidth != null) return display.cachedCharWidth;

Callers 3

estimateHeightFunction · 0.85
updateDisplayInnerFunction · 0.85
codemirror.jsFile · 0.85

Calls 3

eltFunction · 0.85
removeChildrenAndAddFunction · 0.85
removeChildrenFunction · 0.85

Tested by

no test coverage detected