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 24 matching lines...) Expand all Loading... |
35 */ | 35 */ |
36 WebInspector.DOMBreakpointsSidebarPane = function() | 36 WebInspector.DOMBreakpointsSidebarPane = function() |
37 { | 37 { |
38 WebInspector.BreakpointsSidebarPaneBase.call(this); | 38 WebInspector.BreakpointsSidebarPaneBase.call(this); |
39 this._domBreakpointsSetting = WebInspector.settings.createLocalSetting("domB
reakpoints", []); | 39 this._domBreakpointsSetting = WebInspector.settings.createLocalSetting("domB
reakpoints", []); |
40 this.listElement.classList.add("dom-breakpoints-list"); | 40 this.listElement.classList.add("dom-breakpoints-list"); |
41 | 41 |
42 /** @type {!Map<string, !Element>} */ | 42 /** @type {!Map<string, !Element>} */ |
43 this._breakpointElements = new Map(); | 43 this._breakpointElements = new Map(); |
44 | 44 |
45 this._breakpointTypes = { | |
46 SubtreeModified: "subtree-modified", | |
47 AttributeModified: "attribute-modified", | |
48 NodeRemoved: "node-removed" | |
49 }; | |
50 this._breakpointTypeLabels = {}; | |
51 this._breakpointTypeLabels[this._breakpointTypes.SubtreeModified] = WebInspe
ctor.UIString("Subtree Modified"); | |
52 this._breakpointTypeLabels[this._breakpointTypes.AttributeModified] = WebIns
pector.UIString("Attribute Modified"); | |
53 this._breakpointTypeLabels[this._breakpointTypes.NodeRemoved] = WebInspector
.UIString("Node Removed"); | |
54 | |
55 this._contextMenuLabels = {}; | |
56 this._contextMenuLabels[this._breakpointTypes.SubtreeModified] = WebInspecto
r.UIString.capitalize("Subtree ^modifications"); | |
57 this._contextMenuLabels[this._breakpointTypes.AttributeModified] = WebInspec
tor.UIString.capitalize("Attributes ^modifications"); | |
58 this._contextMenuLabels[this._breakpointTypes.NodeRemoved] = WebInspector.UI
String.capitalize("Node ^removal"); | |
59 | |
60 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec
tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 45 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec
tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
61 this._update(); | 46 this._update(); |
62 } | 47 } |
63 | 48 |
| 49 WebInspector.DOMBreakpointsSidebarPane.BreakpointTypes = { |
| 50 SubtreeModified: "subtree-modified", |
| 51 AttributeModified: "attribute-modified", |
| 52 NodeRemoved: "node-removed" |
| 53 }; |
| 54 |
| 55 WebInspector.DOMBreakpointsSidebarPane.BreakpointTypeLabels = { |
| 56 "subtree-modified": WebInspector.UIString("Subtree Modified"), |
| 57 "attribute-modified": WebInspector.UIString("Attribute Modified"), |
| 58 "node-removed": WebInspector.UIString("Node Removed") |
| 59 }; |
| 60 |
| 61 WebInspector.DOMBreakpointsSidebarPane.BreakpointTypeNouns = { |
| 62 "subtree-modified": WebInspector.UIString.capitalize("Subtree ^modifications
"), |
| 63 "attribute-modified": WebInspector.UIString.capitalize("Attribute ^modificat
ions"), |
| 64 "node-removed": WebInspector.UIString.capitalize("Node ^removal") |
| 65 } |
| 66 |
64 WebInspector.DOMBreakpointsSidebarPane.Marker = "breakpoint-marker"; | 67 WebInspector.DOMBreakpointsSidebarPane.Marker = "breakpoint-marker"; |
65 | 68 |
66 WebInspector.DOMBreakpointsSidebarPane.prototype = { | 69 WebInspector.DOMBreakpointsSidebarPane.prototype = { |
67 /** | 70 /** |
68 * @param {!WebInspector.DOMNode} node | 71 * @param {!WebInspector.DOMNode} node |
69 * @param {!WebInspector.ContextMenu} contextMenu | 72 * @param {!WebInspector.ContextMenu} contextMenu |
70 * @param {boolean} createSubMenu | 73 * @param {boolean} createSubMenu |
71 */ | 74 */ |
72 populateNodeContextMenu: function(node, contextMenu, createSubMenu) | 75 populateNodeContextMenu: function(node, contextMenu, createSubMenu) |
73 { | 76 { |
74 if (node.pseudoType()) | 77 if (node.pseudoType()) |
75 return; | 78 return; |
76 | 79 |
77 var nodeBreakpoints = this._nodeBreakpoints(node); | 80 var nodeBreakpoints = this._nodeBreakpoints(node); |
78 | 81 |
79 /** | 82 /** |
80 * @param {!DOMDebuggerAgent.DOMBreakpointType} type | 83 * @param {!DOMDebuggerAgent.DOMBreakpointType} type |
81 * @this {WebInspector.DOMBreakpointsSidebarPane} | 84 * @this {WebInspector.DOMBreakpointsSidebarPane} |
82 */ | 85 */ |
83 function toggleBreakpoint(type) | 86 function toggleBreakpoint(type) |
84 { | 87 { |
85 if (!nodeBreakpoints.has(type)) | 88 if (!nodeBreakpoints.has(type)) |
86 this._setBreakpoint(node, type, true); | 89 this._setBreakpoint(node, type, true); |
87 else | 90 else |
88 this._removeBreakpoint(node, type); | 91 this._removeBreakpoint(node, type); |
89 this._saveBreakpoints(); | 92 this._saveBreakpoints(); |
90 } | 93 } |
91 | 94 |
92 var breakpointsMenu = createSubMenu ? contextMenu.appendSubMenuItem(WebI
nspector.UIString("Break on...")) : contextMenu; | 95 var breakpointsMenu = createSubMenu ? contextMenu.appendSubMenuItem(WebI
nspector.UIString("Break on...")) : contextMenu; |
93 for (var key in this._breakpointTypes) { | 96 for (var key in WebInspector.DOMBreakpointsSidebarPane.BreakpointTypes)
{ |
94 var type = this._breakpointTypes[key]; | 97 var type = WebInspector.DOMBreakpointsSidebarPane.BreakpointTypes[ke
y]; |
95 var label = this._contextMenuLabels[type]; | 98 var label = WebInspector.DOMBreakpointsSidebarPane.BreakpointTypeNou
ns[type]; |
96 breakpointsMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this
, type), nodeBreakpoints.has(type)); | 99 breakpointsMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this
, type), nodeBreakpoints.has(type)); |
97 } | 100 } |
98 }, | 101 }, |
99 | 102 |
100 /** | 103 /** |
101 * @param {!WebInspector.DOMNode} node | 104 * @param {!WebInspector.DOMNode} node |
102 * @return {!Set<!DOMDebuggerAgent.DOMBreakpointType>} | 105 * @return {!Set<!DOMDebuggerAgent.DOMBreakpointType>} |
103 */ | 106 */ |
104 _nodeBreakpoints: function(node) | 107 _nodeBreakpoints: function(node) |
105 { | 108 { |
(...skipping 12 matching lines...) Expand all Loading... |
118 */ | 121 */ |
119 hasBreakpoints: function(node) | 122 hasBreakpoints: function(node) |
120 { | 123 { |
121 for (var element of this._breakpointElements.values()) { | 124 for (var element of this._breakpointElements.values()) { |
122 if (element._node === node && element._checkboxElement.checked) | 125 if (element._node === node && element._checkboxElement.checked) |
123 return true; | 126 return true; |
124 } | 127 } |
125 return false; | 128 return false; |
126 }, | 129 }, |
127 | 130 |
128 /** | |
129 * @param {!WebInspector.DebuggerPausedDetails} details | |
130 * @return {!Element} | |
131 */ | |
132 createBreakpointHitStatusMessage: function(details) | |
133 { | |
134 var auxData = /** @type {!Object} */ (details.auxData); | |
135 var message = "Paused on a \"%s\" breakpoint."; | |
136 var substitutions = []; | |
137 substitutions.push(this._breakpointTypeLabels[auxData["type"]]); | |
138 | |
139 var domModel = WebInspector.DOMModel.fromTarget(details.target()); | |
140 if (!domModel) | |
141 return WebInspector.formatLocalized(message, substitutions); | |
142 | |
143 var node = domModel.nodeForId(auxData["nodeId"]); | |
144 var linkifiedNode = WebInspector.DOMPresentationUtils.linkifyNodeReferen
ce(node); | |
145 substitutions.push(linkifiedNode); | |
146 | |
147 var targetNode = auxData["targetNodeId"] ? domModel.nodeForId(auxData["t
argetNodeId"]) : null; | |
148 var targetNodeLink = targetNode ? WebInspector.DOMPresentationUtils.link
ifyNodeReference(targetNode) : ""; | |
149 | |
150 if (auxData.type === this._breakpointTypes.SubtreeModified) { | |
151 if (auxData["insertion"]) { | |
152 if (targetNode !== node) { | |
153 message = "Paused on a \"%s\" breakpoint set on %s, because
a new child was added to its descendant %s."; | |
154 substitutions.push(targetNodeLink); | |
155 } else | |
156 message = "Paused on a \"%s\" breakpoint set on %s, because
a new child was added to that node."; | |
157 } else { | |
158 message = "Paused on a \"%s\" breakpoint set on %s, because its
descendant %s was removed."; | |
159 substitutions.push(targetNodeLink); | |
160 } | |
161 } else { | |
162 message = "Paused on a \"%s\" breakpoint set on %s."; | |
163 } | |
164 | |
165 return WebInspector.formatLocalized(message, substitutions); | |
166 }, | |
167 | |
168 _nodeRemoved: function(event) | 131 _nodeRemoved: function(event) |
169 { | 132 { |
170 var node = event.data.node; | 133 var node = event.data.node; |
171 this._removeBreakpointsForNode(event.data.node); | 134 this._removeBreakpointsForNode(event.data.node); |
172 var children = node.children(); | 135 var children = node.children(); |
173 if (!children) | 136 if (!children) |
174 return; | 137 return; |
175 for (var i = 0; i < children.length; ++i) | 138 for (var i = 0; i < children.length; ++i) |
176 this._removeBreakpointsForNode(children[i]); | 139 this._removeBreakpointsForNode(children[i]); |
177 this._saveBreakpoints(); | 140 this._saveBreakpoints(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 191 |
229 var labelElement = createElementWithClass("div", "dom-breakpoint"); | 192 var labelElement = createElementWithClass("div", "dom-breakpoint"); |
230 element.appendChild(labelElement); | 193 element.appendChild(labelElement); |
231 | 194 |
232 var linkifiedNode = WebInspector.DOMPresentationUtils.linkifyNodeReferen
ce(node); | 195 var linkifiedNode = WebInspector.DOMPresentationUtils.linkifyNodeReferen
ce(node); |
233 linkifiedNode.classList.add("monospace"); | 196 linkifiedNode.classList.add("monospace"); |
234 linkifiedNode.style.display = "block"; | 197 linkifiedNode.style.display = "block"; |
235 labelElement.appendChild(linkifiedNode); | 198 labelElement.appendChild(linkifiedNode); |
236 | 199 |
237 var description = createElement("div"); | 200 var description = createElement("div"); |
238 description.textContent = this._breakpointTypeLabels[type]; | 201 description.textContent = WebInspector.DOMBreakpointsSidebarPane.Breakpo
intTypeLabels[type]; |
239 labelElement.appendChild(description); | 202 labelElement.appendChild(description); |
240 | 203 |
241 var currentElement = this.listElement.firstChild; | 204 var currentElement = this.listElement.firstChild; |
242 while (currentElement) { | 205 while (currentElement) { |
243 if (currentElement._type && currentElement._type < element._type) | 206 if (currentElement._type && currentElement._type < element._type) |
244 break; | 207 break; |
245 currentElement = currentElement.nextSibling; | 208 currentElement = currentElement.nextSibling; |
246 } | 209 } |
247 this.addListElement(element, currentElement); | 210 this.addListElement(element, currentElement); |
248 return element; | 211 return element; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 domModel.pushNodeByPathToFrontend(path, didPushNodeByPathToFront
end.bind(this, path)); | 363 domModel.pushNodeByPathToFrontend(path, didPushNodeByPathToFront
end.bind(this, path)); |
401 } | 364 } |
402 pathToBreakpoints.get(path).push(breakpoint); | 365 pathToBreakpoints.get(path).push(breakpoint); |
403 } | 366 } |
404 }, | 367 }, |
405 | 368 |
406 __proto__: WebInspector.BreakpointsSidebarPaneBase.prototype | 369 __proto__: WebInspector.BreakpointsSidebarPaneBase.prototype |
407 } | 370 } |
408 | 371 |
409 /** | 372 /** |
| 373 * @param {!WebInspector.DebuggerPausedDetails} details |
| 374 * @return {!Element} |
| 375 */ |
| 376 WebInspector.DOMBreakpointsSidebarPane.createBreakpointHitMessage = function(det
ails) |
| 377 { |
| 378 var messageWrapper = createElement("span"); |
| 379 var mainElement = messageWrapper.createChild("div", "status-main"); |
| 380 var auxData = /** @type {!Object} */ (details.auxData); |
| 381 mainElement.textContent = String.sprintf("Paused on %s", WebInspector.DOMBre
akpointsSidebarPane.BreakpointTypeNouns[auxData["type"]]); |
| 382 |
| 383 var domModel = WebInspector.DOMModel.fromTarget(details.target()); |
| 384 if (domModel) { |
| 385 var subElement = messageWrapper.createChild("div", "status-sub"); |
| 386 var node = domModel.nodeForId(auxData["nodeId"]); |
| 387 var linkifiedNode = WebInspector.DOMPresentationUtils.linkifyNodeReferen
ce(node); |
| 388 subElement.appendChild(linkifiedNode); |
| 389 |
| 390 var targetNode = auxData["targetNodeId"] ? domModel.nodeForId(auxData["t
argetNodeId"]) : null; |
| 391 var targetNodeLink = targetNode ? WebInspector.DOMPresentationUtils.link
ifyNodeReference(targetNode) : ""; |
| 392 var message; |
| 393 if (auxData.type === WebInspector.DOMBreakpointsSidebarPane.BreakpointTy
pes.SubtreeModified) { |
| 394 if (auxData["insertion"]) |
| 395 message = targetNode === node ? "Child %s added" : "Descendant %
s added"; |
| 396 else |
| 397 message = "Descendant %s removed"; |
| 398 subElement.appendChild(createElement("br")); |
| 399 subElement.appendChild(WebInspector.formatLocalized(message, [target
NodeLink])); |
| 400 } |
| 401 } |
| 402 return messageWrapper; |
| 403 } |
| 404 |
| 405 /** |
410 * @constructor | 406 * @constructor |
411 * @extends {WebInspector.VBox} | 407 * @extends {WebInspector.VBox} |
412 */ | 408 */ |
413 WebInspector.DOMBreakpointsSidebarPane.Proxy = function() | 409 WebInspector.DOMBreakpointsSidebarPane.Proxy = function() |
414 { | 410 { |
415 WebInspector.VBox.call(this); | 411 WebInspector.VBox.call(this); |
416 this.registerRequiredCSS("components/breakpointsList.css"); | 412 this.registerRequiredCSS("components/breakpointsList.css"); |
417 } | 413 } |
418 | 414 |
419 WebInspector.DOMBreakpointsSidebarPane.Proxy.prototype = { | 415 WebInspector.DOMBreakpointsSidebarPane.Proxy.prototype = { |
420 wasShown: function() | 416 wasShown: function() |
421 { | 417 { |
422 WebInspector.SimpleView.prototype.wasShown.call(this); | 418 WebInspector.SimpleView.prototype.wasShown.call(this); |
423 var pane = WebInspector.domBreakpointsSidebarPane; | 419 var pane = WebInspector.domBreakpointsSidebarPane; |
424 if (pane.element.parentNode !== this.element) | 420 if (pane.element.parentNode !== this.element) |
425 pane.show(this.element); | 421 pane.show(this.element); |
426 }, | 422 }, |
427 | 423 |
428 __proto__: WebInspector.VBox.prototype | 424 __proto__: WebInspector.VBox.prototype |
429 } | 425 } |
430 | 426 |
431 /** | 427 /** |
432 * @type {!WebInspector.DOMBreakpointsSidebarPane} | 428 * @type {!WebInspector.DOMBreakpointsSidebarPane} |
433 */ | 429 */ |
434 WebInspector.domBreakpointsSidebarPane; | 430 WebInspector.domBreakpointsSidebarPane; |
OLD | NEW |