MCPcopy Index your code
hub / github.com/DHTMLX/gantt / patchDisplay

Function patchDisplay

samples/common/codehighlight/codemirror.js:4195–4234  ·  view source on GitHub ↗
(cm, updateNumbersFrom, dims)

Source from the content-addressed store, hash-verified

4193 // that are not there yet, and updating the ones that are out of
4194 // date.
4195 function patchDisplay(cm, updateNumbersFrom, dims) {
4196 var display = cm.display, lineNumbers = cm.options.lineNumbers;
4197 var container = display.lineDiv, cur = container.firstChild;
4198
4199 function rm(node) {
4200 var next = node.nextSibling;
4201 // Works around a throw-scroll bug in OS X Webkit
4202 if (webkit && mac && cm.display.currentWheelTarget == node)
4203 { node.style.display = "none"; }
4204 else
4205 { node.parentNode.removeChild(node); }
4206 return next
4207 }
4208
4209 var view = display.view, lineN = display.viewFrom;
4210 // Loop over the elements in the view, syncing cur (the DOM nodes
4211 // in display.lineDiv) with the view as we go.
4212 for (var i = 0; i < view.length; i++) {
4213 var lineView = view[i];
4214 if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
4215 var node = buildLineElement(cm, lineView, lineN, dims);
4216 container.insertBefore(node, cur);
4217 } else { // Already drawn
4218 while (cur != lineView.node) { cur = rm(cur); }
4219 var updateNumber = lineNumbers && updateNumbersFrom != null &&
4220 updateNumbersFrom <= lineN && lineView.lineNumber;
4221 if (lineView.changes) {
4222 if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
4223 updateLineForChanges(cm, lineView, lineN, dims);
4224 }
4225 if (updateNumber) {
4226 removeChildren(lineView.lineNumber);
4227 lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
4228 }
4229 cur = lineView.node.nextSibling;
4230 }
4231 lineN += lineView.size;
4232 }
4233 while (cur) { cur = rm(cur); }
4234 }
4235
4236 function updateGutterSpace(display) {
4237 var width = display.gutters.offsetWidth;

Callers 1

updateDisplayIfNeededFunction · 0.85

Calls 6

buildLineElementFunction · 0.85
rmFunction · 0.85
indexOfFunction · 0.85
updateLineForChangesFunction · 0.85
removeChildrenFunction · 0.85
lineNumberForFunction · 0.85

Tested by

no test coverage detected