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

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

Issue 2623053002: [Devtools] Fix left margin for selection element (Closed)
Patch Set: Remove leading underscore Created 3 years, 11 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) 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 * @param {(string|!Node)=} title 312 * @param {(string|!Node)=} title
313 * @param {boolean=} expandable 313 * @param {boolean=} expandable
314 */ 314 */
315 constructor(title, expandable) { 315 constructor(title, expandable) {
316 /** @type {?UI.TreeOutline} */ 316 /** @type {?UI.TreeOutline} */
317 this.treeOutline = null; 317 this.treeOutline = null;
318 this.parent = null; 318 this.parent = null;
319 this.previousSibling = null; 319 this.previousSibling = null;
320 this.nextSibling = null; 320 this.nextSibling = null;
321 321
322 // Adjust based on your CSS, if modified from treeoutline.css
323 // Check the padding-left for the li element
324 this.paddingSize = 12;
dgozman 2017/01/13 01:53:42 Default should be zero preserving -10000px we have
aboxhall 2017/01/13 02:22:03 Done.
325
322 this._listItemNode = createElement('li'); 326 this._listItemNode = createElement('li');
323 this._titleElement = this._listItemNode.createChild('span', 'tree-element-ti tle'); 327 this._titleElement = this._listItemNode.createChild('span', 'tree-element-ti tle');
324 this._listItemNode.treeElement = this; 328 this._listItemNode.treeElement = this;
325 if (title) 329 if (title)
326 this.title = title; 330 this.title = title;
327 this._listItemNode.addEventListener('mousedown', this._handleMouseDown.bind( this), false); 331 this._listItemNode.addEventListener('mousedown', this._handleMouseDown.bind( this), false);
328 this._listItemNode.addEventListener('click', this._treeElementToggled.bind(t his), false); 332 this._listItemNode.addEventListener('click', this._treeElementToggled.bind(t his), false);
329 this._listItemNode.addEventListener('dblclick', this._handleDoubleClick.bind (this), false); 333 this._listItemNode.addEventListener('dblclick', this._handleDoubleClick.bind (this), false);
330 334
331 this._childrenListNode = createElement('ol'); 335 this._childrenListNode = createElement('ol');
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 this._childrenListNode.classList.toggle('hidden', x); 749 this._childrenListNode.classList.toggle('hidden', x);
746 } 750 }
747 751
748 invalidateChildren() { 752 invalidateChildren() {
749 if (this._children) { 753 if (this._children) {
750 this.removeChildren(); 754 this.removeChildren();
751 this._children = null; 755 this._children = null;
752 } 756 }
753 } 757 }
754 758
759 /**
760 * @return {number}
761 */
762 computeLeftIndent() {
763 var treeElement = this.parent;
764 var depth = 0;
765 while (treeElement !== null) {
766 depth++;
767 treeElement = treeElement.parent;
768 }
769
770 return this.paddingSize * (depth - 1) + 4;
771 }
772
755 _ensureSelection() { 773 _ensureSelection() {
756 if (!this.treeOutline || !this.treeOutline._renderSelection) 774 if (!this.treeOutline || !this.treeOutline._renderSelection)
757 return; 775 return;
758 if (!this._selectionElement) 776 if (!this._selectionElement)
759 this._selectionElement = createElementWithClass('div', 'selection fill'); 777 this._selectionElement = createElementWithClass('div', 'selection fill');
778 this._selectionElement.style.setProperty('margin-left', (-this.computeLeftIn dent()) + 'px');
760 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement .firstChild); 779 this._listItemNode.insertBefore(this._selectionElement, this.listItemElement .firstChild);
761 } 780 }
762 781
763 /** 782 /**
764 * @param {!Event} event 783 * @param {!Event} event
765 */ 784 */
766 _treeElementToggled(event) { 785 _treeElementToggled(event) {
767 var element = event.currentTarget; 786 var element = event.currentTarget;
768 if (element.treeElement !== this || element.hasSelection()) 787 if (element.treeElement !== this || element.hasSelection())
769 return; 788 return;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft; 1196 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddingLe ft;
1178 console.assert(paddingLeftValue.endsWith('px')); 1197 console.assert(paddingLeftValue.endsWith('px'));
1179 var computedLeftPadding = parseFloat(paddingLeftValue); 1198 var computedLeftPadding = parseFloat(paddingLeftValue);
1180 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; 1199 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
1181 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable; 1200 return event.pageX >= left && event.pageX <= left + UI.TreeElement._ArrowTog gleWidth && this._expandable;
1182 } 1201 }
1183 }; 1202 };
1184 1203
1185 /** @const */ 1204 /** @const */
1186 UI.TreeElement._ArrowToggleWidth = 10; 1205 UI.TreeElement._ArrowToggleWidth = 10;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698