зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1284221 - Move the font panel to the last position in the sidebar; r=jdescottes
MozReview-Commit-ID: Kh64bTWxQkA --HG-- extra : rebase_source : fef638a9abb65e918ef593434a9224828c44d29e
This commit is contained in:
Родитель
4d95e26734
Коммит
3d0938464a
|
@ -144,7 +144,9 @@ ToolSidebar.prototype = {
|
|||
// Add menuitems to the alltabs menu if there are already tabs in the
|
||||
// sidebar
|
||||
for (let [id, tab] of this._tabs) {
|
||||
let item = this._addItemToAllTabsMenu(id, tab, tab.hasAttribute("selected"));
|
||||
let item = this._addItemToAllTabsMenu(id, tab, {
|
||||
selected: tab.hasAttribute("selected")
|
||||
});
|
||||
if (tab.hidden) {
|
||||
item.hidden = true;
|
||||
}
|
||||
|
@ -179,23 +181,30 @@ ToolSidebar.prototype = {
|
|||
/**
|
||||
* Add an item in the allTabs menu for a given tab.
|
||||
*/
|
||||
_addItemToAllTabsMenu: function (id, tab, selected = false) {
|
||||
_addItemToAllTabsMenu: function (id, tab, options) {
|
||||
if (!this._allTabsBtn) {
|
||||
return;
|
||||
}
|
||||
|
||||
let item = this._panelDoc.createElementNS(XULNS, "menuitem");
|
||||
item.setAttribute("id", "sidebar-alltabs-item-" + id);
|
||||
let idPrefix = "sidebar-alltabs-item-";
|
||||
item.setAttribute("id", idPrefix + id);
|
||||
item.setAttribute("label", tab.getAttribute("label"));
|
||||
item.setAttribute("type", "checkbox");
|
||||
if (selected) {
|
||||
if (options.selected) {
|
||||
item.setAttribute("checked", true);
|
||||
}
|
||||
// The auto-checking of menuitems in this menu doesn't work, so let's do
|
||||
// it manually
|
||||
item.setAttribute("autocheck", false);
|
||||
|
||||
this._allTabsBtn.querySelector("menupopup").appendChild(item);
|
||||
let menu = this._allTabsBtn.querySelector("menupopup");
|
||||
if (options.insertBefore) {
|
||||
let referenceItem = menu.querySelector(`#${idPrefix}${options.insertBefore}`);
|
||||
menu.insertBefore(item, referenceItem);
|
||||
} else {
|
||||
menu.appendChild(item);
|
||||
}
|
||||
|
||||
item.addEventListener("click", () => {
|
||||
this._tabbox.selectedTab = tab;
|
||||
|
@ -210,10 +219,14 @@ ToolSidebar.prototype = {
|
|||
* Register a tab. A tab is a document.
|
||||
* The document must have a title, which will be used as the name of the tab.
|
||||
*
|
||||
* @param {string} tab uniq id
|
||||
* @param {string} url
|
||||
* @param {string} id The unique id for this tab.
|
||||
* @param {string} url The URL of the document to load in this new tab.
|
||||
* @param {Object} options A set of options for this new tab:
|
||||
* - {Boolean} selected Set to true to make this new tab selected by default.
|
||||
* - {String} insertBefore By default, the new tab is appended at the end of the
|
||||
* tabbox, pass the ID of an existing tab to insert it before that tab instead.
|
||||
*/
|
||||
addTab: function (id, url, selected = false) {
|
||||
addTab: function (id, url, options = {}) {
|
||||
let iframe = this._panelDoc.createElementNS(XULNS, "iframe");
|
||||
iframe.className = "iframe-" + id;
|
||||
iframe.setAttribute("flex", "1");
|
||||
|
@ -222,13 +235,21 @@ ToolSidebar.prototype = {
|
|||
|
||||
// Creating the tab and adding it to the tabbox
|
||||
let tab = this._panelDoc.createElementNS(XULNS, "tab");
|
||||
this._tabbox.tabs.appendChild(tab);
|
||||
tab.setAttribute("label", ""); // Avoid showing "undefined" while the tab is loading
|
||||
|
||||
tab.setAttribute("id", this.TAB_ID_PREFIX + id);
|
||||
tab.setAttribute("crop", "end");
|
||||
// Avoid showing "undefined" while the tab is loading
|
||||
tab.setAttribute("label", "");
|
||||
|
||||
if (options.insertBefore) {
|
||||
let referenceTab = this.getTab(options.insertBefore);
|
||||
this._tabbox.tabs.insertBefore(tab, referenceTab);
|
||||
} else {
|
||||
this._tabbox.tabs.appendChild(tab);
|
||||
}
|
||||
|
||||
// Add the tab to the allTabs menu if exists
|
||||
let allTabsItem = this._addItemToAllTabsMenu(id, tab, selected);
|
||||
let allTabsItem = this._addItemToAllTabsMenu(id, tab, options);
|
||||
|
||||
let onIFrameLoaded = (event) => {
|
||||
let doc = event.target;
|
||||
|
@ -251,7 +272,13 @@ ToolSidebar.prototype = {
|
|||
let tabpanel = this._panelDoc.createElementNS(XULNS, "tabpanel");
|
||||
tabpanel.setAttribute("id", this.TABPANEL_ID_PREFIX + id);
|
||||
tabpanel.appendChild(iframe);
|
||||
this._tabbox.tabpanels.appendChild(tabpanel);
|
||||
|
||||
if (options.insertBefore) {
|
||||
let referenceTabpanel = this.getTabPanel(options.insertBefore);
|
||||
this._tabbox.tabpanels.insertBefore(tabpanel, referenceTabpanel);
|
||||
} else {
|
||||
this._tabbox.tabpanels.appendChild(tabpanel);
|
||||
}
|
||||
|
||||
this._tooltip = this._panelDoc.createElementNS(XULNS, "tooltip");
|
||||
this._tooltip.id = "aHTMLTooltip";
|
||||
|
@ -263,7 +290,7 @@ ToolSidebar.prototype = {
|
|||
// We store the index of this tab.
|
||||
this._tabs.set(id, tab);
|
||||
|
||||
if (selected) {
|
||||
if (options.selected) {
|
||||
this._selectTabSoon(id);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ function test() {
|
|||
allTabsReady(panel);
|
||||
});
|
||||
|
||||
panel.sidebar.addTab("tab1", tab1URL, true);
|
||||
panel.sidebar.addTab("tab1", tab1URL, {selected: true});
|
||||
panel.sidebar.addTab("tab2", tab2URL);
|
||||
panel.sidebar.addTab("tab3", tab3URL);
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ function test() {
|
|||
});
|
||||
|
||||
panel.sidebar.once("tab1-selected", () => finishUp(panel));
|
||||
panel.sidebar.addTab("tab1", tab1URL, true);
|
||||
panel.sidebar.addTab("tab1", tab1URL, {selected: true});
|
||||
panel.sidebar.show();
|
||||
}).then(null, console.error);
|
||||
});
|
||||
|
|
|
@ -48,7 +48,7 @@ add_task(function* () {
|
|||
info("Adding 10 tabs to the sidebar widget");
|
||||
for (let nb = 0; nb < 10; nb++) {
|
||||
let url = `data:text/html;charset=utf8,<title>tab ${nb}</title><p>Test tab ${nb}</p>`;
|
||||
sidebar.addTab("tab" + nb, url, nb === 0);
|
||||
sidebar.addTab("tab" + nb, url, {selected: nb === 0});
|
||||
}
|
||||
|
||||
info("Fake an overflow event so that the all-tabs menu is visible");
|
||||
|
|
|
@ -407,19 +407,19 @@ InspectorPanel.prototype = {
|
|||
|
||||
this.ruleview = new RuleViewTool(this, this.panelWin);
|
||||
this.computedview = new ComputedViewTool(this, this.panelWin);
|
||||
|
||||
if (Services.prefs.getBoolPref("devtools.fontinspector.enabled") &&
|
||||
this.canGetUsedFontFaces) {
|
||||
this.fontInspector = new FontInspector(this, this.panelWin);
|
||||
this.sidebar.toggleTab(true, "fontinspector");
|
||||
}
|
||||
|
||||
this.layoutview = new LayoutView(this, this.panelWin);
|
||||
|
||||
if (this.target.form.animationsActor) {
|
||||
this.sidebar.addTab("animationinspector",
|
||||
"chrome://devtools/content/animationinspector/animation-inspector.xhtml",
|
||||
defaultTab == "animationinspector");
|
||||
{selected: defaultTab == "animationinspector",
|
||||
insertBefore: "fontinspector"});
|
||||
}
|
||||
|
||||
if (Services.prefs.getBoolPref("devtools.fontinspector.enabled") &&
|
||||
this.canGetUsedFontFaces) {
|
||||
this.fontInspector = new FontInspector(this, this.panelWin);
|
||||
this.sidebar.toggleTab(true, "fontinspector");
|
||||
}
|
||||
|
||||
this.sidebar.show(defaultTab);
|
||||
|
|
|
@ -58,13 +58,13 @@
|
|||
<tab id="sidebar-tab-computedview"
|
||||
label="&computedViewTitle;"
|
||||
crop="end"/>
|
||||
<tab id="sidebar-tab-layoutview"
|
||||
label="&layoutViewTitle;"
|
||||
crop="end"/>
|
||||
<tab id="sidebar-tab-fontinspector"
|
||||
label="&fontInspectorTitle;"
|
||||
crop="end"
|
||||
hidden="true"/>
|
||||
<tab id="sidebar-tab-layoutview"
|
||||
label="&layoutViewTitle;"
|
||||
crop="end"/>
|
||||
</tabs>
|
||||
<tabpanels flex="1">
|
||||
<tabpanel id="sidebar-panel-ruleview" class="devtools-monospace theme-sidebar inspector-tabpanel">
|
||||
|
@ -116,41 +116,6 @@
|
|||
</html:div>
|
||||
</tabpanel>
|
||||
|
||||
<tabpanel id="sidebar-panel-fontinspector" class="devtools-monospace theme-sidebar inspector-tabpanel">
|
||||
<html:div class="devtools-toolbar">
|
||||
<html:div class="devtools-searchbox">
|
||||
<html:input id="font-preview-text-input"
|
||||
class="devtools-textinput"
|
||||
type="search"
|
||||
placeholder="&previewHint;"/>
|
||||
</html:div>
|
||||
</html:div>
|
||||
|
||||
<html:div id="font-container">
|
||||
<html:ul id="all-fonts"></html:ul>
|
||||
<html:button id="font-showall">&showAllFonts;</html:button>
|
||||
</html:div>
|
||||
|
||||
<html:div id="font-template">
|
||||
<html:section class="font">
|
||||
<html:div class="font-preview-container">
|
||||
<html:img class="font-preview"></html:img>
|
||||
</html:div>
|
||||
<html:div class="font-info">
|
||||
<html:h1 class="font-name"></html:h1>
|
||||
<html:span class="font-is-local">&system;</html:span>
|
||||
<html:span class="font-is-remote">&remote;</html:span>
|
||||
<html:p class="font-format-url">
|
||||
<html:input readonly="readonly" class="font-url"></html:input>
|
||||
<html:span class="font-format"></html:span>
|
||||
</html:p>
|
||||
<html:p class="font-css">&usedAs; "<html:span class="font-css-name"></html:span>"</html:p>
|
||||
<html:pre class="font-css-code"></html:pre>
|
||||
</html:div>
|
||||
</html:section>
|
||||
</html:div>
|
||||
</tabpanel>
|
||||
|
||||
<tabpanel id="sidebar-panel-layoutview" class="devtools-monospace theme-sidebar inspector-tabpanel">
|
||||
<html:div id="layout-wrapper">
|
||||
<html:div id="layout-container">
|
||||
|
@ -199,6 +164,41 @@
|
|||
</html:div>
|
||||
</html:div>
|
||||
</tabpanel>
|
||||
|
||||
<tabpanel id="sidebar-panel-fontinspector" class="devtools-monospace theme-sidebar inspector-tabpanel">
|
||||
<html:div class="devtools-toolbar">
|
||||
<html:div class="devtools-searchbox">
|
||||
<html:input id="font-preview-text-input"
|
||||
class="devtools-textinput"
|
||||
type="search"
|
||||
placeholder="&previewHint;"/>
|
||||
</html:div>
|
||||
</html:div>
|
||||
|
||||
<html:div id="font-container">
|
||||
<html:ul id="all-fonts"></html:ul>
|
||||
<html:button id="font-showall">&showAllFonts;</html:button>
|
||||
</html:div>
|
||||
|
||||
<html:div id="font-template">
|
||||
<html:section class="font">
|
||||
<html:div class="font-preview-container">
|
||||
<html:img class="font-preview"></html:img>
|
||||
</html:div>
|
||||
<html:div class="font-info">
|
||||
<html:h1 class="font-name"></html:h1>
|
||||
<html:span class="font-is-local">&system;</html:span>
|
||||
<html:span class="font-is-remote">&remote;</html:span>
|
||||
<html:p class="font-format-url">
|
||||
<html:input readonly="readonly" class="font-url"></html:input>
|
||||
<html:span class="font-format"></html:span>
|
||||
</html:p>
|
||||
<html:p class="font-css">&usedAs; "<html:span class="font-css-name"></html:span>"</html:p>
|
||||
<html:pre class="font-css-code"></html:pre>
|
||||
</html:div>
|
||||
</html:section>
|
||||
</html:div>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
</box>
|
||||
|
|
|
@ -2309,7 +2309,7 @@ ScratchpadSidebar.prototype = {
|
|||
}
|
||||
else {
|
||||
this._sidebar.once("variablesview-ready", onTabReady);
|
||||
this._sidebar.addTab("variablesview", VARIABLES_VIEW_URL, true);
|
||||
this._sidebar.addTab("variablesview", VARIABLES_VIEW_URL, {selected: true});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
|
|
|
@ -657,7 +657,7 @@ JSTerm.prototype = {
|
|||
}
|
||||
} else {
|
||||
this.sidebar.once("variablesview-ready", onTabReady);
|
||||
this.sidebar.addTab("variablesview", VARIABLES_VIEW_URL, true);
|
||||
this.sidebar.addTab("variablesview", VARIABLES_VIEW_URL, {selected: true});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
|
|
Загрузка…
Ссылка в новой задаче