https://bugs.webkit.org/show_bug.cgi?id=39224
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 May 2010 13:16:21 +0000 (13:16 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 30 May 2010 13:16:21 +0000 (13:16 +0000)
Bug 39224 - Web Inspector: There should be a way to clean up profiles

Reviewed by Pavel Feldman.

WebCore:

Adds a button to clear the profiles from the profiles panel like that
used for the console, the audits panel, and the timeline panel.
Consolidates the css rules, since they all use the same image.
Also allows for individual profiles to be deleted via the keyboard
(U+0008 or U+007F) and uses this new schema for the Elements Tree.

* English.lproj/localizedStrings.js:
Add tooltip text for the button to clear the profiles pane.

* inspector/InspectorBackend.idl:
Add ability to remove the profiles from the backend when they are
deleted or cleared in the frontend.
* inspector/InspectorBackend.cpp:
(WebCore::InspectorBackend::removeProfile):
(WebCore::InspectorBackend::clearProfiles):
* inspector/InspectorBackend.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::removeProfile):
(WebCore::InspectorController::clearProfiles):
* inspector/InspectorController.h:

* inspector/front-end/AuditsPanel.js:
(WebInspector.AuditsPanel):
Use the 'clear-status-bar-item' class.
* inspector/front-end/ChangesView.js:
(WebInspector.ChangesView):
* inspector/front-end/TimelinePanel.js:
(WebInspector.TimelinePanel.prototype._createStatusbarButtons):
* inspector/front-end/audits.css:
* inspector/front-end/inspector.css:
(.clear-status-bar-item .glyph):
* inspector/front-end/inspector.html:

* inspector/front-end/ElementsTreeOutline.js:
Replace the keyDown handler on the Outline with specific methods to
handle delete and enter on the TreeElements.
(WebInspector.ElementsTreeOutline):
(WebInspector.ElementsTreeOutline.prototype.get editing):
Return whether or not an element in the tree is currently being edited.
(WebInspector.ElementsTreeElement.prototype.ondelete):
(WebInspector.ElementsTreeElement.prototype.onenter):

* inspector/front-end/Panel.js:
(WebInspector.Panel.prototype.createSidebar):
Make the TreeOutline for a Panel's sidebar aware of its enclosing Panel.

* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel):
Add the clear button.
(WebInspector.ProfilesPanel.prototype.get statusBarItems):
(WebInspector.ProfilesPanel.prototype._clearProfiles):
Remove the profiles from the backend, the reset the frontend interface.
(WebInspector.ProfilesPanel.prototype.removeProfileHeader):
Remove the profile from both the frontend and the backend, and clear the
view when the last profile is removed.
(WebInspector.ProfilesPanel.prototype._updateInterface):
Hide the clear button when profiling is disabled.
(WebInspector.ProfileSidebarTreeElement.prototype.onselect):
Replace access to global variable with reference to the Panel held by the
TreeOutline.
(WebInspector.ProfileSidebarTreeElement.prototype.ondelete):
Remove the profile corresponding the tree element when the user deletes
that tree element.

* inspector/front-end/treeoutline.js:
(TreeOutline.prototype._treeKeyDown):
Allow the selected tree element to handle the user pressing a delete
key or enter key.

WebKit/chromium:

* src/js/InspectorControllerImpl.js:
(devtools.InspectorBackendImpl):

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

19 files changed:
WebCore/ChangeLog
WebCore/English.lproj/localizedStrings.js
WebCore/inspector/InspectorBackend.cpp
WebCore/inspector/InspectorBackend.h
WebCore/inspector/InspectorBackend.idl
WebCore/inspector/InspectorController.cpp
WebCore/inspector/InspectorController.h
WebCore/inspector/front-end/AuditsPanel.js
WebCore/inspector/front-end/ChangesView.js
WebCore/inspector/front-end/ElementsTreeOutline.js
WebCore/inspector/front-end/Panel.js
WebCore/inspector/front-end/ProfilesPanel.js
WebCore/inspector/front-end/TimelinePanel.js
WebCore/inspector/front-end/audits.css
WebCore/inspector/front-end/inspector.css
WebCore/inspector/front-end/inspector.html
WebCore/inspector/front-end/treeoutline.js
WebKit/chromium/ChangeLog
WebKit/chromium/src/js/InspectorControllerImpl.js

