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

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

Issue 805853002: DevTools: Make labeled checkbox a web component (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 /** 89 /**
90 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint 90 * @param {!WebInspector.BreakpointManager.Breakpoint} breakpoint
91 * @param {!WebInspector.UILocation} uiLocation 91 * @param {!WebInspector.UILocation} uiLocation
92 */ 92 */
93 _addBreakpoint: function(breakpoint, uiLocation) 93 _addBreakpoint: function(breakpoint, uiLocation)
94 { 94 {
95 var element = createElementWithClass("li", "cursor-pointer"); 95 var element = createElementWithClass("li", "cursor-pointer");
96 element.addEventListener("contextmenu", this._breakpointContextMenu.bind (this, breakpoint), true); 96 element.addEventListener("contextmenu", this._breakpointContextMenu.bind (this, breakpoint), true);
97 element.addEventListener("click", this._breakpointClicked.bind(this, uiL ocation), false); 97 element.addEventListener("click", this._breakpointClicked.bind(this, uiL ocation), false);
98 98
99 var checkbox = element.createChild("input", "checkbox-elem"); 99 var checkbox = createCheckboxLabel(uiLocation.linkText(), breakpoint.ena bled());
100 checkbox.type = "checkbox"; 100 element.appendChild(checkbox);
101 checkbox.checked = breakpoint.enabled();
102 checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind( this, breakpoint), false); 101 checkbox.addEventListener("click", this._breakpointCheckboxClicked.bind( this, breakpoint), false);
103 102
104 element.createTextChild(uiLocation.linkText()); 103 var snippetElement = checkbox.textElement.createChild("div", "source-tex t monospace");
105
106 var snippetElement = element.createChild("div", "source-text monospace") ;
107 104
108 /** 105 /**
109 * @param {?string} content 106 * @param {?string} content
110 */ 107 */
111 function didRequestContent(content) 108 function didRequestContent(content)
112 { 109 {
113 var lineNumber = uiLocation.lineNumber 110 var lineNumber = uiLocation.lineNumber
114 var columnNumber = uiLocation.columnNumber; 111 var columnNumber = uiLocation.columnNumber;
115 var contentString = new String(content); 112 var contentString = new String(content);
116 if (lineNumber < contentString.lineCount()) { 113 if (lineNumber < contentString.lineCount()) {
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (enabled) 359 if (enabled)
363 this._updateBreakpointOnTarget(url, true, target); 360 this._updateBreakpointOnTarget(url, true, target);
364 361
365 if (this._breakpointElements.has(url)) 362 if (this._breakpointElements.has(url))
366 return; 363 return;
367 364
368 var element = createElement("li"); 365 var element = createElement("li");
369 element._url = url; 366 element._url = url;
370 element.addEventListener("contextmenu", this._contextMenu.bind(this, url ), true); 367 element.addEventListener("contextmenu", this._contextMenu.bind(this, url ), true);
371 368
372 var checkboxElement = element.createChild("input", "checkbox-elem"); 369 var label = createCheckboxLabel(undefined, enabled);
373 checkboxElement.type = "checkbox"; 370 label.classList.add("checkbox-elem");
374 checkboxElement.checked = enabled; 371 element.appendChild(label);
375 checkboxElement.addEventListener("click", this._checkboxClicked.bind(thi s, url), false); 372 label.checkboxElement.addEventListener("click", this._checkboxClicked.bi nd(this, url), false);
376 element._checkboxElement = checkboxElement; 373 element._checkboxElement = label.checkboxElement;
377 374
378 var labelElement = element.createChild("span", "cursor-auto"); 375 var labelElement = label.createChild("span", "cursor-auto");
379 if (!url) 376 if (!url)
380 labelElement.textContent = WebInspector.UIString("Any XHR"); 377 labelElement.textContent = WebInspector.UIString("Any XHR");
381 else 378 else
382 labelElement.textContent = WebInspector.UIString("URL contains \"%s\ "", url); 379 labelElement.textContent = WebInspector.UIString("URL contains \"%s\ "", url);
383 labelElement.addEventListener("dblclick", this._labelClicked.bind(this, url), false); 380 labelElement.addEventListener("dblclick", this._labelClicked.bind(this, url), false);
384 381
385 var currentElement = /** @type {?Element} */ (this.listElement.firstChil d); 382 var currentElement = /** @type {?Element} */ (this.listElement.firstChil d);
386 while (currentElement) { 383 while (currentElement) {
387 if (currentElement._url && currentElement._url < element._url) 384 if (currentElement._url && currentElement._url < element._url)
388 break; 385 break;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 targetRemoved: function(target) { }, 619 targetRemoved: function(target) { },
623 620
624 /** 621 /**
625 * @param {string} name 622 * @param {string} name
626 * @param {!Array.<string>} eventNames 623 * @param {!Array.<string>} eventNames
627 * @param {boolean=} isInstrumentationEvent 624 * @param {boolean=} isInstrumentationEvent
628 * @param {!Array.<string>=} targetNames 625 * @param {!Array.<string>=} targetNames
629 */ 626 */
630 _createCategory: function(name, eventNames, isInstrumentationEvent, targetNa mes) 627 _createCategory: function(name, eventNames, isInstrumentationEvent, targetNa mes)
631 { 628 {
632 var labelNode = createElement("label"); 629 var labelNode = createCheckboxLabel(name);
633 labelNode.textContent = name;
634 630
635 var categoryItem = {}; 631 var categoryItem = {};
636 categoryItem.element = new TreeElement(labelNode); 632 categoryItem.element = new TreeElement(labelNode);
637 this.categoriesTreeOutline.appendChild(categoryItem.element); 633 this.categoriesTreeOutline.appendChild(categoryItem.element);
638 categoryItem.element.listItemElement.classList.add("event-category"); 634 categoryItem.element.listItemElement.classList.add("event-category");
639 categoryItem.element.selectable = true; 635 categoryItem.element.selectable = true;
640 636
641 categoryItem.checkbox = this._createCheckbox(labelNode); 637 categoryItem.checkbox = labelNode.checkboxElement;
642 categoryItem.checkbox.addEventListener("click", this._categoryCheckboxCl icked.bind(this, categoryItem), true); 638 categoryItem.checkbox.addEventListener("click", this._categoryCheckboxCl icked.bind(this, categoryItem), true);
643 639
644 categoryItem.targetNames = this._stringArrayToLowerCase(targetNames || [ WebInspector.EventListenerBreakpointsSidebarPane.eventTargetAny]); 640 categoryItem.targetNames = this._stringArrayToLowerCase(targetNames || [ WebInspector.EventListenerBreakpointsSidebarPane.eventTargetAny]);
645 categoryItem.children = {}; 641 categoryItem.children = {};
646 var category = (isInstrumentationEvent ? WebInspector.EventListenerBreak pointsSidebarPane.categoryInstrumentation : WebInspector.EventListenerBreakpoin tsSidebarPane.categoryListener); 642 var category = (isInstrumentationEvent ? WebInspector.EventListenerBreak pointsSidebarPane.categoryInstrumentation : WebInspector.EventListenerBreakpoin tsSidebarPane.categoryListener);
647 for (var i = 0; i < eventNames.length; ++i) { 643 for (var i = 0; i < eventNames.length; ++i) {
648 var eventName = category + eventNames[i]; 644 var eventName = category + eventNames[i];
649 645
650 var breakpointItem = {}; 646 var breakpointItem = {};
651 var title = WebInspector.EventListenerBreakpointsSidebarPane.eventNa meForUI(eventName); 647 var title = WebInspector.EventListenerBreakpointsSidebarPane.eventNa meForUI(eventName);
652 648
653 labelNode = createElement("label"); 649 labelNode = createCheckboxLabel(title);
654 labelNode.textContent = title; 650 labelNode.classList.add("source-code");
655 651
656 breakpointItem.element = new TreeElement(labelNode); 652 breakpointItem.element = new TreeElement(labelNode);
657 categoryItem.element.appendChild(breakpointItem.element); 653 categoryItem.element.appendChild(breakpointItem.element);
658 654
659 breakpointItem.element.listItemElement.createChild("div", "breakpoin t-hit-marker"); 655 breakpointItem.element.listItemElement.createChild("div", "breakpoin t-hit-marker");
660 breakpointItem.element.listItemElement.classList.add("source-code");
661 breakpointItem.element.selectable = false; 656 breakpointItem.element.selectable = false;
662 657
663 breakpointItem.checkbox = this._createCheckbox(labelNode); 658 breakpointItem.checkbox = labelNode.checkboxElement;
664 breakpointItem.checkbox.addEventListener("click", this._breakpointCh eckboxClicked.bind(this, eventName, categoryItem.targetNames), true); 659 breakpointItem.checkbox.addEventListener("click", this._breakpointCh eckboxClicked.bind(this, eventName, categoryItem.targetNames), true);
665 breakpointItem.parent = categoryItem; 660 breakpointItem.parent = categoryItem;
666 661
667 categoryItem.children[eventName] = breakpointItem; 662 categoryItem.children[eventName] = breakpointItem;
668 } 663 }
669 this._categoryItems.push(categoryItem); 664 this._categoryItems.push(categoryItem);
670 }, 665 },
671 666
672 /** 667 /**
673 * @param {!Array.<string>} array 668 * @param {!Array.<string>} array
674 * @return {!Array.<string>} 669 * @return {!Array.<string>}
675 */ 670 */
676 _stringArrayToLowerCase: function(array) 671 _stringArrayToLowerCase: function(array)
677 { 672 {
678 return array.map(function(value) { 673 return array.map(function(value) {
679 return value.toLowerCase(); 674 return value.toLowerCase();
680 }); 675 });
681 }, 676 },
682 677
683 /**
684 * @param {!Element} labelNode
685 * @return {!Element}
686 */
687 _createCheckbox: function(labelNode)
688 {
689 var checkbox = createElementWithClass("input", "checkbox-elem");
690 checkbox.type = "checkbox";
691 labelNode.insertBefore(checkbox, labelNode.firstChild);
692 return checkbox;
693 },
694
695 _categoryCheckboxClicked: function(categoryItem) 678 _categoryCheckboxClicked: function(categoryItem)
696 { 679 {
697 var checked = categoryItem.checkbox.checked; 680 var checked = categoryItem.checkbox.checked;
698 for (var eventName in categoryItem.children) { 681 for (var eventName in categoryItem.children) {
699 var breakpointItem = categoryItem.children[eventName]; 682 var breakpointItem = categoryItem.children[eventName];
700 if (breakpointItem.checkbox.checked === checked) 683 if (breakpointItem.checkbox.checked === checked)
701 continue; 684 continue;
702 if (checked) 685 if (checked)
703 this._setBreakpoint(eventName, categoryItem.targetNames); 686 this._setBreakpoint(eventName, categoryItem.targetNames);
704 else 687 else
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 var breakpoints = WebInspector.settings.eventListenerBreakpoints.get(); 857 var breakpoints = WebInspector.settings.eventListenerBreakpoints.get();
875 for (var i = 0; i < breakpoints.length; ++i) { 858 for (var i = 0; i < breakpoints.length; ++i) {
876 var breakpoint = breakpoints[i]; 859 var breakpoint = breakpoints[i];
877 if (breakpoint && typeof breakpoint.eventName === "string") 860 if (breakpoint && typeof breakpoint.eventName === "string")
878 this._setBreakpoint(breakpoint.eventName, breakpoint.targetNames , target); 861 this._setBreakpoint(breakpoint.eventName, breakpoint.targetNames , target);
879 } 862 }
880 }, 863 },
881 864
882 __proto__: WebInspector.SidebarPane.prototype 865 __proto__: WebInspector.SidebarPane.prototype
883 } 866 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sources/AdvancedSearchView.js ('k') | Source/devtools/front_end/sources/CallStackSidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698