diff --git a/mobile/chrome/content/BrowserView.js b/mobile/chrome/content/BrowserView.js index 4bc49bdc10f..18915aa6682 100644 --- a/mobile/chrome/content/BrowserView.js +++ b/mobile/chrome/content/BrowserView.js @@ -391,6 +391,7 @@ BrowserView.prototype = { if (currentBrowser) { currentBrowser.removeEventListener("MozAfterPaint", this.handleMozAfterPaint, false); + currentBrowser.removeEventListener("scroll", this.handlePageScroll, false); // !!! --- RESIZE HACK BEGIN ----- // change to the real event type and perhaps refactor the handler function name @@ -411,6 +412,7 @@ BrowserView.prototype = { this.beginBatchOperation(); browser.addEventListener("MozAfterPaint", this.handleMozAfterPaint, false); + browser.addEventListener("scroll", this.handlePageScroll, false); // !!! --- RESIZE HACK BEGIN ----- // change to the real event type and perhaps refactor the handler function name @@ -463,6 +465,16 @@ BrowserView.prototype = { tm.dirtyRects(rects, this.isRendering()); }, + handlePageScroll: function handlePageScroll(aEvent) { + if (aEvent.target != this._browser.contentDocument) + return; + + let [scrollX, scrollY] = BrowserView.Util.getContentScrollValues(this._browser); + Browser.contentScrollboxScroller.scrollTo(this.browserToViewport(scrollX), + this.browserToViewport(scrollY)); + this.onAfterVisibleMove(); + }, + // !!! --- RESIZE HACK BEGIN ----- simulateMozAfterSizeChange: function simulateMozAfterSizeChange() { let [w, h] = BrowserView.Util.getBrowserDimensions(this._browser);