Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 this._breakpointTypeLabels[this._breakpointTypes.AttributeModified] = WebIns pector.UIString("Attribute Modified"); | 50 this._breakpointTypeLabels[this._breakpointTypes.AttributeModified] = WebIns pector.UIString("Attribute Modified"); |
| 51 this._breakpointTypeLabels[this._breakpointTypes.NodeRemoved] = WebInspector .UIString("Node Removed"); | 51 this._breakpointTypeLabels[this._breakpointTypes.NodeRemoved] = WebInspector .UIString("Node Removed"); |
| 52 | 52 |
| 53 this._contextMenuLabels = {}; | 53 this._contextMenuLabels = {}; |
| 54 this._contextMenuLabels[this._breakpointTypes.SubtreeModified] = WebInspecto r.UIString.capitalize("Subtree ^modifications"); | 54 this._contextMenuLabels[this._breakpointTypes.SubtreeModified] = WebInspecto r.UIString.capitalize("Subtree ^modifications"); |
| 55 this._contextMenuLabels[this._breakpointTypes.AttributeModified] = WebInspec tor.UIString.capitalize("Attributes ^modifications"); | 55 this._contextMenuLabels[this._breakpointTypes.AttributeModified] = WebInspec tor.UIString.capitalize("Attributes ^modifications"); |
| 56 this._contextMenuLabels[this._breakpointTypes.NodeRemoved] = WebInspector.UI String.capitalize("Node ^removal"); | 56 this._contextMenuLabels[this._breakpointTypes.NodeRemoved] = WebInspector.UI String.capitalize("Node ^removal"); |
| 57 | 57 |
| 58 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.InspectedURLChanged, this._inspectedURLChanged, this); | 58 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.InspectedURLChanged, this._inspectedURLChanged, this); |
| 59 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 59 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
| 60 } | 60 }; |
|
lushnikov
2016/07/30 01:24:42
nit: we don't put semicolons after function declar
chenwilliam
2016/08/06 00:28:21
Done.
| |
| 61 | |
| 62 WebInspector.DOMBreakpointsSidebarPane.Marker = "breakpoint-marker"; | |
| 63 | 61 |
| 64 WebInspector.DOMBreakpointsSidebarPane.prototype = { | 62 WebInspector.DOMBreakpointsSidebarPane.prototype = { |
| 65 _inspectedURLChanged: function(event) | 63 _inspectedURLChanged: function(event) |
| 66 { | 64 { |
| 67 var target = /** @type {!WebInspector.Target} */ (event.data); | 65 var target = /** @type {!WebInspector.Target} */ (event.data); |
| 68 if (target !== WebInspector.targetManager.mainTarget()) | 66 if (target !== WebInspector.targetManager.mainTarget()) |
| 69 return; | 67 return; |
| 70 this._breakpointElements = {}; | 68 this._breakpointElements = {}; |
| 71 this.reset(); | 69 this.reset(); |
| 72 this._inspectedURL = target.inspectedURL().removeURLFragment(); | 70 this._inspectedURL = target.inspectedURL().removeURLFragment(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 } | 196 } |
| 199 }, | 197 }, |
| 200 | 198 |
| 201 /** | 199 /** |
| 202 * @param {!WebInspector.DOMNode} node | 200 * @param {!WebInspector.DOMNode} node |
| 203 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | 201 * @param {!DOMDebuggerAgent.DOMBreakpointType} type |
| 204 * @param {boolean} enabled | 202 * @param {boolean} enabled |
| 205 */ | 203 */ |
| 206 _setBreakpoint: function(node, type, enabled) | 204 _setBreakpoint: function(node, type, enabled) |
| 207 { | 205 { |
| 208 var breakpointId = this._createBreakpointId(node.id, type); | 206 var breakpointId = WebInspector.DOMBreakpointsModel.createBreakpointId(n ode.id, type); |
|
lushnikov
2016/07/30 01:24:42
breakpoint id serves only for the needs of DOMBrea
chenwilliam
2016/08/06 00:28:21
I've changed it so the use of createBreakpointId i
| |
| 209 var breakpointElement = this._breakpointElements[breakpointId]; | 207 var breakpointElement = this._breakpointElements[breakpointId]; |
| 210 if (!breakpointElement) { | 208 if (!breakpointElement) { |
| 211 breakpointElement = this._createBreakpointElement(node, type, enable d); | 209 breakpointElement = this._createBreakpointElement(node, type, enable d); |
| 212 this._breakpointElements[breakpointId] = breakpointElement; | 210 this._breakpointElements[breakpointId] = breakpointElement; |
| 213 } else { | 211 } else { |
| 214 breakpointElement._checkboxElement.checked = enabled; | 212 breakpointElement._checkboxElement.checked = enabled; |
| 215 } | 213 } |
| 214 var domBreakpointsModel = WebInspector.DOMBreakpointsModel.fromNode(node ); | |
| 216 if (enabled) | 215 if (enabled) |
| 217 node.target().domdebuggerAgent().setDOMBreakpoint(node.id, type); | 216 domBreakpointsModel.setDOMBreakpoint(node.id, type); |
| 218 node.setMarker(WebInspector.DOMBreakpointsSidebarPane.Marker, true); | 217 domBreakpointsModel.setMarker(node, true); |
| 219 }, | 218 }, |
| 220 | 219 |
| 221 /** | 220 /** |
| 222 * @param {!WebInspector.DOMNode} node | 221 * @param {!WebInspector.DOMNode} node |
| 223 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | 222 * @param {!DOMDebuggerAgent.DOMBreakpointType} type |
| 224 * @param {boolean} enabled | 223 * @param {boolean} enabled |
| 225 */ | 224 */ |
| 226 _createBreakpointElement: function(node, type, enabled) | 225 _createBreakpointElement: function(node, type, enabled) |
| 227 { | 226 { |
| 228 var element = createElement("li"); | 227 var element = createElement("li"); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 } | 264 } |
| 266 this._saveBreakpoints(); | 265 this._saveBreakpoints(); |
| 267 }, | 266 }, |
| 268 | 267 |
| 269 /** | 268 /** |
| 270 * @param {!WebInspector.DOMNode} node | 269 * @param {!WebInspector.DOMNode} node |
| 271 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | 270 * @param {!DOMDebuggerAgent.DOMBreakpointType} type |
| 272 */ | 271 */ |
| 273 _removeBreakpoint: function(node, type) | 272 _removeBreakpoint: function(node, type) |
| 274 { | 273 { |
| 275 var breakpointId = this._createBreakpointId(node.id, type); | 274 var breakpointId = WebInspector.DOMBreakpointsModel.createBreakpointId(n ode.id, type); |
| 276 var element = this._breakpointElements[breakpointId]; | 275 var element = this._breakpointElements[breakpointId]; |
| 277 if (!element) | 276 if (!element) |
| 278 return; | 277 return; |
| 279 | 278 |
| 280 this.removeListElement(element); | 279 this.removeListElement(element); |
| 281 delete this._breakpointElements[breakpointId]; | 280 delete this._breakpointElements[breakpointId]; |
| 281 var domBreakpointsModel = WebInspector.DOMBreakpointsModel.fromNode(node ); | |
| 282 if (element._checkboxElement.checked) | 282 if (element._checkboxElement.checked) |
| 283 node.target().domdebuggerAgent().removeDOMBreakpoint(node.id, type); | 283 domBreakpointsModel.removeDOMBreakpoint(node.id, type); |
| 284 node.setMarker(WebInspector.DOMBreakpointsSidebarPane.Marker, this.hasBr eakpoints(node) ? true : null); | 284 domBreakpointsModel.setMarker(node, this.hasBreakpoints(node) ? true : n ull); |
| 285 }, | 285 }, |
| 286 | 286 |
| 287 /** | 287 /** |
| 288 * @param {!WebInspector.DOMNode} node | 288 * @param {!WebInspector.DOMNode} node |
| 289 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | 289 * @param {!DOMDebuggerAgent.DOMBreakpointType} type |
| 290 * @param {!Event} event | 290 * @param {!Event} event |
| 291 */ | 291 */ |
| 292 _contextMenu: function(node, type, event) | 292 _contextMenu: function(node, type, event) |
| 293 { | 293 { |
| 294 var contextMenu = new WebInspector.ContextMenu(event); | 294 var contextMenu = new WebInspector.ContextMenu(event); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 306 contextMenu.show(); | 306 contextMenu.show(); |
| 307 }, | 307 }, |
| 308 | 308 |
| 309 /** | 309 /** |
| 310 * @param {!WebInspector.DOMNode} node | 310 * @param {!WebInspector.DOMNode} node |
| 311 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | 311 * @param {!DOMDebuggerAgent.DOMBreakpointType} type |
| 312 * @param {!Event} event | 312 * @param {!Event} event |
| 313 */ | 313 */ |
| 314 _checkboxClicked: function(node, type, event) | 314 _checkboxClicked: function(node, type, event) |
| 315 { | 315 { |
| 316 var domBreakpointsModel = WebInspector.DOMBreakpointsModel.fromNode(node ); | |
| 316 if (event.target.checked) | 317 if (event.target.checked) |
| 317 node.target().domdebuggerAgent().setDOMBreakpoint(node.id, type); | 318 domBreakpointsModel.setDOMBreakpoint(node.id, type); |
| 318 else | 319 else |
| 319 node.target().domdebuggerAgent().removeDOMBreakpoint(node.id, type); | 320 domBreakpointsModel.removeDOMBreakpoint(node.id, type); |
| 320 this._saveBreakpoints(); | 321 this._saveBreakpoints(); |
|
lushnikov
2016/07/30 01:24:42
i believe this logic should go to your model as we
chenwilliam
2016/08/06 00:28:21
Done.
| |
| 321 }, | 322 }, |
| 322 | 323 |
| 323 highlightBreakpoint: function(auxData) | 324 highlightBreakpoint: function(auxData) |
| 324 { | 325 { |
| 325 var breakpointId = this._createBreakpointId(auxData.nodeId, auxData.type ); | 326 var breakpointId = WebInspector.DOMBreakpointsModel.createBreakpointId(a uxData.nodeId, auxData.type); |
| 326 var element = this._breakpointElements[breakpointId]; | 327 var element = this._breakpointElements[breakpointId]; |
| 327 if (!element) | 328 if (!element) |
| 328 return; | 329 return; |
| 329 this.revealWidget(); | 330 this.revealWidget(); |
| 330 element.classList.add("breakpoint-hit"); | 331 element.classList.add("breakpoint-hit"); |
| 331 this._highlightedElement = element; | 332 this._highlightedElement = element; |
| 332 }, | 333 }, |
| 333 | 334 |
| 334 clearBreakpointHighlight: function() | 335 clearBreakpointHighlight: function() |
| 335 { | 336 { |
| 336 if (this._highlightedElement) { | 337 if (this._highlightedElement) { |
| 337 this._highlightedElement.classList.remove("breakpoint-hit"); | 338 this._highlightedElement.classList.remove("breakpoint-hit"); |
| 338 delete this._highlightedElement; | 339 delete this._highlightedElement; |
| 339 } | 340 } |
| 340 }, | 341 }, |
| 341 | 342 |
| 342 /** | |
| 343 * @param {number} nodeId | |
| 344 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | |
| 345 */ | |
| 346 _createBreakpointId: function(nodeId, type) | |
| 347 { | |
| 348 return nodeId + ":" + type; | |
| 349 }, | |
| 350 | |
| 351 _saveBreakpoints: function() | 343 _saveBreakpoints: function() |
| 352 { | 344 { |
| 353 var breakpoints = []; | 345 var breakpoints = []; |
| 354 var storedBreakpoints = this._domBreakpointsSetting.get(); | 346 var storedBreakpoints = this._domBreakpointsSetting.get(); |
| 355 for (var i = 0; i < storedBreakpoints.length; ++i) { | 347 for (var i = 0; i < storedBreakpoints.length; ++i) { |
| 356 var breakpoint = storedBreakpoints[i]; | 348 var breakpoint = storedBreakpoints[i]; |
| 357 if (breakpoint.url !== this._inspectedURL) | 349 if (breakpoint.url !== this._inspectedURL) |
| 358 breakpoints.push(breakpoint); | 350 breakpoints.push(breakpoint); |
| 359 } | 351 } |
| 360 for (var id in this._breakpointElements) { | 352 for (var id in this._breakpointElements) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 445 this._wrappedPane.show(this.element); | 437 this._wrappedPane.show(this.element); |
| 446 }, | 438 }, |
| 447 | 439 |
| 448 __proto__: WebInspector.View.prototype | 440 __proto__: WebInspector.View.prototype |
| 449 } | 441 } |
| 450 | 442 |
| 451 /** | 443 /** |
| 452 * @type {!WebInspector.DOMBreakpointsSidebarPane} | 444 * @type {!WebInspector.DOMBreakpointsSidebarPane} |
| 453 */ | 445 */ |
| 454 WebInspector.domBreakpointsSidebarPane; | 446 WebInspector.domBreakpointsSidebarPane; |
| OLD | NEW |