Bug 1101569 - Use the new allTabs menu sidebar in the inspector and netmonitor; r=vporof

This commit is contained in:
Patrick Brosset 2015-01-16 11:58:02 +01:00
parent f4d501dfb1
commit 9d7d563a24
4 changed files with 33 additions and 6 deletions

View File

@ -327,17 +327,35 @@ ToolSidebar.prototype = {
}),
/**
* Show or hide a specific tab
* Show or hide a specific tab and tabpanel.
* @param {Boolean} isVisible True to show the tab/tabpanel, False to hide it.
* @param {String} id The ID of the tab to be hidden.
* @param {String} tabPanelId Optionally pass the ID for the tabPanel if it
* can't be retrieved using the tab ID. This is useful when tabs and tabpanels
* existed before the widget was created.
*/
toggleTab: function(id, isVisible) {
toggleTab: function(isVisible, id, tabPanelId) {
// Toggle the tab.
let tab = this.getTab(id);
if (!tab) {
return;
}
tab.hidden = !isVisible;
// Toggle the item in the allTabs menu.
if (this._allTabsBtn) {
this._allTabsBtn.querySelector("#sidebar-alltabs-item-" + id).hidden = !isVisible;
}
// Toggle the corresponding tabPanel, if one can be found either with the id
// or the provided tabPanelId.
let tabPanel = this.getTabPanel(id);
if (!tabPanel && tabPanelId) {
tabPanel = this.getTabPanel(tabPanelId);
}
if (tabPanel) {
tabPanel.hidden = !isVisible;
}
},
/**

View File

@ -313,7 +313,9 @@ InspectorPanel.prototype = {
*/
setupSidebar: function InspectorPanel_setupSidebar() {
let tabbox = this.panelDoc.querySelector("#inspector-sidebar");
this.sidebar = new ToolSidebar(tabbox, this, "inspector");
this.sidebar = new ToolSidebar(tabbox, this, "inspector", {
showAllTabsMenu: true
});
let defaultTab = Services.prefs.getCharPref("devtools.inspector.activeSidebar");

View File

@ -119,6 +119,7 @@ const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
const EventEmitter = require("devtools/toolkit/event-emitter");
const Editor = require("devtools/sourceeditor/editor");
const {Tooltip} = require("devtools/shared/widgets/Tooltip");
const {ToolSidebar} = require("devtools/framework/sidebar");
XPCOMUtils.defineLazyModuleGetter(this, "Chart",
"resource:///modules/devtools/Chart.jsm");

View File

@ -2001,6 +2001,9 @@ CustomRequestView.prototype = {
function NetworkDetailsView() {
dumpn("NetworkDetailsView was instantiated");
// The ToolSidebar requires the panel object to be able to emit events.
EventEmitter.decorate(this);
this._onTabSelect = this._onTabSelect.bind(this);
};
@ -2025,6 +2028,10 @@ NetworkDetailsView.prototype = {
dumpn("Initializing the NetworkDetailsView");
this.widget = $("#event-details-pane");
this.sidebar = new ToolSidebar(this.widget, this, "netmonitor", {
disableTelemetry: true,
showAllTabsMenu: true
});
this._headers = new VariablesView($("#all-headers"),
Heritage.extend(GENERIC_VARIABLES_VIEW_SETTINGS, {
@ -2065,7 +2072,7 @@ NetworkDetailsView.prototype = {
*/
destroy: function() {
dumpn("Destroying the NetworkDetailsView");
this.sidebar.destroy();
$("tabpanels", this.widget).removeEventListener("select", this._onTabSelect);
},
@ -2090,8 +2097,7 @@ NetworkDetailsView.prototype = {
let isHtml = RequestsMenuView.prototype.isHtml({ attachment: aData });
// Show the "Preview" tabpanel only for plain HTML responses.
$("#preview-tab").hidden = !isHtml;
$("#preview-tabpanel").hidden = !isHtml;
this.sidebar.toggleTab(isHtml, "preview-tab", "preview-tabpanel");
// Show the "Security" tab only for requests that
// 1) are https (state != insecure)