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

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

Issue 1463143005: DevTools: avoid layout thrashing on Layers panel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not center on reveal when scrolling/searching Created 5 years, 1 month 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 /** 189 /**
190 * @return {boolean} 190 * @return {boolean}
191 */ 191 */
192 selectPrevious: function() 192 selectPrevious: function()
193 { 193 {
194 var nextSelectedElement = this.selectedTreeElement.traversePreviousTreeE lement(true); 194 var nextSelectedElement = this.selectedTreeElement.traversePreviousTreeE lement(true);
195 while (nextSelectedElement && !nextSelectedElement.selectable) 195 while (nextSelectedElement && !nextSelectedElement.selectable)
196 nextSelectedElement = nextSelectedElement.traversePreviousTreeElemen t(!this.expandTreeElementsWhenArrowing); 196 nextSelectedElement = nextSelectedElement.traversePreviousTreeElemen t(!this.expandTreeElementsWhenArrowing);
197 if (nextSelectedElement) { 197 if (nextSelectedElement) {
198 nextSelectedElement.reveal(); 198 nextSelectedElement.reveal(false);
pfeldman 2015/11/21 01:38:35 ditto
199 nextSelectedElement.select(false, true); 199 nextSelectedElement.select(false, true);
200 return true; 200 return true;
201 } 201 }
202 return false; 202 return false;
203 }, 203 },
204 204
205 /** 205 /**
206 * @return {boolean} 206 * @return {boolean}
207 */ 207 */
208 selectNext: function() 208 selectNext: function()
209 { 209 {
210 var nextSelectedElement = this.selectedTreeElement.traverseNextTreeEleme nt(true); 210 var nextSelectedElement = this.selectedTreeElement.traverseNextTreeEleme nt(true);
211 while (nextSelectedElement && !nextSelectedElement.selectable) 211 while (nextSelectedElement && !nextSelectedElement.selectable)
212 nextSelectedElement = nextSelectedElement.traverseNextTreeElement(!t his.expandTreeElementsWhenArrowing); 212 nextSelectedElement = nextSelectedElement.traverseNextTreeElement(!t his.expandTreeElementsWhenArrowing);
213 if (nextSelectedElement) { 213 if (nextSelectedElement) {
214 nextSelectedElement.reveal(); 214 nextSelectedElement.reveal(false);
pfeldman 2015/11/21 01:38:35 ditto
215 nextSelectedElement.select(false, true); 215 nextSelectedElement.select(false, true);
216 return true; 216 return true;
217 } 217 }
218 return false; 218 return false;
219 }, 219 },
220 220
221 /** 221 /**
222 * @param {!Event} event 222 * @param {!Event} event
223 */ 223 */
224 _treeKeyDown: function(event) 224 _treeKeyDown: function(event)
(...skipping 22 matching lines...) Expand all
247 if (this.selectedTreeElement.parent.selectable) { 247 if (this.selectedTreeElement.parent.selectable) {
248 nextSelectedElement = this.selectedTreeElement.parent; 248 nextSelectedElement = this.selectedTreeElement.parent;
249 while (nextSelectedElement && !nextSelectedElement.selectabl e) 249 while (nextSelectedElement && !nextSelectedElement.selectabl e)
250 nextSelectedElement = nextSelectedElement.parent; 250 nextSelectedElement = nextSelectedElement.parent;
251 handled = nextSelectedElement ? true : false; 251 handled = nextSelectedElement ? true : false;
252 } else if (this.selectedTreeElement.parent) 252 } else if (this.selectedTreeElement.parent)
253 this.selectedTreeElement.parent.collapse(); 253 this.selectedTreeElement.parent.collapse();
254 } 254 }
255 } else if (event.keyIdentifier === "Right") { 255 } else if (event.keyIdentifier === "Right") {
256 if (!this.selectedTreeElement.revealed()) { 256 if (!this.selectedTreeElement.revealed()) {
257 this.selectedTreeElement.reveal(); 257 this.selectedTreeElement.reveal(false);
pfeldman 2015/11/21 01:38:35 ditto
258 handled = true; 258 handled = true;
259 } else if (this.selectedTreeElement._expandable) { 259 } else if (this.selectedTreeElement._expandable) {
260 handled = true; 260 handled = true;
261 if (this.selectedTreeElement.expanded) { 261 if (this.selectedTreeElement.expanded) {
262 nextSelectedElement = this.selectedTreeElement.firstChild(); 262 nextSelectedElement = this.selectedTreeElement.firstChild();
263 while (nextSelectedElement && !nextSelectedElement.selectabl e) 263 while (nextSelectedElement && !nextSelectedElement.selectabl e)
264 nextSelectedElement = nextSelectedElement.nextSibling; 264 nextSelectedElement = nextSelectedElement.nextSibling;
265 handled = nextSelectedElement ? true : false; 265 handled = nextSelectedElement ? true : false;
266 } else { 266 } else {
267 if (event.altKey) 267 if (event.altKey)
268 this.selectedTreeElement.expandRecursively(); 268 this.selectedTreeElement.expandRecursively();
269 else 269 else
270 this.selectedTreeElement.expand(); 270 this.selectedTreeElement.expand();
271 } 271 }
272 } 272 }
273 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 / * Delete */) 273 } else if (event.keyCode === 8 /* Backspace */ || event.keyCode === 46 / * Delete */)
274 handled = this.selectedTreeElement.ondelete(); 274 handled = this.selectedTreeElement.ondelete();
275 else if (isEnterKey(event)) 275 else if (isEnterKey(event))
276 handled = this.selectedTreeElement.onenter(); 276 handled = this.selectedTreeElement.onenter();
277 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code ) 277 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Space.code )
278 handled = this.selectedTreeElement.onspace(); 278 handled = this.selectedTreeElement.onspace();
279 279
280 if (nextSelectedElement) { 280 if (nextSelectedElement) {
281 nextSelectedElement.reveal(); 281 nextSelectedElement.reveal(false);
pfeldman 2015/11/21 01:38:35 ditto
282 nextSelectedElement.select(false, true); 282 nextSelectedElement.select(false, true);
283 } 283 }
284 284
285 if (handled) 285 if (handled)
286 event.consume(true); 286 event.consume(true);
287 }, 287 },
288 288
289 /**
290 * @param {!TreeElement} treeElement
291 * @param {boolean} center
292 */
293 _deferredScrollIntoView: function(treeElement, center)
294 {
295 if (!this._treeElementToScrollIntoView)
296 this.element.window().requestAnimationFrame(deferredScrollIntoView.b ind(this));
297 this._treeElementToScrollIntoView = treeElement;
298 this._centerUponScrollIntoView = center;
299 /**
300 * @this {TreeOutline}
301 */
302 function deferredScrollIntoView()
303 {
304 this._treeElementToScrollIntoView.listItemElement.scrollIntoViewIfNe eded(this._centerUponScrollIntoView);
305 delete this._treeElementToScrollIntoView;
306 delete this._centerUponScrollIntoView;
307 }
308 },
309
289 __proto__: WebInspector.Object.prototype 310 __proto__: WebInspector.Object.prototype
290 } 311 }
291 312
292 /** 313 /**
293 * @constructor 314 * @constructor
294 * @extends {TreeOutline} 315 * @extends {TreeOutline}
295 * @param {string=} className 316 * @param {string=} className
296 */ 317 */
297 function TreeOutlineInShadow(className) 318 function TreeOutlineInShadow(className)
298 { 319 {
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 maxDepth = 3; 866 maxDepth = 3;
846 867
847 while (item) { 868 while (item) {
848 if (depth < maxDepth) 869 if (depth < maxDepth)
849 item.expand(); 870 item.expand();
850 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth) , info); 871 item = item.traverseNextTreeElement(false, this, (depth >= maxDepth) , info);
851 depth += info.depthChange; 872 depth += info.depthChange;
852 } 873 }
853 }, 874 },
854 875
855 reveal: function() 876 /**
877 * @param {boolean=} center
878 */
879 reveal: function(center)
856 { 880 {
857 var currentAncestor = this.parent; 881 var currentAncestor = this.parent;
858 while (currentAncestor && !currentAncestor.root) { 882 while (currentAncestor && !currentAncestor.root) {
859 if (!currentAncestor.expanded) 883 if (!currentAncestor.expanded)
860 currentAncestor.expand(); 884 currentAncestor.expand();
861 currentAncestor = currentAncestor.parent; 885 currentAncestor = currentAncestor.parent;
862 } 886 }
863 887
864 this.listItemElement.scrollIntoViewIfNeeded(); 888 this.treeOutline._deferredScrollIntoView(this, center || typeof center = == "undefined");
865
866 this.onreveal();
867 }, 889 },
868 890
869 /** 891 /**
870 * @return {boolean} 892 * @return {boolean}
871 */ 893 */
872 revealed: function() 894 revealed: function()
873 { 895 {
874 var currentAncestor = this.parent; 896 var currentAncestor = this.parent;
875 while (currentAncestor && !currentAncestor.root) { 897 while (currentAncestor && !currentAncestor.root) {
876 if (!currentAncestor.expanded) 898 if (!currentAncestor.expanded)
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 1021
1000 /** 1022 /**
1001 * @param {!Event} e 1023 * @param {!Event} e
1002 * @return {boolean} 1024 * @return {boolean}
1003 */ 1025 */
1004 ondblclick: function(e) 1026 ondblclick: function(e)
1005 { 1027 {
1006 return false; 1028 return false;
1007 }, 1029 },
1008 1030
1009 onreveal: function()
1010 {
1011 },
1012
1013 /** 1031 /**
1014 * @param {boolean=} selectedByUser 1032 * @param {boolean=} selectedByUser
1015 * @return {boolean} 1033 * @return {boolean}
1016 */ 1034 */
1017 onselect: function(selectedByUser) 1035 onselect: function(selectedByUser)
1018 { 1036 {
1019 return false; 1037 return false;
1020 }, 1038 },
1021 1039
1022 /** 1040 /**
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 isEventWithinDisclosureTriangle: function(event) 1111 isEventWithinDisclosureTriangle: function(event)
1094 { 1112 {
1095 // FIXME: We should not use getComputedStyle(). For that we need to get rid of using ::before for disclosure triangle. (http://webk.it/74446) 1113 // FIXME: We should not use getComputedStyle(). For that we need to get rid of using ::before for disclosure triangle. (http://webk.it/74446)
1096 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi ngLeft; 1114 var paddingLeftValue = window.getComputedStyle(this._listItemNode).paddi ngLeft;
1097 console.assert(paddingLeftValue.endsWith("px")); 1115 console.assert(paddingLeftValue.endsWith("px"));
1098 var computedLeftPadding = parseFloat(paddingLeftValue); 1116 var computedLeftPadding = parseFloat(paddingLeftValue);
1099 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding; 1117 var left = this._listItemNode.totalOffsetLeft() + computedLeftPadding;
1100 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo ggleWidth && this._expandable; 1118 return event.pageX >= left && event.pageX <= left + TreeElement._ArrowTo ggleWidth && this._expandable;
1101 } 1119 }
1102 } 1120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698