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