mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1396784 - Lazy load Layout view when opening the inspector. r=gl
MozReview-Commit-ID: I5PiZbfy2J2 --HG-- extra : rebase_source : 8c9b36fee29816551bdac59a494a0d07ee662759
This commit is contained in:
parent
55daa8694b
commit
a9f4169300
@ -631,8 +631,28 @@ Inspector.prototype = {
|
||||
// calling inspector.addSidebarTab
|
||||
this.gridInspector = new GridInspector(this, this.panelWin);
|
||||
|
||||
const LayoutView = this.browserRequire("devtools/client/inspector/layout/layout");
|
||||
this.layoutview = new LayoutView(this, this.panelWin);
|
||||
// Inject a lazy loaded react tab by exposing a fake React object
|
||||
// with a lazy defined Tab thanks to `panel` being a function
|
||||
let layoutId = "layoutview";
|
||||
let layoutTitle = INSPECTOR_L10N.getStr("inspector.sidebar.layoutViewTitle2");
|
||||
this.sidebar.addTab(
|
||||
layoutId,
|
||||
layoutTitle,
|
||||
{
|
||||
props: {
|
||||
id: layoutId,
|
||||
title: layoutTitle
|
||||
},
|
||||
panel: () => {
|
||||
if (!this.layoutview) {
|
||||
const LayoutView =
|
||||
this.browserRequire("devtools/client/inspector/layout/layout");
|
||||
this.layoutview = new LayoutView(this, this.panelWin);
|
||||
}
|
||||
return this.layoutview.provider;
|
||||
}
|
||||
},
|
||||
defaultTab == layoutId);
|
||||
|
||||
if (this.target.form.animationsActor) {
|
||||
this.sidebar.addFrameTab(
|
||||
|
@ -101,14 +101,8 @@ LayoutView.prototype = {
|
||||
showBadge: () => Services.prefs.getIntPref(PROMOTE_COUNT_PREF) > 0,
|
||||
}, app);
|
||||
|
||||
let defaultTab = Services.prefs.getCharPref("devtools.inspector.activeSidebar");
|
||||
|
||||
this.inspector.addSidebarTab(
|
||||
"layoutview",
|
||||
INSPECTOR_L10N.getStr("inspector.sidebar.layoutViewTitle2"),
|
||||
provider,
|
||||
defaultTab == "layoutview"
|
||||
);
|
||||
// Expose the provider to let inspector.js use it in setupSidebar.
|
||||
this.provider = provider;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -53,6 +53,7 @@ var openInspectorSidebarTab = Task.async(function* (id) {
|
||||
|
||||
info("Selecting the " + id + " sidebar");
|
||||
|
||||
let onSidebarSelect = inspector.sidebar.once("select");
|
||||
if (id === "computedview" || id === "layoutview") {
|
||||
// The layout and computed views should wait until the box-model widget is ready.
|
||||
let onBoxModelViewReady = inspector.once("boxmodel-view-updated");
|
||||
@ -61,6 +62,7 @@ var openInspectorSidebarTab = Task.async(function* (id) {
|
||||
} else {
|
||||
inspector.sidebar.select(id);
|
||||
}
|
||||
yield onSidebarSelect;
|
||||
|
||||
return {
|
||||
toolbox,
|
||||
|
@ -334,6 +334,13 @@ define(function (require, exports, module) {
|
||||
width: selected ? "100%" : "0",
|
||||
};
|
||||
|
||||
// Allows lazy loading panels by creating them only if they are selected,
|
||||
// then store a copy of the lazy created panel in `tab.panel`.
|
||||
if (typeof tab.panel == "function" && selected) {
|
||||
tab.panel = tab.panel(tab);
|
||||
}
|
||||
let panel = tab.panel || tab;
|
||||
|
||||
return (
|
||||
DOM.div({
|
||||
id: id ? id + "-panel" : "panel-" + index,
|
||||
@ -343,7 +350,7 @@ define(function (require, exports, module) {
|
||||
role: "tabpanel",
|
||||
"aria-labelledby": id ? id + "-tab" : "tab-" + index,
|
||||
},
|
||||
(selected || this.state.created[index]) ? tab : null
|
||||
(selected || this.state.created[index]) ? panel : null
|
||||
)
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user