mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1307940 - Add toolbox-dependent method to serviceContainer only if toolbox is available. r=bgrins
MozReview-Commit-ID: CjRXKemaJ4f --HG-- extra : rebase_source : e2ba83b3b8594528f9c912407110e4a288cb6c97
This commit is contained in:
parent
2ddcc6a9bf
commit
73a7d1d41b
@ -63,9 +63,13 @@ function GripMessageBody(props) {
|
||||
let onDOMNodeMouseOut;
|
||||
let onInspectIconClick;
|
||||
if (serviceContainer) {
|
||||
onDOMNodeMouseOver = (object) => serviceContainer.highlightDomElement(object);
|
||||
onDOMNodeMouseOver = serviceContainer.highlightDomElement
|
||||
? (object) => serviceContainer.highlightDomElement(object)
|
||||
: null;
|
||||
onDOMNodeMouseOut = serviceContainer.unHighlightDomElement;
|
||||
onInspectIconClick = (object) => serviceContainer.openNodeInInspector(object);
|
||||
onInspectIconClick = serviceContainer.openNodeInInspector
|
||||
? (object) => serviceContainer.openNodeInInspector(object)
|
||||
: null;
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -57,9 +57,9 @@ function NetworkEventMessage({
|
||||
statusInfo = `[${httpVersion} ${status} ${statusText} ${totalTime}ms]`;
|
||||
}
|
||||
|
||||
function openNetworkMonitor() {
|
||||
serviceContainer.openNetworkPanel(actor);
|
||||
}
|
||||
const openNetworkMonitor = serviceContainer.openNetworkPanel
|
||||
? () => serviceContainer.openNetworkPanel(actor)
|
||||
: null;
|
||||
|
||||
const method = dom.span({className: "method" }, request.method);
|
||||
const xhr = isXHR
|
||||
|
@ -49,9 +49,9 @@ const Message = createClass({
|
||||
timeStamp: PropTypes.number,
|
||||
serviceContainer: PropTypes.shape({
|
||||
emitNewMessage: PropTypes.func.isRequired,
|
||||
onViewSourceInDebugger: PropTypes.func.isRequired,
|
||||
onViewSourceInScratchpad: PropTypes.func.isRequired,
|
||||
onViewSourceInStyleEditor: PropTypes.func.isRequired,
|
||||
onViewSourceInDebugger: PropTypes.func,
|
||||
onViewSourceInScratchpad: PropTypes.func,
|
||||
onViewSourceInStyleEditor: PropTypes.func,
|
||||
openContextMenu: PropTypes.func.isRequired,
|
||||
openLink: PropTypes.func.isRequired,
|
||||
sourceMapService: PropTypes.any,
|
||||
|
@ -38,16 +38,42 @@ NewConsoleOutputWrapper.prototype = {
|
||||
this.jsterm.hud[id] = node;
|
||||
};
|
||||
|
||||
let childComponent = ConsoleOutput({
|
||||
serviceContainer: {
|
||||
attachRefToHud,
|
||||
emitNewMessage: (node, messageId) => {
|
||||
this.jsterm.hud.emit("new-messages", new Set([{
|
||||
node,
|
||||
messageId,
|
||||
}]));
|
||||
},
|
||||
hudProxyClient: this.jsterm.hud.proxy.client,
|
||||
const serviceContainer = {
|
||||
attachRefToHud,
|
||||
emitNewMessage: (node, messageId) => {
|
||||
this.jsterm.hud.emit("new-messages", new Set([{
|
||||
node,
|
||||
messageId,
|
||||
}]));
|
||||
},
|
||||
hudProxyClient: this.jsterm.hud.proxy.client,
|
||||
openContextMenu: (e, message) => {
|
||||
let { screenX, screenY, target } = e;
|
||||
|
||||
let messageEl = target.closest(".message");
|
||||
let clipboardText = messageEl ? messageEl.textContent : null;
|
||||
|
||||
// Retrieve closes actor id from the DOM.
|
||||
let actorEl = target.closest("[data-link-actor-id]");
|
||||
let actor = actorEl ? actorEl.dataset.linkActorId : null;
|
||||
|
||||
let menu = createContextMenu(this.jsterm, this.parentNode,
|
||||
{ actor, clipboardText, message });
|
||||
|
||||
// Emit the "menu-open" event for testing.
|
||||
menu.once("open", () => this.emit("menu-open"));
|
||||
menu.popup(screenX, screenY, this.toolbox);
|
||||
|
||||
return menu;
|
||||
},
|
||||
openLink: url => this.jsterm.hud.owner.openLink(url),
|
||||
createElement: nodename => {
|
||||
return this.document.createElementNS("http://www.w3.org/1999/xhtml", nodename);
|
||||
},
|
||||
};
|
||||
|
||||
if (this.toolbox) {
|
||||
Object.assign(serviceContainer, {
|
||||
onViewSourceInDebugger: frame => {
|
||||
this.toolbox.viewSourceInDebugger(frame.url, frame.line).then(() =>
|
||||
this.jsterm.hud.emit("source-in-debugger-opened")
|
||||
@ -61,25 +87,6 @@ NewConsoleOutputWrapper.prototype = {
|
||||
frame.url,
|
||||
frame.line
|
||||
),
|
||||
openContextMenu: (e, message) => {
|
||||
let { screenX, screenY, target } = e;
|
||||
|
||||
let messageEl = target.closest(".message");
|
||||
let clipboardText = messageEl ? messageEl.textContent : null;
|
||||
|
||||
// Retrieve closes actor id from the DOM.
|
||||
let actorEl = target.closest("[data-link-actor-id]");
|
||||
let actor = actorEl ? actorEl.dataset.linkActorId : null;
|
||||
|
||||
let menu = createContextMenu(this.jsterm, this.parentNode,
|
||||
{ actor, clipboardText, message });
|
||||
|
||||
// Emit the "menu-open" event for testing.
|
||||
menu.once("open", () => this.emit("menu-open"));
|
||||
menu.popup(screenX, screenY, this.toolbox);
|
||||
|
||||
return menu;
|
||||
},
|
||||
openNetworkPanel: (requestId) => {
|
||||
return this.toolbox.selectTool("netmonitor").then(panel => {
|
||||
return panel.panelWin.NetMonitorController.inspectRequest(requestId);
|
||||
@ -87,25 +94,17 @@ NewConsoleOutputWrapper.prototype = {
|
||||
},
|
||||
sourceMapService:
|
||||
this.toolbox ? this.toolbox._deprecatedServerSourceMapService : null,
|
||||
openLink: url => this.jsterm.hud.owner.openLink(url),
|
||||
createElement: nodename => {
|
||||
return this.document.createElementNS("http://www.w3.org/1999/xhtml", nodename);
|
||||
},
|
||||
highlightDomElement: (grip, options = {}) => {
|
||||
return this.toolbox && this.toolbox.highlighterUtils
|
||||
return this.toolbox.highlighterUtils
|
||||
? this.toolbox.highlighterUtils.highlightDomValueGrip(grip, options)
|
||||
: null;
|
||||
},
|
||||
unHighlightDomElement: (forceHide = false) => {
|
||||
return this.toolbox && this.toolbox.highlighterUtils
|
||||
return this.toolbox.highlighterUtils
|
||||
? this.toolbox.highlighterUtils.unhighlight(forceHide)
|
||||
: null;
|
||||
},
|
||||
openNodeInInspector: async (grip) => {
|
||||
if (!this.toolbox) {
|
||||
return Promise.reject("no toolbox");
|
||||
}
|
||||
|
||||
let onSelectInspector = this.toolbox.selectTool("inspector");
|
||||
let onGripNodeToFront = this.toolbox.highlighterUtils.gripToNodeFront(grip);
|
||||
let [
|
||||
@ -118,8 +117,10 @@ NewConsoleOutputWrapper.prototype = {
|
||||
|
||||
return Promise.all([onNodeFrontSet, onInspectorUpdated]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let childComponent = ConsoleOutput({serviceContainer});
|
||||
|
||||
let filterBar = FilterBar({
|
||||
serviceContainer: {
|
||||
|
Loading…
Reference in New Issue
Block a user