зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1643180 - Part 7: Separate url-only file handling from url/line/column handling. r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D78388
This commit is contained in:
Родитель
3ce268493b
Коммит
5a1f19d2c4
|
@ -3972,6 +3972,23 @@ Toolbox.prototype = {
|
||||||
return this.win.gViewSourceUtils;
|
return this.win.gViewSourceUtils;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a CSS file when there is no line or column information available.
|
||||||
|
*
|
||||||
|
* @param {string} url The URL of the CSS file to open.
|
||||||
|
*/
|
||||||
|
viewGeneratedSourceInStyleEditor: async function(url) {
|
||||||
|
if (typeof url !== "string") {
|
||||||
|
console.warn("Failed to open generated source, no url given");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The style editor hides the generated file if the file has original
|
||||||
|
// sources, so we have no choice but to open whichever original file
|
||||||
|
// corresponds to the first line of the generated file.
|
||||||
|
return viewSource.viewSourceInStyleEditor(this, url, 1);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a URL for a stylesheet (generated or original), open in the style
|
* Given a URL for a stylesheet (generated or original), open in the style
|
||||||
* editor if possible. Falls back to plain "view-source:".
|
* editor if possible. Falls back to plain "view-source:".
|
||||||
|
@ -3983,6 +4000,16 @@ Toolbox.prototype = {
|
||||||
console.warn("Failed to open source, no url given");
|
console.warn("Failed to open source, no url given");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof line !== "number") {
|
||||||
|
console.warn(
|
||||||
|
"No line given when navigating to source. If you're seeing this, there is a bug."
|
||||||
|
);
|
||||||
|
|
||||||
|
// This is a fallback in case of programming errors, but in a perfect
|
||||||
|
// world, viewSourceInStyleEditorByURL would always get a line/colum.
|
||||||
|
line = 1;
|
||||||
|
column = null;
|
||||||
|
}
|
||||||
|
|
||||||
return viewSource.viewSourceInStyleEditor(this, url, line, column);
|
return viewSource.viewSourceInStyleEditor(this, url, line, column);
|
||||||
},
|
},
|
||||||
|
@ -4001,6 +4028,16 @@ Toolbox.prototype = {
|
||||||
console.warn("Failed to open source, no stylesheet given");
|
console.warn("Failed to open source, no stylesheet given");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof line !== "number") {
|
||||||
|
console.warn(
|
||||||
|
"No line given when navigating to source. If you're seeing this, there is a bug."
|
||||||
|
);
|
||||||
|
|
||||||
|
// This is a fallback in case of programming errors, but in a perfect
|
||||||
|
// world, viewSourceInStyleEditorByFront would always get a line/colum.
|
||||||
|
line = 1;
|
||||||
|
column = null;
|
||||||
|
}
|
||||||
|
|
||||||
return viewSource.viewSourceInStyleEditor(
|
return viewSource.viewSourceInStyleEditor(
|
||||||
this,
|
this,
|
||||||
|
@ -4023,6 +4060,20 @@ Toolbox.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a JS file when there is no line or column information available.
|
||||||
|
*
|
||||||
|
* @param {string} url The URL of the JS file to open.
|
||||||
|
*/
|
||||||
|
viewGeneratedSourceInDebugger: async function(url) {
|
||||||
|
if (typeof url !== "string") {
|
||||||
|
console.warn("Failed to open generated source, no url given");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return viewSource.viewSourceInDebugger(this, url, null, null, null, null);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens source in debugger, the sourcemapped location will be selected in
|
* Opens source in debugger, the sourcemapped location will be selected in
|
||||||
* the debugger panel, if the given location resolves to a know sourcemapped one.
|
* the debugger panel, if the given location resolves to a know sourcemapped one.
|
||||||
|
@ -4042,6 +4093,16 @@ Toolbox.prototype = {
|
||||||
console.warn("Failed to open generated source, no url/id given");
|
console.warn("Failed to open generated source, no url/id given");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (typeof sourceLine !== "number") {
|
||||||
|
console.warn(
|
||||||
|
"No line given when navigating to source. If you're seeing this, there is a bug."
|
||||||
|
);
|
||||||
|
|
||||||
|
// This is a fallback in case of programming errors, but in a perfect
|
||||||
|
// world, viewSourceInDebugger would always get a line/colum.
|
||||||
|
sourceLine = 1;
|
||||||
|
sourceColumn = null;
|
||||||
|
}
|
||||||
|
|
||||||
return viewSource.viewSourceInDebugger(
|
return viewSource.viewSourceInDebugger(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -1099,9 +1099,9 @@ MarkupView.prototype = {
|
||||||
if (type === "uri") {
|
if (type === "uri") {
|
||||||
openContentLink(url);
|
openContentLink(url);
|
||||||
} else if (type === "cssresource") {
|
} else if (type === "cssresource") {
|
||||||
return this.toolbox.viewSourceInStyleEditorByURL(url);
|
return this.toolbox.viewGeneratedSourceInStyleEditor(url);
|
||||||
} else if (type === "jsresource") {
|
} else if (type === "jsresource") {
|
||||||
return this.toolbox.viewSourceInDebugger(url);
|
return this.toolbox.viewGeneratedSourceInDebugger(url);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
|
|
|
@ -434,7 +434,7 @@ class RequestListContextMenu {
|
||||||
*/
|
*/
|
||||||
openInDebugger(url) {
|
openInDebugger(url) {
|
||||||
const toolbox = gDevTools.getToolbox(this.props.connector.getTabTarget());
|
const toolbox = gDevTools.getToolbox(this.props.connector.getTabTarget());
|
||||||
toolbox.viewSourceInDebugger(url, 0);
|
toolbox.viewGeneratedSourceInDebugger(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -442,7 +442,7 @@ class RequestListContextMenu {
|
||||||
*/
|
*/
|
||||||
openInStyleEditor(url) {
|
openInStyleEditor(url) {
|
||||||
const toolbox = gDevTools.getToolbox(this.props.connector.getTabTarget());
|
const toolbox = gDevTools.getToolbox(this.props.connector.getTabTarget());
|
||||||
toolbox.viewSourceInStyleEditorByURL(url, 0);
|
toolbox.viewGeneratedSourceInStyleEditor(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -183,6 +183,12 @@ async function getOriginalLocation(
|
||||||
generatedLine,
|
generatedLine,
|
||||||
generatedColumn
|
generatedColumn
|
||||||
) {
|
) {
|
||||||
|
// If there is no line number, then there's no chance that we'll get back
|
||||||
|
// a useful original location.
|
||||||
|
if (typeof generatedLine !== "number") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let originalLocation = null;
|
let originalLocation = null;
|
||||||
try {
|
try {
|
||||||
originalLocation = await toolbox.sourceMapService.getOriginalLocation({
|
originalLocation = await toolbox.sourceMapService.getOriginalLocation({
|
||||||
|
|
Загрузка…
Ссылка в новой задаче