(cm, coords)
| 4604 | // If an editor sits on the top or bottom of the window, partially |
| 4605 | // scrolled out of view, this ensures that the cursor is visible. |
| 4606 | function maybeScrollWindow(cm, coords) { |
| 4607 | if (signalDOMEvent(cm, "scrollCursorIntoView")) return; |
| 4608 | |
| 4609 | var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; |
| 4610 | if (coords.top + box.top < 0) doScroll = true; |
| 4611 | else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; |
| 4612 | if (doScroll != null && !phantom) { |
| 4613 | var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + |
| 4614 | (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + |
| 4615 | (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " + |
| 4616 | coords.left + "px; width: 2px;"); |
| 4617 | cm.display.lineSpace.appendChild(scrollNode); |
| 4618 | scrollNode.scrollIntoView(doScroll); |
| 4619 | cm.display.lineSpace.removeChild(scrollNode); |
| 4620 | } |
| 4621 | } |
| 4622 | |
| 4623 | // Scroll a given position into view (immediately), verifying that |
| 4624 | // it actually became visible (as line heights are accurately |
no test coverage detected