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

Side by Side Diff: Source/devtools/front_end/components/DOMBreakpointsSidebarPane.js

Issue 1273313002: DevTools: introduce dom markers, decorate hidden, forced state and breakpoint elements using marker… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: for landing Created 5 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 /* 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
61 61
62 WebInspector.DOMBreakpointsSidebarPane.Marker = "breakpoint-marker";
63
62 WebInspector.DOMBreakpointsSidebarPane.prototype = { 64 WebInspector.DOMBreakpointsSidebarPane.prototype = {
63 _inspectedURLChanged: function(event) 65 _inspectedURLChanged: function(event)
64 { 66 {
65 this._breakpointElements = {}; 67 this._breakpointElements = {};
66 this.reset(); 68 this.reset();
67 var url = /** @type {string} */ (event.data); 69 var url = /** @type {string} */ (event.data);
68 this._inspectedURL = url.removeURLFragment(); 70 this._inspectedURL = url.removeURLFragment();
69 }, 71 },
70 72
71 /** 73 /**
72 * @param {!WebInspector.DOMNode} node 74 * @param {!WebInspector.DOMNode} node
73 * @param {!WebInspector.ContextMenu} contextMenu 75 * @param {!WebInspector.ContextMenu} contextMenu
74 * @param {boolean} createSubMenu 76 * @param {boolean} createSubMenu
75 */ 77 */
76 populateNodeContextMenu: function(node, contextMenu, createSubMenu) 78 populateNodeContextMenu: function(node, contextMenu, createSubMenu)
77 { 79 {
78 if (node.pseudoType()) 80 if (node.pseudoType())
79 return; 81 return;
80 82
81 var nodeBreakpoints = {}; 83 var nodeBreakpoints = this._nodeBreakpoints(node);
82 for (var id in this._breakpointElements) {
83 var element = this._breakpointElements[id];
84 if (element._node === node && element._checkboxElement.checked)
85 nodeBreakpoints[element._type] = true;
86 }
87 84
88 /** 85 /**
89 * @param {!DOMDebuggerAgent.DOMBreakpointType} type 86 * @param {!DOMDebuggerAgent.DOMBreakpointType} type
90 * @this {WebInspector.DOMBreakpointsSidebarPane} 87 * @this {WebInspector.DOMBreakpointsSidebarPane}
91 */ 88 */
92 function toggleBreakpoint(type) 89 function toggleBreakpoint(type)
93 { 90 {
94 if (!nodeBreakpoints[type]) 91 if (!nodeBreakpoints[type])
95 this._setBreakpoint(node, type, true); 92 this._setBreakpoint(node, type, true);
96 else 93 else
97 this._removeBreakpoint(node, type); 94 this._removeBreakpoint(node, type);
98 this._saveBreakpoints(); 95 this._saveBreakpoints();
99 } 96 }
100 97
101 var breakpointsMenu = createSubMenu ? contextMenu.appendSubMenuItem(WebI nspector.UIString("Break on...")) : contextMenu; 98 var breakpointsMenu = createSubMenu ? contextMenu.appendSubMenuItem(WebI nspector.UIString("Break on...")) : contextMenu;
102 for (var key in this._breakpointTypes) { 99 for (var key in this._breakpointTypes) {
103 var type = this._breakpointTypes[key]; 100 var type = this._breakpointTypes[key];
104 var label = this._contextMenuLabels[type]; 101 var label = this._contextMenuLabels[type];
105 breakpointsMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this , type), nodeBreakpoints[type]); 102 breakpointsMenu.appendCheckboxItem(label, toggleBreakpoint.bind(this , type), nodeBreakpoints[type]);
106 } 103 }
107 }, 104 },
108 105
109 /** 106 /**
107 * @param {!WebInspector.DOMNode} node
108 * @return {!Object<string, boolean>}
109 */
110 _nodeBreakpoints: function(node)
111 {
112 var nodeBreakpoints = {};
113 for (var id in this._breakpointElements) {
114 var element = this._breakpointElements[id];
115 if (element._node === node && element._checkboxElement.checked)
116 nodeBreakpoints[element._type] = true;
117 }
118 return nodeBreakpoints;
119 },
120
121 /**
122 * @param {!WebInspector.DOMNode} node
123 * @return {boolean}
124 */
125 hasBreakpoints: function(node)
126 {
127 for (var id in this._breakpointElements) {
128 var element = this._breakpointElements[id];
129 if (element._node === node && element._checkboxElement.checked)
130 return true;
131 }
132 return false;
133 },
134
135 /**
110 * @param {!WebInspector.DebuggerPausedDetails} details 136 * @param {!WebInspector.DebuggerPausedDetails} details
111 * @param {function(!Element)} callback 137 * @param {function(!Element)} callback
112 */ 138 */
113 createBreakpointHitStatusMessage: function(details, callback) 139 createBreakpointHitStatusMessage: function(details, callback)
114 { 140 {
115 var auxData = /** @type {!Object} */ (details.auxData); 141 var auxData = /** @type {!Object} */ (details.auxData);
116 var domModel = WebInspector.DOMModel.fromTarget(details.target()); 142 var domModel = WebInspector.DOMModel.fromTarget(details.target());
117 if (!domModel) 143 if (!domModel)
118 return; 144 return;
119 if (auxData.type === this._breakpointTypes.SubtreeModified) { 145 if (auxData.type === this._breakpointTypes.SubtreeModified) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 var breakpointId = this._createBreakpointId(node.id, type); 230 var breakpointId = this._createBreakpointId(node.id, type);
205 var breakpointElement = this._breakpointElements[breakpointId]; 231 var breakpointElement = this._breakpointElements[breakpointId];
206 if (!breakpointElement) { 232 if (!breakpointElement) {
207 breakpointElement = this._createBreakpointElement(node, type, enable d); 233 breakpointElement = this._createBreakpointElement(node, type, enable d);
208 this._breakpointElements[breakpointId] = breakpointElement; 234 this._breakpointElements[breakpointId] = breakpointElement;
209 } else { 235 } else {
210 breakpointElement._checkboxElement.checked = enabled; 236 breakpointElement._checkboxElement.checked = enabled;
211 } 237 }
212 if (enabled) 238 if (enabled)
213 node.target().domdebuggerAgent().setDOMBreakpoint(node.id, type); 239 node.target().domdebuggerAgent().setDOMBreakpoint(node.id, type);
240 node.setMarker(WebInspector.DOMBreakpointsSidebarPane.Marker, true);
214 }, 241 },
215 242
216 /** 243 /**
217 * @param {!WebInspector.DOMNode} node 244 * @param {!WebInspector.DOMNode} node
218 * @param {!DOMDebuggerAgent.DOMBreakpointType} type 245 * @param {!DOMDebuggerAgent.DOMBreakpointType} type
219 * @param {boolean} enabled 246 * @param {boolean} enabled
220 */ 247 */
221 _createBreakpointElement: function(node, type, enabled) 248 _createBreakpointElement: function(node, type, enabled)
222 { 249 {
223 var element = createElement("li"); 250 var element = createElement("li");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 { 296 {
270 var breakpointId = this._createBreakpointId(node.id, type); 297 var breakpointId = this._createBreakpointId(node.id, type);
271 var element = this._breakpointElements[breakpointId]; 298 var element = this._breakpointElements[breakpointId];
272 if (!element) 299 if (!element)
273 return; 300 return;
274 301
275 this.removeListElement(element); 302 this.removeListElement(element);
276 delete this._breakpointElements[breakpointId]; 303 delete this._breakpointElements[breakpointId];
277 if (element._checkboxElement.checked) 304 if (element._checkboxElement.checked)
278 node.target().domdebuggerAgent().removeDOMBreakpoint(node.id, type); 305 node.target().domdebuggerAgent().removeDOMBreakpoint(node.id, type);
306 node.setMarker(WebInspector.DOMBreakpointsSidebarPane.Marker, this.hasBr eakpoints(node) ? true : null);
279 }, 307 },
280 308
281 /** 309 /**
282 * @param {!WebInspector.DOMNode} node 310 * @param {!WebInspector.DOMNode} node
283 * @param {!DOMDebuggerAgent.DOMBreakpointType} type 311 * @param {!DOMDebuggerAgent.DOMBreakpointType} type
284 * @param {!Event} event 312 * @param {!Event} event
285 */ 313 */
286 _contextMenu: function(node, type, event) 314 _contextMenu: function(node, type, event)
287 { 315 {
288 var contextMenu = new WebInspector.ContextMenu(event); 316 var contextMenu = new WebInspector.ContextMenu(event);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 _reattachBody: function() 483 _reattachBody: function()
456 { 484 {
457 if (this._wrappedPane.element.parentNode !== this.element) 485 if (this._wrappedPane.element.parentNode !== this.element)
458 this._wrappedPane.show(this.element); 486 this._wrappedPane.show(this.element);
459 }, 487 },
460 488
461 __proto__: WebInspector.SidebarPane.prototype 489 __proto__: WebInspector.SidebarPane.prototype
462 } 490 }
463 491
464 /** 492 /**
493 * @constructor
494 * @implements {WebInspector.DOMPresentationUtils.MarkerDecorator}
495 */
496 WebInspector.DOMBreakpointsSidebarPane.MarkerDecorator = function()
497 {
498 }
499
500 WebInspector.DOMBreakpointsSidebarPane.MarkerDecorator.prototype = {
501 /**
502 * @override
503 * @param {!WebInspector.DOMNode} node
504 * @return {?string}
505 */
506 decorate: function(node)
507 {
508 return WebInspector.UIString("DOM Breakpoint");
509 }
510 }
511
512 /**
465 * @type {!WebInspector.DOMBreakpointsSidebarPane} 513 * @type {!WebInspector.DOMBreakpointsSidebarPane}
466 */ 514 */
467 WebInspector.domBreakpointsSidebarPane; 515 WebInspector.domBreakpointsSidebarPane;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698