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

Side by Side Diff: Source/devtools/front_end/sources/BreakpointsSidebarPane.js

Issue 535143003: DevTools: Correctly set DOM breakpoints on every target. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 this._items.clear(); 284 this._items.clear();
285 }, 285 },
286 286
287 __proto__: WebInspector.SidebarPane.prototype 287 __proto__: WebInspector.SidebarPane.prototype
288 } 288 }
289 289
290 /** 290 /**
291 * @constructor 291 * @constructor
292 * @extends {WebInspector.NativeBreakpointsSidebarPane} 292 * @extends {WebInspector.NativeBreakpointsSidebarPane}
293 * @implements {WebInspector.TargetManager.Observer}
293 */ 294 */
294 WebInspector.XHRBreakpointsSidebarPane = function() 295 WebInspector.XHRBreakpointsSidebarPane = function()
295 { 296 {
296 WebInspector.NativeBreakpointsSidebarPane.call(this, WebInspector.UIString(" XHR Breakpoints")); 297 WebInspector.NativeBreakpointsSidebarPane.call(this, WebInspector.UIString(" XHR Breakpoints"));
297 298
298 this._breakpointElements = {}; 299 // FIXME: Use StringMap.
300 this._breakpointElements = { __proto__: null };
299 301
300 var addButton = document.createElement("button"); 302 var addButton = document.createElement("button");
301 addButton.className = "pane-title-button add"; 303 addButton.className = "pane-title-button add";
302 addButton.addEventListener("click", this._addButtonClicked.bind(this), false ); 304 addButton.addEventListener("click", this._addButtonClicked.bind(this), false );
303 addButton.title = WebInspector.UIString("Add XHR breakpoint"); 305 addButton.title = WebInspector.UIString("Add XHR breakpoint");
304 this.titleElement.appendChild(addButton); 306 this.titleElement.appendChild(addButton);
305 307
306 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM enu.bind(this), true); 308 this.emptyElement.addEventListener("contextmenu", this._emptyElementContextM enu.bind(this), true);
307 309
308 this._restoreBreakpoints(); 310 WebInspector.targetManager.observeTargets(this);
309 } 311 }
310 312
311 WebInspector.XHRBreakpointsSidebarPane.prototype = { 313 WebInspector.XHRBreakpointsSidebarPane.prototype = {
314 /**
315 * @param {!WebInspector.Target} target
316 */
317 targetAdded: function(target)
318 {
319 this._restoreBreakpoints(target);
320 },
321
322 /**
323 * @param {!WebInspector.Target} target
324 */
325 targetRemoved: function(target) { },
326
312 _emptyElementContextMenu: function(event) 327 _emptyElementContextMenu: function(event)
313 { 328 {
314 var contextMenu = new WebInspector.ContextMenu(event); 329 var contextMenu = new WebInspector.ContextMenu(event);
315 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._addButtonClicked.bind(t his)); 330 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._addButtonClicked.bind(t his));
316 contextMenu.show(); 331 contextMenu.show();
317 }, 332 },
318 333
319 _addButtonClicked: function(event) 334 _addButtonClicked: function(event)
320 { 335 {
321 if (event) 336 if (event)
(...skipping 22 matching lines...) Expand all
344 if (accept) { 359 if (accept) {
345 this._setBreakpoint(text, true); 360 this._setBreakpoint(text, true);
346 this._saveBreakpoints(); 361 this._saveBreakpoints();
347 } 362 }
348 } 363 }
349 364
350 var config = new WebInspector.InplaceEditor.Config(finishEditing.bind(th is, true), finishEditing.bind(this, false)); 365 var config = new WebInspector.InplaceEditor.Config(finishEditing.bind(th is, true), finishEditing.bind(this, false));
351 WebInspector.InplaceEditor.startEditing(inputElement, config); 366 WebInspector.InplaceEditor.startEditing(inputElement, config);
352 }, 367 },
353 368
354 _setBreakpoint: function(url, enabled) 369 /**
370 * @param {string} url
371 * @param {boolean} enabled
372 * @param {!WebInspector.Target=} target
373 */
374 _setBreakpoint: function(url, enabled, target)
355 { 375 {
376 if (enabled)
377 this._updateBreakpointOnTarget(url, true, target);
378
356 if (url in this._breakpointElements) 379 if (url in this._breakpointElements)
357 return; 380 return;
358 381
359 var element = document.createElement("li"); 382 var element = document.createElement("li");
360 element._url = url; 383 element._url = url;
361 element.addEventListener("contextmenu", this._contextMenu.bind(this, url ), true); 384 element.addEventListener("contextmenu", this._contextMenu.bind(this, url ), true);
362 385
363 var checkboxElement = document.createElement("input"); 386 var checkboxElement = document.createElement("input");
364 checkboxElement.className = "checkbox-elem"; 387 checkboxElement.className = "checkbox-elem";
365 checkboxElement.type = "checkbox"; 388 checkboxElement.type = "checkbox";
(...skipping 12 matching lines...) Expand all
378 element.appendChild(labelElement); 401 element.appendChild(labelElement);
379 402
380 var currentElement = /** @type {?Element} */ (this.listElement.firstChil d); 403 var currentElement = /** @type {?Element} */ (this.listElement.firstChil d);
381 while (currentElement) { 404 while (currentElement) {
382 if (currentElement._url && currentElement._url < element._url) 405 if (currentElement._url && currentElement._url < element._url)
383 break; 406 break;
384 currentElement = /** @type {?Element} */ (currentElement.nextSibling ); 407 currentElement = /** @type {?Element} */ (currentElement.nextSibling );
385 } 408 }
386 this.addListElement(element, currentElement); 409 this.addListElement(element, currentElement);
387 this._breakpointElements[url] = element; 410 this._breakpointElements[url] = element;
388 if (enabled) {
389 var targets = WebInspector.targetManager.targets();
390 for (var i = 0; i < targets.length; ++i)
391 targets[i].domdebuggerAgent().setXHRBreakpoint(url);
392 }
393 }, 411 },
394 412
395 _removeBreakpoint: function(url) 413 /**
414 * @param {string} url
415 * @param {!WebInspector.Target=} target
416 */
417 _removeBreakpoint: function(url, target)
396 { 418 {
397 var element = this._breakpointElements[url]; 419 var element = this._breakpointElements[url];
398 if (!element) 420 if (!element)
399 return; 421 return;
400 422
401 this.removeListElement(element); 423 this.removeListElement(element);
402 delete this._breakpointElements[url]; 424 delete this._breakpointElements[url];
403 if (element._checkboxElement.checked) { 425 if (element._checkboxElement.checked)
404 var targets = WebInspector.targetManager.targets(); 426 this._updateBreakpointOnTarget(url, false, target);
405 for (var i = 0; i < targets.length; ++i) 427 },
428
429 /**
430 * @param {string} url
431 * @param {boolean} enable
432 * @param {!WebInspector.Target=} target
433 */
434 _updateBreakpointOnTarget: function(url, enable, target)
435 {
436 var targets = target ? [target] : WebInspector.targetManager.targets();
437 for (var i = 0; i < targets.length; ++i) {
438 if (enable)
439 targets[i].domdebuggerAgent().setXHRBreakpoint(url);
440 else
406 targets[i].domdebuggerAgent().removeXHRBreakpoint(url); 441 targets[i].domdebuggerAgent().removeXHRBreakpoint(url);
407 } 442 }
408 }, 443 },
409 444
410 _contextMenu: function(url, event) 445 _contextMenu: function(url, event)
411 { 446 {
412 var contextMenu = new WebInspector.ContextMenu(event); 447 var contextMenu = new WebInspector.ContextMenu(event);
413 448
414 /** 449 /**
415 * @this {WebInspector.XHRBreakpointsSidebarPane} 450 * @this {WebInspector.XHRBreakpointsSidebarPane}
(...skipping 16 matching lines...) Expand all
432 var removeAllTitle = WebInspector.UIString(WebInspector.useLowerCaseMenu Titles() ? "Remove all breakpoints" : "Remove All Breakpoints"); 467 var removeAllTitle = WebInspector.UIString(WebInspector.useLowerCaseMenu Titles() ? "Remove all breakpoints" : "Remove All Breakpoints");
433 468
434 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._addButtonClicked.bind(t his)); 469 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Add breakpoint" : "Add Breakpoint"), this._addButtonClicked.bind(t his));
435 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Remove breakpoint" : "Remove Breakpoint"), removeBreakpoint.bind(t his)); 470 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Remove breakpoint" : "Remove Breakpoint"), removeBreakpoint.bind(t his));
436 contextMenu.appendItem(removeAllTitle, removeAllBreakpoints.bind(this)); 471 contextMenu.appendItem(removeAllTitle, removeAllBreakpoints.bind(this));
437 contextMenu.show(); 472 contextMenu.show();
438 }, 473 },
439 474
440 _checkboxClicked: function(url, event) 475 _checkboxClicked: function(url, event)
441 { 476 {
442 if (event.target.checked) 477 this._updateBreakpointOnTarget(url, event.target.checked);
443 DOMDebuggerAgent.setXHRBreakpoint(url);
444 else
445 DOMDebuggerAgent.removeXHRBreakpoint(url);
446 this._saveBreakpoints(); 478 this._saveBreakpoints();
447 }, 479 },
448 480
449 _labelClicked: function(url) 481 _labelClicked: function(url)
450 { 482 {
451 var element = this._breakpointElements[url]; 483 var element = this._breakpointElements[url];
452 var inputElement = document.createElement("span"); 484 var inputElement = document.createElement("span");
453 inputElement.className = "breakpoint-condition editing"; 485 inputElement.className = "breakpoint-condition editing";
454 inputElement.textContent = url; 486 inputElement.textContent = url;
455 this.listElement.insertBefore(inputElement, element); 487 this.listElement.insertBefore(inputElement, element);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 }, 526 },
495 527
496 _saveBreakpoints: function() 528 _saveBreakpoints: function()
497 { 529 {
498 var breakpoints = []; 530 var breakpoints = [];
499 for (var url in this._breakpointElements) 531 for (var url in this._breakpointElements)
500 breakpoints.push({ url: url, enabled: this._breakpointElements[url]. _checkboxElement.checked }); 532 breakpoints.push({ url: url, enabled: this._breakpointElements[url]. _checkboxElement.checked });
501 WebInspector.settings.xhrBreakpoints.set(breakpoints); 533 WebInspector.settings.xhrBreakpoints.set(breakpoints);
502 }, 534 },
503 535
504 _restoreBreakpoints: function() 536 /**
537 * @param {!WebInspector.Target} target
538 */
539 _restoreBreakpoints: function(target)
505 { 540 {
506 var breakpoints = WebInspector.settings.xhrBreakpoints.get(); 541 var breakpoints = WebInspector.settings.xhrBreakpoints.get();
507 for (var i = 0; i < breakpoints.length; ++i) { 542 for (var i = 0; i < breakpoints.length; ++i) {
508 var breakpoint = breakpoints[i]; 543 var breakpoint = breakpoints[i];
509 if (breakpoint && typeof breakpoint.url === "string") 544 if (breakpoint && typeof breakpoint.url === "string")
510 this._setBreakpoint(breakpoint.url, breakpoint.enabled); 545 this._setBreakpoint(breakpoint.url, breakpoint.enabled, target);
511 } 546 }
512 }, 547 },
513 548
514 __proto__: WebInspector.NativeBreakpointsSidebarPane.prototype 549 __proto__: WebInspector.NativeBreakpointsSidebarPane.prototype
515 } 550 }
516 551
517 /** 552 /**
518 * @constructor 553 * @constructor
519 * @extends {WebInspector.SidebarPane} 554 * @extends {WebInspector.SidebarPane}
555 * @implements {WebInspector.TargetManager.Observer}
520 */ 556 */
521 WebInspector.EventListenerBreakpointsSidebarPane = function() 557 WebInspector.EventListenerBreakpointsSidebarPane = function()
522 { 558 {
523 WebInspector.SidebarPane.call(this, WebInspector.UIString("Event Listener Br eakpoints")); 559 WebInspector.SidebarPane.call(this, WebInspector.UIString("Event Listener Br eakpoints"));
524 this.registerRequiredCSS("breakpointsList.css"); 560 this.registerRequiredCSS("breakpointsList.css");
525 561
526 this.categoriesElement = document.createElement("ol"); 562 this.categoriesElement = document.createElement("ol");
527 this.categoriesElement.tabIndex = 0; 563 this.categoriesElement.tabIndex = 0;
528 this.categoriesElement.classList.add("properties-tree"); 564 this.categoriesElement.classList.add("properties-tree");
529 this.categoriesElement.classList.add("event-listener-breakpoints"); 565 this.categoriesElement.classList.add("event-listener-breakpoints");
(...skipping 13 matching lines...) Expand all
543 this._createCategory(WebInspector.UIString("Keyboard"), ["keydown", "keyup", "keypress", "input"]); 579 this._createCategory(WebInspector.UIString("Keyboard"), ["keydown", "keyup", "keypress", "input"]);
544 this._createCategory(WebInspector.UIString("Load"), ["load", "beforeunload", "unload", "abort", "error", "hashchange", "popstate"]); 580 this._createCategory(WebInspector.UIString("Load"), ["load", "beforeunload", "unload", "abort", "error", "hashchange", "popstate"]);
545 this._createCategory(WebInspector.UIString("Media"), ["play", "pause", "play ing", "canplay", "canplaythrough", "seeking", "seeked", "timeupdate", "ended", " ratechange", "durationchange", "volumechange", "loadstart", "progress", "suspend ", "abort", "error", "emptied", "stalled", "loadedmetadata", "loadeddata", "wait ing"], false, ["audio", "video"]); 581 this._createCategory(WebInspector.UIString("Media"), ["play", "pause", "play ing", "canplay", "canplaythrough", "seeking", "seeked", "timeupdate", "ended", " ratechange", "durationchange", "volumechange", "loadstart", "progress", "suspend ", "abort", "error", "emptied", "stalled", "loadedmetadata", "loadeddata", "wait ing"], false, ["audio", "video"]);
546 this._createCategory(WebInspector.UIString("Mouse"), ["click", "dblclick", " mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel", "whee l"]); 582 this._createCategory(WebInspector.UIString("Mouse"), ["click", "dblclick", " mousedown", "mouseup", "mouseover", "mousemove", "mouseout", "mousewheel", "whee l"]);
547 this._createCategory(WebInspector.UIString("Timer"), ["setTimer", "clearTime r", "timerFired"], true); 583 this._createCategory(WebInspector.UIString("Timer"), ["setTimer", "clearTime r", "timerFired"], true);
548 this._createCategory(WebInspector.UIString("Touch"), ["touchstart", "touchmo ve", "touchend", "touchcancel"]); 584 this._createCategory(WebInspector.UIString("Touch"), ["touchstart", "touchmo ve", "touchend", "touchcancel"]);
549 this._createCategory(WebInspector.UIString("XHR"), ["readystatechange", "loa d", "loadstart", "loadend", "abort", "error", "progress", "timeout"], false, ["X MLHttpRequest", "XMLHttpRequestUpload"]); 585 this._createCategory(WebInspector.UIString("XHR"), ["readystatechange", "loa d", "loadstart", "loadend", "abort", "error", "progress", "timeout"], false, ["X MLHttpRequest", "XMLHttpRequestUpload"]);
550 this._createCategory(WebInspector.UIString("WebGL"), ["webglErrorFired", "we bglWarningFired"], true); 586 this._createCategory(WebInspector.UIString("WebGL"), ["webglErrorFired", "we bglWarningFired"], true);
551 this._createCategory(WebInspector.UIString("Window"), ["close"], true); 587 this._createCategory(WebInspector.UIString("Window"), ["close"], true);
552 588
553 this._restoreBreakpoints(); 589 WebInspector.targetManager.observeTargets(this);
554 } 590 }
555 591
556 WebInspector.EventListenerBreakpointsSidebarPane.categoryListener = "listener:"; 592 WebInspector.EventListenerBreakpointsSidebarPane.categoryListener = "listener:";
557 WebInspector.EventListenerBreakpointsSidebarPane.categoryInstrumentation = "inst rumentation:"; 593 WebInspector.EventListenerBreakpointsSidebarPane.categoryInstrumentation = "inst rumentation:";
558 WebInspector.EventListenerBreakpointsSidebarPane.eventTargetAny = "*"; 594 WebInspector.EventListenerBreakpointsSidebarPane.eventTargetAny = "*";
559 595
560 /** 596 /**
561 * @param {string} eventName 597 * @param {string} eventName
562 * @param {!Object=} auxData 598 * @param {!Object=} auxData
563 * @return {string} 599 * @return {string}
(...skipping 18 matching lines...) Expand all
582 // If there is a hex code of the error, display only this. 618 // If there is a hex code of the error, display only this.
583 errorName = errorName.replace(/^.*(0x[0-9a-f]+).*$/i, "$1"); 619 errorName = errorName.replace(/^.*(0x[0-9a-f]+).*$/i, "$1");
584 return WebInspector.UIString("WebGL Error Fired (%s)", errorName); 620 return WebInspector.UIString("WebGL Error Fired (%s)", errorName);
585 } 621 }
586 } 622 }
587 return WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI[eve ntName] || eventName.substring(eventName.indexOf(":") + 1); 623 return WebInspector.EventListenerBreakpointsSidebarPane._eventNamesForUI[eve ntName] || eventName.substring(eventName.indexOf(":") + 1);
588 } 624 }
589 625
590 WebInspector.EventListenerBreakpointsSidebarPane.prototype = { 626 WebInspector.EventListenerBreakpointsSidebarPane.prototype = {
591 /** 627 /**
628 * @param {!WebInspector.Target} target
629 */
630 targetAdded: function(target)
631 {
632 this._restoreBreakpoints(target);
633 },
634
635 /**
636 * @param {!WebInspector.Target} target
637 */
638 targetRemoved: function(target) { },
639
640 /**
592 * @param {string} name 641 * @param {string} name
593 * @param {!Array.<string>} eventNames 642 * @param {!Array.<string>} eventNames
594 * @param {boolean=} isInstrumentationEvent 643 * @param {boolean=} isInstrumentationEvent
595 * @param {!Array.<string>=} targetNames 644 * @param {!Array.<string>=} targetNames
596 */ 645 */
597 _createCategory: function(name, eventNames, isInstrumentationEvent, targetNa mes) 646 _createCategory: function(name, eventNames, isInstrumentationEvent, targetNa mes)
598 { 647 {
599 var labelNode = document.createElement("label"); 648 var labelNode = document.createElement("label");
600 labelNode.textContent = name; 649 labelNode.textContent = name;
601 650
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 { 734 {
686 if (event.target.checked) 735 if (event.target.checked)
687 this._setBreakpoint(eventName, targetNames); 736 this._setBreakpoint(eventName, targetNames);
688 else 737 else
689 this._removeBreakpoint(eventName, targetNames); 738 this._removeBreakpoint(eventName, targetNames);
690 this._saveBreakpoints(); 739 this._saveBreakpoints();
691 }, 740 },
692 741
693 /** 742 /**
694 * @param {string} eventName 743 * @param {string} eventName
695 * @param {?Array.<string>=} targetNames 744 * @param {?Array.<string>=} eventTargetNames
745 * @param {!WebInspector.Target=} target
696 */ 746 */
697 _setBreakpoint: function(eventName, targetNames) 747 _setBreakpoint: function(eventName, eventTargetNames, target)
698 { 748 {
699 targetNames = targetNames || [WebInspector.EventListenerBreakpointsSideb arPane.eventTargetAny]; 749 eventTargetNames = eventTargetNames || [WebInspector.EventListenerBreakp ointsSidebarPane.eventTargetAny];
700 for (var i = 0; i < targetNames.length; ++i) { 750 for (var i = 0; i < eventTargetNames.length; ++i) {
701 var targetName = targetNames[i]; 751 var eventTargetName = eventTargetNames[i];
702 var breakpointItem = this._findBreakpointItem(eventName, targetName) ; 752 var breakpointItem = this._findBreakpointItem(eventName, eventTarget Name);
703 if (!breakpointItem) 753 if (!breakpointItem)
704 continue; 754 continue;
705 breakpointItem.checkbox.checked = true; 755 breakpointItem.checkbox.checked = true;
706 breakpointItem.parent.dirtyCheckbox = true; 756 breakpointItem.parent.dirtyCheckbox = true;
707 if (eventName.startsWith(WebInspector.EventListenerBreakpointsSideba rPane.categoryListener)) 757 this._updateBreakpointOnTarget(eventName, eventTargetName, true, tar get);
708 DOMDebuggerAgent.setEventListenerBreakpoint(eventName.substring( WebInspector.EventListenerBreakpointsSidebarPane.categoryListener.length), targe tName);
709 else if (eventName.startsWith(WebInspector.EventListenerBreakpointsS idebarPane.categoryInstrumentation))
710 DOMDebuggerAgent.setInstrumentationBreakpoint(eventName.substrin g(WebInspector.EventListenerBreakpointsSidebarPane.categoryInstrumentation.lengt h));
711 } 758 }
712 this._updateCategoryCheckboxes(); 759 this._updateCategoryCheckboxes();
713 }, 760 },
714 761
715 /** 762 /**
716 * @param {string} eventName 763 * @param {string} eventName
717 * @param {?Array.<string>=} targetNames 764 * @param {?Array.<string>=} eventTargetNames
765 * @param {!WebInspector.Target=} target
718 */ 766 */
719 _removeBreakpoint: function(eventName, targetNames) 767 _removeBreakpoint: function(eventName, eventTargetNames, target)
720 { 768 {
721 targetNames = targetNames || [WebInspector.EventListenerBreakpointsSideb arPane.eventTargetAny]; 769 eventTargetNames = eventTargetNames || [WebInspector.EventListenerBreakp ointsSidebarPane.eventTargetAny];
722 for (var i = 0; i < targetNames.length; ++i) { 770 for (var i = 0; i < eventTargetNames.length; ++i) {
723 var targetName = targetNames[i]; 771 var eventTargetName = eventTargetNames[i];
724 var breakpointItem = this._findBreakpointItem(eventName, targetName) ; 772 var breakpointItem = this._findBreakpointItem(eventName, eventTarget Name);
725 if (!breakpointItem) 773 if (!breakpointItem)
726 continue; 774 continue;
727 breakpointItem.checkbox.checked = false; 775 breakpointItem.checkbox.checked = false;
728 breakpointItem.parent.dirtyCheckbox = true; 776 breakpointItem.parent.dirtyCheckbox = true;
729 if (eventName.startsWith(WebInspector.EventListenerBreakpointsSideba rPane.categoryListener)) 777 this._updateBreakpointOnTarget(eventName, eventTargetName, false, ta rget);
730 DOMDebuggerAgent.removeEventListenerBreakpoint(eventName.substri ng(WebInspector.EventListenerBreakpointsSidebarPane.categoryListener.length), ta rgetName);
731 else if (eventName.startsWith(WebInspector.EventListenerBreakpointsS idebarPane.categoryInstrumentation))
732 DOMDebuggerAgent.removeInstrumentationBreakpoint(eventName.subst ring(WebInspector.EventListenerBreakpointsSidebarPane.categoryInstrumentation.le ngth));
733 } 778 }
734 this._updateCategoryCheckboxes(); 779 this._updateCategoryCheckboxes();
735 }, 780 },
736 781
782 /**
783 * @param {string} eventName
784 * @param {string} eventTargetName
785 * @param {boolean} enable
786 * @param {!WebInspector.Target=} target
787 */
788 _updateBreakpointOnTarget: function(eventName, eventTargetName, enable, targ et)
789 {
790 var targets = target ? [target] : WebInspector.targetManager.targets();
791 for (var i = 0; i < targets.length; ++i) {
792 if (eventName.startsWith(WebInspector.EventListenerBreakpointsSideba rPane.categoryListener)) {
793 var protocolEventName = eventName.substring(WebInspector.EventLi stenerBreakpointsSidebarPane.categoryListener.length);
794 if (enable)
795 targets[i].domdebuggerAgent().setEventListenerBreakpoint(pro tocolEventName, eventTargetName);
796 else
797 targets[i].domdebuggerAgent().removeEventListenerBreakpoint( protocolEventName, eventTargetName);
798 } else if (eventName.startsWith(WebInspector.EventListenerBreakpoint sSidebarPane.categoryInstrumentation)) {
799 var protocolEventName = eventName.substring(WebInspector.EventLi stenerBreakpointsSidebarPane.categoryInstrumentation.length);
800 if (enable)
801 targets[i].domdebuggerAgent().setInstrumentationBreakpoint(p rotocolEventName);
802 else
803 targets[i].domdebuggerAgent().removeInstrumentationBreakpoin t(protocolEventName);
804 }
805 }
806 },
807
737 _updateCategoryCheckboxes: function() 808 _updateCategoryCheckboxes: function()
738 { 809 {
739 for (var i = 0; i < this._categoryItems.length; ++i) { 810 for (var i = 0; i < this._categoryItems.length; ++i) {
740 var categoryItem = this._categoryItems[i]; 811 var categoryItem = this._categoryItems[i];
741 if (!categoryItem.dirtyCheckbox) 812 if (!categoryItem.dirtyCheckbox)
742 continue; 813 continue;
743 categoryItem.dirtyCheckbox = false; 814 categoryItem.dirtyCheckbox = false;
744 var hasEnabled = false; 815 var hasEnabled = false;
745 var hasDisabled = false; 816 var hasDisabled = false;
746 for (var eventName in categoryItem.children) { 817 for (var eventName in categoryItem.children) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 var categoryItem = this._categoryItems[i]; 877 var categoryItem = this._categoryItems[i];
807 for (var eventName in categoryItem.children) { 878 for (var eventName in categoryItem.children) {
808 var breakpointItem = categoryItem.children[eventName]; 879 var breakpointItem = categoryItem.children[eventName];
809 if (breakpointItem.checkbox.checked) 880 if (breakpointItem.checkbox.checked)
810 breakpoints.push({ eventName: eventName, targetNames: catego ryItem.targetNames }); 881 breakpoints.push({ eventName: eventName, targetNames: catego ryItem.targetNames });
811 } 882 }
812 } 883 }
813 WebInspector.settings.eventListenerBreakpoints.set(breakpoints); 884 WebInspector.settings.eventListenerBreakpoints.set(breakpoints);
814 }, 885 },
815 886
816 _restoreBreakpoints: function() 887 /**
888 * @param {!WebInspector.Target} target
889 */
890 _restoreBreakpoints: function(target)
817 { 891 {
818 var breakpoints = WebInspector.settings.eventListenerBreakpoints.get(); 892 var breakpoints = WebInspector.settings.eventListenerBreakpoints.get();
819 for (var i = 0; i < breakpoints.length; ++i) { 893 for (var i = 0; i < breakpoints.length; ++i) {
820 var breakpoint = breakpoints[i]; 894 var breakpoint = breakpoints[i];
821 if (breakpoint && typeof breakpoint.eventName === "string") 895 if (breakpoint && typeof breakpoint.eventName === "string")
822 this._setBreakpoint(breakpoint.eventName, breakpoint.targetNames ); 896 this._setBreakpoint(breakpoint.eventName, breakpoint.targetNames , target);
823 } 897 }
824 }, 898 },
825 899
826 __proto__: WebInspector.SidebarPane.prototype 900 __proto__: WebInspector.SidebarPane.prototype
827 } 901 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698