2011-03-09 Pavel Podivilov <podivilov@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: re-implement breakpoints sidebar pane based on debugger presentation model.
        https://bugs.webkit.org/show_bug.cgi?id=55823

        * inspector/front-end/BreakpointsSidebarPane.js:
        (WebInspector.JavaScriptBreakpointsSidebarPane):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint.didLoadSnippet):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.removeBreakpoint):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.highlightBreakpoint):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.clearBreakpointHighlight):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._createBreakpointItemId):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointClicked):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointCheckboxClicked):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype._contextMenu):
        (WebInspector.JavaScriptBreakpointsSidebarPane.prototype.reset):
        * inspector/front-end/DebuggerPresentationModel.js:
        (WebInspector.DebuggerPresentationModel):
        (WebInspector.DebuggerPresentationModel.prototype._parsedScriptSource):
        (WebInspector.DebuggerPresentationModel.prototype._failedToParseScriptSource):
        (WebInspector.DebuggerPresentationModel.prototype._revealHiddenBreakpoints):
        (WebInspector.DebuggerPresentationModel.prototype.breakpointsForSourceFileId):
        (WebInspector.DebuggerPresentationModel.prototype.setBreakpointEnabled):
        (WebInspector.DebuggerPresentationModel.prototype.removeBreakpoint):
        (WebInspector.DebuggerPresentationModel.prototype._breakpointAdded):
        (WebInspector.DebuggerPresentationModel.prototype.set selectedCallFrame):
        (WebInspector.DebuggerPresentationModel.prototype._actualLocationToSourceLocation):
        (WebInspector.DebuggerPresentationModel.prototype.reset):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel):
        (WebInspector.ScriptsPanel.prototype._breakpointAdded):
        (WebInspector.ScriptsPanel.prototype._breakpointRemoved):
        (WebInspector.ScriptsPanel.prototype._debuggerPaused):
        (WebInspector.ScriptsPanel.prototype.reset):
        (WebInspector.ScriptsPanel.prototype._clearInterface):

