Make profiles of the same name in the Inspector group in the
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jun 2008 17:33:49 +0000 (17:33 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jun 2008 17:33:49 +0000 (17:33 +0000)
        sidebar under a collapsable item that contains all the runs.

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

        Reviewed by Darin Adler.

        * English.lproj/localizedStrings.js: New strings.
        * page/inspector/Images/profileGroupIcon.png: Added.
        * page/inspector/Images/profileSmallIcon.png: Added.
        * page/inspector/ProfilesPanel.js:
        (WebInspector.ProfilesPanel.prototype.reset): Clear _profileGroups.
        Remove the "some-expandable" class from the sidebarTree.
        (WebInspector.ProfilesPanel.prototype.addProfile): Append new profiles
        that have the same name as a previous profile into a group. When a
        group has 2 profiles a ProfileGroupSidebarTreeElement is made and the
        ProfileSidebarTreeElements are appended to the group's element.
        (WebInspector.ProfileSidebarTreeElement.prototype.get mainTitle):
        Return _mainTitle is it is set.
        (WebInspector.ProfileSidebarTreeElement.prototype.set mainTitle):
        Set _mainTitle which is an override title.
        (WebInspector.ProfileGroupSidebarTreeElement): Inherit SidebarTreeElement.
        (WebInspector.ProfileGroupSidebarTreeElement.prototype.onselect):
        Show the last profile in the group when selected.
        * page/inspector/SidebarTreeElement.js:
        (WebInspector.SidebarTreeElement.prototype.get small): Return _small.
        (WebInspector.SidebarTreeElement.prototype.set small): Set _small and
        update the style to match.
        (WebInspector.SidebarTreeElement.prototype.onattach): Set the small
        class if the small property is true.
        * page/inspector/inspector.css: New styles for profiles groups
        and for the small profiles.

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

WebCore/ChangeLog
WebCore/English.lproj/localizedStrings.js
WebCore/page/inspector/Images/profileGroupIcon.png [new file with mode: 0644]
WebCore/page/inspector/Images/profileSmallIcon.png [new file with mode: 0644]
WebCore/page/inspector/ProfilesPanel.js
WebCore/page/inspector/SidebarTreeElement.js
WebCore/page/inspector/inspector.css

index 3e59937..d3643d2 100644 (file)
@@ -1,3 +1,38 @@
+2008-06-23  Timothy Hatcher  <timothy@apple.com>
+
+        Make profiles of the same name in the Inspector group in the
+        sidebar under a collapsable item that contains all the runs.
+
+        https://bugs.webkit.org/show_bug.cgi?id=19713
+
+        Reviewed by Darin Adler.
+
+        * English.lproj/localizedStrings.js: New strings.
+        * page/inspector/Images/profileGroupIcon.png: Added.
+        * page/inspector/Images/profileSmallIcon.png: Added.
+        * page/inspector/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.reset): Clear _profileGroups.
+        Remove the "some-expandable" class from the sidebarTree.
+        (WebInspector.ProfilesPanel.prototype.addProfile): Append new profiles
+        that have the same name as a previous profile into a group. When a
+        group has 2 profiles a ProfileGroupSidebarTreeElement is made and the
+        ProfileSidebarTreeElements are appended to the group's element. 
+        (WebInspector.ProfileSidebarTreeElement.prototype.get mainTitle):
+        Return _mainTitle is it is set.
+        (WebInspector.ProfileSidebarTreeElement.prototype.set mainTitle):
+        Set _mainTitle which is an override title.
+        (WebInspector.ProfileGroupSidebarTreeElement): Inherit SidebarTreeElement.
+        (WebInspector.ProfileGroupSidebarTreeElement.prototype.onselect):
+        Show the last profile in the group when selected.
+        * page/inspector/SidebarTreeElement.js:
+        (WebInspector.SidebarTreeElement.prototype.get small): Return _small.
+        (WebInspector.SidebarTreeElement.prototype.set small): Set _small and
+        update the style to match.
+        (WebInspector.SidebarTreeElement.prototype.onattach): Set the small
+        class if the small property is true.
+        * page/inspector/inspector.css: New styles for profiles groups
+        and for the small profiles.
+
 2008-06-23  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Geoff.
index c24a390..af733d1 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/profileGroupIcon.png b/WebCore/page/inspector/Images/profileGroupIcon.png
new file mode 100644 (file)
index 0000000..44616d4
Binary files /dev/null and b/WebCore/page/inspector/Images/profileGroupIcon.png differ
diff --git a/WebCore/page/inspector/Images/profileSmallIcon.png b/WebCore/page/inspector/Images/profileSmallIcon.png
new file mode 100644 (file)
index 0000000..7935520
Binary files /dev/null and b/WebCore/page/inspector/Images/profileSmallIcon.png differ
index cea9816..d0654e0 100644 (file)
@@ -105,6 +105,9 @@ WebInspector.ProfilesPanel.prototype = {
         }
 
         this._profiles = [];
+        this._profileGroups = {};
+
+        this.sidebarTreeElement.removeStyleClass("some-expandable");
 
         this.sidebarTree.removeChildren();
         this.profileViews.removeChildren();
