MCPcopy Create free account
hub / github.com/breck7/scroll / textHeight

Function textHeight

external/.scrollLibs.js:4286–4307  ·  view source on GitHub ↗
(display)

Source from the content-addressed store, hash-verified

4284 var measureText
4285 // Compute the default text height.
4286 function textHeight(display) {
4287 if (display.cachedTextHeight != null) {
4288 return display.cachedTextHeight
4289 }
4290 if (measureText == null) {
4291 measureText = elt("pre")
4292 // Measure a bunch of lines, for browsers that compute
4293 // fractional heights.
4294 for (var i = 0; i < 49; ++i) {
4295 measureText.appendChild(document.createTextNode("x"))
4296 measureText.appendChild(elt("br"))
4297 }
4298 measureText.appendChild(document.createTextNode("x"))
4299 }
4300 removeChildrenAndAdd(display.measure, measureText)
4301 var height = measureText.offsetHeight / 50
4302 if (height > 3) {
4303 display.cachedTextHeight = height
4304 }
4305 removeChildren(display.measure)
4306 return height || 1
4307 }
4308
4309 // Compute the default character width.
4310 function charWidth(display) {

Callers 5

estimateHeightFunction · 0.85
calculateScrollPosFunction · 0.85
.scrollLibs.jsFile · 0.85
addEditorMethodsFunction · 0.85
findPosVFunction · 0.85

Calls 3

eltFunction · 0.85
removeChildrenAndAddFunction · 0.85
removeChildrenFunction · 0.85

Tested by

no test coverage detected