git-svn-id: svn://svn.chromium.org/blink/trunk@80705 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 84100674
2011-03-09 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: re-implement breakpoints sidebar pane based on debugger presentation model.
https://bugs.webkit.org/show_bug.cgi?id=55823
* inspector/front-end/BreakpointsSidebarPane.js:
(WebInspector.JavaScriptBreakpointsSidebarPane):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint.didLoadSnippet):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.addBreakpoint):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.removeBreakpoint):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.highlightBreakpoint):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.clearBreakpointHighlight):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype._createBreakpointItemId):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointClicked):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype._breakpointCheckboxClicked):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype._contextMenu):
(WebInspector.JavaScriptBreakpointsSidebarPane.prototype.reset):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype._parsedScriptSource):
(WebInspector.DebuggerPresentationModel.prototype._failedToParseScriptSource):
(WebInspector.DebuggerPresentationModel.prototype._revealHiddenBreakpoints):
(WebInspector.DebuggerPresentationModel.prototype.breakpointsForSourceFileId):
(WebInspector.DebuggerPresentationModel.prototype.setBreakpointEnabled):
(WebInspector.DebuggerPresentationModel.prototype.removeBreakpoint):
(WebInspector.DebuggerPresentationModel.prototype._breakpointAdded):
(WebInspector.DebuggerPresentationModel.prototype.set selectedCallFrame):
(WebInspector.DebuggerPresentationModel.prototype._actualLocationToSourceLocation):
(WebInspector.DebuggerPresentationModel.prototype.reset):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
(WebInspector.ScriptsPanel.prototype._breakpointAdded):
(WebInspector.ScriptsPanel.prototype._breakpointRemoved):
(WebInspector.ScriptsPanel.prototype._debuggerPaused):
(WebInspector.ScriptsPanel.prototype.reset):
(WebInspector.ScriptsPanel.prototype._clearInterface):
2011-03-10 Andrey Adaikin <aandrey@google.com> 2011-03-10 Andrey Adaikin <aandrey@google.com>
Reviewed by Pavel Feldman. Reviewed by Pavel Feldman.
......
...@@ -33,6 +33,8 @@ WebInspector.DebuggerPresentationModel = function() ...@@ -33,6 +33,8 @@ WebInspector.DebuggerPresentationModel = function()
this._breakpoints = {}; this._breakpoints = {};
this._sourceLocationToBreakpointId = {}; this._sourceLocationToBreakpointId = {};
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._failedToParseScriptSource, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointAdded, this._breakpointAdded, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointRemoved, this._breakpointRemoved, this); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointRemoved, this._breakpointRemoved, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this); WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this);
...@@ -44,17 +46,60 @@ WebInspector.DebuggerPresentationModel.Events = { ...@@ -44,17 +46,60 @@ WebInspector.DebuggerPresentationModel.Events = {
} }
WebInspector.DebuggerPresentationModel.prototype = { WebInspector.DebuggerPresentationModel.prototype = {
_parsedScriptSource: function(event)
{
var script = event.data;
if (script.sourceURL)
this._revealHiddenBreakpoints(script.sourceURL);
},
_failedToParseScriptSource: function(event)
{
var script = event.data;
if (script.sourceURL)
this._revealHiddenBreakpoints(script.sourceURL);
},
_revealHiddenBreakpoints: function(url)
{
for (var id in this._breakpoints) {
var breakpoint = this._breakpoints[id];
if (breakpoint._hidden && breakpoint.url === url) {
delete breakpoint._hidden;
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, breakpoint);
}
}
},
breakpointsForSourceFileId: function(sourceFileId) breakpointsForSourceFileId: function(sourceFileId)
{ {
var breakpoints = []; var breakpoints = [];
for (var id in this._breakpoints) { for (var id in this._breakpoints) {
var breakpoint = this._breakpoints[id]; var breakpoint = this._breakpoints[id];
if (breakpoint.sourceFileId === sourceFileId) if (!breakpoint._hidden && breakpoint.sourceFileId === sourceFileId)
breakpoints.push(breakpoint); breakpoints.push(breakpoint);
} }
return breakpoints; return breakpoints;
}, },
setBreakpointEnabled: function(sourceFileId, lineNumber, enabled)
{
var encodedSourceLocation = this._encodeSourceLocation(sourceFileId, lineNumber);
var breakpointId = this._sourceLocationToBreakpointId[encodedSourceLocation];
if (!breakpointId)
return;
var breakpoint = this._breakpoints[breakpointId];
WebInspector.debuggerModel.updateBreakpoint(breakpointId, breakpoint.condition, enabled);
},
removeBreakpoint: function(sourceFileId, lineNumber)
{
var encodedSourceLocation = this._encodeSourceLocation(sourceFileId, lineNumber);
var breakpointId = this._sourceLocationToBreakpointId[encodedSourceLocation];
if (breakpointId)
WebInspector.debuggerModel.removeBreakpoint(breakpointId);
},
_breakpointAdded: function(event) _breakpointAdded: function(event)
{ {
var breakpoint = event.data; var breakpoint = event.data;
...@@ -76,11 +121,18 @@ WebInspector.DebuggerPresentationModel.prototype = { ...@@ -76,11 +121,18 @@ WebInspector.DebuggerPresentationModel.prototype = {
condition: breakpoint.condition, condition: breakpoint.condition,
enabled: breakpoint.enabled enabled: breakpoint.enabled
}; };
if (location.sourceID) {
var script = WebInspector.debuggerModel.scriptForSourceID(location.sourceID);
presentationBreakpoint.loadSnippet = script.sourceLine.bind(script, location.lineNumber);
}
this._sourceLocationToBreakpointId[encodedSourceLocation] = breakpoint.id; this._sourceLocationToBreakpointId[encodedSourceLocation] = breakpoint.id;
this._breakpoints[breakpoint.id] = presentationBreakpoint; this._breakpoints[breakpoint.id] = presentationBreakpoint;
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, presentationBreakpoint); if (!WebInspector.debuggerModel.scriptsForURL(breakpoint.url).length)
presentationBreakpoint._hidden = true;
else
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, presentationBreakpoint);
}, },
_breakpointRemoved: function(event) _breakpointRemoved: function(event)
...@@ -110,7 +162,6 @@ WebInspector.DebuggerPresentationModel.prototype = { ...@@ -110,7 +162,6 @@ WebInspector.DebuggerPresentationModel.prototype = {
this._selectedCallFrame = callFrame; this._selectedCallFrame = callFrame;
if (!callFrame) if (!callFrame)
return; return;
var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.sourceID); var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.sourceID);
callFrame.sourceLocation = this._actualLocationToSourceLocation(script.sourceURL || script.sourceID, callFrame.line, callFrame.column); callFrame.sourceLocation = this._actualLocationToSourceLocation(script.sourceURL || script.sourceID, callFrame.line, callFrame.column);
this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, callFrame); this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, callFrame);
...@@ -125,6 +176,15 @@ WebInspector.DebuggerPresentationModel.prototype = { ...@@ -125,6 +176,15 @@ WebInspector.DebuggerPresentationModel.prototype = {
{ {
// TODO: use source mapping to obtain source location. // TODO: use source mapping to obtain source location.
return { sourceFileId: sourceID, lineNumber: lineNumber, columnNumber: columnNumber }; return { sourceFileId: sourceID, lineNumber: lineNumber, columnNumber: columnNumber };
},
reset: function()
{
for (var id in this._breakpoints) {
var breakpoint = this._breakpoints[id];
breakpoint._hidden = true;
}
this._sourceLocationToBreakpointId = {};
} }
} }
......
...@@ -142,7 +142,7 @@ WebInspector.ScriptsPanel = function() ...@@ -142,7 +142,7 @@ WebInspector.ScriptsPanel = function()
this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane(); this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane();
this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane(this._presentationModel); this.sidebarPanes.callstack = new WebInspector.CallStackSidebarPane(this._presentationModel);
this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane(); this.sidebarPanes.scopechain = new WebInspector.ScopeChainSidebarPane();
this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSidebarPane(); this.sidebarPanes.jsBreakpoints = new WebInspector.JavaScriptBreakpointsSidebarPane(this._presentationModel);
if (Preferences.nativeInstrumentationEnabled) { if (Preferences.nativeInstrumentationEnabled) {
this.sidebarPanes.domBreakpoints = WebInspector.createDOMBreakpointsSidebarPane(); this.sidebarPanes.domBreakpoints = WebInspector.createDOMBreakpointsSidebarPane();
this.sidebarPanes.xhrBreakpoints = WebInspector.createXHRBreakpointsSidebarPane(); this.sidebarPanes.xhrBreakpoints = WebInspector.createXHRBreakpointsSidebarPane();
...@@ -392,6 +392,8 @@ WebInspector.ScriptsPanel.prototype = { ...@@ -392,6 +392,8 @@ WebInspector.ScriptsPanel.prototype = {
var sourceFrame = this._sourceFileIdToSourceFrame[breakpoint.sourceFileId]; var sourceFrame = this._sourceFileIdToSourceFrame[breakpoint.sourceFileId];
if (sourceFrame && sourceFrame.loaded) if (sourceFrame && sourceFrame.loaded)
sourceFrame.addBreakpoint(breakpoint.lineNumber, breakpoint.resolved, breakpoint.condition, breakpoint.enabled); sourceFrame.addBreakpoint(breakpoint.lineNumber, breakpoint.resolved, breakpoint.condition, breakpoint.enabled);
this.sidebarPanes.jsBreakpoints.addBreakpoint(breakpoint);
}, },
_breakpointRemoved: function(event) _breakpointRemoved: function(event)
...@@ -401,6 +403,8 @@ WebInspector.ScriptsPanel.prototype = { ...@@ -401,6 +403,8 @@ WebInspector.ScriptsPanel.prototype = {
var sourceFrame = this._sourceFileIdToSourceFrame[breakpoint.sourceFileId]; var sourceFrame = this._sourceFileIdToSourceFrame[breakpoint.sourceFileId];
if (sourceFrame && sourceFrame.loaded) if (sourceFrame && sourceFrame.loaded)
sourceFrame.removeBreakpoint(breakpoint.lineNumber); sourceFrame.removeBreakpoint(breakpoint.lineNumber);
this.sidebarPanes.jsBreakpoints.removeBreakpoint(breakpoint.sourceFileId, breakpoint.lineNumber);
}, },
evaluateInSelectedCallFrame: function(code, objectGroup, includeCommandLineAPI, callback) evaluateInSelectedCallFrame: function(code, objectGroup, includeCommandLineAPI, callback)
...@@ -432,6 +436,9 @@ WebInspector.ScriptsPanel.prototype = { ...@@ -432,6 +436,9 @@ WebInspector.ScriptsPanel.prototype = {
this.sidebarPanes.callstack.update(event.data); this.sidebarPanes.callstack.update(event.data);
this.sidebarPanes.callstack.selectedCallFrame = callFrames[0]; this.sidebarPanes.callstack.selectedCallFrame = callFrames[0];
var sourceLocation = this._presentationModel.selectedCallFrame.sourceLocation;
this.sidebarPanes.jsBreakpoints.highlightBreakpoint(sourceLocation.sourceFileId, sourceLocation.lineNumber);
window.focus(); window.focus();
InspectorFrontendHost.bringToFront(); InspectorFrontendHost.bringToFront();
}, },
...@@ -468,6 +475,8 @@ WebInspector.ScriptsPanel.prototype = { ...@@ -468,6 +475,8 @@ WebInspector.ScriptsPanel.prototype = {
reset: function(preserveItems) reset: function(preserveItems)
{ {
this._presentationModel.reset();
this.visibleView = null; this.visibleView = null;
delete this.currentQuery; delete this.currentQuery;
...@@ -486,6 +495,7 @@ WebInspector.ScriptsPanel.prototype = { ...@@ -486,6 +495,7 @@ WebInspector.ScriptsPanel.prototype = {
this.functionsSelectElement.removeChildren(); this.functionsSelectElement.removeChildren();
this.viewsContainerElement.removeChildren(); this.viewsContainerElement.removeChildren();
this.sidebarPanes.jsBreakpoints.reset();
this.sidebarPanes.watchExpressions.refreshExpressions(); this.sidebarPanes.watchExpressions.refreshExpressions();
if (!preserveItems) if (!preserveItems)
this.sidebarPanes.workers.reset(); this.sidebarPanes.workers.reset();
...@@ -786,6 +796,7 @@ WebInspector.ScriptsPanel.prototype = { ...@@ -786,6 +796,7 @@ WebInspector.ScriptsPanel.prototype = {
{ {
this.sidebarPanes.callstack.update(null); this.sidebarPanes.callstack.update(null);
this.sidebarPanes.scopechain.update(null); this.sidebarPanes.scopechain.update(null);
this.sidebarPanes.jsBreakpoints.clearBreakpointHighlight();
this._clearCurrentExecutionLine(); this._clearCurrentExecutionLine();
this._updateDebuggerButtons(); this._updateDebuggerButtons();
......
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