Bug 519231: Backing out bug 514623, r=stechz
authorMark Finkle <mfinkle@mozilla.com>
Mon, 28 Sep 2009 14:16:51 -0400
changeset 65615 860abdf603de697aa765ddf6e8ece13fc938d00d
parent 65614 453cebf6f8bce871f1291755f1ffae211d37ba0d
child 65616 3062d6e242c220efb0c3576539fe91e92d816be7
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)
reviewersstechz
bugs519231, 514623
Bug 519231: Backing out bug 514623, r=stechz
mobile/chrome/content/BrowserView.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/BrowserView.js
+++ b/mobile/chrome/content/BrowserView.js
@@ -229,17 +229,16 @@ BrowserView.prototype = {
     this._batchOps = [];
     this._container = container;
     this._browser = null;
     this._browserViewportState = null;
     this._contentWindow = null;
     this._renderMode = 0;
     this._tileManager = new TileManager(this._appendTile, this._removeTile, this);
     this._visibleRectFactory = visibleRectFactory;
-    this._ignorePageScroll = false;
   },
 
   getVisibleRect: function getVisibleRect() {
     return this._visibleRectFactory();
   },
 
   setViewportDimensions: function setViewportDimensions(width, height, causedByZoom) {
     let bvs = this._browserViewportState;
@@ -392,17 +391,16 @@ BrowserView.prototype = {
 
       this._browser.setAttribute("type", "content");
       this._browser.docShell.isOffScreenBrowser = false;
     }
 
     this._browser = browser;
     this._contentWindow = (browser) ? browser.contentWindow : null;
     this._browserViewportState = browserViewportState;
-    this._ignorePageScroll = false;
 
     if (browser) {
       browser.setAttribute("type", "content-primary");
 
       this.beginBatchOperation();
 
       browser.addEventListener("MozAfterPaint", this.handleMozAfterPaint, false);
       browser.addEventListener("scroll", this.handlePageScroll, false);
@@ -453,65 +451,25 @@ BrowserView.prototype = {
         r.restrictTo(vs.viewportRect);
         rects.push(r);
       } catch(ex) { /* dump("fail\n"); */ }
     }
 
     tm.dirtyRects(rects, this.isRendering());
   },
 
-  _scrollTo: function _scrollTo(frame, x, y) {
-    let origX = {}, origY = {}, newX = {}, newY = {};
-    let windowUtils = frame.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
-
-    windowUtils.getScrollXY(false, origX, origY);
-    frame.scrollTo(x, y);
-    windowUtils.getScrollXY(false, newX, newY);
-
-    return newX.value != origX.value || newY.value != origY.value;
-  },
-  
-  /** Let current browser's scrollbox know about where content has been panned. */
-  scrollBrowserToContent: function scrollBrowserToContent() {
-    let browser = this._browser;
-    if (browser) {
-      let offsetY = document.getElementById("toolbar-container").getBoundingClientRect().height;
-      let [contentX, contentY] = Browser.getScrollboxPosition(Browser.contentScrollboxScroller);
-
-      let windowUtils = BrowserView.Util.getBrowserDOMWindowUtils(browser);
-      if (this._scrollTo(browser.contentWindow,
-          this.viewportToBrowser(contentX),
-          this.viewportToBrowser(contentY - offsetY))) {
-        this._ignorePageScroll = true;
-      }
-    }
-  },
-
-  /** Update content panning to location of browser's scrollbars. */
-  scrollContentToBrowser: function scrollContentToBrowser() {
-    let [viewportX, viewportY] = BrowserView.Util.getContentScrollValues(this._browser);
-    viewportX = this.browserToViewport(viewportX);
-    viewportY = this.browserToViewport(viewportY);
-    let offsetY = document.getElementById("toolbar-container").getBoundingClientRect().height;
-
-    Browser.contentScrollboxScroller.scrollTo(viewportX, viewportY + offsetY);
-    this.onAfterVisibleMove();
-  },
-
   /** If browser scrolls, pan content to new scroll area. */
   handlePageScroll: function handlePageScroll(aEvent) {
     if (aEvent.target != this._browser.contentDocument)
       return;
-    if (this._ignorePageScroll) {
-      // Ignore events caused by updating browser's scrollbox to content.
-      this._ignorePageScroll = false;
-      return;
-    }
 
-    this.scrollContentToBrowser();
+    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);
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -605,16 +605,17 @@ var Browser = {
 
     // round here because when going to full screen, this value tends
     // to be very small but negative
     let dx = Math.round(containerBCR.left);
     if (dx < 0)
       dx = Math.min(Math.round(containerBCR.right - window.innerWidth), 0);
 
     this.controlsScrollboxScroller.scrollBy(dx, 0);
+    Browser.contentScrollbox.customDragger.scrollingOuterX = false; // XXX ugh.
     this._browserView.onAfterVisibleMove();
   },
 
   /**
    * Return the currently active <browser> object
    */
   get selectedBrowser() {
     return this._selectedTab.browser;
@@ -955,21 +956,16 @@ var Browser = {
       } else {
         snappedX = -ritevis * ritew;
       }
     }
 
     return Math.round(snappedX);
   },
 
