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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js

Issue 2564433004: DevTools: migrate last usages of samllIcons.png to UI.Icon (Closed)
Patch Set: better css Created 4 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/treeoutline.css ('k') | 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 26 matching lines...) Expand all
37 super(); 37 super();
38 this._createRootElement(); 38 this._createRootElement();
39 39
40 this.selectedTreeElement = null; 40 this.selectedTreeElement = null;
41 this.expandTreeElementsWhenArrowing = false; 41 this.expandTreeElementsWhenArrowing = false;
42 /** @type {?function(!TreeElement, !TreeElement):number} */ 42 /** @type {?function(!TreeElement, !TreeElement):number} */
43 this._comparator = null; 43 this._comparator = null;
44 44
45 this.contentElement = this._rootElement._childrenListNode; 45 this.contentElement = this._rootElement._childrenListNode;
46 this.contentElement.addEventListener('keydown', this._treeKeyDown.bind(this) , true); 46 this.contentElement.addEventListener('keydown', this._treeKeyDown.bind(this) , true);
47 this.contentElement.addEventListener('focus', setFocused.bind(this, true));
dgozman 2016/12/09 22:04:06 Forgot to pass false for capture here and below.
lushnikov 2016/12/10 00:52:50 Done.
48 this.contentElement.addEventListener('blur', setFocused.bind(this, false));
47 49
48 this.setFocusable(!nonFocusable); 50 this.setFocusable(!nonFocusable);
49 51
50 this.element = this.contentElement; 52 this.element = this.contentElement;
53
54 /**
55 * @param {boolean} isFocused
56 * @this {TreeOutline}
57 */
58 function setFocused(isFocused) {
59 this._focused = isFocused;
60 if (this.selectedTreeElement)
61 this.selectedTreeElement._setFocused(this._focused);
62 }
51 } 63 }
52 64
53 _createRootElement() { 65 _createRootElement() {
54 this._rootElement = new TreeElement(); 66 this._rootElement = new TreeElement();
55 this._rootElement.treeOutline = this; 67 this._rootElement.treeOutline = this;
56 this._rootElement.root = true; 68 this._rootElement.root = true;
57 this._rootElement.selectable = false; 69 this._rootElement.selectable = false;
58 this._rootElement.expanded = true; 70 this._rootElement.expanded = true;
59 this._rootElement._childrenListNode.classList.remove('children'); 71 this._rootElement._childrenListNode.classList.remove('children');
60 } 72 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 * @param {boolean=} expandable 313 * @param {boolean=} expandable
302 */ 314 */
303 constructor(title, expandable) { 315 constructor(title, expandable) {
304 /** @type {?TreeOutline} */ 316 /** @type {?TreeOutline} */
305 this.treeOutline = null; 317 this.treeOutline = null;
306 this.parent = null; 318 this.parent = null;
307 this.previousSibling = null; 319 this.previousSibling = null;
308 this.nextSibling = null; 320 this.nextSibling = null;
309 321
310 this._listItemNode = createElement('li'); 322 this._listItemNode = createElement('li');
323 this._titleElement = this._listItemNode.createChild('span', 'tree-element-ti tle');
311 this._listItemNode.treeElement = this; 324 this._listItemNode.treeElement = this;
312 if (title) 325 if (title)
313 this.title = title; 326 this.title = title;
314 this._listItemNode.addEventListener('mousedown', this._handleMouseDown.bind( this), false); 327 this._listItemNode.addEventListener('mousedown', this._handleMouseDown.bind( this), false);
315 this._listItemNode.addEventListener('click', this._treeElementToggled.bind(t his), false); 328 this._listItemNode.addEventListener('click', this._treeElementToggled.bind(t his), false);
316 this._listItemNode.addEventListener('dblclick', this._handleDoubleClick.bind (this), false); 329 this._listItemNode.addEventListener('dblclick', this._handleDoubleClick.bind (this), false);
317 330
318 this._childrenListNode = createElement('ol'); 331 this._childrenListNode = createElement('ol');
319 this._childrenListNode.parentTreeElement = this; 332 this._childrenListNode.parentTreeElement = this;
320 this._childrenListNode.classList.add('children'); 333 this._childrenListNode.classList.add('children');
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 } 558 }
546 559
547 set selectable(x) { 560 set selectable(x) {
548 this._selectable = x; 561 this._selectable = x;
549 } 562 }
550 563
551 get listItemElement() { 564 get listItemElement() {
552 return this._listItemNode; 565 return this._listItemNode;
553 } 566 }
554 567
568 /**
569 * @return {!Element}
570 */
571 titleElement() {
572 return this._titleElement;
573 }
574
555 get childrenListElement() { 575 get childrenListElement() {
556 return this._childrenListNode; 576 return this._childrenListNode;
557 } 577 }
558 578
559 /** 579 /**
560 * @return {string|!Node} 580 * @return {string|!Node}
561 */ 581 */
562 get title() { 582 get title() {
563 return this._title; 583 return this._title;
564 } 584 }
565 585
566 /** 586 /**
567 * @param {string|!Node} x 587 * @param {string|!Node} x
568 */ 588 */
569 set title(x) { 589 set title(x) {
570 if (this._title === x) 590 if (this._title === x)
571 return; 591 return;
572 this._title = x; 592 this._title = x;
573 593
574 if (typeof x === 'string') { 594 if (typeof x === 'string') {
575 this._titleElement = createElementWithClass('span', 'tree-element-title');
576 this._titleElement.textContent = x; 595 this._titleElement.textContent = x;
577 this.tooltip = x; 596 this.tooltip = x;
578 } else { 597 } else {
579 this._titleElement = x; 598 this._titleElement = x;
580 this.tooltip = ''; 599 this.tooltip = '';
581 } 600 }
582 601
583 this._listItemNode.removeChildren(); 602 this._listItemNode.removeChildren();
584 if (this._iconElement) 603 if (this._iconElement)
585 this._listItemNode.appendChild(this._iconElement); 604 this._listItemNode.appendChild(this._iconElement);
586 605
587 this._listItemNode.appendChild(this._titleElement); 606 this._listItemNode.appendChild(this._titleElement);
607 if (this._trailingIconsElement)
608 this._listItemNode.appendChild(this._trailingIconsElement);
588 this._ensureSelection(); 609 this._ensureSelection();
589 } 610 }
590 611
591 /** 612 /**
592 * @return {string} 613 * @return {string}
593 */ 614 */
594 titleAsText() { 615 titleAsText() {
595 if (!this._title) 616 if (!this._title)
596 return ''; 617 return '';
597 if (typeof this._title === 'string') 618 if (typeof this._title === 'string')
(...skipping 11 matching lines...) Expand all
609 630
610 createIcon() { 631 createIcon() {
611 if (!this._iconElement) { 632 if (!this._iconElement) {
612 this._iconElement = createElementWithClass('div', 'icon'); 633 this._iconElement = createElementWithClass('div', 'icon');
613 this._listItemNode.insertBefore(this._iconElement, this._listItemNode.firs tChild); 634 this._listItemNode.insertBefore(this._iconElement, this._listItemNode.firs tChild);
614 this._ensureSelection(); 635 this._ensureSelection();
615 } 636 }
616 } 637 }
617 638
618 /** 639 /**
640 * @param {!Array<!UI.Icon>} icons
641 */
642 setTrailingIcons(icons) {
643 if (!this._trailingIconsElement && !icons.length)
644 return;
645 if (!this._trailingIconsElement) {
646 this._trailingIconsElement = createElementWithClass('div', 'icons-containe r');
647 this._listItemNode.appendChild(this._trailingIconsElement);
648 this._ensureSelection();
649 }
650 this._trailingIconsElement.removeChildren();
651 for (var icon of icons)
652 this._trailingIconsElement.appendChild(icon);
653 }
654
655 /**
656 * @param {boolean} focused
657 */
658 _setFocused(focused) {
659 this._focused = focused;
660 this._listItemNode.classList.toggle('force-white-icons', focused);
661 }
662
663 /**
619 * @return {string} 664 * @return {string}
620 */ 665 */
621 get tooltip() { 666 get tooltip() {
622 return this._tooltip || ''; 667 return this._tooltip || '';
623 } 668 }
624 669
625 /** 670 /**
626 * @param {string} x 671 * @param {string} x
627 */ 672 */
628 set tooltip(x) { 673 set tooltip(x) {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 this.selected = true; 983 this.selected = true;
939 984
940 if (!omitFocus) 985 if (!omitFocus)
941 this.treeOutline.focus(); 986 this.treeOutline.focus();
942 987
943 // Focusing on another node may detach "this" from tree. 988 // Focusing on another node may detach "this" from tree.
944 if (!this.treeOutline) 989 if (!this.treeOutline)
945 return false; 990 return false;
946 this.treeOutline.selectedTreeElement = this; 991 this.treeOutline.selectedTreeElement = this;
947 this._listItemNode.classList.add('selected'); 992 this._listItemNode.classList.add('selected');
993 this._setFocused(this.treeOutline._focused);
948 this.treeOutline.dispatchEventToListeners(TreeOutline.Events.ElementSelected , this); 994 this.treeOutline.dispatchEventToListeners(TreeOutline.Events.ElementSelected , this);
949 return this.onselect(selectedByUser); 995 return this.onselect(selectedByUser);
950 } 996 }
951 997
952 /** 998 /**
953 * @param {boolean=} omitFocus 999 * @param {boolean=} omitFocus
954 */ 1000 */
955 revealAndSelect(omitFocus) { 1001 revealAndSelect(omitFocus) {
956 this.reveal(true); 1002 this.reveal(true);
957 this.select(omitFocus); 1003 this.select(omitFocus);
958 } 1004 }
959 1005
960 /** 1006 /**
961 * @param {boolean=} supressOnDeselect 1007 * @param {boolean=} supressOnDeselect
962 */ 1008 */
963 deselect(supressOnDeselect) { 1009 deselect(supressOnDeselect) {
964 if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !t his.selected) 1010 if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this || !t his.selected)
965 return; 1011 return;
966 1012
967 this.selected = false; 1013 this.selected = false;
968 this.treeOutline.selectedTreeElement = null; 1014 this.treeOutline.selectedTreeElement = null;
969 this._listItemNode.classList.remove('selected'); 1015 this._listItemNode.classList.remove('selected');
1016 this._setFocused(false);
970 } 1017 }
971 1018
972 _populateIfNeeded() { 1019 _populateIfNeeded() {
973 if (this.treeOutline && this._expandable && !this._children) { 1020 if (this.treeOutline && this._expandable && !this._children) {
974 this._children = []; 1021 this._children = [];
975 this.onpopulate(); 1022 this.onpopulate();
976 } 1023 }
977 } 1024 }
978 1025
979 onpopulate() { 1026 onpopulate() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; 1158 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft;
1112 console.assert(paddingLeftValue.endsWith('px')); 1159 console.assert(paddingLeftValue.endsWith('px'));
1113 var computedLeftPadding = parseFloat(paddingLeftValue); 1160 var computedLeftPadding = parseFloat(paddingLeftValue);
1114 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; 1161 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
1115 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowToggle Width && this._expandable; 1162 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowToggle Width && this._expandable;
1116 } 1163 }
1117 }; 1164 };
1118 1165
1119 /** @const */ 1166 /** @const */
1120 TreeElement._ArrowToggleWidth = 10; 1167 TreeElement._ArrowToggleWidth = 10;
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/treeoutline.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698