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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 this._breakpointTypes = { | 45 this._breakpointTypes = { |
| 46 SubtreeModified: "subtree-modified", | 46 SubtreeModified: "subtree-modified", |
| 47 AttributeModified: "attribute-modified", | 47 AttributeModified: "attribute-modified", |
| 48 NodeRemoved: "node-removed" | 48 NodeRemoved: "node-removed" |
| 49 }; | 49 }; |
| 50 this._breakpointTypeLabels = {}; | 50 this._breakpointTypeLabels = {}; |
| 51 this._breakpointTypeLabels[this._breakpointTypes.SubtreeModified] = WebInspe ctor.UIString("Subtree Modified"); | 51 this._breakpointTypeLabels[this._breakpointTypes.SubtreeModified] = WebInspe ctor.UIString("Subtree Modified"); |
| 52 this._breakpointTypeLabels[this._breakpointTypes.AttributeModified] = WebIns pector.UIString("Attribute Modified"); | 52 this._breakpointTypeLabels[this._breakpointTypes.AttributeModified] = WebIns pector.UIString("Attribute Modified"); |
| 53 this._breakpointTypeLabels[this._breakpointTypes.NodeRemoved] = WebInspector .UIString("Node Removed"); | 53 this._breakpointTypeLabels[this._breakpointTypes.NodeRemoved] = WebInspector .UIString("Node Removed"); |
| 54 | 54 |
| 55 this._contextMenuLabels = {}; | 55 this._breakpointTypeNouns = {}; |
| 56 this._contextMenuLabels[this._breakpointTypes.SubtreeModified] = WebInspecto r.UIString.capitalize("Subtree ^modifications"); | 56 this._breakpointTypeNouns[this._breakpointTypes.SubtreeModified] = WebInspec tor.UIString.capitalize("Subtree ^modifications"); |
| 57 this._contextMenuLabels[this._breakpointTypes.AttributeModified] = WebInspec tor.UIString.capitalize("Attributes ^modifications"); | 57 this._breakpointTypeNouns[this._breakpointTypes.AttributeModified] = WebInsp ector.UIString.capitalize("Attribute ^modifications"); |
| 58 this._contextMenuLabels[this._breakpointTypes.NodeRemoved] = WebInspector.UI String.capitalize("Node ^removal"); | 58 this._breakpointTypeNouns[this._breakpointTypes.NodeRemoved] = WebInspector. UIString.capitalize("Node ^removal"); |
| 59 | 59 |
| 60 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 60 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
| 61 this._update(); | 61 this._update(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 WebInspector.DOMBreakpointsSidebarPane.Marker = "breakpoint-marker"; | 64 WebInspector.DOMBreakpointsSidebarPane.Marker = "breakpoint-marker"; |
| 65 | 65 |
| 66 WebInspector.DOMBreakpointsSidebarPane.prototype = { | 66 WebInspector.DOMBreakpointsSidebarPane.prototype = { |
| 67 /** | 67 /** |
| 68 * @param {!WebInspector.DOMNode} node | 68 * @param {!WebInspector.DOMNode} node |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 85 if (!nodeBreakpoints.has(type)) | 85 if (!nodeBreakpoints.has(type)) |
| 86 this._setBreakpoint(node, type, true); | 86 this._setBreakpoint(node, type, true); |
| 87 else | 87 else |
| 88 this._removeBreakpoint(node, type); | 88 this._removeBreakpoint(node, type); |
| 89 this._saveBreakpoints(); | 89 this._saveBreakpoints(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 var breakpointsMenu = createSubMenu ? contextMenu.appendSubMenuItem(WebI nspector.UIString("Break on...")) : contextMenu; | 92 var breakpointsMenu = createSubMenu ? contextMenu.appendSubMenuItem(WebI nspector.UIString("Break on...")) : contextMenu; |
| 93 for (var key in this._breakpointTypes) { | 93 for (var key in this._breakpointTypes) { |
| 94 var type = this._breakpointTypes[key]; | 94 var type = this._breakpointTypes[key]; |
| 95 var label = this._contextMenuLabels[type]; | 95 var label = this._breakpointTypeNouns[type]; |
| 96 breakpointsMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this , type), nodeBreakpoints.has(type)); | 96 breakpointsMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this , type), nodeBreakpoints.has(type)); |
| 97 } | 97 } |
| 98 }, | 98 }, |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * @param {!WebInspector.DOMNode} node | 101 * @param {!WebInspector.DOMNode} node |
| 102 * @return {!Set<!DOMDebuggerAgent.DOMBreakpointType>} | 102 * @return {!Set<!DOMDebuggerAgent.DOMBreakpointType>} |
| 103 */ | 103 */ |
| 104 _nodeBreakpoints: function(node) | 104 _nodeBreakpoints: function(node) |
| 105 { | 105 { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 122 if (element._node === node && element._checkboxElement.checked) | 122 if (element._node === node && element._checkboxElement.checked) |
| 123 return true; | 123 return true; |
| 124 } | 124 } |
| 125 return false; | 125 return false; |
| 126 }, | 126 }, |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * @param {!WebInspector.DebuggerPausedDetails} details | 129 * @param {!WebInspector.DebuggerPausedDetails} details |
| 130 * @return {!Element} | 130 * @return {!Element} |
| 131 */ | 131 */ |
| 132 createBreakpointHitStatusMessage: function(details) | 132 createBreakpointHitMainMessage: function(details) |
| 133 { | 133 { |
| 134 var auxData = /** @type {!Object} */ (details.auxData); | 134 var auxData = /** @type {!Object} */ (details.auxData); |
| 135 var message = "Paused on a \"%s\" breakpoint."; | 135 var message = String.sprintf("Paused on %s", this._breakpointTypeNouns[a uxData["type"]]); |
| 136 var substitutions = []; | 136 var element = createElement("div"); |
| 137 substitutions.push(this._breakpointTypeLabels[auxData["type"]]); | 137 element.textContent = message; |
| 138 return element; | |
| 139 }, | |
| 138 | 140 |
| 141 /** | |
| 142 * @param {!WebInspector.DebuggerPausedDetails} details | |
| 143 * @return {!Element} | |
| 144 */ | |
| 145 createBreakpointHitSubMessage: function(details) | |
|
lushnikov
2016/10/12 21:26:58
you don't need two functions - let's keep them as
luoe
2016/10/13 00:36:58
Done.
| |
| 146 { | |
| 147 var element = createElement("div"); | |
| 139 var domModel = WebInspector.DOMModel.fromTarget(details.target()); | 148 var domModel = WebInspector.DOMModel.fromTarget(details.target()); |
| 140 if (!domModel) | 149 if (!domModel) |
| 141 return WebInspector.formatLocalized(message, substitutions); | 150 return element; |
| 142 | 151 |
| 152 var auxData = /** @type {!Object} */ (details.auxData); | |
| 143 var node = domModel.nodeForId(auxData["nodeId"]); | 153 var node = domModel.nodeForId(auxData["nodeId"]); |
| 144 var linkifiedNode = WebInspector.DOMPresentationUtils.linkifyNodeReferen ce(node); | 154 var linkifiedNode = WebInspector.DOMPresentationUtils.linkifyNodeReferen ce(node); |
| 145 substitutions.push(linkifiedNode); | 155 element.appendChild(linkifiedNode); |
| 146 | 156 |
| 147 var targetNode = auxData["targetNodeId"] ? domModel.nodeForId(auxData["t argetNodeId"]) : null; | 157 var targetNode = auxData["targetNodeId"] ? domModel.nodeForId(auxData["t argetNodeId"]) : null; |
| 148 var targetNodeLink = targetNode ? WebInspector.DOMPresentationUtils.link ifyNodeReference(targetNode) : ""; | 158 var targetNodeLink = targetNode ? WebInspector.DOMPresentationUtils.link ifyNodeReference(targetNode) : ""; |
| 149 | 159 var message; |
| 150 if (auxData.type === this._breakpointTypes.SubtreeModified) { | 160 if (auxData.type === this._breakpointTypes.SubtreeModified) { |
| 151 if (auxData["insertion"]) { | 161 if (auxData["insertion"]) |
| 152 if (targetNode !== node) { | 162 message = targetNode === node ? "Child %s added" : "Descendant % s added"; |
| 153 message = "Paused on a \"%s\" breakpoint set on %s, because a new child was added to its descendant %s."; | 163 else |
| 154 substitutions.push(targetNodeLink); | 164 message = "Descendant %s removed"; |
| 155 } else | 165 element.appendChild(createElement("br")); |
| 156 message = "Paused on a \"%s\" breakpoint set on %s, because a new child was added to that node."; | 166 element.appendChild(WebInspector.formatLocalized(message, [targetNod eLink])); |
| 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 } | 167 } |
| 164 | 168 return element; |
| 165 return WebInspector.formatLocalized(message, substitutions); | |
| 166 }, | 169 }, |
| 167 | 170 |
| 168 _nodeRemoved: function(event) | 171 _nodeRemoved: function(event) |
| 169 { | 172 { |
| 170 var node = event.data.node; | 173 var node = event.data.node; |
| 171 this._removeBreakpointsForNode(event.data.node); | 174 this._removeBreakpointsForNode(event.data.node); |
| 172 var children = node.children(); | 175 var children = node.children(); |
| 173 if (!children) | 176 if (!children) |
| 174 return; | 177 return; |
| 175 for (var i = 0; i < children.length; ++i) | 178 for (var i = 0; i < children.length; ++i) |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 pane.show(this.element); | 428 pane.show(this.element); |
| 426 }, | 429 }, |
| 427 | 430 |
| 428 __proto__: WebInspector.VBox.prototype | 431 __proto__: WebInspector.VBox.prototype |
| 429 } | 432 } |
| 430 | 433 |
| 431 /** | 434 /** |
| 432 * @type {!WebInspector.DOMBreakpointsSidebarPane} | 435 * @type {!WebInspector.DOMBreakpointsSidebarPane} |
| 433 */ | 436 */ |
| 434 WebInspector.domBreakpointsSidebarPane; | 437 WebInspector.domBreakpointsSidebarPane; |
| OLD | NEW |