-  floatToolbar: function floatToolbar() {
-    BrowserUI.lockToolbar();
-    this.floatedWhileDragging = true;
-  },
-
   tryFloatToolbar: function tryFloatToolbar(dx, dy) {
     if (this.floatedWhileDragging)
       return;
 
     let [leftvis, ritevis, leftw, ritew] = Browser.computeSidebarVisibility(dx, dy);
     // XXX computeSideBarVisibility will normally return 0.0015... for ritevis
     if (leftvis > 0.002 || ritevis > 0.002) {
       BrowserUI.lockToolbar();
@@ -1042,18 +1038,17 @@ var Browser = {
     bv.setZoomLevel(zoomLevel);
 
     bv.forceContainerResize();
     //Browser.forceChromeReflow();
 
     let dx = Math.round(bv.browserToViewport(elRect.left) - margin - vis.left);
     let dy = Math.round(bv.browserToViewport(elementY) - (window.innerHeight / 2) - vis.top);
 
-    Browser.contentScrollboxScroller.scrollBy(dx, dy);
-    bv.scrollBrowserToContent();
+    Browser.contentScrollbox.customDragger.dragMove(dx, dy, scroller);
     bv.commitBatchOperation();
 
     return true;
   },
 
   zoomFromPoint: function zoomFromPoint(cX, cY) {
     let [elementX, elementY] = this.transformClientToBrowser(cX, cY);
 
@@ -1062,18 +1057,17 @@ var Browser = {
     bv.beginBatchOperation();
 
     bv.zoomToPage();
 
     bv.forceContainerResize();
 
     let dy = Math.round(bv.browserToViewport(elementY) - (window.innerHeight / 2) - bv.getVisibleRect().top);
 
-    Browser.contentScrollboxScroller.scrollBy(0, dy);
-    bv.scrollBrowserToContent();
+    this.contentScrollbox.customDragger.dragMove(0, dy, this.contentScrollboxScroller);
 
     Browser.forceChromeReflow();
 
     this.hideSidebars();
 
     bv.commitBatchOperation();
   },
 
@@ -1216,18 +1210,17 @@ Browser.MainDragger.prototype = {
     if (element)
       this.draggedFrame = element.ownerDocument.defaultView;
 
     this.bv.pauseRendering();
   },
 
   dragStop: function dragStop(dx, dy, scroller) {
     this.draggedFrame = null;
-    this.dragMove(Browser.snapSidebars(), 0);
-    this.bv.scrollBrowserToContent();
+    this.dragMove(Browser.snapSidebars(), 0, scroller);
 
     Browser.tryUnfloatToolbar();
 
     this.bv.resumeRendering();
   },
 
   dragMove: function dragMove(dx, dy, scroller) {
     let elem = this.draggedFrame;
@@ -2338,23 +2331,16 @@ Tab.prototype = {
       // !!! --- RESIZE HACK END -----
 
       let restoringPage = (this._state != null);
 
       if (!this._browserViewportState.zoomChanged && !restoringPage) {
         // Only fit page if user hasn't started zooming around and this is a page that
         // isn't being restored.
         bv.zoomToPage();
-        if (this.browser.contentWindow.scrollX != 0 || this.browser.contentWindow.scrollY != 0) {
-          // XXX We want to jump to anchors but not scroll to top of page (removing urlbar)
-          bv.scrollContentToBrowser();
-          Browser.floatToolbar();
-        }
-
-        bv.onAfterVisibleMove();
       }
 
     }
     bv.commitBatchOperation();
 
     if (this._loading) {
       // kick ourselves off 2s later while we're still loading
       bv.beginBatchOperation();