index 0b1f0f1..c766309 100644 (file)
@@ -1,3 +1,79 @@
+2010-05-30  Jessie Berlin  <jberlin@webkit.org>
+
+        Reviewed by Pavel Feldman.
+
+        https://bugs.webkit.org/show_bug.cgi?id=39224
+        Bug 39224 - Web Inspector: There should be a way to clean up profiles
+
+        Adds a button to clear the profiles from the profiles panel like that
+        used for the console, the audits panel, and the timeline panel.
+        Consolidates the css rules, since they all use the same image.
+        Also allows for individual profiles to be deleted via the keyboard
+        (U+0008 or U+007F) and uses this new schema for the Elements Tree.
+
+        * English.lproj/localizedStrings.js:
+        Add tooltip text for the button to clear the profiles pane.
+
+        * inspector/InspectorBackend.idl:
+        Add ability to remove the profiles from the backend when they are
+        deleted or cleared in the frontend.
+        * inspector/InspectorBackend.cpp:
+        (WebCore::InspectorBackend::removeProfile):
+        (WebCore::InspectorBackend::clearProfiles):
+        * inspector/InspectorBackend.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::removeProfile):
+        (WebCore::InspectorController::clearProfiles):
+        * inspector/InspectorController.h:
+
+        * inspector/front-end/AuditsPanel.js:
+        (WebInspector.AuditsPanel):
+        Use the 'clear-status-bar-item' class.
+        * inspector/front-end/ChangesView.js:
+        (WebInspector.ChangesView):
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype._createStatusbarButtons):
+        * inspector/front-end/audits.css:
+        * inspector/front-end/inspector.css:
+        (.clear-status-bar-item .glyph):
+        * inspector/front-end/inspector.html:
+
+        * inspector/front-end/ElementsTreeOutline.js:
+        Replace the keyDown handler on the Outline with specific methods to
+        handle delete and enter on the TreeElements.
+        (WebInspector.ElementsTreeOutline):
+        (WebInspector.ElementsTreeOutline.prototype.get editing):
+        Return whether or not an element in the tree is currently being edited.
+        (WebInspector.ElementsTreeElement.prototype.ondelete):
+        (WebInspector.ElementsTreeElement.prototype.onenter):
+
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.createSidebar):
+        Make the TreeOutline for a Panel's sidebar aware of its enclosing Panel.
+
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel):
+        Add the clear button.
+        (WebInspector.ProfilesPanel.prototype.get statusBarItems):
+        (WebInspector.ProfilesPanel.prototype._clearProfiles):
+        Remove the profiles from the backend, the reset the frontend interface.
+        (WebInspector.ProfilesPanel.prototype.removeProfileHeader):
+        Remove the profile from both the frontend and the backend, and clear the
+        view when the last profile is removed.
+        (WebInspector.ProfilesPanel.prototype._updateInterface):
+        Hide the clear button when profiling is disabled.
+        (WebInspector.ProfileSidebarTreeElement.prototype.onselect):
+        Replace access to global variable with reference to the Panel held by the
+        TreeOutline.
+        (WebInspector.ProfileSidebarTreeElement.prototype.ondelete):
+        Remove the profile corresponding the tree element when the user deletes
+        that tree element.
+
+        * inspector/front-end/treeoutline.js:
+        (TreeOutline.prototype._treeKeyDown):
+        Allow the selected tree element to handle the user pressing a delete
+        key or enter key.
+
 2010-05-29  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
 
         Reviewed by Darin Adler.
index 02ade01..e59b66d 100644 (file)
Binary files a/WebCore/English.lproj/localizedStrings.js and b/WebCore/English.lproj/localizedStrings.js differ
index aed8f2b..0196434 100644 (file)
@@ -254,6 +254,18 @@ void InspectorBackend::getProfile(long callId, unsigned uid)
     if (m_inspectorController)
         m_inspectorController->getProfile(callId, uid);
 }
+
+void InspectorBackend::removeProfile(unsigned uid)
+{
+    if (m_inspectorController)
+        m_inspectorController->removeProfile(uid);
+}
+
+void InspectorBackend::clearProfiles()
+{
+    if (m_inspectorController)
+        m_inspectorController->clearProfiles();
+}
 #endif
 
 void InspectorBackend::setInjectedScriptSource(const String& source)
index 7331843..87bf2e1 100644 (file)
@@ -98,6 +98,9 @@ public:
 
     void getProfileHeaders(long callId);
     void getProfile(long callId, unsigned uid);
+
+    void removeProfile(unsigned uid);
+    void clearProfiles();
 #endif
 
     void setInjectedScriptSource(const String& source);
