Bug 511123: the toolbar can be half viewable while awesomebar/larry/... is on screen [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Mon, 24 Aug 2009 10:18:26 -0400
changeset 65467 4e6cc4820d7345a8e307957017d5ca68f9831e06
parent 65466 39678038dc466d2d3dae511a5aded78ca0cf0a9f
child 65468 04ae566c81ff4ab0327279d65d66a30c4a2a7abf
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)
reviewersmark.finkle
bugs511123
Bug 511123: the toolbar can be half viewable while awesomebar/larry/... is on screen [r=mark.finkle]
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
@@ -180,16 +180,31 @@ var BrowserUI = {
     }
     else {
       //ws.unfreeze("toolbar-main");
     }
 
     this._editToolbar(aFlags & URLBAR_EDIT);
   },
 
+  _toolbarLocked: 0,
+  lockToolbar: function lockToolbar() {
+    this._toolbarLocked++;
+    document.getElementById("toolbar-moveable-container").top = "0";
+  },
+  
+  unlockToolbar: function unlockToolbar() {
+    if (!this._toolbarLocked)
+      return;
+    
+    this._toolbarLocked--;
+    if(!this._toolbarLocked)
+      document.getElementById("toolbar-moveable-container").top = "";
+  },
+
   _editToolbar : function _editToolbar(aEdit) {
     var icons = document.getElementById("urlbar-icons");
     if (aEdit && icons.getAttribute("mode") != "edit") {
       icons.setAttribute("mode", "edit");
       this._edit.defaultValue = this._edit.value;
 
       let urlString = this.getDisplayURI(Browser.selectedBrowser);
       if (urlString == "about:blank")
@@ -225,29 +240,32 @@ var BrowserUI = {
     if (this._dialogs.length)
       return this._dialogs[this._dialogs.length - 1];
     return null;
   },
 
   pushDialog : function pushDialog(aDialog) {
     // If we have a dialog push it on the stack and set the attr for CSS
     if (aDialog) {
+      this.lockToolbar();
       this._dialogs.push(aDialog);
       document.getElementById("toolbar-main").setAttribute("dialog", "true");
     }
   },
 
   popDialog : function popDialog() {
     // Passing null means we pop the topmost dialog
     if (this._dialogs.length)
       this._dialogs.pop();
 
     // If no more dialogs are being displayed, remove the attr for CSS
     if (!this._dialogs.length)
       document.getElementById("toolbar-main").removeAttribute("dialog");
+
+    this.unlockToolbar();
   },
 
   pushPopup: function pushPopup(aPanel, aElements) {
     this._popup =  { "panel": aPanel, 
                      "elements": (aElements instanceof Array) ? aElements : [aElements] };
   },
 
   popPopup: function popPopup() {
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -964,28 +964,28 @@ var Browser = {
 
   tryFloatToolbar: function tryFloatToolbar(dx, dy) {
     if (this.floatedWhileDragging)
       return;
 
     let [leftvis, ritevis, leftw, ritew] = Browser.computeSidebarVisibility(dx, dy);
     // XXX computeSideBarVisibility will normally return 0.0015... for ritevis
     if (leftvis > 0.002 || ritevis > 0.002) {
-      document.getElementById("toolbar-moveable-container").top = 0;
+      BrowserUI.lockToolbar();
       this.floatedWhileDragging = true;
     }
   },
 
   tryUnfloatToolbar: function tryUnfloatToolbar(dx, dy) {
     if (!this.floatedWhileDragging)
       return true;
 
     let [leftvis, ritevis, leftw, ritew] = Browser.computeSidebarVisibility(dx, dy);
     if (leftvis <= 0.002 && ritevis <= 0.002) {
-      document.getElementById("toolbar-moveable-container").top = "";
+      BrowserUI.unlockToolbar();
       this.floatedWhileDragging = false;
       return true;
     }
     return false;
   },
 
   zoom: function zoom(aDirection) {
     Browser._browserView.zoom(aDirection);
@@ -1719,22 +1719,24 @@ IdentityHandler.prototype = {
     this._identityPopup.focus();
 
     this._identityBox.setAttribute("open", "true");
 
     // Update the popup strings
     this.setPopupMessages(this._identityBox.getAttribute("mode") || this.IDENTITY_MODE_UNKNOWN);
 
     BrowserUI.pushPopup(this, [this._identityPopup, this._identityBox]);
+    BrowserUI.lockToolbar();
   },
 
   hide: function ih_hide() {
     this._identityPopup.hidden = true;
-
     this._identityBox.removeAttribute("open");
+    
+    BrowserUI.unlockToolbar();
   },
 
   /**
    * Click handler for the identity-box element in primary chrome.
    */
   handleIdentityButtonEvent: function(event) {
     event.stopPropagation();