Chromium Code Reviews

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

Issue 1461283004: DevTools: defer reveal in TreeOutline using rAF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/SidebarTreeElement.js ('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 268 matching lines...)
279 279
280 if (nextSelectedElement) { 280 if (nextSelectedElement) {
281 nextSelectedElement.reveal(); 281 nextSelectedElement.reveal();
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...)
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);
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 39 matching lines...)
916 this._listItemNode.classList.add("selected"); 938 this._listItemNode.classList.add("selected");
917 this.treeOutline.dispatchEventToListeners(TreeOutline.Events.ElementSele cted, this); 939 this.treeOutline.dispatchEventToListeners(TreeOutline.Events.ElementSele cted, this);
918 return this.onselect(selectedByUser); 940 return this.onselect(selectedByUser);
919 }, 941 },
920 942
921 /** 943 /**
922 * @param {boolean=} omitFocus 944 * @param {boolean=} omitFocus
923 */ 945 */
924 revealAndSelect: function(omitFocus) 946 revealAndSelect: function(omitFocus)
925 { 947 {
926 this.reveal(); 948 this.reveal(true);
927 this.select(omitFocus); 949 this.select(omitFocus);
928 }, 950 },
929 951
930 /** 952 /**
931 * @param {boolean=} supressOnDeselect 953 * @param {boolean=} supressOnDeselect
932 */ 954 */
933 deselect: function(supressOnDeselect) 955 deselect: function(supressOnDeselect)
934 { 956 {
935 if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this | | !this.selected) 957 if (!this.treeOutline || this.treeOutline.selectedTreeElement !== this | | !this.selected)
936 return; 958 return;
(...skipping 62 matching lines...)
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...)
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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/SidebarTreeElement.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine