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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/profiler/ProfilesPanel.js

Issue 2337803003: [DevTools] Migrate ProfilesPanel to TreeOutlineInShadow. (Closed)
Patch Set: Created 4 years, 3 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) 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 this.registerRequiredCSS("ui/panelEnablerView.css"); 438 this.registerRequiredCSS("ui/panelEnablerView.css");
439 this.registerRequiredCSS("profiler/heapProfiler.css"); 439 this.registerRequiredCSS("profiler/heapProfiler.css");
440 this.registerRequiredCSS("profiler/profilesPanel.css"); 440 this.registerRequiredCSS("profiler/profilesPanel.css");
441 this.registerRequiredCSS("components/objectValue.css"); 441 this.registerRequiredCSS("components/objectValue.css");
442 442
443 var mainContainer = new WebInspector.VBox(); 443 var mainContainer = new WebInspector.VBox();
444 this.splitWidget().setMainWidget(mainContainer); 444 this.splitWidget().setMainWidget(mainContainer);
445 445
446 this.profilesItemTreeElement = new WebInspector.ProfilesSidebarTreeElement(t his); 446 this.profilesItemTreeElement = new WebInspector.ProfilesSidebarTreeElement(t his);
447 447
448 this._sidebarTree = new TreeOutline(); 448 this._sidebarTree = new TreeOutlineInShadow();
449 this._sidebarTree.element.classList.add("sidebar-tree"); 449 this._sidebarTree.registerRequiredCSS("profiler/profilesSidebarTree.css");
450 this.panelSidebarElement().appendChild(this._sidebarTree.element); 450 this.panelSidebarElement().appendChild(this._sidebarTree.element);
451 this.setDefaultFocusedElement(this._sidebarTree.element); 451 this.setDefaultFocusedElement(this._sidebarTree.element);
452 452
453 this._sidebarTree.appendChild(this.profilesItemTreeElement); 453 this._sidebarTree.appendChild(this.profilesItemTreeElement);
454 454
455 this.profileViews = createElement("div"); 455 this.profileViews = createElement("div");
456 this.profileViews.id = "profile-views"; 456 this.profileViews.id = "profile-views";
457 this.profileViews.classList.add("vbox"); 457 this.profileViews.classList.add("vbox");
458 mainContainer.element.appendChild(this.profileViews); 458 mainContainer.element.appendChild(this.profileViews);
459 459
(...skipping 23 matching lines...) Expand all
483 this._profileToView = []; 483 this._profileToView = [];
484 this._typeIdToSidebarSection = {}; 484 this._typeIdToSidebarSection = {};
485 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); 485 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes();
486 for (var i = 0; i < types.length; i++) 486 for (var i = 0; i < types.length; i++)
487 this._registerProfileType(types[i]); 487 this._registerProfileType(types[i]);
488 this._launcherView.restoreSelectedProfileType(); 488 this._launcherView.restoreSelectedProfileType();
489 this.profilesItemTreeElement.select(); 489 this.profilesItemTreeElement.select();
490 this._showLauncherView(); 490 this._showLauncherView();
491 491
492 this._createFileSelectorElement(); 492 this._createFileSelectorElement();
493 this.element.addEventListener("contextmenu", this._handleContextMenuEvent.bi nd(this), true); 493 this.element.addEventListener("contextmenu", this._handleContextMenuEvent.bi nd(this), false);
494 494
495 this.contentElement.addEventListener("keydown", this._onKeyDown.bind(this), false); 495 this.contentElement.addEventListener("keydown", this._onKeyDown.bind(this), false);
496 496
497 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.SuspendStateChanged, this._onSuspendStateChanged, this); 497 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.SuspendStateChanged, this._onSuspendStateChanged, this);
498 } 498 }
499 499
500 WebInspector.ProfilesPanel.prototype = { 500 WebInspector.ProfilesPanel.prototype = {
501 /** 501 /**
502 * @param {!Event} event 502 * @param {!Event} event
503 */ 503 */
(...skipping 15 matching lines...) Expand all
519 searchableView: function() 519 searchableView: function()
520 { 520 {
521 return this.visibleView && this.visibleView.searchableView ? this.visibl eView.searchableView() : null; 521 return this.visibleView && this.visibleView.searchableView ? this.visibl eView.searchableView() : null;
522 }, 522 },
523 523
524 _createFileSelectorElement: function() 524 _createFileSelectorElement: function()
525 { 525 {
526 if (this._fileSelectorElement) 526 if (this._fileSelectorElement)
527 this.element.removeChild(this._fileSelectorElement); 527 this.element.removeChild(this._fileSelectorElement);
528 this._fileSelectorElement = WebInspector.createFileSelectorElement(this. _loadFromFile.bind(this)); 528 this._fileSelectorElement = WebInspector.createFileSelectorElement(this. _loadFromFile.bind(this));
529 WebInspector.ProfilesPanel._fileSelectorElement = this._fileSelectorElem ent;
529 this.element.appendChild(this._fileSelectorElement); 530 this.element.appendChild(this._fileSelectorElement);
530 }, 531 },
531 532
532 _findProfileTypeByExtension: function(fileName) 533 _findProfileTypeByExtension: function(fileName)
533 { 534 {
534 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); 535 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes();
535 for (var i = 0; i < types.length; i++) { 536 for (var i = 0; i < types.length; i++) {
536 var type = types[i]; 537 var type = types[i];
537 var extension = type.fileExtension(); 538 var extension = type.fileExtension();
538 if (!extension) 539 if (!extension)
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 676
676 /** 677 /**
677 * @param {!WebInspector.ProfileType} profileType 678 * @param {!WebInspector.ProfileType} profileType
678 */ 679 */
679 _registerProfileType: function(profileType) 680 _registerProfileType: function(profileType)
680 { 681 {
681 this._launcherView.addProfileType(profileType); 682 this._launcherView.addProfileType(profileType);
682 var profileTypeSection = new WebInspector.ProfileTypeSidebarSection(this , profileType); 683 var profileTypeSection = new WebInspector.ProfileTypeSidebarSection(this , profileType);
683 this._typeIdToSidebarSection[profileType.id] = profileTypeSection; 684 this._typeIdToSidebarSection[profileType.id] = profileTypeSection;
684 this._sidebarTree.appendChild(profileTypeSection); 685 this._sidebarTree.appendChild(profileTypeSection);
685 profileTypeSection.childrenListElement.addEventListener("contextmenu", t his._handleContextMenuEvent.bind(this), true); 686 profileTypeSection.childrenListElement.addEventListener("contextmenu", t his._handleContextMenuEvent.bind(this), false);
686 687
687 /** 688 /**
688 * @param {!WebInspector.Event} event 689 * @param {!WebInspector.Event} event
689 * @this {WebInspector.ProfilesPanel} 690 * @this {WebInspector.ProfilesPanel}
690 */ 691 */
691 function onAddProfileHeader(event) 692 function onAddProfileHeader(event)
692 { 693 {
693 this._addProfileHeader(/** @type {!WebInspector.ProfileHeader} */ (e vent.data)); 694 this._addProfileHeader(/** @type {!WebInspector.ProfileHeader} */ (e vent.data));
694 } 695 }
695 696
(...skipping 23 matching lines...) Expand all
719 var profiles = profileType.getProfiles(); 720 var profiles = profileType.getProfiles();
720 for (var i = 0; i < profiles.length; i++) 721 for (var i = 0; i < profiles.length; i++)
721 this._addProfileHeader(profiles[i]); 722 this._addProfileHeader(profiles[i]);
722 }, 723 },
723 724
724 /** 725 /**
725 * @param {!Event} event 726 * @param {!Event} event
726 */ 727 */
727 _handleContextMenuEvent: function(event) 728 _handleContextMenuEvent: function(event)
728 { 729 {
729 var element = event.srcElement;
730 while (element && !element.treeElement && element !== this.element)
731 element = element.parentElement;
732 if (!element)
733 return;
734 if (element.treeElement && element.treeElement.handleContextMenuEvent) {
735 element.treeElement.handleContextMenuEvent(event, this);
736 return;
737 }
738
739 var contextMenu = new WebInspector.ContextMenu(event); 730 var contextMenu = new WebInspector.ContextMenu(event);
740 if (this.visibleView instanceof WebInspector.HeapSnapshotView) { 731 if (this.visibleView instanceof WebInspector.HeapSnapshotView) {
741 this.visibleView.populateContextMenu(contextMenu, event); 732 this.visibleView.populateContextMenu(contextMenu, event);
742 } 733 }
743 if (element !== this.element || event.srcElement === this.panelSidebarEl ement()) { 734 if (this.panelSidebarElement().isSelfOrAncestor(event.srcElement))
744 contextMenu.appendItem(WebInspector.UIString("Load\u2026"), this._fi leSelectorElement.click.bind(this._fileSelectorElement)); 735 contextMenu.appendItem(WebInspector.UIString("Load\u2026"), this._fi leSelectorElement.click.bind(this._fileSelectorElement));
745 }
746 contextMenu.show(); 736 contextMenu.show();
747 }, 737 },
748 738
749 showLoadFromFileDialog: function() 739 showLoadFromFileDialog: function()
750 { 740 {
751 this._fileSelectorElement.click(); 741 this._fileSelectorElement.click();
752 }, 742 },
753 743
754 /** 744 /**
755 * @param {!WebInspector.ProfileHeader} profile 745 * @param {!WebInspector.ProfileHeader} profile
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 926
937 /** 927 /**
938 * @constructor 928 * @constructor
939 * @extends {TreeElement} 929 * @extends {TreeElement}
940 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate 930 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate
941 * @param {!WebInspector.ProfileType} profileType 931 * @param {!WebInspector.ProfileType} profileType
942 */ 932 */
943 WebInspector.ProfileTypeSidebarSection = function(dataDisplayDelegate, profileTy pe) 933 WebInspector.ProfileTypeSidebarSection = function(dataDisplayDelegate, profileTy pe)
944 { 934 {
945 TreeElement.call(this, profileType.treeItemTitle.escapeHTML(), true); 935 TreeElement.call(this, profileType.treeItemTitle.escapeHTML(), true);
936 this.selectable = false;
946 this._dataDisplayDelegate = dataDisplayDelegate; 937 this._dataDisplayDelegate = dataDisplayDelegate;
947 /** @type {!Array<!WebInspector.ProfileSidebarTreeElement>} */ 938 /** @type {!Array<!WebInspector.ProfileSidebarTreeElement>} */
948 this._profileTreeElements = []; 939 this._profileTreeElements = [];
949 /** @type {!Object<string, !WebInspector.ProfileTypeSidebarSection.ProfileGr oup>} */ 940 /** @type {!Object<string, !WebInspector.ProfileTypeSidebarSection.ProfileGr oup>} */
950 this._profileGroups = {}; 941 this._profileGroups = {};
951 this.expand(); 942 this.expand();
952 this.hidden = true; 943 this.hidden = true;
953 } 944 }
954 945
955 /** 946 /**
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 return i; 1068 return i;
1078 } 1069 }
1079 return -1; 1070 return -1;
1080 }, 1071 },
1081 1072
1082 /** 1073 /**
1083 * @override 1074 * @override
1084 */ 1075 */
1085 onattach: function() 1076 onattach: function()
1086 { 1077 {
1087 this.listItemElement.classList.add("sidebar-tree-section"); 1078 this.listItemElement.classList.add("profiles-tree-section");
1088 }, 1079 },
1089 1080
1090 __proto__: TreeElement.prototype 1081 __proto__: TreeElement.prototype
1091 } 1082 }
1092 1083
1093 1084
1094 /** 1085 /**
1095 * @constructor 1086 * @constructor
1096 * @implements {WebInspector.ContextMenu.Provider} 1087 * @implements {WebInspector.ContextMenu.Provider}
1097 */ 1088 */
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 { 1187 {
1197 this.profile.profileType().removeProfile(this.profile); 1188 this.profile.profileType().removeProfile(this.profile);
1198 return true; 1189 return true;
1199 }, 1190 },
1200 1191
1201 /** 1192 /**
1202 * @override 1193 * @override
1203 */ 1194 */
1204 onattach: function() 1195 onattach: function()
1205 { 1196 {
1206 this.listItemElement.classList.add("sidebar-tree-item");
1207 if (this._className) 1197 if (this._className)
1208 this.listItemElement.classList.add(this._className); 1198 this.listItemElement.classList.add(this._className);
1209 if (this._small) 1199 if (this._small)
1210 this.listItemElement.classList.add("small"); 1200 this.listItemElement.classList.add("small");
1211 this.listItemElement.appendChildren(this._iconElement, this._titlesEleme nt); 1201 this.listItemElement.appendChildren(this._iconElement, this._titlesEleme nt);
1202 this.listItemElement.addEventListener("contextmenu", this._handleContext MenuEvent.bind(this), true);
1212 }, 1203 },
1213 1204
1214 /** 1205 /**
1215 * @param {!Event} event 1206 * @param {!Event} event
1216 * @param {!WebInspector.ProfilesPanel} panel
1217 */ 1207 */
1218 handleContextMenuEvent: function(event, panel) 1208 _handleContextMenuEvent: function(event)
1219 { 1209 {
1220 var profile = this.profile; 1210 var profile = this.profile;
1221 var contextMenu = new WebInspector.ContextMenu(event); 1211 var contextMenu = new WebInspector.ContextMenu(event);
1222 // FIXME: use context menu provider 1212 // FIXME: use context menu provider
1223 contextMenu.appendItem(WebInspector.UIString("Load\u2026"), panel._fileS electorElement.click.bind(panel._fileSelectorElement)); 1213 contextMenu.appendItem(WebInspector.UIString("Load\u2026"), WebInspector .ProfilesPanel._fileSelectorElement.click.bind(WebInspector.ProfilesPanel._fileS electorElement));
1224 if (profile.canSaveToFile()) 1214 if (profile.canSaveToFile())
1225 contextMenu.appendItem(WebInspector.UIString("Save\u2026"), profile. saveToFile.bind(profile)); 1215 contextMenu.appendItem(WebInspector.UIString("Save\u2026"), profile. saveToFile.bind(profile));
1226 contextMenu.appendItem(WebInspector.UIString("Delete"), this.ondelete.bi nd(this)); 1216 contextMenu.appendItem(WebInspector.UIString("Delete"), this.ondelete.bi nd(this));
1227 contextMenu.show(); 1217 contextMenu.show();
1228 }, 1218 },
1229 1219
1230 _saveProfile: function(event) 1220 _saveProfile: function(event)
1231 { 1221 {
1232 this.profile.saveToFile(); 1222 this.profile.saveToFile();
1233 }, 1223 },
(...skipping 24 matching lines...) Expand all
1258 * @extends {TreeElement} 1248 * @extends {TreeElement}
1259 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate 1249 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate
1260 * @param {string} title 1250 * @param {string} title
1261 */ 1251 */
1262 WebInspector.ProfileGroupSidebarTreeElement = function(dataDisplayDelegate, titl e) 1252 WebInspector.ProfileGroupSidebarTreeElement = function(dataDisplayDelegate, titl e)
1263 { 1253 {
1264 TreeElement.call(this, "", true); 1254 TreeElement.call(this, "", true);
1265 this.selectable = false; 1255 this.selectable = false;
1266 this._dataDisplayDelegate = dataDisplayDelegate; 1256 this._dataDisplayDelegate = dataDisplayDelegate;
1267 this._title = title; 1257 this._title = title;
1258 this.expand();
1268 } 1259 }
1269 1260
1270 WebInspector.ProfileGroupSidebarTreeElement.prototype = { 1261 WebInspector.ProfileGroupSidebarTreeElement.prototype = {
1271 /** 1262 /**
1272 * @override 1263 * @override
1273 * @return {boolean} 1264 * @return {boolean}
1274 */ 1265 */
1275 onselect: function() 1266 onselect: function()
1276 { 1267 {
1277 var hasChildren = this.childCount() > 0; 1268 var hasChildren = this.childCount() > 0;
1278 if (hasChildren) 1269 if (hasChildren)
1279 this._dataDisplayDelegate.showProfile(this.lastChild().profile); 1270 this._dataDisplayDelegate.showProfile(this.lastChild().profile);
1280 return hasChildren; 1271 return hasChildren;
1281 }, 1272 },
1282 1273
1283 /** 1274 /**
1284 * @override 1275 * @override
1285 */ 1276 */
1286 onattach: function() 1277 onattach: function()
1287 { 1278 {
1288 this.listItemElement.classList.add("sidebar-tree-item", "profile-group-s idebar-tree-item"); 1279 this.listItemElement.classList.add("profile-group-sidebar-tree-item");
1289 this._disclosureButton = this.listItemElement.createChild("button", "dis closure-button");
1290 this.listItemElement.createChild("div", "icon"); 1280 this.listItemElement.createChild("div", "icon");
1291 this.listItemElement.createChild("div", "titles no-subtitle").createChil d("span", "title-container").createChild("span", "title").textContent = this._ti tle; 1281 this.listItemElement.createChild("div", "titles no-subtitle").createChil d("span", "title-container").createChild("span", "title").textContent = this._ti tle;
1292 }, 1282 },
1293 1283
1294 /**
1295 * @override
1296 * @return {boolean}
1297 */
1298 isEventWithinDisclosureTriangle: function(event)
1299 {
1300 return event.target === this._disclosureButton;
1301 },
1302
1303 __proto__: TreeElement.prototype 1284 __proto__: TreeElement.prototype
1304 } 1285 }
1305 1286
1306 /** 1287 /**
1307 * @constructor 1288 * @constructor
1308 * @extends {TreeElement} 1289 * @extends {TreeElement}
1309 * @param {!WebInspector.ProfilesPanel} panel 1290 * @param {!WebInspector.ProfilesPanel} panel
1310 */ 1291 */
1311 WebInspector.ProfilesSidebarTreeElement = function(panel) 1292 WebInspector.ProfilesSidebarTreeElement = function(panel)
1312 { 1293 {
(...skipping 11 matching lines...) Expand all
1324 { 1305 {
1325 this._panel._showLauncherView(); 1306 this._panel._showLauncherView();
1326 return true; 1307 return true;
1327 }, 1308 },
1328 1309
1329 /** 1310 /**
1330 * @override 1311 * @override
1331 */ 1312 */
1332 onattach: function() 1313 onattach: function()
1333 { 1314 {
1334 this.listItemElement.classList.add("sidebar-tree-item", "profile-launche r-view-tree-item"); 1315 this.listItemElement.classList.add("profile-launcher-view-tree-item");
1335 this.listItemElement.createChild("div", "icon"); 1316 this.listItemElement.createChild("div", "icon");
1336 this.listItemElement.createChild("div", "titles no-subtitle").createChil d("span", "title-container").createChild("span", "title").textContent = WebInspe ctor.UIString("Profiles"); 1317 this.listItemElement.createChild("div", "titles no-subtitle").createChil d("span", "title-container").createChild("span", "title").textContent = WebInspe ctor.UIString("Profiles");
1337 }, 1318 },
1338 1319
1339 __proto__: TreeElement.prototype 1320 __proto__: TreeElement.prototype
1340 } 1321 }
1341 1322
1342 WebInspector.ProfilesPanel.show = function() 1323 WebInspector.ProfilesPanel.show = function()
1343 { 1324 {
1344 WebInspector.inspectorView.setCurrentPanel(WebInspector.ProfilesPanel._insta nce()); 1325 WebInspector.inspectorView.setCurrentPanel(WebInspector.ProfilesPanel._insta nce());
(...skipping 23 matching lines...) Expand all
1368 * @return {boolean} 1349 * @return {boolean}
1369 */ 1350 */
1370 handleAction: function(context, actionId) 1351 handleAction: function(context, actionId)
1371 { 1352 {
1372 var panel = WebInspector.context.flavor(WebInspector.ProfilesPanel); 1353 var panel = WebInspector.context.flavor(WebInspector.ProfilesPanel);
1373 console.assert(panel && panel instanceof WebInspector.ProfilesPanel); 1354 console.assert(panel && panel instanceof WebInspector.ProfilesPanel);
1374 panel.toggleRecord(); 1355 panel.toggleRecord();
1375 return true; 1356 return true;
1376 } 1357 }
1377 } 1358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698