MCPcopy Index your code
hub / github.com/TruthHun/BookStack / patchDisplay

Function patchDisplay

static/mergely/lib/codemirror.js:849–889  ·  view source on GitHub ↗
(cm, updateNumbersFrom, dims)

Source from the content-addressed store, hash-verified

847 // that are not there yet, and updating the ones that are out of
848 // date.
849 function patchDisplay(cm, updateNumbersFrom, dims) {
850 var display = cm.display, lineNumbers = cm.options.lineNumbers;
851 var container = display.lineDiv, cur = container.firstChild;
852
853 function rm(node) {
854 var next = node.nextSibling;
855 // Works around a throw-scroll bug in OS X Webkit
856 if (webkit && mac && cm.display.currentWheelTarget == node)
857 node.style.display = "none";
858 else
859 node.parentNode.removeChild(node);
860 return next;
861 }
862
863 var view = display.view, lineN = display.viewFrom;
864 // Loop over the elements in the view, syncing cur (the DOM nodes
865 // in display.lineDiv) with the view as we go.
866 for (var i = 0; i < view.length; i++) {
867 var lineView = view[i];
868 if (lineView.hidden) {
869 } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
870 var node = buildLineElement(cm, lineView, lineN, dims);
871 container.insertBefore(node, cur);
872 } else { // Already drawn
873 while (cur != lineView.node) cur = rm(cur);
874 var updateNumber = lineNumbers && updateNumbersFrom != null &&
875 updateNumbersFrom <= lineN && lineView.lineNumber;
876 if (lineView.changes) {
877 if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
878 updateLineForChanges(cm, lineView, lineN, dims);
879 }
880 if (updateNumber) {
881 removeChildren(lineView.lineNumber);
882 lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
883 }
884 cur = lineView.node.nextSibling;
885 }
886 lineN += lineView.size;
887 }
888 while (cur) cur = rm(cur);
889 }
890
891 // When an aspect of a line changes, a string is added to
892 // lineView.changes. This updates the relevant part of the line's

Callers 1

updateDisplayIfNeededFunction · 0.70

Calls 6

buildLineElementFunction · 0.70
rmFunction · 0.70
indexOfFunction · 0.70
updateLineForChangesFunction · 0.70
removeChildrenFunction · 0.70
lineNumberForFunction · 0.70

Tested by

no test coverage detected