(cm)
| 330 | // Re-synchronize the fake scrollbars with the actual size of the |
| 331 | // content. Optionally force a scrollTop. |
| 332 | function updateScrollbars(cm) { |
| 333 | var d = cm.display, docHeight = cm.doc.height; |
| 334 | var totalHeight = docHeight + paddingVert(d); |
| 335 | d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px"; |
| 336 | d.gutters.style.height = Math.max(totalHeight, d.scroller.clientHeight - scrollerCutOff) + "px"; |
| 337 | var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight); |
| 338 | var needsH = d.scroller.scrollWidth > (d.scroller.clientWidth + 1); |
| 339 | var needsV = scrollHeight > (d.scroller.clientHeight + 1); |
| 340 | if (needsV) { |
| 341 | d.scrollbarV.style.display = "block"; |
| 342 | d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0"; |
| 343 | // A bug in IE8 can cause this value to be negative, so guard it. |
| 344 | d.scrollbarV.firstChild.style.height = |
| 345 | Math.max(0, scrollHeight - d.scroller.clientHeight + d.scrollbarV.clientHeight) + "px"; |
| 346 | } else { |
| 347 | d.scrollbarV.style.display = ""; |
| 348 | d.scrollbarV.firstChild.style.height = "0"; |
| 349 | } |
| 350 | if (needsH) { |
| 351 | d.scrollbarH.style.display = "block"; |
| 352 | d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0"; |
| 353 | d.scrollbarH.firstChild.style.width = |
| 354 | (d.scroller.scrollWidth - d.scroller.clientWidth + d.scrollbarH.clientWidth) + "px"; |
| 355 | } else { |
| 356 | d.scrollbarH.style.display = ""; |
| 357 | d.scrollbarH.firstChild.style.width = "0"; |
| 358 | } |
| 359 | if (needsH && needsV) { |
| 360 | d.scrollbarFiller.style.display = "block"; |
| 361 | d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px"; |
| 362 | } else d.scrollbarFiller.style.display = ""; |
| 363 | if (needsH && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { |
| 364 | d.gutterFiller.style.display = "block"; |
| 365 | d.gutterFiller.style.height = scrollbarWidth(d.measure) + "px"; |
| 366 | d.gutterFiller.style.width = d.gutters.offsetWidth + "px"; |
| 367 | } else d.gutterFiller.style.display = ""; |
| 368 | |
| 369 | if (mac_geLion && scrollbarWidth(d.measure) === 0) { |
| 370 | d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px"; |
| 371 | d.scrollbarV.style.pointerEvents = d.scrollbarH.style.pointerEvents = "none"; |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | function visibleLines(display, doc, viewPort) { |
| 376 | var top = display.scroller.scrollTop, height = display.wrapper.clientHeight; |
no test coverage detected