Diff
Modified: trunk/LayoutTests/http/tests/inspector/debugger-test.js (116397 => 116398)
--- trunk/LayoutTests/http/tests/inspector/debugger-test.js 2012-05-08 06:30:35 UTC (rev 116397)
+++ trunk/LayoutTests/http/tests/inspector/debugger-test.js 2012-05-08 06:56:55 UTC (rev 116398)
@@ -217,8 +217,7 @@
InspectorTest.removeBreakpoint = function(sourceFrame, lineNumber)
{
- var breakpoint = sourceFrame._breakpoints[lineNumber];
- breakpoint.remove();
+ sourceFrame._breakpointManager.findBreakpoint(sourceFrame._uiSourceCode, lineNumber).remove();
};
Modified: trunk/Source/WebCore/ChangeLog (116397 => 116398)
--- trunk/Source/WebCore/ChangeLog 2012-05-08 06:30:35 UTC (rev 116397)
+++ trunk/Source/WebCore/ChangeLog 2012-05-08 06:56:55 UTC (rev 116398)
@@ -1,3 +1,41 @@
+2012-05-05 Pavel Feldman <[email protected]>
+
+ Web Inspector: make _javascript_SourceFrame use breakpoint manager's breakpoints store.
+ https://bugs.webkit.org/show_bug.cgi?id=85714
+
+ Reviewed by Yury Semikhatsky.
+
+ It is currently using its own copy of breakpoints which is not necessary.
+
+ * inspector/front-end/BreakpointManager.js:
+ (WebInspector.BreakpointManager):
+ (WebInspector.BreakpointManager.prototype.restoreBreakpoints):
+ (WebInspector.BreakpointManager.prototype.setBreakpoint):
+ (WebInspector.BreakpointManager.prototype._innerSetBreakpoint):
+ (WebInspector.BreakpointManager.prototype.findBreakpoint):
+ (WebInspector.BreakpointManager.prototype.reset):
+ (WebInspector.BreakpointManager.prototype._debuggerReset):
+ (WebInspector.BreakpointManager.prototype._breakpointResolved):
+ (WebInspector.BreakpointManager.prototype._uiLocationAdded):
+ (WebInspector.BreakpointManager.prototype._uiLocationRemoved):
+ (WebInspector.BreakpointManager.Breakpoint.prototype._breakpointStorageId):
+ (WebInspector.BreakpointManager.Storage.prototype._restoreBreakpoints):
+ (set WebInspector.BreakpointManager.Storage.Item):
+ * inspector/front-end/_javascript_Source.js:
+ (WebInspector._javascript_Source.prototype.consoleMessagesCleared):
+ (WebInspector._javascript_Source.prototype.breakpointStorageId):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame):
+ (WebInspector._javascript_SourceFrame.prototype._onContentChanged):
+ (WebInspector._javascript_SourceFrame.prototype.populateLineGutterContextMenu):
+ (WebInspector._javascript_SourceFrame.prototype.beforeTextChanged):
+ (WebInspector._javascript_SourceFrame.prototype._onMouseDown):
+ (WebInspector._javascript_SourceFrame.prototype._breakpointAdded):
+ (WebInspector._javascript_SourceFrame.prototype._breakpointRemoved):
+ (WebInspector._javascript_SourceFrame.prototype.onTextViewerContentLoaded):
+ (WebInspector._javascript_SourceFrame.prototype._continueToLine):
+ (WebInspector._javascript_SourceFrame.prototype._updateBreakpointsAfterLiveEdit):
+
2012-05-07 Pavel Feldman <[email protected]>
Web Inspector: do not create locations for resolved provisional breakpoints
Modified: trunk/Source/WebCore/inspector/front-end/BreakpointManager.js (116397 => 116398)
--- trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2012-05-08 06:30:35 UTC (rev 116397)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2012-05-08 06:56:55 UTC (rev 116398)
@@ -43,8 +43,8 @@
this._breakpoints = [];
this._breakpointForDebuggerId = {};
- this._breakpointForUILocation = {};
- this._uiSourceCodeIds = {};
+ this._breakpointsForUILocation = {};
+ this._sourceFilesWithRestoredBreakpoints = {};
this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this);
this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
@@ -61,9 +61,10 @@
*/
restoreBreakpoints: function(uiSourceCode)
{
- if (!uiSourceCode.id || this._uiSourceCodeIds[uiSourceCode.id])
+ var sourceFileId = uiSourceCode.breakpointStorageId();
+ if (!sourceFileId || this._sourceFilesWithRestoredBreakpoints[sourceFileId])
return;
- this._uiSourceCodeIds[uiSourceCode.id] = true;
+ this._sourceFilesWithRestoredBreakpoints[sourceFileId] = true;
// Erase provisional breakpoints prior to restoring them.
for (var debuggerId in this._breakpointForDebuggerId) {
@@ -73,7 +74,7 @@
this._debuggerModel.removeBreakpoint(debuggerId);
delete this._breakpointForDebuggerId[debuggerId];
}
- this._storage.restoreBreakpoints(uiSourceCode);
+ this._storage._restoreBreakpoints(uiSourceCode);
},
/**
@@ -81,14 +82,23 @@
* @param {number} lineNumber
* @param {string} condition
* @param {boolean} enabled
- * @param {boolean=} doNotActivateBreakpoints
* @return {WebInspector.BreakpointManager.Breakpoint}
*/
- setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled, doNotActivateBreakpoints)
+ setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled)
{
- if (!doNotActivateBreakpoints)
- this._debuggerModel.setBreakpointsActive(true);
+ this._debuggerModel.setBreakpointsActive(true);
+ return this._innerSetBreakpoint(uiSourceCode, lineNumber, condition, enabled);
+ },
+ /**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ * @param {number} lineNumber
+ * @param {string} condition
+ * @param {boolean} enabled
+ * @return {WebInspector.BreakpointManager.Breakpoint}
+ */
+ _innerSetBreakpoint: function(uiSourceCode, lineNumber, condition, enabled)
+ {
var breakpoint = this.findBreakpoint(uiSourceCode, lineNumber);
if (breakpoint) {
breakpoint._updateBreakpoint(condition, enabled);
@@ -106,7 +116,8 @@
*/
findBreakpoint: function(uiSourceCode, lineNumber)
{
- return this._breakpointForUILocation[uiSourceCode.id + ":" + lineNumber];
+ var breakpoints = this._breakpointsForUILocation[uiSourceCode.id + ":" + lineNumber];
+ return breakpoints ? breakpoints[0] : null;
},
/**
@@ -146,7 +157,7 @@
for (var debuggerId in this._breakpointForDebuggerId)
this._debuggerModel.removeBreakpoint(debuggerId);
this._breakpointForDebuggerId = {};
- this._uiSourceCodeIds = {};
+ this._sourceFilesWithRestoredBreakpoints = {};
},
_debuggerReset: function()
@@ -157,8 +168,8 @@
breakpoints[i]._isProvisional = true;
}
this._breakpoints = [];
- this._breakpointForUILocation = {};
- this._uiSourceCodeIds = {};
+ this._breakpointsForUILocation = {};
+ this._sourceFilesWithRestoredBreakpoints = {};
},
_breakpointResolved: function(event)
@@ -189,7 +200,13 @@
*/
_uiLocationAdded: function(breakpoint, uiLocation)
{
- this._breakpointForUILocation[uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber] = breakpoint;
+ var key = uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber;
+ var breakpoints = this._breakpointsForUILocation[key];
+ if (!breakpoints) {
+ breakpoints = [];
+ this._breakpointsForUILocation[key] = breakpoints;
+ }
+ breakpoints.push(breakpoint);
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointAdded, {breakpoint: breakpoint, uiLocation: uiLocation});
},
@@ -199,7 +216,13 @@
*/
_uiLocationRemoved: function(breakpoint, uiLocation)
{
- delete this._breakpointForUILocation[uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber];
+ var key = uiLocation.uiSourceCode.id + ":" + uiLocation.lineNumber;
+ var breakpoints = this._breakpointsForUILocation[key];
+ if (!breakpoints)
+ return;
+ breakpoints.remove(breakpoint);
+ if (!breakpoints.length)
+ delete this._breakpointsForUILocation[key];
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation});
}
}
@@ -388,7 +411,7 @@
*/
_breakpointStorageId: function()
{
- return this._primaryUILocation.uiSourceCode.id + ":" + this._primaryUILocation.lineNumber;
+ return this._primaryUILocation.uiSourceCode.breakpointStorageId() + ":" + this._primaryUILocation.lineNumber;
},
_fakeBreakpointAtPrimaryLocation: function()
@@ -421,13 +444,14 @@
/**
* @param {WebInspector.UISourceCode} uiSourceCode
*/
- restoreBreakpoints: function(uiSourceCode)
+ _restoreBreakpoints: function(uiSourceCode)
{
this._muted = true;
+ var breakpointStorageId = uiSourceCode.breakpointStorageId();
for (var id in this._breakpoints) {
var breakpoint = this._breakpoints[id];
- if (breakpoint.sourceFileId === uiSourceCode.id)
- this._breakpointManager.setBreakpoint(uiSourceCode, breakpoint.lineNumber, breakpoint.condition, breakpoint.enabled, true);
+ if (breakpoint.sourceFileId === breakpointStorageId)
+ this._breakpointManager._innerSetBreakpoint(uiSourceCode, breakpoint.lineNumber, breakpoint.condition, breakpoint.enabled);
}
delete this._muted;
},
@@ -470,7 +494,7 @@
WebInspector.BreakpointManager.Storage.Item = function(breakpoint)
{
var primaryUILocation = breakpoint.primaryUILocation();
- this.sourceFileId = primaryUILocation.uiSourceCode.id;
+ this.sourceFileId = primaryUILocation.uiSourceCode.breakpointStorageId();
this.lineNumber = primaryUILocation.lineNumber;
this.condition = breakpoint.condition();
this.enabled = breakpoint.enabled();
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (116397 => 116398)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-08 06:30:35 UTC (rev 116397)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-08 06:56:55 UTC (rev 116398)
@@ -67,6 +67,14 @@
{
this._consoleMessages = [];
this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessagesCleared);
+ },
+
+ /**
+ * @return {string}
+ */
+ breakpointStorageId: function()
+ {
+ return this.id;
}
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (116397 => 116398)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-05-08 06:30:35 UTC (rev 116397)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-05-08 06:56:55 UTC (rev 116398)
@@ -41,7 +41,6 @@
this._model = model;
this._breakpointManager = this._model.breakpointManager;
this._uiSourceCode = uiSourceCode;
- this._breakpoints = {};
var locations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);
for (var i = 0; i < locations.length; ++i)
@@ -121,20 +120,18 @@
var oldContent = /** @type {string} */ event.data.oldContent;
var content = /** @type {string} */ event.data.content;
- var breakpoints = {};
- for (var lineNumber in this._breakpoints) {
- breakpoints[lineNumber] = this._breakpoints[lineNumber];
- this._breakpoints[lineNumber].remove();
- }
+ var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);
+ for (var i = 0; i < breakpointLocations.length; ++i)
+ breakpointLocations[i].breakpoint.remove();
this.setContent(content, false, "text/_javascript_");
- this._updateBreakpointsAfterLiveEdit(oldContent, content, breakpoints);
+ this._updateBreakpointsAfterLiveEdit(oldContent, content, breakpointLocations);
},
populateLineGutterContextMenu: function(contextMenu, lineNumber)
{
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Continue to here" : "Continue to Here"), this._continueToLine.bind(this, lineNumber));
- var breakpoint = this._breakpoints[lineNumber];
+ var breakpoint = this._breakpointManager.findBreakpoint(this._uiSourceCode, lineNumber);
if (!breakpoint) {
// This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._setBreakpoint.bind(this, lineNumber, "", true));
@@ -181,15 +178,13 @@
{
if (!this._isDirty) {
// Disable all breakpoints in the model, store them as muted breakpoints.
- for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
- var breakpointAttribute = this.textModel.getAttribute(lineNumber, "breakpoint");
- if (breakpointAttribute) {
- var breakpoint = this._breakpoints[lineNumber];
- if (breakpoint)
- breakpoint.remove();
- // Re-adding decoration only.
- this._addBreakpointDecoration(lineNumber, breakpointAttribute.condition, breakpointAttribute.enabled, true);
- }
+ var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);
+ var lineNumbers = {};
+ for (var i = 0; i < breakpointLocations.length; ++i) {
+ var breakpoint = breakpointLocations[i].breakpoint;
+ breakpointLocations[i].breakpoint.remove();
+ // Re-adding decoration only.
+ this._addBreakpointDecoration(breakpointLocations[i].uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), true);
}
}
@@ -387,7 +382,7 @@
return;
var lineNumber = target.lineNumber;
- var breakpoint = this._breakpoints[lineNumber];
+ var breakpoint = this._breakpointManager.findBreakpoint(this._uiSourceCode, lineNumber);
if (breakpoint) {
if (event.shiftKey)
breakpoint.setEnabled(!breakpoint.enabled());
@@ -503,7 +498,6 @@
return;
var breakpoint = /** @type {WebInspector.BreakpointManager.Breakpoint} */ event.data.breakpoint;
- this._breakpoints[uiLocation.lineNumber] = breakpoint;
if (this.loaded)
this._addBreakpointDecoration(uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), false);
},
@@ -515,11 +509,10 @@
return;
var breakpoint = /** @type {WebInspector.BreakpointManager.Breakpoint} */ event.data.breakpoint;
- if (this._breakpoints[uiLocation.lineNumber] !== breakpoint)
- return;
- delete this._breakpoints[uiLocation.lineNumber];
- if (this.loaded)
+ var remainingBreakpoint = this._breakpointManager.findBreakpoint(this._uiSourceCode, uiLocation.lineNumber);
+ if (!remainingBreakpoint && this.loaded) {
this._removeBreakpointDecoration(uiLocation.lineNumber);
+ }
},
_consoleMessageAdded: function(event)
@@ -539,9 +532,10 @@
if (typeof this._executionLineNumber === "number")
this.setExecutionLine(this._executionLineNumber);
- for (var lineNumber in this._breakpoints) {
- var breakpoint = this._breakpoints[lineNumber];
- this._addBreakpointDecoration(parseInt(lineNumber, 10), breakpoint.condition(), breakpoint.enabled(), false);
+ var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._uiSourceCode);
+ for (var i = 0; i < breakpointLocations.length; ++i) {
+ var breakpoint = breakpointLocations[i].breakpoint;
+ this._addBreakpointDecoration(breakpointLocations[i].uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled(), false);
}
var messages = this._uiSourceCode.consoleMessages();
@@ -572,13 +566,14 @@
/**
* @param {string} oldSource
* @param {string} newSource
- * @param {Object.<string, WebInspector.BreakpointManager.Breakpoint>} breakpoints
+ * @param {Array.<Object>} breakpointLocations
*/
- _updateBreakpointsAfterLiveEdit: function(oldSource, newSource, breakpoints)
+ _updateBreakpointsAfterLiveEdit: function(oldSource, newSource, breakpointLocations)
{
// Clear and re-create breakpoints according to text diff.
var diff = Array.diff(oldSource.split("\n"), newSource.split("\n"));
- for (var lineNumber in breakpoints) {
+ for (var i = 0; i < breakpointLocations.length; ++i) {
+ var lineNumber = breakpointLocations[i].uiLocation.lineNumber;
var newLineNumber = diff.left[lineNumber].row;
if (newLineNumber === undefined) {
for (var i = lineNumber - 1; i >= 0; --i) {
@@ -594,7 +589,7 @@
}
}
if (newLineNumber !== undefined) {
- var breakpoint = breakpoints[lineNumber];
+ var breakpoint = breakpointLocations[i].breakpoint;
this._setBreakpoint(newLineNumber, breakpoint.condition(), breakpoint.enabled());
}
}