summaryrefslogtreecommitdiff
path: root/Source/WebCore/inspector/front-end/BreakpointManager.js
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/inspector/front-end/BreakpointManager.js')
-rw-r--r--Source/WebCore/inspector/front-end/BreakpointManager.js99
1 files changed, 84 insertions, 15 deletions
diff --git a/Source/WebCore/inspector/front-end/BreakpointManager.js b/Source/WebCore/inspector/front-end/BreakpointManager.js
index 8e9d4b655..16f34e914 100644
--- a/Source/WebCore/inspector/front-end/BreakpointManager.js
+++ b/Source/WebCore/inspector/front-end/BreakpointManager.js
@@ -49,6 +49,8 @@ WebInspector.BreakpointManager = function(breakpointStorage, debuggerModel, work
this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.BreakpointResolved, this._breakpointResolved, this);
this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._workspaceReset, this);
this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this);
+ this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeAdded, this._uiSourceCodeAdded, this);
+ this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.TemporaryUISourceCodeRemoved, this._uiSourceCodeRemoved, this);
}
WebInspector.BreakpointManager.Events = {
@@ -56,13 +58,18 @@ WebInspector.BreakpointManager.Events = {
BreakpointRemoved: "breakpoint-removed"
}
+WebInspector.BreakpointManager.breakpointStorageId = function(uiSourceCode)
+{
+ return uiSourceCode.formatted() ? "deobfuscated:" + uiSourceCode.url : uiSourceCode.url;
+}
+
WebInspector.BreakpointManager.prototype = {
/**
* @param {WebInspector.UISourceCode} uiSourceCode
*/
restoreBreakpoints: function(uiSourceCode)
{
- var sourceFileId = uiSourceCode.breakpointStorageId();
+ var sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode);
if (!sourceFileId || this._sourceFilesWithRestoredBreakpoints[sourceFileId])
return;
this._sourceFilesWithRestoredBreakpoints[sourceFileId] = true;
@@ -74,6 +81,7 @@ WebInspector.BreakpointManager.prototype = {
continue;
this._debuggerModel.removeBreakpoint(debuggerId);
delete this._breakpointForDebuggerId[debuggerId];
+ delete breakpoint._debuggerId;
}
this._storage._restoreBreakpoints(uiSourceCode);
},
@@ -89,6 +97,40 @@ WebInspector.BreakpointManager.prototype = {
},
/**
+ * @param {WebInspector.Event} event
+ */
+ _uiSourceCodeRemoved: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
+ if (!(uiSourceCode instanceof WebInspector.JavaScriptSource))
+ return;
+ if (uiSourceCode.divergedVersion)
+ return;
+
+ var sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode);
+ if (!sourceFileId)
+ return;
+
+ var breakpoints = this._breakpoints.slice();
+ for (var i = 0; i < breakpoints.length; ++i) {
+ var breakpoint = breakpoints[i];
+ for (var stringifiedLocation in breakpoint._uiLocations) {
+ var uiLocation = breakpoint._uiLocations[stringifiedLocation];
+ if (uiLocation.uiSourceCode === uiSourceCode)
+ breakpoint.remove(true);
+ }
+ }
+
+ delete this._sourceFilesWithRestoredBreakpoints[sourceFileId];
+
+ var uiSourceCodes = this._workspace.uiSourceCodes();
+ for (var i = 0; i < uiSourceCodes.length; ++i) {
+ if (WebInspector.BreakpointManager.breakpointStorageId(uiSourceCodes[i]) === sourceFileId)
+ this.restoreBreakpoints(uiSourceCodes[i]);
+ }
+ },
+
+ /**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {string} condition
@@ -133,17 +175,17 @@ WebInspector.BreakpointManager.prototype = {
},
/**
- * @param {WebInspector.UISourceCode} uiSourceCode
- * @return {Array.<Object>}
+ * @param {function(WebInspector.BreakpointManager.Breakpoint, WebInspector.UILocation)} filter
+ * @return {Array.<{breakpoint: WebInspector.BreakpointManager.Breakpoint, uiLocation: WebInspector.UILocation}>}
*/
- breakpointLocationsForUISourceCode: function(uiSourceCode)
+ _filteredBreakpointLocations: function(filter)
{
var result = [];
for (var i = 0; i < this._breakpoints.length; ++i) {
var breakpoint = this._breakpoints[i];
for (var stringifiedLocation in breakpoint._uiLocations) {
var uiLocation = breakpoint._uiLocations[stringifiedLocation];
- if (uiLocation.uiSourceCode === uiSourceCode)
+ if (filter(breakpoint, uiLocation))
result.push({breakpoint: breakpoint, uiLocation: uiLocation});
}
}
@@ -151,6 +193,28 @@ WebInspector.BreakpointManager.prototype = {
},
/**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ * @return {Array.<{breakpoint: WebInspector.BreakpointManager.Breakpoint, uiLocation: WebInspector.UILocation}>}
+ */
+ breakpointLocationsForUISourceCode: function(uiSourceCode)
+ {
+ function filter(breakpoint, uiLocation)
+ {
+ return uiLocation.uiSourceCode === uiSourceCode;
+ }
+
+ return this._filteredBreakpointLocations(filter);
+ },
+
+ /**
+ * @return {Array.<{breakpoint: WebInspector.BreakpointManager.Breakpoint, uiLocation: WebInspector.UILocation}>}
+ */
+ allBreakpointLocations: function()
+ {
+ return this._filteredBreakpointLocations(function(breakpoint, uiLocation) { return true; });
+ },
+
+ /**
* @param {boolean} toggleState
*/
toggleAllBreakpoints: function(toggleState)
@@ -257,10 +321,10 @@ WebInspector.BreakpointManager.prototype = {
if (!lineBreakpoints.length)
delete breakpoints[uiLocation.lineNumber];
this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.BreakpointRemoved, {breakpoint: breakpoint, uiLocation: uiLocation});
- }
-}
+ },
-WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
+ __proto__: WebInspector.Object.prototype
+}
/**
* @constructor
@@ -274,7 +338,7 @@ WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, uiSource
{
this._breakpointManager = breakpointManager;
this._primaryUILocation = new WebInspector.UILocation(uiSourceCode, lineNumber, 0);
- this._sourceCodeStorageId = uiSourceCode.breakpointStorageId();
+ this._sourceCodeStorageId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode);
/** @type {Array.<WebInspector.Script.Location>} */
this._liveLocations = [];
/** @type {Object.<string, WebInspector.UILocation>} */
@@ -369,7 +433,8 @@ WebInspector.BreakpointManager.Breakpoint.prototype = {
this._condition = condition;
this._breakpointManager._storage._updateBreakpoint(this);
- if (this._enabled && !this._primaryUILocation.uiSourceCode.isDivergedFromVM()) {
+ var scriptFile = this._primaryUILocation.uiSourceCode.scriptFile();
+ if (this._enabled && !(scriptFile && scriptFile.hasDivergedFromVM())) {
this._setInDebugger();
return;
}
@@ -377,11 +442,15 @@ WebInspector.BreakpointManager.Breakpoint.prototype = {
this._fakeBreakpointAtPrimaryLocation();
},
- remove: function()
+ /**
+ * @param {boolean=} keepInStorage
+ */
+ remove: function(keepInStorage)
{
+ var removeFromStorage = !keepInStorage;
this._resetLocations();
this._removeFromDebugger();
- this._breakpointManager._removeBreakpoint(this, true);
+ this._breakpointManager._removeBreakpoint(this, removeFromStorage);
},
_setInDebugger: function()
@@ -456,7 +525,7 @@ WebInspector.BreakpointManager.Breakpoint.prototype = {
*/
_breakpointStorageId: function()
{
- return this._primaryUILocation.uiSourceCode.breakpointStorageId() + ":" + this._primaryUILocation.lineNumber;
+ return WebInspector.BreakpointManager.breakpointStorageId(this._primaryUILocation.uiSourceCode) + ":" + this._primaryUILocation.lineNumber;
},
_fakeBreakpointAtPrimaryLocation: function()
@@ -492,7 +561,7 @@ WebInspector.BreakpointManager.Storage.prototype = {
_restoreBreakpoints: function(uiSourceCode)
{
this._muted = true;
- var breakpointStorageId = uiSourceCode.breakpointStorageId();
+ var breakpointStorageId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode);
for (var id in this._breakpoints) {
var breakpoint = this._breakpoints[id];
if (breakpoint.sourceFileId === breakpointStorageId)
@@ -539,7 +608,7 @@ WebInspector.BreakpointManager.Storage.prototype = {
WebInspector.BreakpointManager.Storage.Item = function(breakpoint)
{
var primaryUILocation = breakpoint.primaryUILocation();
- this.sourceFileId = primaryUILocation.uiSourceCode.breakpointStorageId();
+ this.sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(primaryUILocation.uiSourceCode);
this.lineNumber = primaryUILocation.lineNumber;
this.condition = breakpoint.condition();
this.enabled = breakpoint.enabled();