OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... |
40 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointS
torage); | 40 this._storage = new WebInspector.BreakpointManager.Storage(this, breakpointS
torage); |
41 this._debuggerModel = debuggerModel; | 41 this._debuggerModel = debuggerModel; |
42 this._workspace = workspace; | 42 this._workspace = workspace; |
43 | 43 |
44 this._breakpoints = new Map(); | 44 this._breakpoints = new Map(); |
45 this._breakpointForDebuggerId = {}; | 45 this._breakpointForDebuggerId = {}; |
46 this._breakpointsForUISourceCode = new Map(); | 46 this._breakpointsForUISourceCode = new Map(); |
47 this._sourceFilesWithRestoredBreakpoints = {}; | 47 this._sourceFilesWithRestoredBreakpoints = {}; |
48 | 48 |
49 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Break
pointResolved, this._breakpointResolved, this); | 49 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Break
pointResolved, this._breakpointResolved, this); |
| 50 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.SetBr
eakpointRequested, this._setBreakpointRequested, this); |
50 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe
set, this._projectWillReset, this); | 51 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillRe
set, this._projectWillReset, this); |
51 this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UI
SourceCodeAdded, this._uiSourceCodeAdded, this); | 52 this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UI
SourceCodeAdded, this._uiSourceCodeAdded, this); |
52 } | 53 } |
53 | 54 |
54 WebInspector.BreakpointManager.Events = { | 55 WebInspector.BreakpointManager.Events = { |
55 BreakpointAdded: "breakpoint-added", | 56 BreakpointAdded: "breakpoint-added", |
56 BreakpointRemoved: "breakpoint-removed" | 57 BreakpointRemoved: "breakpoint-removed" |
57 } | 58 } |
58 | 59 |
59 WebInspector.BreakpointManager.sourceFileId = function(uiSourceCode) | 60 WebInspector.BreakpointManager.sourceFileId = function(uiSourceCode) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 /** | 141 /** |
141 * @param {WebInspector.UISourceCode} uiSourceCode | 142 * @param {WebInspector.UISourceCode} uiSourceCode |
142 * @param {number} lineNumber | 143 * @param {number} lineNumber |
143 * @param {string} condition | 144 * @param {string} condition |
144 * @param {boolean} enabled | 145 * @param {boolean} enabled |
145 * @return {WebInspector.BreakpointManager.Breakpoint} | 146 * @return {WebInspector.BreakpointManager.Breakpoint} |
146 */ | 147 */ |
147 setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled) | 148 setBreakpoint: function(uiSourceCode, lineNumber, condition, enabled) |
148 { | 149 { |
149 this._debuggerModel.setBreakpointsActive(true); | 150 this._debuggerModel.setBreakpointsActive(true); |
150 return this._innerSetBreakpoint(uiSourceCode, lineNumber, condition, ena
bled); | 151 return this._innerSetBreakpoint(uiSourceCode, lineNumber, 0, condition,
enabled); |
151 }, | 152 }, |
152 | 153 |
153 /** | 154 /** |
154 * @param {WebInspector.UISourceCode} uiSourceCode | 155 * @param {WebInspector.UISourceCode} uiSourceCode |
155 * @param {number} lineNumber | 156 * @param {number} lineNumber |
| 157 * @param {number} columnNumber |
156 * @param {string} condition | 158 * @param {string} condition |
157 * @param {boolean} enabled | 159 * @param {boolean} enabled |
158 * @return {WebInspector.BreakpointManager.Breakpoint} | 160 * @return {WebInspector.BreakpointManager.Breakpoint} |
159 */ | 161 */ |
160 _innerSetBreakpoint: function(uiSourceCode, lineNumber, condition, enabled) | 162 _innerSetBreakpoint: function(uiSourceCode, lineNumber, columnNumber, condit
ion, enabled) |
161 { | 163 { |
162 var breakpoint = this.findBreakpoint(uiSourceCode, lineNumber); | 164 var breakpoint = this.findBreakpoint(uiSourceCode, lineNumber); |
163 if (breakpoint) { | 165 if (breakpoint) { |
164 breakpoint._updateBreakpoint(condition, enabled); | 166 breakpoint._updateBreakpoint(condition, enabled); |
165 return breakpoint; | 167 return breakpoint; |
166 } | 168 } |
167 breakpoint = new WebInspector.BreakpointManager.Breakpoint(this, uiSourc
eCode, lineNumber, condition, enabled); | 169 breakpoint = new WebInspector.BreakpointManager.Breakpoint(this, uiSourc
eCode, lineNumber, columnNumber, condition, enabled); |
168 this._breakpoints.put(breakpoint); | 170 this._breakpoints.put(breakpoint); |
169 return breakpoint; | 171 return breakpoint; |
170 }, | 172 }, |
171 | 173 |
172 /** | 174 /** |
173 * @param {WebInspector.UISourceCode} uiSourceCode | 175 * @param {WebInspector.UISourceCode} uiSourceCode |
174 * @param {number} lineNumber | 176 * @param {number} lineNumber |
175 * @return {?WebInspector.BreakpointManager.Breakpoint} | 177 * @return {?WebInspector.BreakpointManager.Breakpoint} |
176 */ | 178 */ |
177 findBreakpoint: function(uiSourceCode, lineNumber) | 179 findBreakpoint: function(uiSourceCode, lineNumber) |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 var breakpointId = /** @type {DebuggerAgent.BreakpointId} */ (event.data
.breakpointId); | 313 var breakpointId = /** @type {DebuggerAgent.BreakpointId} */ (event.data
.breakpointId); |
312 var location = /** @type {WebInspector.DebuggerModel.Location} */ (event
.data.location); | 314 var location = /** @type {WebInspector.DebuggerModel.Location} */ (event
.data.location); |
313 var breakpoint = this._breakpointForDebuggerId[breakpointId]; | 315 var breakpoint = this._breakpointForDebuggerId[breakpointId]; |
314 if (!breakpoint) | 316 if (!breakpoint) |
315 return; | 317 return; |
316 if (!this._breakpoints.contains(breakpoint)) | 318 if (!this._breakpoints.contains(breakpoint)) |
317 this._breakpoints.put(breakpoint); | 319 this._breakpoints.put(breakpoint); |
318 breakpoint._addResolvedLocation(location); | 320 breakpoint._addResolvedLocation(location); |
319 }, | 321 }, |
320 | 322 |
| 323 _setBreakpointRequested: function(event) |
| 324 { |
| 325 var location = /** @type {WebInspector.DebuggerModel.Location} */ (event
.data.location); |
| 326 var script = this._debuggerModel.scriptForId(location.scriptId); |
| 327 var uiLocation = script.rawLocationToUILocation(location.lineNumber, loc
ation.columnNumber); |
| 328 this._innerSetBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber,
uiLocation.columnNumber, "", true); |
| 329 }, |
| 330 |
321 /** | 331 /** |
322 * @param {WebInspector.BreakpointManager.Breakpoint} breakpoint | 332 * @param {WebInspector.BreakpointManager.Breakpoint} breakpoint |
323 * @param {boolean} removeFromStorage | 333 * @param {boolean} removeFromStorage |
324 */ | 334 */ |
325 _removeBreakpoint: function(breakpoint, removeFromStorage) | 335 _removeBreakpoint: function(breakpoint, removeFromStorage) |
326 { | 336 { |
327 console.assert(!breakpoint._debuggerId) | 337 console.assert(!breakpoint._debuggerId) |
328 this._breakpoints.remove(breakpoint); | 338 this._breakpoints.remove(breakpoint); |
329 if (removeFromStorage) | 339 if (removeFromStorage) |
330 this._storage._removeBreakpoint(breakpoint); | 340 this._storage._removeBreakpoint(breakpoint); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 }, | 383 }, |
374 | 384 |
375 __proto__: WebInspector.Object.prototype | 385 __proto__: WebInspector.Object.prototype |
376 } | 386 } |
377 | 387 |
378 /** | 388 /** |
379 * @constructor | 389 * @constructor |
380 * @param {WebInspector.BreakpointManager} breakpointManager | 390 * @param {WebInspector.BreakpointManager} breakpointManager |
381 * @param {WebInspector.UISourceCode} uiSourceCode | 391 * @param {WebInspector.UISourceCode} uiSourceCode |
382 * @param {number} lineNumber | 392 * @param {number} lineNumber |
| 393 * @param {number} columnNumber |
383 * @param {string} condition | 394 * @param {string} condition |
384 * @param {boolean} enabled | 395 * @param {boolean} enabled |
385 */ | 396 */ |
386 WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, uiSource
Code, lineNumber, condition, enabled) | 397 WebInspector.BreakpointManager.Breakpoint = function(breakpointManager, uiSource
Code, lineNumber, columnNumber, condition, enabled) |
387 { | 398 { |
388 this._breakpointManager = breakpointManager; | 399 this._breakpointManager = breakpointManager; |
389 this._primaryUILocation = new WebInspector.UILocation(uiSourceCode, lineNumb
er, 0); | 400 this._primaryUILocation = new WebInspector.UILocation(uiSourceCode, lineNumb
er, columnNumber); |
390 this._sourceFileId = WebInspector.BreakpointManager.sourceFileId(uiSourceCod
e); | 401 this._sourceFileId = WebInspector.BreakpointManager.sourceFileId(uiSourceCod
e); |
391 /** @type {Array.<WebInspector.Script.Location>} */ | 402 /** @type {Array.<WebInspector.Script.Location>} */ |
392 this._liveLocations = []; | 403 this._liveLocations = []; |
393 /** @type {Object.<string, WebInspector.UILocation>} */ | 404 /** @type {Object.<string, WebInspector.UILocation>} */ |
394 this._uiLocations = {}; | 405 this._uiLocations = {}; |
395 | 406 |
396 // Force breakpoint update. | 407 // Force breakpoint update. |
397 /** @type {string} */ this._condition; | 408 /** @type {string} */ this._condition; |
398 /** @type {boolean} */ this._enabled; | 409 /** @type {boolean} */ this._enabled; |
399 this._updateBreakpoint(condition, enabled); | 410 this._updateBreakpoint(condition, enabled); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 /** | 621 /** |
611 * @param {WebInspector.UISourceCode} uiSourceCode | 622 * @param {WebInspector.UISourceCode} uiSourceCode |
612 */ | 623 */ |
613 _restoreBreakpoints: function(uiSourceCode) | 624 _restoreBreakpoints: function(uiSourceCode) |
614 { | 625 { |
615 this._muted = true; | 626 this._muted = true; |
616 var sourceFileId = WebInspector.BreakpointManager.sourceFileId(uiSourceC
ode); | 627 var sourceFileId = WebInspector.BreakpointManager.sourceFileId(uiSourceC
ode); |
617 for (var id in this._breakpoints) { | 628 for (var id in this._breakpoints) { |
618 var breakpoint = this._breakpoints[id]; | 629 var breakpoint = this._breakpoints[id]; |
619 if (breakpoint.sourceFileId === sourceFileId) | 630 if (breakpoint.sourceFileId === sourceFileId) |
620 this._breakpointManager._innerSetBreakpoint(uiSourceCode, breakp
oint.lineNumber, breakpoint.condition, breakpoint.enabled); | 631 this._breakpointManager._innerSetBreakpoint(uiSourceCode, breakp
oint.lineNumber, breakpoint.columnNumber, breakpoint.condition, breakpoint.enabl
ed); |
621 } | 632 } |
622 delete this._muted; | 633 delete this._muted; |
623 }, | 634 }, |
624 | 635 |
625 /** | 636 /** |
626 * @param {WebInspector.BreakpointManager.Breakpoint} breakpoint | 637 * @param {WebInspector.BreakpointManager.Breakpoint} breakpoint |
627 */ | 638 */ |
628 _updateBreakpoint: function(breakpoint) | 639 _updateBreakpoint: function(breakpoint) |
629 { | 640 { |
630 if (this._muted || !breakpoint._breakpointStorageId()) | 641 if (this._muted || !breakpoint._breakpointStorageId()) |
(...skipping 30 matching lines...) Expand all Loading... |
661 { | 672 { |
662 var primaryUILocation = breakpoint.primaryUILocation(); | 673 var primaryUILocation = breakpoint.primaryUILocation(); |
663 this.sourceFileId = breakpoint._sourceFileId; | 674 this.sourceFileId = breakpoint._sourceFileId; |
664 this.lineNumber = primaryUILocation.lineNumber; | 675 this.lineNumber = primaryUILocation.lineNumber; |
665 this.condition = breakpoint.condition(); | 676 this.condition = breakpoint.condition(); |
666 this.enabled = breakpoint.enabled(); | 677 this.enabled = breakpoint.enabled(); |
667 } | 678 } |
668 | 679 |
669 /** @type {WebInspector.BreakpointManager} */ | 680 /** @type {WebInspector.BreakpointManager} */ |
670 WebInspector.breakpointManager = null; | 681 WebInspector.breakpointManager = null; |
OLD | NEW |