Bug 500280 - clicking the preferences button takes a few seconds to switch screens [r=gavin.sharp]
--- a/mobile/chrome/content/Util.js
+++ b/mobile/chrome/content/Util.js
@@ -180,16 +180,17 @@ let Util = {
* Cache of commonly used elements.
*/
let Elements = {};
[
["browserBundle", "bundle_browser"],
["contentShowing", "bcast_contentShowing"],
["stack", "stack"],
+ ["panelUI", "panel-container"],
].forEach(function (elementGlobal) {
let [name, id] = elementGlobal;
Elements.__defineGetter__(name, function () {
let element = document.getElementById(id);
if (!element)
return null;
delete Elements[name];
return Elements[name] = element;
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -320,29 +320,31 @@ var BrowserUI = {
return;
let panel = this._popup.panel;
if (panel.hide)
panel.hide();
},
_isEventInsidePopup: function _isEventInsidePopup(aEvent) {
if (!this._popup)
- return;
+ return false;
let elements = this._popup.elements;
let targetNode = aEvent ? aEvent.target : null;
while (targetNode && elements.indexOf(targetNode) == -1)
targetNode = targetNode.parentNode;
return targetNode ? true : false;
},
- switchPane : function(id) {
+ switchPane : function switchPane(id) {
let button = document.getElementsByAttribute("linkedpanel", id)[0];
if (button)
button.checked = true;
- document.getElementById("panel-items").selectedPanel = document.getElementById(id);
+
+ let pane = document.getElementById(id);
+ document.getElementById("panel-items").selectedPanel = pane;
},
get toolbarH() {
if (!this._toolbarH) {
let toolbar = document.getElementById("toolbar-main");
this._toolbarH = toolbar.boxObject.height;
}
return this._toolbarH;
@@ -401,20 +403,26 @@ var BrowserUI = {
browsers.addEventListener("DOMWillOpenModalDialog", this, true);
// listening mousedown for automatically dismiss some popups (e.g. larry)
window.addEventListener("mousedown", this, true);
// listening escape to dismiss dialog on VK_ESCAPE
window.addEventListener("keypress", this, true);
- ExtensionsView.init();
- DownloadsView.init();
- PreferencesView.init();
- ConsoleView.init();
+ // Push the panel initialization out of the startup path
+ // (Using a timeout because we have no good way to delay-init [Bug 535366])
+ setTimeout(function() {
+ // We unhide the panelUI so the XBL and settings can initialize
+ Elements.panelUI.hidden = false;
+ ExtensionsView.init();
+ DownloadsView.init();
+ PreferencesView.init();
+ ConsoleView.init();
+ }, 1000);
},
uninit : function() {
ExtensionsView.uninit();
ConsoleView.uninit();
},
update : function(aState) {
@@ -604,35 +612,36 @@ var BrowserUI = {
isTabsVisible: function isTabsVisible() {
// The _1, _2 and _3 are to make the js2 emacs mode happy
let [leftvis,_1,_2,_3] = Browser.computeSidebarVisibility();
return (leftvis > 0.002);
},
showPanel: function showPanel(aPage) {
- let panelUI = document.getElementById("panel-container");
-
- panelUI.hidden = false;
- panelUI.width = window.innerWidth;
- panelUI.height = window.innerHeight;
+ Elements.panelUI.left = 0;
+ Elements.panelUI.hidden = false;
+ Elements.panelUI.width = window.innerWidth;
+ Elements.panelUI.height = window.innerHeight;
Elements.contentShowing.setAttribute("disabled", "true");
if (aPage != undefined)
this.switchPane(aPage);
},
hidePanel: function hidePanel() {
- let panelUI = document.getElementById("panel-container");
- panelUI.hidden = true;
-
+ Elements.panelUI.hidden = true;
Elements.contentShowing.removeAttribute("disabled");
},
-
+
+ isPanelVisible: function isPanelVisible() {
+ return (!Elements.panelUI.hidden && Elements.panelUI.left == 0);
+ },
+
switchTask: function switchTask() {
try {
let phone = Cc["@mozilla.org/phone/support;1"].createInstance(Ci.nsIPhoneSupport);
phone.switchTask();
} catch(e) { }
},
#ifdef WINCE
@@ -809,21 +818,20 @@ var BrowserUI = {
button.disabled = true;
setTimeout(function() { button.disabled = false; }, 5000);
Sanitizer.sanitize();
break;
}
case "cmd_panel":
{
- let panelUI = document.getElementById("panel-container");
- if (panelUI.hidden)
+ if (BrowserUI.isPanelVisible())
+ this.hidePanel();
+ else
this.showPanel();
- else
- this.hidePanel();
break;
}
case "cmd_zoomin":
Browser.zoom(-1);
break;
case "cmd_zoomout":
Browser.zoom(1);
break;
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -540,18 +540,18 @@ var Browser = {
this.addTab(whereURI, true);
if (whereURI == "about:blank") {
BrowserUI.showToolbar(true);
BrowserUI.showAutoComplete();
}
// JavaScript Error Console
if (gPrefService.getBoolPref("browser.console.showInPanel")){
- let tool_console = document.getElementById("tool-console");
- tool_console.hidden = false;
+ let button = document.getElementById("tool-console");
+ button.hidden = false;
}
bv.commitBatchOperation();
// If some add-ons were disabled during during an application update, alert user
if (gPrefService.prefHasUserValue("extensions.disabledAddons")) {
let addons = gPrefService.getCharPref("extensions.disabledAddons").split(",");
if (addons.length > 0) {
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -326,17 +326,17 @@
<hbox id="bookmark-form" align="start">
<image id="bookmark-image"/>
</hbox>
<hbox pack="center">
<button class="button-dark" label="&editBookmarkDone.label;" oncommand="BookmarkHelper.save();"/>
</hbox>
</vbox>
- <box id="panel-container" hidden="true" class="panel-dark">
+ <box id="panel-container" class="panel-dark" style="-moz-stack-sizing: ignore" left="10000" hidden="true">
<box id="panel-controls" oncommand="BrowserUI.switchPane(event.target.getAttribute('linkedpanel'));">
<toolbarbutton id="tool-panel-close" class="page-button button-image" command="cmd_panel"/>
<toolbarbutton id="tool-addons" type="radio" group="1" class="panel-button button-image" linkedpanel="addons-container"/>
<toolbarbutton id="tool-downloads" type="radio" group="1" class="panel-button button-image" linkedpanel="downloads-container"/>
<toolbarbutton id="tool-preferences" type="radio" group="1" checked="true" class="panel-button button-image" linkedpanel="prefs-container"/>
<toolbarbutton id="tool-console" type="radio" group="1" hidden="true" class="panel-button button-image" linkedpanel="console-container"/>
</box>
<deck id="panel-items" selectedIndex="2" flex="1">
--- a/mobile/chrome/content/downloads.js
+++ b/mobile/chrome/content/downloads.js
@@ -113,19 +113,18 @@ var DownloadsView = {
if (this._list.itemCount == 0) {
let emptyString = Elements.browserBundle.getString("downloadsEmpty");
let emptyItem = this._list.appendItem(emptyString);
emptyItem.id = "dl-empty-message";
}
},
get visible() {
- let panel = document.getElementById("panel-container");
let items = document.getElementById("panel-items");
- if (panel.hidden == false && items.selectedPanel.id == "downloads-container")
+ if (BrowserUI.isPanelVisible() && items.selectedPanel.id == "downloads-container")
return true;
return false;
},
init: function dv_init() {
if (this._initialized)
return;
this._initialized = true;
--- a/mobile/chrome/content/extensions.js
+++ b/mobile/chrome/content/extensions.js
@@ -207,19 +207,18 @@ var ExtensionsView = {
let item = items[i];
if (item.hideOptions)
item.hideOptions();
}
this._list.ensureSelectedElementIsVisible();
},
get visible() {
- let panel = document.getElementById("panel-container");
let items = document.getElementById("panel-items");
- if (panel.hidden == false && items.selectedPanel.id == "addons-container")
+ if (BrowserUI.isPanelVisible() && items.selectedPanel.id == "addons-container")
return true;
return false;
},
init: function ev_init() {
if (this._extmgr)
return;