Bug 511982: handle pages scrolling themselves by causing the appropriate redraw (fixes acid2), r=froystig
authorVivien Nicolas <21@vingtetun.org>
Sun, 30 Aug 2009 02:37:06 -0400
changeset 65488 8ff9bcdafb49fb6059d98c37c01de8f1990f8ecf
parent 65487 61a684a960d53fe6400718432d51f9f8294f1851
child 65489 28aa63d3a0cc1e65338ec4c9a186eaf29d4f9970
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroystig
bugs511982
Bug 511982: handle pages scrolling themselves by causing the appropriate redraw (fixes acid2), r=froystig
mobile/chrome/content/BrowserView.js
--- a/mobile/chrome/content/BrowserView.js
+++ b/mobile/chrome/content/BrowserView.js
@@ -386,16 +386,17 @@ BrowserView.prototype = {
     }
 
     let currentBrowser = this._browser;
 
     let browserChanged = (currentBrowser !== browser);
 
     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
       currentBrowser.removeEventListener("FakeMozAfterSizeChange", this.handleMozAfterSizeChange, false);
       // !!! --- RESIZE HACK END -------
 
       currentBrowser.setAttribute("type", "content");
       currentBrowser.docShell.isOffScreenBrowser = false;
@@ -406,16 +407,17 @@ BrowserView.prototype = {
     this._browserViewportState = browserViewportState;
 
     if (browser) {
       browser.setAttribute("type", "content-primary");
 
       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
       browser.addEventListener("FakeMozAfterSizeChange", this.handleMozAfterSizeChange, false);
       // !!! --- RESIZE HACK END -------
 
       if (doZoom) {
         browser.docShell.isOffScreenBrowser = true;
@@ -458,16 +460,26 @@ BrowserView.prototype = {
         r.restrictTo(vs.viewportRect);
         rects.push(r);
       } catch(ex) { dump("fail\n"); }
     }
 
     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);
     let ev = document.createEvent("MouseEvents");
     ev.initMouseEvent("FakeMozAfterSizeChange", false, false, window, 0, w, h, 0, 0, false, false, false, false, 0, null);
     this._browser.dispatchEvent(ev);
   },
   // !!! --- RESIZE HACK END -------