Changeset 60414 in webkit


Ignore:
Timestamp:
May 30, 2010 6:16:21 AM (14 years ago)
Author:
jberlin@webkit.org
Message:

https://bugs.webkit.org/show_bug.cgi?id=39224
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):

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60413 r60414  
     12010-05-30  Jessie Berlin  <jberlin@webkit.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=39224
     6        Bug 39224 - Web Inspector: There should be a way to clean up profiles
     7
     8        Adds a button to clear the profiles from the profiles panel like that
     9        used for the console, the audits panel, and the timeline panel.
     10        Consolidates the css rules, since they all use the same image.
     11        Also allows for individual profiles to be deleted via the keyboard
     12        (U+0008 or U+007F) and uses this new schema for the Elements Tree.
     13
     14        * English.lproj/localizedStrings.js:
     15        Add tooltip text for the button to clear the profiles pane.
     16
     17        * inspector/InspectorBackend.idl:
     18        Add ability to remove the profiles from the backend when they are
     19        deleted or cleared in the frontend.
     20        * inspector/InspectorBackend.cpp:
     21        (WebCore::InspectorBackend::removeProfile):
     22        (WebCore::InspectorBackend::clearProfiles):
     23        * inspector/InspectorBackend.h:
     24        * inspector/InspectorController.cpp:
     25        (WebCore::InspectorController::removeProfile):
     26        (WebCore::InspectorController::clearProfiles):
     27        * inspector/InspectorController.h:
     28
     29        * inspector/front-end/AuditsPanel.js:
     30        (WebInspector.AuditsPanel):
     31        Use the 'clear-status-bar-item' class.
     32        * inspector/front-end/ChangesView.js:
     33        (WebInspector.ChangesView):
     34        * inspector/front-end/TimelinePanel.js:
     35        (WebInspector.TimelinePanel.prototype._createStatusbarButtons):
     36        * inspector/front-end/audits.css:
     37        * inspector/front-end/inspector.css:
     38        (.clear-status-bar-item .glyph):
     39        * inspector/front-end/inspector.html:
     40
     41        * inspector/front-end/ElementsTreeOutline.js:
     42        Replace the keyDown handler on the Outline with specific methods to
     43        handle delete and enter on the TreeElements.
     44        (WebInspector.ElementsTreeOutline):
     45        (WebInspector.ElementsTreeOutline.prototype.get editing):
     46        Return whether or not an element in the tree is currently being edited.
     47        (WebInspector.ElementsTreeElement.prototype.ondelete):
     48        (WebInspector.ElementsTreeElement.prototype.onenter):
     49
     50        * inspector/front-end/Panel.js:
     51        (WebInspector.Panel.prototype.createSidebar):
     52        Make the TreeOutline for a Panel's sidebar aware of its enclosing Panel.
     53
     54        * inspector/front-end/ProfilesPanel.js:
     55        (WebInspector.ProfilesPanel):
     56        Add the clear button.
     57        (WebInspector.ProfilesPanel.prototype.get statusBarItems):
     58        (WebInspector.ProfilesPanel.prototype._clearProfiles):
     59        Remove the profiles from the backend, the reset the frontend interface.
     60        (WebInspector.ProfilesPanel.prototype.removeProfileHeader):
     61        Remove the profile from both the frontend and the backend, and clear the
     62        view when the last profile is removed.
     63        (WebInspector.ProfilesPanel.prototype._updateInterface):
     64        Hide the clear button when profiling is disabled.
     65        (WebInspector.ProfileSidebarTreeElement.prototype.onselect):
     66        Replace access to global variable with reference to the Panel held by the
     67        TreeOutline.
     68        (WebInspector.ProfileSidebarTreeElement.prototype.ondelete):
     69        Remove the profile corresponding the tree element when the user deletes
     70        that tree element.
     71
     72        * inspector/front-end/treeoutline.js:
     73        (TreeOutline.prototype._treeKeyDown):
     74        Allow the selected tree element to handle the user pressing a delete
     75        key or enter key.
     76
    1772010-05-29  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
    278
  • trunk/WebCore/inspector/InspectorBackend.cpp

    r56683 r60414  
    255255        m_inspectorController->getProfile(callId, uid);
    256256}
     257
     258void InspectorBackend::removeProfile(unsigned uid)
     259{
     260    if (m_inspectorController)
     261        m_inspectorController->removeProfile(uid);
     262}
     263
     264void InspectorBackend::clearProfiles()
     265{
     266    if (m_inspectorController)
     267        m_inspectorController->clearProfiles();
     268}
    257269#endif
    258270
  • trunk/WebCore/inspector/InspectorBackend.h

    r56683 r60414  
    9999    void getProfileHeaders(long callId);
    100100    void getProfile(long callId, unsigned uid);
     101
     102    void removeProfile(unsigned uid);
     103    void clearProfiles();
    101104#endif
    102105
  • trunk/WebCore/inspector/InspectorBackend.idl

    r56683 r60414  
    7474        void getProfileHeaders(in long callId);
    7575        void getProfile(in long callId, in unsigned long uid);
     76
     77        void removeProfile(in unsigned long uid);
     78        void clearProfiles();
    7679#endif
    7780        void setInjectedScriptSource(in DOMString scriptSource);
  • trunk/WebCore/inspector/InspectorController.cpp

    r60354 r60414  
    13891389}
    13901390
     1391void InspectorController::removeProfile(unsigned uid)
     1392{
     1393    if (!enabled())
     1394        return;
     1395
     1396    if (m_profiles.contains(uid))
     1397        m_profiles.remove(uid);
     1398}
     1399
     1400void InspectorController::clearProfiles()
     1401{
     1402    if (!enabled())
     1403        return;
     1404
     1405    m_profiles.clear();
     1406    m_currentUserInitiatedProfileNumber = 1;
     1407    m_nextUserInitiatedProfileNumber = 1;
     1408}
     1409
    13911410void InspectorController::getProfileHeaders(long callId)
    13921411{
  • trunk/WebCore/inspector/InspectorController.h

    r60234 r60414  
    223223    void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
    224224    void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
     225    void removeProfile(unsigned);
     226    void clearProfiles();
    225227
    226228    bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; }
  • trunk/WebCore/inspector/front-end/AuditsPanel.js

    r56732 r60414  
    5050    this.element.addStyleClass("audits");
    5151
    52     this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear audit results."), "clear-audit-results-status-bar-item");
     52    this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear audit results."), "clear-status-bar-item");
    5353    this.clearResultsButton.addEventListener("click", this._clearButtonClicked.bind(this), false);
    5454
  • trunk/WebCore/inspector/front-end/ChangesView.js

    r46732 r60414  
    3838    this.clearButton.id = "clear-changes-status-bar-item";
    3939    this.clearButton.title = WebInspector.UIString("Clear changes log.");
    40     this.clearButton.className = "status-bar-item";
     40    this.clearButton.className = "status-bar-item clear-status-bar-item";
    4141    this.clearButton.addEventListener("click", this._clearButtonClicked.bind(this), false);
    4242
  • trunk/WebCore/inspector/front-end/ElementsTreeOutline.js

    r59468 r60414  
    4444
    4545    this.element.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), true);
    46     this.element.addEventListener("keydown", this._keyDown.bind(this), true);
    4746}
    4847
     
    116115            }
    117116        }
     117    },
     118
     119    get editing()
     120    {
     121        return this._editing;
    118122    },
    119123
     
    225229
    226230        return element;
    227     },
    228 
    229     _keyDown: function(event)
    230     {
    231         if (event.target !== this.treeOutline.element)
    232             return;
    233 
    234         var selectedElement = this.selectedTreeElement;
    235         if (!selectedElement)
    236             return;
    237 
    238         if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code ||
    239                 event.keyCode === WebInspector.KeyboardShortcut.Keys.Delete.code) {
    240             var startTagTreeElement = this.findTreeElement(selectedElement.representedObject);
    241             if (selectedElement !== startTagTreeElement)
    242                 selectedElement = startTagTreeElement;
    243             selectedElement.remove();
    244             event.preventDefault();
    245             event.stopPropagation();
    246             return;
    247         }
    248 
    249         // On Enter or Return start editing the first attribute
    250         // or create a new attribute on the selected element.
    251         if (isEnterKey(event)) {
    252             if (this._editing)
    253                 return;
    254 
    255             selectedElement._startEditing();
    256 
    257             // prevent a newline from being immediately inserted
    258             event.preventDefault();
    259             event.stopPropagation();
    260             return;
    261         }
    262231    },
    263232
     
    685654        this.updateSelection();
    686655        this.treeOutline.suppressRevealAndSelect = false;
     656    },
     657
     658    ondelete: function()
     659    {
     660        var startTagTreeElement = this.treeOutline.findTreeElement(this.representedObject);
     661        startTagTreeElement ? startTagTreeElement.remove() : this.remove();
     662        return true;
     663    },
     664
     665    onenter: function()
     666    {
     667        // On Enter or Return start editing the first attribute
     668        // or create a new attribute on the selected element.
     669        if (this.treeOutline.editing)
     670            return false;
     671
     672        this._startEditing();
     673
     674        // prevent a newline from being immediately inserted
     675        return true;
    687676    },
    688677
  • trunk/WebCore/inspector/front-end/Panel.js

    r60141 r60414  
    317317
    318318        this.sidebarTree = new TreeOutline(this.sidebarTreeElement);
     319        this.sidebarTree.panel = this;
    319320    },
    320321
  • trunk/WebCore/inspector/front-end/ProfilesPanel.js

    r58745 r60414  
    114114    this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind(this), false);
    115115
     116    this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear CPU profiles."), "clear-status-bar-item");
     117    this.clearResultsButton.addEventListener("click", this._clearProfiles.bind(this), false);
     118
    116119    this.profileViewStatusBarItemsContainer = document.createElement("div");
    117120    this.profileViewStatusBarItemsContainer.id = "profile-view-status-bar-items";
     
    152155            }
    153156        }
    154         items.push(this.profileViewStatusBarItemsContainer);
     157        items.push(this.clearResultsButton.element, this.profileViewStatusBarItemsContainer);
    155158        return items;
    156159    },
     
    215218        this._updateInterface();
    216219        this.welcomeView.show();
     220    },
     221
     222    _clearProfiles: function()
     223    {
     224        InspectorBackend.clearProfiles();
     225        this.reset();
    217226    },
    218227
     
    338347
    339348        sidebarParent.removeChild(profile._profilesTreeElement);
     349
     350        if (!profile.isTemporary)
     351            InspectorBackend.removeProfile(profile.uid);
     352
     353        // No other item will be selected if there aren't any other profiles, so
     354        // make sure that view gets cleared when the last profile is removed.
     355        if (!this._profiles.length)
     356            this.closeVisibleView();
    340357    },
    341358
     
    467484                this._profileTypeButtonsByIdMap[typeId].removeStyleClass("hidden");
    468485            this.profileViewStatusBarItemsContainer.removeStyleClass("hidden");
     486            this.clearResultsButton.element.removeStyleClass("hidden");
    469487            this.panelEnablerView.visible = false;
    470488        } else {
     
    474492                this._profileTypeButtonsByIdMap[typeId].addStyleClass("hidden");
    475493            this.profileViewStatusBarItemsContainer.addStyleClass("hidden");
     494            this.clearResultsButton.element.addStyleClass("hidden");
    476495            this.panelEnablerView.visible = true;
    477496        }
     
    541560    onselect: function()
    542561    {
    543         WebInspector.panels.profiles.showProfile(this.profile);
     562        this.treeOutline.panel.showProfile(this.profile);
     563    },
     564
     565    ondelete: function()
     566    {
     567        this.treeOutline.panel.removeProfileHeader(this.profile);
     568        return true;
    544569    },
    545570
  • trunk/WebCore/inspector/front-end/TimelinePanel.js

    r60412 r60414  
    205205        this.toggleTimelineButton.addEventListener("click", this._toggleTimelineButtonClicked.bind(this), false);
    206206
    207         this.clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "timeline-clear-status-bar-item");
     207        this.clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear"), "clear-status-bar-item");
    208208        this.clearButton.addEventListener("click", this._clearPanel.bind(this), false);
    209209
  • trunk/WebCore/inspector/front-end/audits.css

    r57127 r60414  
    4747}
    4848
    49 button.clear-audit-results-status-bar-item .glyph {
    50     -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
    51 }
    52 
    5349.audit-launcher-view {
    5450    z-index: 1000;
  • trunk/WebCore/inspector/front-end/inspector.css

    r60141 r60414  
    421421}
    422422
    423 #clear-console-status-bar-item .glyph {
     423.clear-status-bar-item .glyph {
    424424    -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
    425425}
     
    427427#changes-status-bar-item .glyph {
    428428    -webkit-mask-image: url(Images/consoleButtonGlyph.png); /* TODO: Needs Image for Changes Toggle Button */
    429 }
    430 
    431 #clear-changes-status-bar-item .glyph {
    432     -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
    433429}
    434430
     
    34323428}
    34333429
    3434 .timeline-clear-status-bar-item .glyph {
    3435     -webkit-mask-image: url(Images/clearConsoleButtonGlyph.png);
    3436 }
    3437 
    34383430.timeline-category-statusbar-item {
    34393431    height: 24px;
  • trunk/WebCore/inspector/front-end/inspector.html

    r60141 r60414  
    142142    <div id="drawer">
    143143        <div id="console-view"><div id="console-messages" class="monospace"><div id="console-prompt" spellcheck="false"><br></div></div></div>
    144         <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>
     144        <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>
    145145    </div>
    146146</body>
  • trunk/WebCore/inspector/front-end/treeoutline.js

    r59150 r60414  
    390390            }
    391391        }
     392    } else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Backspace.code || event.keyCode === WebInspector.KeyboardShortcut.Keys.Delete.code) {
     393        if (this.selectedTreeElement.ondelete)
     394            handled = this.selectedTreeElement.ondelete();
     395    } else if (isEnterKey(event)) {
     396        if (this.selectedTreeElement.onenter)
     397            handled = this.selectedTreeElement.onenter();
    392398    }
    393399
  • trunk/WebKit/chromium/ChangeLog

    r60411 r60414  
     12010-05-30  Jessie Berlin  <jberlin@webkit.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=39224
     6        Bug 39224 - Web Inspector: There should be a way to clean up profiles
     7
     8        * src/js/InspectorControllerImpl.js:
     9        (devtools.InspectorBackendImpl):
     10
    1112010-05-29  Vangelis Kokkevis  <vangelis@chromium.org>
    212
  • trunk/WebKit/chromium/src/js/InspectorControllerImpl.js

    r60154 r60414  
    5757    this.installInspectorControllerDelegate_("getProfile");
    5858    this.installInspectorControllerDelegate_("getProfileHeaders");
     59    this.installInspectorControllerDelegate_("removeProfile");
     60    this.installInspectorControllerDelegate_("clearProfiles");
    5961    this.installInspectorControllerDelegate_("getResourceContent");
    6062    this.installInspectorControllerDelegate_("highlightDOMNode");
Note: See TracChangeset for help on using the changeset viewer.