don't use moz transforms because they are slow right now
authorBenjamin Stover <bstover@mozilla.com>
Wed, 18 Aug 2010 19:43:14 -0700
changeset 66596 4e92db90e8dafaa15a21a47cdb06acc284552076
parent 66595 c22dc6c4e377b43481b87cc5039497ccc59764e5
child 66597 0a9b7b932275848e7afb6a74ec91d1d34263a475
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)
don't use moz transforms because they are slow right now
mobile/chrome/content/BrowserView.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/BrowserView.js
+++ b/mobile/chrome/content/BrowserView.js
@@ -152,33 +152,16 @@ BrowserView.Util = {
   visibleRectToCriticalRect: function visibleRectToCriticalRect(visibleRect, browserViewportState) {
     return visibleRect.intersect(browserViewportState.viewportRect);
   },
 
   createBrowserViewportState: function createBrowserViewportState() {
     return new BrowserView.BrowserViewportState(new Rect(0, 0, 800, 800), 0, 0, 1);
   },
 
-  getViewportStateFromBrowser: function getViewportStateFromBrowser(browser) {
-    return browser.__BrowserView__vps;
-  },
-
-  getNewBatchOperationState: function getNewBatchOperationState() {
-    return {
-      viewportSizeChanged: false,
-      dirtyAll: false
-    };
-  },
-
-  initContainer: function initContainer(container, visibleRect) {
-    container.style.width = visibleRect.width  + 'px';
-    container.style.height = visibleRect.height + 'px';
-    container.style.overflow = '-moz-hidden-unscrollable';
-  },
-
   ensureMozScrolledAreaEvent: function ensureMozScrolledAreaEvent(aBrowser, aWidth, aHeight) {
     let message = {};
     message.target = aBrowser;
     message.name = "Browser:MozScrolledAreaChanged";
     message.json = { width: aWidth, height: aHeight };
 
     Browser._browserView.updateScrolledArea(message);
   }
@@ -247,31 +230,30 @@ BrowserView.prototype = {
     let bvs = this._browserViewportState;
     if (!bvs)
       throw "Cannot get viewport dimensions when no browser is set";
 
     return [bvs.viewportRect.right, bvs.viewportRect.bottom];
   },
 
   setZoomLevel: function setZoomLevel(zoomLevel) {
-    getBrowser().style.MozTransformOrigin = "left top";
-    getBrowser().style.MozTransform = "scale(" + zoomLevel + ")";
     return;
 
     let bvs = this._browserViewportState;
     if (!bvs)
       return;
 
     let newZoomLevel = this.clampZoomLevel(zoomLevel);
     if (newZoomLevel != bvs.zoomLevel) {
       let browserW = this.viewportToBrowser(bvs.viewportRect.right);
       let browserH = this.viewportToBrowser(bvs.viewportRect.bottom);
       bvs.zoomLevel = newZoomLevel; // side-effect: now scale factor in transformations is newZoomLevel
       bvs.viewportRect.right  = this.browserToViewport(browserW);
       bvs.viewportRect.bottom = this.browserToViewport(browserH);
+      this._viewportChanged();
 
       if (this._browser) {
         let event = document.createEvent("Events");
         event.initEvent("ZoomChanged", true, false);
         this._browser.dispatchEvent(event);
       }
     }
   },
@@ -353,24 +335,18 @@ BrowserView.prototype = {
     let vis = this.getVisibleRect();
     let viewport = bvs.viewportRect;
     let oldRight = viewport.right;
     let oldBottom = viewport.bottom;
     viewport.right  = bvs.zoomLevel * json.width;
     viewport.bottom = bvs.zoomLevel * json.height;
 
     if (browser == this._browser) {
-      // Page has now loaded enough to allow zooming.
-      let sizeChanged = oldRight != viewport.right || oldBottom != viewport.bottom;
+      this._viewportChanged();
       this.updateDefaultZoom();
-      if (vis.right > viewport.right || vis.bottom > viewport.bottom) {
-        // Content has shrunk outside of the visible rectangle.
-        // XXX for some reason scroller doesn't know it is outside its bounds
-        Browser.contentScrollboxScroller.scrollBy(0, 0);
-      }
     }
   },
 
   /** Call when default zoom level may change. */
   updateDefaultZoom: function updateDefaultZoom() {
     let bvs = this._browserViewportState;
     if (!bvs)
       return false;
@@ -496,16 +472,23 @@ BrowserView.prototype = {
     let f = this.browserToViewport(1.0);
     return rect.scale(f, f);
   },
 
   browserToViewportCanvasContext: function browserToViewportCanvasContext(ctx) {
     let f = this.browserToViewport(1.0);
     ctx.scale(f, f);
   },
+
+  _viewportChanged: function() {
+    getBrowser().style.MozTransformOrigin = "left top";
+    getBrowser().style.MozTransform = "scale(" + this.getZoomLevel() + ")";
+    getBrowser().style.width = (800 / this.getZoomLevel()) + "px";
+    getBrowser().style.height = (800 / this.getZoomLevel()) + "px";
+  },
 };
 
 
 // -----------------------------------------------------------
 // Helper structures
 //
 
 /**
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -122,59 +122,19 @@ function debug() {
     dump('scrollbox scrolledsize: ' + w + ', ' + h + endl);
 
 
     let sb = document.getElementById("content-scrollbox");
     dump('container location:     ' + Math.round(container.getBoundingClientRect().left) + " " +
                                       Math.round(container.getBoundingClientRect().top) + endl);
 
     dump(endl);
-
-    let mouseModule = ih._modules[0];
-    dump('ih grabber  : ' + ih._grabber           + endl);
-    dump('ih grabdepth: ' + ih._grabDepth         + endl);
-    dump('ih listening: ' + !ih._ignoreEvents     + endl);
-    dump('ih suppress : ' + ih._suppressNextClick + endl);
-    dump('mouseModule : ' + mouseModule           + endl);
-
-    dump(endl);
-
-    dump('tilecache capacity: ' + bv._tileManager._tileCache.getCapacity() + endl);
-    dump('tilecache size    : ' + bv._tileManager._tileCache.size          + endl);
-    dump('tilecache iBound  : ' + bv._tileManager._tileCache.iBound        + endl);
-    dump('tilecache jBound  : ' + bv._tileManager._tileCache.jBound        + endl);
-
-    dump('-----------------------------------------------------\n');
   }
 }
 
-function debugTile(i, j) {
-  let bv = Browser._browserView;
-  let tc = bv._tileManager._tileCache;
-  let t  = tc.getTile(i, j);
-
-  dump('------ DEBUGGING TILE (' + i + ',' + j + ') --------\n');
-
-  dump('in bounds: ' + tc.inBounds(i, j) + endl);
-  dump('occupied : ' + !!tc.lookup(i, j) + endl);
-  if (t)
-  {
-  dump('toString : ' + t.toString(true) + endl);
-  dump('free     : ' + t.free + endl);
-  dump('dirtyRect: ' + t._dirtyTileCanvasRect + endl);
-
-  let len = tc._tilePool.length;
-  for (let k = 0; k < len; ++k)
-    if (tc._tilePool[k] === t)
-      dump('found in tilePool at index ' + k + endl);
-  }
-
-  dump('------------------------------------\n');
-}
-
 function onDebugKeyPress(ev) {
   let bv = Browser._browserView;
 
   if (!ev.ctrlKey)
     return;
 
   // use capitals so we require SHIFT here too
 
@@ -200,92 +160,23 @@ function onDebugKeyPress(ev) {
   const t = 84;
   const u = 85;  // debug given list of tiles separated by space
   const v = 86;
   const w = 87;
   const x = 88;
   const y = 89;
   const z = 90;  // set zoom level to 1
 
-  if (window.tileMapMode) {
-    function putChar(ev, col, row) {
-      let tile = tc.getTile(col, row);
-      switch (ev.charCode) {
-      case h: // held tiles
-        dump(tile ? (tile.free ? '*' : 'h') : ' ');
-        break;
-      case d: // dirty tiles
-        dump(tile ? (tile.isDirty() ? 'd' : '*') : ' ');
-        break;
-      case o: // occupied tileholders
-        dump(tc.lookup(col, row) ? 'o' : ' ');
-        break;
-      }
-    }
-
-    let tc = Browser._browserView._tileManager._tileCache;
-    let col, row;
-
-    dump(endl);
-
-    dump('  ');
-    for (col = 0; col < tc.iBound; ++col)
-      dump(col % 10);
-
-    dump(endl);
-
-    for (row = 0; row < tc.jBound; ++row) {
-
-      dump((row % 10) + ' ');
-
-      for (col = 0; col < tc.iBound; ++col) {
-        putChar(ev, col, row);
-      }
-
-      dump(endl);
-    }
-    dump(endl + endl);
-
-    for (let ii = 0; ii < tc._tilePool.length; ++ii) {
-      let tile = tc._tilePool[ii];
-      putChar(ev, tile.i, tile.j);
-    }
-
-    dump(endl + endl);
-
-    window.tileMapMode = false;
-    return;
-  }
-
   switch (ev.charCode) {
   case f:
     MemoryObserver.observe();
     dump("Forced a GC\n");
     break;
-  case r:
-    //bv.setVisibleRect(Browser.getVisibleRect());
-
   case d:
     debug();
-
-    break;
-  case l:
-    bv._tileManager.restartLazyCrawl(bv._tileManager._criticalRect);
-
-    break;
-  case b:
-    window.tileMapMode = true;
-    break;
-  case u:
-    let ijstrs = window.prompt('row,col plz').split(' ');
-    for each (let ijstr in ijstrs) {
-      let [i, j] = ijstr.split(',').map(function (x) { return parseInt(x); });
-      debugTile(i, j);
-    }
-
     break;
   case a:
     let cr = bv._tileManager._criticalRect;
     dump('>>>>>> critical rect is ' + (cr ? cr.toString() : cr) + '\n');
     if (cr) {
       let starti = cr.left  >> kTileExponentWidth;
       let endi   = cr.right >> kTileExponentWidth;
 
@@ -296,49 +187,31 @@ function onDebugKeyPress(ev) {
         for (var ii = starti; ii <= endi; ++ii)
           debugTile(ii, jj);
     }
 
     break;
   case i:
     window.infoMode = !window.infoMode;
     break;
-  case m:
-    Util.dumpLn("renderMode:", bv._renderMode);
-    Util.dumpLn("batchOps:",bv._batchOps.length);
-    bv.resumeRendering();
-    break;
-  case p:
-    let tc = bv._tileManager._tileCache;
-    dump('************* TILE POOL ****************\n');
-    for (let ii = 0, len = tc._tilePool.length; ii < len; ++ii) {
-      if (window.infoMode)
-        debugTile(tc._tilePool[ii].i, tc._tilePool[ii].j);
-      else
-        dump(tc._tilePool[ii].i + ',' + tc._tilePool[ii].j + '\n');
-    }
-    dump('****************************************\n');
-    break;
 #ifndef MOZ_PLATFORM_MAEMO
   case q:
     if (Util.isPortrait())
       window.top.resizeTo(800,480);
     else
       window.top.resizeTo(480,800);
     break;
 #endif
   case z:
     bv.setZoomLevel(1.0);
     break;
   default:
     break;
   }
 }
-window.infoMode = false;
-window.tileMapMode = false;
 
 var ih = null;
 
 var Browser = {
   _tabs : [],
   _selectedTab : null,
   windowUtils: window.QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIDOMWindowUtils),
@@ -1146,28 +1019,23 @@ var Browser = {
     let zoomRatio = vis.width / rect.width;
     let zoomLevel = bv.getZoomLevel() * zoomRatio;
     let scrollX = rect.left * zoomRatio;
     let scrollY = rect.top * zoomRatio;
 
     // The order of operations below is important for artifacting and for performance. Important
     // side effects of functions are noted below.
 
-    // Hardware scrolling happens immediately when scrollTo is called.  Hide to prevent artifacts.
-    bv.beginOffscreenOperation(rect);
-
     // Critical rect changes when controls are hidden. Must hide before tilemanager viewport.
     this.hideSidebars();
     this.hideTitlebar();
 
     bv.setZoomLevel(zoomLevel);
 
     this.contentScrollboxScroller.scrollTo(scrollX, scrollY);
-
-    bv.commitOffscreenOperation();
   },
 
   zoomToPoint: function zoomToPoint(cX, cY, aRect) {
     let bv = this._browserView;
     if (!bv.allowZoom)
       return null;
 
     let zoomRect = null;