Commit 99d6041b authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2011-04-08 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: use "locations" for debugger scripts, "lineNumbers" for the UI elements.
        https://bugs.webkit.org/show_bug.cgi?id=58118

        This change reuses location for call frames in the protocol + structures script
        location <-> source lines interaction better. When we need UI columns, we will add
        them, but we should distinguish between script and UI terms on the type level, not naming.

        * English.lproj/localizedStrings.js:
        * bindings/v8/DebuggerScript.js:
        * inspector/InjectedScriptSource.js:
        * inspector/Inspector.json:
        * inspector/front-end/CallStackSidebarPane.js:
        (WebInspector.CallStackSidebarPane.prototype.update.didGetSourceLine):
        (WebInspector.CallStackSidebarPane.prototype.update):
        * inspector/front-end/DebuggerPresentationModel.js:
        (WebInspector.DebuggerPresentationModel.prototype.addConsoleMessage.didRequestSourceMapping):
        (WebInspector.DebuggerPresentationModel.prototype.addConsoleMessage):
        (WebInspector.DebuggerPresentationModel.prototype.continueToLine):
        (WebInspector.DebuggerPresentationModel.prototype._setBreakpointInDebugger.didRequestSourceMapping):
        (WebInspector.DebuggerPresentationModel.prototype._setBreakpointInDebugger):
        (WebInspector.DebuggerPresentationModel.prototype._breakpointAdded.didRequestSourceMapping):
        (WebInspector.DebuggerPresentationModel.prototype._breakpointAdded):
        (WebInspector.PresenationCallFrame):
        (WebInspector.PresenationCallFrame.prototype.sourceLine.didRequestSourceMapping):
        (WebInspector.PresenationCallFrame.prototype.sourceLine):
        * inspector/front-end/ScriptFormatter.js:
        (WebInspector.ScriptFormatter.locationToPosition):
        (WebInspector.ScriptFormatter.lineToPosition):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype._debuggerPaused.else.didGetSourceLocation):
        (WebInspector.ScriptsPanel.prototype._debuggerPaused):
        (WebInspector.ScriptsPanel.prototype.showAnchorLocation):
        (WebInspector.ScriptsPanel.prototype._callFrameSelected.didGetSourceLocation):
        (WebInspector.ScriptsPanel.prototype._callFrameSelected):
        * inspector/front-end/SourceFile.js:
        (WebInspector.SourceMapping.prototype.scriptLocationToSourceLine):
        (WebInspector.SourceMapping.prototype.sourceLineToScriptLocation):
        (WebInspector.FormattedSourceMapping.prototype.scriptLocationToSourceLine):
        (WebInspector.FormattedSourceMapping.prototype.sourceLineToScriptLocation):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6782b967
