Modified: trunk/Source/WebCore/ChangeLog (102905 => 102906)
--- trunk/Source/WebCore/ChangeLog 2011-12-15 09:33:24 UTC (rev 102905)
+++ trunk/Source/WebCore/ChangeLog 2011-12-15 09:37:32 UTC (rev 102906)
@@ -1,3 +1,33 @@
+2011-12-14 Alexander Pavlov <[email protected]>
+
+ Web Inspector: make ProfilesPanel scale as the number of ProfileTypes grows
+ https://bugs.webkit.org/show_bug.cgi?id=74391
+
+ Reviewed by Pavel Feldman.
+
+ Whenever a profile is started, this change disables all profile recording buttons, except the one
+ that correponds to the running profile. Once the profiling is finished, all buttons get enabled back again.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/ProfileView.js:
+ (WebInspector.CPUProfileView.profileCallback):
+ (WebInspector.CPUProfileType.prototype.get buttonTooltip):
+ (WebInspector.CPUProfileType.prototype.get buttonStyle):
+ (WebInspector.CPUProfileType.prototype.buttonClicked):
+ * inspector/front-end/ProfilesPanel.js:
+ (WebInspector.ProfilesPanel.prototype.get statusBarItems.clickHandler):
+ (WebInspector.ProfilesPanel.prototype.get statusBarItems):
+ (WebInspector.ProfilesPanel.prototype._addProfileHeader):
+ (WebInspector.ProfilesPanel.prototype.updateProfileTypeButtons):
+ (WebInspector.ProfilesPanel.prototype._updateInterface):
+ (WebInspector.ProfilesPanel.prototype.setRecordingProfile):
+ (WebInspector.ProfilesPanel.prototype.takeHeapSnapshot):
+ (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
+ (WebInspector.ProfilerDispatcher.prototype.setRecordingProfile):
+ * inspector/front-end/inspector.css:
+ (.record-cpu-profile-status-bar-item .glyph):
+ (.record-cpu-profile-status-bar-item.toggled-on .glyph):
+
2011-12-15 Alexander Pavlov <[email protected]>
Web Inspector: [Styles] Update selected DOM element styles whenever applicable media queries change
Modified: trunk/Source/WebCore/inspector/front-end/ProfileView.js (102905 => 102906)
--- trunk/Source/WebCore/inspector/front-end/ProfileView.js 2011-12-15 09:33:24 UTC (rev 102905)
+++ trunk/Source/WebCore/inspector/front-end/ProfileView.js 2011-12-15 09:37:32 UTC (rev 102906)
@@ -85,6 +85,11 @@
{
if (error)
return;
+
+ if (!profile.head) {
+ // Profiling was tentatively terminated with the "Clear all profiles." button.
+ return;
+ }
this.profile.head = profile.head;
this._assignParentsInProfile();
this._changeView();
@@ -574,24 +579,22 @@
WebInspector.CPUProfileType.prototype = {
get buttonTooltip()
{
- return this._recording ? WebInspector.UIString("Stop profiling.") : WebInspector.UIString("Start profiling.");
+ return this._recording ? WebInspector.UIString("Stop CPU profiling.") : WebInspector.UIString("Start CPU profiling.");
},
get buttonStyle()
{
- return this._recording ? "record-profile-status-bar-item status-bar-item toggled-on" : "record-profile-status-bar-item status-bar-item";
+ return this._recording ? "record-cpu-profile-status-bar-item status-bar-item toggled-on" : "record-cpu-profile-status-bar-item status-bar-item";
},
buttonClicked: function()
{
- this._recording = !this._recording;
-
if (this._recording) {
+ this.stopRecordingProfile();
+ WebInspector.networkManager.enableResourceTracking();
+ } else
WebInspector.networkManager.disableResourceTracking();
- ProfilerAgent.start();
- } else {
- ProfilerAgent.stop();
- WebInspector.networkManager.enableResourceTracking();
+ this.startRecordingProfile();
}
},
Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (102905 => 102906)
--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2011-12-15 09:33:24 UTC (rev 102905)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2011-12-15 09:37:32 UTC (rev 102906)
@@ -152,10 +152,11 @@
get statusBarItems()
{
- function clickHandler(profileType, buttonElement)
+ function clickHandler(profileType, button)
{
+ var wasProfiling = button.toggled;
profileType.buttonClicked.call(profileType);
- this.updateProfileTypeButtons();
+ this.updateProfileTypeButtons(!wasProfiling, button);
}
var items = [this.enableToggleButton.element];
@@ -163,9 +164,9 @@
for (var typeId in this._profileTypesByIdMap) {
var profileType = this.getProfileType(typeId);
if (profileType.buttonStyle) {
- var button = new WebInspector.StatusBarButton(profileType.buttonTooltip, profileType.buttonStyle, profileType.buttonCaption);
- this._profileTypeButtonsByIdMap[typeId] = button.element;
- button.element.addEventListener("click", clickHandler.bind(this, profileType, button.element), false);
+ var button = new WebInspector.StatusBarButton(profileType.buttonTooltip, profileType.buttonStyle);
+ this._profileTypeButtonsByIdMap[typeId] = button;
+ button.element.addEventListener("click", clickHandler.bind(this, profileType, button), false);
items.push(button.element);
}
}
@@ -286,12 +287,8 @@
_addProfileHeader: function(profile)
{
- if (this.hasTemporaryProfile(profile.typeId)) {
- if (profile.typeId === WebInspector.CPUProfileType.TypeId)
- this._removeProfileHeader(this._temporaryRecordingProfile);
- else
- this._removeProfileHeader(this._temporaryTakingSnapshot);
- }
+ if (this.hasTemporaryProfile(profile.typeId))
+ this._removeProfileHeader(this._temporaryRecordingProfile);
var typeId = profile.typeId;
var profileType = this.getProfileType(typeId);
@@ -352,6 +349,7 @@
if (!this.visibleView)
this.showProfile(profile);
this.dispatchEventToListeners("profile added");
+ this.updateProfileTypeButtons(false, this._profileTypeButtonsByIdMap[typeId]);
}
},
@@ -505,14 +503,24 @@
this.showProfile(this._profilesIdMap[this._makeKey(match[3], match[1])]);
},
- updateProfileTypeButtons: function()
+ /**
+ * @param {boolean} isProfiling
+ * @param {WebInspector.StatusBarButton=} effectButton
+ */
+ updateProfileTypeButtons: function(isProfiling, effectButton)
{
for (var typeId in this._profileTypeButtonsByIdMap) {
- var buttonElement = this._profileTypeButtonsByIdMap[typeId];
+ var button = this._profileTypeButtonsByIdMap[typeId];
var profileType = this.getProfileType(typeId);
- buttonElement.className = profileType.buttonStyle;
- buttonElement.title = profileType.buttonTooltip;
+ button.element.className = profileType.buttonStyle;
+ button.element.title = profileType.buttonTooltip;
// FIXME: Apply profileType.buttonCaption once captions are added to button controls.
+ if (!isProfiling)
+ button.disabled = false;
+ else {
+ if (effectButton && button !== effectButton)
+ button.disabled = true;
+ }
}
},
@@ -752,7 +760,7 @@
this.enableToggleButton.title = WebInspector.UIString("Profiling enabled. Click to disable.");
this.enableToggleButton.toggled = true;
for (var typeId in this._profileTypeButtonsByIdMap)
- this._profileTypeButtonsByIdMap[typeId].removeStyleClass("hidden");
+ this._profileTypeButtonsByIdMap[typeId].visible = true;
this.profileViewStatusBarItemsContainer.removeStyleClass("hidden");
this.clearResultsButton.element.removeStyleClass("hidden");
this.panelEnablerView.detach();
@@ -760,7 +768,7 @@
this.enableToggleButton.title = WebInspector.UIString("Profiling disabled. Click to enable.");
this.enableToggleButton.toggled = false;
for (var typeId in this._profileTypeButtonsByIdMap)
- this._profileTypeButtonsByIdMap[typeId].addStyleClass("hidden");
+ this._profileTypeButtonsByIdMap[typeId].visible = false;
this.profileViewStatusBarItemsContainer.addStyleClass("hidden");
this.clearResultsButton.element.addStyleClass("hidden");
this.panelEnablerView.show(this.element);
@@ -824,39 +832,41 @@
this.profileViewStatusBarItemsContainer.style.left = Math.max(6 * 31, width) + "px";
},
- _setRecordingProfile: function(isProfiling)
+ setRecordingProfile: function(profileType, isProfiling)
{
- this.getProfileType(WebInspector.CPUProfileType.TypeId).setRecordingProfile(isProfiling);
- if (this.hasTemporaryProfile(WebInspector.CPUProfileType.TypeId) !== isProfiling) {
+ this.getProfileType(profileType).setRecordingProfile(isProfiling);
+ if (this.hasTemporaryProfile(profileType) !== isProfiling) {
if (!this._temporaryRecordingProfile) {
this._temporaryRecordingProfile = {
- typeId: WebInspector.CPUProfileType.TypeId,
- title: WebInspector.UIString("Recording…"),
+ typeId: profileType,
+ title: WebInspector.UIString("Recording\u2026"),
uid: -1,
isTemporary: true
};
}
if (isProfiling) {
this._addProfileHeader(this._temporaryRecordingProfile);
- WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
- } else
+ if (profileType === WebInspector.CPUProfileType.TypeId)
+ WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
+ } else {
this._removeProfileHeader(this._temporaryRecordingProfile);
+ delete this._temporaryRecordingProfile;
+ }
}
- this.updateProfileTypeButtons();
},
takeHeapSnapshot: function()
{
if (!this.hasTemporaryProfile(WebInspector.DetailedHeapshotProfileType.TypeId)) {
- if (!this._temporaryTakingSnapshot) {
- this._temporaryTakingSnapshot = {
+ if (!this._temporaryRecordingProfile) {
+ this._temporaryRecordingProfile = {
typeId: WebInspector.DetailedHeapshotProfileType.TypeId,
- title: WebInspector.UIString("Snapshotting…"),
+ title: WebInspector.UIString("Snapshotting\u2026"),
uid: -1,
isTemporary: true
};
}
- this._addProfileHeader(this._temporaryTakingSnapshot);
+ this._addProfileHeader(this._temporaryRecordingProfile);
}
ProfilerAgent.takeHeapSnapshot();
WebInspector.userMetrics.ProfilesHeapProfileTaken.record();
@@ -865,10 +875,10 @@
_reportHeapSnapshotProgress: function(done, total)
{
if (this.hasTemporaryProfile(WebInspector.DetailedHeapshotProfileType.TypeId)) {
- this._temporaryTakingSnapshot.sidebarElement.subtitle = WebInspector.UIString("%.2f%%", (done / total) * 100);
- this._temporaryTakingSnapshot.sidebarElement.wait = true;
+ this._temporaryRecordingProfile.sidebarElement.subtitle = WebInspector.UIString("%.2f%%", (done / total) * 100);
+ this._temporaryRecordingProfile.sidebarElement.wait = true;
if (done >= total)
- this._removeProfileHeader(this._temporaryTakingSnapshot);
+ this._removeProfileHeader(this._temporaryRecordingProfile);
}
}
}
@@ -904,7 +914,7 @@
setRecordingProfile: function(isProfiling)
{
- this._profiler._setRecordingProfile(isProfiling);
+ this._profiler.setRecordingProfile(WebInspector.CPUProfileType.TypeId, isProfiling);
},
reportHeapSnapshotProgress: function(done, total)
Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (102905 => 102906)
--- trunk/Source/WebCore/inspector/front-end/inspector.css 2011-12-15 09:33:24 UTC (rev 102905)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css 2011-12-15 09:37:32 UTC (rev 102906)
@@ -2507,11 +2507,11 @@
white-space: pre;
}
-.record-profile-status-bar-item .glyph {
+.record-cpu-profile-status-bar-item .glyph {
-webkit-mask-position: -288px 0;
}
-.record-profile-status-bar-item.toggled-on .glyph {
+.record-cpu-profile-status-bar-item.toggled-on .glyph {
-webkit-mask-position: -288px -24px;
background-color: rgb(216, 0, 0) !important;
}