2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * @param {!WebInspector.DebuggerModel} debuggerModel
29 * @param {!WebInspector.BreakpointManager} breakpointManager
30 * @extends {WebInspector.SidebarPane}
32 WebInspector.JavaScriptBreakpointsSidebarPane = function(debuggerModel, breakpointManager, showSourceLineDelegate)
34 WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints"));
35 this._debuggerModel = debuggerModel;
36 this.registerRequiredCSS("breakpointsList.css");
38 this._breakpointManager = breakpointManager;
39 this._showSourceLineDelegate = showSourceLineDelegate;
41 this.listElement = document.createElement("ol");
42 this.listElement.className = "breakpoint-list";
44 this.emptyElement = document.createElement("div");
45 this.emptyElement.className = "info";
46 this.emptyElement.textContent = WebInspector.UIString("No Breakpoints");
48 this.bodyElement.appendChild(this.emptyElement);
50 this._items = new Map();
52 var breakpointLocations = this._breakpointManager.allBreakpointLocations();
53 for (var i = 0; i < breakpointLocations.length; ++i)
54 this._addBreakpoint(breakpointLocations[i].breakpoint, breakpointLocations[i].uiLocation);
56 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this);
57 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpointRemoved, this);
59 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextMenu.bind(this), true);
62 WebInspector.JavaScriptBreakpointsSidebarPane.prototype = {
63 _emptyElementContextMenu: function(event)
65 var contextMenu = new WebInspector.ContextMenu(event);
66 var breakpointActive = this._debuggerModel.breakpointsActive();
67 var breakpointActiveTitle = breakpointActive ?
68 WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Deactivate breakpoints" : "Deactivate Breakpoints") :
69 WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Activate breakpoints" : "Activate Breakpoints");
70 contextMenu.appendItem(breakpointActiveTitle, this._debuggerModel.setBreakpointsActive.bind(this._debuggerModel, !breakpointActive));
75 * @param {!WebInspector.Event} event
77 _breakpointAdded: function(event)
79 this._breakpointRemoved(event);
81 var breakpoint = /** @type {!WebInspector.BreakpointManager.Breakpoint} */ (event.data.breakpoint);
82 var uiLocation = /** @type {!WebInspector.UILocation} */ (event.data.uiLocation);
83 this._addBreakpoint(breakpoint, uiLocation);
87 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
88 * @param {!WebInspector.UILocation} uiLocation
90 _addBreakpoint: function(breakpoint, uiLocation)
92 var element = document.createElement("li");
93 element.classList.add("cursor-pointer");
94 element.addEventListener("contextmenu", this._breakpointContextMenu.bind(this, breakpoint), true);
95 element.addEventListener("click", this._breakpointClicked.bind(this, uiLocation), false);
97 var checkbox = document.createElement("input");
98 checkbox.className = "checkbox-elem";
99 checkbox.type = "checkbox";
100 checkbox.checked = breakpoint.enabled();
101 checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(this, breakpoint), false);
102 element.appendChild(checkbox);
104 var labelElement = document.createTextNode(uiLocation.linkText());
105 element.appendChild(labelElement);
107 var snippetElement = document.createElement("div");
108 snippetElement.className = "source-text monospace";
109 element.appendChild(snippetElement);
112 * @param {?string} content
114 function didRequestContent(content)
116 var lineNumber = uiLocation.lineNumber
117 var columnNumber = uiLocation.columnNumber;
118 var contentString = new String(content);
119 if (lineNumber < contentString.lineCount()) {
120 var lineText = contentString.lineAt(lineNumber);
121 var maxSnippetLength = 200;
122 snippetElement.textContent = lineText.substr(columnNumber).trimEnd(maxSnippetLength);
126 uiLocation.uiSourceCode.requestContent(didRequestContent);
128 element._data = uiLocation;
129 var currentElement = this.listElement.firstChild;
130 while (currentElement) {
131 if (currentElement._data && this._compareBreakpoints(currentElement._data, element._data) > 0)
133 currentElement = currentElement.nextSibling;
135 this._addListElement(element, currentElement);
137 var breakpointItem = {};
138 breakpointItem.element = element;
139 breakpointItem.checkbox = checkbox;
140 this._items.put(breakpoint, breakpointItem);
146 * @param {!WebInspector.Event} event
148 _breakpointRemoved: function(event)
150 var breakpoint = /** @type {!WebInspector.BreakpointManager.Breakpoint} */ (event.data.breakpoint);
151 var uiLocation = /** @type {!WebInspector.UILocation} */ (event.data.uiLocation);
152 var breakpointItem = this._items.get(breakpoint);
155 this._items.remove(breakpoint);
156 this._removeListElement(breakpointItem.element);
160 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
162 highlightBreakpoint: function(breakpoint)
164 var breakpointItem = this._items.get(breakpoint);
167 breakpointItem.element.classList.add("breakpoint-hit");
168 this._highlightedBreakpointItem = breakpointItem;
171 clearBreakpointHighlight: function()
173 if (this._highlightedBreakpointItem) {
174 this._highlightedBreakpointItem.element.classList.remove("breakpoint-hit");
175 delete this._highlightedBreakpointItem;
179 _breakpointClicked: function(uiLocation, event)
181 this._showSourceLineDelegate(uiLocation.uiSourceCode, uiLocation.lineNumber);
185 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
187 _breakpointCheckboxClicked: function(breakpoint, event)
189 // Breakpoint element has it's own click handler.
191 breakpoint.setEnabled(event.target.checked);
195 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
197 _breakpointContextMenu: function(breakpoint, event)
199 var breakpoints = this._items.values();
200 var contextMenu = new WebInspector.ContextMenu(event);
201 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove breakpoint" : "Remove Breakpoint"), breakpoint.remove.bind(breakpoint));
202 if (breakpoints.length > 1) {
203 var removeAllTitle = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove all breakpoints" : "Remove All Breakpoints");
204 contextMenu.appendItem(removeAllTitle, this._breakpointManager.removeAllBreakpoints.bind(this._breakpointManager));
207 contextMenu.appendSeparator();
208 var breakpointActive = this._debuggerModel.breakpointsActive();
209 var breakpointActiveTitle = breakpointActive ?
210 WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Deactivate breakpoints" : "Deactivate Breakpoints") :
211 WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Activate breakpoints" : "Activate Breakpoints");
212 contextMenu.appendItem(breakpointActiveTitle, this._debuggerModel.setBreakpointsActive.bind(this._debuggerModel, !breakpointActive));
214 function enabledBreakpointCount(breakpoints)
217 for (var i = 0; i < breakpoints.length; ++i) {
218 if (breakpoints[i].checkbox.checked)
223 if (breakpoints.length > 1) {
224 var enableBreakpointCount = enabledBreakpointCount(breakpoints);
225 var enableTitle = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Enable all breakpoints" : "Enable All Breakpoints");
226 var disableTitle = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Disable all breakpoints" : "Disable All Breakpoints");
228 contextMenu.appendSeparator();
230 contextMenu.appendItem(enableTitle, this._breakpointManager.toggleAllBreakpoints.bind(this._breakpointManager, true), !(enableBreakpointCount != breakpoints.length));
231 contextMenu.appendItem(disableTitle, this._breakpointManager.toggleAllBreakpoints.bind(this._breakpointManager, false), !(enableBreakpointCount > 1));
237 _addListElement: function(element, beforeElement)
240 this.listElement.insertBefore(element, beforeElement);
242 if (!this.listElement.firstChild) {
243 this.bodyElement.removeChild(this.emptyElement);
244 this.bodyElement.appendChild(this.listElement);
246 this.listElement.appendChild(element);
250 _removeListElement: function(element)
252 this.listElement.removeChild(element);
253 if (!this.listElement.firstChild) {
254 this.bodyElement.removeChild(this.listElement);
255 this.bodyElement.appendChild(this.emptyElement);
259 _compare: function(x, y)
262 return x < y ? -1 : 1;
266 _compareBreakpoints: function(b1, b2)
268 return this._compare(b1.uiSourceCode.originURL(), b2.uiSourceCode.originURL()) || this._compare(b1.lineNumber, b2.lineNumber);
273 this.listElement.removeChildren();
274 if (this.listElement.parentElement) {
275 this.bodyElement.removeChild(this.listElement);
276 this.bodyElement.appendChild(this.emptyElement);
281 __proto__: WebInspector.SidebarPane.prototype
286 * @extends {WebInspector.NativeBreakpointsSidebarPane}
288 WebInspector.XHRBreakpointsSidebarPane = function()
290 WebInspector.NativeBreakpointsSidebarPane.call(this, WebInspector.UIString("XHR Breakpoints"));
292 this._breakpointElements = {};
294 var addButton = document.createElement("button");
295 addButton.className = "pane-title-button add";
296 addButton.addEventListener("click", this._addButtonClicked.bind(this), false);
297 addButton.title = WebInspector.UIString("Add XHR breakpoint");
298 this.titleElement.appendChild(addButton);
300 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextMenu.bind(this), true);
302 this._restoreBreakpoints();
305 WebInspector.XHRBreakpointsSidebarPane.prototype = {
306 _emptyElementContextMenu: function(event)
308 var contextMenu = new WebInspector.ContextMenu(event);
309 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._addButtonClicked.bind(this));
313 _addButtonClicked: function(event)
320 var inputElementContainer = document.createElement("p");
321 inputElementContainer.className = "breakpoint-condition";
322 var inputElement = document.createElement("span");
323 inputElementContainer.textContent = WebInspector.UIString("Break when URL contains:");
324 inputElement.className = "editing";
325 inputElement.id = "breakpoint-condition-input";
326 inputElementContainer.appendChild(inputElement);
327 this._addListElement(inputElementContainer, this.listElement.firstChild);
330 * @param {boolean} accept
331 * @param {!Element} e
332 * @param {string} text
333 * @this {WebInspector.XHRBreakpointsSidebarPane}
335 function finishEditing(accept, e, text)
337 this._removeListElement(inputElementContainer);
339 this._setBreakpoint(text, true);
340 this._saveBreakpoints();
344 var config = new WebInspector.InplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, false));
345 WebInspector.InplaceEditor.startEditing(inputElement, config);
348 _setBreakpoint: function(url, enabled)
350 if (url in this._breakpointElements)
353 var element = document.createElement("li");
355 element.addEventListener("contextmenu", this._contextMenu.bind(this, url), true);
357 var checkboxElement = document.createElement("input");
358 checkboxElement.className = "checkbox-elem";
359 checkboxElement.type = "checkbox";
360 checkboxElement.checked = enabled;
361 checkboxElement.addEventListener("click", this._checkboxClicked.bind(this, url), false);
362 element._checkboxElement = checkboxElement;
363 element.appendChild(checkboxElement);
365 var labelElement = document.createElement("span");
367 labelElement.textContent = WebInspector.UIString("Any XHR");
369 labelElement.textContent = WebInspector.UIString("URL contains \"%s\"", url);
370 labelElement.classList.add("cursor-auto");
371 labelElement.addEventListener("dblclick", this._labelClicked.bind(this, url), false);
372 element.appendChild(labelElement);
374 var currentElement = this.listElement.firstChild;
375 while (currentElement) {
376 if (currentElement._url && currentElement._url < element._url)
378 currentElement = currentElement.nextSibling;
380 this._addListElement(element, currentElement);
381 this._breakpointElements[url] = element;
383 DOMDebuggerAgent.setXHRBreakpoint(url);
386 _removeBreakpoint: function(url)
388 var element = this._breakpointElements[url];
392 this._removeListElement(element);
393 delete this._breakpointElements[url];
394 if (element._checkboxElement.checked)
395 DOMDebuggerAgent.removeXHRBreakpoint(url);
398 _contextMenu: function(url, event)
400 var contextMenu = new WebInspector.ContextMenu(event);
403 * @this {WebInspector.XHRBreakpointsSidebarPane}
405 function removeBreakpoint()
407 this._removeBreakpoint(url);
408 this._saveBreakpoints();
412 * @this {WebInspector.XHRBreakpointsSidebarPane}
414 function removeAllBreakpoints()
416 for (var url in this._breakpointElements)
417 this._removeBreakpoint(url);
418 this._saveBreakpoints();
420 var removeAllTitle = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove all breakpoints" : "Remove All Breakpoints");
422 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._addButtonClicked.bind(this));
423 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove breakpoint" : "Remove Breakpoint"), removeBreakpoint.bind(this));
424 contextMenu.appendItem(removeAllTitle, removeAllBreakpoints.bind(this));
428 _checkboxClicked: function(url, event)
430 if (event.target.checked)
431 DOMDebuggerAgent.setXHRBreakpoint(url);
433 DOMDebuggerAgent.removeXHRBreakpoint(url);
434 this._saveBreakpoints();
437 _labelClicked: function(url)
439 var element = this._breakpointElements[url];
440 var inputElement = document.createElement("span");
441 inputElement.className = "breakpoint-condition editing";
442 inputElement.textContent = url;
443 this.listElement.insertBefore(inputElement, element);
444 element.classList.add("hidden");
447 * @param {boolean} accept
448 * @param {!Element} e
449 * @param {string} text
450 * @this {WebInspector.XHRBreakpointsSidebarPane}
452 function finishEditing(accept, e, text)
454 this._removeListElement(inputElement);
456 this._removeBreakpoint(url);
457 this._setBreakpoint(text, element._checkboxElement.checked);
458 this._saveBreakpoints();
460 element.classList.remove("hidden");
463 WebInspector.InplaceEditor.startEditing(inputElement, new WebInspector.InplaceEditor.Config(finishEditing.bind(this, true), finishEditing.bind(this, false)));
466 highlightBreakpoint: function(url)
468 var element = this._breakpointElements[url];
472 element.classList.add("breakpoint-hit");
473 this._highlightedElement = element;
476 clearBreakpointHighlight: function()
478 if (this._highlightedElement) {
479 this._highlightedElement.classList.remove("breakpoint-hit");
480 delete this._highlightedElement;
484 _saveBreakpoints: function()
486 var breakpoints = [];
487 for (var url in this._breakpointElements)
488 breakpoints.push({ url: url, enabled: this._breakpointElements[url]._checkboxElement.checked });
489 WebInspector.settings.xhrBreakpoints.set(breakpoints);
492 _restoreBreakpoints: function()
494 var breakpoints = WebInspector.settings.xhrBreakpoints.get();
495 for (var i = 0; i < breakpoints.length; ++i) {
496 var breakpoint = breakpoints[i];
497 if (breakpoint && typeof breakpoint.url === "string")
498 this._setBreakpoint(breakpoint.url, breakpoint.enabled);
502 __proto__: WebInspector.NativeBreakpointsSidebarPane.prototype
507 * @extends {WebInspector.SidebarPane}
509 WebInspector.EventListenerBreakpointsSidebarPane = function()
511 WebInspector.SidebarPane.call(this, WebInspector.UIString("Event Listener Breakpoints"));
512 this.registerRequiredCSS("breakpointsList.css");
514 this.categoriesElement = document.createElement("ol");
515 this.categoriesElement.tabIndex = 0;
516 this.categoriesElement.classList.add("properties-tree");
517 this.categoriesElement.classList.add("event-listener-breakpoints");
518 this.categoriesTreeOutline = new TreeOutline(this.categoriesElement);
519 this.bodyElement.appendChild(this.categoriesElement);
521 this._breakpointItems = {};
522 // FIXME: uncomment following once inspector stops being drop targer in major ports.
523 // Otherwise, inspector page reacts on drop event and tries to load the event data.
524 // this._createCategory(WebInspector.UIString("Drag"), true, ["drag", "drop", "dragstart", "dragend", "dragenter", "dragleave", "dragover"]);
525 this._createCategory(WebInspector.UIString("Animation"), false, ["requestAnimationFrame", "cancelAnimationFrame", "animationFrameFired"]);
526 this._createCategory(WebInspector.UIString("Control"), true, ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"]);
527 this._createCategory(WebInspector.UIString("Clipboard"), true, ["copy", "cut", "paste", "beforecopy", "beforecut", "beforepaste"]);
528 this._createCategory(WebInspector.UIString("DOM Mutation"), true, ["DOMActivate", "DOMFocusIn", "DOMFocusOut", "DOMAttrModified", "DOMCharacterDataModified", "DOMNodeInserted", "DOMNodeInsertedIntoDocument", "DOMNodeRemoved", "DOMNodeRemovedFromDocument", "DOMSubtreeModified", "DOMContentLoaded"]);
529 this._createCategory(WebInspector.UIString("Device"), true, ["deviceorientation", "devicemotion"]);
530 this._createCategory(WebInspector.UIString("Drag / drop"), true, ["dragenter", "dragover", "dragleave", "drop"]);
531 this._createCategory(WebInspector.UIString("Keyboard"), true, ["keydown", "keyup", "keypress", "input"]);
532 this._createCategory(WebInspector.UIString("Load"), true, ["load", "beforeunload", "unload", "abort", "error", "hashchange", "popstate"]);
533 this._createCategory(WebInspector.UIString("Mouse"), true, ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel", "wheel"]);
534 this._createCategory(WebInspector.UIString("Timer"), false, ["setTimer", "clearTimer", "timerFired"]);
535 this._createCategory(WebInspector.UIString("Touch"), true, ["touchstart", "touchmove", "touchend", "touchcancel"]);
536 this._createCategory(WebInspector.UIString("WebGL"), false, ["webglErrorFired", "webglWarningFired"]);
538 this._restoreBreakpoints();
541 WebInspector.EventListenerBreakpointsSidebarPane.categotyListener = "listener:";
542 WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation = "instrumentation:";
545 * @param {string} eventName
546 * @param {!Object=} auxData
549 WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI = function(eventName, auxData)
551 if (!WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI) {
552 WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI = {
553 "instrumentation:setTimer": WebInspector.UIString("Set Timer"),
554 "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
555 "instrumentation:timerFired": WebInspector.UIString("Timer Fired"),
556 "instrumentation:requestAnimationFrame": WebInspector.UIString("Request Animation Frame"),
557 "instrumentation:cancelAnimationFrame": WebInspector.UIString("Cancel Animation Frame"),
558 "instrumentation:animationFrameFired": WebInspector.UIString("Animation Frame Fired"),
559 "instrumentation:webglErrorFired": WebInspector.UIString("WebGL Error Fired"),
560 "instrumentation:webglWarningFired": WebInspector.UIString("WebGL Warning Fired")
564 if (eventName === "instrumentation:webglErrorFired" && auxData["webglErrorName"]) {
565 var errorName = auxData["webglErrorName"];
566 // If there is a hex code of the error, display only this.
567 errorName = errorName.replace(/^.*(0x[0-9a-f]+).*$/i, "$1");
568 return WebInspector.UIString("WebGL Error Fired (%s)", errorName);
571 return WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI[eventName] || eventName.substring(eventName.indexOf(":") + 1);
574 WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
575 _createCategory: function(name, isDOMEvent, eventNames)
577 var labelNode = document.createElement("label");
578 labelNode.textContent = name;
580 var categoryItem = {};
581 categoryItem.element = new TreeElement(labelNode);
582 this.categoriesTreeOutline.appendChild(categoryItem.element);
583 categoryItem.element.listItemElement.classList.add("event-category");
584 categoryItem.element.selectable = true;
586 categoryItem.checkbox = this._createCheckbox(labelNode);
587 categoryItem.checkbox.addEventListener("click", this._categoryCheckboxClicked.bind(this, categoryItem), true);
589 categoryItem.children = {};
590 for (var i = 0; i < eventNames.length; ++i) {
591 var eventName = (isDOMEvent ? WebInspector.EventListenerBreakpointsSidebarPane.categotyListener : WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation) + eventNames[i];
593 var breakpointItem = {};
594 var title = WebInspector.EventListenerBreakpointsSidebarPane.eventNameForUI(eventName);
596 labelNode = document.createElement("label");
597 labelNode.textContent = title;
599 breakpointItem.element = new TreeElement(labelNode);
600 categoryItem.element.appendChild(breakpointItem.element);
602 var hitMarker = document.createElement("div");
603 hitMarker.className = "breakpoint-hit-marker";
604 breakpointItem.element.listItemElement.appendChild(hitMarker);
605 breakpointItem.element.listItemElement.classList.add("source-code");
606 breakpointItem.element.selectable = false;
608 breakpointItem.checkbox = this._createCheckbox(labelNode);
609 breakpointItem.checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind(this, eventName), true);
610 breakpointItem.parent = categoryItem;
612 this._breakpointItems[eventName] = breakpointItem;
613 categoryItem.children[eventName] = breakpointItem;
617 _createCheckbox: function(labelNode)
619 var checkbox = document.createElement("input");
620 checkbox.className = "checkbox-elem";
621 checkbox.type = "checkbox";
623 labelNode.insertBefore(checkbox, labelNode.firstChild);
627 _categoryCheckboxClicked: function(categoryItem)
629 var checked = categoryItem.checkbox.checked;
630 for (var eventName in categoryItem.children) {
631 var breakpointItem = categoryItem.children[eventName];
632 if (breakpointItem.checkbox.checked === checked)
635 this._setBreakpoint(eventName);
637 this._removeBreakpoint(eventName);
639 this._saveBreakpoints();
642 _breakpointCheckboxClicked: function(eventName, event)
644 if (event.target.checked)
645 this._setBreakpoint(eventName);
647 this._removeBreakpoint(eventName);
648 this._saveBreakpoints();
651 _setBreakpoint: function(eventName)
653 var breakpointItem = this._breakpointItems[eventName];
656 breakpointItem.checkbox.checked = true;
657 if (eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener))
658 DOMDebuggerAgent.setEventListenerBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener.length));
659 else if (eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation))
660 DOMDebuggerAgent.setInstrumentationBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation.length));
661 this._updateCategoryCheckbox(breakpointItem.parent);
664 _removeBreakpoint: function(eventName)
666 var breakpointItem = this._breakpointItems[eventName];
669 breakpointItem.checkbox.checked = false;
670 if (eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener))
671 DOMDebuggerAgent.removeEventListenerBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyListener.length));
672 else if (eventName.startsWith(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation))
673 DOMDebuggerAgent.removeInstrumentationBreakpoint(eventName.substring(WebInspector.EventListenerBreakpointsSidebarPane.categotyInstrumentation.length));
674 this._updateCategoryCheckbox(breakpointItem.parent);
677 _updateCategoryCheckbox: function(categoryItem)
679 var hasEnabled = false, hasDisabled = false;
680 for (var eventName in categoryItem.children) {
681 var breakpointItem = categoryItem.children[eventName];
682 if (breakpointItem.checkbox.checked)
687 categoryItem.checkbox.checked = hasEnabled;
688 categoryItem.checkbox.indeterminate = hasEnabled && hasDisabled;
691 highlightBreakpoint: function(eventName)
693 var breakpointItem = this._breakpointItems[eventName];
697 breakpointItem.parent.element.expand();
698 breakpointItem.element.listItemElement.classList.add("breakpoint-hit");
699 this._highlightedElement = breakpointItem.element.listItemElement;
702 clearBreakpointHighlight: function()
704 if (this._highlightedElement) {
705 this._highlightedElement.classList.remove("breakpoint-hit");
706 delete this._highlightedElement;
710 _saveBreakpoints: function()
712 var breakpoints = [];
713 for (var eventName in this._breakpointItems) {
714 if (this._breakpointItems[eventName].checkbox.checked)
715 breakpoints.push({ eventName: eventName });
717 WebInspector.settings.eventListenerBreakpoints.set(breakpoints);
720 _restoreBreakpoints: function()
722 var breakpoints = WebInspector.settings.eventListenerBreakpoints.get();
723 for (var i = 0; i < breakpoints.length; ++i) {
724 var breakpoint = breakpoints[i];
725 if (breakpoint && typeof breakpoint.eventName === "string")
726 this._setBreakpoint(breakpoint.eventName);
730 __proto__: WebInspector.SidebarPane.prototype