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

Function updateDisplayInner

GUI/codemirror/lib/codemirror.js:583–644  ·  view source on GitHub ↗
(cm, visible, forced)

Source from the content-addressed store, hash-verified

581 // (returning false) when there is nothing to be done and forced is
582 // false.
583 function updateDisplayInner(cm, visible, forced) {
584 var display = cm.display, doc = cm.doc;
585 if (!display.wrapper.offsetWidth) {
586 resetView(cm);
587 return;
588 }
589
590 // Bail out if the visible area is already rendered and nothing changed.
591 if (!forced && visible.from >= display.viewFrom && visible.to <= display.viewTo &&
592 countDirtyView(cm) == 0)
593 return;
594
595 if (maybeUpdateLineNumberWidth(cm))
596 resetView(cm);
597 var dims = getDimensions(cm);
598
599 // Compute a suitable new viewport (from & to)
600 var end = doc.first + doc.size;
601 var from = Math.max(visible.from - cm.options.viewportMargin, doc.first);
602 var to = Math.min(end, visible.to + cm.options.viewportMargin);
603 if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
604 if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
605 if (sawCollapsedSpans) {
606 from = visualLineNo(cm.doc, from);
607 to = visualLineEndNo(cm.doc, to);
608 }
609
610 var different = from != display.viewFrom || to != display.viewTo ||
611 display.lastSizeC != display.wrapper.clientHeight;
612 adjustView(cm, from, to);
613
614 display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
615 // Position the mover div to align with the current scroll position
616 cm.display.mover.style.top = display.viewOffset + "px";
617
618 var toUpdate = countDirtyView(cm);
619 if (!different && toUpdate == 0 && !forced) return;
620
621 // For big changes, we hide the enclosing element during the
622 // update, since that speeds up the operations on most browsers.
623 var focused = activeElt();
624 if (toUpdate > 4) display.lineDiv.style.display = "none";
625 patchDisplay(cm, display.updateLineNumbers, dims);
626 if (toUpdate > 4) display.lineDiv.style.display = "";
627 // There might have been a widget with a focused element that got
628 // hidden or updated, if so re-focus it.
629 if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
630
631 // Prevent selection and cursors from interfering with the scroll
632 // width.
633 removeChildren(display.cursorDiv);
634 removeChildren(display.selectionDiv);
635
636 if (different) {
637 display.lastSizeC = display.wrapper.clientHeight;
638 startWorker(cm, 400);
639 }
640

Callers 1

updateDisplayFunction · 0.85

Calls 14

resetViewFunction · 0.85
countDirtyViewFunction · 0.85
getDimensionsFunction · 0.85
visualLineNoFunction · 0.85
visualLineEndNoFunction · 0.85
adjustViewFunction · 0.85
heightAtLineFunction · 0.85
getLineFunction · 0.85
activeEltFunction · 0.85
patchDisplayFunction · 0.85
removeChildrenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…