(from, to, intact)
| 1167 | } |
| 1168 | |
| 1169 | function patchDisplay(from, to, intact) { |
| 1170 | function killNode(node) { |
| 1171 | var tmp = node.nextSibling; |
| 1172 | node.parentNode.removeChild(node); |
| 1173 | return tmp; |
| 1174 | } |
| 1175 | // The first pass removes the DOM nodes that aren't intact. |
| 1176 | if (!intact.length) removeChildren(lineDiv); |
| 1177 | else { |
| 1178 | var domPos = 0, curNode = lineDiv.firstChild, n; |
| 1179 | for (var i = 0; i < intact.length; ++i) { |
| 1180 | var cur = intact[i]; |
| 1181 | while (cur.domStart > domPos) {curNode = killNode(curNode); domPos++;} |
| 1182 | for (var j = 0, e = cur.to - cur.from; j < e; ++j) {curNode = curNode.nextSibling; domPos++;} |
| 1183 | } |
| 1184 | while (curNode) curNode = killNode(curNode); |
| 1185 | } |
| 1186 | // This pass fills in the lines that actually changed. |
| 1187 | var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from; |
| 1188 | doc.iter(from, to, function(line) { |
| 1189 | if (nextIntact && nextIntact.to == j) nextIntact = intact.shift(); |
| 1190 | if (!nextIntact || nextIntact.from > j) { |
| 1191 | if (line.hidden) var lineElement = elt("pre"); |
| 1192 | else { |
| 1193 | var lineElement = lineContent(line); |
| 1194 | if (line.className) lineElement.className = line.className; |
| 1195 | // Kludge to make sure the styled element lies behind the selection (by z-index) |
| 1196 | if (line.bgClassName) { |
| 1197 | var pre = elt("pre", "\u00a0", line.bgClassName, "position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2"); |
| 1198 | lineElement = elt("div", [pre, lineElement], null, "position: relative"); |
| 1199 | } |
| 1200 | } |
| 1201 | lineDiv.insertBefore(lineElement, curNode); |
| 1202 | } else { |
| 1203 | curNode = curNode.nextSibling; |
| 1204 | } |
| 1205 | ++j; |
| 1206 | }); |
| 1207 | } |
| 1208 | |
| 1209 | function updateGutter() { |
| 1210 | if (!options.gutter && !options.lineNumbers) return; |
no test coverage detected
searching dependent graphs…