index cf0fe01..48e663d 100644 (file)
@@ -73,6 +73,9 @@ module core {
 
         void getProfileHeaders(in long callId);
         void getProfile(in long callId, in unsigned long uid);
+
+        void removeProfile(in unsigned long uid);
+        void clearProfiles();
 #endif
         void setInjectedScriptSource(in DOMString scriptSource);
         void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in DOMString methodName, in DOMString arguments, in boolean async);
index 6958391..f38f8d0 100644 (file)
@@ -1388,6 +1388,25 @@ void InspectorController::addStartProfilingMessageToConsole(const String& title,
     addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lineNumber, sourceURL);
 }
 
+void InspectorController::removeProfile(unsigned uid)
+{
+    if (!enabled())
+        return;
+
+    if (m_profiles.contains(uid))
+        m_profiles.remove(uid);
+}
+
+void InspectorController::clearProfiles()
+{
+    if (!enabled())
+        return;
+
+    m_profiles.clear();
+    m_currentUserInitiatedProfileNumber = 1;
+    m_nextUserInitiatedProfileNumber = 1;
+}
+
 void InspectorController::getProfileHeaders(long callId)
 {
     if (!m_frontend)
index de7f7a5..a2c8a77 100644 (file)
@@ -222,6 +222,8 @@ public:
     void addProfile(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
     void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
     void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
+    void removeProfile(unsigned);
+    void clearProfiles();
 
     bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; }
 
index c3318ce..481df80 100644 (file)
@@ -49,7 +49,7 @@ WebInspector.AuditsPanel = function()
 
     this.element.addStyleClass("audits");
 
-    this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear audit results."), "clear-audit-results-status-bar-item");
+    this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear audit results."), "clear-status-bar-item");
     this.clearResultsButton.addEventListener("click", this._clearButtonClicked.bind(this), false);
 
     this.viewsContainerElement = document.createElement("div");
index 802fdba..5ab6942 100644 (file)
@@ -37,7 +37,7 @@ WebInspector.ChangesView = function(drawer)
     this.clearButton = document.createElement("button");
     this.clearButton.id = "clear-changes-status-bar-item";
     this.clearButton.title = WebInspector.UIString("Clear changes log.");
-    this.clearButton.className = "status-bar-item";
+    this.clearButton.className = "status-bar-item clear-status-bar-item";
     this.clearButton.addEventListener("click", this._clearButtonClicked.bind(this), false);
 
     this.toggleChangesButton = document.getElementById("changes-status-bar-item");
index 0e943c0..e8fecb0 100644 (file)
@@ -43,7 +43,6 @@ WebInspector.ElementsTreeOutline = function() {
     this.focusedDOMNode = null;
 
     this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
-    this.element.addEventListener("keydown", this._keyDown.bind(this), true);
 }
 
 WebInspector.ElementsTreeOutline.prototype = {
@@ -117,6 +116,11 @@ WebInspector.ElementsTreeOutline.prototype = {
         }
     },
 
+    get editing()
+    {
+        return this._editing;
+    },
+
     update: function()
     {
         var selectedNode = this.selectedTreeElement ? this.selectedTreeElement.representedObject : null;
@@ -226,41 +230,6 @@ WebInspector.ElementsTreeOutline.prototype = {
         return element;
     },
 
-    _keyDown: function(event)
-    {
-        if (event.target !== this.treeOutline.element)
-            return;
-
-        var selectedElement = this.selectedTreeElement;
-        if (!selectedElement)
-            return;
-
-        if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code ||
-                event.keyCode === WebInspector.KeyboardShortcut.Keys.Delete.code) {
-            var startTagTreeElement = this.findTreeElement(selectedElement.representedObject);
-            if (selectedElement !== startTagTreeElement)
-                selectedElement = startTagTreeElement;
-            selectedElement.remove();
-            event.preventDefault();
-            event.stopPropagation();
-            return;
-        }
-
-        // On Enter or Return start editing the first attribute
-        // or create a new attribute on the selected element.
-        if (isEnterKey(event)) {
-            if (this._editing)
-                return;
-
-            selectedElement._startEditing();
-
-            // prevent a newline from being immediately inserted
-            event.preventDefault();
-            event.stopPropagation();
-            return;
-        }
-    },
-
     _onmousedown: function(event)
     {
         var element = this._treeElementFromEvent(event);
@@ -686,6 +655,26 @@ WebInspector.ElementsTreeElement.prototype = {
         this.treeOutline.suppressRevealAndSelect = false;
     },
 
+    ondelete: function()
+    {
+        var startTagTreeElement = this.treeOutline.findTreeElement(this.representedObject);
+        startTagTreeElement ? startTagTreeElement.remove() : this.remove();
+        return true;
+    },
+
+    onenter: function()
+    {
+        // On Enter or Return start editing the first attribute
+        // or create a new attribute on the selected element.
+        if (this.treeOutline.editing)
+            return false;
+
+        this._startEditing();
+
+        // prevent a newline from being immediately inserted
+        return true;
+    },
+
     selectOnMouseDown: function(event)
     {
         TreeElement.prototype.selectOnMouseDown.call(this, event);
index 675e95f..9fd0a60 100644 (file)
@@ -316,6 +316,7 @@ WebInspector.Panel.prototype = {
         this.sidebarElement.appendChild(this.sidebarTreeElement);
 
         this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
+        this.sidebarTree.panel = this;
     },
 
     _startSidebarDragging: function(event)
index cca9e33..1980fa5 100644 (file)
@@ -113,6 +113,9 @@ WebInspector.ProfilesPanel = function()
     this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item");
     this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind(this), false);
 
+    this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear CPU profiles."), "clear-status-bar-item");
+    this.clearResultsButton.addEventListener("click", this._clearProfiles.bind(this), false);
+
     this.profileViewStatusBarItemsContainer = document.createElement("div");
     this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items";
 
@@ -151,7 +154,7 @@ WebInspector.ProfilesPanel.prototype = {
                 items.push(button.element);
             }
         }
-        items.push(this.profileViewStatusBarItemsContainer);
+        items.push(this.clearResultsButton.element, this.profileViewStatusBarItemsContainer);
         return items;
     },
 
