OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 { | 1182 { |
1192 this.profile.profileType().removeProfile(this.profile); | 1183 this.profile.profileType().removeProfile(this.profile); |
1193 return true; | 1184 return true; |
1194 }, | 1185 }, |
1195 | 1186 |
1196 /** | 1187 /** |
1197 * @override | 1188 * @override |
1198 */ | 1189 */ |
1199 onattach: function() | 1190 onattach: function() |
1200 { | 1191 { |
1201 this.listItemElement.classList.add("sidebar-tree-item"); | |
1202 if (this._className) | 1192 if (this._className) |
1203 this.listItemElement.classList.add(this._className); | 1193 this.listItemElement.classList.add(this._className); |
1204 if (this._small) | 1194 if (this._small) |
1205 this.listItemElement.classList.add("small"); | 1195 this.listItemElement.classList.add("small"); |
1206 this.listItemElement.appendChildren(this._iconElement, this._titlesEleme
nt); | 1196 this.listItemElement.appendChildren(this._iconElement, this._titlesEleme
nt); |
| 1197 this.listItemElement.addEventListener("contextmenu", this._handleContext
MenuEvent.bind(this), true); |
1207 }, | 1198 }, |
1208 | 1199 |
1209 /** | 1200 /** |
1210 * @param {!Event} event | 1201 * @param {!Event} event |
1211 * @param {!WebInspector.ProfilesPanel} panel | |
1212 */ | 1202 */ |
1213 handleContextMenuEvent: function(event, panel) | 1203 _handleContextMenuEvent: function(event) |
1214 { | 1204 { |
1215 var profile = this.profile; | 1205 var profile = this.profile; |
1216 var contextMenu = new WebInspector.ContextMenu(event); | 1206 var contextMenu = new WebInspector.ContextMenu(event); |
1217 // FIXME: use context menu provider | 1207 // FIXME: use context menu provider |
1218 contextMenu.appendItem(WebInspector.UIString("Load\u2026"), panel._fileS
electorElement.click.bind(panel._fileSelectorElement)); | 1208 contextMenu.appendItem(WebInspector.UIString("Load\u2026"), WebInspector
.ProfilesPanel._fileSelectorElement.click.bind(WebInspector.ProfilesPanel._fileS
electorElement)); |
1219 if (profile.canSaveToFile()) | 1209 if (profile.canSaveToFile()) |
1220 contextMenu.appendItem(WebInspector.UIString("Save\u2026"), profile.
saveToFile.bind(profile)); | 1210 contextMenu.appendItem(WebInspector.UIString("Save\u2026"), profile.
saveToFile.bind(profile)); |
1221 contextMenu.appendItem(WebInspector.UIString("Delete"), this.ondelete.bi
nd(this)); | 1211 contextMenu.appendItem(WebInspector.UIString("Delete"), this.ondelete.bi
nd(this)); |
1222 contextMenu.show(); | 1212 contextMenu.show(); |
1223 }, | 1213 }, |
1224 | 1214 |
1225 _saveProfile: function(event) | 1215 _saveProfile: function(event) |
1226 { | 1216 { |
1227 this.profile.saveToFile(); | 1217 this.profile.saveToFile(); |
1228 }, | 1218 }, |
(...skipping 24 matching lines...) Expand all Loading... |
1253 * @extends {TreeElement} | 1243 * @extends {TreeElement} |
1254 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 1244 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
1255 * @param {string} title | 1245 * @param {string} title |
1256 */ | 1246 */ |
1257 WebInspector.ProfileGroupSidebarTreeElement = function(dataDisplayDelegate, titl
e) | 1247 WebInspector.ProfileGroupSidebarTreeElement = function(dataDisplayDelegate, titl
e) |
1258 { | 1248 { |
1259 TreeElement.call(this, "", true); | 1249 TreeElement.call(this, "", true); |
1260 this.selectable = false; | 1250 this.selectable = false; |
1261 this._dataDisplayDelegate = dataDisplayDelegate; | 1251 this._dataDisplayDelegate = dataDisplayDelegate; |
1262 this._title = title; | 1252 this._title = title; |
| 1253 this.expand(); |
| 1254 this.toggleOnClick = true; |
1263 } | 1255 } |
1264 | 1256 |
1265 WebInspector.ProfileGroupSidebarTreeElement.prototype = { | 1257 WebInspector.ProfileGroupSidebarTreeElement.prototype = { |
1266 /** | 1258 /** |
1267 * @override | 1259 * @override |
1268 * @return {boolean} | 1260 * @return {boolean} |
1269 */ | 1261 */ |
1270 onselect: function() | 1262 onselect: function() |
1271 { | 1263 { |
1272 var hasChildren = this.childCount() > 0; | 1264 var hasChildren = this.childCount() > 0; |
1273 if (hasChildren) | 1265 if (hasChildren) |
1274 this._dataDisplayDelegate.showProfile(this.lastChild().profile); | 1266 this._dataDisplayDelegate.showProfile(this.lastChild().profile); |
1275 return hasChildren; | 1267 return hasChildren; |
1276 }, | 1268 }, |
1277 | 1269 |
1278 /** | 1270 /** |
1279 * @override | 1271 * @override |
1280 */ | 1272 */ |
1281 onattach: function() | 1273 onattach: function() |
1282 { | 1274 { |
1283 this.listItemElement.classList.add("sidebar-tree-item", "profile-group-s
idebar-tree-item"); | 1275 this.listItemElement.classList.add("profile-group-sidebar-tree-item"); |
1284 this._disclosureButton = this.listItemElement.createChild("button", "dis
closure-button"); | |
1285 this.listItemElement.createChild("div", "icon"); | 1276 this.listItemElement.createChild("div", "icon"); |
1286 this.listItemElement.createChild("div", "titles no-subtitle").createChil
d("span", "title-container").createChild("span", "title").textContent = this._ti
tle; | 1277 this.listItemElement.createChild("div", "titles no-subtitle").createChil
d("span", "title-container").createChild("span", "title").textContent = this._ti
tle; |
1287 }, | 1278 }, |
1288 | 1279 |
1289 /** | |
1290 * @override | |
1291 * @param {!Event} event | |
1292 * @return {boolean} | |
1293 */ | |
1294 isEventWithinDisclosureTriangle: function(event) | |
1295 { | |
1296 return event.target === this._disclosureButton; | |
1297 }, | |
1298 | |
1299 __proto__: TreeElement.prototype | 1280 __proto__: TreeElement.prototype |
1300 } | 1281 } |
1301 | 1282 |
1302 /** | 1283 /** |
1303 * @constructor | 1284 * @constructor |
1304 * @extends {TreeElement} | 1285 * @extends {TreeElement} |
1305 * @param {!WebInspector.ProfilesPanel} panel | 1286 * @param {!WebInspector.ProfilesPanel} panel |
1306 */ | 1287 */ |
1307 WebInspector.ProfilesSidebarTreeElement = function(panel) | 1288 WebInspector.ProfilesSidebarTreeElement = function(panel) |
1308 { | 1289 { |
(...skipping 11 matching lines...) Expand all Loading... |
1320 { | 1301 { |
1321 this._panel._showLauncherView(); | 1302 this._panel._showLauncherView(); |
1322 return true; | 1303 return true; |
1323 }, | 1304 }, |
1324 | 1305 |
1325 /** | 1306 /** |
1326 * @override | 1307 * @override |
1327 */ | 1308 */ |
1328 onattach: function() | 1309 onattach: function() |
1329 { | 1310 { |
1330 this.listItemElement.classList.add("sidebar-tree-item", "profile-launche
r-view-tree-item"); | 1311 this.listItemElement.classList.add("profile-launcher-view-tree-item"); |
1331 this.listItemElement.createChild("div", "icon"); | 1312 this.listItemElement.createChild("div", "icon"); |
1332 this.listItemElement.createChild("div", "titles no-subtitle").createChil
d("span", "title-container").createChild("span", "title").textContent = WebInspe
ctor.UIString("Profiles"); | 1313 this.listItemElement.createChild("div", "titles no-subtitle").createChil
d("span", "title-container").createChild("span", "title").textContent = WebInspe
ctor.UIString("Profiles"); |
1333 }, | 1314 }, |
1334 | 1315 |
1335 __proto__: TreeElement.prototype | 1316 __proto__: TreeElement.prototype |
1336 } | 1317 } |
1337 | 1318 |
1338 WebInspector.ProfilesPanel.show = function() | 1319 WebInspector.ProfilesPanel.show = function() |
1339 { | 1320 { |
1340 WebInspector.inspectorView.setCurrentPanel(WebInspector.ProfilesPanel._insta
nce()); | 1321 WebInspector.inspectorView.setCurrentPanel(WebInspector.ProfilesPanel._insta
nce()); |
(...skipping 23 matching lines...) Expand all Loading... |
1364 * @return {boolean} | 1345 * @return {boolean} |
1365 */ | 1346 */ |
1366 handleAction: function(context, actionId) | 1347 handleAction: function(context, actionId) |
1367 { | 1348 { |
1368 var panel = WebInspector.context.flavor(WebInspector.ProfilesPanel); | 1349 var panel = WebInspector.context.flavor(WebInspector.ProfilesPanel); |
1369 console.assert(panel && panel instanceof WebInspector.ProfilesPanel); | 1350 console.assert(panel && panel instanceof WebInspector.ProfilesPanel); |
1370 panel.toggleRecord(); | 1351 panel.toggleRecord(); |
1371 return true; | 1352 return true; |
1372 } | 1353 } |
1373 } | 1354 } |
OLD | NEW |