Bug 606672 - Fennec scrolling code is too expensive. part1, part2. [r=mfinkle]
authorOleg Romashin <romaxa@gmail.com>
Thu, 18 Nov 2010 16:47:16 +0200
changeset 67046 6f36c4bfa491d129e0fc1ffa60221d97b0cdea99
parent 67045 0a25a8d9ff7a6fbb36da6f4cb1dc840f38dbcc77
child 67047 73bc5dd7de901e0afa11fa7f9e20e66e0a9814ee
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)
reviewersmfinkle
bugs606672
Bug 606672 - Fennec scrolling code is too expensive. part1, part2. [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -77,19 +77,20 @@ let Elements = {};
 [
   ["browserBundle",      "bundle_browser"],
   ["contentShowing",     "bcast_contentShowing"],
   ["urlbarState",        "bcast_urlbarState"],
   ["stack",              "stack"],
   ["tabs",               "tabs-container"],
   ["controls",           "browser-controls"],
   ["panelUI",            "panel-container"],
-  ["viewBuffer",         "view-buffer"],
   ["toolbarContainer",   "toolbar-container"],
-  ["browsers",           "browsers"]
+  ["browsers",           "browsers"],
+  ["contentViewport",    "content-viewport"],
+  ["contentNavigator",   "content-navigator"]
 ].forEach(function (aElementGlobal) {
   let [name, id] = aElementGlobal;
   XPCOMUtils.defineLazyGetter(Elements, name, function() {
     return document.getElementById(id);
   });
 });
 
 const TOOLBARSTATE_LOADING  = 1;
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -213,19 +213,19 @@ var Browser = {
         getBrowser().scrollBy(aDx, aDy);
       },
 
       scrollTo: function(aX, aY) {
         getBrowser().scrollTo(aX, aY);
       },
 
       getPosition: function(aScrollX, aScrollY) {
-        let { x: x, y: y } = getBrowser().getPosition();
-        aScrollX.value = x;
-        aScrollY.value = y;
+        let scroll = getBrowser().getPosition();
+        aScrollX.value = scroll.x;
+        aScrollY.value = scroll.y;
       }
     };
 
     /* horizontally scrolling box that holds the sidebars as well as the contentScrollbox */
     let controlsScrollbox = this.controlsScrollbox = document.getElementById("controls-scrollbox");
     this.controlsScrollboxScroller = controlsScrollbox.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
     controlsScrollbox.customDragger = {
       isDraggable: function isDraggable(target, content) { return {}; },
@@ -767,18 +767,18 @@ var Browser = {
       event.initEvent("TabSelect", true, false);
       event.lastTab = lastTab;
       tab.chromeTab.dispatchEvent(event);
     }
 
     tab.lastSelected = Date.now();
 
     if (tab.pageScrollOffset) {
-      let { x: pageScrollX, y: pageScrollY } = tab.pageScrollOffset;
-      Browser.pageScrollboxScroller.scrollTo(pageScrollX, pageScrollY);
+      let pageScroll = tab.pageScrollOffset;
+      Browser.pageScrollboxScroller.scrollTo(pageScroll.x, pageScroll.y);
     }
   },
 
   supportsCommand: function(cmd) {
     var isSupported = false;
     switch (cmd) {
       case "cmd_fullscreen":
         isSupported = true;
@@ -1161,34 +1161,34 @@ Browser.MainDragger.prototype = {
     let x = 0, y = 0, rect;
 
     rect = Rect.fromRect(Browser.pageScrollbox.getBoundingClientRect()).map(Math.round);
     if (doffset.x < 0 && rect.right < window.innerWidth)
       x = Math.max(doffset.x, rect.right - window.innerWidth);
     if (doffset.x > 0 && rect.left > 0)
       x = Math.min(doffset.x, rect.left);
 
-    let height = document.getElementById("content-viewport").getBoundingClientRect().height;
-    height -= document.getElementById("content-navigator").getBoundingClientRect().height;
+    let height = Elements.contentViewport.getBoundingClientRect().height;
+    height -= Elements.contentNavigator.getBoundingClientRect().height;
     rect = Rect.fromRect(Browser.contentScrollbox.getBoundingClientRect()).map(Math.round);
     if (doffset.y < 0 && rect.bottom < height)
       y = Math.max(doffset.y, rect.bottom - height);
     if (doffset.y > 0 && rect.top > 0)
       y = Math.min(doffset.y, rect.top);
 
     doffset.subtract(x, y);
     return new Point(x, y);
   },
 
   /** Pan scroller by the given amount. Updates doffset with leftovers. */
   _panScroller: function _panScroller(scroller, doffset) {
-    let { x: x0, y: y0 } = Browser.getScrollboxPosition(scroller);
+    let scroll = Browser.getScrollboxPosition(scroller);
     scroller.scrollBy(doffset.x, doffset.y);
-    let { x: x1, y: y1 } = Browser.getScrollboxPosition(scroller);
-    doffset.subtract(x1 - x0, y1 - y0);
+    let scroll1 = Browser.getScrollboxPosition(scroller);
+    doffset.subtract(scroll1.x - scroll.x, scroll1.y - scroll.y);
   }
 };
 
 
 function nsBrowserAccess()
 {
 }