@@ -121,10 +124,54 @@ WebInspector.ProfilesPanel.prototype = {
     {
         this._profiles.push(profile);
 
+        var sidebarParent = this.sidebarTree;
+        var small = false;
+        var alternateTitle;
+
+        if (profile.title !== "org.webkit.profiles.user-initiated") {
+            if (!(profile.title in this._profileGroups))
+                this._profileGroups[profile.title] = [];
+
+            var group = this._profileGroups[profile.title];
+            group.push(profile);
+
+            if (group.length === 2) {
+                // Make a group TreeElement now that there are 2 profiles.
+                group._profilesTreeElement = new WebInspector.ProfileGroupSidebarTreeElement(profile.title);
+
+                // Insert at the same index for the first profile of the group.
+                var index = this.sidebarTree.children.indexOf(group[0]._profilesTreeElement);
+                this.sidebarTree.insertChild(group._profilesTreeElement, index);
+
+                // Move the first profile to the group.
+                var selected = group[0]._profilesTreeElement.selected;
+                this.sidebarTree.removeChild(group[0]._profilesTreeElement);
+                group._profilesTreeElement.appendChild(group[0]._profilesTreeElement);
+                if (selected) {
+                    group[0]._profilesTreeElement.select();
+                    group[0]._profilesTreeElement.reveal();
+                }
+
+                group[0]._profilesTreeElement.small = true;
+                group[0]._profilesTreeElement.mainTitle = WebInspector.UIString("Run %d", 1);
+
+                this.sidebarTreeElement.addStyleClass("some-expandable");
+            }
+
+            if (group.length >= 2) {
+                sidebarParent = group._profilesTreeElement;
+                alternateTitle = WebInspector.UIString("Run %d", group.length);
+                small = true;
+            }
+        }
+
         var profileTreeElement = new WebInspector.ProfileSidebarTreeElement(profile);
+        profileTreeElement.small = small;
+        if (alternateTitle)
+            profileTreeElement.mainTitle = alternateTitle;
         profile._profilesTreeElement = profileTreeElement;
 
-        this.sidebarTree.appendChild(profileTreeElement);
+        sidebarParent.appendChild(profileTreeElement);
     },
 
     showProfile: function(profile)
@@ -255,6 +302,8 @@ WebInspector.ProfileSidebarTreeElement.prototype = {
 
     get mainTitle()
     {
+        if (this._mainTitle)
+            return this._mainTitle;
         if (this.profile.title === "org.webkit.profiles.user-initiated")
             return WebInspector.UIString("Profile %d", this._profileNumber);
         return this.profile.title;
@@ -262,7 +311,8 @@ WebInspector.ProfileSidebarTreeElement.prototype = {
 
     set mainTitle(x)
     {
-        // Can't change mainTitle.
+        this._mainTitle = x;
+        this.refreshTitles();
     },
 
     get subtitle()
@@ -277,3 +327,17 @@ WebInspector.ProfileSidebarTreeElement.prototype = {
 }
 
 WebInspector.ProfileSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype;
+
+WebInspector.ProfileGroupSidebarTreeElement = function(title, subtitle)
+{
+    WebInspector.SidebarTreeElement.call(this, "profile-group-sidebar-tree-item", title, subtitle, null, true);
+}
+
+WebInspector.ProfileGroupSidebarTreeElement.prototype = {
+    onselect: function()
+    {
+        WebInspector.panels.profiles.showProfile(this.children[this.children.length - 1].profile);
+    }
+}
+
+WebInspector.ProfileGroupSidebarTreeElement.prototype.__proto__ = WebInspector.SidebarTreeElement.prototype;
index c849f2f..c08b0ef 100644 (file)
@@ -97,6 +97,23 @@ WebInspector.SidebarTreeElement = function(className, title, subtitle, represent
 }
 
 WebInspector.SidebarTreeElement.prototype = {
+    get small()
+    {
+        return this._small;
+    },
+
+    set small(x)
+    {
+        this._small = x;
+
+        if (this._listItemNode) {
+            if (this._small)
+                this._listItemNode.addStyleClass("small");
+            else
+                this._listItemNode.removeStyleClass("small");
+        }
+    },
+
     get mainTitle()
     {
         return this._mainTitle;
@@ -163,6 +180,9 @@ WebInspector.SidebarTreeElement.prototype = {
         if (this.className)
             this._listItemNode.addStyleClass(this.className);
 
+        if (this.small)
+            this._listItemNode.addStyleClass("small");
+
         if (this.hasChildren && this.disclosureButton)
             this._listItemNode.appendChild(this.disclosureButton);
 
index b3990c8..7990e41 100644 (file)
@@ -2486,6 +2486,14 @@ body.inactive .sidebar-tree-item.selected {
     content: url(Images/profileIcon.png);
 }
 
+.profile-sidebar-tree-item.small .icon {
+    content: url(Images/profileSmallIcon.png);
+}
+
+.profile-group-sidebar-tree-item .icon {
+    content: url(Images/profileGroupIcon.png);
+}
+
 .profile-view {
     display: none;
     overflow: hidden;