diff --git a/chrome/content/browser.js b/chrome/content/browser.js --- a/chrome/content/browser.js +++ b/chrome/content/browser.js @@ -1364,31 +1364,101 @@ Browser.MainDragger.prototype = { } catch(e) {} if (scrollable) { this.contentScrollbox = wrapper.scrollBoxObject || wrapper.boxObject.QueryInterface(Ci.nsIScrollBoxObject); return; } } } + this.showScrollBars(); + this.drawScrollBars(); if (element) this.draggedFrame = element.ownerDocument.defaultView; this.bv.pauseRendering(); }, dragStop: function dragStop(dx, dy, scroller) { this.draggedFrame = null; this.dragMove(Browser.snapSidebars(), 0, scroller); Browser.tryUnfloatToolbar(); + this.hideScrollBars(); + this.bv.resumeRendering(); }, + kScrollBarWidth : 10, + + showScrollBars: function showScrollBars() { + let [vpWidth, vpHeight] = Browser._browserView.getViewportDimensions(); + let visibleRect = Browser._browserView.getVisibleRect(); + if (vpHeight > visibleRect.height) { + let scroll = document.getElementById("scrollbar-y"); + scroll.setAttribute("left", visibleRect.width - this.kScrollBarWidth); + scroll.setAttribute("top", 0); + scroll.width = this.kScrollBarWidth; + scroll.height = visibleRect.height; + scroll.style.display = "block"; + } + if (vpWidth > visibleRect.width) { + let scroll = document.getElementById("scrollbar-x"); + scroll.setAttribute("left", 0); + scroll.setAttribute("top", visibleRect.height - this.kScrollBarWidth); + scroll.width = visibleRect.width; + scroll.height = this.kScrollBarWidth; + scroll.style.display = "block"; + } + }, + + drawScrollBars: function drawScrollBars() { + let [vpWidth, vpHeight] = Browser._browserView.getViewportDimensions(); + let visibleRect = Browser._browserView.getVisibleRect(); + let scrollpoint = Browser.getScrollboxPosition(Browser.contentScrollboxScroller); + + // vertical scrollbar + if (vpHeight > visibleRect.height) { + let scroll = document.getElementById("scrollbar-y"); + let y = Math.round(scrollpoint.y * visibleRect.height / vpHeight); + let height = Math.round(visibleRect.height * visibleRect.height / vpHeight); + let width = this.kScrollBarWidth; + let ctx = scroll.getContext("2d"); + ctx.save(); + ctx.clearRect(0, 0, scroll.width, scroll.height); + ctx.fillStyle = "rgba(0, 145, 255, .5)"; + ctx.strokeStyle = "rgb(0, 145, 255)"; + ctx.strokeRect(0, y, width, height); + ctx.fillRect(0, y, width, height); + ctx.restore(); + } + + // horizontal scrollbar + if (vpWidth > visibleRect.width) { + let scroll = document.getElementById("scrollbar-x"); + x = Math.round(scrollpoint.x * visibleRect.width / vpWidth); + let width = Math.round(visibleRect.width * visibleRect.width / vpWidth); + let height = this.kScrollBarWidth; + let ctx = scroll.getContext("2d"); + ctx.save(); + ctx.clearRect(0, 0, scroll.width, scroll.height); + ctx.fillStyle = "rgba(0, 145, 255, .5)"; + ctx.strokeStyle = "rgb(0, 145, 255)"; + ctx.strokeRect(x, 0, width, height); + ctx.fillRect(x, 0, width, height); + ctx.restore(); + } + }, + + hideScrollBars: function hideScrollBars() { + document.getElementById("scrollbar-y").style.display = "none"; + document.getElementById("scrollbar-x").style.display = "none"; + }, + dragMove: function dragMove(dx, dy, scroller) { let elem = this.draggedFrame; let doffset = new Point(dx, dy); let render = false; this.bv.onBeforeVisibleMove(dx, dy); // First calculate any panning to take sidebars out of view @@ -1412,16 +1482,18 @@ Browser.MainDragger.prototype = { // Any leftover panning in doffset would bring controls into view. Add to sidebar // away panning for the total scroll offset. doffset.add(panOffset); Browser.tryFloatToolbar(doffset.x, 0); this._panScroller(Browser.controlsScrollboxScroller, doffset); this._panScroller(Browser.pageScrollboxScroller, doffset); + this.drawScrollBars(); + this.bv.onAfterVisibleMove(); if (render) this.bv.renderNow(); return !doffset.equals(dx, dy); }, diff --git a/chrome/content/browser.xul b/chrome/content/browser.xul --- a/chrome/content/browser.xul +++ b/chrome/content/browser.xul @@ -238,22 +238,22 @@ - + - +