(display)
| 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; |
no test coverage detected