@@ -216,6 +219,12 @@ WebInspector.ProfilesPanel.prototype = {
         this.welcomeView.show();
     },
 
+    _clearProfiles: function()
+    {
+        InspectorBackend.clearProfiles();
+        this.reset();
+    },
+
     registerProfileType: function(profileType)
     {
         this._profileTypesByIdMap[profileType.id] = profileType;
@@ -337,6 +346,14 @@ WebInspector.ProfilesPanel.prototype = {
         delete this._profileGroups[profileTitleKey];
 
         sidebarParent.removeChild(profile._profilesTreeElement);
+
+        if (!profile.isTemporary)
+            InspectorBackend.removeProfile(profile.uid);
+
+        // No other item will be selected if there aren't any other profiles, so
+        // make sure that view gets cleared when the last profile is removed.
+        if (!this._profiles.length)
+            this.closeVisibleView();
     },
 
     showProfile: function(profile)
@@ -466,6 +483,7 @@ WebInspector.ProfilesPanel.prototype = {
             for (var typeId in this._profileTypeButtonsByIdMap)
                 this._profileTypeButtonsByIdMap[typeId].removeStyleClass("hidden");
             this.profileViewStatusBarItemsContainer.removeStyleClass("hidden");
+            this.clearResultsButton.element.removeStyleClass("hidden");
             this.panelEnablerView.visible = false;
         } else {
             this.enableToggleButton.title = WebInspector.UIString("Profiling disabled. Click to enable.");
@@ -473,6 +491,7 @@ WebInspector.ProfilesPanel.prototype = {
             for (var typeId in this._profileTypeButtonsByIdMap)
                 this._profileTypeButtonsByIdMap[typeId].addStyleClass("hidden");
             this.profileViewStatusBarItemsContainer.addStyleClass("hidden");
+            this.clearResultsButton.element.addStyleClass("hidden");
             this.panelEnablerView.visible = true;
         }
     },
@@ -540,7 +559,13 @@ WebInspector.ProfileSidebarTreeElement = function(profile)
 WebInspector.ProfileSidebarTreeElement.prototype = {
     onselect: function()
     {
-        WebInspector.panels.profiles.showProfile(this.profile);
+        this.treeOutline.panel.showProfile(this.profile);
+    },
+
+    ondelete: function()
+    {
+        this.treeOutline.panel.removeProfileHeader(this.profile);
+        return true;
     },
 
     get mainTitle()
index fd050d9..b9f0814 100644 (file)
@@ -204,7 +204,7 @@ WebInspector.TimelinePanel.prototype = {
         this.toggleTimelineButton = new WebInspector.StatusBarButton(WebInspector.UIString("Record"), "record-profile-status-bar-item");
         this.toggleTimelineButton.addEventListener("click", this._toggleTimelineButtonClicked.bind(this), false);
 
-        this.clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "timeline-clear-status-bar-item");
+        this.clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "clear-status-bar-item");
         this.clearButton.addEventListener("click", this._clearPanel.bind(this), false);
 
         this.toggleFilterButton = new WebInspector.StatusBarButton(this._hideShortRecordsTitleText, "timeline-filter-status-bar-item");
index ad12db3..d36efc6 100644 (file)
     overflow: auto;
 }
 
