Bug 513949: avoid scrollTo on open, since it slows down awesomebar appearance, r=mfinkle
authorGavin Sharp <gavin@mozilla.com>
Tue, 01 Sep 2009 14:05:43 -0400
changeset 65494 a69079e758a40854e6160286867ede018fc67f4e
parent 65493 c37766afef8c33c3bc25d4d8dd8af3f399e36eec
child 65495 5f7f0e55316a654e655379976acfd1462e288838
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
bugs513949
Bug 513949: avoid scrollTo on open, since it slows down awesomebar appearance, r=mfinkle
mobile/chrome/content/bindings.xml
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -156,16 +156,23 @@
             return;
 
           this.selectedIndex = -1;
           this.input.controller.stopSearch();
 
           this.collapsed = true;
           this._popupOpen = false;
 
+          // Scroll to the top left for the next open (only if necessary).
+          // Doing this now rather than in open() turns out to be faster,
+          // possibly because it avoids scrolling too soon after we uncollapse
+          // ourselves
+          if (this._items.scrollTop || this._items.scrollLeft)
+            this._scrollBoxObject.scrollTo(0, 0);
+
           BrowserUI.showToolbar();
           BrowserUI.popDialog();
         ]]></body>
       </method>
 
       <!-- Helper used by active dialog system -->
       <method name="close">
         <body><![CDATA[
@@ -177,20 +184,16 @@
       <field name="_XULNS">("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")</field>
 
       <method name="invalidate">
         <body><![CDATA[
           // Don't bother doing work if we're not even open
           if (!this.popupOpen)
             return;
 
-          // Scroll to the top left if only if necessary
-          if (this._items.scrollTop || this._items.scrollLeft)
-            this._scrollBoxObject.scrollTo(0, 0);
-
           let controller = this.input.controller;
           let searchString = controller.searchString;
           let items = this._items;
 
           // Remove the allBookmarksItem if present, before populating the list.
           if (!this._allBookmarksItem._hidden) {
             items.removeChild(this._allBookmarksItem);
             this._allBookmarksItem._hidden = true;