| 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.BreakpointsSidebarPaneBase} | 7 * @extends {WebInspector.BreakpointsSidebarPaneBase} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 * @implements {WebInspector.ToolbarItem.ItemsProvider} |
| 9 */ | 10 */ |
| 10 WebInspector.XHRBreakpointsSidebarPane = function() | 11 WebInspector.XHRBreakpointsSidebarPane = function() |
| 11 { | 12 { |
| 12 WebInspector.BreakpointsSidebarPaneBase.call(this, WebInspector.UIString("XH
R Breakpoints")); | 13 WebInspector.BreakpointsSidebarPaneBase.call(this); |
| 13 this._xhrBreakpointsSetting = WebInspector.settings.createLocalSetting("xhrB
reakpoints", []); | 14 this._xhrBreakpointsSetting = WebInspector.settings.createLocalSetting("xhrB
reakpoints", []); |
| 14 | 15 |
| 15 /** @type {!Map.<string, !Element>} */ | 16 /** @type {!Map.<string, !Element>} */ |
| 16 this._breakpointElements = new Map(); | 17 this._breakpointElements = new Map(); |
| 17 | 18 |
| 18 var addButton = new WebInspector.ToolbarButton(WebInspector.UIString("Add br
eakpoint"), "add-toolbar-item"); | 19 this._addButton = new WebInspector.ToolbarButton(WebInspector.UIString("Add
breakpoint"), "add-toolbar-item"); |
| 19 addButton.addEventListener("click", this._addButtonClicked.bind(this)); | 20 this._addButton.addEventListener("click", this._addButtonClicked.bind(this))
; |
| 20 this.addToolbarItem(addButton); | |
| 21 | 21 |
| 22 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM
enu.bind(this), true); | 22 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM
enu.bind(this), true); |
| 23 | 23 |
| 24 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); | 24 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 25 } | 25 } |
| 26 | 26 |
| 27 WebInspector.XHRBreakpointsSidebarPane.prototype = { | 27 WebInspector.XHRBreakpointsSidebarPane.prototype = { |
| 28 /** | 28 /** |
| 29 * @override | 29 * @override |
| 30 * @param {!WebInspector.Target} target | 30 * @param {!WebInspector.Target} target |
| 31 */ | 31 */ |
| 32 targetAdded: function(target) | 32 targetAdded: function(target) |
| 33 { | 33 { |
| 34 this._restoreBreakpoints(target); | 34 this._restoreBreakpoints(target); |
| 35 }, | 35 }, |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * @override | 38 * @override |
| 39 * @param {!WebInspector.Target} target | 39 * @param {!WebInspector.Target} target |
| 40 */ | 40 */ |
| 41 targetRemoved: function(target) { }, | 41 targetRemoved: function(target) { }, |
| 42 | 42 |
| 43 /** |
| 44 * @override |
| 45 * @return {!Array<!WebInspector.ToolbarItem>} |
| 46 */ |
| 47 toolbarItems: function() |
| 48 { |
| 49 return [this._addButton]; |
| 50 }, |
| 51 |
| 43 _emptyElementContextMenu: function(event) | 52 _emptyElementContextMenu: function(event) |
| 44 { | 53 { |
| 45 var contextMenu = new WebInspector.ContextMenu(event); | 54 var contextMenu = new WebInspector.ContextMenu(event); |
| 46 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakpoint
"), this._addButtonClicked.bind(this)); | 55 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakpoint
"), this._addButtonClicked.bind(this)); |
| 47 contextMenu.show(); | 56 contextMenu.show(); |
| 48 }, | 57 }, |
| 49 | 58 |
| 50 _addButtonClicked: function(event) | 59 _addButtonClicked: function(event) |
| 51 { | 60 { |
| 52 if (event) | 61 if (event) |
| 53 event.consume(); | 62 event.consume(); |
| 54 | 63 |
| 55 this.revealView(); | 64 WebInspector.viewManager.revealViewWithWidget(this); |
| 56 | 65 |
| 57 var inputElementContainer = createElementWithClass("p", "breakpoint-cond
ition"); | 66 var inputElementContainer = createElementWithClass("p", "breakpoint-cond
ition"); |
| 58 inputElementContainer.textContent = WebInspector.UIString("Break when UR
L contains:"); | 67 inputElementContainer.textContent = WebInspector.UIString("Break when UR
L contains:"); |
| 59 | 68 |
| 60 var inputElement = inputElementContainer.createChild("span", "editing"); | 69 var inputElement = inputElementContainer.createChild("span", "editing"); |
| 61 inputElement.id = "breakpoint-condition-input"; | 70 inputElement.id = "breakpoint-condition-input"; |
| 62 this.addListElement(inputElementContainer, /** @type {?Element} */ (this
.listElement.firstChild)); | 71 this.addListElement(inputElementContainer, /** @type {?Element} */ (this
.listElement.firstChild)); |
| 63 | 72 |
| 64 /** | 73 /** |
| 65 * @param {boolean} accept | 74 * @param {boolean} accept |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 this._removeBreakpoint(url); | 214 this._removeBreakpoint(url); |
| 206 this._setBreakpoint(text, element._checkboxElement.checked); | 215 this._setBreakpoint(text, element._checkboxElement.checked); |
| 207 this._saveBreakpoints(); | 216 this._saveBreakpoints(); |
| 208 } else | 217 } else |
| 209 element.classList.remove("hidden"); | 218 element.classList.remove("hidden"); |
| 210 } | 219 } |
| 211 | 220 |
| 212 WebInspector.InplaceEditor.startEditing(inputElement, new WebInspector.I
nplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, fal
se))); | 221 WebInspector.InplaceEditor.startEditing(inputElement, new WebInspector.I
nplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, fal
se))); |
| 213 }, | 222 }, |
| 214 | 223 |
| 215 highlightBreakpoint: function(url) | 224 /** |
| 225 * @override |
| 226 * @param {?WebInspector.DebuggerPausedDetails} details |
| 227 */ |
| 228 highlightDetails: function(details) |
| 216 { | 229 { |
| 230 if (!details || details.reason !== WebInspector.DebuggerModel.BreakReaso
n.XHR) { |
| 231 if (this._highlightedElement) { |
| 232 this._highlightedElement.classList.remove("breakpoint-hit"); |
| 233 delete this._highlightedElement; |
| 234 } |
| 235 return; |
| 236 } |
| 237 var url = details.auxData["breakpointURL"]; |
| 217 var element = this._breakpointElements.get(url); | 238 var element = this._breakpointElements.get(url); |
| 218 if (!element) | 239 if (!element) |
| 219 return; | 240 return; |
| 220 this.revealView(); | 241 WebInspector.viewManager.revealViewWithWidget(this); |
| 221 element.classList.add("breakpoint-hit"); | 242 element.classList.add("breakpoint-hit"); |
| 222 this._highlightedElement = element; | 243 this._highlightedElement = element; |
| 223 }, | 244 }, |
| 224 | 245 |
| 225 clearBreakpointHighlight: function() | |
| 226 { | |
| 227 if (this._highlightedElement) { | |
| 228 this._highlightedElement.classList.remove("breakpoint-hit"); | |
| 229 delete this._highlightedElement; | |
| 230 } | |
| 231 }, | |
| 232 | |
| 233 _saveBreakpoints: function() | 246 _saveBreakpoints: function() |
| 234 { | 247 { |
| 235 var breakpoints = []; | 248 var breakpoints = []; |
| 236 for (var url of this._breakpointElements.keys()) | 249 for (var url of this._breakpointElements.keys()) |
| 237 breakpoints.push({ url: url, enabled: this._breakpointElements.get(u
rl)._checkboxElement.checked }); | 250 breakpoints.push({ url: url, enabled: this._breakpointElements.get(u
rl)._checkboxElement.checked }); |
| 238 this._xhrBreakpointsSetting.set(breakpoints); | 251 this._xhrBreakpointsSetting.set(breakpoints); |
| 239 }, | 252 }, |
| 240 | 253 |
| 241 /** | 254 /** |
| 242 * @param {!WebInspector.Target} target | 255 * @param {!WebInspector.Target} target |
| 243 */ | 256 */ |
| 244 _restoreBreakpoints: function(target) | 257 _restoreBreakpoints: function(target) |
| 245 { | 258 { |
| 246 var breakpoints = this._xhrBreakpointsSetting.get(); | 259 var breakpoints = this._xhrBreakpointsSetting.get(); |
| 247 for (var i = 0; i < breakpoints.length; ++i) { | 260 for (var i = 0; i < breakpoints.length; ++i) { |
| 248 var breakpoint = breakpoints[i]; | 261 var breakpoint = breakpoints[i]; |
| 249 if (breakpoint && typeof breakpoint.url === "string") | 262 if (breakpoint && typeof breakpoint.url === "string") |
| 250 this._setBreakpoint(breakpoint.url, breakpoint.enabled, target); | 263 this._setBreakpoint(breakpoint.url, breakpoint.enabled, target); |
| 251 } | 264 } |
| 252 }, | 265 }, |
| 253 | 266 |
| 254 __proto__: WebInspector.BreakpointsSidebarPaneBase.prototype | 267 __proto__: WebInspector.BreakpointsSidebarPaneBase.prototype |
| 255 } | 268 } |
| OLD | NEW |