Bug 783103 - Avoid layout flush from isElementVisible when attempting to focus the URL bar or search bar. r=enn
authorDão Gottwald <dao@mozilla.com>
Tue, 21 Aug 2012 15:53:39 +0200
changeset 102939 caeb23f6d9570eff0f7a040e2a7b0a92e1354422
parent 102938 aaadec548e0b3afa08959ecdb675cce04b151cb3
child 102940 88def2d79ce8c144b1b1599f74bbb424430d6b33
push id23317
push userryanvm@gmail.com
push dateWed, 22 Aug 2012 02:05:02 +0000
treeherdermozilla-central@abc17059522b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn
bugs783103
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 783103 - Avoid layout flush from isElementVisible when attempting to focus the URL bar or search bar. r=enn
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1281,19 +1281,19 @@ var gBrowserInit = {
     if (mustLoadSidebar) {
       let sidebar = document.getElementById("sidebar");
       let sidebarBox = document.getElementById("sidebar-box");
       sidebar.setAttribute("src", sidebarBox.getAttribute("src"));
     }
 
     UpdateUrlbarSearchSplitterState();
 
-    if (isLoadingBlank && gURLBar && isElementVisible(gURLBar))
+    if (isLoadingBlank && gURLBar)
       gURLBar.focus();
-    else
+    if (!isLoadingBlank || !gURLBar || !gURLBar.focused)
       gBrowser.selectedBrowser.focus();
 
     gNavToolbox.customizeDone = BrowserToolboxCustomizeDone;
     gNavToolbox.customizeChange = BrowserToolboxCustomizeChange;
 
     // Set up Sanitize Item
     this._initializeSanitizer();
 
@@ -1983,18 +1983,19 @@ function loadOneOrMoreURIs(aURIString)
   catch (e) {
   }
 }
 
 function focusAndSelectUrlBar() {
   if (gURLBar) {
     if (window.fullScreen)
       FullScreen.mouseoverToggle(true);
-    if (isElementVisible(gURLBar)) {
-      gURLBar.focus();
+
+    gURLBar.focus();
+    if (gURLBar.focused) {
       gURLBar.select();
       return true;
     }
   }
   return false;
 }
 
 function openLocation() {
@@ -3345,20 +3346,20 @@ const BrowserSearch = {
         Services.obs.addObserver(observer, "browser-delayed-startup-finished", false);
       }
       return;
     }
 #endif
     var searchBar = this.searchBar;
     if (searchBar && window.fullScreen)
       FullScreen.mouseoverToggle(true);
-
-    if (isElementVisible(searchBar)) {
+    if (searchBar)
+      searchBar.focus();
+    if (searchBar && searchBar.textbox.focused) {
       searchBar.select();
-      searchBar.focus();
     } else {
       openUILinkIn(Services.search.defaultEngine.searchForm, "current");
     }
   },
 
   /**
    * Loads a search results page, given a set of search terms. Uses the current
    * engine if the search bar is visible, or the default engine otherwise.