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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 this._breakpointsActive = true; | 47 this._breakpointsActive = true; |
48 this._breakpointsForUISourceCode = new Map(); | 48 this._breakpointsForUISourceCode = new Map(); |
49 this._breakpointsForPrimaryUISourceCode = new Map(); | 49 this._breakpointsForPrimaryUISourceCode = new Map(); |
50 /** @type {!Multimap.<string, !WebInspector.BreakpointManager.Breakpoint>} *
/ | 50 /** @type {!Multimap.<string, !WebInspector.BreakpointManager.Breakpoint>} *
/ |
51 this._provisionalBreakpoints = new Multimap(); | 51 this._provisionalBreakpoints = new Multimap(); |
52 | 52 |
53 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove
d, this._projectRemoved, this); | 53 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectRemove
d, this._projectRemoved, this); |
54 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); | 54 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA
dded, this._uiSourceCodeAdded, this); |
55 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); | 55 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeR
emoved, this._uiSourceCodeRemoved, this); |
56 } | 56 }; |
57 | 57 |
58 /** @enum {symbol} */ | 58 /** @enum {symbol} */ |
59 WebInspector.BreakpointManager.Events = { | 59 WebInspector.BreakpointManager.Events = { |
60 BreakpointAdded: Symbol("breakpoint-added"), | 60 BreakpointAdded: Symbol("breakpoint-added"), |
61 BreakpointRemoved: Symbol("breakpoint-removed"), | 61 BreakpointRemoved: Symbol("breakpoint-removed"), |
62 BreakpointsActiveStateChanged: Symbol("BreakpointsActiveStateChanged") | 62 BreakpointsActiveStateChanged: Symbol("BreakpointsActiveStateChanged") |
63 } | 63 }; |
64 | 64 |
65 /** | 65 /** |
66 * @param {string} sourceFileId | 66 * @param {string} sourceFileId |
67 * @param {number} lineNumber | 67 * @param {number} lineNumber |
68 * @param {number} columnNumber | 68 * @param {number} columnNumber |
69 * @return {string} | 69 * @return {string} |
70 */ | 70 */ |
71 WebInspector.BreakpointManager._breakpointStorageId = function(sourceFileId, lin
eNumber, columnNumber) | 71 WebInspector.BreakpointManager._breakpointStorageId = function(sourceFileId, lin
eNumber, columnNumber) |
72 { | 72 { |
73 if (!sourceFileId) | 73 if (!sourceFileId) |
74 return ""; | 74 return ""; |
75 return sourceFileId + ":" + lineNumber + ":" + columnNumber; | 75 return sourceFileId + ":" + lineNumber + ":" + columnNumber; |
76 } | 76 }; |
77 | 77 |
78 WebInspector.BreakpointManager.prototype = { | 78 WebInspector.BreakpointManager.prototype = { |
79 /** | 79 /** |
80 * @param {!WebInspector.UISourceCode} uiSourceCode | 80 * @param {!WebInspector.UISourceCode} uiSourceCode |
81 * @return {string} | 81 * @return {string} |
82 */ | 82 */ |
83 _sourceFileId: function(uiSourceCode) | 83 _sourceFileId: function(uiSourceCode) |
84 { | 84 { |
85 // TODO(lushnikov): _sourceFileId is not needed any more. | 85 // TODO(lushnikov): _sourceFileId is not needed any more. |
86 return uiSourceCode.url(); | 86 return uiSourceCode.url(); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 /** | 451 /** |
452 * @return {boolean} | 452 * @return {boolean} |
453 */ | 453 */ |
454 breakpointsActive: function() | 454 breakpointsActive: function() |
455 { | 455 { |
456 return this._breakpointsActive; | 456 return this._breakpointsActive; |
457 }, | 457 }, |
458 | 458 |
459 __proto__: WebInspector.Object.prototype | 459 __proto__: WebInspector.Object.prototype |
460 } | 460 }; |
461 | 461 |
462 /** | 462 /** |
463 * @constructor | 463 * @constructor |
464 * @implements {WebInspector.TargetManager.Observer} | 464 * @implements {WebInspector.TargetManager.Observer} |
465 * @param {!WebInspector.BreakpointManager} breakpointManager | 465 * @param {!WebInspector.BreakpointManager} breakpointManager |
466 * @param {string} projectId | 466 * @param {string} projectId |
467 * @param {string} path | 467 * @param {string} path |
468 * @param {string} sourceFileId | 468 * @param {string} sourceFileId |
469 * @param {number} lineNumber | 469 * @param {number} lineNumber |
470 * @param {number} columnNumber | 470 * @param {number} columnNumber |
(...skipping 16 matching lines...) Expand all Loading... |
487 /** @type {string} */ this._condition; | 487 /** @type {string} */ this._condition; |
488 /** @type {boolean} */ this._enabled; | 488 /** @type {boolean} */ this._enabled; |
489 /** @type {boolean} */ this._isRemoved; | 489 /** @type {boolean} */ this._isRemoved; |
490 /** @type {!WebInspector.UILocation|undefined} */ this._fakePrimaryLocation; | 490 /** @type {!WebInspector.UILocation|undefined} */ this._fakePrimaryLocation; |
491 | 491 |
492 this._currentState = null; | 492 this._currentState = null; |
493 /** @type {!Map.<!WebInspector.Target, !WebInspector.BreakpointManager.Targe
tBreakpoint>}*/ | 493 /** @type {!Map.<!WebInspector.Target, !WebInspector.BreakpointManager.Targe
tBreakpoint>}*/ |
494 this._targetBreakpoints = new Map(); | 494 this._targetBreakpoints = new Map(); |
495 this._updateState(condition, enabled); | 495 this._updateState(condition, enabled); |
496 this._breakpointManager._targetManager.observeTargets(this); | 496 this._breakpointManager._targetManager.observeTargets(this); |
497 } | 497 }; |
498 | 498 |
499 WebInspector.BreakpointManager.Breakpoint.prototype = { | 499 WebInspector.BreakpointManager.Breakpoint.prototype = { |
500 /** | 500 /** |
501 * @override | 501 * @override |
502 * @param {!WebInspector.Target} target | 502 * @param {!WebInspector.Target} target |
503 */ | 503 */ |
504 targetAdded: function(target) | 504 targetAdded: function(target) |
505 { | 505 { |
506 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 506 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
507 if (!debuggerModel) | 507 if (!debuggerModel) |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 713 } |
714 }, | 714 }, |
715 | 715 |
716 _resetLocations: function() | 716 _resetLocations: function() |
717 { | 717 { |
718 this._removeFakeBreakpointAtPrimaryLocation(); | 718 this._removeFakeBreakpointAtPrimaryLocation(); |
719 var targetBreakpoints = this._targetBreakpoints.valuesArray(); | 719 var targetBreakpoints = this._targetBreakpoints.valuesArray(); |
720 for (var i = 0; i < targetBreakpoints.length; ++i) | 720 for (var i = 0; i < targetBreakpoints.length; ++i) |
721 targetBreakpoints[i]._resetLocations(); | 721 targetBreakpoints[i]._resetLocations(); |
722 } | 722 } |
723 } | 723 }; |
724 | 724 |
725 /** | 725 /** |
726 * @constructor | 726 * @constructor |
727 * @extends {WebInspector.SDKObject} | 727 * @extends {WebInspector.SDKObject} |
728 * @param {!WebInspector.DebuggerModel} debuggerModel | 728 * @param {!WebInspector.DebuggerModel} debuggerModel |
729 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint | 729 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint |
730 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 730 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
731 */ | 731 */ |
732 WebInspector.BreakpointManager.TargetBreakpoint = function(debuggerModel, breakp
oint, debuggerWorkspaceBinding) | 732 WebInspector.BreakpointManager.TargetBreakpoint = function(debuggerModel, breakp
oint, debuggerWorkspaceBinding) |
733 { | 733 { |
734 WebInspector.SDKObject.call(this, debuggerModel.target()); | 734 WebInspector.SDKObject.call(this, debuggerModel.target()); |
735 this._debuggerModel = debuggerModel; | 735 this._debuggerModel = debuggerModel; |
736 this._breakpoint = breakpoint; | 736 this._breakpoint = breakpoint; |
737 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; | 737 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
738 | 738 |
739 this._liveLocations = new WebInspector.LiveLocationPool(); | 739 this._liveLocations = new WebInspector.LiveLocationPool(); |
740 | 740 |
741 /** @type {!Map<string, !WebInspector.UILocation>} */ | 741 /** @type {!Map<string, !WebInspector.UILocation>} */ |
742 this._uiLocations = new Map(); | 742 this._uiLocations = new Map(); |
743 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug
gerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); | 743 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug
gerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); |
744 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug
gerWasEnabled, this._scheduleUpdateInDebugger, this); | 744 this._debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Debug
gerWasEnabled, this._scheduleUpdateInDebugger, this); |
745 this._hasPendingUpdate = false; | 745 this._hasPendingUpdate = false; |
746 this._isUpdating = false; | 746 this._isUpdating = false; |
747 this._cancelCallback = false; | 747 this._cancelCallback = false; |
748 this._currentState = null; | 748 this._currentState = null; |
749 if (this._debuggerModel.debuggerEnabled()) | 749 if (this._debuggerModel.debuggerEnabled()) |
750 this._scheduleUpdateInDebugger(); | 750 this._scheduleUpdateInDebugger(); |
751 } | 751 }; |
752 | 752 |
753 WebInspector.BreakpointManager.TargetBreakpoint.prototype = { | 753 WebInspector.BreakpointManager.TargetBreakpoint.prototype = { |
754 | 754 |
755 _resetLocations: function() | 755 _resetLocations: function() |
756 { | 756 { |
757 for (var uiLocation of this._uiLocations.values()) | 757 for (var uiLocation of this._uiLocations.values()) |
758 this._breakpoint._removeUILocation(uiLocation); | 758 this._breakpoint._removeUILocation(uiLocation); |
759 | 759 |
760 this._uiLocations.clear(); | 760 this._uiLocations.clear(); |
761 this._liveLocations.disposeAll(); | 761 this._liveLocations.disposeAll(); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 this._didRemoveFromDebugger(function() {}); | 949 this._didRemoveFromDebugger(function() {}); |
950 }, | 950 }, |
951 | 951 |
952 _removeEventListeners: function() | 952 _removeEventListeners: function() |
953 { | 953 { |
954 this._debuggerModel.removeEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); | 954 this._debuggerModel.removeEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasDisabled, this._cleanUpAfterDebuggerIsGone, this); |
955 this._debuggerModel.removeEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasEnabled, this._scheduleUpdateInDebugger, this); | 955 this._debuggerModel.removeEventListener(WebInspector.DebuggerModel.Event
s.DebuggerWasEnabled, this._scheduleUpdateInDebugger, this); |
956 }, | 956 }, |
957 | 957 |
958 __proto__: WebInspector.SDKObject.prototype | 958 __proto__: WebInspector.SDKObject.prototype |
959 } | 959 }; |
960 | 960 |
961 /** | 961 /** |
962 * @constructor | 962 * @constructor |
963 * @param {?string} url | 963 * @param {?string} url |
964 * @param {?string} scriptId | 964 * @param {?string} scriptId |
965 * @param {number} lineNumber | 965 * @param {number} lineNumber |
966 * @param {number} columnNumber | 966 * @param {number} columnNumber |
967 * @param {string} condition | 967 * @param {string} condition |
968 */ | 968 */ |
969 WebInspector.BreakpointManager.Breakpoint.State = function(url, scriptId, lineNu
mber, columnNumber, condition) | 969 WebInspector.BreakpointManager.Breakpoint.State = function(url, scriptId, lineNu
mber, columnNumber, condition) |
970 { | 970 { |
971 this.url = url; | 971 this.url = url; |
972 this.scriptId = scriptId; | 972 this.scriptId = scriptId; |
973 this.lineNumber = lineNumber; | 973 this.lineNumber = lineNumber; |
974 this.columnNumber = columnNumber; | 974 this.columnNumber = columnNumber; |
975 this.condition = condition; | 975 this.condition = condition; |
976 } | 976 }; |
977 | 977 |
978 /** | 978 /** |
979 * @param {?WebInspector.BreakpointManager.Breakpoint.State|undefined} stateA | 979 * @param {?WebInspector.BreakpointManager.Breakpoint.State|undefined} stateA |
980 * @param {?WebInspector.BreakpointManager.Breakpoint.State|undefined} stateB | 980 * @param {?WebInspector.BreakpointManager.Breakpoint.State|undefined} stateB |
981 * @return {boolean} | 981 * @return {boolean} |
982 */ | 982 */ |
983 WebInspector.BreakpointManager.Breakpoint.State.equals = function(stateA, stateB
) | 983 WebInspector.BreakpointManager.Breakpoint.State.equals = function(stateA, stateB
) |
984 { | 984 { |
985 if (!stateA || !stateB) | 985 if (!stateA || !stateB) |
986 return false; | 986 return false; |
987 | 987 |
988 if (stateA.scriptId || stateB.scriptId) | 988 if (stateA.scriptId || stateB.scriptId) |
989 return false; | 989 return false; |
990 | 990 |
991 return stateA.url === stateB.url && stateA.lineNumber === stateB.lineNumber
&& stateA.columnNumber === stateB.columnNumber && stateA.condition === stateB.co
ndition; | 991 return stateA.url === stateB.url && stateA.lineNumber === stateB.lineNumber
&& stateA.columnNumber === stateB.columnNumber && stateA.condition === stateB.co
ndition; |
992 } | 992 }; |
993 | 993 |
994 /** | 994 /** |
995 * @constructor | 995 * @constructor |
996 * @param {!WebInspector.BreakpointManager} breakpointManager | 996 * @param {!WebInspector.BreakpointManager} breakpointManager |
997 * @param {?WebInspector.Setting} setting | 997 * @param {?WebInspector.Setting} setting |
998 */ | 998 */ |
999 WebInspector.BreakpointManager.Storage = function(breakpointManager, setting) | 999 WebInspector.BreakpointManager.Storage = function(breakpointManager, setting) |
1000 { | 1000 { |
1001 this._breakpointManager = breakpointManager; | 1001 this._breakpointManager = breakpointManager; |
1002 this._setting = setting || WebInspector.settings.createLocalSetting("breakpo
ints", []); | 1002 this._setting = setting || WebInspector.settings.createLocalSetting("breakpo
ints", []); |
1003 var breakpoints = this._setting.get(); | 1003 var breakpoints = this._setting.get(); |
1004 /** @type {!Object.<string, !WebInspector.BreakpointManager.Storage.Item>} *
/ | 1004 /** @type {!Object.<string, !WebInspector.BreakpointManager.Storage.Item>} *
/ |
1005 this._breakpoints = {}; | 1005 this._breakpoints = {}; |
1006 for (var i = 0; i < breakpoints.length; ++i) { | 1006 for (var i = 0; i < breakpoints.length; ++i) { |
1007 var breakpoint = /** @type {!WebInspector.BreakpointManager.Storage.Item
} */ (breakpoints[i]); | 1007 var breakpoint = /** @type {!WebInspector.BreakpointManager.Storage.Item
} */ (breakpoints[i]); |
1008 breakpoint.columnNumber = breakpoint.columnNumber || 0; | 1008 breakpoint.columnNumber = breakpoint.columnNumber || 0; |
1009 this._breakpoints[breakpoint.sourceFileId + ":" + breakpoint.lineNumber
+ ":" + breakpoint.columnNumber] = breakpoint; | 1009 this._breakpoints[breakpoint.sourceFileId + ":" + breakpoint.lineNumber
+ ":" + breakpoint.columnNumber] = breakpoint; |
1010 } | 1010 } |
1011 } | 1011 }; |
1012 | 1012 |
1013 WebInspector.BreakpointManager.Storage.prototype = { | 1013 WebInspector.BreakpointManager.Storage.prototype = { |
1014 mute: function() | 1014 mute: function() |
1015 { | 1015 { |
1016 this._muted = true; | 1016 this._muted = true; |
1017 }, | 1017 }, |
1018 | 1018 |
1019 unmute: function() | 1019 unmute: function() |
1020 { | 1020 { |
1021 delete this._muted; | 1021 delete this._muted; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 this._save(); | 1058 this._save(); |
1059 }, | 1059 }, |
1060 | 1060 |
1061 _save: function() | 1061 _save: function() |
1062 { | 1062 { |
1063 var breakpointsArray = []; | 1063 var breakpointsArray = []; |
1064 for (var id in this._breakpoints) | 1064 for (var id in this._breakpoints) |
1065 breakpointsArray.push(this._breakpoints[id]); | 1065 breakpointsArray.push(this._breakpoints[id]); |
1066 this._setting.set(breakpointsArray); | 1066 this._setting.set(breakpointsArray); |
1067 } | 1067 } |
1068 } | 1068 }; |
1069 | 1069 |
1070 /** | 1070 /** |
1071 * @constructor | 1071 * @constructor |
1072 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint | 1072 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint |
1073 */ | 1073 */ |
1074 WebInspector.BreakpointManager.Storage.Item = function(breakpoint) | 1074 WebInspector.BreakpointManager.Storage.Item = function(breakpoint) |
1075 { | 1075 { |
1076 this.sourceFileId = breakpoint._sourceFileId; | 1076 this.sourceFileId = breakpoint._sourceFileId; |
1077 this.lineNumber = breakpoint.lineNumber(); | 1077 this.lineNumber = breakpoint.lineNumber(); |
1078 this.columnNumber = breakpoint.columnNumber(); | 1078 this.columnNumber = breakpoint.columnNumber(); |
1079 this.condition = breakpoint.condition(); | 1079 this.condition = breakpoint.condition(); |
1080 this.enabled = breakpoint.enabled(); | 1080 this.enabled = breakpoint.enabled(); |
1081 } | 1081 }; |
1082 | 1082 |
1083 /** @type {!WebInspector.BreakpointManager} */ | 1083 /** @type {!WebInspector.BreakpointManager} */ |
1084 WebInspector.breakpointManager; | 1084 WebInspector.breakpointManager; |
OLD | NEW |