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

Function updateHeightsInViewport

external/.scrollLibs.js:4692–4735  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

4690 // Read the actual heights of the rendered lines, and update their
4691 // stored heights to match.
4692 function updateHeightsInViewport(cm) {
4693 var display = cm.display
4694 var prevBottom = display.lineDiv.offsetTop
4695 for (var i = 0; i < display.view.length; i++) {
4696 var cur = display.view[i],
4697 wrapping = cm.options.lineWrapping
4698 var height = void 0,
4699 width = 0
4700 if (cur.hidden) {
4701 continue
4702 }
4703 if (ie && ie_version < 8) {
4704 var bot = cur.node.offsetTop + cur.node.offsetHeight
4705 height = bot - prevBottom
4706 prevBottom = bot
4707 } else {
4708 var box = cur.node.getBoundingClientRect()
4709 height = box.bottom - box.top
4710 // Check that lines don't extend past the right of the current
4711 // editor width
4712 if (!wrapping && cur.text.firstChild) {
4713 width = cur.text.firstChild.getBoundingClientRect().right - box.left - 1
4714 }
4715 }
4716 var diff = cur.line.height - height
4717 if (diff > 0.005 || diff < -0.005) {
4718 updateLineHeight(cur.line, height)
4719 updateWidgetHeight(cur.line)
4720 if (cur.rest) {
4721 for (var j = 0; j < cur.rest.length; j++) {
4722 updateWidgetHeight(cur.rest[j])
4723 }
4724 }
4725 }
4726 if (width > cm.display.sizerWidth) {
4727 var chWidth = Math.ceil(width / charWidth(cm.display))
4728 if (chWidth > cm.display.maxLineLength) {
4729 cm.display.maxLineLength = chWidth
4730 cm.display.maxLine = cur.line
4731 cm.display.maxLineChanged = true
4732 }
4733 }
4734 }
4735 }
4736
4737 // Read and store the height of line widgets associated with the
4738 // given line.

Callers 4

updateScrollbarsFunction · 0.85
endOperation_R2Function · 0.85
postUpdateDisplayFunction · 0.85
updateDisplaySimpleFunction · 0.85

Calls 3

updateLineHeightFunction · 0.85
updateWidgetHeightFunction · 0.85
charWidthFunction · 0.85

Tested by

no test coverage detected