diff --git a/chrome/content/browser.js b/chrome/content/browser.js --- a/chrome/content/browser.js +++ b/chrome/content/browser.js @@ -1219,63 +1219,83 @@ var Browser = { */ getScrollboxPosition: function getScrollboxPosition(scroller) { let x = {}; let y = {}; scroller.getPosition(x, y); return [x.value, y.value]; }, + /** + * Convenience function for getting the scrollbox content size off of a + * scrollBoxObject interface. Returns the actual values instead of the + * wrapping objects. + * + * @param scroller a scrollBoxObject on which to call scroller.getScrolledSize() + */ + getScrollboxSize: function getScrollboxSize(scroller) { + let width = {}; + let height = {}; + scroller.getScrolledSize(width, height); + return [width.value, height.value]; + }, + forceChromeReflow: function forceChromeReflow() { let dummy = getComputedStyle(document.documentElement, "").width; } }; Browser.MainDragger = function MainDragger(browserView) { this.allowRealtimeDownUp = true; this.scrollingOuterX = false; this.bv = browserView; this.floatedWhileDragging = false; this.draggedFrame = null; + + this.vmarker = document.getElementById("vscroll-marker"); + this.hmarker = document.getElementById("hscroll-marker"); }; Browser.MainDragger.prototype = { - dragStart: function dragStart(clientX, clientY, target, scroller) { this.draggedFrame = null; if (this._targetIsContent(target)) { // since we're dealing with content, look to see if user has started // a drag while over a IFRAME/FRAME element let [x, y] = Browser.transformClientToBrowser(clientX, clientY); let element = Browser.elementFromPoint(x, y); if (element && element.ownerDocument != Browser.selectedBrowser.contentDocument) { Util.dumpLn("*** dragStart got element ", element, " ownerDoc ", element.ownerDocument, " selectedBrowser.contentDoc ", Browser.selectedBrowser.contentDocument); this.draggedFrame = element.ownerDocument.defaultView; } } + this._showMarkers(true); + this.bv.pauseRendering(); }, dragStop: function dragStop(dx, dy, scroller) { let dx = this.dragMove(dx, dy, scroller, true); dx += this.dragMove(Browser.snapSidebars(), 0, scroller, true); /* XXX * Set scrollingOuterX to be true when the sidebars are open. * We should really just take a look at our geometry at this point * and determine this ourselves rather than relying on our helper * functions to give us this information */ this.scrollingOuterX = !Browser.tryUnfloatToolbar(); + + this._showMarkers(false); this.bv.resumeRendering(); return (dx != 0) || (dy != 0); }, dragMove: function dragMove(dx, dy, scroller, doReturnDX) { let outrv = 0; @@ -1324,16 +1344,19 @@ Browser.MainDragger.prototype = { scroller.scrollBy(dx, dy); let [x1, y1] = Browser.getScrollboxPosition(scroller); let realdx = x1 - x0; let realdy = y1 - y0; this.bv.onAfterVisibleMove(); + let [w, h] = Browser.getScrollboxSize(scroller); + this._updateMarkers(Browser.contentScrollbox.getBoundingClientRect(), x1, y1, w, h); + //dump(" dx, realdx: " + dx + " " + realdx + "\n"); if (realdx != dx) { let restdx = dx - realdx; this.scrollingOuterX = true; this.dragMove(restdx, 0, scroller, doReturnDX); } @@ -1403,18 +1426,45 @@ Browser.MainDragger.prototype = { if (target === window) return false; if (target === tileBox) return true; target = target.parentNode; } return false; + }, + + _updateMarkers : function _updateMarkers(rect, scrollX, scrollY, contentW, contentH) { + const SCROLLMARKER_SIZE = 10; + + let viewW = rect.width; + let viewH = rect.height; + + // Get the marker sizes or collaspe to zero if markers aren't needed + let markerH = (viewH < contentH ? (viewH * viewH) / contentH : 0); + let markerW = (viewW < contentW ? (viewW * viewW) / contentW : 0); + + // Position and size the markers + this.vmarker.style.height = markerH + "px"; + this.vmarker.top = (scrollY * viewH) / contentH; + this.vmarker.left = rect.right - SCROLLMARKER_SIZE - rect.left; + + this.hmarker.style.width = markerW + "px"; + this.hmarker.top = rect.bottom - (viewW < contentW ? SCROLLMARKER_SIZE : 0); + this.hmarker.left = (scrollX * viewW) / contentW; + }, + + _showMarkers : function(aShow) { + this.vmarker.style.height = "0px"; + this.vmarker.hidden = !aShow; + + this.hmarker.style.width = "0px"; + this.hmarker.hidden = !aShow; } - }; function nsBrowserAccess() { } nsBrowserAccess.prototype = { QueryInterface: function(aIID) { diff --git a/chrome/content/browser.xul b/chrome/content/browser.xul --- a/chrome/content/browser.xul +++ b/chrome/content/browser.xul @@ -460,16 +460,19 @@ + +