OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @extends {WebInspector.SidebarPane} | 7 * @extends {WebInspector.SidebarPane} |
8 * @param {!WebInspector.BreakpointManager} breakpointManager | 8 * @param {!WebInspector.BreakpointManager} breakpointManager |
9 * @param {function(!WebInspector.UISourceCode, number=, number=, boolean=)} sho
wSourceLineDelegate | 9 * @param {function(!WebInspector.UISourceCode, number=, number=, boolean=)} sho
wSourceLineDelegate |
10 */ | 10 */ |
11 WebInspector.JavaScriptBreakpointsSidebarPane = function(breakpointManager, show
SourceLineDelegate) | 11 WebInspector.JavaScriptBreakpointsSidebarPane = function(breakpointManager, show
SourceLineDelegate) |
12 { | 12 { |
13 WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints")); | 13 WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints")); |
14 this.registerRequiredCSS("components/breakpointsList.css"); | 14 this.registerRequiredCSS("components/breakpointsList.css"); |
15 | 15 |
16 this._breakpointManager = breakpointManager; | 16 this._breakpointManager = breakpointManager; |
17 this._showSourceLineDelegate = showSourceLineDelegate; | 17 this._showSourceLineDelegate = showSourceLineDelegate; |
18 | 18 |
19 this.listElement = createElementWithClass("ol", "breakpoint-list"); | 19 this.listElement = createElementWithClass("ol", "breakpoint-list"); |
20 | 20 |
21 this.emptyElement = this.bodyElement.createChild("div", "info"); | 21 this.emptyElement = this.element.createChild("div", "info"); |
22 this.emptyElement.textContent = WebInspector.UIString("No Breakpoints"); | 22 this.emptyElement.textContent = WebInspector.UIString("No Breakpoints"); |
23 | 23 |
24 this._items = new Map(); | 24 this._items = new Map(); |
25 | 25 |
26 var breakpointLocations = this._breakpointManager.allBreakpointLocations(); | 26 var breakpointLocations = this._breakpointManager.allBreakpointLocations(); |
27 for (var i = 0; i < breakpointLocations.length; ++i) | 27 for (var i = 0; i < breakpointLocations.length; ++i) |
28 this._addBreakpoint(breakpointLocations[i].breakpoint, breakpointLocatio
ns[i].uiLocation); | 28 this._addBreakpoint(breakpointLocations[i].breakpoint, breakpointLocatio
ns[i].uiLocation); |
29 | 29 |
30 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointAdded, this._breakpointAdded, this); | 30 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointAdded, this._breakpointAdded, this); |
31 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointRemoved, this._breakpointRemoved, this); | 31 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointRemoved, this._breakpointRemoved, this); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 /** | 68 /** |
69 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint | 69 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint |
70 * @param {!WebInspector.UILocation} uiLocation | 70 * @param {!WebInspector.UILocation} uiLocation |
71 */ | 71 */ |
72 _addBreakpoint: function(breakpoint, uiLocation) | 72 _addBreakpoint: function(breakpoint, uiLocation) |
73 { | 73 { |
74 var element = createElementWithClass("li", "cursor-pointer"); | 74 var element = createElementWithClass("li", "cursor-pointer"); |
75 element.addEventListener("contextmenu", this._breakpointContextMenu.bind
(this, breakpoint), true); | 75 element.addEventListener("contextmenu", this._breakpointContextMenu.bind
(this, breakpoint), true); |
76 element.addEventListener("click", this._breakpointClicked.bind(this, uiL
ocation), false); | 76 element.addEventListener("click", this._breakpointClicked.bind(this, uiL
ocation), false); |
77 | 77 |
78 var checkbox = element.createChild("input", "checkbox-elem"); | 78 var checkbox = createCheckboxLabel(uiLocation.linkText(), breakpoint.ena
bled()); |
79 checkbox.type = "checkbox"; | 79 element.appendChild(checkbox); |
80 checkbox.checked = breakpoint.enabled(); | |
81 checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(
this, breakpoint), false); | 80 checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(
this, breakpoint), false); |
82 | 81 |
83 element.createTextChild(uiLocation.linkText()); | |
84 | |
85 var snippetElement = element.createChild("div", "source-text monospace")
; | 82 var snippetElement = element.createChild("div", "source-text monospace")
; |
86 | 83 |
87 /** | 84 /** |
88 * @param {?string} content | 85 * @param {?string} content |
89 */ | 86 */ |
90 function didRequestContent(content) | 87 function didRequestContent(content) |
91 { | 88 { |
92 var lineNumber = uiLocation.lineNumber | 89 var lineNumber = uiLocation.lineNumber |
93 var columnNumber = uiLocation.columnNumber; | 90 var columnNumber = uiLocation.columnNumber; |
94 var contentString = new String(content); | 91 var contentString = new String(content); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 202 |
206 contextMenu.show(); | 203 contextMenu.show(); |
207 }, | 204 }, |
208 | 205 |
209 _addListElement: function(element, beforeElement) | 206 _addListElement: function(element, beforeElement) |
210 { | 207 { |
211 if (beforeElement) | 208 if (beforeElement) |
212 this.listElement.insertBefore(element, beforeElement); | 209 this.listElement.insertBefore(element, beforeElement); |
213 else { | 210 else { |
214 if (!this.listElement.firstChild) { | 211 if (!this.listElement.firstChild) { |
215 this.bodyElement.removeChild(this.emptyElement); | 212 this.element.removeChild(this.emptyElement); |
216 this.bodyElement.appendChild(this.listElement); | 213 this.element.appendChild(this.listElement); |
217 } | 214 } |
218 this.listElement.appendChild(element); | 215 this.listElement.appendChild(element); |
219 } | 216 } |
220 }, | 217 }, |
221 | 218 |
222 _removeListElement: function(element) | 219 _removeListElement: function(element) |
223 { | 220 { |
224 this.listElement.removeChild(element); | 221 this.listElement.removeChild(element); |
225 if (!this.listElement.firstChild) { | 222 if (!this.listElement.firstChild) { |
226 this.bodyElement.removeChild(this.listElement); | 223 this.element.removeChild(this.listElement); |
227 this.bodyElement.appendChild(this.emptyElement); | 224 this.element.appendChild(this.emptyElement); |
228 } | 225 } |
229 }, | 226 }, |
230 | 227 |
231 _compare: function(x, y) | 228 _compare: function(x, y) |
232 { | 229 { |
233 if (x !== y) | 230 if (x !== y) |
234 return x < y ? -1 : 1; | 231 return x < y ? -1 : 1; |
235 return 0; | 232 return 0; |
236 }, | 233 }, |
237 | 234 |
238 _compareBreakpoints: function(b1, b2) | 235 _compareBreakpoints: function(b1, b2) |
239 { | 236 { |
240 return this._compare(b1.uiSourceCode.originURL(), b2.uiSourceCode.origin
URL()) || this._compare(b1.lineNumber, b2.lineNumber); | 237 return this._compare(b1.uiSourceCode.originURL(), b2.uiSourceCode.origin
URL()) || this._compare(b1.lineNumber, b2.lineNumber); |
241 }, | 238 }, |
242 | 239 |
243 reset: function() | 240 reset: function() |
244 { | 241 { |
245 this.listElement.removeChildren(); | 242 this.listElement.removeChildren(); |
246 if (this.listElement.parentElement) { | 243 if (this.listElement.parentElement) { |
247 this.bodyElement.removeChild(this.listElement); | 244 this.element.removeChild(this.listElement); |
248 this.bodyElement.appendChild(this.emptyElement); | 245 this.element.appendChild(this.emptyElement); |
249 } | 246 } |
250 this._items.clear(); | 247 this._items.clear(); |
251 }, | 248 }, |
252 | 249 |
253 __proto__: WebInspector.SidebarPane.prototype | 250 __proto__: WebInspector.SidebarPane.prototype |
254 } | 251 } |
OLD | NEW |