зеркало из https://github.com/mozilla/pjs.git
Bug 672002 - Move HTML panel to a docked panel in the main browser window (highlighter); r=msucan
This commit is contained in:
Родитель
fb6eccdaa0
Коммит
9463d479c8
|
@ -49,6 +49,8 @@ Cu.import("resource:///modules/Services.jsm");
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["TreePanel"];
|
var EXPORTED_SYMBOLS = ["TreePanel"];
|
||||||
|
|
||||||
|
const INSPECTOR_URI = "chrome://browser/content/inspector.html";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreePanel
|
* TreePanel
|
||||||
* A container for the Inspector's HTML Tree Panel widget constructor function.
|
* A container for the Inspector's HTML Tree Panel widget constructor function.
|
||||||
|
@ -62,13 +64,21 @@ function TreePanel(aContext, aIUI) {
|
||||||
TreePanel.prototype = {
|
TreePanel.prototype = {
|
||||||
showTextNodesWithWhitespace: false,
|
showTextNodesWithWhitespace: false,
|
||||||
id: "treepanel", // DO NOT LOCALIZE
|
id: "treepanel", // DO NOT LOCALIZE
|
||||||
|
openInDock: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* container.
|
* The tree panel container element.
|
||||||
* @returns xul:panel element
|
* @returns xul:panel|xul:vbox|null
|
||||||
|
* xul:panel is returned when the tree panel is not docked, or
|
||||||
|
* xul:vbox when when the tree panel is docked.
|
||||||
|
* null is returned when no container is available.
|
||||||
*/
|
*/
|
||||||
get container()
|
get container()
|
||||||
{
|
{
|
||||||
|
if (this.openInDock) {
|
||||||
|
return this.document.getElementById("inspector-tree-box");
|
||||||
|
}
|
||||||
|
|
||||||
return this.document.getElementById("inspector-tree-panel");
|
return this.document.getElementById("inspector-tree-panel");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -98,13 +108,15 @@ TreePanel.prototype = {
|
||||||
show: this.open,
|
show: this.open,
|
||||||
hide: this.close,
|
hide: this.close,
|
||||||
onSelect: this.select,
|
onSelect: this.select,
|
||||||
panel: this.container,
|
panel: this.openInDock ? null : this.container,
|
||||||
unregister: this.destroy,
|
unregister: this.destroy,
|
||||||
};
|
};
|
||||||
this.editingEvents = {};
|
this.editingEvents = {};
|
||||||
|
|
||||||
this._boundClose = this.close.bind(this);
|
if (!this.openInDock) {
|
||||||
this.container.addEventListener("popuphiding", this._boundClose, false);
|
this._boundClose = this.close.bind(this);
|
||||||
|
this.container.addEventListener("popuphiding", this._boundClose, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Register the HTML panel with the highlighter
|
// Register the HTML panel with the highlighter
|
||||||
this.IUI.registerTool(this.registrationObject);
|
this.IUI.registerTool(this.registrationObject);
|
||||||
|
@ -144,38 +156,49 @@ TreePanel.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initializingTreePanel = true;
|
this.initializingTreePanel = true;
|
||||||
this.container.hidden = false;
|
if (!this.openInDock)
|
||||||
|
this.container.hidden = false;
|
||||||
|
|
||||||
this.treeIFrame = this.document.getElementById("inspector-tree-iframe");
|
this.treeIFrame = this.document.getElementById("inspector-tree-iframe");
|
||||||
if (!this.treeIFrame) {
|
if (!this.treeIFrame) {
|
||||||
let resizerBox = this.document.getElementById("tree-panel-resizer-box");
|
|
||||||
this.treeIFrame = this.document.createElement("iframe");
|
this.treeIFrame = this.document.createElement("iframe");
|
||||||
this.treeIFrame.setAttribute("id", "inspector-tree-iframe");
|
this.treeIFrame.setAttribute("id", "inspector-tree-iframe");
|
||||||
this.treeIFrame.setAttribute("flex", "1");
|
this.treeIFrame.flex = 1;
|
||||||
this.treeIFrame.setAttribute("type", "content");
|
this.treeIFrame.setAttribute("type", "content");
|
||||||
this.treeIFrame = this.container.insertBefore(this.treeIFrame, resizerBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let self = this;
|
if (this.openInDock) { // Create vbox
|
||||||
this.container.addEventListener("popupshown", function treePanelShown() {
|
this.openDocked();
|
||||||
self.container.removeEventListener("popupshown",
|
return;
|
||||||
treePanelShown, false);
|
}
|
||||||
|
|
||||||
self.treeIFrame.addEventListener("load",
|
let resizerBox = this.document.getElementById("tree-panel-resizer-box");
|
||||||
function loadedInitializeTreePanel() {
|
this.treeIFrame = this.container.insertBefore(this.treeIFrame, resizerBox);
|
||||||
self.treeIFrame.removeEventListener("load",
|
|
||||||
loadedInitializeTreePanel, true);
|
|
||||||
self.initializeIFrame();
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
let src = self.treeIFrame.getAttribute("src");
|
let boundLoadedInitializeTreePanel = function loadedInitializeTreePanel()
|
||||||
if (src != "chrome://browser/content/inspector.html") {
|
{
|
||||||
self.treeIFrame.setAttribute("src",
|
this.treeIFrame.removeEventListener("load",
|
||||||
"chrome://browser/content/inspector.html");
|
boundLoadedInitializeTreePanel, true);
|
||||||
|
this.initializeIFrame();
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
let boundTreePanelShown = function treePanelShown()
|
||||||
|
{
|
||||||
|
this.container.removeEventListener("popupshown",
|
||||||
|
boundTreePanelShown, false);
|
||||||
|
|
||||||
|
this.treeIFrame.addEventListener("load",
|
||||||
|
boundLoadedInitializeTreePanel, true);
|
||||||
|
|
||||||
|
let src = this.treeIFrame.getAttribute("src");
|
||||||
|
if (src != INSPECTOR_URI) {
|
||||||
|
this.treeIFrame.setAttribute("src", INSPECTOR_URI);
|
||||||
} else {
|
} else {
|
||||||
self.treeIFrame.contentWindow.location.reload();
|
this.treeIFrame.contentWindow.location.reload();
|
||||||
}
|
}
|
||||||
}, false);
|
}.bind(this);
|
||||||
|
|
||||||
|
this.container.addEventListener("popupshown", boundTreePanelShown, false);
|
||||||
|
|
||||||
const panelWidthRatio = 7 / 8;
|
const panelWidthRatio = 7 / 8;
|
||||||
const panelHeightRatio = 1 / 5;
|
const panelHeightRatio = 1 / 5;
|
||||||
|
@ -192,11 +215,68 @@ TreePanel.prototype = {
|
||||||
this.container.sizeTo(width, height);
|
this.container.sizeTo(width, height);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openDocked: function TP_openDocked()
|
||||||
|
{
|
||||||
|
let treeBox = null;
|
||||||
|
let toolbar = this.IUI.toolbar.nextSibling; // Addons bar, typically
|
||||||
|
let toolbarParent =
|
||||||
|
this.IUI.browser.ownerDocument.getElementById("browser-bottombox");
|
||||||
|
treeBox = this.document.createElement("vbox");
|
||||||
|
treeBox.id = "inspector-tree-box";
|
||||||
|
treeBox.state = "open"; // for the registerTools API.
|
||||||
|
treeBox.minHeight = 10;
|
||||||
|
treeBox.flex = 1;
|
||||||
|
toolbarParent.insertBefore(treeBox, toolbar);
|
||||||
|
this.createResizer();
|
||||||
|
treeBox.appendChild(this.treeIFrame);
|
||||||
|
|
||||||
|
let boundLoadedInitializeTreePanel = function loadedInitializeTreePanel()
|
||||||
|
{
|
||||||
|
this.treeIFrame.removeEventListener("load",
|
||||||
|
boundLoadedInitializeTreePanel, true);
|
||||||
|
this.initializeIFrame();
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.treeIFrame.addEventListener("load",
|
||||||
|
boundLoadedInitializeTreePanel, true);
|
||||||
|
|
||||||
|
let src = this.treeIFrame.getAttribute("src");
|
||||||
|
if (src != INSPECTOR_URI) {
|
||||||
|
this.treeIFrame.setAttribute("src", INSPECTOR_URI);
|
||||||
|
} else {
|
||||||
|
this.treeIFrame.contentWindow.location.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lame resizer on the toolbar.
|
||||||
|
*/
|
||||||
|
createResizer: function TP_createResizer()
|
||||||
|
{
|
||||||
|
let resizer = this.document.createElement("resizer");
|
||||||
|
resizer.id = "inspector-horizontal-splitter";
|
||||||
|
resizer.setAttribute("dir", "top");
|
||||||
|
resizer.flex = 1;
|
||||||
|
resizer.setAttribute("element", "inspector-tree-box");
|
||||||
|
resizer.height = 24;
|
||||||
|
this.IUI.toolbar.appendChild(resizer);
|
||||||
|
this.resizer = resizer;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the TreePanel.
|
* Close the TreePanel.
|
||||||
*/
|
*/
|
||||||
close: function TP_close()
|
close: function TP_close()
|
||||||
{
|
{
|
||||||
|
if (this.openInDock) {
|
||||||
|
this.IUI.toolbar.removeChild(this.resizer);
|
||||||
|
let treeBox = this.container;
|
||||||
|
let treeBoxParent = treeBox.parentNode;
|
||||||
|
treeBoxParent.removeChild(treeBox);
|
||||||
|
} else {
|
||||||
|
this.container.hidePopup();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.treePanelDiv) {
|
if (this.treePanelDiv) {
|
||||||
this.treePanelDiv.ownerPanel = null;
|
this.treePanelDiv.ownerPanel = null;
|
||||||
let parent = this.treePanelDiv.parentNode;
|
let parent = this.treePanelDiv.parentNode;
|
||||||
|
@ -206,7 +286,6 @@ TreePanel.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.treeLoaded = false;
|
this.treeLoaded = false;
|
||||||
this.container.hidePopup();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,6 +294,9 @@ TreePanel.prototype = {
|
||||||
*/
|
*/
|
||||||
isOpen: function TP_isOpen()
|
isOpen: function TP_isOpen()
|
||||||
{
|
{
|
||||||
|
if (this.openInDock)
|
||||||
|
return this.treeLoaded && this.container;
|
||||||
|
|
||||||
return this.treeLoaded && this.container.state == "open";
|
return this.treeLoaded && this.container.state == "open";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -664,6 +746,7 @@ TreePanel.prototype = {
|
||||||
|
|
||||||
domplateUtils.setDOM(null);
|
domplateUtils.setDOM(null);
|
||||||
|
|
||||||
|
delete this.resizer;
|
||||||
delete this.treeWalker;
|
delete this.treeWalker;
|
||||||
|
|
||||||
if (this.treePanelDiv) {
|
if (this.treePanelDiv) {
|
||||||
|
@ -687,8 +770,10 @@ TreePanel.prototype = {
|
||||||
delete this.ioBox;
|
delete this.ioBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.container.removeEventListener("popuphiding", this._boundClose, false);
|
if (!this.openInDock) {
|
||||||
delete this._boundClose;
|
this.container.removeEventListener("popuphiding", this._boundClose, false);
|
||||||
|
delete this._boundClose;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1942,3 +1942,12 @@ panel[dimmed="true"] {
|
||||||
box-shadow: 0 0 0 1px black;
|
box-shadow: 0 0 0 1px black;
|
||||||
outline-color: white;
|
outline-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* need a "bumpy" background image for this!
|
||||||
|
*/
|
||||||
|
#inspector-horizontal-splitter {
|
||||||
|
background: none !important;
|
||||||
|
-moz-appearance: none;
|
||||||
|
cursor: n-resize;
|
||||||
|
}
|
||||||
|
|
|
@ -2602,3 +2602,13 @@ panel[dimmed="true"] {
|
||||||
#inspector-tools > toolbarbutton[checked]:hover:active {
|
#inspector-tools > toolbarbutton[checked]:hover:active {
|
||||||
background-color: hsla(210,8%,5%,.2);
|
background-color: hsla(210,8%,5%,.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* need a "bumpy" background image for this!
|
||||||
|
*/
|
||||||
|
#inspector-horizontal-splitter {
|
||||||
|
background: none !important;
|
||||||
|
-moz-appearance: none;
|
||||||
|
cursor: n-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -2558,3 +2558,13 @@ panel[dimmed="true"] {
|
||||||
box-shadow: 0 0 0 1px black;
|
box-shadow: 0 0 0 1px black;
|
||||||
outline-color: white;
|
outline-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* need a "bumpy" background image for this!
|
||||||
|
*/
|
||||||
|
#inspector-horizontal-splitter {
|
||||||
|
background: none !important;
|
||||||
|
-moz-appearance: none;
|
||||||
|
cursor: n-resize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче