Bug 564075 - Url bar gets displaced, with open sidebar, focusing url bar and then dismissing awesome bar [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Thu, 06 May 2010 10:32:24 -0400
changeset 66210 fb0b212cb7bfd56f12252d0b1ea441d33d82826b
parent 66209 6768d5faaebc77470e2d699434a351cb867ce5f4
child 66211 3fb43ad612729f709e336c3b95d940891027308e
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
bugs564075
Bug 564075 - Url bar gets displaced, with open sidebar, focusing url bar and then dismissing awesome bar [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
@@ -192,23 +192,21 @@ var BrowserUI = {
     let forward = document.getElementById("cmd_forward");
 
     back.setAttribute("disabled", !aBrowser.canGoBack);
     forward.setAttribute("disabled", !aBrowser.canGoForward);
   },
 
   _updateToolbar: function _updateToolbar() {
     let icons = document.getElementById("urlbar-icons");
-    if (Browser.selectedTab.isLoading() && icons.getAttribute("mode") != "loading") {
-      this.lockToolbar();
+    let mode = icons.getAttribute("mode");
+    if (Browser.selectedTab.isLoading() && mode != "loading") {
       icons.setAttribute("mode", "loading");
     }
-    else if (icons.getAttribute("mode") != "view") {
-      if (this.isToolbarLocked())
-        this.unlockToolbar();
+    else if (mode != "view") {
       icons.setAttribute("mode", "view");
     }
   },
 
   _tabSelect : function(aEvent) {
     let browser = Browser.selectedBrowser;
     this._titleChanged(browser.contentDocument);
     this._updateToolbar();
@@ -458,24 +456,26 @@ var BrowserUI = {
     let browser = Browser.selectedBrowser;
 
     switch (aState) {
       case TOOLBARSTATE_LOADED:
         if (icons.getAttribute("mode") != "edit")
           this._updateToolbar();
 
         this._updateIcon(browser.mIconURL);
+        this.unlockToolbar();
         break;
 
       case TOOLBARSTATE_LOADING:
         if (icons.getAttribute("mode") != "edit")
           this._updateToolbar();
 
         browser.mIconURL = "";
         this._updateIcon();
+        this.lockToolbar();
         break;
     }
   },
 
   _updateIcon : function(aIconSrc) {
     this._favicon.src = aIconSrc || "";
     if (Browser.selectedTab.isLoading()) {
       this._throbber.hidden = false;
@@ -749,21 +749,19 @@ var BrowserUI = {
             this.doCommand("cmd_openLocation");
             break;
           default:
             break;
         }
         break;
       // URL textbox events
       case "mouseup":
-        if (!this._isEventInsidePopup(aEvent))
-          this._hidePopup();
-
-        if (aEvent.detail < 2 && aEvent.button == 0)
+        if (aEvent.detail < 2 && aEvent.button == 0 && gFocusManager.focusedElement == this._edit.inputField) {
           this.doCommand("cmd_openLocation");
+        }
         break;
       case "mousedown":
         if (!this._isEventInsidePopup(aEvent))
           this._hidePopup();
 
         let selectAll = gPrefService.getBoolPref("browser.urlbar.doubleClickSelectsAll");
         if (aEvent.detail == 2 && aEvent.button == 0 && selectAll && aEvent.target == this._edit) {
           this._edit.editor.selectAll();
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -776,22 +776,30 @@ var Browser = {
       tab = this.getTabFromChrome(tab);
 
     if (!tab || this._selectedTab == tab)
       return;
 
     if (this._selectedTab) {
       this._selectedTab.contentScrollOffset = this.getScrollboxPosition(this.contentScrollboxScroller);
       this._selectedTab.pageScrollOffset = this.getScrollboxPosition(this.pageScrollboxScroller);
+
+      // Make sure we leave the toolbar in an unlocked state
+      if (this._selectedTab.isLoading())
+        BrowserUI.unlockToolbar();
     }
 
     let isFirstTab = this._selectedTab == null;
     let lastTab = this._selectedTab;
     this._selectedTab = tab;
 
+    // Lock the toolbar if the new tab is still loading
+    if (this._selectedTab.isLoading())
+      BrowserUI.lockToolbar();
+
     tab.ensureBrowserExists();
 
     bv.beginBatchOperation();
 
     bv.setBrowser(tab.browser, tab.browserViewportState);
     bv.forceContainerResize();
     bv.updateDefaultZoom();