......@@ -106,13 +106,13 @@ InspectorTest.captureStackTrace = function(callFrames)
InspectorTest.addResult("Call stack:");
for (var i = 0; i < callFrames.length; i++) {
var frame = callFrames[i];
var script = WebInspector.debuggerModel.scriptForSourceID(frame.sourceID);
var script = WebInspector.debuggerModel.scriptForSourceID(frame.location.sourceID);
var url;
if (script)
url = WebInspector.displayNameForURL(script.sourceURL);
else
url = "(internal script)"
var s = " " + i + ") " + frame.functionName + " (" + url + ":" + (frame.line + 1) + ")";
var s = " " + i + ") " + frame.functionName + " (" + url + ":" + (frame.location.lineNumber + 1) + ")";
InspectorTest.addResult(s);
}
};
......
2011-04-08 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: use "locations" for debugger scripts, "lineNumbers" for the UI elements.
https://bugs.webkit.org/show_bug.cgi?id=58118
This change reuses location for call frames in the protocol + structures script
location <-> source lines interaction better. When we need UI columns, we will add
them, but we should distinguish between script and UI terms on the type level, not naming.
* English.lproj/localizedStrings.js:
* bindings/v8/DebuggerScript.js:
* inspector/InjectedScriptSource.js:
* inspector/Inspector.json:
* inspector/front-end/CallStackSidebarPane.js:
(WebInspector.CallStackSidebarPane.prototype.update.didGetSourceLine):
(WebInspector.CallStackSidebarPane.prototype.update):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.addConsoleMessage.didRequestSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype.addConsoleMessage):
(WebInspector.DebuggerPresentationModel.prototype.continueToLine):
(WebInspector.DebuggerPresentationModel.prototype._setBreakpointInDebugger.didRequestSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._setBreakpointInDebugger):
(WebInspector.DebuggerPresentationModel.prototype._breakpointAdded.didRequestSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._breakpointAdded):
(WebInspector.PresenationCallFrame):
(WebInspector.PresenationCallFrame.prototype.sourceLine.didRequestSourceMapping):
(WebInspector.PresenationCallFrame.prototype.sourceLine):
* inspector/front-end/ScriptFormatter.js:
(WebInspector.ScriptFormatter.locationToPosition):
(WebInspector.ScriptFormatter.lineToPosition):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._debuggerPaused.else.didGetSourceLocation):
(WebInspector.ScriptsPanel.prototype._debuggerPaused):
(WebInspector.ScriptsPanel.prototype.showAnchorLocation):
(WebInspector.ScriptsPanel.prototype._callFrameSelected.didGetSourceLocation):
(WebInspector.ScriptsPanel.prototype._callFrameSelected):
* inspector/front-end/SourceFile.js:
(WebInspector.SourceMapping.prototype.scriptLocationToSourceLine):
(WebInspector.SourceMapping.prototype.sourceLineToScriptLocation):
(WebInspector.FormattedSourceMapping.prototype.scriptLocationToSourceLine):
(WebInspector.FormattedSourceMapping.prototype.sourceLineToScriptLocation):
2011-04-08 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
......@@ -91,7 +91,7 @@ DebuggerScript._formatScript = function(script)
DebuggerScript.setBreakpoint = function(execState, args)
{
var breakId = Debug.setScriptBreakPointById(args.scriptId, args.lineNumber, args.columnNumber, args.condition);
var breakId = Debug.setScriptBreakPointById(args.sourceID, args.lineNumber, args.columnNumber, args.condition);
var locations = Debug.findBreakPointActualLocations(breakId);
if (!locations.length)
......@@ -250,7 +250,6 @@ DebuggerScript._frameMirrorToJSCallFrame = function(frameMirror, callerFrame)
"line": location.line,
"column": location.column,
"functionName": functionName,
"type": "function",
"thisObject": thisObject,
"scopeChain": scopeChain,
"scopeType": scopeType,
......
......@@ -67,7 +67,7 @@ String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea
v8::Context::Scope contextScope(debuggerContext);
v8::Local<v8::Object> args = v8::Object::New();
args->Set(v8::String::New("scriptId"), v8String(sourceID));
args->Set(v8::String::New("sourceID"), v8String(sourceID));
args->Set(v8::String::New("lineNumber"), v8::Integer::New(scriptBreakpoint.lineNumber));
args->Set(v8::String::New("columnNumber"), v8::Integer::New(scriptBreakpoint.columnNumber));
args->Set(v8::String::New("condition"), v8String(scriptBreakpoint.condition));
......
......@@ -474,11 +474,8 @@ InjectedScript.RemoteObject.fromObject = function(object, objectId)
InjectedScript.CallFrameProxy = function(ordinal, callFrame)
{
this.id = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + injectedScriptId + "}";
this.type = callFrame.type;
this.functionName = (this.type === "function" ? callFrame.functionName : "");
this.sourceID = callFrame.sourceID;
this.line = callFrame.line;
this.column = callFrame.column;
this.functionName = (callFrame.type === "function" ? callFrame.functionName : "");
this.location = { sourceID: callFrame.sourceID, lineNumber: callFrame.line, columnNumber: callFrame.column };
this.scopeChain = this._wrapScopeChain(callFrame);
}
......
......@@ -1232,7 +1232,7 @@
"properties": {
"sourceID": { "type": "string", "description": "Script identifier as reported by the <code>scriptParsed</code>" },
"lineNumber": { "type": "integer", "description": "Line number in the script." },
"columnNumber": { "type": "integer", "description": "Column number in the script." }
"columnNumber": { "type": "integer", "optional": true, "description": "Column number in the script." }
},
"description": "Location in the source code."
},
......@@ -1241,11 +1241,8 @@
"type": "object",
"properties": {
"id": { "type": "string", "description": "Call frame identifier" },
"type": { "type": "string", "description": "Call frame type. // FIXME" },
"functionName": { "type": "string", "description": "Name of the function called on this frame." },
"sourceID": { "type": "string", "description": "Script identifier." },
"line": { "type": "integer", "description": "Line number in the script." },
"column": { "type": "integer", "description": "Column number in the script." },
"location": { "$ref": "Location", "description": "Location in the source code." },
"scopeChain": { "type": "array", "items": { "type": "object" }, "description": "Scope chain for given call frame. // FIXME" }
},
"description": "Debugger call frame. Array of call frames form call stack."
......@@ -1284,14 +1281,12 @@
{
"name": "setBreakpoint",
"parameters": [
{ "name": "sourceId", "type": "string", "description": "Source ID of the resource to set breakpoint on (as reported by <code>scriptParsed</code>)." },
{ "name": "lineNumber", "type": "integer", "description": "Line number to set breakpoint at." },
{ "name": "columnNumber", "type": "integer", "optional": true, "description": "Offset in the line to set breakpoint at." },
{ "name": "location", "$ref": "Location", "description": "Location to set breakpoint in." },
{ "name": "condition", "type": "string", "optional": true, "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true." }
],
"returns": [
{ "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." },
{ "name": "location", "$ref" : "Location", "description": "Location this breakpoint resolved into." }
{ "name": "actualLocation", "$ref" : "Location", "description": "Location this breakpoint resolved into." }
],
"description": "Sets JavaScript breakpoint at a given location."
},
......@@ -1305,9 +1300,7 @@
{
"name": "continueToLocation",
"parameters": [
{ "name": "sourceId", "type": "string", "description": "Source ID of the resource to continue to (as reported by <code>scriptParsed</code>)." },
{ "name": "lineNumber", "type": "integer", "description": "Line number to stop at." },
{ "name": "columnNumber", "type": "integer", "description": "Column number to stop at." }
{ "name": "location", "$ref": "Location", "description": "Location to continue to." }
],
"description": "Continues execution until specific location is reached."
},
......
......@@ -174,17 +174,35 @@ void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url,
*outBreakpointId = breakpointId;
}
void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, const String& sourceId, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, String* outBreakpointId, RefPtr<InspectorObject>* location)
static bool parseLocation(ErrorString* errorString, RefPtr<InspectorObject> location, String* sourceId, int* lineNumber, int* columnNumber)
{
int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0;
if (!location->getString("sourceID", sourceId) || !location->getNumber("lineNumber", lineNumber)) {
// FIXME: replace with input validation.
*errorString = "sourceId and lineNumber are required.";
return false;
}
*columnNumber = 0;
location->getNumber("columnNumber", columnNumber);
return true;
}
void InspectorDebuggerAgent::setBreakpoint(ErrorString* errorString, PassRefPtr<InspectorObject> location, const String* const optionalCondition, String* outBreakpointId, RefPtr<InspectorObject>* actualLocation)
{
String sourceId;
int lineNumber;
int columnNumber;
if (!parseLocation(errorString, location, &sourceId, &lineNumber, &columnNumber))
return;
String condition = optionalCondition ? *optionalCondition : "";
String breakpointId = makeString(sourceId, ":", String::number(lineNumber), ":", String::number(columnNumber));
if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end())
return;
ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
*location = resolveBreakpoint(breakpointId, sourceId, breakpoint);
if (*location)
*actualLocation = resolveBreakpoint(breakpointId, sourceId, breakpoint);
if (*actualLocation)
*outBreakpointId = breakpointId;
else
*errorString = "Could not resolve breakpoint";
......@@ -204,15 +222,23 @@ void InspectorDebuggerAgent::removeBreakpoint(ErrorString*, const String& breakp
m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIterator);
}
void InspectorDebuggerAgent::continueToLocation(ErrorString* error, const String& sourceId, int lineNumber, int columnNumber)
void InspectorDebuggerAgent::continueToLocation(ErrorString* errorString, PassRefPtr<InspectorObject> location)
{
if (!m_continueToLocationBreakpointId.isEmpty()) {
scriptDebugServer().removeBreakpoint(m_continueToLocationBreakpointId);
m_continueToLocationBreakpointId = "";
}
String sourceId;
int lineNumber;
int columnNumber;
if (!parseLocation(errorString, location, &sourceId, &lineNumber, &columnNumber))
return;
ScriptBreakpoint breakpoint(lineNumber, columnNumber, "");
m_continueToLocationBreakpointId = scriptDebugServer().setBreakpoint(sourceId, breakpoint, &lineNumber, &columnNumber);
resume(error);
resume(errorString);
}
PassRefPtr<InspectorObject> InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint& breakpoint)
......
......@@ -81,9 +81,9 @@ public:
void setBreakpointsActive(ErrorString*, bool active);
void setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, String* breakpointId, RefPtr<InspectorArray>* locations);
void setBreakpoint(ErrorString*, const String& sourceId, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, String* breakpointId, RefPtr<InspectorObject>* location);
void setBreakpoint(ErrorString*, PassRefPtr<InspectorObject> location, const String* const optionalCondition, String* breakpointId, RefPtr<InspectorObject>* actualLocation);
void removeBreakpoint(ErrorString*, const String& breakpointId);
void continueToLocation(ErrorString*, const String& sourceId, int lineNumber, int columnNumber);
void continueToLocation(ErrorString*, PassRefPtr<InspectorObject> location);
void editScriptSource(ErrorString*, const String& sourceID, const String& newContent, RefPtr<InspectorArray>* newCallFrames);
void getScriptSource(ErrorString*, const String& sourceID, String* scriptSource);
......
......@@ -46,20 +46,9 @@ WebInspector.CallStackSidebarPane.prototype = {
return;
}
var title;
var subtitle;
var script;
for (var i = 0; i < callFrames.length; ++i) {
var callFrame = callFrames[i];
switch (callFrame.type) {
case "function":
title = callFrame.functionName || WebInspector.UIString("(anonymous function)");
break;
case "program":
title = WebInspector.UIString("(program)");
break;
}
var title = callFrame.functionName || WebInspector.UIString("(anonymous function)");
var subtitle;
if (!callFrame.isInternalScript)
......@@ -71,7 +60,7 @@ WebInspector.CallStackSidebarPane.prototype = {
placard.callFrame = callFrame;
placard.element.addEventListener("click", this._placardSelected.bind(this, placard), false);
function didGetSourceLocation(placard, sourceFileId, lineNumber, columnNumber)
function didGetSourceLine(placard, sourceFileId, lineNumber)
{
if (placard.subtitle)
placard.subtitle += ":" + (lineNumber + 1);
......@@ -79,7 +68,7 @@ WebInspector.CallStackSidebarPane.prototype = {
placard.subtitle = WebInspector.UIString("line %d", lineNumber + 1);
placard._text = WebInspector.UIString("%s() at %s", placard.title, placard.subtitle);
}
callFrame.sourceLocation(didGetSourceLocation.bind(this, placard));
callFrame.sourceLine(didGetSourceLine.bind(this, placard));
this.placards.push(placard);
this.bodyElement.appendChild(placard.element);
......
......@@ -68,9 +68,9 @@ WebInspector.DebuggerModel.prototype = {
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasDisabled);
},
continueToLocation: function(sourceID, lineNumber, columnNumber)
continueToLocation: function(location)
{
DebuggerAgent.continueToLocation(sourceID, lineNumber, columnNumber);
DebuggerAgent.continueToLocation(location);
},
setBreakpoint: function(url, lineNumber, columnNumber, condition, callback)
......@@ -92,14 +92,14 @@ WebInspector.DebuggerModel.prototype = {
DebuggerAgent.setBreakpointByUrl(url, lineNumber, columnNumber, condition, didSetBreakpoint.bind(this));
},
setBreakpointBySourceId: function(sourceID, lineNumber, columnNumber, condition, callback)
setBreakpointBySourceId: function(location, condition, callback)
{
function didSetBreakpoint(error, breakpointId, location)
function didSetBreakpoint(error, breakpointId, actualLocation)
{
if (callback)
callback(error ? null : breakpointId, [location]);
callback(error ? null : breakpointId, [actualLocation]);
}
DebuggerAgent.setBreakpoint(sourceID, lineNumber, columnNumber, condition, didSetBreakpoint.bind(this));
DebuggerAgent.setBreakpoint(location, condition, didSetBreakpoint.bind(this));
},
removeBreakpoint: function(breakpointId, callback)
......
......@@ -235,7 +235,7 @@ WebInspector.DebuggerPresentationModel.prototype = {
{
var presentationMessage = {};
presentationMessage.sourceFileId = sourceFile.id;
presentationMessage.lineNumber = mapping.scriptLocationToSourceLocation(message.line - 1, 0).lineNumber;
presentationMessage.lineNumber = mapping.scriptLocationToSourceLine({lineNumber:message.line - 1, columnNumber:0});
presentationMessage.originalMessage = message;
sourceFile.messages.push(presentationMessage);
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage);
......@@ -254,8 +254,8 @@ WebInspector.DebuggerPresentationModel.prototype = {
{
function didRequestSourceMapping(mapping)
{
var location = mapping.sourceLocationToScriptLocation(lineNumber, 0);
WebInspector.debuggerModel.continueToLocation(location.scriptId, location.lineNumber, location.columnNumber);
var location = mapping.sourceLineToScriptLocation(lineNumber);
WebInspector.debuggerModel.continueToLocation(location);
}
this._sourceFiles[sourceFileId].requestSourceMapping(didRequestSourceMapping.bind(this));
},
......@@ -308,12 +308,14 @@ WebInspector.DebuggerPresentationModel.prototype = {
function didRequestSourceMapping(mapping)
{
var location = mapping.sourceLocationToScriptLocation(breakpoint.lineNumber, 0);
var script = WebInspector.debuggerModel.scriptForSourceID(location.scriptId);
var location = mapping.sourceLineToScriptLocation(breakpoint.lineNumber);
var script = WebInspector.debuggerModel.scriptForSourceID(location.sourceID);
if (script.sourceURL)
WebInspector.debuggerModel.setBreakpoint(script.sourceURL, location.lineNumber, location.columnNumber, breakpoint.condition, didSetBreakpoint.bind(this));
else
WebInspector.debuggerModel.setBreakpointBySourceId(script.sourceID, location.lineNumber, location.columnNumber, breakpoint.condition, didSetBreakpoint.bind(this));
else {
location.sourceID = script.sourceID;
WebInspector.debuggerModel.setBreakpointBySourceId(location, breakpoint.condition, didSetBreakpoint.bind(this));
}
}
breakpoint.sourceFile.requestSourceMapping(didRequestSourceMapping.bind(this));
},
......@@ -405,10 +407,8 @@ WebInspector.DebuggerPresentationModel.prototype = {
function didRequestSourceMapping(mapping)
{
// Refine line number based on resolved location.
if (breakpoint.location) {
var sourceLocation = mapping.scriptLocationToSourceLocation(breakpoint.location.lineNumber, breakpoint.location.columnNumber);
breakpoint.lineNumber = sourceLocation.lineNumber;
}
if (breakpoint.location)
breakpoint.lineNumber = mapping.scriptLocationToSourceLine(breakpoint.location);
var existingBreakpoint = this.findBreakpoint(sourceFile.id, breakpoint.lineNumber);
if (existingBreakpoint) {
......@@ -500,7 +500,7 @@ WebInspector.DebuggerPresentationModel.prototype = {
for (var i = 0; i < callFrames.length; ++i) {
var callFrame = callFrames[i];
var sourceFile;
var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.sourceID);
var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.sourceID);
if (script)
sourceFile = this._sourceFileForScript(script.sourceURL, script.sourceID);
this._presentationCallFrames.push(new WebInspector.PresenationCallFrame(callFrame, i, sourceFile));
......@@ -633,7 +633,7 @@ WebInspector.PresenationCallFrame = function(callFrame, index, sourceFile)
this._callFrame = callFrame;
this._index = index;
this._sourceFile = sourceFile;
this._script = WebInspector.debuggerModel.scriptForSourceID(callFrame.sourceID);
this._script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.sourceID);
}
WebInspector.PresenationCallFrame.prototype = {
......@@ -683,17 +683,16 @@ WebInspector.PresenationCallFrame.prototype = {
DebuggerAgent.evaluateOnCallFrame(this._callFrame.id, code, objectGroup, includeCommandLineAPI, didEvaluateOnCallFrame.bind(this));
},
sourceLocation: function(callback)
sourceLine: function(callback)
{
if (!this._sourceFile) {
callback(undefined, this._callFrame.line, this._callFrame.column);
callback(undefined, this._callFrame.location.lineNumber);
return;
}
function didRequestSourceMapping(mapping)
{
var sourceLocation = mapping.scriptLocationToSourceLocation(this._callFrame.line, this._callFrame.column);
callback(this._sourceFile.id, sourceLocation.lineNumber, sourceLocation.columnNumber);
callback(this._sourceFile.id, mapping.scriptLocationToSourceLine(this._callFrame.location));
}
this._sourceFile.requestSourceMapping(didRequestSourceMapping.bind(this));
}
......
......@@ -36,10 +36,15 @@ WebInspector.ScriptFormatter = function()
this._tasks = [];
}
WebInspector.ScriptFormatter.locationToPosition = function(lineEndings, lineNumber, columnNumber)
WebInspector.ScriptFormatter.locationToPosition = function(lineEndings, location)
{
var position = lineNumber ? lineEndings[lineNumber - 1] + 1 : 0;
return position + columnNumber;
var position = location.lineNumber ? lineEndings[location.lineNumber - 1] + 1 : 0;
return position + location.columnNumber;
}
WebInspector.ScriptFormatter.lineToPosition = function(lineEndings, lineNumber)
{
return this.locationToPosition(lineEndings, { lineNumber: lineNumber, columnNumber: 0 });
}
WebInspector.ScriptFormatter.positionToLocation = function(lineEndings, position)
......@@ -58,7 +63,7 @@ WebInspector.ScriptFormatter.findScriptRanges = function(lineEndings, scripts)
var scriptRanges = [];
for (var i = 0; i < scripts.length; ++i) {
var start = { lineNumber: scripts[i].lineOffset, columnNumber: scripts[i].columnOffset };
start.position = WebInspector.ScriptFormatter.locationToPosition(lineEndings, start.lineNumber, start.columnNumber);
start.position = WebInspector.ScriptFormatter.locationToPosition(lineEndings, start);
var endPosition = start.position + scripts[i].length;
var end = WebInspector.ScriptFormatter.positionToLocation(lineEndings, endPosition);
end.position = endPosition;
......
......@@ -387,14 +387,14 @@ WebInspector.ScriptsPanel.prototype = {
status = WebInspector.UIString("Paused on a XMLHttpRequest.");
}
} else {
function didGetSourceLocation(sourceFileId, lineNumber, columnNumber)
function didGetSourceLocation(sourceFileId, lineNumber)
{
if (!sourceFileId || !this._presentationModel.findBreakpoint(sourceFileId, lineNumber))
return;
this.sidebarPanes.jsBreakpoints.highlightBreakpoint(sourceFileId, lineNumber);
status = WebInspector.UIString("Paused on a JavaScript breakpoint.");
}
callFrames[0].sourceLocation(didGetSourceLocation.bind(this));
callFrames[0].sourceLine(didGetSourceLocation.bind(this));
}
if (status)
this.sidebarPanes.callstack.setStatus(status);
......@@ -487,8 +487,8 @@ WebInspector.ScriptsPanel.prototype = {
{
function didRequestSourceMapping(mapping)
{
var location = mapping.scriptLocationToSourceLocation(anchor.getAttribute("line_number") - 1, 0);
this._showSourceLine(sourceFile.id, location.lineNumber);
var lineNumber = mapping.scriptLocationToSourceLine({lineNumber:anchor.getAttribute("line_number") - 1, columnNumber:0});
this._showSourceLine(sourceFile.id, lineNumber);
}
var sourceFile = this._presentationModel.sourceFileForScriptURL(anchor.href);
sourceFile.requestSourceMapping(didRequestSourceMapping.bind(this));
......@@ -621,7 +621,7 @@ WebInspector.ScriptsPanel.prototype = {
this.sidebarPanes.watchExpressions.refreshExpressions();
this.sidebarPanes.callstack.selectedCallFrame = this._presentationModel.selectedCallFrame;
function didGetSourceLocation(sourceFileId, lineNumber, columnNumber)
function didGetSourceLocation(sourceFileId, lineNumber)
{
if (!sourceFileId)
return;
......@@ -634,7 +634,7 @@ WebInspector.ScriptsPanel.prototype = {
sourceFrame.setExecutionLine(lineNumber);
this._executionSourceFrame = sourceFrame;
}
callFrame.sourceLocation(didGetSourceLocation.bind(this));
callFrame.sourceLine(didGetSourceLocation.bind(this));
},
_filesSelectChanged: function()
......
......@@ -254,13 +254,14 @@ WebInspector.SourceMapping = function(sortedScripts)
}
WebInspector.SourceMapping.prototype = {
scriptLocationToSourceLocation: function(lineNumber, columnNumber)
scriptLocationToSourceLine: function(location)
{
return { lineNumber: lineNumber, columnNumber: columnNumber };
return location.lineNumber;
},
sourceLocationToScriptLocation: function(lineNumber, columnNumber)
sourceLineToScriptLocation: function(lineNumber)
{
var columnNumber = 0;
var closestScript = this._sortedScripts[0];
for (var i = 1; i < this._sortedScripts.length; ++i) {
script = this._sortedScripts[i];
......@@ -268,7 +269,7 @@ WebInspector.SourceMapping.prototype = {
break;
closestScript = script;
}
return { scriptId: closestScript.sourceID, lineNumber: lineNumber, columnNumber: columnNumber };
return { sourceID: closestScript.sourceID, lineNumber: lineNumber, columnNumber: columnNumber };
}
}
......@@ -281,19 +282,19 @@ WebInspector.FormattedSourceMapping = function(sortedScripts, originalText, form
}
WebInspector.FormattedSourceMapping.prototype = {
scriptLocationToSourceLocation: function(lineNumber, columnNumber)
scriptLocationToSourceLine: function(location)
{
var originalPosition = WebInspector.ScriptFormatter.locationToPosition(this._originalLineEndings, lineNumber, columnNumber);
var originalPosition = WebInspector.ScriptFormatter.locationToPosition(this._originalLineEndings, location);
var formattedPosition = this._convertPosition(this._mapping.original, this._mapping.formatted, originalPosition);
return WebInspector.ScriptFormatter.positionToLocation(this._formattedLineEndings, formattedPosition);
return WebInspector.ScriptFormatter.positionToLocation(this._formattedLineEndings, formattedPosition).lineNumber;
},
sourceLocationToScriptLocation: function(lineNumber, columnNumber)
sourceLineToScriptLocation: function(lineNumber)
{
var formattedPosition = WebInspector.ScriptFormatter.locationToPosition(this._formattedLineEndings, lineNumber, columnNumber);
var formattedPosition = WebInspector.ScriptFormatter.lineToPosition(this._formattedLineEndings, lineNumber);
var originalPosition = this._convertPosition(this._mapping.formatted, this._mapping.original, formattedPosition);
var originalLocation = WebInspector.ScriptFormatter.positionToLocation(this._originalLineEndings, originalPosition);
return WebInspector.SourceMapping.prototype.sourceLocationToScriptLocation.call(this, originalLocation.lineNumber, originalLocation.columnNumber);
return WebInspector.SourceMapping.prototype.sourceLineToScriptLocation.call(this, originalLocation.lineNumber);
},
_convertPosition: function(positions1, positions2, position)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment