Bug 1131609 - getOriginalLocation should take a sourceActor;r=jlong

This commit is contained in:
Eddy Bruël 2015-02-12 05:40:52 +01:00
Родитель 39f8bd559d
Коммит 7572460b47
2 изменённых файлов: 44 добавлений и 36 удалений

Просмотреть файл

@ -742,7 +742,7 @@ ThreadActor.prototype = {
}
packet.why = aReason;
let loc = getFrameLocation(aFrame);
let loc = this.sources.getFrameLocation(aFrame);
this.sources.getOriginalLocation(loc).then(aOrigPosition => {
if (!aOrigPosition.sourceActor) {
// The only time the source actor will be null is if there
@ -805,7 +805,7 @@ ThreadActor.prototype = {
_makeOnEnterFrame: function ({ pauseAndRespond }) {
return aFrame => {
const generatedLocation = getFrameLocation(aFrame);
const generatedLocation = this.sources.getFrameLocation(aFrame);
let { sourceActor } = this.synchronize(this.sources.getOriginalLocation(
generatedLocation));
let url = sourceActor.url;
@ -820,7 +820,7 @@ ThreadActor.prototype = {
return function (aCompletion) {
// onPop is called with 'this' set to the current frame.
const generatedLocation = getFrameLocation(this);
const generatedLocation = thread.sources.getFrameLocation(this);
const { sourceActor } = thread.synchronize(thread.sources.getOriginalLocation(
generatedLocation));
const url = sourceActor.url;
@ -862,7 +862,7 @@ ThreadActor.prototype = {
return function () {
// onStep is called with 'this' set to the current frame.
const generatedLocation = getFrameLocation(this);
const generatedLocation = thread.sources.getFrameLocation(this);
const newLocation = thread.synchronize(thread.sources.getOriginalLocation(
generatedLocation));
@ -942,7 +942,7 @@ ThreadActor.prototype = {
message: "Unknown resumeLimit type" });
}
const generatedLocation = getFrameLocation(this.youngestFrame);
const generatedLocation = this.sources.getFrameLocation(this.youngestFrame);
return this.sources.getOriginalLocation(generatedLocation)
.then(originalLocation => {
const { onEnterFrame, onPop, onStep } = this._makeSteppingHooks(originalLocation,
@ -1289,7 +1289,7 @@ ThreadActor.prototype = {
frames.push(form);
let promise = this.sources.getOriginalLocation({
source: frame.script.source,
sourceActor: this.sources.createNonSourceMappedActor(frame.script.source),
line: form.where.line,
column: form.where.column
}).then((aOrigLocation) => {
@ -1902,7 +1902,7 @@ ThreadActor.prototype = {
onDebuggerStatement: function (aFrame) {
// Don't pause if we are currently stepping (in or over) or the frame is
// black-boxed.
const generatedLocation = getFrameLocation(aFrame);
const generatedLocation = this.sources.getFrameLocation(aFrame);
const { sourceActor } = this.synchronize(this.sources.getOriginalLocation(
generatedLocation));
const url = sourceActor ? sourceActor.url : null;
@ -1934,7 +1934,7 @@ ThreadActor.prototype = {
return undefined;
}
const generatedLocation = getFrameLocation(aFrame);
const generatedLocation = this.sources.getFrameLocation(aFrame);
const { sourceActor } = this.synchronize(this.sources.getOriginalLocation(
generatedLocation));
const url = sourceActor ? sourceActor.url : null;
@ -2956,7 +2956,7 @@ SourceActor.prototype = {
return Promise.resolve().then(() => {
if (actualLocation.sourceActor.source) {
return this.threadActor.sources.getOriginalLocation({
source: actualLocation.sourceActor.source,
sourceActor: actualLocation.sourceActor,
line: actualLocation.line,
column: actualLocation.column
});
@ -3330,7 +3330,7 @@ ObjectActor.prototype = {
}
const generatedLocation = {
source: this.obj.script.source,
sourceActor: this.threadActor.sources.createNonSourceMappedActor(this.obj.script.source),
line: this.obj.script.startLine,
// TODO bug 901138: use Debugger.Script.prototype.startColumn.
column: 0
@ -4573,7 +4573,12 @@ FrameActor.prototype = {
form.this = threadActor.createValueGrip(this.frame.this);
form.arguments = this._args();
if (this.frame.script) {
form.where = getFrameLocation(this.frame);
var loc = this.threadActor.sources.getFrameLocation(this.frame);
form.where = {
source: loc.sourceActor.form(),
line: loc.line,
column: loc.column
};
}
if (!this.frame.older) {
@ -4709,7 +4714,7 @@ BreakpointActor.prototype = {
hit: function (aFrame) {
// Don't pause if we are currently stepping (in or over) or the frame is
// black-boxed.
let loc = getFrameLocation(aFrame);
let loc = this.threadActor.sources.getFrameLocation(aFrame);
let { sourceActor } = this.threadActor.synchronize(
this.threadActor.sources.getOriginalLocation(loc));
let url = sourceActor.url;
@ -5536,6 +5541,26 @@ ThreadSources.prototype = {
this._sourceMapCache[url] = resolve(aMap);
},
/**
* Return the non-source-mapped location of the given Debugger.Frame. If the
* frame does not have a script, the location's properties are all null.
*
* @param Debugger.Frame aFrame
* The frame whose location we are getting.
* @returns Object
* Returns an object of the form { source, line, column }
*/
getFrameLocation: function (aFrame) {
if (!aFrame || !aFrame.script) {
return { sourceActor: null, line: null, column: null };
}
return {
sourceActor: this.createNonSourceMappedActor(aFrame.script.source),
line: aFrame.script.getOffsetLine(aFrame.offset),
column: getOffsetColumn(aFrame.offset, aFrame.script)
}
},
/**
* Returns a promise of the location in the original source if the source is
* source mapped, otherwise a promise of the same location. This can
@ -5543,7 +5568,10 @@ ThreadSources.prototype = {
* sure to that it works properly, reusing source maps if already
* fetched. Use this from any actor that needs sourcemapping.
*/
getOriginalLocation: function ({ source, line, column }) {
getOriginalLocation: function ({ sourceActor, line, column }) {
let source = sourceActor.source;
let url = source ? source.url : sourceActor._originalUrl;
// In certain scenarios the source map may have not been fetched
// yet (or at least tied to this Debugger.Source instance), so use
// `fetchSourceMap` instead of `getSourceMap`. This allows this
@ -5582,8 +5610,8 @@ ThreadSources.prototype = {
// No source map
return resolve({
sourceActor: this.createNonSourceMappedActor(source),
url: source.url,
sourceActor: sourceActor,
url: url,
line: line,
column: column
});
@ -5737,26 +5765,6 @@ function isHiddenSource(aSource) {
return aSource.text === '() {\n}';
}
/**
* Return the non-source-mapped location of the given Debugger.Frame. If the
* frame does not have a script, the location's properties are all null.
*
* @param Debugger.Frame aFrame
* The frame whose location we are getting.
* @returns Object
* Returns an object of the form { source, line, column }
*/
function getFrameLocation(aFrame) {
if (!aFrame || !aFrame.script) {
return { source: null, line: null, column: null };
}
return {
source: aFrame.script.source,
line: aFrame.script.getOffsetLine(aFrame.offset),
column: getOffsetColumn(aFrame.offset, aFrame.script)
}
}
/**
* Returns true if its argument is not null.
*/

Просмотреть файл

@ -340,7 +340,7 @@ TracerActor.prototype = {
let sources = this._parent.threadActor.sources;
sourceMappedLocation = yield sources.getOriginalLocation({
source: aFrame.script.source,
sourceActor: sources.createNonSourceMappedActor(aFrame.script.source),
url: aFrame.script.source.url,
line: aFrame.script.startLine,
// We should return the location of the start of the script, but