Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/JavaScriptBreakpointsSidebarPane.js

Issue 2238003002: DevTools: migrate sources panel sidebar to views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: followed up on the watch test. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManag er.Events.BreakpointsActiveStateChanged, this._breakpointsActiveStateChanged, th is);
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
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
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 ? WebInspector.breakpointManager.findBreakpo intOnLine(uiLocation.uiSourceCode, uiLocation.lineNumber) : null;
dgozman 2016/08/15 21:31:03 Either this._breakpointManager or WI.breakpointMan
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.revealViewWithWidget(this);
148 }, 164 },
149 165
150 clearBreakpointHighlight: function() 166 _breakpointsActiveStateChanged: function()
151 { 167 {
152 if (this._highlightedBreakpointItem) { 168 this._listElement.classList.toggle("breakpoints-list-deactivated", !WebI nspector.breakpointManager.breakpointsActive());
153 this._highlightedBreakpointItem.element.classList.remove("breakpoint -hit");
154 delete this._highlightedBreakpointItem;
155 }
156 }, 169 },
157 170
158 _breakpointClicked: function(uiLocation, event) 171 _breakpointClicked: function(uiLocation, event)
159 { 172 {
160 this._showSourceLineDelegate(uiLocation.uiSourceCode, uiLocation.lineNum ber); 173 WebInspector.Revealer.reveal(uiLocation);
dgozman 2016/08/15 21:31:03 Inline it.
161 }, 174 },
162 175
163 /** 176 /**
164 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint 177 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
165 * @param {!Event} event 178 * @param {!Event} event
166 */ 179 */
167 _breakpointCheckboxClicked: function(breakpoint, event) 180 _breakpointCheckboxClicked: function(breakpoint, event)
168 { 181 {
169 // Breakpoint element has it's own click handler. 182 // Breakpoint element has it's own click handler.
170 event.consume(); 183 event.consume();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 contextMenu.appendItem(enableTitle, this._breakpointManager.toggleAl lBreakpoints.bind(this._breakpointManager, true), !(enableBreakpointCount !== br eakpoints.length)); 220 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) ); 221 contextMenu.appendItem(disableTitle, this._breakpointManager.toggleA llBreakpoints.bind(this._breakpointManager, false), !(enableBreakpointCount > 1) );
209 } 222 }
210 223
211 contextMenu.show(); 224 contextMenu.show();
212 }, 225 },
213 226
214 _addListElement: function(element, beforeElement) 227 _addListElement: function(element, beforeElement)
215 { 228 {
216 if (beforeElement) 229 if (beforeElement)
217 this.listElement.insertBefore(element, beforeElement); 230 this._listElement.insertBefore(element, beforeElement);
218 else { 231 else {
219 if (!this.listElement.firstChild) { 232 if (!this._listElement.firstChild) {
220 this.element.removeChild(this.emptyElement); 233 this.element.removeChild(this.emptyElement);
221 this.element.appendChild(this.listElement); 234 this.element.appendChild(this._listElement);
222 } 235 }
223 this.listElement.appendChild(element); 236 this._listElement.appendChild(element);
224 } 237 }
225 }, 238 },
226 239
227 _removeListElement: function(element) 240 _removeListElement: function(element)
228 { 241 {
229 this.listElement.removeChild(element); 242 this._listElement.removeChild(element);
230 if (!this.listElement.firstChild) { 243 if (!this._listElement.firstChild) {
231 this.element.removeChild(this.listElement); 244 this.element.removeChild(this._listElement);
232 this.element.appendChild(this.emptyElement); 245 this.element.appendChild(this.emptyElement);
233 } 246 }
234 }, 247 },
235 248
236 _compare: function(x, y) 249 _compare: function(x, y)
237 { 250 {
238 if (x !== y) 251 if (x !== y)
239 return x < y ? -1 : 1; 252 return x < y ? -1 : 1;
240 return 0; 253 return 0;
241 }, 254 },
242 255
243 _compareBreakpoints: function(b1, b2) 256 _compareBreakpoints: function(b1, b2)
244 { 257 {
245 return this._compare(b1.uiSourceCode.url(), b2.uiSourceCode.url()) || th is._compare(b1.lineNumber, b2.lineNumber); 258 return this._compare(b1.uiSourceCode.url(), b2.uiSourceCode.url()) || th is._compare(b1.lineNumber, b2.lineNumber);
246 }, 259 },
247 260
248 reset: function() 261 reset: function()
249 { 262 {
250 this.listElement.removeChildren(); 263 this._listElement.removeChildren();
251 if (this.listElement.parentElement) { 264 if (this._listElement.parentElement) {
252 this.element.removeChild(this.listElement); 265 this.element.removeChild(this._listElement);
253 this.element.appendChild(this.emptyElement); 266 this.element.appendChild(this.emptyElement);
254 } 267 }
255 this._items.clear(); 268 this._items.clear();
256 }, 269 },
257 270
258 __proto__: WebInspector.SimpleView.prototype 271 __proto__: WebInspector.VBox.prototype
259 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698