Adds a percentage toggle button the profile view status bar that
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 23:51:47 +0000 (23:51 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 May 2008 23:51:47 +0000 (23:51 +0000)
changes the time columns between absolute and percents.

https://bugs.webkit.org/show_bug.cgi?id=19224

Reviewed by Kevin McCullough.

* English.lproj/localizedStrings.js: New strings.
* page/inspector/Images/percentButtons.png: Added.
* page/inspector/ProfileView.js: Make the button and add it to the
status bar. Make clicking toggle the showAsPercent* properties.
* page/inspector/inspector.css: New styles.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/English.lproj/localizedStrings.js
WebCore/page/inspector/Images/percentButtons.png [new file with mode: 0644]
WebCore/page/inspector/ProfileView.js
WebCore/page/inspector/inspector.css

index b19e22a..6fe1805 100644 (file)
@@ -1,5 +1,20 @@
 2008-05-23  Timothy Hatcher  <timothy@apple.com>
 
+        Adds a percentage toggle button the profile view status bar that
+        changes the time columns between absolute and percents.
+
+        https://bugs.webkit.org/show_bug.cgi?id=19224
+
+        Reviewed by Kevin McCullough.
+
+        * English.lproj/localizedStrings.js: New strings.
+        * page/inspector/Images/percentButtons.png: Added.
+        * page/inspector/ProfileView.js: Make the button and add it to the
+        status bar. Make clicking toggle the showAsPercent* properties.
+        * page/inspector/inspector.css: New styles.
+
+2008-05-23  Timothy Hatcher  <timothy@apple.com>
+
         Fixes a bug where excluding nodes from the profile could
         show an empty parent node.
 
index 56147f1..4642f35 100644 (file)
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
diff --git a/WebCore/page/inspector/Images/percentButtons.png b/WebCore/page/inspector/Images/percentButtons.png
new file mode 100644 (file)
index 0000000..2635b24
Binary files /dev/null and b/WebCore/page/inspector/Images/percentButtons.png differ
index 8152ec9..ebc75cc 100644 (file)
@@ -44,6 +44,10 @@ WebInspector.ProfileView = function(profile)
     this.dataGrid.element.addEventListener("mousedown", this._mouseDownInDataGrid.bind(this), true);
     this.element.appendChild(this.dataGrid.element);
 
+    this.percentButton = document.createElement("button");
+    this.percentButton.className = "percent-time-status-bar-item status-bar-item";
+    this.percentButton.addEventListener("click", this._percentClicked.bind(this), false);
+
     this.focusButton = document.createElement("button");
     this.focusButton.title = WebInspector.UIString("Focus selected function.");
     this.focusButton.className = "focus-profile-node-status-bar-item status-bar-item";
@@ -65,13 +69,15 @@ WebInspector.ProfileView = function(profile)
     // column and direction padded to the DataGrid above.
     profile.head.sortTotalTimeDescending();
 
+    this._updatePercentButton();
+
     this.refresh();
 }
 
 WebInspector.ProfileView.prototype = {
     get statusBarItems()
     {
-        return [this.focusButton, this.excludeButton, this.resetButton];
+        return [this.percentButton, this.focusButton, this.excludeButton, this.resetButton];
     },
 
     refresh: function()
@@ -92,6 +98,8 @@ WebInspector.ProfileView.prototype = {
 
     refreshShowAsPercents: function()
     {
+        this._updatePercentButton();
+
         var child = this.dataGrid.children[0];
         while (child) {
             child.refresh();
@@ -99,6 +107,25 @@ WebInspector.ProfileView.prototype = {
         }
     },
 
+    _percentClicked: function(event)
+    {
+        var currentState = this.showSelfTimeAsPercent && this.showTotalTimeAsPercent;
+        this.showSelfTimeAsPercent = !currentState;
+        this.showTotalTimeAsPercent = !currentState;
+        this.refreshShowAsPercents();
+    },
+
+    _updatePercentButton: function()
+    {
+        if (this.showSelfTimeAsPercent && this.showTotalTimeAsPercent) {
+            this.percentButton.title = WebInspector.UIString("Show absolute total and self times.");
+            this.percentButton.addStyleClass("toggled-on");
+        } else {
+            this.percentButton.title = WebInspector.UIString("Show total and self times as percentages.");
+            this.percentButton.removeStyleClass("toggled-on");
+        }
+    },
+
     _focusClicked: function(event)
     {
         if (!this.dataGrid.selectedNode || !this.dataGrid.selectedNode.profileNode)
index 1ebab1d..507c2f3 100644 (file)
@@ -2562,6 +2562,22 @@ body.inactive .sidebar-tree-item.selected {
     background-position: 32px 24px;
 }
 
+.percent-time-status-bar-item {
+    background-image: url(Images/percentButtons.png) !important;
+}
+
+.percent-time-status-bar-item:active {
+    background-position: 32px 0;
+}
+
+.percent-time-status-bar-item.toggled-on {
+    background-position: 0 24px;
+}
+
+.percent-time-status-bar-item.toggled-on:active {
+    background-position: 32px 24px;
+}
+
 .focus-profile-node-status-bar-item {
     background-image: url(Images/focusButtons.png) !important;
 }