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.SimpleView} | 7 * @extends {WebInspector.VBox} |
8 * @param {!WebInspector.BreakpointManager} breakpointManager | 8 * @implements {WebInspector.ContextFlavorListener} |
9 * @param {function(!WebInspector.UISourceCode, number=, number=, boolean=)} sho
wSourceLineDelegate | |
10 */ | 9 */ |
11 WebInspector.JavaScriptBreakpointsSidebarPane = function(breakpointManager, show
SourceLineDelegate) | 10 WebInspector.JavaScriptBreakpointsSidebarPane = function() |
12 { | 11 { |
13 WebInspector.SimpleView.call(this, WebInspector.UIString("Breakpoints")); | 12 WebInspector.VBox.call(this); |
14 this.registerRequiredCSS("components/breakpointsList.css"); | 13 this.registerRequiredCSS("components/breakpointsList.css"); |
15 | 14 |
16 this._breakpointManager = breakpointManager; | 15 this._breakpointManager = WebInspector.breakpointManager; |
17 this._showSourceLineDelegate = showSourceLineDelegate; | |
18 | 16 |
19 this.listElement = createElementWithClass("ol", "breakpoint-list"); | 17 this._listElement = createElementWithClass("ol", "breakpoint-list"); |
20 | 18 |
21 this.emptyElement = this.element.createChild("div", "gray-info-message"); | 19 this.emptyElement = this.element.createChild("div", "gray-info-message"); |
22 this.emptyElement.textContent = WebInspector.UIString("No Breakpoints"); | 20 this.emptyElement.textContent = WebInspector.UIString("No Breakpoints"); |
23 | 21 |
24 this._items = new Map(); | 22 this._items = new Map(); |
25 | 23 |
26 var breakpointLocations = this._breakpointManager.allBreakpointLocations(); | 24 var breakpointLocations = this._breakpointManager.allBreakpointLocations(); |
27 for (var i = 0; i < breakpointLocations.length; ++i) | 25 for (var i = 0; i < breakpointLocations.length; ++i) |
28 this._addBreakpoint(breakpointLocations[i].breakpoint, breakpointLocatio
ns[i].uiLocation); | 26 this._addBreakpoint(breakpointLocations[i].breakpoint, breakpointLocatio
ns[i].uiLocation); |
29 | 27 |
30 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointAdded, this._breakpointAdded, this); | 28 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointAdded, this._breakpointAdded, this); |
31 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointRemoved, this._breakpointRemoved, this); | 29 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointRemoved, this._breakpointRemoved, this); |
32 | 30 |
33 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM
enu.bind(this), true); | 31 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM
enu.bind(this), true); |
| 32 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even
ts.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, this); |
| 33 this._breakpointsActiveStateChanged(); |
| 34 this._update(); |
34 } | 35 } |
35 | 36 |
36 WebInspector.JavaScriptBreakpointsSidebarPane.prototype = { | 37 WebInspector.JavaScriptBreakpointsSidebarPane.prototype = { |
37 _emptyElementContextMenu: function(event) | 38 _emptyElementContextMenu: function(event) |
38 { | 39 { |
39 var contextMenu = new WebInspector.ContextMenu(event); | 40 var contextMenu = new WebInspector.ContextMenu(event); |
40 this._appendBreakpointActiveItem(contextMenu); | 41 this._appendBreakpointActiveItem(contextMenu); |
41 contextMenu.show(); | 42 contextMenu.show(); |
42 }, | 43 }, |
43 | 44 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 var maxSnippetLength = 200; | 96 var maxSnippetLength = 200; |
96 var snippetStartIndex = columnNumber > 100 ? columnNumber : 0; | 97 var snippetStartIndex = columnNumber > 100 ? columnNumber : 0; |
97 snippetElement.textContent = lineText.substr(snippetStartIndex).
trimEnd(maxSnippetLength); | 98 snippetElement.textContent = lineText.substr(snippetStartIndex).
trimEnd(maxSnippetLength); |
98 } | 99 } |
99 this.didReceiveBreakpointLineForTest(uiLocation.uiSourceCode); | 100 this.didReceiveBreakpointLineForTest(uiLocation.uiSourceCode); |
100 } | 101 } |
101 | 102 |
102 uiLocation.uiSourceCode.requestContent().then(didRequestContent.bind(thi
s)); | 103 uiLocation.uiSourceCode.requestContent().then(didRequestContent.bind(thi
s)); |
103 | 104 |
104 element._data = uiLocation; | 105 element._data = uiLocation; |
105 var currentElement = this.listElement.firstChild; | 106 var currentElement = this._listElement.firstChild; |
106 while (currentElement) { | 107 while (currentElement) { |
107 if (currentElement._data && this._compareBreakpoints(currentElement.
_data, element._data) > 0) | 108 if (currentElement._data && this._compareBreakpoints(currentElement.
_data, element._data) > 0) |
108 break; | 109 break; |
109 currentElement = currentElement.nextSibling; | 110 currentElement = currentElement.nextSibling; |
110 } | 111 } |
111 this._addListElement(element, currentElement); | 112 this._addListElement(element, currentElement); |
112 | 113 |
113 var breakpointItem = { element: element, checkbox: checkboxLabel.checkbo
xElement }; | 114 var breakpointItem = { element: element, checkbox: checkboxLabel.checkbo
xElement }; |
114 this._items.set(breakpoint, breakpointItem); | 115 this._items.set(breakpoint, breakpointItem); |
115 }, | 116 }, |
(...skipping 12 matching lines...) Expand all Loading... |
128 { | 129 { |
129 var breakpoint = /** @type {!WebInspector.BreakpointManager.Breakpoint}
*/ (event.data.breakpoint); | 130 var breakpoint = /** @type {!WebInspector.BreakpointManager.Breakpoint}
*/ (event.data.breakpoint); |
130 var breakpointItem = this._items.get(breakpoint); | 131 var breakpointItem = this._items.get(breakpoint); |
131 if (!breakpointItem) | 132 if (!breakpointItem) |
132 return; | 133 return; |
133 this._items.remove(breakpoint); | 134 this._items.remove(breakpoint); |
134 this._removeListElement(breakpointItem.element); | 135 this._removeListElement(breakpointItem.element); |
135 }, | 136 }, |
136 | 137 |
137 /** | 138 /** |
138 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint | 139 * @override |
| 140 * @param {?Object} object |
139 */ | 141 */ |
140 highlightBreakpoint: function(breakpoint) | 142 flavorChanged: function(object) |
141 { | 143 { |
| 144 this._update(); |
| 145 }, |
| 146 |
| 147 _update: function() |
| 148 { |
| 149 var details = WebInspector.context.flavor(WebInspector.DebuggerPausedDet
ails); |
| 150 var uiLocation = details && details.callFrames.length ? WebInspector.deb
uggerWorkspaceBinding.rawLocationToUILocation(details.callFrames[0].location())
: null; |
| 151 var breakpoint = uiLocation ? this._breakpointManager.findBreakpointOnLi
ne(uiLocation.uiSourceCode, uiLocation.lineNumber) : null; |
142 var breakpointItem = this._items.get(breakpoint); | 152 var breakpointItem = this._items.get(breakpoint); |
143 if (!breakpointItem) | 153 if (!breakpointItem) { |
| 154 if (this._highlightedBreakpointItem) { |
| 155 this._highlightedBreakpointItem.element.classList.remove("breakp
oint-hit"); |
| 156 delete this._highlightedBreakpointItem; |
| 157 } |
144 return; | 158 return; |
| 159 } |
| 160 |
145 breakpointItem.element.classList.add("breakpoint-hit"); | 161 breakpointItem.element.classList.add("breakpoint-hit"); |
146 this._highlightedBreakpointItem = breakpointItem; | 162 this._highlightedBreakpointItem = breakpointItem; |
147 this.revealView(); | 163 WebInspector.viewManager.showView("sources.jsBreakpoints"); |
148 }, | 164 }, |
149 | 165 |
150 clearBreakpointHighlight: function() | 166 _breakpointsActiveStateChanged: function() |
151 { | 167 { |
152 if (this._highlightedBreakpointItem) { | 168 this._listElement.classList.toggle("breakpoints-list-deactivated", !this
._breakpointManager.breakpointsActive()); |
153 this._highlightedBreakpointItem.element.classList.remove("breakpoint
-hit"); | |
154 delete this._highlightedBreakpointItem; | |
155 } | |
156 }, | |
157 | |
158 _breakpointClicked: function(uiLocation, event) | |
159 { | |
160 this._showSourceLineDelegate(uiLocation.uiSourceCode, uiLocation.lineNum
ber); | |
161 }, | 169 }, |
162 | 170 |
163 /** | 171 /** |
| 172 * @param {!WebInspector.UILocation} uiLocation |
| 173 */ |
| 174 _breakpointClicked: function(uiLocation) |
| 175 { |
| 176 WebInspector.Revealer.reveal(uiLocation); |
| 177 }, |
| 178 |
| 179 /** |
164 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint | 180 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint |
165 * @param {!Event} event | 181 * @param {!Event} event |
166 */ | 182 */ |
167 _breakpointCheckboxClicked: function(breakpoint, event) | 183 _breakpointCheckboxClicked: function(breakpoint, event) |
168 { | 184 { |
169 // Breakpoint element has it's own click handler. | 185 // Breakpoint element has it's own click handler. |
170 event.consume(); | 186 event.consume(); |
171 breakpoint.setEnabled(event.target.checkboxElement.checked); | 187 breakpoint.setEnabled(event.target.checkboxElement.checked); |
172 }, | 188 }, |
173 | 189 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 contextMenu.appendItem(enableTitle, this._breakpointManager.toggleAl
lBreakpoints.bind(this._breakpointManager, true), !(enableBreakpointCount !== br
eakpoints.length)); | 223 contextMenu.appendItem(enableTitle, this._breakpointManager.toggleAl
lBreakpoints.bind(this._breakpointManager, true), !(enableBreakpointCount !== br
eakpoints.length)); |
208 contextMenu.appendItem(disableTitle, this._breakpointManager.toggleA
llBreakpoints.bind(this._breakpointManager, false), !(enableBreakpointCount > 1)
); | 224 contextMenu.appendItem(disableTitle, this._breakpointManager.toggleA
llBreakpoints.bind(this._breakpointManager, false), !(enableBreakpointCount > 1)
); |
209 } | 225 } |
210 | 226 |
211 contextMenu.show(); | 227 contextMenu.show(); |
212 }, | 228 }, |
213 | 229 |
214 _addListElement: function(element, beforeElement) | 230 _addListElement: function(element, beforeElement) |
215 { | 231 { |
216 if (beforeElement) | 232 if (beforeElement) |
217 this.listElement.insertBefore(element, beforeElement); | 233 this._listElement.insertBefore(element, beforeElement); |
218 else { | 234 else { |
219 if (!this.listElement.firstChild) { | 235 if (!this._listElement.firstChild) { |
220 this.element.removeChild(this.emptyElement); | 236 this.element.removeChild(this.emptyElement); |
221 this.element.appendChild(this.listElement); | 237 this.element.appendChild(this._listElement); |
222 } | 238 } |
223 this.listElement.appendChild(element); | 239 this._listElement.appendChild(element); |
224 } | 240 } |
225 }, | 241 }, |
226 | 242 |
227 _removeListElement: function(element) | 243 _removeListElement: function(element) |
228 { | 244 { |
229 this.listElement.removeChild(element); | 245 this._listElement.removeChild(element); |
230 if (!this.listElement.firstChild) { | 246 if (!this._listElement.firstChild) { |
231 this.element.removeChild(this.listElement); | 247 this.element.removeChild(this._listElement); |
232 this.element.appendChild(this.emptyElement); | 248 this.element.appendChild(this.emptyElement); |
233 } | 249 } |
234 }, | 250 }, |
235 | 251 |
236 _compare: function(x, y) | 252 _compare: function(x, y) |
237 { | 253 { |
238 if (x !== y) | 254 if (x !== y) |
239 return x < y ? -1 : 1; | 255 return x < y ? -1 : 1; |
240 return 0; | 256 return 0; |
241 }, | 257 }, |
242 | 258 |
243 _compareBreakpoints: function(b1, b2) | 259 _compareBreakpoints: function(b1, b2) |
244 { | 260 { |
245 return this._compare(b1.uiSourceCode.url(), b2.uiSourceCode.url()) || th
is._compare(b1.lineNumber, b2.lineNumber); | 261 return this._compare(b1.uiSourceCode.url(), b2.uiSourceCode.url()) || th
is._compare(b1.lineNumber, b2.lineNumber); |
246 }, | 262 }, |
247 | 263 |
248 reset: function() | 264 reset: function() |
249 { | 265 { |
250 this.listElement.removeChildren(); | 266 this._listElement.removeChildren(); |
251 if (this.listElement.parentElement) { | 267 if (this._listElement.parentElement) { |
252 this.element.removeChild(this.listElement); | 268 this.element.removeChild(this._listElement); |
253 this.element.appendChild(this.emptyElement); | 269 this.element.appendChild(this.emptyElement); |
254 } | 270 } |
255 this._items.clear(); | 271 this._items.clear(); |
256 }, | 272 }, |
257 | 273 |
258 __proto__: WebInspector.SimpleView.prototype | 274 __proto__: WebInspector.VBox.prototype |
259 } | 275 } |
OLD | NEW |