-button.clear-audit-results-status-bar-item .glyph {
-    -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
-}
-
 .audit-launcher-view {
     z-index: 1000;
     position: absolute;
index 27692af..ef34f2c 100644 (file)
@@ -420,7 +420,7 @@ body.port-qt #dock-status-bar-item {
     -webkit-mask-image: url(Images/consoleButtonGlyph.png);
 }
 
-#clear-console-status-bar-item .glyph {
+.clear-status-bar-item .glyph {
     -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
 }
 
@@ -428,10 +428,6 @@ body.port-qt #dock-status-bar-item {
     -webkit-mask-image: url(Images/consoleButtonGlyph.png); /* TODO: Needs Image for Changes Toggle Button */
 }
 
-#clear-changes-status-bar-item .glyph {
-    -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
-}
-
 #counters {
     position: absolute;
     right: 16px;
@@ -3431,10 +3427,6 @@ body.inactive .sidebar-tree-item.selected .bubble.search-matches {
     overflow-x: hidden;
 }
 
-.timeline-clear-status-bar-item .glyph {
-    -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
-}
-
 .timeline-category-statusbar-item {
     height: 24px;
     line-height: 24px;
index 4610ca5..1403665 100644 (file)
@@ -141,7 +141,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     </div>
     <div id="drawer">
         <div id="console-view"><div id="console-messages" class="monospace"><div id="console-prompt" spellcheck="false"><br></div></div></div>
-        <div id="drawer-status-bar" class="status-bar"><div id="other-drawer-status-bar-items"><button id="clear-console-status-bar-item" class="status-bar-item"><div class="glyph"></div><div class="glyph shadow"></div></button><div id="console-filter" class="scope-bar status-bar-item"></div></div></div>
+        <div id="drawer-status-bar" class="status-bar"><div id="other-drawer-status-bar-items"><button id="clear-console-status-bar-item" class="status-bar-item clear-status-bar-item"><div class="glyph"></div><div class="glyph shadow"></div></button><div id="console-filter" class="scope-bar status-bar-item"></div></div></div>
     </div>
 </body>
 </html>
index 7d58954..297bbab 100644 (file)
@@ -389,6 +389,12 @@ TreeOutline.prototype._treeKeyDown = function(event)
                     this.selectedTreeElement.expand();
             }
         }
+    } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code || event.keyCode === WebInspector.KeyboardShortcut.Keys.Delete.code) {
+        if (this.selectedTreeElement.ondelete)
+            handled = this.selectedTreeElement.ondelete();
+    } else if (isEnterKey(event)) {
+        if (this.selectedTreeElement.onenter)
+            handled = this.selectedTreeElement.onenter();
     }
 
     if (nextSelectedElement) {
index 6fec3d8..d4c79c6 100644 (file)
@@ -1,3 +1,13 @@
+2010-05-30  Jessie Berlin  <jberlin@webkit.org>
+
+        Reviewed by Pavel Feldman.
+
+        https://bugs.webkit.org/show_bug.cgi?id=39224
+        Bug 39224 - Web Inspector: There should be a way to clean up profiles
+
+        * src/js/InspectorControllerImpl.js:
+        (devtools.InspectorBackendImpl):
+
 2010-05-29  Vangelis Kokkevis  <vangelis@chromium.org>
 
         Reviewed by Darin Fisher.
index 58c6d0c..4f2bae3 100644 (file)
@@ -56,6 +56,8 @@ devtools.InspectorBackendImpl = function()
     this.installInspectorControllerDelegate_("getEventListenersForNode");
     this.installInspectorControllerDelegate_("getProfile");
     this.installInspectorControllerDelegate_("getProfileHeaders");
+    this.installInspectorControllerDelegate_("removeProfile");
+    this.installInspectorControllerDelegate_("clearProfiles");
     this.installInspectorControllerDelegate_("getResourceContent");
     this.installInspectorControllerDelegate_("highlightDOMNode");
     this.installInspectorControllerDelegate_("hideDOMNodeHighlight");